ranuts 0.2.0-alpha.1 → 0.4.0-alpha.1
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/CLAUDE.md +126 -24
- package/README.md +7 -5
- package/README.zh-CN.md +7 -5
- package/dist/chain-CTywmh_H.js +1 -0
- package/dist/{color-CRdlaDqQ.js → color-Dohr9BXX.js} +1 -1
- package/dist/enums-BAgbyGdH.js +1 -0
- package/dist/i18n-Cf5TtRb4.js +1 -0
- package/dist/index.d.ts +1 -5
- package/dist/index.js +1 -1
- package/dist/src/node/appendFile.d.ts +3 -3
- package/dist/src/node/fileInfo.d.ts +2 -2
- package/dist/src/node/index.js +1 -1
- package/dist/src/node/paresUrl.d.ts +1 -1
- package/dist/src/node/readFile.d.ts +3 -3
- package/dist/src/node/traverse.d.ts +2 -2
- package/dist/src/node/watchFile.d.ts +3 -3
- package/dist/src/node/writeFile.d.ts +3 -3
- package/dist/src/sw/index.d.ts +109 -0
- package/dist/src/sw/index.js +1 -0
- package/dist/src/utils/async.d.ts +81 -0
- package/dist/src/utils/audioRecorder.d.ts +1 -1
- package/dist/src/utils/behavior.d.ts +12 -3
- package/dist/src/utils/bom.d.ts +68 -178
- package/dist/src/utils/bridge.d.ts +153 -0
- package/dist/src/utils/canvas.d.ts +54 -0
- package/dist/src/utils/chain.d.ts +80 -0
- package/dist/src/utils/color.d.ts +76 -4
- package/dist/src/utils/compose.d.ts +1 -1
- package/dist/src/utils/console.d.ts +19 -1
- package/dist/src/utils/debounce.d.ts +27 -5
- package/dist/src/utils/device.d.ts +31 -3
- package/dist/src/utils/dom.d.ts +5 -84
- package/dist/src/utils/error.d.ts +18 -1
- package/dist/src/utils/event.d.ts +61 -0
- package/dist/src/utils/file.d.ts +35 -0
- package/dist/src/utils/i18n/index.js +1 -0
- package/dist/src/utils/i18n.d.ts +69 -0
- package/dist/src/utils/idb.d.ts +218 -0
- package/dist/src/utils/img.d.ts +60 -4
- package/dist/src/utils/index.d.ts +50 -16
- package/dist/src/utils/index.js +1 -1
- package/dist/src/utils/lang.d.ts +69 -0
- package/dist/src/utils/localePath.d.ts +62 -0
- package/dist/src/utils/memoize.d.ts +53 -5
- package/dist/src/utils/monitor.d.ts +55 -26
- package/dist/src/utils/number.d.ts +46 -9
- package/dist/src/utils/obj.d.ts +56 -31
- package/dist/src/utils/paginate.d.ts +73 -0
- package/dist/src/utils/prefetch.d.ts +81 -0
- package/dist/src/utils/queue.d.ts +53 -23
- package/dist/src/utils/report.d.ts +51 -3
- package/dist/src/utils/request.d.ts +26 -7
- package/dist/src/utils/script.d.ts +26 -4
- package/dist/src/utils/segment.d.ts +62 -0
- package/dist/src/utils/signal.d.ts +35 -3
- package/dist/src/utils/storage.d.ts +57 -0
- package/dist/src/utils/str.d.ts +112 -88
- package/dist/src/utils/style.d.ts +31 -0
- package/dist/src/utils/subscribe.d.ts +5 -5
- package/dist/src/utils/throttle.d.ts +26 -13
- package/dist/src/utils/time.d.ts +38 -6
- package/dist/src/utils/tween.d.ts +40 -0
- package/dist/src/utils/visual/application.d.ts +4 -4
- package/dist/src/utils/visual/enums.d.ts +4 -4
- package/dist/src/utils/visual/graphics/graphics.d.ts +25 -25
- package/dist/src/utils/visual/graphics/graphicsData.d.ts +1 -1
- package/dist/src/utils/visual/graphics/graphicsGeometry.d.ts +6 -6
- package/dist/src/utils/visual/index.js +1 -1
- package/dist/src/utils/visual/math/matrix.d.ts +8 -8
- package/dist/src/utils/visual/math/transform.d.ts +1 -1
- package/dist/src/utils/visual/render/batchRenderer.d.ts +20 -18
- package/dist/src/utils/visual/render/utils/batch/index.d.ts +13 -13
- package/dist/src/utils/visual/render/utils/float.d.ts +13 -13
- package/dist/src/utils/visual/render/utils/verticy.d.ts +3 -3
- package/dist/src/utils/visual/render/utils/webgl/initShader.d.ts +3 -2
- package/dist/src/utils/visual/render/utils/webgpu/shaders.d.ts +2 -2
- package/dist/src/utils/visual/render/webGPURenderer.d.ts +8 -8
- package/dist/src/utils/visual/vertex/container.d.ts +17 -16
- package/dist/src/utils/worker.d.ts +125 -0
- package/dist/src/utils/zip.d.ts +162 -0
- package/dist/src/vnode/index.d.ts +1 -1
- package/dist/src/vnode/index.js +1 -1
- package/dist/src/vnode/is.d.ts +4 -0
- package/dist/test/canvas.test.d.ts +1 -0
- package/dist/test/color.test.d.ts +1 -0
- package/dist/test/sw.test.d.ts +1 -0
- package/dist/test/tween.test.d.ts +1 -0
- package/dist/test/utils/async.test.d.ts +1 -0
- package/dist/test/utils/file-read.test.d.ts +1 -0
- package/dist/test/utils/format.test.d.ts +1 -0
- package/dist/test/utils/idb-collection.test.d.ts +1 -0
- package/dist/test/utils/idb.test.d.ts +1 -0
- package/dist/test/utils/instrumentation.test.d.ts +1 -0
- package/dist/test/utils/lang.test.d.ts +1 -0
- package/dist/test/utils/locale-path.test.d.ts +1 -0
- package/dist/test/utils/media-query.test.d.ts +1 -0
- package/dist/test/utils/number-parse.test.d.ts +1 -0
- package/dist/test/utils/paginate.test.d.ts +1 -0
- package/dist/test/utils/prefetch.test.d.ts +1 -0
- package/dist/test/utils/query-storage.test.d.ts +1 -0
- package/dist/test/utils/queue.test.d.ts +1 -0
- package/dist/test/utils/report-config.test.d.ts +1 -0
- package/dist/test/utils/report-image.test.d.ts +1 -0
- package/dist/test/utils/segment.test.d.ts +1 -0
- package/dist/test/utils/signal-once.test.d.ts +1 -0
- package/dist/test/utils/single-flight.test.d.ts +1 -0
- package/dist/test/utils/timing.test.d.ts +1 -0
- package/dist/test/utils/worker-client.test.d.ts +1 -0
- package/dist/test/utils/worker-serve.test.d.ts +1 -0
- package/dist/test/utils/zip.test.d.ts +1 -0
- package/dist/umd/index.umd.cjs +1 -1
- package/dist/umd/node/node.umd.cjs +1 -1
- package/dist/umd/utils/utils.umd.cjs +1 -1
- package/dist/utils-8TVtLBjA.js +1 -0
- package/docs/API.md +341 -147
- package/package.json +13 -6
- package/dist/src/vnode/chainDom.d.ts +0 -47
- package/dist/subscribe-CINWsor3.js +0 -1
- package/dist/utils-_OxsVZmz.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ranuts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-alpha.1",
|
|
4
4
|
"description": "Tree-shakeable TypeScript utility library: DOM/BOM helpers, string/object/number/color utils, debounce/throttle/compose, a 2D rendering engine and a virtual DOM.",
|
|
5
5
|
"main": "dist/index.umd.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -29,6 +29,14 @@
|
|
|
29
29
|
"types": "./dist/src/utils/visual/index.d.ts",
|
|
30
30
|
"import": "./dist/src/utils/visual/index.js"
|
|
31
31
|
},
|
|
32
|
+
"./sw": {
|
|
33
|
+
"types": "./dist/src/sw/index.d.ts",
|
|
34
|
+
"import": "./dist/src/sw/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./i18n": {
|
|
37
|
+
"types": "./dist/src/utils/i18n.d.ts",
|
|
38
|
+
"import": "./dist/src/utils/i18n/index.js"
|
|
39
|
+
},
|
|
32
40
|
"./vnode": {
|
|
33
41
|
"types": "./dist/src/vnode/index.d.ts",
|
|
34
42
|
"import": "./dist/src/vnode/index.js"
|
|
@@ -68,20 +76,19 @@
|
|
|
68
76
|
"author": "",
|
|
69
77
|
"license": "MIT",
|
|
70
78
|
"devDependencies": {
|
|
71
|
-
"@babel/parser": "^8.0.4",
|
|
72
|
-
"@types/earcut": "^3.0.0",
|
|
73
79
|
"@types/node": "^26.1.1",
|
|
74
80
|
"@vitest/coverage-v8": "^4.1.10",
|
|
75
81
|
"@webgpu/types": "^0.1.71",
|
|
82
|
+
"jsdom": "^29.1.1",
|
|
83
|
+
"terser": "^5.49.0",
|
|
76
84
|
"tsx": "^4.23.0",
|
|
77
|
-
"typescript": "^
|
|
85
|
+
"typescript": "^7.0.2",
|
|
78
86
|
"vite": "^8.1.4",
|
|
79
87
|
"vitest": "^4.1.10"
|
|
80
88
|
},
|
|
81
89
|
"dependencies": {
|
|
82
90
|
"earcut": "^3.2.3",
|
|
83
|
-
"jschardet": "^3.1.4"
|
|
84
|
-
"magic-string": "^0.30.21"
|
|
91
|
+
"jschardet": "^3.1.4"
|
|
85
92
|
},
|
|
86
93
|
"scripts": {
|
|
87
94
|
"build": "sh ./bin/build.sh",
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description: 链式调用的 dom 操作
|
|
3
|
-
* @return {HTMLElement}
|
|
4
|
-
*/
|
|
5
|
-
export declare class Chain {
|
|
6
|
-
element: HTMLElement;
|
|
7
|
-
constructor(tagName: string, options?: ElementCreationOptions);
|
|
8
|
-
/**
|
|
9
|
-
* @description: 创建元素
|
|
10
|
-
* @param {string} tagName
|
|
11
|
-
* @param {ElementCreationOptions} options
|
|
12
|
-
* @return {Chain}
|
|
13
|
-
*/
|
|
14
|
-
create: (tagName: string, options?: ElementCreationOptions) => HTMLElement;
|
|
15
|
-
/**
|
|
16
|
-
* @description: 设置当前元素的属性
|
|
17
|
-
* @param {string} name
|
|
18
|
-
* @param {string} value
|
|
19
|
-
* @return {Chain}
|
|
20
|
-
*/
|
|
21
|
-
setAttribute: (name: string, value: string) => Chain;
|
|
22
|
-
/**
|
|
23
|
-
* @description: 移除当前元素的属性
|
|
24
|
-
* @param {string} name
|
|
25
|
-
* @return {Chain}
|
|
26
|
-
*/
|
|
27
|
-
removeAttribute: (name: string) => Chain;
|
|
28
|
-
/**
|
|
29
|
-
* @description: 当前元素添加子元素
|
|
30
|
-
* @param {HTMLElement} child
|
|
31
|
-
* @return {ChainElement}
|
|
32
|
-
*/
|
|
33
|
-
append: (child: HTMLElement) => Chain;
|
|
34
|
-
/**
|
|
35
|
-
* @description: 当前元素移除子元素
|
|
36
|
-
* @param {HTMLElement} child
|
|
37
|
-
* @return {Chain}
|
|
38
|
-
*/
|
|
39
|
-
remove: (child: HTMLElement) => Chain;
|
|
40
|
-
/**
|
|
41
|
-
* @description: 给当前元素设置文本内容
|
|
42
|
-
* @param {string} text
|
|
43
|
-
* @return {Chain}
|
|
44
|
-
*/
|
|
45
|
-
setTextContent: (text: string) => Chain;
|
|
46
|
-
}
|
|
47
|
-
export declare const create: (tagName: string, options?: ElementCreationOptions) => Chain;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var t=class{_events=/* @__PURE__ */new Map;tap=(t,e)=>{this._events.get(t)&&t!==Symbol.for("NEW_LISTENER")&&this.call(Symbol.for("NEW_LISTENER"),t);const a=this._events.get(t)||/* @__PURE__ */new Set;return"function"==typeof e?a.add({name:t,callback:e}):a.add(e),this._events.set(t,a),this};call=(t,...e)=>((this._events.get(t)||/* @__PURE__ */new Set).forEach(t=>{const{callback:a}=t;a(...e)}),this);callSync=async(t,...e)=>{const a=this._events.get(t)||/* @__PURE__ */new Set;for(const n of a){const{callback:t}=n;await t(...e)}return this};once=(t,e)=>{let a;if("function"==typeof e)a={name:t,callback:(...n)=>{e(...n),this.off(t,a)},initialCallback:e};else{const{callback:n}=e;a={name:t,callback:(...e)=>{n(...e),this.off(t,a)},initialCallback:n}}return this.tap(t,a),this};off=(t,e)=>{const a=[...this._events.get(t)||/* @__PURE__ */new Set].filter(t=>{if("function"==typeof e)return t.callback!==e&&t.initialCallback!==e;{const{callback:a}=e;return t.callback!==a&&t.initialCallback!==a}});return this._events.set(t,new Set(a)),this}};export{t};
|
package/dist/utils-_OxsVZmz.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./subscribe-CINWsor3.js";import{A as t,F as n,M as r,k as i}from"./color-CRdlaDqQ.js";var a=(e="")=>{if(0===e.length)return 0;if(e.endsWith("%")){const t=Number(e.replace("%",""));return t>1?t/100:t}return Number(e)},o=(e,t=0,n=1)=>Math.min(n,Math.max(t,e)),s=class e{getDecimalLength=e=>{const[t,n]=e.toString().split(".");return n?n.length:0};amend=(e,t=15)=>parseFloat(Number(e).toPrecision(t));power=(e,t)=>Math.pow(10,Math.max(this.getDecimalLength(e),this.getDecimalLength(t)));static handleMethod=(t,n)=>{const{power:r,amend:i}=new e,a=r(t,n),o=i(t*a),s=i(n*a);return e=>{switch(e){case"+":return(o+s)/a;case"-":return(o-s)/a;case"*":return o*s/(a*a);case"/":return o/s}}};static add=(e,t)=>this.handleMethod(e,t)("+");static divide=(e,t)=>this.handleMethod(e,t)("/");static multiply=(e,t)=>this.handleMethod(e,t)("*");static subtract=(e,t)=>this.handleMethod(e,t)("-")};function c(e,t,n){function r(e){const[t,n]=e.toString().split(".");return n?n.length:0}const i=(e,t=15)=>parseFloat(Number(e).toPrecision(t)),a=Math.pow(10,Math.max(r(e),r(n)));let o=0;switch(e=i(e*a),n=i(n*a),t){case"+":o=(e+n)/a;break;case"-":o=(e-n)/a;break;case"*":o=e*n/(a*a);break;case"/":o=e/n}return o=i(o),{result:o,next:(e,t)=>c(o,e,t)}}var d=(e,t="zh-CN",n=2,r=2)=>{let i=["","K","M","B","T"],a=3;if("zh-CN"===t&&(i=[""," 万"," 亿"," 万亿"],a=4),"zh-HK"===t&&(i=[""," 萬"," 億"," 萬億"],a=4),!/^[+-]?\d+(?:\.\d+)?$/.test(e))return"--";const o=parseInt(e).toString().length,c=Math.min(Math.floor((o-1)/a),i.length-1),d=s.divide(Number(e),10**(c*a))?.toFixed(n);return Number(d).toFixed(r)+i[c]},u=(e,t)=>n(e).startsWith("+")||n(e).startsWith("-")?n(e):t?Number(t||0)>0?`+${n(e)}`:n(e):Number(e||0)>0?`+${n(e)}`:n(e),h=e=>"function"==typeof e,l=()=>{};function p(e){return e<10?`0${e}`:e}function m(e){let t=/* @__PURE__ */new Date;return e&&(t=new Date(e)),t.format=(e="YYYY-MM-DD HH:mm:ss")=>{const n=t.getFullYear(),r=p(t.getMonth()+1),i=p(t.getDate()),a=p(t.getHours()),o=p(t.getMinutes()),s=p(t.getSeconds());return e.replace(/Y+/gi,`${n}`).replace(/M+/g,`${r}`).replace(/D+/gi,`${i}`).replace(/H+/gi,`${a}`).replace(/m+/g,`${o}`).replace(/S+/gi,`${s}`)},t}var f=e=>{if(0===e)return"00:00";if(!e)return"";const t=Math.trunc(e/3600),n=Math.trunc(e%3600/60),r=p(Math.trunc(e-3600*t-60*n));return 0===t?`${p(n)}:${r}`:`${p(t)}:${p(n)}:${r}`},g=()=>{if("undefined"!=typeof document)return performance.now();if("undefined"!=typeof process){const[e,t]=process.hrtime();return 1e3*e+t/1e6}return Date.now()},w=/* @__PURE__ */function(e){return e.IPAD="ipad",e.ANDROID="android",e.IPhONE="iphone",e.PC="pc",e}({}),y=()=>{if("undefined"!=typeof window){const e=navigator.userAgent.toLowerCase();return/ipad|ipod/.test(e)?"ipad":/android/.test(e)?"android":/iphone/.test(e)?"iphone":"pc"}return"pc"},C="undefined"!=typeof window,b=()=>!!C&&window.navigator.userAgent.toLowerCase().includes("micromessenger"),S=()=>{if(!C)return!1;const e=window.navigator.userAgent;return!!/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(e)},A=()=>{if(!C)return!1;const e=/iphone/i.test(window.navigator.userAgent),t=window.devicePixelRatio&&2===window.devicePixelRatio,n=window.devicePixelRatio&&3===window.devicePixelRatio,r=360===window.screen.width&&780===window.screen.height,i=375===window.screen.width&&812===window.screen.height,a=390===window.screen.width&&844===window.screen.height,o=414===window.screen.width&&896===window.screen.height,s=428===window.screen.width&&926===window.screen.height;switch(!0){case e&&n&&r:case e&&n&&i:case e&&n&&a:case e&&t&&o:case e&&n&&o:case e&&n&&s:return!0;default:return!1}},v=(e=l)=>{const t=()=>{e(),C&&window.removeEventListener("popstate",t)};C&&window.history.pushState(null,"",window.location.href),setTimeout(()=>{C&&window.addEventListener("popstate",t)},500)},O=e=>{const t=document.cookie.split("; ");for(let n=0;n<t.length;n++){const r=t[n].split("=");if(r[0]===e)return decodeURIComponent(r[1])}return""},E=(e,t)=>new Promise(function(n,r){const i=new XMLHttpRequest;i.open(t.method||"GET",e,!0),i.responseType=t.responseType||"arraybuffer",i.onload=function(){200===i.status?n({success:!0,data:i.response,message:""}):r({success:!1,data:i.status,message:`The request status is${i.status}`})},i.onerror=function(e){r({success:!1,data:e,message:""})},i.onprogress=e=>{t.onProgress&&t.onProgress(e)},i.withCredentials=t.withCredentials||!1,t.headers&&Object.keys(t.headers).forEach(function(e){t.headers?.[e]&&i.setRequestHeader(e,t.headers[e])}),i.send(t.body)}),U=e=>{const t=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||1;return(C&&window.devicePixelRatio||1)/t},B=async e=>{if("string"==typeof e)return e;if(e instanceof Blob)return URL.createObjectURL(e);if(e instanceof ArrayBuffer)return URL.createObjectURL(new Blob([e]));if(e instanceof Response){const t=await e.blob();return URL.createObjectURL(t)}return e},M=(e=10)=>{const t=[];let n,r=0;return new Promise(i=>{const a=()=>{const o=g(),s=o-r;0!==r&&t.push(s),r=o,t.length>e&&(i(1/(t.reduce((e,t)=>e+t)/e)),cancelAnimationFrame(n)),n=requestAnimationFrame(a)};t.length<=e&&(n=requestAnimationFrame(a))})},T=e=>{if("undefined"!=typeof window){let n="";if(e&&t(e))n=/trunk|neibu|release/.test(e)?`.${e}`:/test/.test(e)?e:(/prod/.test(e),"");else{const e=/\w(\.trunk|\.neibu|\.release|test)\./.exec(window.location.hostname);e&&(n=e[1])}return`//log.${n}`}},k=e=>{if("undefined"!=typeof window){const t={},n=e||window.location.href;return n.split("?")[1]&&n.split("?")[1].split("&").forEach(e=>{const[n,r]=e.split("=");n&&r&&(t[n]=decodeURIComponent(r))}),t}return{}},L=e=>{if("undefined"!=typeof window){const t={},n=e||window.location.href;return n.split("?")[1]&&n.split("?")[1].split("&").forEach(e=>{const[n,r]=e.split("=");n&&r&&(t[n]=decodeURIComponent(r))}),t}return{}};function F(e,t={}){let n=e;0===n.indexOf("//")&&(n=n.replace("//","https://"));const r=new URL(n);return t&&Object.keys(t).forEach(e=>{t[e]&&r.searchParams.set(e,t[e])}),r.href}var R=e=>{const t=document.createElement("img");t.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",t.width=0,t.height=0,t.style.opacity="0",e.dataTransfer&&e.dataTransfer.setDragImage(t,0,0)};function H(e){if("undefined"!=typeof window){const t=new RegExp(`(^| )${e}(?:=([^;]*))?(;|$)`).exec(document.cookie);if(t&&t[2])return t[2]}return""}var D=()=>"undefined"!=typeof window?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0},P=()=>{if("undefined"!=typeof window)return window.navigator.connection},x=/(?:[^\x21\x25\x26-\x3B\x3D\x3F-\x5B\x5D\x5F\x7E]|%(?:[^\da-f]|[\da-f][^\da-f]|$))+/gi,I=/(^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/g;function z(e){return String(e).replace(I,"$1�$2").replace(x,encodeURI)}var j=e=>new Promise((t,n)=>{const r=new Image,i=/* @__PURE__ */(new Date).getTime();r.src=e||`https://github.com/favicon.ico?d=${i}`,r.onload=()=>{t(/* @__PURE__ */(new Date).getTime()-i)},r.onerror=e=>{n(e)}}),N=(e,...t)=>n=>new Promise((r,i)=>{setTimeout(async()=>{try{r(await e(...t))}catch(n){i(n)}},n)}),K=async e=>{const{url:t,duration:n=3e3,count:r=5}=e;let i=0,a=0;const o=[];for(let s=0;s<r;s++){const e=await N(j,t)(n);o.push(e)}return i=Math.max(...o)-Math.min(...o),a=o.reduce((e,t)=>e+t)/o.length,{ping:a,jitter:i}},_=()=>{if("undefined"!=typeof navigator)return navigator.vendor&&navigator.vendor.indexOf("Apple")>-1&&navigator.userAgent&&!navigator.userAgent.includes("CriOS")&&!navigator.userAgent.includes("FxiOS")},q=12e4,V="__ranuts_bridge__",W="default",$=new class{bridges=/* @__PURE__ */new Set;attachedWindow=null;handleMessage=e=>{for(const t of Array.from(this.bridges))t.receive(e)};add(e){this.bridges.add(e),"undefined"!=typeof window&&this.attachedWindow!==window&&(window.addEventListener("message",this.handleMessage),this.attachedWindow=window)}remove(e){this.bridges.delete(e),0===this.bridges.size&&this.attachedWindow&&(this.attachedWindow.removeEventListener("message",this.handleMessage),this.attachedWindow=null)}},Y=class{targetWindow;targetOrigin;messageHandlers;pendingRequests;channel;senderId;available;constructor(e,t="*",n=W){this.targetOrigin=t,this.channel=n,this.senderId=i(12),this.messageHandlers=/* @__PURE__ */new Map,this.pendingRequests=/* @__PURE__ */new Map,this.available="undefined"!=typeof window,this.available?(this.targetWindow=e??window,$.add(this)):this.targetWindow=void 0}post(e,t){const n={...t,__bridge:V,channel:this.channel,senderId:this.senderId};e.postMessage(n,this.targetOrigin)}receive=e=>{if(!this.available)return;if("*"!==this.targetOrigin&&e.origin!==this.targetOrigin)return;if(e.source&&e.source!==this.targetWindow)return;const t=e.data;if(!t||"object"!=typeof t||"__ranuts_bridge__"!==t.__bridge)return;if((t.channel??"default")!==this.channel)return;const{type:n,payload:r,id:i,isResponse:a,isError:o,senderId:s}=t;if(a&&i){const e=this.pendingRequests.get(i);return void(e&&(o?e.reject(new Error("string"==typeof r?r:"Bridge request failed")):e.resolve(r),this.pendingRequests.delete(i)))}if(s&&s===this.senderId)return;if("string"!=typeof n||!this.messageHandlers.has(n))return;const c=this.messageHandlers.get(n);if(h(c)){const t=e.source??this.targetWindow;Promise.resolve(c(r)).then(e=>{i&&this.post(t,{type:n,payload:e,id:i,isResponse:!0})}).catch(e=>{i&&this.post(t,{type:n,payload:e instanceof Error?e.message:String(e),id:i,isResponse:!0,isError:!0})})}};on=(e,t)=>{this.messageHandlers.set(e,t)};off=e=>{this.messageHandlers.delete(e)};send=async(e,t)=>{if(!this.available)return Promise.reject(/* @__PURE__ */new Error("PostMessageBridge is unavailable outside a browser environment"));const n=i(10);return new Promise((r,i)=>{const a=setTimeout(()=>{this.pendingRequests.has(n)&&(this.pendingRequests.delete(n),i(/* @__PURE__ */new Error("Request timeout")))},q),o=e=>{clearTimeout(a),i(e)};this.pendingRequests.set(n,{resolve:e=>{clearTimeout(a),r(e)},reject:o});try{this.post(this.targetWindow,{type:e,payload:t,id:n})}catch(s){this.pendingRequests.delete(n),o(s instanceof Error?s:/* @__PURE__ */new Error("Failed to post message"))}})};broadcast=e=>{if(this.available)try{this.post(this.targetWindow,{type:e.type,payload:e.payload})}catch{}};destroy=()=>{$.remove(this),this.messageHandlers.clear(),this.pendingRequests.forEach(e=>{e.reject(/* @__PURE__ */new Error("Bridge destroyed"))}),this.pendingRequests.clear()}},X=class e{static instance;bridges=/* @__PURE__ */new Map;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}connectClient=({id:e,targetOrigin:t,targetWindow:n,channel:r})=>{const a=new Y(n,t,r);if(e||(e=i(10)),this.bridges.has(e))throw new Error(`Bridge ${e} already exists`);return this.bridges.set(e,a),{bridge:a,id:e}};getClient=e=>this.bridges.get(e);removeClient=e=>{const t=this.bridges.get(e);t&&(t.destroy(),this.bridges.delete(e))};removeAllClient=()=>{this.bridges.forEach(e=>{e.destroy()}),this.bridges.clear()};broadcast=e=>{this.bridges.forEach(t=>{t.broadcast(e)})};sendTo=(e,t,n)=>{const r=this.getClient(e);return r?r.send(t,n):Promise.reject(/* @__PURE__ */new Error(`Bridge ${e} not found`))}},G=X.getInstance(),J={connect:({id:e,targetWindow:t,targetOrigin:n,channel:r})=>G.connectClient({id:e,targetWindow:t,targetOrigin:n,channel:r}),remove:e=>{e&&G.removeClient(e)},removeAll:()=>{G.removeAllClient()},broadcast:e=>G.broadcast(e),call:({id:e,type:t,payload:n})=>G.sendTo(e,t,n),broadcastToAll:e=>{if("undefined"==typeof window)return;const t={__bridge:V,channel:W,type:e.type,payload:e.payload};return window.postMessage(t,"*")}},Q={init:e=>{const t=new Map(Object.entries(e).filter(e=>h(e[1]))),n=async e=>{const n=e.data;if(!n||"object"!=typeof n||"__ranuts_bridge__"!==n.__bridge)return;const{type:r,payload:i,id:a}=n,o=n.channel??"default";if("string"!=typeof r||!t.has(r))return;const s=t.get(r);if(!s)return;const c=t=>{a&&e.source?.postMessage({__bridge:V,channel:o,type:r,id:a,isResponse:!0,...t},{targetOrigin:e.origin})};try{c({payload:await s(i)})}catch(d){c({payload:d instanceof Error?d.message:String(d),isError:!0})}};window.removeEventListener("message",n),window.addEventListener("message",n);return{destroy:()=>{window.removeEventListener("message",n)}}}},Z="__ranuts_port_init__",ee=e=>{const t=/* @__PURE__ */new Map,n=/* @__PURE__ */new Map,r=r=>{const i=r.data;if(!i||"object"!=typeof i||"string"!=typeof i.type)return;const{type:a,payload:o,id:s,isResponse:c,isError:d}=i;if(c&&s){const e=n.get(s);return void(e&&(d?e.reject(new Error("string"==typeof o?o:"Bridge request failed")):e.resolve(o),n.delete(s)))}if(!t.has(a))return;const u=t.get(a);h(u)&&Promise.resolve(u(o)).then(t=>{s&&e.postMessage({type:a,payload:t,id:s,isResponse:!0})}).catch(t=>{s&&e.postMessage({type:a,payload:t instanceof Error?t.message:String(t),id:s,isResponse:!0,isError:!0})})};return e.addEventListener("message",r),e.start(),{on:(e,n)=>{t.set(e,n)},off:e=>{t.delete(e)},send:(t,r)=>{const a=i(10);return new Promise((i,o)=>{const s=setTimeout(()=>{n.has(a)&&(n.delete(a),o(/* @__PURE__ */new Error("Request timeout")))},q),c=e=>{clearTimeout(s),o(e)};n.set(a,{resolve:e=>{clearTimeout(s),i(e)},reject:c});try{e.postMessage({type:t,payload:r,id:a})}catch(d){n.delete(a),c(d instanceof Error?d:/* @__PURE__ */new Error("Failed to post message"))}})},broadcast:t=>{try{e.postMessage({type:t.type,payload:t.payload})}catch{}},destroy:()=>{e.removeEventListener("message",r),t.clear(),n.forEach(e=>e.reject(/* @__PURE__ */new Error("Bridge destroyed"))),n.clear(),e.close()}}},te=({targetWindow:e,targetOrigin:t="*",name:n="default"})=>{const r=new MessageChannel;return e.postMessage({[Z]:!0,name:n},t,[r.port2]),ee(r.port1)},ne=({targetOrigin:e="*",name:t="default"}={})=>"undefined"==typeof window?Promise.reject(/* @__PURE__ */new Error("acceptPortBridge is unavailable outside a browser environment")):new Promise(n=>{const r=i=>{if("*"!==e&&i.origin!==e)return;const a=i.data;if(!a||"object"!=typeof a||!0!==a[Z]||a.name!==t)return;const o=i.ports?.[0];o&&(window.removeEventListener("message",r),n(ee(o)))};window.addEventListener("message",r)}),re=e=>{let t,n=!1;return(...r)=>(n||(t="function"==typeof e?e(...r):e,n=!0,e=void 0),t)};function ie(e={}){if("object"!=typeof e)throw new TypeError("param must be object");return Object.entries(e).reduce((e,[t,n])=>(void 0===n||null==n||e.append(decodeURIComponent(t),decodeURIComponent(n)),e),new URLSearchParams).toString()}var ae=(e,t=()=>{})=>{let n="",r=0;let i=((e,t=()=>{})=>{let n="";if("[object String]"!==Object.prototype.toString.call(e))try{n=JSON.stringify(e)}catch(r){t(r)}else try{e="string"==typeof e?e.replace(/'/g,'"'):JSON.stringify(e),n=JSON.stringify(JSON.parse(e))}catch(r){t(r)}return n})(e,t);if(!i)return i;const a=[];let o=null,s=null,c=[];return i=i.replace(/([{}])/g,"\r\n$1\r\n"),i=i.replace(/([[\]])/g,"\r\n$1\r\n"),i=i.replace(/,/g,",\r\n"),i=i.replace(/\r\n\r\n/g,"\r\n"),i=i.replace(/\r\n,/g,","),c=i.split("\r\n"),c.forEach(function(e,t){const n=e.match(/"/g)&&e.match(/"/g)?.length||0;n%2&&!o&&(o=t),n%2&&o&&o!==t&&(s=t),o&&s&&(a.push({start:o,end:s}),o=null,s=null)}),a.reverse().forEach(function(e){const t=c.slice(e.start,e.end+1);c.splice(e.start,e.end+1-e.start,t.join(""))}),i=c.join("\r\n"),i=i.replace(/:\r\n\{/g,":{"),i=i.replace(/:\r\n\[/g,":["),c=i.split("\r\n"),c.forEach(function(e){let t=0,i=0,a="";for(e.endsWith("{")||e.endsWith("[")?i+=1:e.endsWith("}")||e.endsWith("]")||e.endsWith("},")||e.endsWith("],")?0!==r&&(r-=1):i=0,t=0;t<r;t++)a+=" ";n+=a+e+"\r\n",r+=i}),n.trim()},oe=(e,t)=>{const n={};return Object.keys(e).forEach(r=>{t.includes(r)||(n[r]=e[r])}),n},se=(e,t)=>{if(e&&t)for(const n in t)e[n]=t[n];return e};function ce(e,t,n,r){if(void 0!==e&&(t in e||r)){const r=n(e[t]);"function"==typeof r&&(e[t]=r)}}var de=(e,t)=>{const n=Object.getOwnPropertyDescriptors(t);for(const r of Object.keys(n)){const t=n[r];if(t.get){const n=t.get;Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:re(n)})}else{if("object"!=typeof t.value)throw new Error("Exposed values must be either a getter or an nested object");Object.defineProperty(e,r,{configurable:!1,enumerable:!0,writable:!1,value:de({},t.value)})}}return Object.freeze(e)},ue=(e,t)=>{"undefined"!=typeof window&&(window[e]=t),"undefined"!=typeof global&&(global[e]=t)};function he(e){return Object.prototype.toString.call(e)}function le(e,t,n=/* @__PURE__ */new Map){if(e===t)return!0;if(null==e||null==t)return e===t;if(e!=e&&t!=t)return!0;const r=typeof e;if(r!==typeof t)return!1;if("object"!==r)return e===t;const i=he(e);if(i!==he(t))return!1;if(n.has(e))return n.get(e)===t;if(n.set(e,t),"[object Array]"===i){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!le(e[r],t[r],n))return!1;return!0}if("[object Date]"===i)return+e===+t;if("[object RegExp]"===i)return e.toString()===t.toString();if("[object Map]"===i){if(e.size!==t.size)return!1;let r=!0;return e.forEach((e,i)=>{r&&(t.has(i)&&le(e,t.get(i),n)||(r=!1))}),r}if("[object Set]"===i){if(e.size!==t.size)return!1;const r=Array.from(e),i=Array.from(t);return r.every(e=>i.some(t=>le(e,t,n)))}const a=Object.keys(e),o=Object.keys(t);if(a.length!==o.length)return!1;for(const s of a)if(!Object.prototype.hasOwnProperty.call(t,s)||!le(e[s],t[s],n))return!1;return!0}var pe=(e,t=/* @__PURE__ */new WeakMap)=>{if(null===e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(Array.isArray(e)){const n=[];t.set(e,n);for(let r=0;r<e.length;r++)n[r]=pe(e[r],t);return n}if(e instanceof Map){const n=/* @__PURE__ */new Map;return t.set(e,n),e.forEach((e,r)=>{n.set("object"==typeof r&&null!==r?pe(r,t):r,pe(e,t))}),n}if(e instanceof Set){const n=/* @__PURE__ */new Set;return t.set(e,n),e.forEach(e=>{n.add(pe(e,t))}),n}if("object"==typeof e&&e.constructor===Object){const n={};return t.set(e,n),[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)].forEach(r=>{n[r]=pe(e[r],t)}),n}try{const n=new(0,Object.getPrototypeOf(e).constructor);t.set(e,n);for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=pe(e[r],t));return n}catch{return console.warn(`Unable to deeply clone object of type ${Object.prototype.toString.call(e)}. Fallback to shallow copy.`),{...e}}},me={172351395:{name:"EBML",type:"Container"},646:{name:"EBMLVersion",type:"Uint"},759:{name:"EBMLReadVersion",type:"Uint"},754:{name:"EBMLMaxIDLength",type:"Uint"},755:{name:"EBMLMaxSizeLength",type:"Uint"},642:{name:"DocType",type:"String"},647:{name:"DocTypeVersion",type:"Uint"},645:{name:"DocTypeReadVersion",type:"Uint"},108:{name:"Void",type:"Binary"},63:{name:"CRC-32",type:"Binary"},190023271:{name:"SignatureSlot",type:"Container"},16010:{name:"SignatureAlgo",type:"Uint"},16026:{name:"SignatureHash",type:"Uint"},16037:{name:"SignaturePublicKey",type:"Binary"},16053:{name:"Signature",type:"Binary"},15963:{name:"SignatureElements",type:"Container"},15995:{name:"SignatureElementList",type:"Container"},9522:{name:"SignedElement",type:"Binary"},139690087:{name:"Segment",type:"Container"},21863284:{name:"SeekHead",type:"Container"},3515:{name:"Seek",type:"Container"},5035:{name:"SeekID",type:"Binary"},5036:{name:"SeekPosition",type:"Uint"},88713574:{name:"Info",type:"Container"},13220:{name:"SegmentUID",type:"Binary"},13188:{name:"SegmentFilename",type:"String"},1882403:{name:"PrevUID",type:"Binary"},1868715:{name:"PrevFilename",type:"String"},2013475:{name:"NextUID",type:"Binary"},1999803:{name:"NextFilename",type:"String"},1092:{name:"SegmentFamily",type:"Binary"},10532:{name:"ChapterTranslate",type:"Container"},10748:{name:"ChapterTranslateEditionUID",type:"Uint"},10687:{name:"ChapterTranslateCodec",type:"Uint"},10661:{name:"ChapterTranslateID",type:"Binary"},710577:{name:"TimecodeScale",type:"Uint"},1161:{name:"Duration",type:"Float"},1121:{name:"DateUTC",type:"Date"},15273:{name:"Title",type:"String"},3456:{name:"MuxingApp",type:"String"},5953:{name:"WritingApp",type:"String"},103:{name:"Timecode",type:"Uint"},6228:{name:"SilentTracks",type:"Container"},6359:{name:"SilentTrackNumber",type:"Uint"},39:{name:"Position",type:"Uint"},43:{name:"PrevSize",type:"Uint"},35:{name:"SimpleBlock",type:"Binary"},32:{name:"BlockGroup",type:"Container"},33:{name:"Block",type:"Binary"},34:{name:"BlockVirtual",type:"Binary"},13729:{name:"BlockAdditions",type:"Container"},38:{name:"BlockMore",type:"Container"},110:{name:"BlockAddID",type:"Uint"},37:{name:"BlockAdditional",type:"Binary"},27:{name:"BlockDuration",type:"Uint"},122:{name:"ReferencePriority",type:"Uint"},123:{name:"ReferenceBlock",type:"Int"},125:{name:"ReferenceVirtual",type:"Int"},36:{name:"CodecState",type:"Binary"},13730:{name:"DiscardPadding",type:"Int"},14:{name:"Slices",type:"Container"},104:{name:"TimeSlice",type:"Container"},76:{name:"LaceNumber",type:"Uint"},77:{name:"FrameNumber",type:"Uint"},75:{name:"BlockAdditionID",type:"Uint"},78:{name:"Delay",type:"Uint"},79:{name:"SliceDuration",type:"Uint"},72:{name:"ReferenceFrame",type:"Container"},73:{name:"ReferenceOffset",type:"Uint"},74:{name:"ReferenceTimeCode",type:"Uint"},47:{name:"EncryptedBlock",type:"Binary"},106212971:{name:"Tracks",type:"Container"},46:{name:"TrackEntry",type:"Container"},87:{name:"TrackNumber",type:"Uint"},13253:{name:"TrackUID",type:"Uint"},3:{name:"TrackType",type:"Uint"},57:{name:"FlagEnabled",type:"Uint"},8:{name:"FlagDefault",type:"Uint"},5546:{name:"FlagForced",type:"Uint"},28:{name:"FlagLacing",type:"Uint"},11751:{name:"MinCache",type:"Uint"},11768:{name:"MaxCache",type:"Uint"},254851:{name:"DefaultDuration",type:"Uint"},216698:{name:"DefaultDecodedFieldDuration",type:"Uint"},209231:{name:"TrackTimecodeScale",type:"Float"},4991:{name:"TrackOffset",type:"Int"},5614:{name:"MaxBlockAdditionID",type:"Uint"},4974:{name:"Name",type:"String"},177564:{name:"Language",type:"String"},6:{name:"CodecID",type:"String"},9122:{name:"CodecPrivate",type:"Binary"},362120:{name:"CodecName",type:"String"},13382:{name:"AttachmentLink",type:"Uint"},1742487:{name:"CodecSettings",type:"String"},1785920:{name:"CodecInfoURL",type:"String"},438848:{name:"CodecDownloadURL",type:"String"},42:{name:"CodecDecodeAll",type:"Uint"},12203:{name:"TrackOverlay",type:"Uint"},5802:{name:"CodecDelay",type:"Uint"},5819:{name:"SeekPreRoll",type:"Uint"},9764:{name:"TrackTranslate",type:"Container"},9980:{name:"TrackTranslateEditionUID",type:"Uint"},9919:{name:"TrackTranslateCodec",type:"Uint"},9893:{name:"TrackTranslateTrackID",type:"Binary"},96:{name:"Video",type:"Container"},26:{name:"FlagInterlaced",type:"Uint"},5048:{name:"StereoMode",type:"Uint"},5056:{name:"AlphaMode",type:"Uint"},5049:{name:"OldStereoMode",type:"Uint"},48:{name:"PixelWidth",type:"Uint"},58:{name:"PixelHeight",type:"Uint"},5290:{name:"PixelCropBottom",type:"Uint"},5307:{name:"PixelCropTop",type:"Uint"},5324:{name:"PixelCropLeft",type:"Uint"},5341:{name:"PixelCropRight",type:"Uint"},5296:{name:"DisplayWidth",type:"Uint"},5306:{name:"DisplayHeight",type:"Uint"},5298:{name:"DisplayUnit",type:"Uint"},5299:{name:"AspectRatioType",type:"Uint"},963876:{name:"ColourSpace",type:"Binary"},1029411:{name:"GammaValue",type:"Float"},230371:{name:"FrameRate",type:"Float"},97:{name:"Audio",type:"Container"},53:{name:"SamplingFrequency",type:"Float"},14517:{name:"OutputSamplingFrequency",type:"Float"},31:{name:"Channels",type:"Uint"},15739:{name:"ChannelPositions",type:"Binary"},8804:{name:"BitDepth",type:"Uint"},98:{name:"TrackOperation",type:"Container"},99:{name:"TrackCombinePlanes",type:"Container"},100:{name:"TrackPlane",type:"Container"},101:{name:"TrackPlaneUID",type:"Uint"},102:{name:"TrackPlaneType",type:"Uint"},105:{name:"TrackJoinBlocks",type:"Container"},109:{name:"TrackJoinUID",type:"Uint"},64:{name:"TrickTrackUID",type:"Uint"},65:{name:"TrickTrackSegmentUID",type:"Binary"},70:{name:"TrickTrackFlag",type:"Uint"},71:{name:"TrickMasterTrackUID",type:"Uint"},68:{name:"TrickMasterTrackSegmentUID",type:"Binary"},11648:{name:"ContentEncodings",type:"Container"},8768:{name:"ContentEncoding",type:"Container"},4145:{name:"ContentEncodingOrder",type:"Uint"},4146:{name:"ContentEncodingScope",type:"Uint"},4147:{name:"ContentEncodingType",type:"Uint"},4148:{name:"ContentCompression",type:"Container"},596:{name:"ContentCompAlgo",type:"Uint"},597:{name:"ContentCompSettings",type:"Binary"},4149:{name:"ContentEncryption",type:"Container"},2017:{name:"ContentEncAlgo",type:"Uint"},2018:{name:"ContentEncKeyID",type:"Binary"},2019:{name:"ContentSignature",type:"Binary"},2020:{name:"ContentSigKeyID",type:"Binary"},2021:{name:"ContentSigAlgo",type:"Uint"},2022:{name:"ContentSigHashAlgo",type:"Uint"},206814059:{name:"Cues",type:"Container"},59:{name:"CuePoint",type:"Container"},51:{name:"CueTime",type:"Uint"},55:{name:"CueTrackPositions",type:"Container"},119:{name:"CueTrack",type:"Uint"},113:{name:"CueClusterPosition",type:"Uint"},112:{name:"CueRelativePosition",type:"Uint"},50:{name:"CueDuration",type:"Uint"},4984:{name:"CueBlockNumber",type:"Uint"},106:{name:"CueCodecState",type:"Uint"},91:{name:"CueReference",type:"Container"},22:{name:"CueRefTime",type:"Uint"},23:{name:"CueRefCluster",type:"Uint"},4959:{name:"CueRefNumber",type:"Uint"},107:{name:"CueRefCodecState",type:"Uint"},155296873:{name:"Attachments",type:"Container"},8615:{name:"AttachedFile",type:"Container"},1662:{name:"FileDescription",type:"String"},1646:{name:"FileName",type:"String"},1632:{name:"FileMimeType",type:"String"},1628:{name:"FileData",type:"Binary"},1710:{name:"FileUID",type:"Uint"},1653:{name:"FileReferral",type:"Binary"},1633:{name:"FileUsedStartTime",type:"Uint"},1634:{name:"FileUsedEndTime",type:"Uint"},4433776:{name:"Chapters",type:"Container"},1465:{name:"EditionEntry",type:"Container"},1468:{name:"EditionUID",type:"Uint"},1469:{name:"EditionFlagHidden",type:"Uint"},1499:{name:"EditionFlagDefault",type:"Uint"},1501:{name:"EditionFlagOrdered",type:"Uint"},54:{name:"ChapterAtom",type:"Container"},13252:{name:"ChapterUID",type:"Uint"},5716:{name:"ChapterStringUID",type:"String"},17:{name:"ChapterTimeStart",type:"Uint"},18:{name:"ChapterTimeEnd",type:"Uint"},24:{name:"ChapterFlagHidden",type:"Uint"},1432:{name:"ChapterFlagEnabled",type:"Uint"},11879:{name:"ChapterSegmentUID",type:"Binary"},11964:{name:"ChapterSegmentEditionUID",type:"Uint"},9155:{name:"ChapterPhysicalEquiv",type:"Uint"},15:{name:"ChapterTrack",type:"Container"},9:{name:"ChapterTrackNumber",type:"Uint"},0:{name:"ChapterDisplay",type:"Container"},5:{name:"ChapString",type:"String"},892:{name:"ChapLanguage",type:"String"},894:{name:"ChapCountry",type:"String"},10564:{name:"ChapProcess",type:"Container"},10581:{name:"ChapProcessCodecID",type:"Uint"},1293:{name:"ChapProcessPrivate",type:"Binary"},10513:{name:"ChapProcessCommand",type:"Container"},10530:{name:"ChapProcessTime",type:"Uint"},10547:{name:"ChapProcessData",type:"Binary"},39109479:{name:"Tags",type:"Container"},13171:{name:"Tag",type:"Container"},9152:{name:"Targets",type:"Container"},10442:{name:"TargetTypeValue",type:"Uint"},9162:{name:"TargetType",type:"String"},9157:{name:"TagTrackUID",type:"Uint"},9161:{name:"TagEditionUID",type:"Uint"},9156:{name:"TagChapterUID",type:"Uint"},9158:{name:"TagAttachmentUID",type:"Uint"},10184:{name:"SimpleTag",type:"Container"},1443:{name:"TagName",type:"String"},1146:{name:"TagLanguage",type:"String"},1156:{name:"TagDefault",type:"Uint"},1159:{name:"TagString",type:"String"},1157:{name:"TagBinary",type:"Binary"}},fe=class{name;type;source;data;constructor(e="Unknown",t="Unknown"){this.name=e,this.type=t}updateBySource(){}setSource(e){this.source=e,this.updateBySource()}updateByData(){}setData(e){this.data=e,this.updateByData()}};function ge(e){return e.length%2==1?"0"+e:e}var we=class extends fe{constructor(e,t){super(e,t||"Uint")}updateBySource(){this.data="";for(let e=0;e<this.source.length;e++){const t=this.source[e].toString(16);this.data+=ge(t)}}updateByData(){const e=this.data.length/2;this.source=new Uint8Array(e);for(let t=0;t<e;t++){const e=this.data.substr(2*t,2);this.source[t]=parseInt(e,16)}}getValue(){return parseInt(this.data,16)}setValue(e){this.setData(ge(e.toString(16)))}},ye=class extends fe{constructor(e,t){super(e,t||"Float")}getFloatArrayType(){return this.source&&4===this.source.length?Float32Array:Float64Array}updateBySource(){const e=this.source.reverse(),t=new(this.getFloatArrayType())(e.buffer);this.data=t[0]}updateByData(){const e=new(this.getFloatArrayType())([this.data]),t=new Uint8Array(e.buffer);this.source=t.reverse()}getValue(){return this.data}setValue(e){this.setData(e)}},Ce=class e extends fe{offset=0;data=[];constructor(e,t){super(e,t||"Container")}readByte(){return this.source[this.offset++]}readUint(){const e=this.readByte(),t=8-e.toString(2).length;let n=e-(1<<7-t);for(let r=0;r<t;r++)n*=256,n+=this.readByte();return n}updateBySource(){let t;for(this.data=[],this.offset=0;this.offset<this.source.length;this.offset=t){const n=this.readUint(),r=this.readUint();t=Math.min(this.offset+r,this.source.length);const i=this.source.slice(this.offset,t),a=me[n]||{name:"Unknown",type:"Unknown"};let o=fe;switch(a.type){case"Container":o=e;break;case"Uint":o=we;break;case"Float":o=ye}const s=new o(a.name,a.type);s.setSource(i),this.data.push({id:n,idHex:n.toString(16),data:s})}}writeUint(e,t=!1){let n=1,r=128;for(;e>=r&&n<8;)n++,r*=128;if(!t){let t=r+e;for(let e=n-1;e>=0;e--){const n=t%256;this.source[this.offset+e]=n,t=(t-n)/256}}this.offset+=n}writeSections(e=!1){this.offset=0;for(let t=0;t<this.data.length;t++){const n=this.data[t],r=n.data.source,i=r.length;this.writeUint(n.id,e),this.writeUint(i,e),e||this.source.set(r,this.offset),this.offset+=i}return this.offset}updateByData(){const e=this.writeSections(!0);this.source=new Uint8Array(e),this.writeSections()}getSectionById(e){for(let t=0;t<this.data.length;t++){const n=this.data[t];if(n.id===e)return n.data}}},be=class extends Ce{constructor(e){super("File","File"),this.setSource(e)}fixDuration(e){const t=this.getSectionById(139690087);if(!t)return!1;const n=t.getSectionById(88713574);if(!n)return!1;const r=n.getSectionById(710577);if(!r)return!1;let i=n.getSectionById(1161);if(i){if(!(i.getValue()<=0))return!1;i.setValue(e)}else i=new ye("Duration","Float"),i.setValue(e),n.data.push({id:1161,data:i});return r.setValue(1e6),n.updateByData(),t.updateByData(),this.updateByData(),!0}toBlob(e="video/webm"){return new Blob([this.source.buffer],{type:e})}};var Se=class{startTime;chunks;mediaRecorder;blob;constructor(){this.startTime=Date.now(),this.chunks=[],navigator.mediaDevices.getUserMedia({audio:!0}).then(e=>{this.init(e)}).catch(e=>{})}init(e){const t=function(){const e=["audio/webm","audio/mp4","audio/ogg","audio/wav","audio/aac"];for(let t=0;t<e.length;t++)if(MediaRecorder.isTypeSupported(e[t]))return e[t]}();this.mediaRecorder=new MediaRecorder(e,{mimeType:t}),this.mediaRecorder?.addEventListener("dataavailable",async e=>{if(e.data.size>0&&this.chunks.push(e.data),"inactive"===this.mediaRecorder?.state){const e=Date.now()-this.startTime;this.blob=new Blob(this.chunks,{type:t}),"audio/webm"===t&&(this.blob=await((e,t,n="video/webm")=>new Promise((r,i)=>{try{const a=new FileReader;a.addEventListener("loadend",()=>{try{const i=a.result,o=new be(new Uint8Array(i));o.fixDuration(t)?r(o.toBlob(n)):r(e)}catch(o){i(o)}}),a.addEventListener("error",()=>i()),a.readAsArrayBuffer(e)}catch(a){i(a)}}))(this.blob,e,this.blob.type)),this.chunks=[]}}),this.mediaRecorder?.start()}start(){return"paused"===this.mediaRecorder?.state&&this.mediaRecorder.resume(),this.mediaRecorder}pause(){return"recording"===this.mediaRecorder?.state&&this.mediaRecorder.pause(),this.mediaRecorder}stop(){return this.mediaRecorder?.stop(),this.blob}},Ae=new e,ve=(e,t)=>{const n={value:e,compare:pe(e),subscribers:Ae,comparator:t?.equals},{subscriber:r}=t||{},i=e=>{le(n.compare,e)||(n.value=e,n.compare=pe(e),r&&n.subscribers.call(r))};return[()=>n.value,e=>{const{comparator:t}=n;if(t instanceof Function)return!t(n.value,e)&&i(e);void 0===t?n.value!==e&&i(e):t||i(e)}]},Oe=()=>{const e=document.createElement("canvas").getContext("webgl2");return e?function(e){const t=e.getExtension("WEBGL_debug_renderer_info");return t?{vendor:e.getParameter(t.UNMASKED_VENDOR_WEBGL),renderer:e.getParameter(t.UNMASKED_RENDERER_WEBGL)}:null}(e):null},Ee=()=>{const e=document.createElement("canvas"),t=e.getContext("2d"),n="BrowserLeaks,com <canvas> 1.0";return t?(t.textBaseline="top",t.font="14px 'Arial'",t.textBaseline="alphabetic",t.fillStyle="#f60",t.fillRect(125,1,62,20),t.fillStyle="#069",t.fillText(n,2,15),t.fillStyle="rgba(102, 204, 0, 0.7)",t.fillText(n,4,17),e.toDataURL()):null},Ue=()=>new Promise((e,t)=>{C||t("window is undefined");const n=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(1,44100,44100),r=n.createOscillator();r.type="triangle",r.frequency.setValueAtTime(1e4,n.currentTime);const i=n.createDynamicsCompressor();!function(e,t){if(Array.prototype.forEach&&e.forEach===Array.prototype.forEach)e.forEach(t);else if(e.length===+e.length)for(let n=0,r=e.length;n<r;n++)t(e[n],n,e);else for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(e[n],Number(n),e)}([["threshold",-50],["knee",40],["ratio",12],["reduction",-20],["attack",0],["release",.25]],function(e){if(i[e[0]]&&"number"!=typeof i[e[0]]){const{setValueAtTime:t}=i[e[0]];t(e[1],n.currentTime)}}),r.connect(i),i.connect(n.destination),r.start(0),n.startRendering();const a=setTimeout(function(){return n.oncomplete=()=>{},t("audioTimeout"),"audioTimeout"},100);n.oncomplete=n=>{try{clearTimeout(a);const t=n.renderedBuffer.getChannelData(0).slice(4500,5e3).reduce(function(e,t){return e+Math.abs(t)},0).toString();return r.disconnect(),i.disconnect(),e(t),t}catch(o){return void t(o)}}}),Be="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Me(e,t,n,r){let i,a,o;const s=t||[0],c=(n=n||0)>>>3,d=-1===r?3:0;for(i=0;i<e.length;i+=1)o=i+c,a=o>>>2,s.length<=a&&s.push(0),s[a]|=e[i]<<8*(d+r*(o%4));return{value:s,binLen:8*e.length+n}}function Te(e,t,n){switch(t){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(e){case"HEX":return function(e,t,r){return function(e,t,n,r){let i,a,o,s;if(0!=e.length%2)throw new Error("String of HEX type must be in byte increments");const c=t||[0],d=(n=n||0)>>>3,u=-1===r?3:0;for(i=0;i<e.length;i+=2){if(a=parseInt(e.substr(i,2),16),isNaN(a))throw new Error("String of HEX type contains invalid characters");for(s=(i>>>1)+d,o=s>>>2;c.length<=o;)c.push(0);c[o]|=a<<8*(u+r*(s%4))}return{value:c,binLen:4*e.length+n}}(e,t,r,n)};case"TEXT":return function(e,r,i){return function(e,t,n,r,i){let a,o,s,c,d,u,h,l,p=0;const m=n||[0],f=(r=r||0)>>>3;if("UTF8"===t)for(h=-1===i?3:0,s=0;s<e.length;s+=1)for(a=e.charCodeAt(s),o=[],128>a?o.push(a):2048>a?(o.push(192|a>>>6),o.push(128|63&a)):55296>a||57344<=a?o.push(224|a>>>12,128|a>>>6&63,128|63&a):(s+=1,a=65536+((1023&a)<<10|1023&e.charCodeAt(s)),o.push(240|a>>>18,128|a>>>12&63,128|a>>>6&63,128|63&a)),c=0;c<o.length;c+=1){for(u=p+f,d=u>>>2;m.length<=d;)m.push(0);m[d]|=o[c]<<8*(h+i*(u%4)),p+=1}else for(h=-1===i?2:0,l="UTF16LE"===t&&1!==i||"UTF16LE"!==t&&1===i,s=0;s<e.length;s+=1){for(a=e.charCodeAt(s),!0===l&&(c=255&a,a=c<<8|a>>>8),u=p+f,d=u>>>2;m.length<=d;)m.push(0);m[d]|=a<<8*(h+i*(u%4)),p+=2}return{value:m,binLen:8*p+r}}(e,t,r,i,n)};case"B64":return function(e,t,r){return function(e,t,n,r){let i,a,o,s,c,d,u,h=0;const l=t||[0],p=(n=n||0)>>>3,m=-1===r?3:0,f=e.indexOf("=");if(-1===e.search(/^[a-z\d=+/]+$/i))throw new Error("Invalid character in base-64 string");if(e=e.replace(/=/g,""),-1!==f&&f<e.length)throw new Error("Invalid '=' found in base-64 string");for(a=0;a<e.length;a+=4){for(c=e.substr(a,4),s=0,o=0;o<c.length;o+=1)i=Be.indexOf(c.charAt(o)),s|=i<<18-6*o;for(o=0;o<c.length-1;o+=1){for(u=h+p,d=u>>>2;l.length<=d;)l.push(0);l[d]|=(s>>>16-8*o&255)<<8*(m+r*(u%4)),h+=1}}return{value:l,binLen:8*h+n}}(e,t,r,n)};case"BYTES":return function(e,t,r){return function(e,t,n,r){let i,a,o,s;const c=t||[0],d=(n=n||0)>>>3,u=-1===r?3:0;for(a=0;a<e.length;a+=1)i=e.charCodeAt(a),s=a+d,o=s>>>2,c.length<=o&&c.push(0),c[o]|=i<<8*(u+r*(s%4));return{value:c,binLen:8*e.length+n}}(e,t,r,n)};case"ARRAYBUFFER":return function(e,t,r){return function(e,t,n,r){return Me(new Uint8Array(e),t,n,r)}(e,t,r,n)};case"UINT8ARRAY":return function(e,t,r){return Me(e,t,r,n)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function ke(e,t,n,r){switch(e){case"HEX":return function(e){return function(e,t,n,r){const i="0123456789abcdef";let a,o,s="";const c=t/8,d=-1===n?3:0;for(a=0;a<c;a+=1)o=e[a>>>2]>>>8*(d+n*(a%4)),s+=i.charAt(o>>>4&15)+i.charAt(15&o);return r.outputUpper?s.toUpperCase():s}(e,t,n,r)};case"B64":return function(e){return function(e,t,n,r){let i,a,o,s,c,d="";const u=t/8,h=-1===n?3:0;for(i=0;i<u;i+=3)for(s=i+1<u?e[i+1>>>2]:0,c=i+2<u?e[i+2>>>2]:0,o=(e[i>>>2]>>>8*(h+n*(i%4))&255)<<16|(s>>>8*(h+n*((i+1)%4))&255)<<8|c>>>8*(h+n*((i+2)%4))&255,a=0;a<4;a+=1)d+=8*i+6*a<=t?Be.charAt(o>>>6*(3-a)&63):r.b64Pad;return d}(e,t,n,r)};case"BYTES":return function(e){return function(e,t,n){let r,i,a="";const o=t/8,s=-1===n?3:0;for(r=0;r<o;r+=1)i=e[r>>>2]>>>8*(s+n*(r%4))&255,a+=String.fromCharCode(i);return a}(e,t,n)};case"ARRAYBUFFER":return function(e){return function(e,t,n){let r;const i=t/8,a=new ArrayBuffer(i),o=new Uint8Array(a),s=-1===n?3:0;for(r=0;r<i;r+=1)o[r]=e[r>>>2]>>>8*(s+n*(r%4))&255;return a}(e,t,n)};case"UINT8ARRAY":return function(e){return function(e,t,n){let r;const i=t/8,a=-1===n?3:0,o=new Uint8Array(i);for(r=0;r<i;r+=1)o[r]=e[r>>>2]>>>8*(a+n*(r%4))&255;return o}(e,t,n)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}var Le=4294967296,Fe=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Re=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],He=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],De="Chosen SHA variant is not supported",Pe="Cannot set numRounds with MAC";function xe(e,t){let n,r;const i=e.binLen>>>3,a=t.binLen>>>3,o=i<<3,s=4-i<<3;if(i%4!=0){for(n=0;n<a;n+=4)r=i+n>>>2,e.value[r]|=t.value[n>>>2]<<o,e.value.push(0),e.value[r+1]|=t.value[n>>>2]>>>s;return(e.value.length<<2)-4>=a+i&&e.value.pop(),{value:e.value,binLen:e.binLen+t.binLen}}return{value:e.value.concat(t.value),binLen:e.binLen+t.binLen}}function Ie(e){const t={outputUpper:!1,b64Pad:"=",outputLen:-1},n=e||{},r="Output length must be a multiple of 8";if(t.outputUpper=n.outputUpper||!1,n.b64Pad&&(t.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(r);t.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(r);t.outputLen=n.shakeLen}if("boolean"!=typeof t.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw new Error("Invalid b64Pad formatting option");return t}function ze(e,t,n,r){const i=e+" must include a value and format";if(!t){if(!r)throw new Error(i);return r}if(void 0===t.value||!t.format)throw new Error(i);return Te(t.format,t.encoding||"UTF8",n)(t.value)}var je=class{shaVariant;inputFormat;utfType;numRounds;keyWithIPad;keyWithOPad;remainder;remainderLen;updateCalled;processedLen;macKeySet;constructor(e,t,n){const r=n||{};if(this.inputFormat=t,this.utfType=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.shaVariant=e,this.remainder=[],this.remainderLen=0,this.updateCalled=!1,this.processedLen=0,this.macKeySet=!1,this.keyWithIPad=[],this.keyWithOPad=[]}update(e){let t,n=0;const r=this.variantBlockSize>>>5,i=this.converterFunc(e,this.remainder,this.remainderLen),a=i.binLen,o=i.value,s=a>>>5;for(t=0;t<s;t+=r)n+this.variantBlockSize<=a&&(this.intermediateState=this.roundFunc(o.slice(t,t+r),this.intermediateState),n+=this.variantBlockSize);return this.processedLen+=n,this.remainder=o.slice(n>>>5),this.remainderLen=a%this.variantBlockSize,this.updateCalled=!0,this}getHash(e,t){let n,r,i=this.outputBinLen;const a=Ie(t);if(this.isVariableLen){if(-1===a.outputLen)throw new Error("Output length must be specified in options");i=a.outputLen}const o=ke(e,i,this.bigEndianMod,a);if(this.macKeySet&&this.getMAC)return o(this.getMAC(a));for(r=this.finalizeFunc(this.remainder.slice(),this.remainderLen,this.processedLen,this.stateCloneFunc(this.intermediateState),i),n=1;n<this.numRounds;n+=1)this.isVariableLen&&i%32!=0&&(r[r.length-1]&=16777215>>>24-i%32),r=this.finalizeFunc(r,i,0,this.newStateFunc(this.shaVariant),i);return o(r)}setHMACKey(e,t,n){if(!this.HMACSupported)throw new Error("Variant does not support HMAC");if(this.updateCalled)throw new Error("Cannot set MAC key after calling update");const r=Te(t,(n||{}).encoding||"UTF8",this.bigEndianMod);this._setHMACKey(r(e))}_setHMACKey(e){const t=this.variantBlockSize>>>3,n=t/4-1;let r;if(1!==this.numRounds)throw new Error(Pe);if(this.macKeySet)throw new Error("MAC key already set");for(t<e.binLen/8&&(e.value=this.finalizeFunc(e.value,e.binLen,0,this.newStateFunc(this.shaVariant),this.outputBinLen));e.value.length<=n;)e.value.push(0);for(r=0;r<=n;r+=1)this.keyWithIPad[r]=909522486^e.value[r],this.keyWithOPad[r]=1549556828^e.value[r];this.intermediateState=this.roundFunc(this.keyWithIPad,this.intermediateState),this.processedLen=this.variantBlockSize,this.macKeySet=!0}getHMAC(e,t){const n=Ie(t);return ke(e,this.outputBinLen,this.bigEndianMod,n)(this._getHMAC())}_getHMAC(){let e;if(!this.macKeySet)throw new Error("Cannot call getHMAC without first setting MAC key");const t=this.finalizeFunc(this.remainder.slice(),this.remainderLen,this.processedLen,this.stateCloneFunc(this.intermediateState),this.outputBinLen);return e=this.roundFunc(this.keyWithOPad,this.newStateFunc(this.shaVariant)),e=this.finalizeFunc(t,this.outputBinLen,this.variantBlockSize,e,this.outputBinLen),e}};function Ne(e,t){return e<<t|e>>>32-t}function Ke(e,t){return e>>>t|e<<32-t}function _e(e,t){return e>>>t}function qe(e,t,n){return e^t^n}function Ve(e,t,n){return e&t^~e&n}function We(e,t,n){return e&t^e&n^t&n}function $e(e){return Ke(e,2)^Ke(e,13)^Ke(e,22)}function Ye(e,t){const n=(65535&e)+(65535&t);return((e>>>16)+(t>>>16)+(n>>>16)&65535)<<16|65535&n}function Xe(e,t,n,r){const i=(65535&e)+(65535&t)+(65535&n)+(65535&r);return((e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16)&65535)<<16|65535&i}function Ge(e,t,n,r,i){const a=(65535&e)+(65535&t)+(65535&n)+(65535&r)+(65535&i);return((e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16)+(a>>>16)&65535)<<16|65535&a}function Je(e){return Ke(e,17)^Ke(e,19)^_e(e,10)}function Qe(e){return Ke(e,7)^Ke(e,18)^_e(e,3)}function Ze(e){return Ke(e,6)^Ke(e,11)^Ke(e,25)}function et(e){return[1732584193,4023233417,2562383102,271733878,3285377520]}function tt(e,t){let n,r,i,a,o,s,c;const d=[];for(n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],c=0;c<80;c+=1)d[c]=c<16?e[c]:Ne(d[c-3]^d[c-8]^d[c-14]^d[c-16],1),s=c<20?Ge(Ne(n,5),Ve(r,i,a),o,1518500249,d[c]):c<40?Ge(Ne(n,5),qe(r,i,a),o,1859775393,d[c]):c<60?Ge(Ne(n,5),We(r,i,a),o,2400959708,d[c]):Ge(Ne(n,5),qe(r,i,a),o,3395469782,d[c]),o=a,a=i,i=Ne(r,30),r=n,n=s;return t[0]=Ye(n,t[0]),t[1]=Ye(r,t[1]),t[2]=Ye(i,t[2]),t[3]=Ye(a,t[3]),t[4]=Ye(o,t[4]),t}function nt(e,t,n,r){let i;const a=15+(t+65>>>9<<4),o=t+n;for(;e.length<=a;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[a]=4294967295&o,e[a-1]=o/Le|0,i=0;i<e.length;i+=16)r=tt(e.slice(i,i+16),r);return r}var rt=class extends je{intermediateState;variantBlockSize;bigEndianMod;outputBinLen;isVariableLen;HMACSupported;converterFunc;roundFunc;finalizeFunc;stateCloneFunc;newStateFunc;getMAC;constructor(e,t,n){if("SHA-1"!==e)throw new Error(De);super(e,t,n);const r=n||{};this.HMACSupported=!0,this.getMAC=this._getHMAC,this.bigEndianMod=-1,this.converterFunc=Te(this.inputFormat,this.utfType,this.bigEndianMod),this.roundFunc=tt,this.stateCloneFunc=function(e){return e.slice()},this.newStateFunc=et,this.finalizeFunc=nt,this.intermediateState=[1732584193,4023233417,2562383102,271733878,3285377520],this.variantBlockSize=512,this.outputBinLen=160,this.isVariableLen=!1,r.hmacKey&&this._setHMACKey(ze("hmacKey",r.hmacKey,this.bigEndianMod))}};function it(e){let t;return t="SHA-224"===e?Re.slice():He.slice(),t}function at(e,t){let n,r,i,a,o,s,c,d,u,h,l;const p=[];for(n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],d=t[7],l=0;l<64;l+=1)p[l]=l<16?e[l]:Xe(Je(p[l-2]),p[l-7],Qe(p[l-15]),p[l-16]),u=Ge(d,Ze(o),Ve(o,s,c),Fe[l],p[l]),h=Ye($e(n),We(n,r,i)),d=c,c=s,s=o,o=Ye(a,u),a=i,i=r,r=n,n=Ye(u,h);return t[0]=Ye(n,t[0]),t[1]=Ye(r,t[1]),t[2]=Ye(i,t[2]),t[3]=Ye(a,t[3]),t[4]=Ye(o,t[4]),t[5]=Ye(s,t[5]),t[6]=Ye(c,t[6]),t[7]=Ye(d,t[7]),t}var ot=class extends je{intermediateState;variantBlockSize;bigEndianMod;outputBinLen;isVariableLen;HMACSupported;converterFunc;roundFunc;finalizeFunc;stateCloneFunc;newStateFunc;getMAC;constructor(e,t,n){if("SHA-224"!==e&&"SHA-256"!==e)throw new Error(De);super(e,t,n);const r=n||{};this.getMAC=this._getHMAC,this.HMACSupported=!0,this.bigEndianMod=-1,this.converterFunc=Te(this.inputFormat,this.utfType,this.bigEndianMod),this.roundFunc=at,this.stateCloneFunc=function(e){return e.slice()},this.newStateFunc=it,this.finalizeFunc=function(t,n,r,i){return function(e,t,n,r,i){let a,o;const s=15+(t+65>>>9<<4),c=t+n;for(;e.length<=s;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[s]=4294967295&c,e[s-1]=c/Le|0,a=0;a<e.length;a+=16)r=at(e.slice(a,a+16),r);return o="SHA-224"===i?[r[0],r[1],r[2],r[3],r[4],r[5],r[6]]:r,o}(t,n,r,i,e)},this.intermediateState=it(e),this.variantBlockSize=512,this.outputBinLen="SHA-224"===e?224:256,this.isVariableLen=!1,r.hmacKey&&this._setHMACKey(ze("hmacKey",r.hmacKey,this.bigEndianMod))}},st=class{highOrder;lowOrder;constructor(e,t){this.highOrder=e,this.lowOrder=t}};function ct(e,t){let n;return t>32?(n=64-t,new st(e.lowOrder<<t|e.highOrder>>>n,e.highOrder<<t|e.lowOrder>>>n)):0!==t?(n=32-t,new st(e.highOrder<<t|e.lowOrder>>>n,e.lowOrder<<t|e.highOrder>>>n)):e}function dt(e,t){let n;return t<32?(n=32-t,new st(e.highOrder>>>t|e.lowOrder<<n,e.lowOrder>>>t|e.highOrder<<n)):(n=64-t,new st(e.lowOrder>>>t|e.highOrder<<n,e.highOrder>>>t|e.lowOrder<<n))}function ut(e,t){return new st(e.highOrder>>>t,e.lowOrder>>>t|e.highOrder<<32-t)}function ht(e,t,n){return new st(e.highOrder&t.highOrder^~e.highOrder&n.highOrder,e.lowOrder&t.lowOrder^~e.lowOrder&n.lowOrder)}function lt(e,t,n){return new st(e.highOrder&t.highOrder^e.highOrder&n.highOrder^t.highOrder&n.highOrder,e.lowOrder&t.lowOrder^e.lowOrder&n.lowOrder^t.lowOrder&n.lowOrder)}function pt(e){const t=dt(e,28),n=dt(e,34),r=dt(e,39);return new st(t.highOrder^n.highOrder^r.highOrder,t.lowOrder^n.lowOrder^r.lowOrder)}function mt(e,t){let n,r;n=(65535&e.lowOrder)+(65535&t.lowOrder),r=(e.lowOrder>>>16)+(t.lowOrder>>>16)+(n>>>16);const i=(65535&r)<<16|65535&n;n=(65535&e.highOrder)+(65535&t.highOrder)+(r>>>16),r=(e.highOrder>>>16)+(t.highOrder>>>16)+(n>>>16);return new st((65535&r)<<16|65535&n,i)}function ft(e,t,n,r){let i,a;i=(65535&e.lowOrder)+(65535&t.lowOrder)+(65535&n.lowOrder)+(65535&r.lowOrder),a=(e.lowOrder>>>16)+(t.lowOrder>>>16)+(n.lowOrder>>>16)+(r.lowOrder>>>16)+(i>>>16);const o=(65535&a)<<16|65535&i;i=(65535&e.highOrder)+(65535&t.highOrder)+(65535&n.highOrder)+(65535&r.highOrder)+(a>>>16),a=(e.highOrder>>>16)+(t.highOrder>>>16)+(n.highOrder>>>16)+(r.highOrder>>>16)+(i>>>16);return new st((65535&a)<<16|65535&i,o)}function gt(e,t,n,r,i){let a,o;a=(65535&e.lowOrder)+(65535&t.lowOrder)+(65535&n.lowOrder)+(65535&r.lowOrder)+(65535&i.lowOrder),o=(e.lowOrder>>>16)+(t.lowOrder>>>16)+(n.lowOrder>>>16)+(r.lowOrder>>>16)+(i.lowOrder>>>16)+(a>>>16);const s=(65535&o)<<16|65535&a;a=(65535&e.highOrder)+(65535&t.highOrder)+(65535&n.highOrder)+(65535&r.highOrder)+(65535&i.highOrder)+(o>>>16),o=(e.highOrder>>>16)+(t.highOrder>>>16)+(n.highOrder>>>16)+(r.highOrder>>>16)+(i.highOrder>>>16)+(a>>>16);return new st((65535&o)<<16|65535&a,s)}function wt(e,t){return new st(e.highOrder^t.highOrder,e.lowOrder^t.lowOrder)}function yt(e,t,n,r,i){return new st(e.highOrder^t.highOrder^n.highOrder^r.highOrder^i.highOrder,e.lowOrder^t.lowOrder^n.lowOrder^r.lowOrder^i.lowOrder)}function Ct(e){const t=dt(e,19),n=dt(e,61),r=ut(e,6);return new st(t.highOrder^n.highOrder^r.highOrder,t.lowOrder^n.lowOrder^r.lowOrder)}function bt(e){const t=dt(e,1),n=dt(e,8),r=ut(e,7);return new st(t.highOrder^n.highOrder^r.highOrder,t.lowOrder^n.lowOrder^r.lowOrder)}function St(e){const t=dt(e,14),n=dt(e,18),r=dt(e,41);return new st(t.highOrder^n.highOrder^r.highOrder,t.lowOrder^n.lowOrder^r.lowOrder)}var At=[new st(Fe[0],3609767458),new st(Fe[1],602891725),new st(Fe[2],3964484399),new st(Fe[3],2173295548),new st(Fe[4],4081628472),new st(Fe[5],3053834265),new st(Fe[6],2937671579),new st(Fe[7],3664609560),new st(Fe[8],2734883394),new st(Fe[9],1164996542),new st(Fe[10],1323610764),new st(Fe[11],3590304994),new st(Fe[12],4068182383),new st(Fe[13],991336113),new st(Fe[14],633803317),new st(Fe[15],3479774868),new st(Fe[16],2666613458),new st(Fe[17],944711139),new st(Fe[18],2341262773),new st(Fe[19],2007800933),new st(Fe[20],1495990901),new st(Fe[21],1856431235),new st(Fe[22],3175218132),new st(Fe[23],2198950837),new st(Fe[24],3999719339),new st(Fe[25],766784016),new st(Fe[26],2566594879),new st(Fe[27],3203337956),new st(Fe[28],1034457026),new st(Fe[29],2466948901),new st(Fe[30],3758326383),new st(Fe[31],168717936),new st(Fe[32],1188179964),new st(Fe[33],1546045734),new st(Fe[34],1522805485),new st(Fe[35],2643833823),new st(Fe[36],2343527390),new st(Fe[37],1014477480),new st(Fe[38],1206759142),new st(Fe[39],344077627),new st(Fe[40],1290863460),new st(Fe[41],3158454273),new st(Fe[42],3505952657),new st(Fe[43],106217008),new st(Fe[44],3606008344),new st(Fe[45],1432725776),new st(Fe[46],1467031594),new st(Fe[47],851169720),new st(Fe[48],3100823752),new st(Fe[49],1363258195),new st(Fe[50],3750685593),new st(Fe[51],3785050280),new st(Fe[52],3318307427),new st(Fe[53],3812723403),new st(Fe[54],2003034995),new st(Fe[55],3602036899),new st(Fe[56],1575990012),new st(Fe[57],1125592928),new st(Fe[58],2716904306),new st(Fe[59],442776044),new st(Fe[60],593698344),new st(Fe[61],3733110249),new st(Fe[62],2999351573),new st(Fe[63],3815920427),new st(3391569614,3928383900),new st(3515267271,566280711),new st(3940187606,3454069534),new st(4118630271,4000239992),new st(116418474,1914138554),new st(174292421,2731055270),new st(289380356,3203993006),new st(460393269,320620315),new st(685471733,587496836),new st(852142971,1086792851),new st(1017036298,365543100),new st(1126000580,2618297676),new st(1288033470,3409855158),new st(1501505948,4234509866),new st(1607167915,987167468),new st(1816402316,1246189591)];function vt(e){return"SHA-384"===e?[new st(3418070365,Re[0]),new st(1654270250,Re[1]),new st(2438529370,Re[2]),new st(355462360,Re[3]),new st(1731405415,Re[4]),new st(41048885895,Re[5]),new st(3675008525,Re[6]),new st(1203062813,Re[7])]:[new st(He[0],4089235720),new st(He[1],2227873595),new st(He[2],4271175723),new st(He[3],1595750129),new st(He[4],2917565137),new st(He[5],725511199),new st(He[6],4215389547),new st(He[7],327033209)]}function Ot(e,t){let n,r,i,a,o,s,c,d,u,h,l,p;const m=[];for(n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],d=t[7],l=0;l<80;l+=1)l<16?(p=2*l,m[l]=new st(e[p],e[p+1])):m[l]=ft(Ct(m[l-2]),m[l-7],bt(m[l-15]),m[l-16]),u=gt(d,St(o),ht(o,s,c),At[l],m[l]),h=mt(pt(n),lt(n,r,i)),d=c,c=s,s=o,o=mt(a,u),a=i,i=r,r=n,n=mt(u,h);return t[0]=mt(n,t[0]),t[1]=mt(r,t[1]),t[2]=mt(i,t[2]),t[3]=mt(a,t[3]),t[4]=mt(o,t[4]),t[5]=mt(s,t[5]),t[6]=mt(c,t[6]),t[7]=mt(d,t[7]),t}var Et=class extends je{intermediateState;variantBlockSize;bigEndianMod;outputBinLen;isVariableLen;HMACSupported;converterFunc;roundFunc;finalizeFunc;stateCloneFunc;newStateFunc;getMAC;constructor(e,t,n){if("SHA-384"!==e&&"SHA-512"!==e)throw new Error(De);super(e,t,n);const r=n||{};this.getMAC=this._getHMAC,this.HMACSupported=!0,this.bigEndianMod=-1,this.converterFunc=Te(this.inputFormat,this.utfType,this.bigEndianMod),this.roundFunc=Ot,this.stateCloneFunc=function(e){return e.slice()},this.newStateFunc=vt,this.finalizeFunc=function(t,n,r,i){return function(e,t,n,r,i){let a,o;const s=31+(t+129>>>10<<5),c=t+n;for(;e.length<=s;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[s]=4294967295&c,e[s-1]=c/Le|0,a=0;a<e.length;a+=32)r=Ot(e.slice(a,a+32),r);return o="SHA-384"===i?[r[0].highOrder,r[0].lowOrder,r[1].highOrder,r[1].lowOrder,r[2].highOrder,r[2].lowOrder,r[3].highOrder,r[3].lowOrder,r[4].highOrder,r[4].lowOrder,r[5].highOrder,r[5].lowOrder]:[r[0].highOrder,r[0].lowOrder,r[1].highOrder,r[1].lowOrder,r[2].highOrder,r[2].lowOrder,r[3].highOrder,r[3].lowOrder,r[4].highOrder,r[4].lowOrder,r[5].highOrder,r[5].lowOrder,r[6].highOrder,r[6].lowOrder,r[7].highOrder,r[7].lowOrder],o}(t,n,r,i,e)},this.intermediateState=vt(e),this.variantBlockSize=1024,this.outputBinLen="SHA-384"===e?384:512,this.isVariableLen=!1,r.hmacKey&&this._setHMACKey(ze("hmacKey",r.hmacKey,this.bigEndianMod))}},Ut=[new st(0,1),new st(0,32898),new st(2147483648,32906),new st(2147483648,2147516416),new st(0,32907),new st(0,2147483649),new st(2147483648,2147516545),new st(2147483648,32777),new st(0,138),new st(0,136),new st(0,2147516425),new st(0,2147483658),new st(0,2147516555),new st(2147483648,139),new st(2147483648,32905),new st(2147483648,32771),new st(2147483648,32770),new st(2147483648,128),new st(0,32778),new st(2147483648,2147483658),new st(2147483648,2147516545),new st(2147483648,32896),new st(0,2147483649),new st(2147483648,2147516424)],Bt=[[0,36,3,41,18],[1,44,10,45,2],[62,6,43,15,61],[28,55,25,21,56],[27,20,39,8,14]];function Mt(e){let t;const n=[];for(t=0;t<5;t+=1)n[t]=[new st(0,0),new st(0,0),new st(0,0),new st(0,0),new st(0,0)];return n}function Tt(e){let t;const n=[];for(t=0;t<5;t+=1)n[t]=e[t].slice();return n}function kt(e,t){let n,r,i,a;const o=[],s=[];if(null!=e)for(r=0;r<e.length;r+=2)t[(r>>>1)%5][(r>>>1)/5|0]=wt(t[(r>>>1)%5][(r>>>1)/5|0],new st(e[r+1],e[r]));for(n=0;n<24;n+=1){for(a=Mt(),r=0;r<5;r+=1)o[r]=yt(t[r][0],t[r][1],t[r][2],t[r][3],t[r][4]);for(r=0;r<5;r+=1)s[r]=wt(o[(r+4)%5],ct(o[(r+1)%5],1));for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)t[r][i]=wt(t[r][i],s[r]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)a[i][(2*r+3*i)%5]=ct(t[r][i],Bt[r][i]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)t[r][i]=wt(a[r][i],new st(~a[(r+1)%5][i].highOrder&a[(r+2)%5][i].highOrder,~a[(r+1)%5][i].lowOrder&a[(r+2)%5][i].lowOrder));t[0][0]=wt(t[0][0],Ut[n])}return t}function Lt(e){let t,n,r=0;const i=[0,0],a=[4294967295&e,e/Le&2097151];for(t=6;t>=0;t--)n=a[t>>2]>>>8*t&255,0===n&&0===r||(i[r+1>>2]|=n<<8*(r+1),r+=1);return r=0!==r?r:1,i[0]|=r,{value:r+1>4?i:[i[0]],binLen:8+8*r}}function Ft(e){return xe(Lt(e.binLen),e)}function Rt(e,t){let n,r=Lt(t);r=xe(r,e);const i=t>>>2,a=(i-r.value.length%i)%i;for(n=0;n<a;n++)r.value.push(0);return r.value}var Ht=class extends je{intermediateState;variantBlockSize;bigEndianMod;outputBinLen;isVariableLen;HMACSupported;converterFunc;roundFunc;finalizeFunc;stateCloneFunc;newStateFunc;getMAC;constructor(e,t,n){let r=6,i=0;super(e,t,n);const a=n||{};if(1!==this.numRounds){if(a.kmacKey||a.hmacKey)throw new Error(Pe);if("CSHAKE128"===this.shaVariant||"CSHAKE256"===this.shaVariant)throw new Error("Cannot set numRounds for CSHAKE variants")}switch(this.bigEndianMod=1,this.converterFunc=Te(this.inputFormat,this.utfType,this.bigEndianMod),this.roundFunc=kt,this.stateCloneFunc=Tt,this.newStateFunc=Mt,this.intermediateState=Mt(),this.isVariableLen=!1,e){case"SHA3-224":this.variantBlockSize=i=1152,this.outputBinLen=224,this.HMACSupported=!0,this.getMAC=this._getHMAC;break;case"SHA3-256":this.variantBlockSize=i=1088,this.outputBinLen=256,this.HMACSupported=!0,this.getMAC=this._getHMAC;break;case"SHA3-384":this.variantBlockSize=i=832,this.outputBinLen=384,this.HMACSupported=!0,this.getMAC=this._getHMAC;break;case"SHA3-512":this.variantBlockSize=i=576,this.outputBinLen=512,this.HMACSupported=!0,this.getMAC=this._getHMAC;break;case"SHAKE128":r=31,this.variantBlockSize=i=1344,this.outputBinLen=-1,this.isVariableLen=!0,this.HMACSupported=!1,this.getMAC=null;break;case"SHAKE256":r=31,this.variantBlockSize=i=1088,this.outputBinLen=-1,this.isVariableLen=!0,this.HMACSupported=!1,this.getMAC=null;break;case"KMAC128":r=4,this.variantBlockSize=i=1344,this._initializeKMAC(n),this.outputBinLen=-1,this.isVariableLen=!0,this.HMACSupported=!1,this.getMAC=this._getKMAC;break;case"KMAC256":r=4,this.variantBlockSize=i=1088,this._initializeKMAC(n),this.outputBinLen=-1,this.isVariableLen=!0,this.HMACSupported=!1,this.getMAC=this._getKMAC;break;case"CSHAKE128":this.variantBlockSize=i=1344,r=this._initializeCSHAKE(n),this.outputBinLen=-1,this.isVariableLen=!0,this.HMACSupported=!1,this.getMAC=null;break;case"CSHAKE256":this.variantBlockSize=i=1088,r=this._initializeCSHAKE(n),this.outputBinLen=-1,this.isVariableLen=!0,this.HMACSupported=!1,this.getMAC=null;break;default:throw new Error(De)}this.finalizeFunc=function(e,t,n,a,o){return function(e,t,n,r,i,a,o){let s,c,d=0;const u=[],h=i>>>5,l=t>>>5;for(s=0;s<l&&t>=i;s+=h)r=kt(e.slice(s,s+h),r),t-=i;for(e=e.slice(s),t%=i;e.length<h;)e.push(0);for(s=t>>>3,e[s>>2]^=a<<s%4*8,e[h-1]^=2147483648,r=kt(e,r);32*u.length<o&&(c=r[d%5][d/5|0],u.push(c.lowOrder),!(32*u.length>=o));)u.push(c.highOrder),d+=1,0==64*d%i&&(kt(null,r),d=0);return u}(e,t,0,a,i,r,o)},a.hmacKey&&this._setHMACKey(ze("hmacKey",a.hmacKey,this.bigEndianMod))}_initializeCSHAKE(e,t){const n=function(e){const t=e||{};return{funcName:ze("funcName",t.funcName,1,{value:[],binLen:0}),customization:ze("Customization",t.customization,1,{value:[],binLen:0})}}(e||{});t&&(n.funcName=t);const r=xe(Ft(n.funcName),Ft(n.customization));if(0!==n.customization.binLen||0!==n.funcName.binLen){const e=Rt(r,this.variantBlockSize>>>3);for(let t=0;t<e.length;t+=this.variantBlockSize>>>5)this.intermediateState=this.roundFunc(e.slice(t,t+(this.variantBlockSize>>>5)),this.intermediateState),this.processedLen+=this.variantBlockSize;return 4}return 31}_initializeKMAC(e){const t=function(e){const t=e||{};return{kmacKey:ze("kmacKey",t.kmacKey,1),funcName:{value:[1128353099],binLen:32},customization:ze("Customization",t.customization,1,{value:[],binLen:0})}}(e||{});this._initializeCSHAKE(e,t.funcName);const n=Rt(Ft(t.kmacKey),this.variantBlockSize>>>3);for(let r=0;r<n.length;r+=this.variantBlockSize>>>5)this.intermediateState=this.roundFunc(n.slice(r,r+(this.variantBlockSize>>>5)),this.intermediateState),this.processedLen+=this.variantBlockSize;this.macKeySet=!0}_getKMAC(e){const t=xe({value:this.remainder.slice(),binLen:this.remainderLen},function(e){let t,n,r=0;const i=[0,0],a=[4294967295&e,e/Le&2097151];for(t=6;t>=0;t--)n=a[t>>2]>>>8*t&255,0===n&&0===r||(i[r>>2]|=n<<8*r,r+=1);return r=0!==r?r:1,i[r>>2]|=r<<8*r,{value:r+1>4?i:[i[0]],binLen:8+8*r}}(e.outputLen));return this.finalizeFunc(t.value,t.binLen,this.processedLen,this.stateCloneFunc(this.intermediateState),e.outputLen)}},Dt=class{shaObj;constructor(e,t,n){if("SHA-1"===e)this.shaObj=new rt(e,t,n);else if("SHA-224"===e||"SHA-256"===e)this.shaObj=new ot(e,t,n);else if("SHA-384"===e||"SHA-512"===e)this.shaObj=new Et(e,t,n);else{if("SHA3-224"!==e&&"SHA3-256"!==e&&"SHA3-384"!==e&&"SHA3-512"!==e&&"SHAKE128"!==e&&"SHAKE256"!==e&&"CSHAKE128"!==e&&"CSHAKE256"!==e&&"KMAC128"!==e&&"KMAC256"!==e)throw new Error(De);this.shaObj=new Ht(e,t,n)}}update(e){return this.shaObj.update(e),this}getHash(e,t){return this.shaObj.getHash(e,t)}setHMACKey(e,t,n){this.shaObj.setHMACKey(e,t,n)}getHMAC(e,t){return this.shaObj.getHMAC(e,t)}},Pt=class{static generate(e,t){const n={digits:6,algorithm:"SHA-1",period:30,timestamp:Date.now(),...t},r=Math.floor(n.timestamp/1e3),i=this.leftpad(this.dec2hex(Math.floor(r/n.period)),16,"0"),a=new Dt(n.algorithm,"HEX");a.setHMACKey(this.base32tohex(e),"HEX"),a.update(i);const o=a.getHMAC("HEX"),s=this.hex2dec(o.substring(o.length-1));let c=(this.hex2dec(o.slice(2*s,2*s+8))&this.hex2dec("7fffffff"))+"";const d=Math.max(c.length-n.digits,0);c=c.substring(d,d+n.digits);return{otp:c,expires:Math.ceil((n.timestamp+1)/(1e3*n.period))*n.period*1e3}}static hex2dec(e){return parseInt(e,16)}static dec2hex(e){return(e<15.5?"0":"")+Math.round(e).toString(16)}static base32tohex(e){let t="",n="";const r=e.endsWith("=")?e.slice(0,e.lastIndexOf("=")):e;for(let i=0;i<r.length;i++){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".indexOf(e.charAt(i).toUpperCase());if(-1===n)throw new Error("Invalid base32 character in key");t+=this.leftpad(n.toString(2),5,"0")}for(let i=0;i+8<=t.length;i+=8){const e=t.slice(i,i+8);n+=this.leftpad(parseInt(e,2).toString(16),2,"0")}return n}static leftpad(e,t,n){return t+1>=e.length&&(e=Array(t+1-e.length).join(n)+e),e}},xt=(e,t)=>{C&&localStorage.setItem(e,t)},It=e=>C&&localStorage.getItem(e)||"";function zt(e){if(!Array.isArray(e))throw new TypeError("Middleware stack must be an array!");for(const t of e)if("function"!=typeof t)throw new TypeError("Middleware must be composed of functions!");return function(t,n){let r=-1;return function i(a){if(a<=r)return Promise.reject(/* @__PURE__ */new Error("next() called multiple times"));r=a;let o=e[a];a===e.length&&n&&(o=n);if(!o)return Promise.resolve();try{return Promise.resolve(o(t,i.bind(null,a+1)))}catch(s){return Promise.reject(s)}}(0)}}var jt=(e=l)=>{["log","info","warn","error","assert"].forEach(t=>{ce(console,t,n=>function(...r){n&&(e(t,...r),n.apply(console,r))})})},Nt=(e,t=500)=>{let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>{e.apply(void 0,r)},t)}},Kt=(e,t)=>{if("undefined"==typeof document)return;const n=e.classList;n.contains(t)||n.add(t)},_t=(e,t)=>{if("undefined"==typeof document)return;const n=e.classList;n.contains(t)&&n.remove(t)},qt=e=>{if("undefined"==typeof document)return;const t=document.createDocumentFragment();return e.forEach(e=>t.appendChild(e)),t},Vt=/["'&<>]/;function Wt(e){const t=""+e,n=Vt.exec(t);if(!n)return t;let r,i="",a=0,o=0;for(a=n.index;a<t.length;a++){switch(t.charCodeAt(a)){case 34:r=""";break;case 38:r="&";break;case 39:r="'";break;case 60:r="<";break;case 62:r=">";break;default:continue}o!==a&&(i+=t.substring(o,a)),o=a+1,i+=r}return o!==a?i+t.substring(o,a):i}var $t=(e=375)=>{let t=e;const{documentElement:n}=document,r=window.matchMedia("(orientation: portrait)");let i,a=667/375;function o(){const e=!r.matches;let i=window.screen.width,o=window.screen.height;i<o&&([i,o]=[o,i]);let s=n.clientWidth,c=o;s/c>=a?(s=c*a,n.classList.remove("adjustHeight"),n.classList.add("adjustWidth")):(c=s/a,n.classList.remove("adjustWidth"),n.classList.add("adjustHeight"));let d=s/t*16;e&&(d/=a),n.style.fontSize=`${d}px`;const u=window.getComputedStyle(n).fontSize.replace("px","")||0;d!==u&&(n.style.fontSize=d/Number(u)*d+"px")}y()===w.IPAD&&(a=1024/768,t=768),window.addEventListener("resize",function(){clearTimeout(i),i=setTimeout(o,300)},!1),window.addEventListener("pageshow",function(e){e.persisted&&(clearTimeout(i),i=setTimeout(o,300))},!1),window.addEventListener("orientationchange",function(){o()},!1),o()},Yt=["svg","path","g","circle","rect","line","polyline","polygon","ellipse","text","tspan","textPath","defs","marker","radialGradient","stop","linearGradient","clipPath","mask","pattern","image","use","symbol","foreignObject","feGaussianBlur","feColorMatrix"],Xt=class e{listener;element;constructor(e,t){this.element=this.create(e,t),this.listener=/* @__PURE__ */new Map}create=(e,t)=>Yt.includes(e)?document.createElementNS("http://www.w3.org/2000/svg",e,t):document.createElement(e,t);setAttribute=(e,t)=>(this.element.setAttribute(e,t),this);removeAttribute=e=>(this.element.removeAttribute(e),this);append=e=>(this.element.appendChild(e),this);remove=e=>(this.element.removeChild(e),this);setTextContent=e=>(this.element.textContent=e,this);setStyle=(e,t)=>(this.element.style.setProperty(e,t),this);addElementByType=(t,n)=>{t instanceof e&&n.appendChild(t.element),t instanceof HTMLElement&&n.appendChild(t)};addChild=e=>{if(Array.isArray(e)){const t=document.createDocumentFragment();e.forEach(e=>{this.addElementByType(e,t)}),this.element.appendChild(t)}else this.addElementByType(e,this.element);return this};listen=(e,t,n)=>{let r=this.listener.get(e);r||(r=/* @__PURE__ */new Map,this.listener.set(e,r));const i=r.get(t.name);return i===t&&console.warn(`${i.name} listener has been added to ${e} event, please remove it first.`),this.element.addEventListener(e,t,n),r.set(t.name,t),this};clearListener=(e,t,n)=>{this.element.removeEventListener(e,t,n);const r=this.listener.get(e);return r?r.delete(t.name):console.warn(`No ${e} event listener has been added.`),this};clearAllListener=()=>{for(const[e,t]of this.listener){for(const[n,r]of t)this.element.removeEventListener(e,r),t.delete(n);this.listener.delete(e)}return this}},Gt=(e,t)=>new Xt(e,t),Jt=(e=l)=>{"undefined"!=typeof window&&(window.addEventListener("unhandledrejection",t=>{e(t)},!0),window.addEventListener("error",t=>(e(t),!1),!0))},Qt=(e,t,n)=>new Promise((r,i)=>{C||i("window is undefined");const a=window.URL||window.webkitURL,o=new Image;o.onload=function(){let e=!1;t&&(e=o.width===t),n&&(e=o.height===n),a.revokeObjectURL(o.src),r(e)},o.src=a.createObjectURL(e)}),Zt=e=>new Promise((t,n)=>{const r=new FileReader;r.onload=function(){t({success:!0,data:r.result,message:""})},r.onerror=e=>{n({success:!1,data:e,message:""})},r.readAsDataURL(e)});function en(){if("undefined"!=typeof window){const[e]=performance.getEntriesByType("navigation"),[t={},n={}]=performance.getEntriesByType("paint"),{startTime:r}=t,{startTime:i}=n,{domainLookupEnd:a,domainLookupStart:o,connectEnd:s,connectStart:c,secureConnectionStart:d,loadEventStart:u,domInteractive:h,domContentLoadedEventEnd:l,duration:p,responseStart:m,requestStart:f,responseEnd:g,fetchStart:w,transferSize:y,encodedBodySize:C,redirectEnd:b,redirectStart:S,redirectCount:A}=e;return{dnsSearch:a-o,tcpConnect:s-c,sslConnect:s-d,request:m-f,response:g-m,parseDomTree:h-g,resource:u-l,domReady:l-w,interactive:h-w,complete:u-w,httpHead:y-C,redirect:A,redirectTime:b-S,duration:p,fp:r,fcp:i}}}var tn=({url:e="",type:t="application/json; charset=UTF-8",payload:n={}})=>{const r=e||T();return"undefined"!=typeof navigator?(({url:e="",type:t="application/json; charset=UTF-8",payload:n={}})=>{const r=e||T();if(navigator.sendBeacon&&r){const e=new Blob([JSON.stringify(n)],{type:t});return navigator.sendBeacon(r,e)}})({url:r,type:t,payload:n}):(({url:e="",payload:t={}})=>{const n=e||T();if("undefined"!=typeof document&&n){const e=new Image;e.width=1,e.height=1,e.src=`${n}?${ie(t)}`}})({url:r,payload:n})};function nn(e={}){if("undefined"!=typeof window){const{width:t,height:n}=D();return Object.assign({},{id:r(),path:window.location.href,time:Date.now(),referrer:document.referrer,ip:window.returnCitySN||{cid:"",cip:"",cname:""},userId:O("chaxus_prod"),ratio:`${t}x${n}`,userAgent:window.navigator.userAgent},e)}return{}}var rn=(e={})=>{if("undefined"!=typeof window){const{requestHook:t=l,responseHook:n=l,errorHook:r=l}=e;ce(window,"fetch",e=>(i,a)=>(t(i,a),e.apply(window,[i,a]).then(e=>(n(i,a,e),e)).catch(e=>{throw r(i,e),e})))}},an=(e={})=>{if("undefined"!=typeof window){const t=XMLHttpRequest.prototype,{requestHook:n=l,responseHook:r=l,errorHook:i=l}=e;ce(t,"open",e=>function(...t){n(t),e.apply(this,t)});ce(t,"send",e=>function(...t){this.addEventListener("loadend",function(){r(this)}),this.addEventListener("error",function(){i(this)}),e.apply(this,t)})}};function on(e,t=300){let n=0,r=null;return function(...i){const a=Date.now();a-n>=t?(null!=r&&(clearTimeout(r),r=null),n=a,e.apply(this,i)):null==r&&(r=window.setTimeout(()=>{n=Date.now(),e.apply(this,i),r=null},t-(a-n)))}}var sn=()=>{let e=0,t=null;return function(n,r=300){return function(...i){const a=Date.now();a-e>=r?(null!=t&&(clearTimeout(t),t=null),e=a,n.apply(this,i)):null==t&&(t=window.setTimeout(()=>{e=Date.now(),n.apply(this,i),t=null},r-(a-e)))}}},cn=class{constructor(){this.initialize()}reportPerformance(){const e=en(),t=nn();tn({payload:{...e,...t}})}log(e){tn({payload:e})}reportClick(){const e=on(tn),t=nn();((e=l)=>{"undefined"!=typeof document&&document.addEventListener("click",function(t){e(t)},!0)})(n=>{const{pageX:r,pageY:i,screenX:a,screenY:o,type:s}=n;e({payload:{...t,data:{pageX:r,pageY:i,screenX:a,screenY:o,type:s},type:"click"}})})}reportXhr(){const e=on(tn),t=nn();an({requestHook:(...n)=>{e({payload:{...t,data:{...n},type:"xhrRequest"}})},responseHook:(...n)=>{e({payload:{...t,data:{...n},type:"xhrResponse"}})},errorHook:(...n)=>{e({payload:{...t,data:{...n},type:"xhrError"}})}})}reportFetch(){const e=on(tn),t=nn();rn({requestHook:(...n)=>{e({payload:{...t,data:{...n},type:"fetchRequest"}})},responseHook:(...n)=>{e({payload:{...t,data:{...n},type:"fetchResponse"}})},errorHook:(...n)=>{e({payload:{...t,data:{...n},type:"fetchError"}})}})}reportError(){const e=on(tn),t=nn();Jt((...n)=>{e({payload:{...t,data:{...n},type:"error"}})})}reportConsole(){const e=on(tn),t=nn();jt((...n)=>{e({payload:{...t,data:{...n},type:"console"}})})}init=()=>{this.reportClick(),this.reportError(),this.reportFetch(),this.reportPerformance(),this.reportXhr()};initialize(){"undefined"==typeof window||window.ranlog||(window.ranlog=!0,this.init()),"undefined"==typeof process||process.ranlog||(process.ranlog=!0,this.init())}},dn=/* @__PURE__ */new Map([[100,"Continue"],[101,"Switching Protocols"],[102,"Processing"],[103,"Early Hints"],[200,"OK"],[201,"Created"],[202,"Accepted"],[203,"Non-Authoritative Information"],[204,"No Content"],[205,"Reset Content"],[206,"Partial Content"],[207,"Multi-Status"],[208,"Already Reported"],[226,"IM Used"],[300,"Multiple Choices"],[301,"Moved Permanently"],[302,"Found"],[303,"See Other"],[304,"Not Modified"],[305,"Use Proxy"],[307,"Temporary Redirect"],[308,"Permanent Redirect"],[400,"Bad Request"],[401,"Unauthorized"],[402,"Payment Required"],[403,"Forbidden"],[404,"Not Found"],[405,"Method Not Allowed"],[406,"Not Acceptable"],[407,"Proxy Authentication Required"],[408,"Request Timeout"],[409,"Conflict"],[410,"Gone"],[411,"Length Required"],[412,"Precondition Failed"],[413,"Payload Too Large"],[414,"URI Too Long"],[415,"Unsupported Media Type"],[416,"Range Not Satisfiable"],[417,"Expectation Failed"],[418,"I'm a Teapot"],[421,"Misdirected Request"],[422,"Unprocessable Entity"],[423,"Locked"],[424,"Failed Dependency"],[425,"Too Early"],[426,"Upgrade Required"],[428,"Precondition Required"],[429,"Too Many Requests"],[431,"Request Header Fields Too Large"],[451,"Unavailable For Legal Reasons"],[500,"Internal Server Error"],[501,"Not Implemented"],[502,"Bad Gateway"],[503,"Service Unavailable"],[504,"Gateway Timeout"],[505,"HTTP Version Not Supported"],[506,"Variant Also Negotiates"],[507,"Insufficient Storage"],[508,"Loop Detected"],[509,"Bandwidth Limit Exceeded"],[510,"Not Extended"],[511,"Network Authentication Required"]]),un={message:dn,code:function(e){const t=/* @__PURE__ */new Map;for(const[n,r]of e)t.set(r.toLowerCase(),n);return t}(dn),codes:function(e){const t=[];for(const[n,r]of e)t.push(n);return t}(dn),redirect:{300:!0,301:!0,302:!0,303:!0,305:!0,307:!0,308:!0},empty:{204:!0,205:!0,304:!0},retry:{502:!0,503:!0,504:!0}};function hn(e){if(!un.message.has(e))throw new Error("invalid status code: "+e);return un.message.get(e)}function ln(e){if("number"==typeof e)return hn(e);if("string"!=typeof e)throw new TypeError("code must be a number or string");const t=parseInt(e,10);return!isNaN(t)&&un.codes.includes(t)?hn(t):function(e){const t=e.toLowerCase();if(un.code.has(t),!un.code.has(t))throw new Error('invalid status message: "'+e+'"');return un.code.get(t)}(e)}var pn=class{current;queue;simultaneous;executed;total;constructor({simultaneous:e,total:t}){this.current=0,this.queue=[],this.simultaneous=e,this.executed=0,this.total=t}add=e=>{if("function"!=typeof e)return;this.queue.push(()=>new Promise((t,n)=>{this.current++,e().then(t).catch(n).finally(()=>{this.current--,this.running()})}))};running=()=>new Promise((e,t)=>{if(this.current<=this.simultaneous&&this.queue.length){const n=this.queue.pop();n&&n().then(e).catch(t).finally(()=>{this.executed++})}else e({})});allSettled=()=>{let e=0;return new Promise((t,n)=>{const r=[];if(this.current<this.simultaneous&&this.queue.length){const i=this.queue.pop();e++,i&&i().then(n=>{r[e]=n,t(n)}).catch(t=>{r[e]=t,n(t)}).finally(()=>{this.executed++})}this.executed>=this.total&&t(r)})}},mn=(e,t,n)=>{const r=(e=Array.isArray(e)?e:[e]).map(e=>{let n;if(e.toLowerCase().endsWith(".css")){const t=document.createElement("link");t.type="text/css",t.rel="stylesheet",t.href=e,n=t}else n=document.createElement("script"),n.type="text/javascript",n.src=e;const r=document.getElementsByTagName("body")[0];return(t||r).appendChild(n),new Promise(e=>{n.onload=()=>{e()}})});return new Promise(e=>{Promise.all(r).then(()=>{n&&n(),e()})})};export{P as $,Oe as A,c as At,ie as B,jt as C,b as Ct,Pt as D,l as Dt,xt as E,m as Et,oe as F,X as G,ue as H,ae as I,Q as J,J as K,le as L,Ae as M,o as Mt,Se as N,d as Nt,Ue as O,s as Ot,pe as P,G as Q,se as R,Nt as S,S as St,It as T,f as Tt,re as U,ce as V,V as W,ne as X,Y,F as Z,Gt as _,E as _t,cn as a,O as at,_t as b,A as bt,rn as c,T as ct,en as d,D as dt,B as et,Zt as f,j as ft,Kt as g,R as gt,Xt as h,te as ht,un as i,k as it,ve as j,a as jt,Ee as k,u as kt,nn as l,U as lt,Jt as m,K as mt,pn as n,N as nt,sn as o,H as ot,Qt as p,_ as pt,W as q,ln as r,z as rt,on as s,M as st,mn as t,ee as tt,tn as u,L as ut,qt as v,v as vt,zt as w,g as wt,$t as x,C as xt,Wt as y,y as yt,de as z};
|