@shgysk8zer0/polyfills 0.3.0 → 0.3.2
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/CHANGELOG.md +19 -0
- package/README.md +1 -1
- package/all.min.js +14 -14
- package/all.min.js.map +1 -1
- package/array.js +336 -234
- package/assets/SanitizerConfigW3C.js +215 -631
- package/assets/sanitizerUtils.js +17 -4
- package/element.js +117 -0
- package/iterator.js +39 -0
- package/math.js +61 -56
- package/package.json +1 -1
- package/popover.css +25 -0
- package/popover.js +118 -0
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [v0.3.2] - 2024-03-09
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- WIP implementation of the [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
|
|
13
|
+
- Add `Array.isTemplateObject()`
|
|
14
|
+
- Add `Iterator.prototype.chunks()`
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- Allow `blob:` URIs and `data-` attributes in sanitizer
|
|
18
|
+
|
|
19
|
+
## [v0.3.1] - 2024-01-31
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
- Add `Uint8Array` base64 + hex proposed methods
|
|
23
|
+
- Add `Math.sum()`
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
- Allow `data-*` attributes in sanitizer config
|
|
27
|
+
|
|
9
28
|
## [v0.3.0] - 2024-01-06
|
|
10
29
|
|
|
11
30
|
### Added
|
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ for features including `AbortSignal`, `CookieStore`, `Sanitizer`, and many more.
|
|
|
15
15
|
|
|
16
16
|
[](https://www.npmjs.com/package/@shgysk8zer0/polyfills)
|
|
17
17
|
<!--  -->
|
|
18
|
-

|
|
19
19
|
[](https://www.npmjs.com/package/@shgysk8zer0/polyfills)
|
|
20
20
|
|
|
21
21
|
[](https://github.com/shgysk8zer0)
|
package/all.min.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
!function(){"use strict";function e(e,t,n,{writable:r=!0,enumerable:o=!0,configurable:i=!0}={}){e[t]instanceof Function||Object.defineProperty(e,t,{value:n,writable:r,enumerable:o,configurable:i})}function t(e,t,{get:n,set:r,enumerable:o=!0,configurable:i=!0}={}){e.hasOwnProperty(t)||Object.defineProperty(e,t,{get:n,set:r,enumerable:o,configurable:i})}!function(){"undefined"==typeof globalThis&&("undefined"!=typeof window?Object.defineProperty(Window.prototype,"globalThis",{enumerable:!1,writable:!0,configurable:!0,value:window}):"undefined"!=typeof global?Object.defineProperty(global,"globalThis",{enumerable:!1,writable:!0,configurable:!0,value:global}):"undefined"!=typeof self?Object.defineProperty(self,"globalThis",{enumerable:!1,writable:!0,configurable:!0,value:self}):Object.defineProperty(this,"globalThis",{enumerable:!1,writable:!0,configurable:!0,value:this}))}(),!("crypto"in window)&&"msCrypto"in window&&(globalThis.crypto=globalThis.msCrypto),"Notification"in window||(globalThis.Notification=globalThis.notifications||globalThis.webkitNotifications||globalThis.oNotifications||globalThis.msNotifications||!1),"doNotTrack"in navigator||(navigator.doNotTrack=globalThis.doNotTrack||navigator.msDoNotTrack||"unspecified"),"indexedDB"in window||(globalThis.indexedDB=globalThis.indexedDB||globalThis.mozIndexedDB||globalThis.webkitIndexedDB||globalThis.msIndexedDB||!1),"hidden"in document||(document.hidden=document.webkitHidden||document.msHidden||document.mozHidden||!1),"visibilityState"in document||(document.visibilityState=document.webkitVisibilityState||document.msVisibilityState||document.mozVisibilityState||"visible"),"fullscreenElement"in document||(document.fullscreenElement=document.mozFullScreenElement||document.webkitFullscreenElement||!1),"requestAnimationFrame"in window||(globalThis.requestAnimationFrame=globalThis.mozRequestAnimationFrame||globalThis.webkitRequestAnimationFrame||globalThis.msRequestAnimationFrame||!1),"exitFullscreen"in Document.prototype||(Document.prototype.exitFullscreen=document.mozCancelFullScreen||document.webkitCancelFullScreen||document.msCancelFullScreen||!1),"requestFullscreen"in HTMLElement.prototype||(HTMLElement.prototype.requestFullscreen=HTMLElement.prototype.requestFullScreen||HTMLElement.prototype.mozRequestFullScreen||HTMLElement.prototype.webkitRequestFullScreen||!1),"fullscreen"in Document.prototype||Object.defineProperty(Document.prototype,"fullscreen",{get:()=>document.fullscreenElement instanceof Element}),Object.groupBy instanceof Function||(Object.groupBy=function(e,t){return Array.from(e).reduce(((e,n,r)=>{const o=t.call(e,n,r);return e.hasOwnProperty(o)?e[o].push(n):e[o]=[n],e}),{})}),Map.prototype.emplace instanceof Function||(Map.prototype.emplace=function(e,{insert:t,update:n}={}){const r=this.has(e);if(r&&n instanceof Function){const t=this.get(e),r=n.call(this,t,e,this);return r!==t&&this.set(e,r),r}if(r)return this.get(e);if(t instanceof Function){const n=t.call(this,e,this);return this.set(e,n),n}throw new Error("Key is not found and no `insert()` given")}),Map.groupBy instanceof Function||(Map.groupBy=function(e,t){return Array.from(e).reduce(((e,n,r)=>(e.emplace(t.call(e,n,r),{insert:()=>[n],update:e=>(e.push(n),e)}),e)),new Map)}),function(){const e=[Array,String,globalThis.Int8Array,globalThis.Uint8Array,globalThis.Uint8ClampedArray,globalThis.Int16Array,globalThis.Uint16Array,globalThis.Int32Array,globalThis.Uint32Array,globalThis.Float32Array,globalThis.Float64Array,globalThis.BigInt64Array,globalThis.BigUint64Array];if(Array.prototype.flat instanceof Function||(Array.prototype.flat=function(e=1){const t=[];e=Math.min(Number.MAX_SAFE_INTEGER,Math.max(0,e));const n=(e,r)=>{Array.isArray(e)&&r>=0?e.forEach((e=>n(e,r-1))):t.push(e)};return n(this,Number.isNaN(e)?0:e),t}),Array.prototype.flatMap instanceof Function||(Array.prototype.flatMap=function(e,t){return this.map(e,t).flat(1)}),Array.prototype.findLast instanceof Function||(Array.prototype.findLast=function(e,t){let n;return this.forEach(((r,o,i)=>{e.call(t,r,o,i)&&(n=r)}),t),n}),"lastIndex"in Array.prototype||Object.defineProperty(Array.prototype,"lastIndex",{enumerable:!1,configurable:!1,get:function(){return Math.max(0,this.length-1)}}),"lastItem"in Array.prototype||Object.defineProperty(Array.prototype,"lastItem",{enumerable:!1,configurable:!1,get:function(){return this[this.lastIndex]},set:function(e){this[this.lastIndex]=e}}),Array.prototype.findLastIndex instanceof Function||(Array.prototype.findLastIndex=function(e,t){let n=-1;return this.forEach(((r,o,i)=>{e.call(t,r,o,i)&&(n=o)}),t),n}),!(Array.prototype.at instanceof Function)){const t=function(e){if((e=Math.trunc(e)||0)<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]};for(const n of e)void 0!==n&&Object.defineProperty(n.prototype,"at",{value:t,writable:!0,enumerable:!1,configurable:!0})}!(Array.prototype.group instanceof Function)&&Object.groupBy instanceof Function&&(Array.prototype.group=function(e){return console.warn("`Array.group()` is deprecated. Please use `Object.groupBy()` instead."),Object.groupBy(this,e)}),!(Array.prototype.groupBy instanceof Function)&&Object.groupBy instanceof Function&&(Array.prototype.groupBy=function(e){return console.warn("`Array.goupBy()` is deprecated. Please use `Object.groupBy()` instead."),Object.groupBy(this,e)}),!(Array.prototype.groupToMap instanceof Function)&&Map.groupBy instanceof Function&&(Array.prototype.groupToMap=function(e){return console.warn("`Array.groupToMap()` is deprecated. Please use `Map.groupBy()` instead."),Map.groupBy(this,e)}),Map.groupBy instanceof Function&&(Array.prototype.groupByToMap=function(e){return console.warn("`Array.groupByToMap()` is deprecated. Please use `Map.groupBy()` instead."),Map.groupBy(this,e)}),Array.fromAsync instanceof Function||(Array.fromAsync=async function(e,t,n=globalThis){let r=[];for await(const t of e)r.push(await t);return Array.from(r,t,n)}),Array.prototype.equals instanceof Function||(Array.prototype.equals=function(e){return this===e||!!Array.isArray(e)&&(this.length===e.length&&this.every(((t,n)=>{const r=e[n];return Array.isArray(t)?Array.isArray(r)&&t.equals(r):Object.is(t,r)})))}),Array.prototype.uniqueBy instanceof Function||(Array.prototype.uniqueBy=function(e){if(void 0===e)return[...new Set(this)];if("string"==typeof e){const t=[];return this.filter((n=>{const r=n[e];return!t.includes(r)&&(t.push(r),!0)}))}if(e instanceof Function){const t=[];return this.filter(((...n)=>{try{const r=e.apply(this,n);return"string"==typeof r&&(!t.includes(r)&&(t.push(r),!0))}catch(e){return!1}}))}throw new TypeError("Not a valid argument for uniqueBy")}),Array.prototype.toReversed instanceof Function||(Array.prototype.toReversed=function(){return[...this].reverse()}),Array.prototype.toSorted instanceof Function||(Array.prototype.toSorted=function(e){return[...this].sort(e)}),Array.prototype.toSpliced instanceof Function||(Array.prototype.toSpliced=function(e,t,...n){const r=[...this];return r.splice(e,t,...n),r}),Array.prototype.with instanceof Function||(Array.prototype.with=function(e,t){const n=[...this];return n[e]=t,n})}(),"Symbol"in globalThis&&(void 0===Symbol.toStringTag&&(Symbol.toStringTag=Symbol("Symbol.toStringTag")),void 0===Symbol.iterator&&(Symbol.iterator=Symbol("Symbol.iterator"))),function(){if(!(Function.prototype.once instanceof Function)){const e=new WeakMap;Function.prototype.once=function(t){const n=this;return function(...r){if(e.has(n))return e.get(n);if("AsyncFunction"===n.constructor.name){const o=n.apply(t||n,r).catch((t=>{throw e.delete(n),t}));return e.set(n,o),o}if(n instanceof Function){const o=n.apply(t||n,r);return e.set(n,o),o}}}}}(),e(URL,"canParse",((e,t)=>{try{return new URL(e,t),!0}catch{return!1}})),Number.range instanceof Function||(Number.range=function(e,t,n=1){return console.warn("`Number.range()` is deprecated. Use `Iterator.range()` instead."),globalThis.Iterator.range(e,t,{step:n})});const n="Iterator"in globalThis,r=n?Object.getPrototypeOf(globalThis.Iterator):Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())),o=n?globalThis.Iterator:(e=>{class t{[Symbol.iterator](){return this}}return Object.setPrototypeOf(t,e),t})(r);var i;o.range instanceof Function||(o.range=function(e,t,n){if("number"==typeof n||"bigint"==typeof n)return o.range(e,t,{step:n});if("object"!=typeof n||Object.is(n,null))return o.range(e,t,{});{const{step:r=("number"==typeof e?e<t?1:-1:e<t?1n:-1n),inclusive:i=!1}=n;if("number"!=typeof e&&"bigint"!=typeof e)throw new TypeError("Start must be a number");if(Number.isNaN(e))throw new RangeError("Invalid start");if("number"!=typeof t&&"bigint"!=typeof t)throw new TypeError("End must be a number");if(Number.isNaN(t))throw new RangeError("Invalid end");if("number"!=typeof r&&"bigint"!=typeof r)throw new TypeError("Step must be a number");if(Number.isNaN(r))throw new RangeError("Invalid step");if(0===r)throw new RangeError("Step must not be 0");if(r<0&&e<t||r>0&&e>t)return;if(i){let n=e;return r>0?o.from({next(){const e=n<=t?{value:n,done:!1}:{done:!0};return n+=r,e}}):o.from({next(){const e=n>=t?{value:n,done:!1}:{done:!0};return n+=r,e}})}{let n=e;if(r>0)return o.from({next(){const e=n<t?{value:n,done:!1}:{done:!0};return n+=r,e}});{let n=e;return o.from({next(){const e=n>t?{value:n,done:!1}:{done:!0};return n+=r,e}})}}}}),r[Symbol.toStringTag]||(r[Symbol.toStringTag]="Iterator"),r.take instanceof Function||(r.take=function(e){let t=0;const n=this;return o.from({next:()=>t++>=e?{done:!0}:n.next()})}),r.drop instanceof Function||(r.drop=function(e){for(let t=0;t<e;t++){const{done:e}=this.next();if(e)break}return this}),r.toArray instanceof Function||(r.toArray=function(){return Array.from(this)}),r.forEach instanceof Function||(r.forEach=function(e){for(const t of this)e.call(this,t)}),r.flatMap instanceof Function||(r.flatMap=function(e){const t=this;let n=this.next();const r=({value:n,done:r=!0}={})=>r?o.from({next:()=>({done:!0})}):o.from(e.call(t,n));let i=r(n);return o.from({next(){const{value:e,done:o=!0}=i.next();return n.done&&o?{done:!0}:o?n.done?{done:!0}:(n=t.next(),i=r(n),i.next()):{value:e,done:o}}})}),r.map instanceof Function||(r.map=function(e){const t=this;return o.from({next(){const{done:n,value:r}=t.next();return n?{done:n}:{value:e.call(t,r),done:!1}}})}),r.reduce instanceof Function||(r.reduce=function(e,t){let n=void 0===t?this.next().value:t;for(const t of this)n=e.call(this,n,t);return n}),r.filter instanceof Function||(r.filter=function(e){const t=this;let n,r=!1;return o.from({next(){for(;!r;){const o=t.next();if(r=o.done,r)break;if(e.call(t,o.value)){n=o.value;break}}return{done:r,value:n}}})}),r.some instanceof Function||(r.some=function(e){let t=!1;for(const n of this)if(e.call(this,n)){t=!0;break}return t}),r.every instanceof Function||(r.every=function(e){let t=!0;for(const n of this)if(!e.call(this,n)){t=!1;break}return t}),r.find instanceof Function||(r.find=function(e){for(const t of this)if(e.call(this,t))return t}),r.indexed instanceof Function||(r.indexed=function(){let e=0;return this.map((t=>[e++,t]))}),o.from instanceof Function||(o.from=function(e){if("object"!=typeof e||null===e)throw new TypeError("Not an object.");if(e.next instanceof Function){return Object.create(r,{next:{enumerable:!0,configurable:!1,writable:!1,value:(...t)=>e.next(...t)}})}if(e[Symbol.iterator]instanceof Function)return o.from(e[Symbol.iterator]())}),n||(globalThis.Iterator=o),Number.hasOwnProperty("isSafeInteger")||(Number.MAX_SAFE_INTEGER=2**53-1,Number.MIN_SAFE_INTEGER=-Number.MAX_SAFE_INTEGER,Number.isSafeInteger=e=>e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER),Number.hasOwnProperty("EPSILON")||(Number.EPSILON=2**-52),Math.hasOwnProperty("sign")||(Math.sign=e=>(e>0)-(e<0)||+e),Math.hasOwnProperty("trunc")||(Math.trunc=e=>{const t=e-e%1;return 0===t&&(e<0||0===e&&1/e!=1/0)?-0:t}),Math.hasOwnProperty("expm1")||(Math.expm1=e=>Math.exp(e)-1),Math.hasOwnProperty("hypot")||(Math.hypot=(...e)=>Math.sqrt(e.reduce(((e,t)=>e+t**2),0))),Math.hasOwnProperty("cbrt")||(Math.cbrt=e=>e**(1/3)),Math.hasOwnProperty("log10")||(Math.log10=e=>Math.log(e)*Math.LOG10E),Math.hasOwnProperty("log2")||(Math.log2=e=>Math.log(e)*Math.LOG2E),Math.hasOwnProperty("log1p")||(Math.log1p=e=>Math.log(1+e)),Math.hasOwnProperty("fround")||(Math.fround=(i=new Float32Array(1),function(e){return i[0]=e,i[0]})),Math.clamp instanceof Function||(Math.clamp=function(e,t,n){return Math.min(Math.max(e,t),n)}),Math.constrain instanceof Function||(Math.constrain=Math.clamp),function(){if(!("isSecureContext"in globalThis)){const e=["localhost","127.0.0.1"],t="https:",n=[t,"file:","wss:"],r=(e=globalThis.document)=>[...e.scripts].every((({src:n})=>{if(0===n.length)return!0;{const{protocol:r,hostname:o}=new URL(n,e.baseURI);return r===t||o===location.hostname}}));Object.defineProperty(globalThis,"isSecureContext",{enumerable:!0,configurable:!0,get:function(){return window.parent===window&&(!(!n.includes(location.protocol)&&!e.includes(location.hostname))&&r())}})}}();const a=new WeakMap;function s(e){return e instanceof Function&&"AsyncFunction"===e.constructor.name}function l(e){return"object"==typeof e&&!Object.is(e,null)&&!Array.isArray(e)}function c(e){switch(typeof e){case"undefined":return"Undefined";case"function":return"prototype"in e?c(e.prototype):"constructor"in e?e.constructor.name:"Function";case"object":return Object.is(e,null)?"Null":"constructor"in e?e.constructor.name:Symbol.toStringTag in e?e[Symbol.toStringTag]:"prototype"in e?c(e.prototype):(console.log(e),"Unknown Object");case"string":return"String";case"number":return Number.isNaN(e)?"NaN":"Number";case"bigint":return"BigInt";case"boolean":return"Boolean";case"symbol":return"Symbol";default:return"Unknown"}}function u(e,t){return e.once instanceof Function?e.once(t):function(...n){if(a.has(e))return a.get(e);if(s(e)){const r=e.apply(t||this,n).catch((t=>{throw a.delete(e),t}));return a.set(e,r),r}if(e instanceof Function){const r=e.apply(t||this,n);return a.set(e,r),r}}}
|
|
1
|
+
!function(){"use strict";!function(){"undefined"==typeof globalThis&&("undefined"!=typeof window?Object.defineProperty(Window.prototype,"globalThis",{enumerable:!1,writable:!0,configurable:!0,value:window}):"undefined"!=typeof global?Object.defineProperty(global,"globalThis",{enumerable:!1,writable:!0,configurable:!0,value:global}):"undefined"!=typeof self?Object.defineProperty(self,"globalThis",{enumerable:!1,writable:!0,configurable:!0,value:self}):Object.defineProperty(this,"globalThis",{enumerable:!1,writable:!0,configurable:!0,value:this}))}(),!("crypto"in window)&&"msCrypto"in window&&(globalThis.crypto=globalThis.msCrypto),"Notification"in window||(globalThis.Notification=globalThis.notifications||globalThis.webkitNotifications||globalThis.oNotifications||globalThis.msNotifications||!1),"doNotTrack"in navigator||(navigator.doNotTrack=globalThis.doNotTrack||navigator.msDoNotTrack||"unspecified"),"indexedDB"in window||(globalThis.indexedDB=globalThis.indexedDB||globalThis.mozIndexedDB||globalThis.webkitIndexedDB||globalThis.msIndexedDB||!1),"hidden"in document||(document.hidden=document.webkitHidden||document.msHidden||document.mozHidden||!1),"visibilityState"in document||(document.visibilityState=document.webkitVisibilityState||document.msVisibilityState||document.mozVisibilityState||"visible"),"fullscreenElement"in document||(document.fullscreenElement=document.mozFullScreenElement||document.webkitFullscreenElement||!1),"requestAnimationFrame"in window||(globalThis.requestAnimationFrame=globalThis.mozRequestAnimationFrame||globalThis.webkitRequestAnimationFrame||globalThis.msRequestAnimationFrame||!1),"exitFullscreen"in Document.prototype||(Document.prototype.exitFullscreen=document.mozCancelFullScreen||document.webkitCancelFullScreen||document.msCancelFullScreen||!1),"requestFullscreen"in HTMLElement.prototype||(HTMLElement.prototype.requestFullscreen=HTMLElement.prototype.requestFullScreen||HTMLElement.prototype.mozRequestFullScreen||HTMLElement.prototype.webkitRequestFullScreen||!1),"fullscreen"in Document.prototype||Object.defineProperty(Document.prototype,"fullscreen",{get:()=>document.fullscreenElement instanceof Element}),Object.groupBy instanceof Function||(Object.groupBy=function(e,t){return Array.from(e).reduce(((e,n,r)=>{const o=t.call(e,n,r);return e.hasOwnProperty(o)?e[o].push(n):e[o]=[n],e}),{})}),Map.prototype.emplace instanceof Function||(Map.prototype.emplace=function(e,{insert:t,update:n}={}){const r=this.has(e);if(r&&n instanceof Function){const t=this.get(e),r=n.call(this,t,e,this);return r!==t&&this.set(e,r),r}if(r)return this.get(e);if(t instanceof Function){const n=t.call(this,e,this);return this.set(e,n),n}throw new Error("Key is not found and no `insert()` given")}),Map.groupBy instanceof Function||(Map.groupBy=function(e,t){return Array.from(e).reduce(((e,n,r)=>(e.emplace(t.call(e,n,r),{insert:()=>[n],update:e=>(e.push(n),e)}),e)),new Map)});const e=[Array,String,globalThis.Int8Array,globalThis.Uint8Array,globalThis.Uint8ClampedArray,globalThis.Int16Array,globalThis.Uint16Array,globalThis.Int32Array,globalThis.Uint32Array,globalThis.Float32Array,globalThis.Float64Array,globalThis.BigInt64Array,globalThis.BigUint64Array];if(Array.prototype.flat instanceof Function||(Array.prototype.flat=function(e=1){const t=[];e=Math.min(Number.MAX_SAFE_INTEGER,Math.max(0,e));const n=(e,r)=>{Array.isArray(e)&&r>=0?e.forEach((e=>n(e,r-1))):t.push(e)};return n(this,Number.isNaN(e)?0:e),t}),Array.prototype.flatMap instanceof Function||(Array.prototype.flatMap=function(e,t){return this.map(e,t).flat(1)}),Array.prototype.findLast instanceof Function||(Array.prototype.findLast=function(e,t){let n;return this.forEach(((r,o,i)=>{e.call(t,r,o,i)&&(n=r)}),t),n}),"lastIndex"in Array.prototype||Object.defineProperty(Array.prototype,"lastIndex",{enumerable:!1,configurable:!1,get:function(){return Math.max(0,this.length-1)}}),"lastItem"in Array.prototype||Object.defineProperty(Array.prototype,"lastItem",{enumerable:!1,configurable:!1,get:function(){return this[this.lastIndex]},set:function(e){this[this.lastIndex]=e}}),Array.prototype.findLastIndex instanceof Function||(Array.prototype.findLastIndex=function(e,t){let n=-1;return this.forEach(((r,o,i)=>{e.call(t,r,o,i)&&(n=o)}),t),n}),!(Array.prototype.at instanceof Function)){const De=function(e){if((e=Math.trunc(e)||0)<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]};for(const Re of e)void 0!==Re&&Object.defineProperty(Re.prototype,"at",{value:De,writable:!0,enumerable:!1,configurable:!0})}function t(e,t,n,{writable:r=!0,enumerable:o=!0,configurable:i=!0}={}){e[t]instanceof Function||Object.defineProperty(e,t,{value:n,writable:r,enumerable:o,configurable:i})}function n(e,t,{get:n,set:r,enumerable:o=!0,configurable:i=!0}={}){e.hasOwnProperty(t)||Object.defineProperty(e,t,{get:n,set:r,enumerable:o,configurable:i})}!(Array.prototype.group instanceof Function)&&Object.groupBy instanceof Function&&(Array.prototype.group=function(e){return console.warn("`Array.group()` is deprecated. Please use `Object.groupBy()` instead."),Object.groupBy(this,e)}),!(Array.prototype.groupBy instanceof Function)&&Object.groupBy instanceof Function&&(Array.prototype.groupBy=function(e){return console.warn("`Array.goupBy()` is deprecated. Please use `Object.groupBy()` instead."),Object.groupBy(this,e)}),!(Array.prototype.groupToMap instanceof Function)&&Map.groupBy instanceof Function&&(Array.prototype.groupToMap=function(e){return console.warn("`Array.groupToMap()` is deprecated. Please use `Map.groupBy()` instead."),Map.groupBy(this,e)}),Map.groupBy instanceof Function&&(Array.prototype.groupByToMap=function(e){return console.warn("`Array.groupByToMap()` is deprecated. Please use `Map.groupBy()` instead."),Map.groupBy(this,e)}),Array.fromAsync instanceof Function||(Array.fromAsync=async function(e,t,n=globalThis){let r=[];for await(const t of e)r.push(await t);return Array.from(r,t,n)}),Array.prototype.equals instanceof Function||(Array.prototype.equals=function(e){return this===e||!!Array.isArray(e)&&(this.length===e.length&&this.every(((t,n)=>{const r=e[n];return Array.isArray(t)?Array.isArray(r)&&t.equals(r):Object.is(t,r)})))}),Array.prototype.uniqueBy instanceof Function||(Array.prototype.uniqueBy=function(e){if(void 0===e)return[...new Set(this)];if("string"==typeof e){const t=[];return this.filter((n=>{const r=n[e];return!t.includes(r)&&(t.push(r),!0)}))}if(e instanceof Function){const t=[];return this.filter(((...n)=>{try{const r=e.apply(this,n);return"string"==typeof r&&(!t.includes(r)&&(t.push(r),!0))}catch(e){return!1}}))}throw new TypeError("Not a valid argument for uniqueBy")}),Array.prototype.toReversed instanceof Function||(Array.prototype.toReversed=function(){return[...this].reverse()}),Array.prototype.toSorted instanceof Function||(Array.prototype.toSorted=function(e){return[...this].sort(e)}),Array.prototype.toSpliced instanceof Function||(Array.prototype.toSpliced=function(e,t,...n){const r=[...this];return r.splice(e,t,...n),r}),Array.prototype.with instanceof Function||(Array.prototype.with=function(e,t){const n=[...this];return n[e]=t,n}),Array.isTemplateObject instanceof Function||(Array.isTemplateObject=function(e){return!!(Array.isArray(e)&&Array.isArray(e.raw)&&Object.isFrozen(e)&&Object.isFrozen(e.raw))&&(0!==e.length&&e.length===e.raw.length)}),Uint8Array.prototype.toHex instanceof Function||(Uint8Array.prototype.toHex=function(){return Array.from(this).map((e=>e.toString(16).padStart("0",2))).join("")}),Uint8Array.prototype.toBase64 instanceof Function||(Uint8Array.prototype.toBase64=function({alphabet:e="base64"}={}){if("base64"===e)return btoa(String.fromCodePoint(...this));if("base64url"===e)return this.toBase64({alphabet:"base64"}).replaceAll("+","-").replaceAll("/","_");throw new TypeError('expected alphabet to be either "base64" or "base64url')}),Uint8Array.fromHex instanceof Function||(Uint8Array.fromHex=function(e){if("string"!=typeof e)throw new TypeError("expected input to be a string");if(0===!(1&e.length))throw new SyntaxError("string should be an even number of characters");return Uint8Array.from(globalThis.Iterator.range(0,e.length,{step:2}),(t=>parseInt(e.substring(t,t+2),16)))}),Uint8Array.fromBase64 instanceof Function||(Uint8Array.fromBase64=function(e,{alphabet:t="base64",lastChunkHandling:n="loose"}={}){if("string"!=typeof e)throw new TypeError("expected input to be a string");if(!["base64","base64url"].includes(t))throw new TypeError('expected alphabet to be either "base64" or "base64url');if(!["loose","strict","stop-before-partial"].includes(n))throw new TypeError(`Invalid \`lastChunkHandling\`: "${n}".`);if("base64"!==t)return Uint8Array.fromBase64(e.replaceAll("-","+").replaceAll("_","/"),{alphabet:"base64"});{const t=e.length%4;if(1===t)throw new TypeError("Invalid string length.");if(0===t)return(new TextEncoder).encode(atob(e));switch(n){case"strict":throw new SyntaxError("Missing padding.");case"loose":return Uint8Array.fromBase64(e.padEnd(e.length+(4-t),"="),{alphabet:"base64",lastChunkHandling:"strict"});case"stop-before-partial":return Uint8Array.fromBase64(e.slice(0,e.length-t),{alphabet:"base64",lastChunkHandling:"strict"})}}}),"Symbol"in globalThis&&(void 0===Symbol.toStringTag&&(Symbol.toStringTag=Symbol("Symbol.toStringTag")),void 0===Symbol.iterator&&(Symbol.iterator=Symbol("Symbol.iterator"))),function(){if(!(Function.prototype.once instanceof Function)){const e=new WeakMap;Function.prototype.once=function(t){const n=this;return function(...r){if(e.has(n))return e.get(n);if("AsyncFunction"===n.constructor.name){const o=n.apply(t||n,r).catch((t=>{throw e.delete(n),t}));return e.set(n,o),o}if(n instanceof Function){const o=n.apply(t||n,r);return e.set(n,o),o}}}}}(),t(URL,"canParse",((e,t)=>{try{return new URL(e,t),!0}catch{return!1}})),Number.range instanceof Function||(Number.range=function(e,t,n=1){return console.warn("`Number.range()` is deprecated. Use `Iterator.range()` instead."),globalThis.Iterator.range(e,t,{step:n})});const r="Iterator"in globalThis,o=r?Object.getPrototypeOf(globalThis.Iterator):Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())),i=r?globalThis.Iterator:(e=>{class t{[Symbol.iterator](){return this}}return Object.setPrototypeOf(t,e),t})(o);var a;i.range instanceof Function||(i.range=function(e,t,n){if("number"==typeof n||"bigint"==typeof n)return i.range(e,t,{step:n});if("object"!=typeof n||Object.is(n,null))return i.range(e,t,{});{const{step:r=("number"==typeof e?e<t?1:-1:e<t?1n:-1n),inclusive:o=!1}=n;if("number"!=typeof e&&"bigint"!=typeof e)throw new TypeError("Start must be a number");if(Number.isNaN(e))throw new RangeError("Invalid start");if("number"!=typeof t&&"bigint"!=typeof t)throw new TypeError("End must be a number");if(Number.isNaN(t))throw new RangeError("Invalid end");if("number"!=typeof r&&"bigint"!=typeof r)throw new TypeError("Step must be a number");if(Number.isNaN(r))throw new RangeError("Invalid step");if(0===r)throw new RangeError("Step must not be 0");if(r<0&&e<t||r>0&&e>t)return;if(o){let n=e;return r>0?i.from({next(){const e=n<=t?{value:n,done:!1}:{done:!0};return n+=r,e}}):i.from({next(){const e=n>=t?{value:n,done:!1}:{done:!0};return n+=r,e}})}{let n=e;if(r>0)return i.from({next(){const e=n<t?{value:n,done:!1}:{done:!0};return n+=r,e}});{let n=e;return i.from({next(){const e=n>t?{value:n,done:!1}:{done:!0};return n+=r,e}})}}}}),o[Symbol.toStringTag]||(o[Symbol.toStringTag]="Iterator"),o.take instanceof Function||(o.take=function(e){let t=0;const n=this;return i.from({next:()=>t++>=e?{done:!0}:n.next()})}),o.drop instanceof Function||(o.drop=function(e){for(let t=0;t<e;t++){const{done:e}=this.next();if(e)break}return this}),o.toArray instanceof Function||(o.toArray=function(){return Array.from(this)}),o.forEach instanceof Function||(o.forEach=function(e){for(const t of this)e.call(this,t)}),o.flatMap instanceof Function||(o.flatMap=function(e){const t=this;let n=this.next();const r=({value:n,done:r=!0}={})=>r?i.from({next:()=>({done:!0})}):i.from(e.call(t,n));let o=r(n);return i.from({next(){const{value:e,done:i=!0}=o.next();return n.done&&i?{done:!0}:i?n.done?{done:!0}:(n=t.next(),o=r(n),o.next()):{value:e,done:i}}})}),o.map instanceof Function||(o.map=function(e){const t=this;return i.from({next(){const{done:n,value:r}=t.next();return n?{done:n}:{value:e.call(t,r),done:!1}}})}),o.reduce instanceof Function||(o.reduce=function(e,t){let n=void 0===t?this.next().value:t;for(const t of this)n=e.call(this,n,t);return n}),o.filter instanceof Function||(o.filter=function(e){const t=this;let n,r=!1;return i.from({next(){for(;!r;){const o=t.next();if(r=o.done,r)break;if(e.call(t,o.value)){n=o.value;break}}return{done:r,value:n}}})}),o.some instanceof Function||(o.some=function(e){let t=!1;for(const n of this)if(e.call(this,n)){t=!0;break}return t}),o.every instanceof Function||(o.every=function(e){let t=!0;for(const n of this)if(!e.call(this,n)){t=!1;break}return t}),o.find instanceof Function||(o.find=function(e){for(const t of this)if(e.call(this,t))return t}),o.indexed instanceof Function||(o.indexed=function(){let e=0;return this.map((t=>[e++,t]))}),o.chunks instanceof Function||(o.chunks=function(e){if(!Number.isSafeInteger(e)||e<1)throw new TypeError("Size must be a positive integer.");{const t=this;let n=!1;return i.from({next(){if(n)return{done:n};{const r=[];let o=0;for(;o++<e&&!n;){const e=t.next();if(e.done){n=!0,void 0!==e.value&&r.push(e.value);break}r.push(e.value)}return{value:r,done:!1}}}})}}),i.from instanceof Function||(i.from=function(e){if("object"!=typeof e||null===e)throw new TypeError("Not an object.");if(e.next instanceof Function){return Object.create(o,{next:{enumerable:!0,configurable:!1,writable:!1,value:(...t)=>e.next(...t)}})}if(e[Symbol.iterator]instanceof Function)return i.from(e[Symbol.iterator]())}),r||(globalThis.Iterator=i),Number.hasOwnProperty("isSafeInteger")||(Number.MAX_SAFE_INTEGER=2**53-1,Number.MIN_SAFE_INTEGER=-Number.MAX_SAFE_INTEGER,Number.isSafeInteger=e=>e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER),Number.hasOwnProperty("EPSILON")||(Number.EPSILON=2**-52),Math.hasOwnProperty("sign")||(Math.sign=e=>(e>0)-(e<0)||+e),Math.hasOwnProperty("trunc")||(Math.trunc=e=>{const t=e-e%1;return 0===t&&(e<0||0===e&&1/e!=1/0)?-0:t}),Math.hasOwnProperty("expm1")||(Math.expm1=e=>Math.exp(e)-1),Math.hasOwnProperty("hypot")||(Math.hypot=(...e)=>Math.sqrt(e.reduce(((e,t)=>e+t**2),0))),Math.hasOwnProperty("cbrt")||(Math.cbrt=e=>e**(1/3)),Math.hasOwnProperty("log10")||(Math.log10=e=>Math.log(e)*Math.LOG10E),Math.hasOwnProperty("log2")||(Math.log2=e=>Math.log(e)*Math.LOG2E),Math.hasOwnProperty("log1p")||(Math.log1p=e=>Math.log(1+e)),Math.hasOwnProperty("fround")||(Math.fround=(a=new Float32Array(1),function(e){return a[0]=e,a[0]})),Math.clamp instanceof Function||(Math.clamp=function(e,t,n){return Math.min(Math.max(e,t),n)}),Math.constrain instanceof Function||(Math.constrain=Math.clamp),Math.sum instanceof Function||(Math.sum=function(...e){return e.map((e=>parseFloat(e))).reduce(((e,t)=>e+t))}),function(){if(!("isSecureContext"in globalThis)){const e=["localhost","127.0.0.1"],t="https:",n=[t,"file:","wss:"],r=(e=globalThis.document)=>[...e.scripts].every((({src:n})=>{if(0===n.length)return!0;{const{protocol:r,hostname:o}=new URL(n,e.baseURI);return r===t||o===location.hostname}}));Object.defineProperty(globalThis,"isSecureContext",{enumerable:!0,configurable:!0,get:function(){return window.parent===window&&(!(!n.includes(location.protocol)&&!e.includes(location.hostname))&&r())}})}}();const s=new WeakMap;function l(e){return e instanceof Function&&"AsyncFunction"===e.constructor.name}function c(e){return"object"==typeof e&&!Object.is(e,null)&&!Array.isArray(e)}function u(e){switch(typeof e){case"undefined":return"Undefined";case"function":return"prototype"in e?u(e.prototype):"constructor"in e?e.constructor.name:"Function";case"object":return Object.is(e,null)?"Null":"constructor"in e?e.constructor.name:Symbol.toStringTag in e?e[Symbol.toStringTag]:"prototype"in e?u(e.prototype):(console.log(e),"Unknown Object");case"string":return"String";case"number":return Number.isNaN(e)?"NaN":"Number";case"bigint":return"BigInt";case"boolean":return"Boolean";case"symbol":return"Symbol";default:return"Unknown"}}function p(e,t){return e.once instanceof Function?e.once(t):function(...n){if(s.has(e))return s.get(e);if(l(e)){const r=e.apply(t||this,n).catch((t=>{throw s.delete(e),t}));return s.set(e,r),r}if(e instanceof Function){const r=e.apply(t||this,n);return s.set(e,r),r}}}
|
|
2
2
|
/**
|
|
3
3
|
* @copyright 2023 Chris Zuber <admin@kernvalley.us>
|
|
4
4
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Lock
|
|
5
|
-
*/const
|
|
5
|
+
*/const d=new WeakMap;class f{constructor(e,t="exclusive"){if(!["exclusive","shared"].includes(t))throw new TypeError(`'${t}' (value of 'mode' member of LockOptions) is not a valid value for enumeration LockMode.`);if("string"!=typeof e&&(e=e.toString()),e.startsWith("-"))throw new DOMException("Names starting with `-` are reserved");d.set(this,{name:e,mode:t})}get name(){return d.get(this).name}get mode(){return d.get(this).mode}}
|
|
6
6
|
/**
|
|
7
7
|
* @copyright 2023 Chris Zuber <admin@kernvalley.us>
|
|
8
|
-
*/const f=new Map,m=Symbol("lock-key"),h="locks"in navigator&&navigator.locks.request instanceof Function;const y=async function(){return await new Promise((e=>{"locks"in navigator&&navigator.locks.request instanceof Function?navigator.locks.query().then((()=>e(!0))).catch((()=>e(!1))):e(!1)}))}();async function b(e,t=null){return new Promise(((n,r)=>{var o;s(o=e)||o instanceof Promise?e.call(globalThis,t).then(n,r):queueMicrotask((()=>{try{const r=e.call(globalThis,t);n(r)}catch(e){r(e)}}))}))}async function g(e){f.has(e)&&await f.get(e).promise.catch(console.error)}function w(e,t,n){const{resolve:r,reject:o,promise:i}=function(){if(Promise.withResolvers instanceof Function)return Promise.withResolvers();{const e={};return e.promise=new Promise(((t,n)=>{e.resolve=t,e.reject=n})),e}}(),a=new AbortController,s=new d(e,t),l=function({name:e,mode:t}){switch(t){case"exclusive":return v().some((t=>t.name===e));case"shared":return v().some((t=>t.name===e&&"exclusive"===t.mode))}}(s);return f.set(s,{resolve:r,reject:o,promise:i,callback:n,pending:l,controller:a}),s}function T(e){return e instanceof d&&f.has(e)&&f.get(e).pending}function v(e){return"string"==typeof e?[...f.keys()].filter((t=>t.name===e)):[...f.keys()]}function E(e){return v(e).filter((e=>!T(e)))}function S(e){return v(e).filter((e=>T(e)))}async function A(e){switch(e.mode){case"exclusive":await Promise.allSettled(v().filter((t=>t.name===e.name&&t!==e)).map(g));break;case"shared":await Promise.allSettled(v().filter((t=>t.name===e.name&&"exclusive"===t.mode&&t!==e)).map(g))}}function M(e){if(f.has(e))return f.get(e).controller.signal}async function O(e){if(f.has(e)){const{resolve:t,reject:n,promise:r,callback:o,pending:i,controller:a}=f.get(e);return i&&function(e,t=!0){f.has(e)&&f.set(e,{...f.get(e),pending:t})}(e,!1),b(o,e).then(t,n).finally((()=>{f.delete(e),requestIdleCallback((()=>a.abort()))})),r}}class L{constructor(e){if(e!==m)throw new TypeError("Invalid constructor")}static async request(e,...t){let n,r={};t[0]instanceof Function?n=t[0]:t[1]instanceof Function&&([r,n]=t),"string"!=typeof e&&(e=e.toString());const{mode:o="exclusive",ifAvailable:i=!1,steal:a=!1,signal:s}=r;if(a&&i)throw new DOMException("LockManager.request: `steal` and `ifAvailable` cannot be used together");if(e.startsWith("-"))throw new DOMException("LockManager.request: Names starting with `-` are reserved");if(!["exclusive","shared"].includes(o))throw new TypeError(`LockManager.request: '${o}' (value of 'mode' member of LockOptions) is not a valid value for enumeration LockMode.`);if(s instanceof AbortSignal&&s.aborted)throw s.reason;if("shared"===o&&a)throw new DOMException("LockManager.request: `steal` is only supported for exclusive lock requests");const l=E(e),c=S(e),u=[...l,...c].some((t=>t.name===e));a&&u&&function(e){[...f.entries()].filter((([t])=>t.name===e)).forEach((([e,{reject:t,controller:n}])=>{requestIdleCallback((()=>{n.abort(),f.delete(e)})),t(new DOMException("The lock request is aborted"))}))}(e);const p=w(e,o,n);switch(s instanceof AbortSignal&&s.addEventListener("abort",(()=>{if(f.has(p)){const{reject:e,controller:t}=f.get(p);f.delete(p),e(new DOMException("The lock request is aborted")),t.abort()}}),{once:!0,signal:M(p)}),o){case"exclusive":if(!i||0===l.length&&0===c.length)return await A(p),await O(p);{const e=f.get(p).controller;return f.delete(p),await b(n,null).then((t=>(requestIdleCallback((()=>e.abort())),t)))}case"shared":if(i){if([...l,...c].some((e=>"exclusive"===e.mode))){const e=f.get(p).controller;return f.delete(p),await b(n,null).then((t=>(requestIdleCallback((()=>e.abort())),t)))}return await A(p),await O(p)}return await A(p),await O(p);default:throw new TypeError(`LockManager.request: '${o}' (value of 'mode' member of LockOptions) is not a valid value for enumeration LockMode.`)}}static async query(){return{held:E().map((({name:e,mode:t})=>({name:e,mode:t,clientId:null}))),pending:S().map((({name:e,mode:t})=>({name:e,mode:t,clientId:null})))}}}function F(e,t="error"){if(e instanceof Error){const{message:n,name:r,fileName:o,lineNumber:i,columnNumber:a}=e;return new ErrorEvent(t,{error:e,message:`${r}: ${n}`,filename:o,lineno:i,colno:a})}throw new TypeError("`errorToEvent()` only accepts Errors")}let x=!1;new Promise((async e=>{if(h)if(await y)e(!1);else try{navigator.locks.request=L.request,navigator.locks.query=L.query,x=!0,e(!0)}catch(t){globalThis.dispatchEvent(F(t)),e(!1)}else try{navigator.locks=L,x=!0,e(!0)}catch(t){globalThis.dispatchEvent(F(t)),e(!1)}})),navigator.canShare instanceof Function||(navigator.canShare=function({title:e,text:t,url:n,files:r}={}){return navigator.share instanceof Function&&(!Array.isArray(r)||0===r.length)&&(!![e,t,n].every((e=>void 0===e))||[e,t,n].some((e=>"string"==typeof e&&0!==e.length)))}),navigator.setAppBadge instanceof Function||(navigator.setAppBadge=async e=>{if(!Number.isInteger(e))throw new TypeError("Failed to execute 'setAppBadge' on 'Navigator': Value is not of type 'unsigned long long'");if(e<0)throw new TypeError("Failed to execute 'setAppBadge' on 'Navigator': Value is outside the 'unsigned long long' value range.");0===e?document.title.startsWith("(")&&(document.title=document.title.replace(/^\((\d{1,2}\+?)\)\s/,"")):e<100?(await navigator.clearAppBadge(),document.title=`(${e}) ${document.title}`):(await navigator.clearAppBadge(),document.title=`(99+) ${document.title}`)}),navigator.clearAppBadge instanceof Function||(navigator.clearAppBadge=()=>navigator.setAppBadge(0)),Navigator.prototype.hasOwnProperty("pdfViewerEnabled")||Object.defineProperty(navigator,"pdfViewerEnabled",{enumerable:!0,configurable:!1,writable:!1,value:!1}),Navigator.prototype.getInstalledRelatedApps instanceof Function||(Navigator.prototype.getInstalledRelatedApps=async()=>[]),Navigator.prototype.getGamepads instanceof Function||(Navigator.prototype.getGamepads=()=>[]),"hardwareConcurrency"in Navigator.prototype||Object.defineProperty(Navigator.prototype,"hardwareConcurrency",{get:()=>1}),"connection"in Navigator.prototype?"type"in navigator.connection||(navigator.connection.type="unknown"):Object.defineProperty(Navigator.prototype,"connection",{get:()=>Object.create(EventTarget.prototype,{type:{value:"unknown"},effectiveType:{value:"4g"},rtt:{value:NaN},downlink:{value:NaN},downlinkMax:{value:1/0},saveData:{value:!1},onchange:{value:null,writable:!0},ontypechange:{value:null,writable:!0}})}),"doNotTrack"in Navigator.prototype||Object.defineProperty(Navigator.prototype,"doNotTrack",{get:()=>"unspecified"}),"globalPrivacyControl"in Navigator.prototype||Object.defineProperty(Navigator.prototype,"globalPrivacyControl",{get:()=>!1}),function(){if(!(globalThis.requestIdleCallback instanceof Function)){const e=e=>Number.isSafeInteger(e)&&e>0;globalThis.requestIdleCallback=function(t,{timeout:n}={}){const r=performance.now(),o=()=>e(n)?Math.max(0,n-(performance.now()-r)):Math.max(0,600-(performance.now()-r));return setTimeout((()=>t({didTimeout:!!e(n)&&0===o(),timeRemaining:o})),1)}}globalThis.cancelIdleCallback instanceof Function||(globalThis.cancelIdleCallback=e=>clearTimeout(e)),globalThis.requestAnimationFrame instanceof Function||(globalThis.requestAnimationFrame=e=>setTimeout((()=>e(performance.now())),1e3/60)),globalThis.cancelAnimationFrame instanceof Function||(globalThis.cancelAnimationFrame=e=>clearTimeout(e)),globalThis.queueMicrotask instanceof Function||(globalThis.queueMicrotask=e=>Promise.resolve().then(e).catch((e=>setTimeout((()=>{throw e})))))}(),function(){if(!("AbortSignal"in globalThis)){const e={signal:Symbol("signal"),aborted:Symbol("aborted"),reason:Symbol("reason"),onabort:Symbol("onabort")};globalThis.AbortError=class extends Error{},globalThis.AbortSignal=class t extends EventTarget{constructor(){super(),Object.defineProperties(this,{[e.aborted]:{enumerable:!1,writable:!0,configurable:!1,value:!1},[e.reason]:{enumerable:!1,writable:!0,configurable:!1,value:void 0},[e.onabort]:{enumerable:!1,writable:!0,configurable:!1,value:null}}),this.addEventListener("abort",(e=>{this.onabort instanceof Function&&this.onabort.call(this,e)}))}get aborted(){return this[e.aborted]}get onabort(){return this[e.onabort]}set onabort(t){this[e.onabort]=t instanceof Function?t:null}get reason(){return this[e.reason]}throwIfAborted(){if(this.aborted)throw this.reason}static abort(n=new DOMException("Operation aborted")){const r=new t;return r[e.aborted]=!0,r[e.reason]=n,r}},globalThis.AbortController=class{constructor(){this[e.signal]=new AbortSignal}get signal(){return this[e.signal]}abort(t=new DOMException("Operation aborted")){const n=this.signal;n.aborted||(n[e.aborted]=!0,n[e.reason]=t,n.dispatchEvent(new Event("abort")))}}}if(!("reason"in AbortSignal.prototype)){const e=new WeakMap,t=AbortController.prototype.abort;if(AbortSignal.abort instanceof Function){const t=AbortSignal.abort;AbortSignal.abort=function(n=new DOMException("Operation aborted")){const r=t();return e.set(r,n),r}}else AbortSignal.abort=function(e=new DOMException("Operation aborted")){const t=new AbortController;return t.abort(e),t.reason};Object.defineProperty(AbortSignal.prototype,"reason",{enumerable:!0,configurable:!0,get:function(){return e.has(this)?e.get(this):void 0}}),AbortController.prototype.abort=function(n=new DOMException("Operation aborted")){e.set(this.signal,n),t.call(this)}}AbortSignal.prototype.throwIfAborted instanceof Function||(AbortSignal.prototype.throwIfAborted=function(){if(this.aborted)throw this.reason}),AbortSignal.timeout instanceof Function||(AbortSignal.timeout=function(e){if(void 0===e)throw new TypeError("At least one 1 argument required but only 0 passed");if(Number.isFinite(e)){if(e<0)throw new TypeError("Argument 1 is out of range for unsigned long long.");{const t=new AbortController;return setTimeout((()=>t.abort(new DOMException("The operation timed out."))),e),t.signal}}throw new TypeError("Argument 1 is not a finite value, so it is out of range for unsigned long long.")}),AbortSignal.any instanceof Function||(AbortSignal.any=function(e){if(!Array.isArray(e))throw new TypeError("Expected an array of signals");const t=new AbortController;for(const n of e){if(!(n instanceof AbortSignal)){const e=new TypeError("`signal` is not an `AbortSignal`");throw t.abort(e),e}if(n.aborted){t.abort(n.reason||new DOMException("Operation aborted."));break}n.addEventListener("abort",(({target:e})=>{t.abort(e.reason||new DOMException("Operation aborted."))}),{signal:t.signal})}return t.signal})}(),globalThis.hasOwnProperty("AggregateError")||(globalThis.AggregateError=class extends Error{constructor(e,t){void 0===t?(super(e),this.errors=[]):(super(t),this.errors=e)}}),globalThis.reportError instanceof Function||(globalThis.reportError=function(e){globalThis.dispatchEvent(F(e))}),function(){if("MediaQueryListEvent"in globalThis||(globalThis.MediaQueryListEvent=class extends Event{constructor(e,{media:t,matches:n}={}){super(e),Object.defineProperties(this,{media:{enumerable:!0,configurable:!1,writable:!1,value:t},matches:{enumerable:!0,configurable:!1,writable:!1,value:n}})}}),"MediaQueryList"in globalThis&&!(globalThis.MediaQueryList.prototype.addEventListener instanceof Function)){const e=new WeakMap,t=function(){const{media:e,matches:t}=this;this.dispatchEvent(new MediaQueryListEvent("change",{media:e,matches:t}))},n=function(n){return e.has(n)||(e.set(n,new EventTarget),n.addListener(t.bind(n))),e.get(n)};globalThis.MediaQueryList.prototype.addEventListener=function(e,t,r){n(this).addEventListener(e,t,r)},globalThis.MediaQueryList.prototype.removeEventListener=function(e,t,r){n(this).removeEventListener(e,t,r)},globalThis.MediaQueryList.prototype.dispatchEvent=function(e){n(this).dispatchEvent(e)}}}(),"Promise"in globalThis&&(Promise.prototype.finally instanceof Function||(Promise.prototype.finally=function(e){return this.then((async t=>(await e(),t)),(async t=>(await e(),t)))}),Promise.allSettled instanceof Function||(Promise.allSettled=function(e){return Promise.all(Array.from(e).map((function(e){return new Promise((function(t){e instanceof Promise||(e=Promise.resolve(e)),e.then((function(e){t({status:"fulfilled",value:e})})).catch((function(e){t({status:"rejected",reason:e})}))}))})))}),Promise.any instanceof Function||(Promise.any=e=>new Promise(((t,n)=>{let r=[];e.forEach((o=>{o.then(t).catch((t=>{r.push(t),r.length===e.length&&n(new globalThis.AggregateError(r,"No Promise in Promise.any was resolved"))}))}))}))),Promise.race instanceof Function||(Promise.race=e=>new Promise(((t,n)=>{e.forEach((e=>e.then(t,n)))}))),Promise.try instanceof Function||(Promise.try=e=>new Promise((t=>t(e())))),Promise.withResolvers instanceof Function||(Promise.withResolvers=function(){const e={};return e.promise=new Promise(((t,n)=>{e.resolve=t,e.reject=n})),e}))
|
|
8
|
+
*/const h=new Map,m=Symbol("lock-key"),y="locks"in navigator&&navigator.locks.request instanceof Function;const g=async function(){return await new Promise((e=>{"locks"in navigator&&navigator.locks.request instanceof Function?navigator.locks.query().then((()=>e(!0))).catch((()=>e(!1))):e(!1)}))}();async function b(e,t=null){return new Promise(((n,r)=>{var o;l(o=e)||o instanceof Promise?e.call(globalThis,t).then(n,r):queueMicrotask((()=>{try{const r=e.call(globalThis,t);n(r)}catch(e){r(e)}}))}))}async function w(e){h.has(e)&&await h.get(e).promise.catch(console.error)}function T(e,t,n){const{resolve:r,reject:o,promise:i}=function(){if(Promise.withResolvers instanceof Function)return Promise.withResolvers();{const e={};return e.promise=new Promise(((t,n)=>{e.resolve=t,e.reject=n})),e}}(),a=new AbortController,s=new f(e,t),l=function({name:e,mode:t}){switch(t){case"exclusive":return E().some((t=>t.name===e));case"shared":return E().some((t=>t.name===e&&"exclusive"===t.mode))}}(s);return h.set(s,{resolve:r,reject:o,promise:i,callback:n,pending:l,controller:a}),s}function v(e){return e instanceof f&&h.has(e)&&h.get(e).pending}function E(e){return"string"==typeof e?[...h.keys()].filter((t=>t.name===e)):[...h.keys()]}function S(e){return E(e).filter((e=>!v(e)))}function A(e){return E(e).filter((e=>v(e)))}async function M(e){switch(e.mode){case"exclusive":await Promise.allSettled(E().filter((t=>t.name===e.name&&t!==e)).map(w));break;case"shared":await Promise.allSettled(E().filter((t=>t.name===e.name&&"exclusive"===t.mode&&t!==e)).map(w))}}function L(e){if(h.has(e))return h.get(e).controller.signal}async function O(e){if(h.has(e)){const{resolve:t,reject:n,promise:r,callback:o,pending:i,controller:a}=h.get(e);return i&&function(e,t=!0){h.has(e)&&h.set(e,{...h.get(e),pending:t})}(e,!1),b(o,e).then(t,n).finally((()=>{h.delete(e),requestIdleCallback((()=>a.abort()))})),r}}class F{constructor(e){if(e!==m)throw new TypeError("Invalid constructor")}static async request(e,...t){let n,r={};t[0]instanceof Function?n=t[0]:t[1]instanceof Function&&([r,n]=t),"string"!=typeof e&&(e=e.toString());const{mode:o="exclusive",ifAvailable:i=!1,steal:a=!1,signal:s}=r;if(a&&i)throw new DOMException("LockManager.request: `steal` and `ifAvailable` cannot be used together");if(e.startsWith("-"))throw new DOMException("LockManager.request: Names starting with `-` are reserved");if(!["exclusive","shared"].includes(o))throw new TypeError(`LockManager.request: '${o}' (value of 'mode' member of LockOptions) is not a valid value for enumeration LockMode.`);if(s instanceof AbortSignal&&s.aborted)throw s.reason;if("shared"===o&&a)throw new DOMException("LockManager.request: `steal` is only supported for exclusive lock requests");const l=S(e),c=A(e),u=[...l,...c].some((t=>t.name===e));a&&u&&function(e){[...h.entries()].filter((([t])=>t.name===e)).forEach((([e,{reject:t,controller:n}])=>{requestIdleCallback((()=>{n.abort(),h.delete(e)})),t(new DOMException("The lock request is aborted"))}))}(e);const p=T(e,o,n);switch(s instanceof AbortSignal&&s.addEventListener("abort",(()=>{if(h.has(p)){const{reject:e,controller:t}=h.get(p);h.delete(p),e(new DOMException("The lock request is aborted")),t.abort()}}),{once:!0,signal:L(p)}),o){case"exclusive":if(!i||0===l.length&&0===c.length)return await M(p),await O(p);{const e=h.get(p).controller;return h.delete(p),await b(n,null).then((t=>(requestIdleCallback((()=>e.abort())),t)))}case"shared":if(i){if([...l,...c].some((e=>"exclusive"===e.mode))){const e=h.get(p).controller;return h.delete(p),await b(n,null).then((t=>(requestIdleCallback((()=>e.abort())),t)))}return await M(p),await O(p)}return await M(p),await O(p);default:throw new TypeError(`LockManager.request: '${o}' (value of 'mode' member of LockOptions) is not a valid value for enumeration LockMode.`)}}static async query(){return{held:S().map((({name:e,mode:t})=>({name:e,mode:t,clientId:null}))),pending:A().map((({name:e,mode:t})=>({name:e,mode:t,clientId:null})))}}}function x(e,t="error"){if(e instanceof Error){const{message:n,name:r,fileName:o,lineNumber:i,columnNumber:a}=e;return new ErrorEvent(t,{error:e,message:`${r}: ${n}`,filename:o,lineno:i,colno:a})}throw new TypeError("`errorToEvent()` only accepts Errors")}let k=!1;new Promise((async e=>{if(y)if(await g)e(!1);else try{navigator.locks.request=F.request,navigator.locks.query=F.query,k=!0,e(!0)}catch(t){globalThis.dispatchEvent(x(t)),e(!1)}else try{navigator.locks=F,k=!0,e(!0)}catch(t){globalThis.dispatchEvent(x(t)),e(!1)}})),navigator.canShare instanceof Function||(navigator.canShare=function({title:e,text:t,url:n,files:r}={}){return navigator.share instanceof Function&&(!Array.isArray(r)||0===r.length)&&(!![e,t,n].every((e=>void 0===e))||[e,t,n].some((e=>"string"==typeof e&&0!==e.length)))}),navigator.setAppBadge instanceof Function||(navigator.setAppBadge=async e=>{if(!Number.isInteger(e))throw new TypeError("Failed to execute 'setAppBadge' on 'Navigator': Value is not of type 'unsigned long long'");if(e<0)throw new TypeError("Failed to execute 'setAppBadge' on 'Navigator': Value is outside the 'unsigned long long' value range.");0===e?document.title.startsWith("(")&&(document.title=document.title.replace(/^\((\d{1,2}\+?)\)\s/,"")):e<100?(await navigator.clearAppBadge(),document.title=`(${e}) ${document.title}`):(await navigator.clearAppBadge(),document.title=`(99+) ${document.title}`)}),navigator.clearAppBadge instanceof Function||(navigator.clearAppBadge=()=>navigator.setAppBadge(0)),Navigator.prototype.hasOwnProperty("pdfViewerEnabled")||Object.defineProperty(navigator,"pdfViewerEnabled",{enumerable:!0,configurable:!1,writable:!1,value:!1}),Navigator.prototype.getInstalledRelatedApps instanceof Function||(Navigator.prototype.getInstalledRelatedApps=async()=>[]),Navigator.prototype.getGamepads instanceof Function||(Navigator.prototype.getGamepads=()=>[]),"hardwareConcurrency"in Navigator.prototype||Object.defineProperty(Navigator.prototype,"hardwareConcurrency",{get:()=>1}),"connection"in Navigator.prototype?"type"in navigator.connection||(navigator.connection.type="unknown"):Object.defineProperty(Navigator.prototype,"connection",{get:()=>Object.create(EventTarget.prototype,{type:{value:"unknown"},effectiveType:{value:"4g"},rtt:{value:NaN},downlink:{value:NaN},downlinkMax:{value:1/0},saveData:{value:!1},onchange:{value:null,writable:!0},ontypechange:{value:null,writable:!0}})}),"doNotTrack"in Navigator.prototype||Object.defineProperty(Navigator.prototype,"doNotTrack",{get:()=>"unspecified"}),"globalPrivacyControl"in Navigator.prototype||Object.defineProperty(Navigator.prototype,"globalPrivacyControl",{get:()=>!1}),function(){if(!(globalThis.requestIdleCallback instanceof Function)){const e=e=>Number.isSafeInteger(e)&&e>0;globalThis.requestIdleCallback=function(t,{timeout:n}={}){const r=performance.now(),o=()=>e(n)?Math.max(0,n-(performance.now()-r)):Math.max(0,600-(performance.now()-r));return setTimeout((()=>t({didTimeout:!!e(n)&&0===o(),timeRemaining:o})),1)}}globalThis.cancelIdleCallback instanceof Function||(globalThis.cancelIdleCallback=e=>clearTimeout(e)),globalThis.requestAnimationFrame instanceof Function||(globalThis.requestAnimationFrame=e=>setTimeout((()=>e(performance.now())),1e3/60)),globalThis.cancelAnimationFrame instanceof Function||(globalThis.cancelAnimationFrame=e=>clearTimeout(e)),globalThis.queueMicrotask instanceof Function||(globalThis.queueMicrotask=e=>Promise.resolve().then(e).catch((e=>setTimeout((()=>{throw e})))))}(),function(){if(!("AbortSignal"in globalThis)){const e={signal:Symbol("signal"),aborted:Symbol("aborted"),reason:Symbol("reason"),onabort:Symbol("onabort")};globalThis.AbortError=class extends Error{},globalThis.AbortSignal=class t extends EventTarget{constructor(){super(),Object.defineProperties(this,{[e.aborted]:{enumerable:!1,writable:!0,configurable:!1,value:!1},[e.reason]:{enumerable:!1,writable:!0,configurable:!1,value:void 0},[e.onabort]:{enumerable:!1,writable:!0,configurable:!1,value:null}}),this.addEventListener("abort",(e=>{this.onabort instanceof Function&&this.onabort.call(this,e)}))}get aborted(){return this[e.aborted]}get onabort(){return this[e.onabort]}set onabort(t){this[e.onabort]=t instanceof Function?t:null}get reason(){return this[e.reason]}throwIfAborted(){if(this.aborted)throw this.reason}static abort(n=new DOMException("Operation aborted")){const r=new t;return r[e.aborted]=!0,r[e.reason]=n,r}},globalThis.AbortController=class{constructor(){this[e.signal]=new AbortSignal}get signal(){return this[e.signal]}abort(t=new DOMException("Operation aborted")){const n=this.signal;n.aborted||(n[e.aborted]=!0,n[e.reason]=t,n.dispatchEvent(new Event("abort")))}}}if(!("reason"in AbortSignal.prototype)){const e=new WeakMap,t=AbortController.prototype.abort;if(AbortSignal.abort instanceof Function){const t=AbortSignal.abort;AbortSignal.abort=function(n=new DOMException("Operation aborted")){const r=t();return e.set(r,n),r}}else AbortSignal.abort=function(e=new DOMException("Operation aborted")){const t=new AbortController;return t.abort(e),t.reason};Object.defineProperty(AbortSignal.prototype,"reason",{enumerable:!0,configurable:!0,get:function(){return e.has(this)?e.get(this):void 0}}),AbortController.prototype.abort=function(n=new DOMException("Operation aborted")){e.set(this.signal,n),t.call(this)}}AbortSignal.prototype.throwIfAborted instanceof Function||(AbortSignal.prototype.throwIfAborted=function(){if(this.aborted)throw this.reason}),AbortSignal.timeout instanceof Function||(AbortSignal.timeout=function(e){if(void 0===e)throw new TypeError("At least one 1 argument required but only 0 passed");if(Number.isFinite(e)){if(e<0)throw new TypeError("Argument 1 is out of range for unsigned long long.");{const t=new AbortController;return setTimeout((()=>t.abort(new DOMException("The operation timed out."))),e),t.signal}}throw new TypeError("Argument 1 is not a finite value, so it is out of range for unsigned long long.")}),AbortSignal.any instanceof Function||(AbortSignal.any=function(e){if(!Array.isArray(e))throw new TypeError("Expected an array of signals");const t=new AbortController;for(const n of e){if(!(n instanceof AbortSignal)){const e=new TypeError("`signal` is not an `AbortSignal`");throw t.abort(e),e}if(n.aborted){t.abort(n.reason||new DOMException("Operation aborted."));break}n.addEventListener("abort",(({target:e})=>{t.abort(e.reason||new DOMException("Operation aborted."))}),{signal:t.signal})}return t.signal})}(),globalThis.hasOwnProperty("AggregateError")||(globalThis.AggregateError=class extends Error{constructor(e,t){void 0===t?(super(e),this.errors=[]):(super(t),this.errors=e)}}),globalThis.reportError instanceof Function||(globalThis.reportError=function(e){globalThis.dispatchEvent(x(e))}),function(){if("MediaQueryListEvent"in globalThis||(globalThis.MediaQueryListEvent=class extends Event{constructor(e,{media:t,matches:n}={}){super(e),Object.defineProperties(this,{media:{enumerable:!0,configurable:!1,writable:!1,value:t},matches:{enumerable:!0,configurable:!1,writable:!1,value:n}})}}),"MediaQueryList"in globalThis&&!(globalThis.MediaQueryList.prototype.addEventListener instanceof Function)){const e=new WeakMap,t=function(){const{media:e,matches:t}=this;this.dispatchEvent(new MediaQueryListEvent("change",{media:e,matches:t}))},n=function(n){return e.has(n)||(e.set(n,new EventTarget),n.addListener(t.bind(n))),e.get(n)};globalThis.MediaQueryList.prototype.addEventListener=function(e,t,r){n(this).addEventListener(e,t,r)},globalThis.MediaQueryList.prototype.removeEventListener=function(e,t,r){n(this).removeEventListener(e,t,r)},globalThis.MediaQueryList.prototype.dispatchEvent=function(e){n(this).dispatchEvent(e)}}}(),"Promise"in globalThis&&(Promise.prototype.finally instanceof Function||(Promise.prototype.finally=function(e){return this.then((async t=>(await e(),t)),(async t=>(await e(),t)))}),Promise.allSettled instanceof Function||(Promise.allSettled=function(e){return Promise.all(Array.from(e).map((function(e){return new Promise((function(t){e instanceof Promise||(e=Promise.resolve(e)),e.then((function(e){t({status:"fulfilled",value:e})})).catch((function(e){t({status:"rejected",reason:e})}))}))})))}),Promise.any instanceof Function||(Promise.any=e=>new Promise(((t,n)=>{let r=[];e.forEach((o=>{o.then(t).catch((t=>{r.push(t),r.length===e.length&&n(new globalThis.AggregateError(r,"No Promise in Promise.any was resolved"))}))}))}))),Promise.race instanceof Function||(Promise.race=e=>new Promise(((t,n)=>{e.forEach((e=>e.then(t,n)))}))),Promise.try instanceof Function||(Promise.try=e=>new Promise((t=>t(e())))),Promise.withResolvers instanceof Function||(Promise.withResolvers=function(){const e={};return e.promise=new Promise(((t,n)=>{e.resolve=t,e.reject=n})),e}))
|
|
9
9
|
/**
|
|
10
10
|
* @copyright 2023 Chris Zuber <admin@kernvalley.us>
|
|
11
|
-
*/;class
|
|
11
|
+
*/;let P=class{get encoding(){return"utf-8"}encode(e){return new Uint8Array(e.split("").flatMap((e=>{const t=e.charCodeAt(0);if(t<128)return[t];return[194+Math.floor((t-128)/64),t%64+128]})))}encodeInto(e,t){if(t instanceof Uint8Array){const n=this.encode(e),r=Math.min(t.length,n.length);return n.length>t.length?t.set(n.slice(0,r)):t.set(n),{read:r,written:r}}throw new TypeError("TextEncoder.encodeInto: Argument 2 does not implement interface Uint8Array.")}};
|
|
12
12
|
/**
|
|
13
13
|
* @copyright 2023 Chris Zuber <admin@kernvalley.us>
|
|
14
|
-
*/const
|
|
14
|
+
*/const N=["utf-8","utf8"];class C{constructor(e="utf-8",{fatal:t=!1,ignoreBOM:n=!1}={}){if(e="string"!=typeof e?e.toString().toLowerCase():e.toLowerCase(),!N.includes(e))throw new RangeError(`TextDecoder constructor: The given encoding '${e}' is not supported.`);Object.defineProperties(this,{encoding:{configurable:!1,enumerable:!0,writable:!1,value:e},fatal:{configurable:!1,enumerable:!0,writable:!1,value:t},ignoreBOM:{configurable:!1,enumerable:!0,writable:!1,value:n}})}decode(e){switch(this.encoding){case"utf-8":case"utf8":{let t=NaN;return e.reduce(((e,n,r)=>{if(Number.isNaN(t)&&n<128)return e+String.fromCharCode(n);if(Number.isNaN(t)&&n>193)return t=n,e;if(t>193&&(o=128,a=194,"number"==typeof(i=n)&&i>=o&&i<=a)){const r=64*(t-194);return t=NaN,e+String.fromCharCode(r+n)}if(this.fatal)throw new RangeError(`Unhandled character at postion ${r}`);return t=NaN,e;var o,i,a}),"")}default:throw new TypeError(`Unsupported encoding '${this.encoding}'`)}}}"TextEncoder"in globalThis||(globalThis.TextEncoder=P),"TextDecoder"in globalThis||(globalThis.TextDecoder=C),globalThis.TextEncoder.prototype.encodeInto instanceof Function||(globalThis.TextEncoder.prototype.encodeInto=function(...e){return P.prototype.encodeInto.apply(this,e)}),!(crypto in globalThis)||crypto.randomUUID instanceof Function||(crypto.randomUUID=function(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)))})
|
|
15
15
|
/**
|
|
16
16
|
* @copyright 2023 Chris Zuber <admin@kernvalley.us>
|
|
17
17
|
* @SEE https://wicg.github.io/cookie-store/
|
|
@@ -20,31 +20,31 @@
|
|
|
20
20
|
* cookie properties, such as expires, etc.
|
|
21
21
|
*
|
|
22
22
|
* @TODO verify spec compliance as best as is possible
|
|
23
|
-
*/;const
|
|
23
|
+
*/;const I="cookieStore"in globalThis,j={constructor:Symbol("constructor")};function D(){return 0===document.cookie.length?[]:document.cookie.split(";").map((e=>{const[t,n=null]=e.split("=");return{name:decodeURIComponent(t.trim()),value:"string"==typeof n?decodeURIComponent(n.trim()):null,path:void 0,expires:void 0,domain:void 0,sameSite:void 0,secure:void 0,partitioned:!1}}))}function R({name:e=null,value:t=null}={}){return"string"==typeof e&&(e=decodeURIComponent(e)),"string"==typeof t&&(t=decodeURIComponent(t)),"string"==typeof e&&"string"==typeof t?D().filter((n=>n.name===e&&n.value===t)):"string"==typeof e?D().filter((t=>t.name===e)):"string"==typeof t?D().filter((e=>e.value===t)):D()}function H({name:e,value:t,expires:n=null,maxAge:r=null,path:o="/",sameSite:i="lax",domain:a=null,secure:s=!1,partitioned:l=!1}){if(Number.isInteger(r))H({name:e,value:t,expires:Date.now()+r,path:o,sameSite:i,domain:a,secure:s,partitioned:l});else{let r=`${encodeURIComponent(e)}=`;t&&(r+=encodeURIComponent(t)),Number.isInteger(n)?r+=`;expires=${new Date(n).toUTCString()}`:n instanceof Date&&(r+=`;expires=${n.toUTCString()}`),"string"==typeof o&&(r+=`;path=${o}`),"string"==typeof a&&(r+=`;domain=${a}`),"string"==typeof i&&(r+=`;sameSite=${i}`),!0===s&&(r+=";secure"),!0===l&&(r+=";partitioned"),document.cookie=r}}class U extends EventTarget{constructor(e){if(e!==j.constructor)throw new DOMException("Invalid constructor");super(),Object.defineProperty(this,j.onchange,{enumerable:!1,configurable:!1,writable:!0,value:null})}get onchange(){return this[j.onchange]}set onchange(e){this[j.onchange]instanceof Function&&this.removeEventListener("change",this[j.onchange]),e instanceof Function&&this.addEventListener("change",e)}async get(e){const t=await this.getAll(e);return Array.isArray(t)&&0!==t.length?t[0]:null}async getAll(e){return R("string"==typeof e?{name:e}:e)}async set(...e){if(1===e.length&&"object"==typeof e[0]&&"string"==typeof e[0].name){const t=function({name:e,value:t=null,domain:n=null,path:r="/",expires:o=null,maxAge:i=null,sameSite:a="lax",secure:s=!1,partitioned:l=!1}){return{name:e,value:t,domain:n,path:r,expires:o,maxAge:i,sameSite:a,secure:s,partitioned:l}}(e[0]);H(t);const n=new Event("change");n.changed=[t],n.deleted=[],this.dispatchEvent(n)}else{if(2!==e.length)throw new Error("Invalid arguments");this.set({name:e[0],value:e[1]})}}async delete(e={}){if("string"==typeof e)this.delete({name:e});else{if("object"!=typeof e||"string"!=typeof e.name)throw new TypeError("Failed to execute 'delete' on 'CookieStore': required member name is undefined.");{const t=await this.getAll(e);if(0!==t.length){const n=new Event("change");n.changed=[],n.deleted=new Array(t.length),t.forEach(((t,r)=>{t.path=e.path||"/",t.domain=e.domain||null,t.secure=e.secure||null,delete t.value,t.sameSite=e.sameSite||"lax",n.deleted[r]=t,H({...t,value:null,expires:1})})),this.dispatchEvent(n)}}}}}const q=new U(j.constructor);
|
|
24
24
|
/**
|
|
25
25
|
* @copyright 2023 Chris Zuber <admin@kernvalley.us>
|
|
26
26
|
*/
|
|
27
|
-
function
|
|
27
|
+
function z(){return"trustedTypes"in globalThis&&trustedTypes instanceof EventTarget&&trustedTypes.createPolicy instanceof Function}!I&&(globalThis.cookieStore=q),globalThis.hasOwnProperty("Animation")&&!Animation.prototype.hasOwnProperty("finished")&&Object.defineProperty(Animation.prototype,"finished",{get:function(){return new Promise(((e,t)=>{"finished"===this.playState?e(this):(this.addEventListener("finish",(()=>e(this)),{once:!0}),this.addEventListener("error",(e=>t(e)),{once:!0}))}))}}),globalThis.hasOwnProperty("Animation")&&!Animation.prototype.hasOwnProperty("ready")&&Object.defineProperty(Animation.prototype,"ready",{get:function(){return new Promise(((e,t)=>{this.pending?(this.addEventListener("ready",(()=>e(this)),{once:!0}),this.addEventListener("error",(e=>t(e)),{once:!0})):e(this)}))}});
|
|
28
28
|
/**
|
|
29
29
|
* @copyright 2023 Chris Zuber <admin@kernvalley.us>
|
|
30
30
|
*/
|
|
31
|
-
const
|
|
31
|
+
const B=Object.keys(Object.getOwnPropertyDescriptors(HTMLElement.prototype)).filter((e=>e.startsWith("on"))),$=["action","cite","formaction","href","ping","src"],_=p((async function(){const{ok:e,headers:t}=await fetch(location.href,{method:"HEAD"});if(e&&t.has("Content-Security-Policy")){const e=t.get("Content-Security-Policy").trim().split(";").filter((e=>0!==e.length));return Object.fromEntries(e.map((e=>{const[t,...n]=e.trim().split(" ").filter((e=>0!==e.length));return[t,n]})))}}));function V(){const e=document.head.querySelector('meta[http-equiv="Content-Security-Policy"][content]');if(e instanceof HTMLMetaElement){const t=e.content.trim().split(";").filter((e=>0!==e.length));return Object.fromEntries(t.map((e=>{const[t,...n]=e.trim().split(" ").filter((e=>0!==e.length));return[t,n]})))}return{}}
|
|
32
32
|
/**
|
|
33
33
|
* @copyright 2023 Chris Zuber <admin@kernvalley.us>
|
|
34
|
-
*/const
|
|
34
|
+
*/const W="1"===document.documentElement.dataset.fetchTrustCsp;function G({"trusted-types":e=null}={}){if(Array.isArray(e)){const t=new Set(e),n=t.has("'allow-duplicates'"),r=t.has("'none'");return n&&t.delete("'allow-duplicates'"),r&&t.clear(),t.add("empty#html"),t.add("empty#script"),{policies:t,allowDuplicates:n,hasNone:r}}return{}}const{allowDuplicates:K,allowedPolicies:Q}=function(){const e=G(V());if("object"==typeof e&&e.policies instanceof Set){const{policies:t,allowDuplicates:n}=e;return{allowDuplicates:n,allowedPolicies:t}}{const e=(()=>{const e=G(V());return"object"==typeof e&&"allowDuplicates"in e?e.allowDuplicates:"1"===document.documentElement.dataset.allowTrustDuplicates})(),t=(()=>{if(document.documentElement.dataset.hasOwnProperty("trustedPolicies"))return new Set(["empty#html","empty#script",...document.documentElement.dataset.trustedPolicies.split(" ")]);{const{policies:e}=G(V());return e instanceof Set?e:new Set(["empty#html","empty#script"])}})();return t.has("'none'")&&t.clear(),t.add("empty#html"),t.add("empty#script"),{allowDuplicates:e,allowedPolicies:t}}}();z();const J={trustedValue:Symbol("[[Data]]"),trustedKey:Symbol("trusted-key"),emptyHTML:Symbol("policy-empty#html"),emptyScript:Symbol("policy-empty#script"),policy:Symbol.for("trust-policy"),defaultPolicy:Symbol("default-policy"),trustedTypesCSP:Symbol("trusted-types-csp")};Symbol.hasOwnProperty("toStringTag")||(Symbol.toStringTag=Symbol("Symbol.toStringTag"));const X=[];function Z(e){return null!==function(e){return X.find((t=>t.name===e))||null}(e)}function Y(e,t){return function(){throw new TypeError(`Failed to execute '${t}' on 'TrustedTypePolicy': Policy ${e.name}'s TrustedTypePolicyOptions did not specify a '${t}' member.`)}}class ee{constructor(e,{key:t,policy:n}){if(t!==J.trustedKey)throw new TypeError("Invalid constructor");Object.defineProperties(this,{[J.trustedValue]:{enumerable:!1,configurable:!1,writable:!1,value:e.toString()},[J.policy]:{enumerable:!1,configurable:!1,writable:!1,value:n.name}}),Object.freeze(this)}toString(){return this.valueOf()}toJSON(){return this.valueOf()}valueOf(){return this[J.trustedValue]}}class te extends ee{[Symbol.toStringTag](){return"TrustedHTML"}}class ne extends ee{[Symbol.toStringTag](){return"TrustedScript"}}class re extends ee{[Symbol.toStringTag](){return"TrustedScriptURL"}}class oe{constructor(e,{createHTML:t,createScript:n,createScriptURL:r}={},{key:o}){if(o!==J.trustedKey)throw new TypeError("Invalid constructor");Object.defineProperties(this,{name:{enumerable:!0,configurable:!1,writable:!1,value:e.toString()},createHTML:{enumerable:!0,configurable:!1,writable:!1,value:t instanceof Function?(e,...n)=>new te(t(e.toString(),...n),{key:J.trustedKey,policy:this}):Y(this,"createHTML")},createScript:{enumerable:!0,configurable:!1,writable:!1,value:n instanceof Function?(e,...t)=>new ne(n(e.toString(),...t),{key:J.trustedKey,policy:this}):Y(this,"createScript")},createScriptURL:{enumerable:!0,configurable:!1,writable:!1,value:r instanceof Function?(e,...t)=>new re(r(e.toString(),...t),{key:J.trustedKey,policy:this}):Y(this,"createScriptURL")}})}}class ie extends EventTarget{constructor(e){if(super(),e!==J.trustedKey)throw new TypeError("Invalid constructor");W&&async function(){const{policies:e,allowDuplicates:t=!1,hasNone:n=!1}=await _().then(G);return e instanceof Set?{policies:e,allowDuplicates:t,hasNone:n}:{}}().then((({policies:e,allowDuplicates:t=!1,hasNone:n=!1})=>{void 0!==e&&Object.defineProperty(ie,J.trustedTypesCSP,{value:{policies:e,allowDuplicates:t,hasNone:n},enumberable:!1,writable:!1,configurable:!1})})).catch((e=>console.error(e))),Object.defineProperties(this,{[J.defaultPolicy]:{enumerable:!1,configurable:!1,writable:!0,value:null},[J.emptyHTML]:{enumerable:!1,configurable:!1,writable:!1,value:this.createPolicy("empty#html",{createHTML:()=>""})},[J.emptyScript]:{enumerable:!1,configurable:!1,writable:!1,value:this.createPolicy("empty#script",{createScript:()=>""})}})}isHTML(e){return e instanceof globalThis.TrustedHTML}isScript(e){return e instanceof globalThis.TrustedScript}isScriptURL(e){return e instanceof globalThis.TrustedScriptURL}createPolicy(e,{createHTML:t,createScript:n,createScriptURL:r}={}){const o=new oe(e,{createHTML:t,createScript:n,createScriptURL:r},{key:J.trustedKey});if(!e.toString().match(/^[-#a-zA-Z0-9=_/@.%]+$/g))throw new TypeError(`Failed to execute 'createPolicy' on 'TrustedTypePolicyFactory': Policy: "${e}" contains invalid characters.`);if(ie.hasOwnProperty(J.trustedTypesCSP)){const{policies:t,allowDuplicates:n,hasNone:r}=ie[J.trustedTypesCSP];if(r&&"empty#html"!==e&&"empty#script"!==e)throw new TypeError(`Failed to execute 'createPolicy' on 'TrustedTypePolicyFactory': Policy: "${e}" disallowed.`);if(!t.has(e))throw new TypeError(`Failed to execute 'createPolicy' on 'TrustedTypePolicyFactory': Policy: "${e}" disallowed.`);if(!n&&Z(e))throw new TypeError(`Failed to execute 'createPolicy' on 'TrustedTypePolicyFactory': Policy: "${e}" already exists.`)}else{if(Q.size>2&&!Q.has(e))throw new TypeError(`Failed to execute 'createPolicy' on 'TrustedTypePolicyFactory': Policy: "${e}" disallowed.`);if(!K&&Z(e))throw new TypeError(`Failed to execute 'createPolicy' on 'TrustedTypePolicyFactory': Policy: "${e}" already exists.`)}return"default"===o.name&&(this[J.defaultPolicy]=o),X.push(o),o}getAttributeType(e,t,n){if(e=e.toLowerCase(),t=t.toLowerCase(),"string"==typeof elementNS&&0!==n.length)return B.includes(t)?"TrustedScript":null;if(B.includes(t))return"TrustedScript";switch(e){case"script":return"src"===t?"TrustedScriptURL":null;case"iframe":return"srcdoc"===t?"TrustedHTML":"src"===t?"TrustedScriptURL":null;default:return null}}getPropertyType(e,t){if(e=e.toLowerCase(),B.includes(t.toLowerCase()))return"TrustedScript";switch(e){case"embed":case"iframe":return"src"===t?"TrustedScriptURL":null;case"script":return"src"===t?"TrustedScriptURL":["text","innerText","textContent","innerHTML"].includes(t)?"TrustedScript":["outerHTML"].includes(t)?"TrustedHTML":null;default:return["innerHTML","outerHTML"].includes(t)?"TrustedHTML":null}}get emptyHTML(){return this[J.emptyHTML].createHTML("")}get emptyScript(){return this[J.emptyScript].createScript("")}get defaultPolicy(){return this[J.defaultPolicy]}get _isPolyfill_(){return!0}static get allowDuplicates(){return K}}const ae=new ie(J.trustedKey);!function(){if("TrustedTypePolicyFactory"in globalThis||(globalThis.TrustedTypePolicyFactory=ie),"TrustedTypePolicy"in globalThis||(globalThis.TrustedTypePolicy=oe),"TrustedType"in globalThis||(globalThis.TrustedType=ee),"TrustedHTML"in globalThis||(globalThis.TrustedHTML=te),"TrustedScript"in globalThis||(globalThis.TrustedScript=ne),"TrustedScriptURL"in globalThis||(globalThis.TrustedScriptURL=re),"trustedTypes"in globalThis)try{globalThis.trustedTypes.createPolicy("empty#html",{createHTML:()=>""}),globalThis.trustedTypes.createPolicy("empty#script",{createScript:()=>""})}catch(e){console.error(e)}else globalThis.trustedTypes=ae}();
|
|
35
35
|
/**
|
|
36
|
-
* @copyright 2023 Chris Zuber <admin@kernvalley.us>
|
|
36
|
+
* @copyright 2023-2024 Chris Zuber <admin@kernvalley.us>
|
|
37
37
|
* @see https://wicg.github.io/sanitizer-api/#default-configuration-dictionary
|
|
38
38
|
*/
|
|
39
|
-
const ae=JSON.parse('{\n "allowCustomElements": false,\n "allowUnknownMarkup": false,\n "allowElements": [\n "a",\n "abbr",\n "acronym",\n "address",\n "area",\n "article",\n "aside",\n "audio",\n "b",\n "bdi",\n "bdo",\n "bgsound",\n "big",\n "blockquote",\n "body",\n "br",\n "button",\n "canvas",\n "caption",\n "center",\n "cite",\n "code",\n "col",\n "colgroup",\n "datalist",\n "dd",\n "del",\n "details",\n "dfn",\n "dialog",\n "dir",\n "div",\n "dl",\n "dt",\n "em",\n "fieldset",\n "figcaption",\n "figure",\n "font",\n "footer",\n "form",\n "h1",\n "h2",\n "h3",\n "h4",\n "h5",\n "h6",\n "head",\n "header",\n "hgroup",\n "hr",\n "html",\n "i",\n "img",\n "input",\n "ins",\n "kbd",\n "keygen",\n "label",\n "layer",\n "legend",\n "li",\n "link",\n "listing",\n "main",\n "map",\n "mark",\n "marquee",\n "menu",\n "meta",\n "meter",\n "nav",\n "nobr",\n "ol",\n "optgroup",\n "option",\n "output",\n "p",\n "picture",\n "popup",\n "pre",\n "progress",\n "q",\n "rb",\n "rp",\n "rt",\n "rtc",\n "ruby",\n "s",\n "samp",\n "section",\n "select",\n "selectmenu",\n "small",\n "source",\n "span",\n "strike",\n "strong",\n "style",\n "sub",\n "summary",\n "sup",\n "table",\n "tbody",\n "td",\n "tfoot",\n "th",\n "thead",\n "time",\n "tr",\n "track",\n "tt",\n "u",\n "ul",\n "var",\n "video",\n "wbr"\n ],\n "allowAttributes": {\n "abbr": [\n "*"\n ],\n "accept": [\n "*"\n ],\n "accept-charset": [\n "*"\n ],\n "accesskey": [\n "*"\n ],\n "action": [\n "*"\n ],\n "align": [\n "*"\n ],\n "alink": [\n "*"\n ],\n "allow": [\n "*"\n ],\n "allowfullscreen": [\n "*"\n ],\n "alt": [\n "*"\n ],\n "anchor": [\n "*"\n ],\n "archive": [\n "*"\n ],\n "as": [\n "*"\n ],\n "async": [\n "*"\n ],\n "autocapitalize": [\n "*"\n ],\n "autocomplete": [\n "*"\n ],\n "autocorrect": [\n "*"\n ],\n "autofocus": [\n "*"\n ],\n "autopictureinpicture": [\n "*"\n ],\n "autoplay": [\n "*"\n ],\n "axis": [\n "*"\n ],\n "background": [\n "*"\n ],\n "behavior": [\n "*"\n ],\n "bgcolor": [\n "*"\n ],\n "border": [\n "*"\n ],\n "bordercolor": [\n "*"\n ],\n "capture": [\n "*"\n ],\n "cellpadding": [\n "*"\n ],\n "cellspacing": [\n "*"\n ],\n "challenge": [\n "*"\n ],\n "char": [\n "*"\n ],\n "charoff": [\n "*"\n ],\n "charset": [\n "*"\n ],\n "checked": [\n "*"\n ],\n "cite": [\n "*"\n ],\n "class": [\n "*"\n ],\n "classid": [\n "*"\n ],\n "clear": [\n "*"\n ],\n "code": [\n "*"\n ],\n "codebase": [\n "*"\n ],\n "codetype": [\n "*"\n ],\n "color": [\n "*"\n ],\n "cols": [\n "*"\n ],\n "colspan": [\n "*"\n ],\n "compact": [\n "*"\n ],\n "content": [\n "*"\n ],\n "contenteditable": [\n "*"\n ],\n "controls": [\n "*"\n ],\n "controlslist": [\n "*"\n ],\n "conversiondestination": [\n "*"\n ],\n "coords": [\n "*"\n ],\n "crossorigin": [\n "*"\n ],\n "csp": [\n "*"\n ],\n "data": [\n "*"\n ],\n "datetime": [\n "*"\n ],\n "declare": [\n "*"\n ],\n "decoding": [\n "*"\n ],\n "default": [\n "*"\n ],\n "defer": [\n "*"\n ],\n "dir": [\n "*"\n ],\n "direction": [\n "*"\n ],\n "dirname": [\n "*"\n ],\n "disabled": [\n "*"\n ],\n "disablepictureinpicture": [\n "*"\n ],\n "disableremoteplayback": [\n "*"\n ],\n "disallowdocumentaccess": [\n "*"\n ],\n "download": [\n "*"\n ],\n "draggable": [\n "*"\n ],\n "elementtiming": [\n "*"\n ],\n "enctype": [\n "*"\n ],\n "end": [\n "*"\n ],\n "enterkeyhint": [\n "*"\n ],\n "event": [\n "*"\n ],\n "exportparts": [\n "*"\n ],\n "face": [\n "*"\n ],\n "for": [\n "*"\n ],\n "form": [\n "*"\n ],\n "formaction": [\n "*"\n ],\n "formenctype": [\n "*"\n ],\n "formmethod": [\n "*"\n ],\n "formnovalidate": [\n "*"\n ],\n "formtarget": [\n "*"\n ],\n "frame": [\n "*"\n ],\n "frameborder": [\n "*"\n ],\n "headers": [\n "*"\n ],\n "height": [\n "*"\n ],\n "hidden": [\n "*"\n ],\n "high": [\n "*"\n ],\n "href": [\n "*"\n ],\n "hreflang": [\n "*"\n ],\n "hreftranslate": [\n "*"\n ],\n "hspace": [\n "*"\n ],\n "http-equiv": [\n "*"\n ],\n "id": [\n "*"\n ],\n "imagesizes": [\n "*"\n ],\n "imagesrcset": [\n "*"\n ],\n "importance": [\n "*"\n ],\n "impressiondata": [\n "*"\n ],\n "impressionexpiry": [\n "*"\n ],\n "incremental": [\n "*"\n ],\n "inert": [\n "*"\n ],\n "inputmode": [\n "*"\n ],\n "integrity": [\n "*"\n ],\n "invisible": [\n "*"\n ],\n "is": [\n "*"\n ],\n "ismap": [\n "*"\n ],\n "keytype": [\n "*"\n ],\n "kind": [\n "*"\n ],\n "label": [\n "*"\n ],\n "lang": [\n "*"\n ],\n "language": [\n "*"\n ],\n "latencyhint": [\n "*"\n ],\n "leftmargin": [\n "*"\n ],\n "link": [\n "*"\n ],\n "list": [\n "*"\n ],\n "loading": [\n "*"\n ],\n "longdesc": [\n "*"\n ],\n "loop": [\n "*"\n ],\n "low": [\n "*"\n ],\n "lowsrc": [\n "*"\n ],\n "manifest": [\n "*"\n ],\n "marginheight": [\n "*"\n ],\n "marginwidth": [\n "*"\n ],\n "max": [\n "*"\n ],\n "maxlength": [\n "*"\n ],\n "mayscript": [\n "*"\n ],\n "media": [\n "*"\n ],\n "method": [\n "*"\n ],\n "min": [\n "*"\n ],\n "minlength": [\n "*"\n ],\n "multiple": [\n "*"\n ],\n "muted": [\n "*"\n ],\n "name": [\n "*"\n ],\n "nohref": [\n "*"\n ],\n "nomodule": [\n "*"\n ],\n "nonce": [\n "*"\n ],\n "noresize": [\n "*"\n ],\n "noshade": [\n "*"\n ],\n "novalidate": [\n "*"\n ],\n "nowrap": [\n "*"\n ],\n "object": [\n "*"\n ],\n "open": [\n "*"\n ],\n "optimum": [\n "*"\n ],\n "part": [\n "*"\n ],\n "pattern": [\n "*"\n ],\n "ping": [\n "*"\n ],\n "placeholder": [\n "*"\n ],\n "playsinline": [\n "*"\n ],\n "policy": [\n "*"\n ],\n "poster": [\n "*"\n ],\n "preload": [\n "*"\n ],\n "pseudo": [\n "*"\n ],\n "readonly": [\n "*"\n ],\n "referrerpolicy": [\n "*"\n ],\n "rel": [\n "*"\n ],\n "reportingorigin": [\n "*"\n ],\n "required": [\n "*"\n ],\n "resources": [\n "*"\n ],\n "rev": [\n "*"\n ],\n "reversed": [\n "*"\n ],\n "role": [\n "*"\n ],\n "rows": [\n "*"\n ],\n "rowspan": [\n "*"\n ],\n "rules": [\n "*"\n ],\n "sandbox": [\n "*"\n ],\n "scheme": [\n "*"\n ],\n "scope": [\n "*"\n ],\n "scopes": [\n "*"\n ],\n "scrollamount": [\n "*"\n ],\n "scrolldelay": [\n "*"\n ],\n "scrolling": [\n "*"\n ],\n "select": [\n "*"\n ],\n "selected": [\n "*"\n ],\n "shadowroot": [\n "*"\n ],\n "shadowrootdelegatesfocus": [\n "*"\n ],\n "shape": [\n "*"\n ],\n "size": [\n "*"\n ],\n "sizes": [\n "*"\n ],\n "slot": [\n "*"\n ],\n "span": [\n "*"\n ],\n "spellcheck": [\n "*"\n ],\n "src": [\n "*"\n ],\n "srcdoc": [\n "*"\n ],\n "srclang": [\n "*"\n ],\n "srcset": [\n "*"\n ],\n "standby": [\n "*"\n ],\n "start": [\n "*"\n ],\n "step": [\n "*"\n ],\n "style": [\n "*"\n ],\n "summary": [\n "*"\n ],\n "tabindex": [\n "*"\n ],\n "target": [\n "*"\n ],\n "text": [\n "*"\n ],\n "title": [\n "*"\n ],\n "topmargin": [\n "*"\n ],\n "translate": [\n "*"\n ],\n "truespeed": [\n "*"\n ],\n "trusttoken": [\n "*"\n ],\n "type": [\n "*"\n ],\n "usemap": [\n "*"\n ],\n "valign": [\n "*"\n ],\n "value": [\n "*"\n ],\n "valuetype": [\n "*"\n ],\n "version": [\n "*"\n ],\n "virtualkeyboardpolicy": [\n "*"\n ],\n "vlink": [\n "*"\n ],\n "vspace": [\n "*"\n ],\n "webkitdirectory": [\n "*"\n ],\n "width": [\n "*"\n ],\n "wrap": [\n "*"\n ]\n }\n}'),se=function(e,t,n=ae){const r=fe(t,n);e.replaceChildren(pe(r))},le=["https:"];le.includes(location.protocol)||le.push(location.protocol);const ce=u((()=>function(e,{createHTML:t=(()=>{throw new TypeError("This policy does not provide `createHTML()`")}),createScript:n=(()=>{throw new TypeError("This policy does not provide `createScript()`")}),createScriptURL:r=(()=>{throw new TypeError("This policy does not provide `createScriptURL()`")})}){return q()?trustedTypes.createPolicy(e,{createHTML:t,createScript:n,createScriptURL:r}):Object.freeze({name:e,createHTML:(e,...n)=>t(e.toString(),...n),createScript:(e,...t)=>n(e.toString(),...t),createScriptURL:(e,...t)=>r(e.toString(),...t)})}("sanitizer-raw#html",{createHTML:e=>e}))),ue=e=>ce().createHTML(e);function pe(e){const t=document.createDocumentFragment(),n=e.cloneNode(!0);return t.append(...n.head.childNodes,...n.body.childNodes),t}function de({allowAttributes:e,allowComments:t,allowElements:n,allowCustomElements:r,blockElements:o,dropAttributes:i,dropElements:a,allowUnknownMarkup:s,sanitizer:l}={},c){return l instanceof Sanitizer?de(l.getConfiguration(),c):(void 0===e&&void 0===i&&(e=ae.allowAttributes),void 0===n&&void 0===a&&(n=ae.allowElements),{allowAttributes:e,allowComments:t,allowElements:n,allowCustomElements:r,blockElements:o,dropAttributes:i,dropElements:a,allowUnknownMarkup:s})}function fe(e,t=ae){const n=(new DOMParser).parseFromString(ue(e),"text/html");return Array.isArray(t.allowElements)&&!t.allowElements.includes("html")&&(t.allowElements=[...new Set([...t.allowElements,"html","head","body"])]),he(n,t)}function me(e,t=ae){if(e instanceof Node){if(e.nodeType===Node.DOCUMENT_FRAGMENT_NODE)return he(e,t);if(e.nodeType===Node.DOCUMENT_NODE)return he(pe(e),t);throw new TypeError("sanitize requires a Document or DocumentFragment")}throw new TypeError("sanitize requires a Document or DocumentFragment")}function he(e,t=ae){try{if(!(e instanceof Node))throw new TypeError(`Expected a Node but got a ${c(e)}.`);if(!l(t))throw new TypeError(`Expected config to be an object but got ${c(t)}.`);const{allowElements:n,allowComments:r,allowAttributes:o,allowCustomElements:i,blockElements:a,dropAttributes:s,dropElements:u,allowUnknownMarkup:p}=de(t),d=document.createNodeIterator(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT);let f=d.root.nodeType===Node.ELEMENT_NODE?d.root:d.nextNode();for(;f instanceof Node;){switch(f.nodeType){case Node.ELEMENT_NODE:{if(!p&&(!(f instanceof HTMLElement)||f instanceof HTMLUnknownElement)){f.remove();break}const e=f.tagName.toLowerCase();Array.isArray(u)&&u.includes(e)?f.remove():Array.isArray(a)&&a.includes(e)?f.hasChildNodes()?f.replaceWith(...f.childNodes):f.remove():e.includes("-")&&!i||Array.isArray(n)&&!n.includes(e)?f.remove():f.hasAttributes()&&f.getAttributeNames().forEach((t=>{const n=f.getAttributeNode(t),{value:r}=n;B.includes(t)&&!le.includes(new URL(r,document.baseURI).protocol)?f.removeAttributeNode(n):l(s)?t in s&&["*",e].some((e=>s[t].includes(e)))&&f.removeAttributeNode(n):l(o)&&(t in o&&["*",e].some((e=>o[t].includes(e)))||f.removeAttributeNode(n))}));break}case Node.COMMENT_NODE:r||f.remove()}"template"===f.localName&&he(f.content,t),f=d.nextNode()}return e}catch(t){console.error(t),e.parentElement.removeChild(e)}}
|
|
39
|
+
const se=JSON.parse('{\n "allowCustomElements": false,\n "allowUnknownMarkup": false,\n "allowElements": [\n "a",\n "abbr",\n "acronym",\n "address",\n "area",\n "article",\n "aside",\n "audio",\n "b",\n "bdi",\n "bdo",\n "bgsound",\n "big",\n "blockquote",\n "body",\n "br",\n "button",\n "canvas",\n "caption",\n "center",\n "cite",\n "code",\n "col",\n "colgroup",\n "datalist",\n "dd",\n "del",\n "details",\n "dfn",\n "dialog",\n "dir",\n "div",\n "dl",\n "dt",\n "em",\n "fieldset",\n "figcaption",\n "figure",\n "font",\n "footer",\n "form",\n "h1",\n "h2",\n "h3",\n "h4",\n "h5",\n "h6",\n "head",\n "header",\n "hgroup",\n "hr",\n "html",\n "i",\n "img",\n "input",\n "ins",\n "kbd",\n "keygen",\n "label",\n "layer",\n "legend",\n "li",\n "link",\n "listing",\n "main",\n "map",\n "mark",\n "marquee",\n "menu",\n "meta",\n "meter",\n "nav",\n "nobr",\n "ol",\n "optgroup",\n "option",\n "output",\n "p",\n "picture",\n "popup",\n "pre",\n "progress",\n "q",\n "rb",\n "rp",\n "rt",\n "rtc",\n "ruby",\n "s",\n "samp",\n "section",\n "select",\n "selectmenu",\n "small",\n "source",\n "span",\n "strike",\n "strong",\n "style",\n "sub",\n "summary",\n "sup",\n "table",\n "tbody",\n "td",\n "tfoot",\n "th",\n "thead",\n "time",\n "tr",\n "track",\n "tt",\n "u",\n "ul",\n "var",\n "video",\n "wbr"\n ],\n "allowAttributes": {\n "abbr": ["*"],\n "accept": ["*"],\n "accept-charset": ["*"],\n "accesskey": ["*"],\n "action": ["*"],\n "align": ["*"],\n "alink": ["*"],\n "allow": ["*"],\n "allowfullscreen": ["*"],\n "alt": ["*"],\n "anchor": ["*"],\n "archive": ["*"],\n "as": ["*"],\n "async": ["*"],\n "autocapitalize": ["*"],\n "autocomplete": ["*"],\n "autocorrect": ["*"],\n "autofocus": ["*"],\n "autopictureinpicture": ["*"],\n "autoplay": ["*"],\n "axis": ["*"],\n "background": ["*"],\n "behavior": ["*"],\n "bgcolor": ["*"],\n "border": ["*"],\n "bordercolor": ["*"],\n "capture": ["*"],\n "cellpadding": ["*"],\n "cellspacing": ["*"],\n "challenge": ["*"],\n "char": ["*"],\n "charoff": ["*"],\n "charset": ["*"],\n "checked": ["*"],\n "cite": ["*"],\n "class": ["*"],\n "classid": ["*"],\n "clear": ["*"],\n "code": ["*"],\n "codebase": ["*"],\n "codetype": ["*"],\n "color": ["*"],\n "cols": ["*"],\n "colspan": ["*"],\n "compact": ["*"],\n "content": ["*"],\n "contenteditable": ["*"],\n "controls": ["*"],\n "controlslist": ["*"],\n "conversiondestination": ["*"],\n "coords": ["*"],\n "crossorigin": ["*"],\n "csp": ["*"],\n "data": ["*"],\n "datetime": ["*"],\n "declare": ["*"],\n "decoding": ["*"],\n "default": ["*"],\n "defer": ["*"],\n "dir": ["*"],\n "direction": ["*"],\n "dirname": ["*"],\n "disabled": ["*"],\n "disablepictureinpicture": ["*"],\n "disableremoteplayback": ["*"],\n "disallowdocumentaccess": ["*"],\n "download": ["*"],\n "draggable": ["*"],\n "elementtiming": ["*"],\n "enctype": ["*"],\n "end": ["*"],\n "enterkeyhint": ["*"],\n "event": ["*"],\n "exportparts": ["*"],\n "face": ["*"],\n "for": ["*"],\n "form": ["*"],\n "formaction": ["*"],\n "formenctype": ["*"],\n "formmethod": ["*"],\n "formnovalidate": ["*"],\n "formtarget": ["*"],\n "frame": ["*"],\n "frameborder": ["*"],\n "headers": ["*"],\n "height": ["*"],\n "hidden": ["*"],\n "high": ["*"],\n "href": ["*"],\n "hreflang": ["*"],\n "hreftranslate": ["*"],\n "hspace": ["*"],\n "http-equiv": ["*"],\n "id": ["*"],\n "imagesizes": ["*"],\n "imagesrcset": ["*"],\n "importance": ["*"],\n "impressiondata": ["*"],\n "impressionexpiry": ["*"],\n "incremental": ["*"],\n "inert": ["*"],\n "inputmode": ["*"],\n "integrity": ["*"],\n "invisible": ["*"],\n "is": ["*"],\n "ismap": ["*"],\n "keytype": ["*"],\n "kind": ["*"],\n "label": ["*"],\n "lang": ["*"],\n "language": ["*"],\n "latencyhint": ["*"],\n "leftmargin": ["*"],\n "link": ["*"],\n "list": ["*"],\n "loading": ["*"],\n "longdesc": ["*"],\n "loop": ["*"],\n "low": ["*"],\n "lowsrc": ["*"],\n "manifest": ["*"],\n "marginheight": ["*"],\n "marginwidth": ["*"],\n "max": ["*"],\n "maxlength": ["*"],\n "mayscript": ["*"],\n "media": ["*"],\n "method": ["*"],\n "min": ["*"],\n "minlength": ["*"],\n "multiple": ["*"],\n "muted": ["*"],\n "name": ["*"],\n "nohref": ["*"],\n "nomodule": ["*"],\n "nonce": ["*"],\n "noresize": ["*"],\n "noshade": ["*"],\n "novalidate": ["*"],\n "nowrap": ["*"],\n "object": ["*"],\n "open": ["*"],\n "optimum": ["*"],\n "part": ["*"],\n "pattern": ["*"],\n "ping": ["*"],\n "placeholder": ["*"],\n "playsinline": ["*"],\n "policy": ["*"],\n "popover": ["*"],\n "popovertarget": ["*"],\n "popovertargetaction": ["*"],\n "poster": ["*"],\n "preload": ["*"],\n "pseudo": ["*"],\n "readonly": ["*"],\n "referrerpolicy": ["*"],\n "rel": ["*"],\n "reportingorigin": ["*"],\n "required": ["*"],\n "resources": ["*"],\n "rev": ["*"],\n "reversed": ["*"],\n "role": ["*"],\n "rows": ["*"],\n "rowspan": ["*"],\n "rules": ["*"],\n "sandbox": ["*"],\n "scheme": ["*"],\n "scope": ["*"],\n "scopes": ["*"],\n "scrollamount": ["*"],\n "scrolldelay": ["*"],\n "scrolling": ["*"],\n "select": ["*"],\n "selected": ["*"],\n "shadowroot": ["*"],\n "shadowrootmode": ["*"],\n "shadowrootdelegatesfocus": ["*"],\n "shape": ["*"],\n "size": ["*"],\n "sizes": ["*"],\n "slot": ["*"],\n "span": ["*"],\n "spellcheck": ["*"],\n "src": ["*"],\n "srcdoc": ["*"],\n "srclang": ["*"],\n "srcset": ["*"],\n "standby": ["*"],\n "start": ["*"],\n "step": ["*"],\n "style": ["*"],\n "summary": ["*"],\n "tabindex": ["*"],\n "target": ["*"],\n "text": ["*"],\n "title": ["*"],\n "topmargin": ["*"],\n "translate": ["*"],\n "truespeed": ["*"],\n "trusttoken": ["*"],\n "type": ["*"],\n "usemap": ["*"],\n "valign": ["*"],\n "value": ["*"],\n "valuetype": ["*"],\n "version": ["*"],\n "virtualkeyboardpolicy": ["*"],\n "vlink": ["*"],\n "vspace": ["*"],\n "webkitdirectory": ["*"],\n "width": ["*"],\n "wrap": ["*"]\n }\n}'),le=e=>e.length>5&&"data-"===e.substring(0,5),ce=function(e,t,n=se){const r=me(t,n);e.replaceChildren(fe(r))},ue=["https:","blob:"];ue.includes(location.protocol)||ue.push(location.protocol);const pe=p((()=>function(e,{createHTML:t=(()=>{throw new TypeError("This policy does not provide `createHTML()`")}),createScript:n=(()=>{throw new TypeError("This policy does not provide `createScript()`")}),createScriptURL:r=(()=>{throw new TypeError("This policy does not provide `createScriptURL()`")})}){return z()?trustedTypes.createPolicy(e,{createHTML:t,createScript:n,createScriptURL:r}):Object.freeze({name:e,createHTML:(e,...n)=>t(e.toString(),...n),createScript:(e,...t)=>n(e.toString(),...t),createScriptURL:(e,...t)=>r(e.toString(),...t)})}("sanitizer-raw#html",{createHTML:e=>e}))),de=e=>pe().createHTML(e);function fe(e){const t=document.createDocumentFragment(),n=e.cloneNode(!0);return t.append(...n.head.childNodes,...n.body.childNodes),t}function he({allowAttributes:e,allowComments:t,allowElements:n,allowCustomElements:r,blockElements:o,dropAttributes:i,dropElements:a,allowUnknownMarkup:s,sanitizer:l}={},c){return l instanceof Sanitizer?he(l.getConfiguration(),c):(void 0===e&&void 0===i&&(e=se.allowAttributes),void 0===n&&void 0===a&&(n=se.allowElements),{allowAttributes:e,allowComments:t,allowElements:n,allowCustomElements:r,blockElements:o,dropAttributes:i,dropElements:a,allowUnknownMarkup:s})}function me(e,t=se){const n=(new DOMParser).parseFromString(de(e),"text/html");return Array.isArray(t.allowElements)&&!t.allowElements.includes("html")&&(t.allowElements=[...new Set([...t.allowElements,"html","head","body"])]),ge(n,t)}function ye(e,t=se){if(e instanceof Node){if(e.nodeType===Node.DOCUMENT_FRAGMENT_NODE)return ge(e,t);if(e.nodeType===Node.DOCUMENT_NODE)return ge(fe(e),t);throw new TypeError("sanitize requires a Document or DocumentFragment")}throw new TypeError("sanitize requires a Document or DocumentFragment")}function ge(e,t=se){try{if(!(e instanceof Node))throw new TypeError(`Expected a Node but got a ${u(e)}.`);if(!c(t))throw new TypeError(`Expected config to be an object but got ${u(t)}.`);const{allowElements:n,allowComments:r,allowAttributes:o,allowCustomElements:i,blockElements:a,dropAttributes:s,dropElements:l,allowUnknownMarkup:p}=he(t),d=document.createNodeIterator(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT);let f=d.root.nodeType===Node.ELEMENT_NODE?d.root:d.nextNode();for(;f instanceof Node;){switch(f.nodeType){case Node.ELEMENT_NODE:{if(!p&&(!(f instanceof HTMLElement)||f instanceof HTMLUnknownElement)){f.remove();break}const e=f.tagName.toLowerCase();Array.isArray(l)&&l.includes(e)?f.remove():Array.isArray(a)&&a.includes(e)?f.hasChildNodes()?f.replaceWith(...f.childNodes):f.remove():e.includes("-")&&!i||Array.isArray(n)&&!n.includes(e)?f.remove():f.hasAttributes()&&f.getAttributeNames().forEach((t=>{const n=f.getAttributeNode(t),{value:r}=n;$.includes(t)&&!ue.includes(new URL(r,document.baseURI).protocol)?f.removeAttributeNode(n):c(s)?t in s&&["*",e].some((e=>s[t].includes(e)))&&f.removeAttributeNode(n):c(o)&&(t in o&&["*",e].some((e=>o[t].includes(e)))||le(t)||f.removeAttributeNode(n))}));break}case Node.COMMENT_NODE:r||f.remove()}"template"===f.localName&&ge(f.content,t),f=d.nextNode()}return e}catch(t){console.error(t),e.parentElement.removeChild(e)}}
|
|
40
40
|
/**
|
|
41
41
|
* @copyright 2022-2023 Chris Zuber <admin@kernvalley.us>
|
|
42
42
|
*/
|
|
43
|
-
const ye=new WeakMap;const{setHTML:be,polyfill:ge}=function(e,t){return{setHTML:se,polyfill:function(){let n=!1;if("Sanitizer"in globalThis){if(globalThis.Sanitizer.getDefaultConfiguration instanceof Function||(globalThis.Sanitizer.getDefaultConfiguration=function(){return t},n=!0),!(globalThis.Sanitizer.prototype.getConfiguration instanceof Function)){const e=new WeakMap,t=globalThis.Sanitizer;globalThis.Sanitizer=class extends t{constructor({allowAttributes:n,allowComments:r,allowElements:o,allowCustomElements:i,blockElements:a,dropAttributes:s,dropElements:l,allowUnknownMarkup:c}=t.getDefaultConfiguration()){super({allowAttributes:n,allowComments:r,allowElements:o,allowCustomElements:i,blockElements:a,dropAttributes:s,dropElements:l,allowUnknownMarkup:c}),e.set(this,{allowAttributes:n,allowComments:r,allowElements:o,allowCustomElements:i,blockElements:a,dropAttributes:s,dropElements:l,allowUnknownMarkup:c})}getConfiguration(){return e.get(this)}},n=!0}globalThis.Sanitizer.prototype.sanitize instanceof Function||(globalThis.Sanitizer.prototype.sanitize=function(e){if(e instanceof Node){if([Node.DOCUMENT_NODE,Node.DOCUMENT_FRAGMENT_NODE].includes(e.nodeType))return me(e,this.getConfiguration());throw new TypeError("Expected a Document or DocumentFragment in `Sanitizer.sanitize()`.")}throw new TypeError("`Sanitizer.sanitize()` expects a `Node`")},n=!0),globalThis.Sanitizer.prototype.sanitizeFor instanceof Function||(globalThis.Sanitizer.prototype.sanitizeFor=function(e,t){const n=document.createElement(e);return se(n,t,this.getConfiguration()),n},n=!0),Element.prototype.setHTML instanceof Function||(Element.prototype.setHTML=function(e,n=t){se(this,e,n)},n=!0)}else globalThis.Sanitizer=e,n=!0;return n}}}(class e{constructor({allowElements:t,allowAttributes:n,blockElements:r,dropAttributes:o,dropElements:i,allowComments:a=ae.allowComments,allowCustomElements:s=ae.allowCustomElements,allowUnknownMarkup:l=ae.allowUnknownMarkup}=e.getDefaultConfiguration()){ye.set(this,{allowElements:t,allowComments:a,allowAttributes:n,allowCustomElements:s,blockElements:r,dropAttributes:o,dropElements:i,allowUnknownMarkup:l})}getConfiguration(){return ye.get(this)}sanitize(e){return me(e,this.getConfiguration())}sanitizeFor(e,t){const n=document.createElement(e);return n.setHTML(t,this.getConfiguration()),n}static getDefaultConfiguration(){return ae}},ae);ge();const we={get(){return Array.from(this.styleSheets).filter((e=>e.ownerNode.classList.contains("_adopted")))},set(e){if(!Array.isArray(e))throw new TypeError("Must be an array");{const t=new Set(this.adoptedStyleSheets);t.difference(e).forEach((e=>e.ownerNode.remove()));const n=[...new Set(e).difference(t)].map((e=>{const t=document.createElement("link"),n=new AbortController,r=n.signal,o=URL.createObjectURL(new File([],"adopted.css",{type:"text/css"}));return t.rel="stylesheet",t.href=o,t.classList.add("_adopted"),t.disabled=e.disabled,t.addEventListener("load",(({target:r})=>{n.abort(),t.media=e.media.mediaText,[...e.cssRules].forEach(((e,t)=>{r.sheet.insertRule(e.cssText,t)})),setTimeout((()=>URL.revokeObjectURL(r.href)),100)}),{once:!0,signal:r}),t.addEventListener("error",(({target:e})=>{n.abort(),URL.revokeObjectURL(e.href)}),{once:!0,signal:r}),t}));this instanceof Document?this.head.append(...n):this.append(...n)}}};function Te(e){for(;e.cssRules.length>0;)e.deleteRule(0)}e(Document,"parseHTML",((...e)=>fe(...e))),t(Document.prototype,"adoptedStyleSheets",we),"ShadowRoot"in globalThis&&t(ShadowRoot.prototype,"adoptedStyleSheets",we);try{new CSSStyleSheet}catch{const Ce=globalThis.CSSStyleSheet;globalThis.CSSStyleSheet=function({disabled:e=!1,media:t}={}){const n=function(e="",{disabled:t=!1,media:n}={}){const r=Document.parseHTML(`<style>${e}</style>`,{sanitizer:new Sanitizer({allowElements:["style","html","head","body"]})}).styleSheets.item(0);return"string"==typeof n&&r.media.appendMedium(n),r.disabled=t,r}("#dfgbkjdfg{color:red;}",{disabled:e,media:t});return n.deleteRule(0),n},globalThis.CSSStyleSheet.prototype=Ce.prototype,Ce.prototype.constructor=globalThis.CSSStyleSheet}CSSStyleSheet.prototype.replace instanceof Function||(CSSStyleSheet.prototype.replace=function(e){const t=document.createElement("link"),n=new AbortController,{resolve:r,reject:o,promise:i}=Promise.withResolvers();return t.addEventListener("load",(({target:e})=>{Te(this),[...e.sheet.cssRules].forEach(((e,t)=>this.insertRule(e.cssText,t))),r(this),n.abort(),URL.revokeObjectURL(e.href),e.remove()}),{once:!0,signal:n.signal}),t.addEventListener("error",(({target:e})=>{const t=new DOMException("Error loading stylesheet.");o(t),n.abort(t),URL.revokeObjectURL(e.href),e.remove()}),{once:!0,signal:n.signal}),t.rel="stylesheet",t.crossOrigin="anonymous",t.referrerPolicy="no-referrer",t.media="no-op",t.href=URL.createObjectURL(new File([e],"tmp.css",{type:"text/css"})),document.head.append(t),i}),CSSStyleSheet.prototype.replaceSync instanceof Function||(CSSStyleSheet.prototype.replaceSync=function(e){const t=Document.parseHTML(`<style>${e}</style>`,{sanitizer:new Sanitizer({allowElements:["style","html","head","body"]})}).styleSheets.item(0);Te(this),[...t.cssRules].forEach(((e,t)=>this.insertRule(e.cssText,t)))});const ve={ariaAtomic:"aria-atomic",ariaAutoComplete:"aria-autocomplete",ariaBusy:"aria-busy",ariaChecked:"aria-checked",ariaColCount:"aria-colcount",ariaColIndex:"aria-colindex",ariaColIndexText:"aria-colindextext",ariaColSpan:"aria-colspan",ariaCurrent:"aria-current",ariaDisabled:"aria-disabled",ariaExpanded:"aria-expanded",ariaHasPopup:"aria-haspopup",ariaHidden:"aria-hidden",ariaInvalid:"aria-invalid",ariaKeyShortcuts:"aria-keyshortcuts",ariaLabel:"aria-label",ariaLevel:"aria-level",ariaLive:"aria-live",ariaModal:"aria-modal",ariaMultiLine:"aria-multiline",ariaMultiSelectable:"aria-multiselectable",ariaOrientation:"aria-orientation",ariaPlaceholder:"aria-placeholder",ariaPosInSet:"aria-posinset",ariaPressed:"aria-pressed",ariaReadOnly:"aria-readonly",ariaRelevant:"aria-relevant",ariaRequired:"aria-required",ariaRoleDescription:"aria-roledescription",ariaRowCount:"aria-rowcount",ariaRowIndex:"aria-rowindex",ariaRowIndexText:"aria-rowindextext",ariaRowSpan:"aria-rowspan",ariaSelected:"aria-selected",ariaSetSize:"aria-setsize",ariaSort:"aria-sort",ariaValueMax:"aria-valuemax",ariaValueMin:"aria-valuemin",ariaValueNow:"aria-valuenow",ariaValueText:"aria-valuetext",role:"role"};if(HTMLScriptElement.supports instanceof Function||(HTMLScriptElement.supports=function(e){switch(e.toLowerCase()){case"classic":return!0;case"module":return"noModule"in HTMLScriptElement.prototype;default:return!1}}),!Element.prototype.hasOwnProperty(ve.role)){const Ie=!0,je=!0,De=Object.fromEntries(Object.entries(ve).map((([e,t])=>[e,{get:function(){return this.getAttribute(t)},set:function(e){"string"==typeof e?this.setAttribute(t,e):this.removeAttribute(t)},enumerable:Ie,configurable:je}])));Object.defineProperties(Element.prototype,De)}if(!HTMLElement.prototype.hasOwnProperty("inert")){const Re=new WeakMap,He=e=>{Re.has(e)&&(e.tabIndex=Re.get(e)),e.hasChildNodes()&&[...e.children].forEach(He)},Ue=e=>{-1!==e.tabIndex&&(Re.set(e,e.tabIndex),e.tabIndex=-1),e.hasChildNodes()&&[...e.children].forEach(Ue)};Object.defineProperty(HTMLElement.prototype,"inert",{get:function(){return this.hasAttribute("inert")},set:function(e){e?(this.setAttribute("aria-hidden","true"),this.setAttribute("inert",""),Ue(this)):(this.removeAttribute("aria-hidden"),this.removeAttribute("inert"),He(this))},enumerable:!0,configurable:!0})}if(HTMLImageElement.prototype.hasOwnProperty("complete")||Object.defineProperty(HTMLImageElement.prototype,"complete",{get:function(){return""===this.src||this.naturalHeight>0}}),HTMLImageElement.prototype.decode instanceof Function||(HTMLImageElement.prototype.decode=function(){return this.complete?Promise.resolve():new Promise(((e,t)=>{const n=()=>{this.removeEventListener("error",r),this.removeEventListener("load",n),e()},r=e=>{this.removeEventListener("error",r),this.removeEventListener("load",n),t(e)};this.addEventListener("load",n),this.addEventListener("error",r)}))}),Element.prototype.setHTML instanceof Function?function(e,t,n){const{value:r,enumerable:o,configurable:i,writable:a}=Object.getOwnPropertyDescriptor(e,t),s=n(r);if(!(s instanceof Function))throw new TypeError(`Error overwriting ${t}. The func MUST be a function that accepts the original as an argument and return a function.`);Object.defineProperty(e,t,{value:s,enumerable:o,configurable:i,writable:a})}(Element.prototype,"setHTML",(function(e){return function(t,n={}){if(n.sanitizer instanceof Sanitizer)e.call(this,t,n);else{const r=new Sanitizer(function({allowAttributes:e,allowComments:t,allowElements:n,allowCustomElements:r,blockElements:o,dropAttributes:i,dropElements:a,allowUnknownMarkup:s}={}){return void 0===e&&void 0===i&&(e=ae.allowAttributes),void 0===n&&void 0===a&&(n=ae.allowElements),{allowAttributes:e,allowComments:t,allowElements:n,allowCustomElements:r,blockElements:o,dropAttributes:i,dropElements:a,allowUnknownMarkup:s}}(n));e.call(this,t,{sanitizer:r})}}})):Element.prototype.setHTML=function(e,t=ae){se(this,e,t)},!HTMLTemplateElement.prototype.hasOwnProperty("shadowRootMode")){Object.defineProperty(HTMLTemplateElement.prototype,"shadowRootMode",{get:function(){return this.getAttribute("shadowrootmode")},set:function(e){this.setAttribute("shadowrootmode",e)},enumerable:!0,configurable:!0});const qe=(e=document)=>{e.querySelectorAll("template[shadowrootmode]").forEach((e=>{const t=e.parentElement.attachShadow({mode:e.shadowRootMode});t.append(e.content),e.remove(),qe(t)}))};"loading"===document.readyState?document.addEventListener("readystatechange",(()=>qe(document)),{once:!0}):qe(document)}HTMLFormElement.prototype.requestSubmit instanceof Function||(HTMLFormElement.prototype.requestSubmit=function(e){if(void 0===e){const e=document.createElement("button");e.type="submit",e.hidden=!0,this.append(e),this.requestSubmit(e),setTimeout((()=>e.remove()),100)}else{if(!(e instanceof HTMLButtonElement||e instanceof HTMLInputElement))throw new TypeError("HTMLFormElement.requestSubmit: The submitter is not a submit button.");if(!("submit"===e.type||e instanceof HTMLInputElement&&"image"===e.type))throw new TypeError("HTMLFormElement.requestSubmit: The submitter is not a submit button.");if(!this.isSameNode(e.form))throw new DOMException("HTMLFormElement.requestSubmit: The submitter is not owned by this form.","NotFoundError");e.click()}}),"loading"in HTMLIFrameElement.prototype||t(HTMLIFrameElement.prototype,"loading",{get:function(){return this.getAttribute("loading")||"auto"},set:function(e){this.setAttribute("loading",e)}}),"credentialless"in HTMLIFrameElement.prototype||t(HTMLIFrameElement.prototype,"credentialless",{get:function(){return this.hasAttribute("credentialless")},set:function(e){this.toggleAttribute("credentialless",e)}});const Ee="Expected a set-like object.",Se=["has","keys"],Ae=["size"],Me=e=>e instanceof Set,Oe=e=>Me(e)||"object"==typeof e&&null!==e&&Se.every((t=>e[t]instanceof Function))&&Ae.every((t=>t in e));Set.prototype.intersection instanceof Function||(Set.prototype.intersection=function(e){if(!Oe(e))throw new TypeError(Ee);return new Set([...this].filter((t=>e.has(t))))}),Set.prototype.difference instanceof Function||(Set.prototype.difference=function(e){if(!Oe(e))throw new TypeError(Ee);return new Set([...this].filter((t=>!e.has(t))))}),Set.prototype.union instanceof Function||(Set.prototype.union=function(e){return new Set([...this,...e])}),Set.prototype.isSubsetOf instanceof Function||(Set.prototype.isSubsetOf=function(e){if(!Oe(e))throw new TypeError(Ee);return[...this].every((t=>e.has(t)))}),Set.prototype.isSupersetOf instanceof Function||(Set.prototype.isSupersetOf=function(e){if(!Oe(e))throw new TypeError(Ee);return Me(e)?e.isSubsetOf(this):new Set(e.keys()).isSubsetOf(this)}),Set.prototype.symmetricDifference instanceof Function||(Set.prototype.symmetricDifference=function(e){if(!Oe(e))throw new TypeError(Ee);return Me(e)?new Set([...this.difference(e),...e.difference(this)]):new Set([...this.difference(e),...new Set(e.keys()).difference(this)])}),Set.prototype.isDisjointFrom instanceof Function||(Set.prototype.isDisjointFrom=function(e){if(!Oe(e))throw new TypeError(Ee);return new Set([...this,...e]).size===this.size+e.size}),WeakMap.prototype.emplace instanceof Function||(WeakMap.prototype.emplace=function(e,{insert:t,update:n}={}){const r=this.has(e);if(r&&n instanceof Function){const t=this.get(e),r=n.call(this,t,e,this);return r!==t&&this.set(e,t),r}if(r)return this.get(e);if(t instanceof Function){const n=t.call(this,e,this);return this.set(e,n),n}throw new Error("Key is not found and no `insert()` given")}),function(){if("screen"in globalThis&&!(globalThis.getScreenDetails instanceof Function)){class e extends EventTarget{get availHeight(){return screen.availHeight}get availLeft(){return screen.availLeft}get availTop(){return screen.availTop}get availWidth(){return screen.availWidth}get colorDepth(){return screen.colorDepth}get devicePixelRatio(){return globalThis.devicePixelRatio||1}get height(){return screen.height}get isExtended(){return screen.isExtended}get isInternal(){return!0}get isPrimary(){return!0}get label(){return"Unknown"}get orientation(){return screen.orientation}get pixelDepth(){return screen.pixelDepth}get top(){return screen.top}get width(){return screen.width}}class t extends EventTarget{get currentScreen(){return new e}get screens(){return[this.currentScreen]}}Object.defineProperty(Screen.prototype,"isExtended",{enumerable:!0,configurable:!0,get:()=>!1}),globalThis.getScreenDetails=async()=>new t}}();
|
|
43
|
+
const be=new WeakMap;const{setHTML:we,polyfill:Te}=function(e,t){return{setHTML:ce,polyfill:function(){let n=!1;if("Sanitizer"in globalThis){if(globalThis.Sanitizer.getDefaultConfiguration instanceof Function||(globalThis.Sanitizer.getDefaultConfiguration=function(){return t},n=!0),!(globalThis.Sanitizer.prototype.getConfiguration instanceof Function)){const e=new WeakMap,t=globalThis.Sanitizer;globalThis.Sanitizer=class extends t{constructor({allowAttributes:n,allowComments:r,allowElements:o,allowCustomElements:i,blockElements:a,dropAttributes:s,dropElements:l,allowUnknownMarkup:c}=t.getDefaultConfiguration()){super({allowAttributes:n,allowComments:r,allowElements:o,allowCustomElements:i,blockElements:a,dropAttributes:s,dropElements:l,allowUnknownMarkup:c}),e.set(this,{allowAttributes:n,allowComments:r,allowElements:o,allowCustomElements:i,blockElements:a,dropAttributes:s,dropElements:l,allowUnknownMarkup:c})}getConfiguration(){return e.get(this)}},n=!0}globalThis.Sanitizer.prototype.sanitize instanceof Function||(globalThis.Sanitizer.prototype.sanitize=function(e){if(e instanceof Node){if([Node.DOCUMENT_NODE,Node.DOCUMENT_FRAGMENT_NODE].includes(e.nodeType))return ye(e,this.getConfiguration());throw new TypeError("Expected a Document or DocumentFragment in `Sanitizer.sanitize()`.")}throw new TypeError("`Sanitizer.sanitize()` expects a `Node`")},n=!0),globalThis.Sanitizer.prototype.sanitizeFor instanceof Function||(globalThis.Sanitizer.prototype.sanitizeFor=function(e,t){const n=document.createElement(e);return ce(n,t,this.getConfiguration()),n},n=!0),Element.prototype.setHTML instanceof Function||(Element.prototype.setHTML=function(e,n=t){ce(this,e,n)},n=!0)}else globalThis.Sanitizer=e,n=!0;return n}}}(class e{constructor({allowElements:t,allowAttributes:n,blockElements:r,dropAttributes:o,dropElements:i,allowComments:a=se.allowComments,allowCustomElements:s=se.allowCustomElements,allowUnknownMarkup:l=se.allowUnknownMarkup}=e.getDefaultConfiguration()){be.set(this,{allowElements:t,allowComments:a,allowAttributes:n,allowCustomElements:s,blockElements:r,dropAttributes:o,dropElements:i,allowUnknownMarkup:l})}getConfiguration(){return be.get(this)}sanitize(e){return ye(e,this.getConfiguration())}sanitizeFor(e,t){const n=document.createElement(e);return n.setHTML(t,this.getConfiguration()),n}static getDefaultConfiguration(){return se}},se);Te();const ve={get(){return Array.from(this.styleSheets).filter((e=>e.ownerNode.classList.contains("_adopted")))},set(e){if(!Array.isArray(e))throw new TypeError("Must be an array");{const t=new Set(this.adoptedStyleSheets);t.difference(e).forEach((e=>e.ownerNode.remove()));const n=[...new Set(e).difference(t)].map((e=>{const t=document.createElement("link"),n=new AbortController,r=n.signal,o=URL.createObjectURL(new File([],"adopted.css",{type:"text/css"}));return t.rel="stylesheet",t.href=o,t.classList.add("_adopted"),t.disabled=e.disabled,t.addEventListener("load",(({target:r})=>{n.abort(),t.media=e.media.mediaText,[...e.cssRules].forEach(((e,t)=>{r.sheet.insertRule(e.cssText,t)})),setTimeout((()=>URL.revokeObjectURL(r.href)),100)}),{once:!0,signal:r}),t.addEventListener("error",(({target:e})=>{n.abort(),URL.revokeObjectURL(e.href)}),{once:!0,signal:r}),t}));this instanceof Document?this.head.append(...n):this.append(...n)}}};function Ee(e){for(;e.cssRules.length>0;)e.deleteRule(0)}t(Document,"parseHTML",((...e)=>me(...e))),n(Document.prototype,"adoptedStyleSheets",ve),"ShadowRoot"in globalThis&&n(ShadowRoot.prototype,"adoptedStyleSheets",ve);try{new CSSStyleSheet}catch{const He=globalThis.CSSStyleSheet;globalThis.CSSStyleSheet=function({disabled:e=!1,media:t}={}){const n=function(e="",{disabled:t=!1,media:n}={}){const r=Document.parseHTML(`<style>${e}</style>`,{sanitizer:new Sanitizer({allowElements:["style","html","head","body"]})}).styleSheets.item(0);return"string"==typeof n&&r.media.appendMedium(n),r.disabled=t,r}("#dfgbkjdfg{color:red;}",{disabled:e,media:t});return n.deleteRule(0),n},globalThis.CSSStyleSheet.prototype=He.prototype,He.prototype.constructor=globalThis.CSSStyleSheet}CSSStyleSheet.prototype.replace instanceof Function||(CSSStyleSheet.prototype.replace=function(e){const t=document.createElement("link"),n=new AbortController,{resolve:r,reject:o,promise:i}=Promise.withResolvers();return t.addEventListener("load",(({target:e})=>{Ee(this),[...e.sheet.cssRules].forEach(((e,t)=>this.insertRule(e.cssText,t))),r(this),n.abort(),URL.revokeObjectURL(e.href),e.remove()}),{once:!0,signal:n.signal}),t.addEventListener("error",(({target:e})=>{const t=new DOMException("Error loading stylesheet.");o(t),n.abort(t),URL.revokeObjectURL(e.href),e.remove()}),{once:!0,signal:n.signal}),t.rel="stylesheet",t.crossOrigin="anonymous",t.referrerPolicy="no-referrer",t.media="no-op",t.href=URL.createObjectURL(new File([e],"tmp.css",{type:"text/css"})),document.head.append(t),i}),CSSStyleSheet.prototype.replaceSync instanceof Function||(CSSStyleSheet.prototype.replaceSync=function(e){const t=Document.parseHTML(`<style>${e}</style>`,{sanitizer:new Sanitizer({allowElements:["style","html","head","body"]})}).styleSheets.item(0);Ee(this),[...t.cssRules].forEach(((e,t)=>this.insertRule(e.cssText,t)))});const Se={ariaAtomic:"aria-atomic",ariaAutoComplete:"aria-autocomplete",ariaBusy:"aria-busy",ariaChecked:"aria-checked",ariaColCount:"aria-colcount",ariaColIndex:"aria-colindex",ariaColIndexText:"aria-colindextext",ariaColSpan:"aria-colspan",ariaCurrent:"aria-current",ariaDisabled:"aria-disabled",ariaExpanded:"aria-expanded",ariaHasPopup:"aria-haspopup",ariaHidden:"aria-hidden",ariaInvalid:"aria-invalid",ariaKeyShortcuts:"aria-keyshortcuts",ariaLabel:"aria-label",ariaLevel:"aria-level",ariaLive:"aria-live",ariaModal:"aria-modal",ariaMultiLine:"aria-multiline",ariaMultiSelectable:"aria-multiselectable",ariaOrientation:"aria-orientation",ariaPlaceholder:"aria-placeholder",ariaPosInSet:"aria-posinset",ariaPressed:"aria-pressed",ariaReadOnly:"aria-readonly",ariaRelevant:"aria-relevant",ariaRequired:"aria-required",ariaRoleDescription:"aria-roledescription",ariaRowCount:"aria-rowcount",ariaRowIndex:"aria-rowindex",ariaRowIndexText:"aria-rowindextext",ariaRowSpan:"aria-rowspan",ariaSelected:"aria-selected",ariaSetSize:"aria-setsize",ariaSort:"aria-sort",ariaValueMax:"aria-valuemax",ariaValueMin:"aria-valuemin",ariaValueNow:"aria-valuenow",ariaValueText:"aria-valuetext",role:"role"};function Ae({currentTarget:e}){switch(e.popoverTargetAction){case"show":e.popoverTargetElement.showPopover();break;case"hide":e.popoverTargetElement.hidePopover();break;default:e.popoverTargetElement.togglePopover()}}if(globalThis.ToggleEvent instanceof Function){class Ue extends Event{#e;#t;constructor(e,{newState:t,oldState:n}){super(e,{bubbles:!0}),this.#e=t,this.#t=n}get newState(){return this.#e}get oldState(){return this.#t}}globalThis.ToggleEvent=Ue}if(!(HTMLElement.prototype.showPopover instanceof Function)){const qe=e=>e.classList.contains("_popover-open");Object.defineProperties(HTMLElement.prototype,{showPopover:{value:function(){if(!qe(this)){if(this.dispatchEvent(new ToggleEvent("beforetoggle",{oldState:"closed",newState:"open"})),"auto"===this.getAttribute("popover")){const e=new AbortController;document.body.addEventListener("click",(({target:t})=>{this.contains(t)||this.isSameNode(t.popoverTargetElement)||(e.abort(),this.hidePopover())}),{signal:e.signal,capture:!0}),document.body.addEventListener("keydown",(({key:t})=>{"Escape"===t&&(e.abort(),this.hidePopover())}),{signal:e.signal,capture:!0}),document.addEventListener("beforetoggle",(({target:t})=>{t.isSameNode(this)||"auto"!==t.getAttribute("popover")||(e.abort(),this.hidePopover())}),{signal:e.signal})}this.classList.add("_popover-open"),this.dispatchEvent(new ToggleEvent("toggle",{oldState:"closed",newState:"open"}))}}},hidePopover:{value:function(){qe(this)&&(this.dispatchEvent(new ToggleEvent("beforetoggle",{oldState:"open",newState:"closed"})),queueMicrotask((()=>this.classList.remove("_popover-open"))),this.dispatchEvent(new ToggleEvent("toggle",{oldState:"open",newState:"closed"})))}},togglePopover:{value:function(){qe(this)?this.hidePopover():this.showPopover()}}}),Object.defineProperties(HTMLButtonElement.prototype,{popoverTargetElement:{get(){return document.getElementById(this.getAttribute("popovertarget"))}},popoverTargetAction:{get(){return this.getAttribute("popovertargetaction")||"toggle"},set(e){this.setAttribute("popovertargetaction",e)}}}),function(e=document.body){e.querySelectorAll('button[popovertarget], input[type="button"][popovertarget]').forEach((e=>e.addEventListener("click",Ae)))}()}if(HTMLScriptElement.supports instanceof Function||(HTMLScriptElement.supports=function(e){switch(e.toLowerCase()){case"classic":return!0;case"module":return"noModule"in HTMLScriptElement.prototype;default:return!1}}),!Element.prototype.hasOwnProperty(Se.role)){const ze=!0,Be=!0,$e=Object.fromEntries(Object.entries(Se).map((([e,t])=>[e,{get:function(){return this.getAttribute(t)},set:function(e){"string"==typeof e?this.setAttribute(t,e):this.removeAttribute(t)},enumerable:ze,configurable:Be}])));Object.defineProperties(Element.prototype,$e)}if(!HTMLElement.prototype.hasOwnProperty("inert")){const _e=new WeakMap,Ve=e=>{_e.has(e)&&(e.tabIndex=_e.get(e)),e.hasChildNodes()&&[...e.children].forEach(Ve)},We=e=>{-1!==e.tabIndex&&(_e.set(e,e.tabIndex),e.tabIndex=-1),e.hasChildNodes()&&[...e.children].forEach(We)};Object.defineProperty(HTMLElement.prototype,"inert",{get:function(){return this.hasAttribute("inert")},set:function(e){e?(this.setAttribute("aria-hidden","true"),this.setAttribute("inert",""),We(this)):(this.removeAttribute("aria-hidden"),this.removeAttribute("inert"),Ve(this))},enumerable:!0,configurable:!0})}if(HTMLImageElement.prototype.hasOwnProperty("complete")||Object.defineProperty(HTMLImageElement.prototype,"complete",{get:function(){return""===this.src||this.naturalHeight>0}}),HTMLImageElement.prototype.decode instanceof Function||(HTMLImageElement.prototype.decode=function(){return this.complete?Promise.resolve():new Promise(((e,t)=>{const n=()=>{this.removeEventListener("error",r),this.removeEventListener("load",n),e()},r=e=>{this.removeEventListener("error",r),this.removeEventListener("load",n),t(e)};this.addEventListener("load",n),this.addEventListener("error",r)}))}),Element.prototype.setHTML instanceof Function?function(e,t,n){const{value:r,enumerable:o,configurable:i,writable:a}=Object.getOwnPropertyDescriptor(e,t),s=n(r);if(!(s instanceof Function))throw new TypeError(`Error overwriting ${t}. The func MUST be a function that accepts the original as an argument and return a function.`);Object.defineProperty(e,t,{value:s,enumerable:o,configurable:i,writable:a})}(Element.prototype,"setHTML",(function(e){return function(t,n={}){if(n.sanitizer instanceof Sanitizer)e.call(this,t,n);else{const r=new Sanitizer(function({allowAttributes:e,allowComments:t,allowElements:n,allowCustomElements:r,blockElements:o,dropAttributes:i,dropElements:a,allowUnknownMarkup:s}={}){return void 0===e&&void 0===i&&(e=se.allowAttributes),void 0===n&&void 0===a&&(n=se.allowElements),{allowAttributes:e,allowComments:t,allowElements:n,allowCustomElements:r,blockElements:o,dropAttributes:i,dropElements:a,allowUnknownMarkup:s}}(n));e.call(this,t,{sanitizer:r})}}})):Element.prototype.setHTML=function(e,t=se){ce(this,e,t)},!HTMLTemplateElement.prototype.hasOwnProperty("shadowRootMode")){Object.defineProperty(HTMLTemplateElement.prototype,"shadowRootMode",{get:function(){return this.getAttribute("shadowrootmode")},set:function(e){this.setAttribute("shadowrootmode",e)},enumerable:!0,configurable:!0});const Ge=(e=document)=>{e.querySelectorAll("template[shadowrootmode]").forEach((e=>{const t=e.parentElement.attachShadow({mode:e.shadowRootMode});t.append(e.content),e.remove(),Ge(t)}))};"loading"===document.readyState?document.addEventListener("readystatechange",(()=>Ge(document)),{once:!0}):Ge(document)}HTMLFormElement.prototype.requestSubmit instanceof Function||(HTMLFormElement.prototype.requestSubmit=function(e){if(void 0===e){const e=document.createElement("button");e.type="submit",e.hidden=!0,this.append(e),this.requestSubmit(e),setTimeout((()=>e.remove()),100)}else{if(!(e instanceof HTMLButtonElement||e instanceof HTMLInputElement))throw new TypeError("HTMLFormElement.requestSubmit: The submitter is not a submit button.");if(!("submit"===e.type||e instanceof HTMLInputElement&&"image"===e.type))throw new TypeError("HTMLFormElement.requestSubmit: The submitter is not a submit button.");if(!this.isSameNode(e.form))throw new DOMException("HTMLFormElement.requestSubmit: The submitter is not owned by this form.","NotFoundError");e.click()}}),"loading"in HTMLIFrameElement.prototype||n(HTMLIFrameElement.prototype,"loading",{get:function(){return this.getAttribute("loading")||"auto"},set:function(e){this.setAttribute("loading",e)}}),"credentialless"in HTMLIFrameElement.prototype||n(HTMLIFrameElement.prototype,"credentialless",{get:function(){return this.hasAttribute("credentialless")},set:function(e){this.toggleAttribute("credentialless",e)}});const Me="Expected a set-like object.",Le=["has","keys"],Oe=["size"],Fe=e=>e instanceof Set,xe=e=>Fe(e)||"object"==typeof e&&null!==e&&Le.every((t=>e[t]instanceof Function))&&Oe.every((t=>t in e));Set.prototype.intersection instanceof Function||(Set.prototype.intersection=function(e){if(!xe(e))throw new TypeError(Me);return new Set([...this].filter((t=>e.has(t))))}),Set.prototype.difference instanceof Function||(Set.prototype.difference=function(e){if(!xe(e))throw new TypeError(Me);return new Set([...this].filter((t=>!e.has(t))))}),Set.prototype.union instanceof Function||(Set.prototype.union=function(e){return new Set([...this,...e])}),Set.prototype.isSubsetOf instanceof Function||(Set.prototype.isSubsetOf=function(e){if(!xe(e))throw new TypeError(Me);return[...this].every((t=>e.has(t)))}),Set.prototype.isSupersetOf instanceof Function||(Set.prototype.isSupersetOf=function(e){if(!xe(e))throw new TypeError(Me);return Fe(e)?e.isSubsetOf(this):new Set(e.keys()).isSubsetOf(this)}),Set.prototype.symmetricDifference instanceof Function||(Set.prototype.symmetricDifference=function(e){if(!xe(e))throw new TypeError(Me);return Fe(e)?new Set([...this.difference(e),...e.difference(this)]):new Set([...this.difference(e),...new Set(e.keys()).difference(this)])}),Set.prototype.isDisjointFrom instanceof Function||(Set.prototype.isDisjointFrom=function(e){if(!xe(e))throw new TypeError(Me);return new Set([...this,...e]).size===this.size+e.size}),WeakMap.prototype.emplace instanceof Function||(WeakMap.prototype.emplace=function(e,{insert:t,update:n}={}){const r=this.has(e);if(r&&n instanceof Function){const t=this.get(e),r=n.call(this,t,e,this);return r!==t&&this.set(e,t),r}if(r)return this.get(e);if(t instanceof Function){const n=t.call(this,e,this);return this.set(e,n),n}throw new Error("Key is not found and no `insert()` given")}),function(){if("screen"in globalThis&&!(globalThis.getScreenDetails instanceof Function)){class e extends EventTarget{get availHeight(){return screen.availHeight}get availLeft(){return screen.availLeft}get availTop(){return screen.availTop}get availWidth(){return screen.availWidth}get colorDepth(){return screen.colorDepth}get devicePixelRatio(){return globalThis.devicePixelRatio||1}get height(){return screen.height}get isExtended(){return screen.isExtended}get isInternal(){return!0}get isPrimary(){return!0}get label(){return"Unknown"}get orientation(){return screen.orientation}get pixelDepth(){return screen.pixelDepth}get top(){return screen.top}get width(){return screen.width}}class t extends EventTarget{get currentScreen(){return new e}get screens(){return[this.currentScreen]}}Object.defineProperty(Screen.prototype,"isExtended",{enumerable:!0,configurable:!0,get:()=>!1}),globalThis.getScreenDetails=async()=>new t}}();
|
|
44
44
|
/**
|
|
45
45
|
* @copyright 2023 Chris Zuber <admin@kernvalley.us>
|
|
46
46
|
*/
|
|
47
|
-
const
|
|
47
|
+
const ke="user-blocking",Pe="user-visible",Ne="background";async function Ce(e,{delay:t=0,signal:n}={}){return new Promise(((r,o)=>{if(n instanceof AbortSignal&&n.aborted)o(n.reason);else{const i=new AbortController,a=setTimeout((()=>{r(e()),i.abort()}),t);n instanceof AbortSignal&&n.addEventListener("abort",(({target:e})=>{o(e.reason),clearTimeout(a)}),{once:!0,signal:i.signal})}}))}class Ie{async postTask(e,{priority:t=Pe,delay:n,signal:r}={}){return new Promise(((o,i)=>{if(r instanceof AbortSignal&&r.aborted)i(r.reason);else switch(t){case ke:"number"==typeof n&&!Number.isNaN(n)&&n>0?Ce(e,{delay:n,signal:r}).then(o,i):o((async()=>await e())());break;case Pe:if("number"==typeof n&&!Number.isNaN(n)&&n>0)Ce((()=>requestAnimationFrame((async()=>{try{const t=await e();o(t)}catch(e){i(e)}}))),{delay:n,signal:r}).catch(i);else{const t=new AbortController,n=requestAnimationFrame((async()=>{try{const t=await e();o(t)}catch(e){i(e)}finally{t.abort()}}));r instanceof AbortSignal&&r.addEventListener("abort",(({target:e})=>{cancelAnimationFrame(n),i(e.reason)}),{once:!0,signal:t.signal})}break;case Ne:if("number"==typeof n&&!Number.isNaN(n)&&n>0)Ce((()=>requestIdleCallback((async()=>{try{const t=await e();o(t)}catch(e){i(e)}}))),{delay:n,signal:r}).catch(i);else{const t=new AbortController,n=requestIdleCallback((async()=>{try{const t=await e();o(t)}catch(e){i(e)}finally{t.abort()}}));r instanceof AbortSignal&&r.addEventListener("abort",(({target:e})=>{cancelIdleCallback(n),i(e.reason)}),{once:!0,signal:t.signal})}break;default:throw new TypeError(`Scheduler.postTask: '${t}' (value of 'priority' member of SchedulerPostTaskOptions) is not a valid value for enumeration TaskPriority.`)}}))}}"scheduler"in globalThis||(globalThis.scheduler=new Ie)
|
|
48
48
|
/**
|
|
49
49
|
* @copyright 2023 Chris Zuber <admin@kernvalley.us>
|
|
50
50
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals
|
|
@@ -62,5 +62,5 @@ const Le="user-blocking",Fe="user-visible",xe="background";async function ke(e,{
|
|
|
62
62
|
* Additionally, if `internals.states._polyfilled`
|
|
63
63
|
* - Use `._state--*` in addition to `:--*` to query element internals states
|
|
64
64
|
* - This includes `:disabled` -> `._state--disabled` & `:invalid` -> `._state--invalid`
|
|
65
|
-
*/;const Ne={key:Symbol("key"),internals:Symbol("element-internals"),form:Symbol("form"),fieldset:Symbol("fieldset"),element:Symbol("element"),validity:Symbol("validity"),validationMessage:Symbol("validation-message"),value:Symbol("value"),state:Symbol("state"),formController:Symbol("form-controller"),anchor:Symbol("anchor"),customInputs:Symbol("custom-inputs")};if(!(HTMLElement.prototype.attachInternals instanceof Function)&&"FormDataEvent"in globalThis){const ze={valueMissing:!1,typeMismatch:!1,patternMismatch:!1,tooLong:!1,tooShort:!1,rangeUnderflow:!1,rangeOverflow:!1,stepMismatch:!1,badInput:!1,customError:!1,valid:!0},Be=e=>e.hasOwnProperty(Ne.fieldset)&&e[Ne.fieldset]instanceof HTMLFieldSetElement&&e[Ne.fieldset].disabled,$e=e=>e instanceof HTMLElement&&e.tagName.includes("-")&&customElements.get(e.tagName.toLowerCase()).formAssociated,_e=(e,t)=>function(n){if(n.target.reportValidity()){if(t.willValidate&&n.formData instanceof FormData){const r=t[Ne.value];r instanceof FormData?r.entries().forEach((([e,t])=>n.formData.set(e,t))):e.hasAttribute("name")&&n.formData.set(e.getAttribute("name"),t[Ne.value])}}else n.preventDefault(),n.stopImmediatePropagation(),n.stopPropagation()},Ve=(e,t)=>{Object.entries(t).forEach((([t,n])=>e.style.setProperty(t,n)))},We=e=>e.hasAttribute("form")&&document.forms[e.getAttribute("form")]||e.closest("form"),Ge=(e,t,n)=>{if(e instanceof HTMLFormElement){if(!(n instanceof HTMLElement&&n.tagName.includes("-")))throw new TypeError("Not a custom element");if(!(t instanceof Je||t instanceof globalThis.ElementInternals))throw new TypeError("Invalid ElementInternals");if(!$e(n))throw new TypeError(`${n.tagName} is not form associated.`);if(!(n.formAssociatedCallback instanceof Function))throw new TypeError(`${n.tagName} is missing a formAssociatedCallback method.`);{const r=new AbortController,o=n.closest("fieldset");o instanceof Element&&(n[Ne.fieldset]=o,o.hasOwnProperty(Ne.customInputs)||(o[Ne.customInputs]=new Set),o[Ne.customInputs].add(n),Ke.observe(o,Qe)),t[Ne.form]=e,t[Ne.formController]=r;const{checkValidity:i,reportValidity:a}=e;e.reportValidity=function(){return!!a.call(this)&&t.reportValidity()},e.checkValidity=function(){return!!i.call(this)&&t.checkValidity()},r.signal.addEventListener("abort",(()=>{e.reportValidity=a,e.checkValidity=i}),{once:!0}),e.addEventListener("formdata",_e(n,t),{signal:r.signal}),e.addEventListener("submit",(e=>{e.target.reportValidity()||(e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation())}),{signal:r.signal}),n.formResetCallback instanceof Function&&e.addEventListener("reset",(()=>n.formResetCallback()),{signal:r.signal})}}else if(t[Ne.formController]instanceof AbortController&&t[Ne.formController].abort(),t[Ne.form]=null,t[Ne.formController]=null,n.hasOwnProperty(Ne.fieldset)){const e=n[Ne.fieldset];e.hasOwnProperty(Ne.customInputs)&&(e[Ne.customInputs].delete(n),0===e[Ne.customInputs.size]&&delete e[Ne.customInputs]),n[Ne.fieldset]=null}},Ke=new MutationObserver((e=>{e.forEach((({target:t,type:n,attributeName:r})=>{if("attributes"===n&&"disabled"===r){const n=t.hasAttribute("disabled");if($e(t)&&t.hasOwnProperty(Ne.internals)&&t[Ne.internals].states.has("--disabled")!==n&&(1===e.length?!Be(t):t.hasAttribute("disabled")===Be(t)&&e.some((e=>e.target.isSameNode(t[Ne.fieldset]))))){const e=t[Ne.internals];n?e.states.add("--disabled"):e.states.delete("--disabled"),t.formDisabledCallback instanceof Function&&t.formDisabledCallback(n)}else"FIELDSET"!==t.tagName||!t.hasOwnProperty(Ne.customInputs)||1!==e.length&&e.some((e=>t[Ne.customInputs].has(e.target)))||t[Ne.customInputs].forEach((e=>{e.isConnected&&e.hasOwnProperty(Ne.internals)?e.hasAttribute("disabled")||(n?e[Ne.internals].states.add("--disabled"):e[Ne.internals].states.delete("--disabled"),e.formDisabledCallback instanceof Function&&e.formDisabledCallback(n)):t[Ne.customInputs].delete(e)}))}}))})),Qe={attributes:!0,attributeFilter:["disabled"]};class Je{constructor(e,t){if(t!==Ne.key)throw new TypeError("Illegal constructor");if(!(e instanceof HTMLElement))throw new TypeError("Must be called on an HTMLElement");if(!e.tagName.includes("-"))throw new DOMException("Cannot attach internals to a built-in element.");{const t=!0,n=!1,r=!0;Object.defineProperties(this,{[Ne.element]:{value:e,configurable:t,enumerable:n,writable:r},[Ne.form]:{value:null,configurable:t,enumerable:n,writable:r},[Ne.fieldset]:{value:null,configurable:t,enumerable:n,writable:r},[Ne.anchor]:{value:null,configurable:t,enumerable:n,writable:r},[Ne.validity]:{value:ze,configurable:t,enumerable:n,writable:r},[Ne.validationMessage]:{value:"",configurable:t,enumerable:n,writable:r},[Ne.value]:{value:null,configurable:t,enumerable:n,writable:r},[Ne.state]:{value:null,configurable:t,enumerable:n,writable:r},[Ne.formController]:{value:null,configurable:t,enumerable:n,writable:r}}),$e(e)&&Ke.observe(e,Qe),Object.defineProperty(e,Ne.internals,{value:this,enumerable:!1,configurable:!1,writable:!1}),setTimeout((()=>this.states.add("--element-internals-polyfilled")),10)}}get form(){return this[Ne.form]}get labels(){const e=this.form;return e instanceof HTMLFormElement&&0!==this[Ne.element].id.length?e.querySelectorAll(`label[for="${this[Ne.element].id}"]`):document.createDocumentFragment().childNodes}get _polyfilled(){return!0}get shadowRoot(){return this[Ne.element].shadowRoot}get validity(){return $e(this[Ne.element])?this[Ne.validity]:void 0}get validationMessage(){return $e(this[Ne.element])?this[Ne.validationMessage]||"":void 0}get willValidate(){const e=this[Ne.element];return $e(e)&&!Be(e)&&!["disabled","readonly"].some((t=>e.hasAttribute(t)))}checkValidity(){if(this.willValidate){if(this.validity.valid){const e=this[Ne.element].nextElementSibling;return e instanceof HTMLElement&&e.classList.contains("_element-internals-popup")&&e.remove(),!0}return this[Ne.element].dispatchEvent(new Event("invalid")),!1}return!0}reportValidity(){if(this.checkValidity())return!0;{const e=this.validationMessage;if("string"==typeof e&&0!==e.length){const{bottom:t,left:n}=this[Ne.element].getBoundingClientRect(),r=document.createElement("div");r.textContent=e,Ve(r,{position:"fixed","background-color":"#2b2a33",color:"#fafafa",top:`${t+2}px`,left:`${n}px`,"z-index":2147483647,"color-scheme":"light-dark","font-family":"system-ui, serif","font-size":"18px",display:"inline-block",padding:"0.6em 0.8em",border:"1px solid #1a1a1a","border-radius":"6px"}),r.classList.add("_element-internals-popup"),this[Ne.element].focus();const o=this[Ne.element].nextElementSibling;o instanceof Element&&o.classList.contains("_element-internals-popup")&&o.remove(),this[Ne.element].insertAdjacentElement("afterend",r),this[Ne.anchor]instanceof Element&&this[Ne.anchor].focus(),setTimeout((()=>{r.isConnected&&r.remove()}),3e3)}return!1}}setFormValue(e,t){if(!$e(this[Ne.element]))throw new DOMException("Not form associated");this[Ne.value]=e,this[Ne.state]=t}setValidity({valueMissing:e=!1,typeMismatch:t=!1,patternMismatch:n=!1,tooLong:r=!1,tooShort:o=!1,rangeUnderflow:i=!1,rangeOverflow:a=!1,stepMismatch:s=!1,badInput:l=!1,customError:c=!1},u="",p){if(!$e(this[Ne.element]))throw new DOMException("Not form associated");if(("string"!=typeof u||0===u.length)&&(e||t||n||r||o||i||a||s||l||c))throw new DOMException("Message required if any flags are true.");{const d=[e,t,n,r,o,i,a,s,l,c].every((e=>!1===e));this[Ne.validity]={valueMissing:e,typeMismatch:t,patternMismatch:n,tooLong:r,tooShort:o,rangeUnderflow:i,rangeOverflow:a,stepMismatch:s,badInput:l,customError:c,valid:d},this[Ne.validationMessage]=u,this[Ne.anchor]=p,d?(this.states.delete("--invalid"),this.states.add("--valid")):(this.states.add("--invalid"),this.states.delete("--valid"),this[Ne.element].dispatchEvent(new Event("invalid")))}}_associateForm(e,t){Ge(e,this,t)}_findAssociatedForm(e){return We(e)}}HTMLElement.prototype.attachInternals=function(){if(this.hasOwnProperty(Ne.internals))throw new DOMException("Invalid operation");if(this.tagName.includes("-"))return new Je(this,Ne.key);throw new DOMException("Cannot call attachInternals on built-in elements.")},globalThis.ElementInternals=Je}if("ElementInternals"in globalThis&&!("CustomStateSet"in globalThis)){const Xe="_state",Ze=new WeakMap,Ye=e=>{if(e.toString().startsWith("--"))return`${Xe}${e}`;throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value '${e}' must start with '--'.`)},{value:et,writable:tt,configurable:nt,enumerable:rt}=Object.getOwnPropertyDescriptor(HTMLElement.prototype,"attachInternals");class ot{constructor(e,t){if(t!==Ne.key)throw new TypeError("Illegal Constructor");if(!(e instanceof HTMLElement))throw new TypeError("el must be an HTMLElement");Ze.set(this,e),this.add("--custom-states-polyfilled")}get _polyfilled(){return!0}get size(){return[...this.values()].length}add(e){Ze.get(this).classList.add(Ye(e))}has(e){return Ze.get(this).classList.contains(Ye(e))}delete(e){const t=Ye(e);return!!Ze.get(this).classList.contains(t)&&(Ze.get(this).classList.remove(t),!0)}clear(){this.values().forEach((e=>this.delete(e)))}keys(){return this.values()}values(){return Ze.get(this).classList.values().filter((e=>e.startsWith(`${Xe}--`))).map((e=>e.substr(Xe.length)))}entries(){return this.values().map((e=>[e,e]))}forEach(e,t){this.values().forEach((n=>e.call(t||this,n,n,this)))}[Symbol.toStringTag](){return"CustomStateSet"}[Symbol.iterator](){return this.values()}}Object.defineProperty(HTMLElement.prototype,"attachInternals",{value:function(){const e=et.call(this);return Object.defineProperty(e,Ne.element,{value:this,enumerable:!1,writable:!1,configurable:!1}),Object.defineProperty(e,"states",{value:new ot(this,Ne.key),configurable:!0,enumberable:!0}),Object.is(e.shadowRoot,null)&&!Object.is(this.shadowRoot,null)&&Object.defineProperty(e,"shadowRoot",{value:this.shadowRoot,configurable:!0,enumerable:!0}),e},writable:tt,configurable:nt,enumerable:rt}),globalThis.CustomStateSet=ot,function(e){const t=Object.fromEntries(Object.keys(ve).map((e=>[e,{get:function(){return this[Ne.element][e]},set:function(t){this[Ne.element][e]=t},enumerable:!0,configurable:!0}])));Object.defineProperties(e,t)}(ElementInternals.prototype)}if(e(Response,"json",((e,{status:t=200,statusText:n="",headers:r=new Headers}={})=>r instanceof Headers?(r.set("Content-Type","application/json"),new Response(JSON.stringify(e),{status:t,statusText:n,headers:r})):Response.json(e,{status:t,statusText:n,headers:new Headers(r)}))),e(Response,"redirect",((e,t=302)=>new Response("",{status:t,headers:new Headers({Location:e})}))),!(globalThis.Record instanceof Function)){function it(e){if(new.target===it)throw new TypeError("Record is not a constructor");const t=Object.create(it.prototype);return Object.defineProperties(t,Object.fromEntries(Object.entries(e).map((([e,t])=>[e,{enumerable:!0,configurable:!1,writable:!1,value:t}])))),Object.freeze(t),t}it.prototype.constructor=it,Object.defineProperty(it.prototype,Symbol.toStringTag,{value:"Record",enumerable:!0,configurable:!1,writable:!1}),it.fromEntries=function(e){return it(Object.fromEntries(e))},globalThis.Record=it}if(!(globalThis.Tuple instanceof Function)){const at=e=>{const t=Array.apply(Object.create(st.prototype),e);return Object.setPrototypeOf(t,st.prototype),t};function st(...e){if(new.target===st)throw new TypeError("Tuple is not a constructor");const t=at(e);return Object.freeze(t),t}st.prototype.forEach=function(e,t){Array.prototype.forEach.call(this,e,t)},st.prototype.join=function(e=","){return Array.prototype.join.call(this,e)},st.prototype.concat=function(...e){return st(...this,...e)},st.prototype.slice=function(e,t){return st.from(Array.prototype.slice.call(this,e,t))},st.prototype.indexOf=function(e,t){return Array.prototype.indexOf.call(this,e,t)},st.prototype.lastIndexOf=function(e,t){return Array.prototype.lastIndexOf.call(this,e,t)},st.prototype.findIndex=function(e,t){return Array.prototype.findIndex.call(this,e,t)},st.prototype.find=function(e,t){return Array.prototype.find.call(this,e,t)},st.prototype.findLast=function(e,t){return Array.prototype.findLast.call(this,e,t)},st.prototype.findLastIndex=function(e,t){return Array.prototype.findLastIndex.call(this,e,t)},st.prototype.every=function(e,t){return Array.prototype.every.call(this,e,t)},st.prototype.some=function(e,t){return Array.prototype.some.call(this,e,t)},st.prototype.includes=function(e,t){return Array.prototype.includes.call(this,e,t)},st.prototype.map=function(e,t){return st.from(Array.prototype.map.call(this,e,t))},st.prototype.filter=function(e,t){return st.from(Array.prototype.filter.call(this,e,t))},st.prototype.flat=function(e){return st.from(Array.prototype.flat.call(this,e))},st.prototype.flatMap=function(e,t){return st.from(Array.prototype.flatMap.call(this,e,t))},st.prototype.at=function(e){return Array.prototype.at.call(this,e)},st.prototype.reduce=function(e,t){return st.from(Array.prototype.reduce.call(this,e,t))},st.prototype.reduceRight=function(e,t){return st.from(Array.prototype.reduceRight.call(this,e,t))},st.prototype.toSorted=function(e){return st.from(Array.prototype.toSorted.call(this,e))},st.prototype.toSpliced=function(e,t,...n){return st.from(Array.prototype.toSpliced.call(this,e,t,...n))},st.prototype.toReversed=function(){return st.from(Array.prototype.toReversed.apply(this))},st.prototype.with=function(e,t){return st.from(Array.prototype.with.call(this,e,t))},st.prototype.toLocaleString=function(e,t){return Array.prototype.toLocaleString.call(this,e,t)},st.prototype.toJSON=function(){return[...this]},st.prototype.keys=function(){return Array.prototype.keys.apply(this)},st.prototype.values=function(){return Array.prototype.values.apply(this)},st.prototype.entries=function(){return Array.prototype.entries.apply(this)},st.prototype[Symbol.iterator]=function(){return Array.prototype[Symbol.iterator].apply(this)},st.from=function(e,t,n){const r=at([]);return Array.prototype.push.apply(r,Array.from(e,t,n)),Object.freeze(r),r},st.of=function(...e){return st.from(e)},Object.defineProperties(st.prototype,{length:{get:function(){return Object.getOwnPropertyDescriptor(Array.prototype,"length").get.apply(this)},enumerable:!0,configurable:!1},lastItem:{get:function(){return this[this.lastIndex]},enumerable:!0,configurable:!1},lastIndex:{get:function(){return Object.getOwnPropertyDescriptor(Array.prototype,"lastIndex").get.apply(this)},enumerable:!0,configurable:!1},[Symbol.toStringTag]:{value:"Tuple",enumerable:!0,configurable:!1,writable:!1}}),globalThis.Tuple=st}if(!(JSON.parseImmutable instanceof Function)){function lt(e){return"object"==typeof e?null===e?null:Array.isArray(e)?Tuple.from(e.map((e=>lt(e)))):Record.fromEntries(Object.entries(e).map((([e,t])=>[e,lt(t)]))):e}JSON.parseImmutable=function(e){return JSON.parse(e,((e,t)=>lt(t)))}}}();
|
|
65
|
+
*/;const je={key:Symbol("key"),internals:Symbol("element-internals"),form:Symbol("form"),fieldset:Symbol("fieldset"),element:Symbol("element"),validity:Symbol("validity"),validationMessage:Symbol("validation-message"),value:Symbol("value"),state:Symbol("state"),formController:Symbol("form-controller"),anchor:Symbol("anchor"),customInputs:Symbol("custom-inputs")};if(!(HTMLElement.prototype.attachInternals instanceof Function)&&"FormDataEvent"in globalThis){const Ke={valueMissing:!1,typeMismatch:!1,patternMismatch:!1,tooLong:!1,tooShort:!1,rangeUnderflow:!1,rangeOverflow:!1,stepMismatch:!1,badInput:!1,customError:!1,valid:!0},Qe=e=>e.hasOwnProperty(je.fieldset)&&e[je.fieldset]instanceof HTMLFieldSetElement&&e[je.fieldset].disabled,Je=e=>e instanceof HTMLElement&&e.tagName.includes("-")&&customElements.get(e.tagName.toLowerCase()).formAssociated,Xe=(e,t)=>function(n){if(n.target.reportValidity()){if(t.willValidate&&n.formData instanceof FormData){const r=t[je.value];r instanceof FormData?r.entries().forEach((([e,t])=>n.formData.set(e,t))):e.hasAttribute("name")&&n.formData.set(e.getAttribute("name"),t[je.value])}}else n.preventDefault(),n.stopImmediatePropagation(),n.stopPropagation()},Ze=(e,t)=>{Object.entries(t).forEach((([t,n])=>e.style.setProperty(t,n)))},Ye=e=>e.hasAttribute("form")&&document.forms[e.getAttribute("form")]||e.closest("form"),et=(e,t,n)=>{if(e instanceof HTMLFormElement){if(!(n instanceof HTMLElement&&n.tagName.includes("-")))throw new TypeError("Not a custom element");if(!(t instanceof rt||t instanceof globalThis.ElementInternals))throw new TypeError("Invalid ElementInternals");if(!Je(n))throw new TypeError(`${n.tagName} is not form associated.`);if(!(n.formAssociatedCallback instanceof Function))throw new TypeError(`${n.tagName} is missing a formAssociatedCallback method.`);{const r=new AbortController,o=n.closest("fieldset");o instanceof Element&&(n[je.fieldset]=o,o.hasOwnProperty(je.customInputs)||(o[je.customInputs]=new Set),o[je.customInputs].add(n),tt.observe(o,nt)),t[je.form]=e,t[je.formController]=r;const{checkValidity:i,reportValidity:a}=e;e.reportValidity=function(){return!!a.call(this)&&t.reportValidity()},e.checkValidity=function(){return!!i.call(this)&&t.checkValidity()},r.signal.addEventListener("abort",(()=>{e.reportValidity=a,e.checkValidity=i}),{once:!0}),e.addEventListener("formdata",Xe(n,t),{signal:r.signal}),e.addEventListener("submit",(e=>{e.target.reportValidity()||(e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation())}),{signal:r.signal}),n.formResetCallback instanceof Function&&e.addEventListener("reset",(()=>n.formResetCallback()),{signal:r.signal})}}else if(t[je.formController]instanceof AbortController&&t[je.formController].abort(),t[je.form]=null,t[je.formController]=null,n.hasOwnProperty(je.fieldset)){const e=n[je.fieldset];e.hasOwnProperty(je.customInputs)&&(e[je.customInputs].delete(n),0===e[je.customInputs.size]&&delete e[je.customInputs]),n[je.fieldset]=null}},tt=new MutationObserver((e=>{e.forEach((({target:t,type:n,attributeName:r})=>{if("attributes"===n&&"disabled"===r){const n=t.hasAttribute("disabled");if(Je(t)&&t.hasOwnProperty(je.internals)&&t[je.internals].states.has("--disabled")!==n&&(1===e.length?!Qe(t):t.hasAttribute("disabled")===Qe(t)&&e.some((e=>e.target.isSameNode(t[je.fieldset]))))){const e=t[je.internals];n?e.states.add("--disabled"):e.states.delete("--disabled"),t.formDisabledCallback instanceof Function&&t.formDisabledCallback(n)}else"FIELDSET"!==t.tagName||!t.hasOwnProperty(je.customInputs)||1!==e.length&&e.some((e=>t[je.customInputs].has(e.target)))||t[je.customInputs].forEach((e=>{e.isConnected&&e.hasOwnProperty(je.internals)?e.hasAttribute("disabled")||(n?e[je.internals].states.add("--disabled"):e[je.internals].states.delete("--disabled"),e.formDisabledCallback instanceof Function&&e.formDisabledCallback(n)):t[je.customInputs].delete(e)}))}}))})),nt={attributes:!0,attributeFilter:["disabled"]};class rt{constructor(e,t){if(t!==je.key)throw new TypeError("Illegal constructor");if(!(e instanceof HTMLElement))throw new TypeError("Must be called on an HTMLElement");if(!e.tagName.includes("-"))throw new DOMException("Cannot attach internals to a built-in element.");{const t=!0,n=!1,r=!0;Object.defineProperties(this,{[je.element]:{value:e,configurable:t,enumerable:n,writable:r},[je.form]:{value:null,configurable:t,enumerable:n,writable:r},[je.fieldset]:{value:null,configurable:t,enumerable:n,writable:r},[je.anchor]:{value:null,configurable:t,enumerable:n,writable:r},[je.validity]:{value:Ke,configurable:t,enumerable:n,writable:r},[je.validationMessage]:{value:"",configurable:t,enumerable:n,writable:r},[je.value]:{value:null,configurable:t,enumerable:n,writable:r},[je.state]:{value:null,configurable:t,enumerable:n,writable:r},[je.formController]:{value:null,configurable:t,enumerable:n,writable:r}}),Je(e)&&tt.observe(e,nt),Object.defineProperty(e,je.internals,{value:this,enumerable:!1,configurable:!1,writable:!1}),setTimeout((()=>this.states.add("--element-internals-polyfilled")),10)}}get form(){return this[je.form]}get labels(){const e=this.form;return e instanceof HTMLFormElement&&0!==this[je.element].id.length?e.querySelectorAll(`label[for="${this[je.element].id}"]`):document.createDocumentFragment().childNodes}get _polyfilled(){return!0}get shadowRoot(){return this[je.element].shadowRoot}get validity(){return Je(this[je.element])?this[je.validity]:void 0}get validationMessage(){return Je(this[je.element])?this[je.validationMessage]||"":void 0}get willValidate(){const e=this[je.element];return Je(e)&&!Qe(e)&&!["disabled","readonly"].some((t=>e.hasAttribute(t)))}checkValidity(){if(this.willValidate){if(this.validity.valid){const e=this[je.element].nextElementSibling;return e instanceof HTMLElement&&e.classList.contains("_element-internals-popup")&&e.remove(),!0}return this[je.element].dispatchEvent(new Event("invalid")),!1}return!0}reportValidity(){if(this.checkValidity())return!0;{const e=this.validationMessage;if("string"==typeof e&&0!==e.length){const{bottom:t,left:n}=this[je.element].getBoundingClientRect(),r=document.createElement("div");r.textContent=e,Ze(r,{position:"fixed","background-color":"#2b2a33",color:"#fafafa",top:`${t+2}px`,left:`${n}px`,"z-index":2147483647,"color-scheme":"light-dark","font-family":"system-ui, serif","font-size":"18px",display:"inline-block",padding:"0.6em 0.8em",border:"1px solid #1a1a1a","border-radius":"6px"}),r.classList.add("_element-internals-popup"),this[je.element].focus();const o=this[je.element].nextElementSibling;o instanceof Element&&o.classList.contains("_element-internals-popup")&&o.remove(),this[je.element].insertAdjacentElement("afterend",r),this[je.anchor]instanceof Element&&this[je.anchor].focus(),setTimeout((()=>{r.isConnected&&r.remove()}),3e3)}return!1}}setFormValue(e,t){if(!Je(this[je.element]))throw new DOMException("Not form associated");this[je.value]=e,this[je.state]=t}setValidity({valueMissing:e=!1,typeMismatch:t=!1,patternMismatch:n=!1,tooLong:r=!1,tooShort:o=!1,rangeUnderflow:i=!1,rangeOverflow:a=!1,stepMismatch:s=!1,badInput:l=!1,customError:c=!1},u="",p){if(!Je(this[je.element]))throw new DOMException("Not form associated");if(("string"!=typeof u||0===u.length)&&(e||t||n||r||o||i||a||s||l||c))throw new DOMException("Message required if any flags are true.");{const d=[e,t,n,r,o,i,a,s,l,c].every((e=>!1===e));this[je.validity]={valueMissing:e,typeMismatch:t,patternMismatch:n,tooLong:r,tooShort:o,rangeUnderflow:i,rangeOverflow:a,stepMismatch:s,badInput:l,customError:c,valid:d},this[je.validationMessage]=u,this[je.anchor]=p,d?(this.states.delete("--invalid"),this.states.add("--valid")):(this.states.add("--invalid"),this.states.delete("--valid"),this[je.element].dispatchEvent(new Event("invalid")))}}_associateForm(e,t){et(e,this,t)}_findAssociatedForm(e){return Ye(e)}}HTMLElement.prototype.attachInternals=function(){if(this.hasOwnProperty(je.internals))throw new DOMException("Invalid operation");if(this.tagName.includes("-"))return new rt(this,je.key);throw new DOMException("Cannot call attachInternals on built-in elements.")},globalThis.ElementInternals=rt}if("ElementInternals"in globalThis&&!("CustomStateSet"in globalThis)){const ot="_state",it=new WeakMap,at=e=>{if(e.toString().startsWith("--"))return`${ot}${e}`;throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value '${e}' must start with '--'.`)},{value:st,writable:lt,configurable:ct,enumerable:ut}=Object.getOwnPropertyDescriptor(HTMLElement.prototype,"attachInternals");class pt{constructor(e,t){if(t!==je.key)throw new TypeError("Illegal Constructor");if(!(e instanceof HTMLElement))throw new TypeError("el must be an HTMLElement");it.set(this,e),this.add("--custom-states-polyfilled")}get _polyfilled(){return!0}get size(){return[...this.values()].length}add(e){it.get(this).classList.add(at(e))}has(e){return it.get(this).classList.contains(at(e))}delete(e){const t=at(e);return!!it.get(this).classList.contains(t)&&(it.get(this).classList.remove(t),!0)}clear(){this.values().forEach((e=>this.delete(e)))}keys(){return this.values()}values(){return it.get(this).classList.values().filter((e=>e.startsWith(`${ot}--`))).map((e=>e.substr(ot.length)))}entries(){return this.values().map((e=>[e,e]))}forEach(e,t){this.values().forEach((n=>e.call(t||this,n,n,this)))}[Symbol.toStringTag](){return"CustomStateSet"}[Symbol.iterator](){return this.values()}}Object.defineProperty(HTMLElement.prototype,"attachInternals",{value:function(){const e=st.call(this);return Object.defineProperty(e,je.element,{value:this,enumerable:!1,writable:!1,configurable:!1}),Object.defineProperty(e,"states",{value:new pt(this,je.key),configurable:!0,enumberable:!0}),Object.is(e.shadowRoot,null)&&!Object.is(this.shadowRoot,null)&&Object.defineProperty(e,"shadowRoot",{value:this.shadowRoot,configurable:!0,enumerable:!0}),e},writable:lt,configurable:ct,enumerable:ut}),globalThis.CustomStateSet=pt,function(e){const t=Object.fromEntries(Object.keys(Se).map((e=>[e,{get:function(){return this[je.element][e]},set:function(t){this[je.element][e]=t},enumerable:!0,configurable:!0}])));Object.defineProperties(e,t)}(ElementInternals.prototype)}if(t(Response,"json",((e,{status:t=200,statusText:n="",headers:r=new Headers}={})=>r instanceof Headers?(r.set("Content-Type","application/json"),new Response(JSON.stringify(e),{status:t,statusText:n,headers:r})):Response.json(e,{status:t,statusText:n,headers:new Headers(r)}))),t(Response,"redirect",((e,t=302)=>new Response("",{status:t,headers:new Headers({Location:e})}))),!(globalThis.Record instanceof Function)){function dt(e){if(new.target===dt)throw new TypeError("Record is not a constructor");const t=Object.create(dt.prototype);return Object.defineProperties(t,Object.fromEntries(Object.entries(e).map((([e,t])=>[e,{enumerable:!0,configurable:!1,writable:!1,value:t}])))),Object.freeze(t),t}dt.prototype.constructor=dt,Object.defineProperty(dt.prototype,Symbol.toStringTag,{value:"Record",enumerable:!0,configurable:!1,writable:!1}),dt.fromEntries=function(e){return dt(Object.fromEntries(e))},globalThis.Record=dt}if(!(globalThis.Tuple instanceof Function)){const ft=e=>{const t=Array.apply(Object.create(ht.prototype),e);return Object.setPrototypeOf(t,ht.prototype),t};function ht(...e){if(new.target===ht)throw new TypeError("Tuple is not a constructor");const t=ft(e);return Object.freeze(t),t}ht.prototype.forEach=function(e,t){Array.prototype.forEach.call(this,e,t)},ht.prototype.join=function(e=","){return Array.prototype.join.call(this,e)},ht.prototype.concat=function(...e){return ht(...this,...e)},ht.prototype.slice=function(e,t){return ht.from(Array.prototype.slice.call(this,e,t))},ht.prototype.indexOf=function(e,t){return Array.prototype.indexOf.call(this,e,t)},ht.prototype.lastIndexOf=function(e,t){return Array.prototype.lastIndexOf.call(this,e,t)},ht.prototype.findIndex=function(e,t){return Array.prototype.findIndex.call(this,e,t)},ht.prototype.find=function(e,t){return Array.prototype.find.call(this,e,t)},ht.prototype.findLast=function(e,t){return Array.prototype.findLast.call(this,e,t)},ht.prototype.findLastIndex=function(e,t){return Array.prototype.findLastIndex.call(this,e,t)},ht.prototype.every=function(e,t){return Array.prototype.every.call(this,e,t)},ht.prototype.some=function(e,t){return Array.prototype.some.call(this,e,t)},ht.prototype.includes=function(e,t){return Array.prototype.includes.call(this,e,t)},ht.prototype.map=function(e,t){return ht.from(Array.prototype.map.call(this,e,t))},ht.prototype.filter=function(e,t){return ht.from(Array.prototype.filter.call(this,e,t))},ht.prototype.flat=function(e){return ht.from(Array.prototype.flat.call(this,e))},ht.prototype.flatMap=function(e,t){return ht.from(Array.prototype.flatMap.call(this,e,t))},ht.prototype.at=function(e){return Array.prototype.at.call(this,e)},ht.prototype.reduce=function(e,t){return ht.from(Array.prototype.reduce.call(this,e,t))},ht.prototype.reduceRight=function(e,t){return ht.from(Array.prototype.reduceRight.call(this,e,t))},ht.prototype.toSorted=function(e){return ht.from(Array.prototype.toSorted.call(this,e))},ht.prototype.toSpliced=function(e,t,...n){return ht.from(Array.prototype.toSpliced.call(this,e,t,...n))},ht.prototype.toReversed=function(){return ht.from(Array.prototype.toReversed.apply(this))},ht.prototype.with=function(e,t){return ht.from(Array.prototype.with.call(this,e,t))},ht.prototype.toLocaleString=function(e,t){return Array.prototype.toLocaleString.call(this,e,t)},ht.prototype.toJSON=function(){return[...this]},ht.prototype.keys=function(){return Array.prototype.keys.apply(this)},ht.prototype.values=function(){return Array.prototype.values.apply(this)},ht.prototype.entries=function(){return Array.prototype.entries.apply(this)},ht.prototype[Symbol.iterator]=function(){return Array.prototype[Symbol.iterator].apply(this)},ht.from=function(e,t,n){const r=ft([]);return Array.prototype.push.apply(r,Array.from(e,t,n)),Object.freeze(r),r},ht.of=function(...e){return ht.from(e)},Object.defineProperties(ht.prototype,{length:{get:function(){return Object.getOwnPropertyDescriptor(Array.prototype,"length").get.apply(this)},enumerable:!0,configurable:!1},lastItem:{get:function(){return this[this.lastIndex]},enumerable:!0,configurable:!1},lastIndex:{get:function(){return Object.getOwnPropertyDescriptor(Array.prototype,"lastIndex").get.apply(this)},enumerable:!0,configurable:!1},[Symbol.toStringTag]:{value:"Tuple",enumerable:!0,configurable:!1,writable:!1}}),globalThis.Tuple=ht}if(!(JSON.parseImmutable instanceof Function)){function mt(e){return"object"==typeof e?null===e?null:Array.isArray(e)?Tuple.from(e.map((e=>mt(e)))):Record.fromEntries(Object.entries(e).map((([e,t])=>[e,mt(t)]))):e}JSON.parseImmutable=function(e){return JSON.parse(e,((e,t)=>mt(t)))}}}();
|
|
66
66
|
//# sourceMappingURL=all.min.js.map
|