@eightshift/ui-components 5.6.0 → 5.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/{Button-BhEIfWLY.js → Button-CQ5ZZJ2w.js} +1 -1
  2. package/dist/{Dialog-B8p4Ymh7.js → Dialog-BMgMUQuN.js} +7 -7
  3. package/dist/{List-Bll1lQEW.js → List-BiAnh5G5.js} +1 -1
  4. package/dist/{ListBox-CEpKw7yC.js → ListBox-DggfiuO_.js} +5 -5
  5. package/dist/{OverlayArrow-DDfa8khI.js → OverlayArrow-DraDOoRn.js} +1 -1
  6. package/dist/{SearchField-D6mPli0i.js → SearchField-DWGdCvnn.js} +2 -2
  7. package/dist/{Select-CHzjZxXy.js → Select-BvggcFOX.js} +7 -7
  8. package/dist/{Select-ef7c0426.esm-BJmjGGzK.js → Select-ef7c0426.esm-CmTkSxDx.js} +1 -1
  9. package/dist/{SelectionManager-D77bfEbg.js → SelectionManager-B6-b5NM2.js} +2 -2
  10. package/dist/{Separator-DcqCdD4k.js → Separator-B-xeqOkC.js} +1 -1
  11. package/dist/{SharedElementTransition-BjRNHsjx.js → SharedElementTransition-fML-zIv6.js} +1 -1
  12. package/dist/components/breakpoint-preview/breakpoint-preview.js +0 -1
  13. package/dist/components/button/button.js +1 -1
  14. package/dist/components/checkbox/checkbox.js +2 -2
  15. package/dist/components/color-pickers/solid-color-picker.js +1 -1
  16. package/dist/components/draggable/draggable.js +1 -1
  17. package/dist/components/draggable-list/draggable-list.js +1 -1
  18. package/dist/components/expandable/expandable.js +2 -2
  19. package/dist/components/link-input/link-input.js +10 -10
  20. package/dist/components/matrix-align/matrix-align.js +0 -1
  21. package/dist/components/menu/menu.js +2 -2
  22. package/dist/components/modal/modal.js +3 -3
  23. package/dist/components/number-picker/number-picker.js +2 -2
  24. package/dist/components/placeholders/file-picker-shell.js +0 -1
  25. package/dist/components/popover/popover.js +1 -1
  26. package/dist/components/radio/radio.js +2 -2
  27. package/dist/components/repeater/repeater.js +1 -1
  28. package/dist/components/responsive/mini-responsive.js +0 -1
  29. package/dist/components/responsive/responsive-legacy.js +0 -1
  30. package/dist/components/responsive/responsive.js +0 -1
  31. package/dist/components/responsive-preview/responsive-preview.js +0 -1
  32. package/dist/components/select/async-multi-select.js +3 -3
  33. package/dist/components/select/async-single-select.js +2 -2
  34. package/dist/components/select/custom-select-default-components.js +1 -1
  35. package/dist/components/select/multi-select-components.js +1 -1
  36. package/dist/components/select/multi-select.js +3 -3
  37. package/dist/components/select/react-select-component-wrappers.js +1 -1
  38. package/dist/components/select/single-select.js +2 -2
  39. package/dist/components/select/v2/async-multi-select.js +5 -6
  40. package/dist/components/select/v2/async-select.js +5 -6
  41. package/dist/components/select/v2/multi-select.js +6 -7
  42. package/dist/components/select/v2/shared.js +1 -1
  43. package/dist/components/select/v2/single-select.js +6 -6
  44. package/dist/components/smart-image/smart-image.js +2 -2
  45. package/dist/components/smart-image/worker-inline.js +1 -1
  46. package/dist/components/tabs/tabs.js +5 -5
  47. package/dist/components/toggle/switch.js +1 -1
  48. package/dist/components/toggle-button/toggle-button.js +1 -1
  49. package/dist/components/tooltip/tooltip.js +2 -2
  50. package/dist/{general-6STKQIrk.js → general-Ck8IV7xJ.js} +2 -2
  51. package/dist/{index-641ee5b8.esm-DiwvO-RP.js → index-641ee5b8.esm-DVp0njHa.js} +1 -1
  52. package/dist/{index-DjyEH0Gg.js → index-D8-Zjpbd.js} +3 -1
  53. package/dist/{multi-select-components-B3KuDyYd.js → multi-select-components-CT_W0Cy9.js} +1 -1
  54. package/dist/{react-select-async.esm-_4pk-41v.js → react-select-async.esm-Zl1LPaPb.js} +3 -3
  55. package/dist/{react-select.esm-BeuAkAyY.js → react-select.esm-Bu36HujU.js} +3 -3
  56. package/dist/{useButton-B2EaQJT_.js → useButton-v9ngEj50.js} +1 -1
  57. package/dist/{useDragAndDrop-DUXKDS0N.js → useDragAndDrop-C08ZXv4F.js} +5 -5
  58. package/dist/{useFilter-BPcJ-Jzv.js → useFilter-BlkUH1Ma.js} +1 -1
  59. package/dist/{useListState-DZycqxCn.js → useListState-RdLrYsMP.js} +1 -1
  60. package/dist/{useNumberField-CEA9Q4w_.js → useNumberField-D16dDfYF.js} +1 -1
  61. package/dist/{usePress-BCEPS3hl.js → usePress-DJskZBH9.js} +1 -1
  62. package/dist/{useSingleSelectListState-BFZEfeqI.js → useSingleSelectListState-n0AVMr3Y.js} +1 -1
  63. package/dist/{useToggle-DNoP2bvV.js → useToggle-DSBDAfdw.js} +1 -1
  64. package/dist/utilities/general.js +2 -2
  65. package/dist/utilities/hash.js +30 -0
  66. package/dist/utilities/index.js +4 -6
  67. package/dist/workers/image-analysis.worker.js +1 -1
  68. package/package.json +7 -8
  69. package/dist/_commonjsHelpers-BhWcALO8.js +0 -38
  70. package/dist/sha256-C56UDWfQ.js +0 -533
@@ -1,20 +1,19 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { _ as __ } from "../../../default-i18n-DBm-GqWM.js";
3
3
  import { BaseControl } from "../../base-control/base-control.js";
4
- import { $ as $d2f53cda644affe3$export$2f2b9559550c7bbc, a as $440f4836bcb56932$export$b94867ecbd698f21 } from "../../../SearchField-D6mPli0i.js";
5
- import { $ as $d2b4bc8c273e7be6$export$353f5b6fc5456de1 } from "../../../Button-BhEIfWLY.js";
4
+ import { $ as $d2f53cda644affe3$export$2f2b9559550c7bbc, a as $440f4836bcb56932$export$b94867ecbd698f21 } from "../../../SearchField-DWGdCvnn.js";
5
+ import { $ as $d2b4bc8c273e7be6$export$353f5b6fc5456de1 } from "../../../Button-CQ5ZZJ2w.js";
6
6
  import { $ as $3985021b0ad6602f$export$f5b8910cec6cf069 } from "../../../Input-8yja_IHC.js";
7
7
  import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../../Label-DWVaNd2E.js";
8
- import { $ as $eed445e0843c11d0$export$41f133550aa26f48 } from "../../../ListBox-CEpKw7yC.js";
9
- import { e as $07b14b47974efb58$export$5b6b19405a83ff9d } from "../../../Dialog-B8p4Ymh7.js";
10
- import { $ as $82d7e5349645de74$export$ef9b1a59e592288f, a as $82d7e5349645de74$export$e288731fd71264f0, b as $82d7e5349645de74$export$ef445b55be0601bd } from "../../../Select-CHzjZxXy.js";
8
+ import { $ as $eed445e0843c11d0$export$41f133550aa26f48 } from "../../../ListBox-DggfiuO_.js";
9
+ import { e as $07b14b47974efb58$export$5b6b19405a83ff9d } from "../../../Dialog-BMgMUQuN.js";
10
+ import { $ as $82d7e5349645de74$export$ef9b1a59e592288f, a as $82d7e5349645de74$export$e288731fd71264f0, b as $82d7e5349645de74$export$ef445b55be0601bd } from "../../../Select-BvggcFOX.js";
11
11
  import { useRef, useEffect, cloneElement, useContext } from "react";
12
12
  import { icons } from "../../../icons/icons.js";
13
13
  import "../../../react-jsx-parser.min-VUl-CuCv.js";
14
14
  import { OptionItemBase } from "./shared.js";
15
15
  import { RichLabel } from "../../rich-label/rich-label.js";
16
16
  import { unescapeHTML } from "../../../utilities/text-helpers.js";
17
- import "../../../sha256-C56UDWfQ.js";
18
17
  import { c as clsx } from "../../../utils-cvK1vxO7.js";
19
18
  import { $ as $f86e6c1ec7da6ebb$export$bc3384a35de93d66 } from "../../../useAsyncList-D52mQcrH.js";
20
19
  /**
@@ -1,14 +1,14 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { _ as __ } from "../../../default-i18n-DBm-GqWM.js";
3
3
  import { BaseControl } from "../../base-control/base-control.js";
4
- import { $ as $d2f53cda644affe3$export$2f2b9559550c7bbc, a as $440f4836bcb56932$export$b94867ecbd698f21 } from "../../../SearchField-D6mPli0i.js";
5
- import { $ as $d2b4bc8c273e7be6$export$353f5b6fc5456de1 } from "../../../Button-BhEIfWLY.js";
6
- import { g as $de32f1b87079253c$export$2e1e1122cf0cba88, e as $07b14b47974efb58$export$5b6b19405a83ff9d } from "../../../Dialog-B8p4Ymh7.js";
4
+ import { $ as $d2f53cda644affe3$export$2f2b9559550c7bbc, a as $440f4836bcb56932$export$b94867ecbd698f21 } from "../../../SearchField-DWGdCvnn.js";
5
+ import { $ as $d2b4bc8c273e7be6$export$353f5b6fc5456de1 } from "../../../Button-CQ5ZZJ2w.js";
6
+ import { g as $de32f1b87079253c$export$2e1e1122cf0cba88, e as $07b14b47974efb58$export$5b6b19405a83ff9d } from "../../../Dialog-BMgMUQuN.js";
7
7
  import { $ as $3985021b0ad6602f$export$f5b8910cec6cf069 } from "../../../Input-8yja_IHC.js";
8
8
  import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../../Label-DWVaNd2E.js";
9
- import { $ as $eed445e0843c11d0$export$41f133550aa26f48, a as $eed445e0843c11d0$export$a11e76429ed99b4, b as $612b8eb6cb90e02d$export$62ed72bc21f6b8a6 } from "../../../ListBox-CEpKw7yC.js";
9
+ import { $ as $eed445e0843c11d0$export$41f133550aa26f48, a as $eed445e0843c11d0$export$a11e76429ed99b4, b as $612b8eb6cb90e02d$export$62ed72bc21f6b8a6 } from "../../../ListBox-DggfiuO_.js";
10
10
  import { $ as $514c0188e459b4c0$export$5f1af8db9871e1d6 } from "../../../Text-AxKZjtFm.js";
11
- import { $ as $d8f176866e6dc039$export$2cfc5be7a55829f6 } from "../../../useDragAndDrop-DUXKDS0N.js";
11
+ import { $ as $d8f176866e6dc039$export$2cfc5be7a55829f6 } from "../../../useDragAndDrop-C08ZXv4F.js";
12
12
  import { useRef, cloneElement } from "react";
13
13
  import { icons } from "../../../icons/icons.js";
14
14
  import "../../../react-jsx-parser.min-VUl-CuCv.js";
@@ -17,8 +17,7 @@ import { RichLabel } from "../../rich-label/rich-label.js";
17
17
  import { c as clsx } from "../../../utils-cvK1vxO7.js";
18
18
  import { getValue, moveArrayItem } from "../shared.js";
19
19
  import { truncateEnd } from "../../../utilities/text-helpers.js";
20
- import "../../../sha256-C56UDWfQ.js";
21
- import { $ as $bb77f239b46e8c72$export$3274cf84b703fff } from "../../../useFilter-BPcJ-Jzv.js";
20
+ import { $ as $bb77f239b46e8c72$export$3274cf84b703fff } from "../../../useFilter-BlkUH1Ma.js";
22
21
  /**
23
22
  * Multi-select menu.
24
23
  *
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { a as $eed445e0843c11d0$export$a11e76429ed99b4 } from "../../../ListBox-CEpKw7yC.js";
2
+ import { a as $eed445e0843c11d0$export$a11e76429ed99b4 } from "../../../ListBox-DggfiuO_.js";
3
3
  import { c as clsx } from "../../../utils-cvK1vxO7.js";
4
4
  import { icons } from "../../../icons/icons.js";
5
5
  import "react";
@@ -1,20 +1,20 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { _ as __ } from "../../../default-i18n-DBm-GqWM.js";
3
3
  import { BaseControl } from "../../base-control/base-control.js";
4
- import { $ as $d2f53cda644affe3$export$2f2b9559550c7bbc, a as $440f4836bcb56932$export$b94867ecbd698f21 } from "../../../SearchField-D6mPli0i.js";
5
- import { $ as $d2b4bc8c273e7be6$export$353f5b6fc5456de1 } from "../../../Button-BhEIfWLY.js";
4
+ import { $ as $d2f53cda644affe3$export$2f2b9559550c7bbc, a as $440f4836bcb56932$export$b94867ecbd698f21 } from "../../../SearchField-DWGdCvnn.js";
5
+ import { $ as $d2b4bc8c273e7be6$export$353f5b6fc5456de1 } from "../../../Button-CQ5ZZJ2w.js";
6
6
  import { $ as $3985021b0ad6602f$export$f5b8910cec6cf069 } from "../../../Input-8yja_IHC.js";
7
7
  import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../../Label-DWVaNd2E.js";
8
- import { $ as $eed445e0843c11d0$export$41f133550aa26f48 } from "../../../ListBox-CEpKw7yC.js";
9
- import { e as $07b14b47974efb58$export$5b6b19405a83ff9d } from "../../../Dialog-B8p4Ymh7.js";
10
- import { $ as $82d7e5349645de74$export$ef9b1a59e592288f, a as $82d7e5349645de74$export$e288731fd71264f0, b as $82d7e5349645de74$export$ef445b55be0601bd } from "../../../Select-CHzjZxXy.js";
8
+ import { $ as $eed445e0843c11d0$export$41f133550aa26f48 } from "../../../ListBox-DggfiuO_.js";
9
+ import { e as $07b14b47974efb58$export$5b6b19405a83ff9d } from "../../../Dialog-BMgMUQuN.js";
10
+ import { $ as $82d7e5349645de74$export$ef9b1a59e592288f, a as $82d7e5349645de74$export$e288731fd71264f0, b as $82d7e5349645de74$export$ef445b55be0601bd } from "../../../Select-BvggcFOX.js";
11
11
  import { useRef, cloneElement, useContext } from "react";
12
12
  import { icons } from "../../../icons/icons.js";
13
13
  import "../../../react-jsx-parser.min-VUl-CuCv.js";
14
14
  import { OptionItemBase } from "./shared.js";
15
15
  import { RichLabel } from "../../rich-label/rich-label.js";
16
16
  import { c as clsx } from "../../../utils-cvK1vxO7.js";
17
- import { $ as $bb77f239b46e8c72$export$3274cf84b703fff } from "../../../useFilter-BPcJ-Jzv.js";
17
+ import { $ as $bb77f239b46e8c72$export$3274cf84b703fff } from "../../../useFilter-BlkUH1Ma.js";
18
18
  /**
19
19
  * Select menu.
20
20
  *
@@ -7,7 +7,7 @@ import "../../react-jsx-parser.min-VUl-CuCv.js";
7
7
  import { DecorativeTooltip } from "../tooltip/tooltip.js";
8
8
  import { useImageAnalysisWorker } from "../../utilities/web-workers.js";
9
9
  import workerInline from "./worker-inline.js";
10
- import { s as sha256Exports } from "../../sha256-C56UDWfQ.js";
10
+ import { cyrb64Hash } from "../../utilities/hash.js";
11
11
  /**
12
12
  * @typedef {Object} CustomImageProps
13
13
  * @property {JSX.Element} [props.renderError] - Component to render if image analysis fails. `(error) => JSX:Element`.
@@ -112,7 +112,7 @@ const SmartImage = (props) => {
112
112
  setHasAnalysed(true);
113
113
  return;
114
114
  }
115
- const cacheKey = `es-uic-img-analysis-${sha256Exports.sha256(imageProps.src)}`;
115
+ const cacheKey = `es-uic-img-analysis-${cyrb64Hash(imageProps.src)}`;
116
116
  if (localStorage?.getItem(cacheKey)) {
117
117
  const { isDark: dark, dominantColors: colors, isTransparent: transparent, transparencyInfo: transparencyInfo2 } = JSON.parse(localStorage.getItem(cacheKey));
118
118
  setIsDark(dark);
@@ -1,4 +1,4 @@
1
- const workerInline = '(function(){"use strict";var E=(t=>(t[t.ALPHA=0]="ALPHA",t[t.BLUE=1]="BLUE",t[t.GREEN=2]="GREEN",t[t.RED=3]="RED",t))(E||{});const Le=["rotateCW","rotate180","rotateCCW"],fr=(t,e=t,n,r={})=>{const s=document.createElement("canvas");return dr(s,t,e,r.dpr),r.pixelated&&(s.style.imageRendering="pixelated"),{canvas:s,ctx:s.getContext("2d",r.ctx)}},ur=(t,e=t,n,r)=>fr(t,e,n,{dpr:1,...r}),dr=(t,e,n,r=window.devicePixelRatio||1)=>(r!==1&&(t.style.width=`${e}px`,t.style.height=`${n}px`),t.width=e*r,t.height=n*r,r),it=t=>typeof t=="number";function gr(t,e,n,r){let s,o;if(it(t)){const c=ur(t,e,n,r);s=c.canvas,o=c.ctx}else s=t,o=s.getContext("2d");const a=o.getImageData(0,0,s.width,s.height),i=new Uint32Array(a.data.buffer);return{canvas:s,ctx:o,img:a,data:i}}const wt=(t,e,n)=>{n.configurable=!1},Ft=(t,e={})=>{const n=Reflect.ownKeys(t),r=Reflect.ownKeys(e),s=Symbol("isa");function o(a){for(let i of n){const c=Object.getOwnPropertyDescriptor(a.prototype,i);(!c||c.configurable)&&Object.defineProperty(a.prototype,i,{value:t[i],writable:!0})}return Object.defineProperty(a.prototype,s,{value:!0}),a}for(let a of r)Object.defineProperty(o,a,{value:e[a],enumerable:e.propertyIsEnumerable(a)});return Object.defineProperty(o,Symbol.hasInstance,{value:a=>!!a[s]}),o};Ft({order(){return[0]},includes(t){return t>=0&&t<this.size[0]},indexAt(t){return this.includes(t)?this.indexAtUnsafe(t):-1},indexAtUnsafe(t){return this.offset+(t|0)*this.stride[0]},getAt(t){return this.includes(t)?this.data[this.indexAtUnsafe(t)]:0},getAtUnsafe(t){return this.data[this.indexAtUnsafe(t)]},setAt(t,e){return this.includes(t)?(this.data[this.indexAtUnsafe(t)]=e,!0):!1},setAtUnsafe(t,e){return this.data[this.indexAtUnsafe(t)]=e,!0}});const We=Ft({order(){return Math.abs(this.stride[1])>Math.abs(this.stride[0])?[1,0]:[0,1]},includes(t,e){const n=this.size;return t>=0&&t<n[0]&&e>=0&&e<n[1]},indexAt(t,e){return this.includes(t,e)?this.indexAtUnsafe(t,e):-1},indexAtUnsafe(t,e){return this.offset+(t|0)*this.stride[0]+(e|0)*this.stride[1]},getAt(t,e){return this.includes(t,e)?this.data[this.indexAtUnsafe(t,e)]:0},getAtUnsafe(t,e){return this.data[this.indexAtUnsafe(t,e)]},setAt(t,e,n){return this.includes(t,e)?(this.data[this.indexAtUnsafe(t,e)]=n,!0):!1},setAtUnsafe(t,e,n){return this.data[this.indexAtUnsafe(t,e)]=n,!0}});Ft({order(){return Ve(this.stride)},includes(t,e,n){const r=this.size;return t>=0&&t<r[0]&&e>=0&&e<r[1]&&n>=0&&n<r[2]},indexAt(t,e,n){return this.includes(t,e,n)?this.indexAtUnsafe(t,e,n):-1},indexAtUnsafe(t,e,n){const r=this.stride;return this.offset+(t|0)*r[0]+(e|0)*r[1]+(n|0)*r[2]},getAt(t,e,n){return this.includes(t,e,n)?this.data[this.indexAtUnsafe(t,e,n)]:0},getAtUnsafe(t,e,n){return this.data[this.indexAtUnsafe(t,e,n)]},setAt(t,e,n,r){return this.includes(t,e,n)?(this.data[this.indexAtUnsafe(t,e,n)]=r,!0):!1},setAtUnsafe(t,e,n,r){return this.data[this.indexAtUnsafe(t,e,n)]=r,!0}}),Ft({order(){return Ve(this.stride)},includes(t,e,n,r){const s=this.size;return t>=0&&t<s[0]&&e>=0&&e<s[1]&&n>=0&&n<s[2]&&r>=0&&r<s[3]},indexAt(t,e,n,r){return this.includes(t,e,n,r)?this.indexAtUnsafe(t,e,n,r):-1},indexAtUnsafe(t,e,n,r){const s=this.stride;return this.offset+(t|0)*s[0]+(e|0)*s[1]+(n|0)*s[2]+(r|0)*s[3]},getAt(t,e,n,r){return this.includes(t,e,n,r)?this.data[this.indexAtUnsafe(t,e,n,r)]:0},getAtUnsafe(t,e,n,r){return this.data[this.indexAtUnsafe(t,e,n,r)]},setAt(t,e,n,r,s){return this.includes(t,e,n,r)?(this.data[this.indexAtUnsafe(t,e,n,r)]=s,!0):!1},setAtUnsafe(t,e,n,r,s){return this.data[this.indexAtUnsafe(t,e,n,r)]=s,!0}});const Ve=t=>[...t].map((e,n)=>[e,n]).sort((e,n)=>Math.abs(n[0])-Math.abs(e[0])).map(e=>e[1]),ot=t=>typeof t=="string",Rt=(t,e=n=>n!==void 0?": "+n:"")=>class extends Error{origMessage;constructor(n){super(t(n)+e(n)),this.origMessage=n!==void 0?String(n):""}},mr={};var Ye={};const br=Rt(()=>"Assertion failed"),M=(typeof process<"u"&&Ye!==void 0?Ye.UMBRELLA_ASSERTS:!mr)?(t,e)=>{if(typeof t=="function"&&!t()||!t)throw new br(typeof e=="function"?e():e)}:()=>{},j=(t,e,n)=>t<e?e:t>n?n:t,F=t=>t<0?0:t>1?1:t,Xe=(t,e,n,r,s)=>(t[0]=e,t[1]=n,t[2]=r,t[3]=s,t),yr=(t,e)=>{const n=e[3];return Xe(e,e[0]*n,e[1]*n,e[2]*n,n)},xr=t=>{const e=(t>>>24)/255;return t&4278190080|(t>>>16&255)*e<<16|(t>>>8&255)*e<<8|(t&255)*e},pr=(t,e)=>{const n=e[3];return n>0?Xe(e,e[0]/n,e[1]/n,e[2]/n,n):e},Ar=t=>{const e=(t>>>24)/255;return e>0?(t&4278190080|Math.min(255,(t>>>16&255)/e)<<16|Math.min(255,(t>>>8&255)/e)<<8|Math.min(255,(t&255)/e))>>>0:t},_r=t=>{const e=t[3];return t[0]<=e&&t[1]<=e||t[2]<=e},wr=t=>{const e=t>>>24;return(t>>>16&255)<=e&&(t>>>8&255)<=e&&(t&255)<=e},Je=(t,e,n,r=1)=>M(t.length>=e*n*r,"pixel buffer too small"),Ke=(t,e,n)=>t?(Xt(t,e,n),t):new ImageData(e,n),Xt=(t,e,n)=>M(t.width===e&&t.height===n,"imagedata has wrong dimensions"),X=(t,e)=>{const n=t.channels[e];return M(n!=null,`invalid channel ID: ${e}`),n},Fr=t=>M(!!t.alpha,"missing alpha channel"),vt=t=>t,Jt=t=>((t>>>16&255)*29+(t>>>8&255)*150+(t&255)*76)/255,St=(t,e,n,r,s,o,a=0,i=0)=>(t|=0,e|=0,n|=0,r|=0,t<0&&(n+=t,a-=t,t=0),e<0&&(r+=e,i-=e,e=0),[t,e,j(n,0,s-t),j(r,0,o-e),a,i]),Bt=(t,e,n={})=>{const r=t.width,s=e.width;let o,a,i,c,h,l;return[o,a,h,l]=St(n.sx||0,n.sy||0,n.w||r,n.h||t.height,r,t.height),[i,c,h,l,o,a]=St(n.dx||0,n.dy||0,h,l,s,e.height,o,a),{sx:o,sy:a,dx:i,dy:c,rw:h,rh:l}},Rr=(t,e,n)=>{for(let r=t.length;r-- >0;)t[r]=n(t[r],e)},vr=(t,e,n,r)=>{for(let s=t.length;s-- >0;)t[s]=r(t[s],n(e[s]))},Sr=(t,e,n,r,s)=>{const o=~s;for(let a=t.length;a-- >0;)t[a]=t[a]&o|n(r(e[a]))&s},Ze=(t,e,n)=>{const r=e.fromABGR,s=e.toABGR;for(let o=t.length;o-- >0;)t[o]=r(n(s(t[o])))},Qe=(t,e,n={})=>(e instanceof HTMLCanvasElement||e instanceof OffscreenCanvas?e.getContext("2d"):e).putImageData(t.toImageData(n.data),n.x||0,n.y||0),Ct=t=>{const e=t.channels,n=e.reduce((a,i)=>(a[i]=3-i<<3,a),{}),r={...t,__float:!0,size:e.length,shift:n,range:[0,1],normalized:F,fromNormalized:vt};if(t.convert)return Object.assign(r,t.convert),r;const s=(a,i)=>(F(a[i])*255+.5|0)<<n[e[i]],o=(a,i)=>(a>>>n[e[i]]&255)/255;switch(e.length){case 1:t.gray?Cr(r):Br(r,o,s);break;case 2:t.gray?Mr(r,o):$r(r,o,s);break;case 3:Ur(r,o,s);break;case 4:Or(r,o,s);break}return r},Br=(t,e,n)=>{t.toABGR=r=>{let s=t.alpha?0:4278190080;return s|=n(r,0),s>>>0},t.fromABGR=(r,s=[])=>(s[0]=e(r,0),s)},Cr=t=>{t.toABGR=e=>((F(e[0])*255+.5|0)*65793|4278190080)>>>0,t.fromABGR=(e,n=[])=>(n[0]=Jt(e)/255,n)},$r=(t,e,n)=>{t.toABGR=r=>{let s=t.alpha?0:4278190080;return s|=n(r,0),s|=n(r,1),s>>>0},t.fromABGR=(r,s=[])=>(s[0]=e(r,0),s[1]=e(r,1),s)},Mr=(t,e)=>{const n=~~(t.channels[0]===E.ALPHA),r=n^1;t.toABGR=s=>{let o=(F(s[n])*255+.5|0)*65793;return o|=(s[r]*255+.5|0)<<24,o>>>0},t.fromABGR=(s,o=[])=>(o[n]=Jt(s)/255,o[r]=e(s,r),o)},Ur=(t,e,n)=>{t.toABGR=r=>{let s=t.alpha?0:4278190080;return s|=n(r,0),s|=n(r,1),s|=n(r,2),s>>>0},t.fromABGR=(r,s=[])=>(s[0]=e(r,0),s[1]=e(r,1),s[2]=e(r,2),s)},Or=(t,e,n)=>{t.toABGR=r=>{let s=t.alpha?0:4278190080;return s|=n(r,0),s|=n(r,1),s|=n(r,2),s|=n(r,3),s>>>0},t.fromABGR=(r,s=[])=>(s[0]=e(r,0),s[1]=e(r,1),s[2]=e(r,2),s[3]=e(r,3),s)},tn=Ct({gray:!0,channels:[E.RED]}),Er={5120:"i8",5121:"u8",5122:"i16",5123:"u16",5124:"i32",5125:"u32",5126:"f32"},Ir={f32:Float32Array,f64:Float64Array},zr={i8:Int8Array,i16:Int16Array,i32:Int32Array},kr={u8:Uint8Array,u8c:Uint8ClampedArray,u16:Uint16Array,u32:Uint32Array},Gr={i64:BigInt64Array,u64:BigUint64Array},Nr={...Ir,...zr,...kr},Dr=t=>{const e=Er[t];return e!==void 0?e:t};function $t(t,...e){const n=Gr[t];return new(n||Nr[Dr(t)])(...e)}const Tr=t=>t>16?"u32":t>8?"u16":"u8",Kt=(t,e)=>e>0?`(${t} << ${e})`:e<0?`(${t} >>> ${-e})`:`${t}`,Zt=(t,e)=>Kt(t,-e),en=t=>`0x${t.toString(16)}`,jr=t=>{const e=8-t,n=(1<<t)-1;return new Function("luma",`return (x) => ${Zt("luma(x)",e)} & ${n};`)(Jt)},Pr=t=>{let e;if(t!==8){const n=(1<<t)-1,r=255/n;e=`(((x & ${n}) * ${r}) | 0)`}else e="x";return new Function("x",`return 0xff000000 | (${e} * 0x010101);`)},qr=t=>new Function("x","return ("+t.map(e=>{const n=e.abgrShift+(8-e.size);return`(${Zt("x",n)} & ${en(e.maskA)})`}).join(" | ")+") >>> 0;"),Hr=(t,e)=>{const n=t.map(s=>{if(s.size!==8){const o=s.mask0,a=255/o,i=Zt("x",s.shift);return Kt(`((${i} & ${o}) * ${a})`,24-s.lane*8)}else return Kt(`(x & ${en(s.maskA)})`,s.abgrShift)}).join(" | "),r=e?"":"0xff000000 | ";return new Function("x",`return (${r}${n}) >>> 0;`)},Lr=(t,e,n)=>{const r=1<<t.size,s=r-1,o=s<<n>>>0,a=~o>>>0,i=t.lane!=null?t.lane:e,c=l=>l>>>n&s,h=(l,u)=>l&a|(u&s)<<n;return{size:t.size,num:r,abgrShift:24-i*8-n,lane:i,shift:n,mask0:s,maskA:o,int:c,setInt:h,float:l=>c(l)/s,setFloat:(l,u)=>h(l,F(u)*s)}},nn=t=>{M(t.channels.length>0,"no channel specs given");const e=t.channels.reduce(([n,r],s,o)=>(r-=s.size,n.push(Lr(s,o,r)),[n,r]),[[],t.size])[0];return{__packed:!0,type:t.type,size:t.size,alpha:t.alpha||0,channels:e,fromABGR:t.fromABGR||qr(e),toABGR:t.toABGR||Hr(e,!!t.alpha)}},Qt=nn({type:"u32",size:32,alpha:8,channels:[{size:8,lane:E.ALPHA},{size:8,lane:E.BLUE},{size:8,lane:E.GREEN},{size:8,lane:E.RED}],fromABGR:vt,toABGR:vt}),rn=Math.PI,P=rn*2,Wr=1/P;let W=1e-6;const sn=(t,e,n,r,s,o)=>{const a=1-s,i=1-o;return t*a*i+e*s*i+n*a*o+r*s*o},dt=(t,e,n,r,s)=>{r*=.5;const o=-.5*t+1.5*e-1.5*n+r,a=t-2.5*e+2*n-r,i=-.5*t+.5*n,c=e,h=s*s;return s*h*o+h*a+s*i+c},on=(t,e,n,r,s,o,a,i,c,h,l,u,f,g,p,w,S,$)=>dt(dt(t,e,n,r,S),dt(s,o,a,i,S),dt(c,h,l,u,S),dt(f,g,p,w,S),$),Mt=(t,e)=>t-e*Math.floor(t/e),U=t=>t-Math.floor(t),an=(t,e=1)=>Math.round(t/e)*e;function cn(t,e="linear",n="clamp"){const r=!!t.format.__float,s=t.format.channels.length===1?"1":"",o=`${e[0]}${n[0]}${s}`,a=(r?{nc1:Ut,nw1:Ot,nr1:Et,nc:Ut,nw:Ot,nr:Et,lc1:i=>te(Z(i)),lw1:i=>te(Q(i)),lr1:i=>te(tt(i)),lc:i=>ne(i,Ut(i)),lw:i=>ne(i,Ot(i)),lr:i=>ne(i,Et(i)),cc1:i=>se(Z(i)),cw1:i=>se(Q(i)),cr1:i=>se(tt(i)),cc:i=>oe(i,Ut(i)),cw:i=>oe(i,Ot(i)),cr:i=>oe(i,Et(i))}:{nc1:Z,nw1:Q,nr1:tt,nc:Z,nw:Q,nr:tt,lc1:i=>It(Z(i)),lw1:i=>It(Q(i)),lr1:i=>It(tt(i)),lc:i=>ee(i,Z(i)),lw:i=>ee(i,Q(i)),lr:i=>ee(i,tt(i)),cc1:i=>re(i,Z(i)),cw1:i=>re(i,Q(i)),cr1:i=>re(i,tt(i)),cc:i=>ie(i,Z(i)),cw:i=>ie(i,Q(i)),cr:i=>ie(i,tt(i))})[o];return M(!!a,`missing impl for ${o}`),a(t)}const Z=({data:t,width:e,height:n})=>(r,s)=>r>=0&&r<e&&s>=0&&s<n?t[(s|0)*e+(r|0)]:0,Q=({data:t,width:e,height:n})=>(r,s)=>t[Mt(s|0,n)*e+Mt(r|0,e)],tt=({data:t,width:e,height:n})=>{const r=e-1,s=n-1;return(o,a)=>t[j(a|0,0,s)*e+j(o|0,0,r)]},Ut=({data:t,width:e,height:n,stride:[r,s]})=>(o,a)=>{let i;return o>=0&&o<e&&a>=0&&a<n?(i=(a|0)*s+(o|0)*r,t.slice(i,i+r)):[0]},Ot=({data:t,width:e,height:n,stride:[r,s]})=>(o,a)=>{let i=Mt(a|0,n)*s+Mt(o|0,e)*r;return t.slice(i,i+r)},Et=({data:t,width:e,height:n,stride:[r,s]})=>{const o=e-1,a=n-1;return(i,c)=>{let h=j(c|0,0,a)*s+j(i|0,0,o)*r;return t.slice(h,h+r)}},gt=(t,e,n,r,s=4)=>sn(t[r],t[r+s],t[r+2*s],t[r+3*s],e,n),It=t=>(e,n)=>(e-=.5,n-=.5,sn(t(e,n),t(e+1,n),t(e,n+1),t(e+1,n+1),U(e),U(n))),te=t=>(t=It(t),(e,n)=>[t(e,n)]),ee=(t,e)=>{const{fromABGR:n,toABGR:r}=t.format,s=new Uint32Array(4),o=new Uint8Array(s.buffer);return(a,i)=>{a-=.5,i-=.5,s[0]=r(e(a,i)),s[1]=r(e(a+1,i)),s[2]=r(e(a,i+1)),s[3]=r(e(a+1,i+1));const c=U(a),h=U(i);return n(gt(o,c,h,0)|gt(o,c,h,1)<<8|gt(o,c,h,2)<<16|gt(o,c,h,3)<<24)>>>0}},ne=({stride:[t]},e)=>{const n=new Float32Array(t*4);return(r,s)=>{r-=.5,s-=.5,n.set(e(r,s),0),n.set(e(r+1,s),t),n.set(e(r,s+1),t*2),n.set(e(r+1,s+1),t*3);const o=U(r),a=U(s);let i=[];for(let c=0;c<t;c++)i.push(gt(n,o,a,c,t));return i}},hn=t=>(e,n)=>{e-=.5,n-=.5;const r=e-1,s=e+1,o=e+2,a=n-1,i=n+1,c=n+2;return on(t(r,a),t(e,a),t(s,a),t(o,a),t(r,n),t(e,n),t(s,n),t(o,n),t(r,i),t(e,i),t(s,i),t(o,i),t(r,c),t(e,c),t(s,c),t(o,c),U(e),U(n))},re=(t,e)=>{const n=t.format.channels[0].mask0;return e=hn(e),(r,s)=>j(e(r,s),0,n)},se=t=>(t=hn(t),(e,n)=>[t(e,n)]),ln=(t,e,n,r,s=4)=>on(t[r],t[r+s],t[r+2*s],t[r+3*s],t[r+4*s],t[r+5*s],t[r+6*s],t[r+7*s],t[r+8*s],t[r+9*s],t[r+10*s],t[r+11*s],t[r+12*s],t[r+13*s],t[r+14*s],t[r+15*s],e,n),zt=(t,e,n,r,s=4)=>j(ln(t,e,n,r,s),0,255),ie=(t,e)=>{const{fromABGR:n,toABGR:r}=t.format,s=new Uint32Array(16),o=new Uint8Array(s.buffer);return(a,i)=>{a-=.5,i-=.5;const c=a-1,h=a+1,l=a+2,u=i-1,f=i+1,g=i+2,p=U(a),w=U(i);return s[0]=r(e(c,u)),s[1]=r(e(a,u)),s[2]=r(e(h,u)),s[3]=r(e(l,u)),s[4]=r(e(c,i)),s[5]=r(e(a,i)),s[6]=r(e(h,i)),s[7]=r(e(l,i)),s[8]=r(e(c,f)),s[9]=r(e(a,f)),s[10]=r(e(h,f)),s[11]=r(e(l,f)),s[12]=r(e(c,g)),s[13]=r(e(a,g)),s[14]=r(e(h,g)),s[15]=r(e(l,g)),n(zt(o,p,w,0)|zt(o,p,w,1)<<8|zt(o,p,w,2)<<16|zt(o,p,w,3)<<24)>>>0}},oe=({stride:[t]},e)=>{const n=new Float32Array(t*16);return(r,s)=>{r-=.5,s-=.5;const o=r-1,a=r+1,i=r+2,c=s-1,h=s+1,l=s+2,u=U(r),f=U(s);n.set(e(o,c),0),n.set(e(r,c),t),n.set(e(a,c),2*t),n.set(e(i,c),3*t),n.set(e(o,s),4*t),n.set(e(r,s),5*t),n.set(e(a,s),6*t),n.set(e(i,s),7*t),n.set(e(o,h),8*t),n.set(e(r,h),9*t),n.set(e(a,h),10*t),n.set(e(i,h),11*t),n.set(e(o,l),12*t),n.set(e(r,l),13*t),n.set(e(a,l),14*t),n.set(e(i,l),15*t);let g=[];for(let p=0;p<t;p++)g.push(ln(n,u,f,p,t));return g}};var Vr=Object.getOwnPropertyDescriptor,Yr=(t,e,n,r)=>{for(var s=r>1?void 0:r?Vr(e,n):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(s=a(s)||s);return s};function Xr(...t){return t[0]instanceof V?t[0].as(t[1]):new V(...t)}const Jr=(t,e=Qt)=>{const{data:n}=gr(t),r=t.width,s=t.height;let o;if(e===Qt)o=n;else{o=$t(e.type,r*s);const a=n,i=e.fromABGR;for(let c=o.length;c-- >0;)o[c]=i(a[c])}return new V(r,s,e,o)};let V=class{size;stride;format;data;constructor(t,e,n=Qt,r){this.size=[t,e],this.stride=[1,t],this.format=n.__packed?n:nn(n),this.data=r||$t(n.type,t*e)}get pixels(){return this.data}get width(){return this.size[0]}get height(){return this.size[1]}get offset(){return 0}get dim(){return 2}*[Symbol.iterator](){yield*this.data}as(t){if(!t.__float)return this.getRegion(0,0,this.width,this.height,t);const e=new G(this.width,this.height,t),{data:n,format:r,stride:[s]}=e,{data:o,format:a}=this;for(let i=o.length;i-- >0;)n.set(r.fromABGR(a.toABGR(o[i])),i*s);return e}copy(){const t=this.empty();return t.data.set(this.data),t}empty(){return new V(this.width,this.height,this.format)}order(){}includes(t,e){}indexAt(t,e){}indexAtUnsafe(t,e){}getAt(t,e){}getAtUnsafe(t,e){}setAt(t,e,n){}setAtUnsafe(t,e,n){}getChannelAt(t,e,n,r=!1){const s=X(this.format,n),o=this.getAt(t,e);return r?s.float(o):s.int(o)}setChannelAt(t,e,n,r,s=!1){const o=X(this.format,n),a=this.getAt(t,e);return s?o.setFloat(a,r):o.setInt(a,r),this}blend(t,e,n){let r=this.width,s=e.width;const{sx:o,sy:a,dx:i,dy:c,rw:h,rh:l}=Bt(this,e,n);if(h<1||l<1)return e;const u=this.data,f=e.data,g=this.format.toABGR,p=e.format.toABGR,w=e.format.fromABGR;for(let S=(o|0)+(a|0)*r,$=(i|0)+(c|0)*s,L=0;L<l;L++,S+=r,$+=s)for(let C=0;C<h;C++)f[$+C]=w(t(g(u[S+C]),p(f[$+C])));return e}blit(t,e){let n=this.width,r=t.width;const{sx:s,sy:o,dx:a,dy:i,rw:c,rh:h}=Bt(this,t,e);if(c<1||h<1)return t;const l=this.data,u=t.data,f=this.format.toABGR,g=t.format.fromABGR,p=this.format!==t.format?(w,S)=>{for(let $=0;$<c;$++)u[S+$]=g(f(l[w+$]))}:(w,S)=>u.set(l.subarray(w,w+c),S);for(let w=(s|0)+(o|0)*n,S=(a|0)+(i|0)*r,$=0;$<h;$++,w+=n,S+=r)p(w,S);return t}blitCanvas(t,e={}){Qe(this,t,e)}setImageData(t){Xt(t,this.width,this.height);const e=new Uint32Array(t.data.buffer),n=this.data,r=this.format.fromABGR;for(let s=e.length;s-- >0;)n[s]=r(e[s]);return this}toImageData(t){t=Ke(t,this.width,this.height);const e=new Uint32Array(t.data.buffer),n=this.data,r=this.format.toABGR;for(let s=e.length;s-- >0;)e[s]=r(n[s]);return t}getRegion(t,e,n,r,s){const[o,a,i,c]=St(t,e,n,r,this.width,this.height);if(!(i<1||c<1))return this.blit(new V(i,c,s||this.format),{sx:o,sy:a,w:i,h:c})}getChannel(t){const e=X(this.format,t),n=new V(this.width,this.height,{type:Tr(e.size),size:e.size,channels:[{size:e.size,lane:E.RED}],fromABGR:jr(e.size),toABGR:Pr(e.size)}),r=this.data,s=n.data,o=e.int;for(let a=r.length;a-- >0;)s[a]=o(r[a]);return n}setChannel(t,e){const n=X(this.format,t),r=this.data,s=n.setInt;if(it(e))Rr(r,e,s);else{const o=e.data,a=e.format.channels[0];Je(o,this.width,this.height),n.size===a.size?vr(r,o,a.int,s):Sr(r,o,this.format.fromABGR,e.format.toABGR,n.maskA)}return this}invert(){const{data:t,format:e}=this,n=Math.pow(2,e.size-e.alpha)-1;for(let r=t.length;r-- >0;)t[r]^=n;return this}premultiply(){return Fr(this.format),Ze(this.data,this.format,xr),this}postmultiply(){return Ze(this.data,this.format,Ar),this}isPremultiplied(){const t=this.data,e=this.format.toABGR;for(let n=t.length;n-- >0;)if(!wr(e(t[n])))return!1;return!0}forEach(t){const e=this.data;for(let n=e.length;n-- >0;)e[n]=t(e[n],n);return this}fill(t){this.data.fill(t)}flipX(){const{data:t,width:e}=this;for(let n=0;n<t.length;n+=e)t.subarray(n,n+e).reverse();return this}flipY(){const{data:t,width:e}=this,n=$t(this.format.type,e);for(let r=0,s=t.length-e;r<s;r+=e,s-=e)n.set(t.subarray(r,r+e)),t.copyWithin(r,s,s+e),t.set(n,s);return this}rotateByID(t){return t>0?this[Le[t-1]]():this}rotateCW(){const{width:t,height:e}=this,n=e-1;return this._rotate((r,s)=>r*e+n-s),this.size[0]=e,this.size[1]=t,this}rotateCCW(){const{width:t,height:e}=this,n=t-1;return this._rotate((r,s)=>(n-r)*e+s),this.size[0]=e,this.size[1]=t,this}rotate180(){const{width:t,height:e}=this,n=t-1,r=e-1;return this._rotate((s,o)=>(r-o)*t+n-s),this}scale(t,e="linear"){return M(t>0,"scale must be > 0"),this.resize(this.width*t,this.height*t,e)}resize(t,e,n="linear"){t|=0,e|=0,M(t>0&&e>0,"target width & height must be > 0");const r=Xr(t,e,this.format),s=r.data,o=t>0?this.width/t:0,a=e>0?this.height/e:0;n=ot(n)?cn(this,n,"repeat"):n;for(let i=0,c=0;i<e;i++){const h=i*a;for(let l=0;l<t;l++,c++)s[c]=n(l*o,h)}return r}upsize(){const{width:t,height:e,data:n}=this,r=new V(t*2,e*2,this.format),s=r.data;for(let o=0,a=0;o<e;o++)for(let i=0,c=o*t*4;i<t;i++,a++,c+=2)s[c]=n[a];return r}_rotate(t){const{data:e,format:n,width:r,height:s}=this,o=$t(n.type,r*s);for(let a=0;a<s;a++)for(let i=0;i<r;i++)o[t(i,a)]=e[a*r+i];this.data=o}};V=Yr([We],V);var Kr=Object.defineProperty,Zr=Object.getOwnPropertyDescriptor,mt=(t,e,n,r)=>{for(var s=r>1?void 0:r?Zr(e,n):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(s=(r?a(e,n,s):a(s))||s);return r&&s&&Kr(e,n,s),s};function fn(...t){return t[0]instanceof V?Qr(...t):new G(...t)}const Qr=(t,e)=>{const n=new G(t.width,t.height,e),{data:r,format:s,stride:[o]}=n,{data:a,format:i}=t;for(let c=a.length;c-- >0;)r.set(s.fromABGR(i.toABGR(a[c])),c*o);return n},ts=(t,e=at)=>Jr(t).as(e);let G=class{size;stride;format;data;__empty;constructor(t,e,n=at,r){this.size=[t,e],this.format=n.__float?n:Ct(n);const s=this.format.channels.length;this.stride=[s,t*s],this.data=r||new Float32Array(t*e*s),this.__empty=Object.freeze(new Array(s).fill(0))}get pixels(){return this.data}get width(){return this.size[0]}get height(){return this.size[1]}get offset(){return 0}get dim(){return 2}*[Symbol.iterator](){const{data:t,stride:[e]}=this;for(let n=0,r=t.length;n<r;n+=e)yield t.subarray(n,n+e)}as(t){const{width:e,height:n,stride:[r],data:s,format:{size:o,normalized:a,toABGR:i}}=this;let c=0,h=0,l=s.length;if(t.__float){const u=t,f=new G(e,n,u),{data:g,stride:[p]}=f;if(o===1&&u.channels.length===1){const w=u.fromNormalized;for(;c<l;c+=r,h+=p)g[h]=w(a(s[c]))}else for(;c<l;c+=r,h+=p)g.set(u.fromABGR(i(s.subarray(c,c+r))),h);return f}else{const u=t,f=new V(e,n,u),g=f.data;if(o===1&&u.channels.length===1){const p=u.channels[0].setFloat;for(;c<l;c+=r,h++)g[h]=p(0,a(s[c]))}else for(;c<l;c+=r,h++)g[h]=u.fromABGR(i(s.subarray(c,c+r)));return f}}copy(){const t=this.empty();return t.data.set(this.data),t}empty(){return new G(this.width,this.height,this.format)}order(){}includes(t,e){}indexAt(t,e){}indexAtUnsafe(t,e){}getAt(t,e){return this.includes(t,e)?this.getAtUnsafe(t,e):this.__empty}getAtUnsafe(t,e){const n=this.indexAtUnsafe(t,e);return this.data.subarray(n,n+this.stride[0])}setAt(t,e,n){return this.includes(t,e)?(this.data.set(n,this.indexAtUnsafe(t,e)),!0):!1}setAtUnsafe(t,e,n){return this.data.set(n,this.indexAtUnsafe(t,e)),!0}getChannelAt(t,e,n){return X(this.format,n),this.includes(t,e)?this.data[this.indexAtUnsafe(t,e)+n]:void 0}setChannelAt(t,e,n,r){return X(this.format,n),this.includes(t,e)&&(this.data[this.indexAtUnsafe(t,e)+n]=r),this}getChannel(t){X(this.format,t);const{data:e,stride:[n]}=this,[r,s]=this.format.range,o=new Float32Array(this.width*this.height);for(let a=t,i=0,c=e.length;a<c;a+=n,i++)o[i]=j(e[a],r,s);return new G(this.width,this.height,tn,o)}setChannel(t,e){X(this.format,t);const{data:n,stride:[r]}=this;if(it(e))for(let s=t,o=n.length;s<o;s+=r)n[s]=e;else{const{data:s,stride:[o]}=e;Je(s,this.width,this.height,o);for(let a=t,i=0,c=n.length;a<c;a+=r,i+=o)n[a]=s[i]}return this}blend(t,e,n){this.ensureFormat(e);const{sx:r,sy:s,dx:o,dy:a,rw:i,rh:c}=Bt(this,e,n);if(i<1||c<1)return e;const h=this.data,l=e.data,[u,f]=this.stride,g=e.stride[1];for(let p=(r|0)*u+(s|0)*f,w=(o|0)*u+(a|0)*g,S=0;S<c;S++,p+=f,w+=g)for(let $=i,L=p,C=w;$-- >0;L+=u,C+=u){const J=l.subarray(C,C+u);t(J,h.subarray(L,L+u),J)}return e}blit(t,e){this.ensureFormat(t);const{sx:n,sy:r,dx:s,dy:o,rw:a,rh:i}=Bt(this,t,e);if(a<1||i<1)return t;const c=this.data,h=t.data,[l,u]=this.stride,f=t.stride[1],g=a*l;for(let p=(n|0)*l+(r|0)*u,w=(s|0)*l+(o|0)*f,S=0;S<i;S++,p+=u,w+=f)h.set(c.subarray(p,p+g),w);return t}blitCanvas(t,e={}){Qe(this,t,e)}setImageData(t){Xt(t,this.width,this.height);const e=new Uint32Array(t.data.buffer),{data:n,format:{fromABGR:r},stride:[s]}=this,o=[];for(let a=e.length;a-- >0;)n.set(r(e[a],o),a*s);return this}toImageData(t){t=Ke(t,this.width,this.height);const e=new Uint32Array(t.data.buffer),{stride:[n],data:r,format:s}=this;for(let o=0,a=0,i=r.length;o<i;o+=n,a++)e[a]=s.toABGR(r.subarray(o,o+n));return t}getRegion(t,e,n,r){const[s,o,a,i]=St(t,e,n,r,this.width,this.height);if(!(a<1||i<1))return this.blit(new G(a,i,this.format),{sx:s,sy:o,w:a,h:i})}forEach(t){const{data:e,stride:[n]}=this;for(let r=0,s=0,o=e.length;r<o;r+=n,s++)e.set(t(e.subarray(r,r+n),s),r);return this}fill(t){M(t.length<=this.format.channels.length,"fill value has too many channels");const{data:e,stride:[n]}=this;for(let r=0,s=e.length;r<s;r+=n)e.set(t,r)}premultiply(){this.ensureRGBA();const{data:t,stride:[e]}=this;for(let n=0,r=t.length;n<r;n+=e)yr(null,t.subarray(n,n+e));return this}postmultiply(){this.ensureRGBA();const{data:t,stride:[e]}=this;for(let n=0,r=t.length;n<r;n+=e)pr(null,t.subarray(n,n+e));return this}isPremultiplied(){this.ensureRGBA();const{data:t,stride:[e]}=this;for(let n=0,r=t.length;n<r;n+=e)if(!_r(t.subarray(n,n+e)))return!1;return!0}clamp(){const t=this.data,[e,n]=this.format.range;for(let r=t.length;r-- >0;)t[r]=j(t[r],e,n);return this}clampChannel(t){X(this.format,t);const{data:e,stride:[n]}=this,[r,s]=this.format.range;for(let o=t,a=e.length;o<a;o+=n)e[o]=j(e[o],r,s)}flipX(){const{data:t,width:e,height:n,stride:[r,s]}=this,o=new Float32Array(r),a=e-1,i=e>>>1;for(let c=0;c<n;c++)for(let h=0,l=c*s,u=l+a*r;h<i;h++,l+=r,u-=r)o.set(t.subarray(l,l+r)),t.copyWithin(l,u,u+r),t.set(o,u);return this}flipY(){const t=this.data,e=this.stride[1],n=new Float32Array(e);for(let r=0,s=t.length-e;r<s;r+=e,s-=e)n.set(t.subarray(r,r+e)),t.copyWithin(r,s,s+e),t.set(n,s);return this}rotateByID(t){return t>0?this[Le[t-1]]():this}rotateCW(){const{width:t,height:e}=this,n=e-1;return this._rotate((r,s)=>r*e+n-s),this.size[0]=e,this.size[1]=t,this}rotateCCW(){const{width:t,height:e}=this,n=t-1;return this._rotate((r,s)=>(n-r)*e+s),this.size[0]=e,this.size[1]=t,this}rotate180(){const{width:t,height:e}=this,n=t-1,r=e-1;return this._rotate((s,o)=>(r-o)*t+n-s),this}invert(){const{data:t,format:e,stride:[n]}=this;for(let r=0,s=t.length,o=e.alpha?n-1:n;r<s;r+=n)for(let a=0;a<o;a++)t[r+a]=1-t[r+a];return this}scale(t,e){return M(t>0,"scale must be > 0"),this.resize(this.width*t,this.height*t,e)}resize(t,e,n="linear"){t|=0,e|=0,M(t>0&&e>0,"target width & height must be > 0");const r=fn(t,e,this.format),s=r.data,o=t>0?this.width/t:0,a=e>0?this.height/e:0,i=this.stride[0];n=ot(n)?cn(this,n,"repeat"):n;for(let c=0,h=0;c<e;c++){const l=c*a;for(let u=0;u<t;u++,h+=i)s.set(n(u*o,l),h)}return r}upsize(){const{width:t,height:e,data:n,stride:[r,s]}=this,o=r*2,a=fn(t*2,e*2,this.format),i=a.data;for(let c=0,h=0;c<e;c++)for(let l=0,u=c*s*4;l<t;l++,h+=r,u+=o)i.set(n.subarray(h,h+r),u);return a}_rotate(t){const{data:e,width:n,height:r,stride:[s]}=this,o=new Float32Array(n*r*s);for(let a=0,i=0;a<r;a++)for(let c=0;c<n;c++,i+=s)o.set(e.subarray(i,i+s),t(c,a)*s);this.data=o}ensureFormat(t){M(t.format===this.format,"dest buffer format must be same as src")}ensureRGBA(){M(this.format===at,"require FLOAT_RGBA format")}};mt([wt],G.prototype,"getAt",1),mt([wt],G.prototype,"getAtUnsafe",1),mt([wt],G.prototype,"setAt",1),mt([wt],G.prototype,"setAtUnsafe",1),G=mt([We],G);const es=(t,e,n)=>(t-e)/(n-e),ns=(t,e,n,r,s)=>r+(s-r)*es(t,e,n),kt=Math.abs,rs=Math.min,ss=Ct({alpha:!0,channels:[E.RED,E.GREEN,E.BLUE,E.ALPHA],convert:{fromABGR:(t,e=[])=>{const n=(t>>>24&255)/255,r=(t>>>16&255)/255,s=(t>>>8&255)/255,o=(t&255)/255;let a,i,c,h,l,u,f,g;s<r?(a=r,i=s,c=-1,h=2/3):(a=s,i=r,c=0,h=-1/3),o<a?(l=a,u=i,f=h,g=o):(l=o,u=i,f=c,g=a);const p=l-rs(u,g);return l=F(l),e[0]=F(kt((g-u)/(6*p+W)+f)),e[1]=F(p/(l+W)),e[2]=l,e[3]=n,e},toABGR:t=>{const e=t[0]*6,n=t[1],r=t[2]*255,s=t[3]*255,o=((F(kt(e-3)-1)-1)*n+1)*r,a=((F(2-kt(e-2))-1)*n+1)*r,i=((F(2-kt(e-4))-1)*n+1)*r;return(s<<24|i<<16|a<<8|o)>>>0}}}),at=Ct({alpha:!0,channels:[E.RED,E.GREEN,E.BLUE,E.ALPHA]}),is=Rt(()=>"unsupported operation"),ae=t=>{throw new is(t)},q=(t=1,e,...n)=>{const r=[,,].concat(n),s=(...o)=>{const a=r[o[t].length]||e;return a?a(...o):ae(`no impl for vec size ${o[t].length}`)};return s.add=(o,a)=>r[o]=a,s.default=o=>e=o,s.impl=o=>o!=null&&r[o]||e,s},os=(t,e)=>t[0]*e[0]+t[1]*e[1],ce=(t,e)=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2],as=q(0,(t,e)=>{let n=0;for(let r=t.length;r-- >0;)n+=t[r]*e[r];return n},os,ce,(t,e)=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]);function un(t,e=Object.create(null)){return(...n)=>{const r=JSON.stringify(n);return r!==void 0?r in e?e[r]:e[r]=t.apply(null,n):t.apply(null,n)}}function dn(t,e=Object.create(null)){return(...n)=>{const r=n.join("-");return r in e?e[r]:e[r]=t(...n)}}const cs=dn((t,e)=>t.repeat(e)),gn=un((t,e=!1)=>e?n=>hs(n)||n.toFixed(t):n=>n.toFixed(t)),hs=t=>isNaN(t)?"NaN":t===1/0?"+∞":t===-1/0?"-∞":void 0,ls=(t=0)=>e=>(e*100).toFixed(t)+"%",fs=[.299,.587,.114],mn=[.2126,.7152,.0722],us=[3.1338561,-.9787684,.0719453,-1.6168667,1.9161415,-.2289914,-.4906146,.033454,1.4052427],ds=[3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252],gs=[.96422,1,.82521],ms=[.95047,1,1.08883],bs=[.2104542553,1.9779984951,.0259040371,.793617785,-2.428592205,.7827717662,-.0040720468,.4505937099,-.808675766];let Gt=gn(3),bn=ls(3);const H=1/255,he=(t,e=mn)=>ce(t,e),ys=t=>ce(t,fs),xs=(t,e)=>(!t&&(t=[]),t[0]=e[0],t[1]=e[1],t),ps=(t,e)=>(!t&&(t=[]),t[0]=e[0],t[1]=e[1],t[2]=e[2],t),ct=(t,e)=>(!t&&(t=[]),t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t),As=q(1,(t,e)=>{!t&&(t=[]);for(let n=e.length;n-- >0;)t[n]=e[n];return t},xs,ps,ct),bt=(t,e)=>typeof t?.[e]=="function",le=t=>t!=null&&typeof t!="function"&&t.length!==void 0,_s=Rt(()=>"illegal argument(s)"),fe=t=>{throw new _s(t)},ws=un((t,e=3,n=",",r="[",s="]")=>{const o=typeof e=="number"?gn(e):e;switch(t){case 1:return a=>`${r}${o(a[0])}${s}`;case 2:return a=>`${r}${o(a[0])}${n}${o(a[1])}${s}`;case 3:return a=>`${r}${o(a[0])}${n}${o(a[1])}${n}${o(a[2])}${s}`;case 4:return a=>`${r}${o(a[0])}${n}${o(a[1])}${n}${o(a[2])}${n}${o(a[3])}${s}`;default:return a=>{const i=[];for(let c=0;c<a.length;c++)i.push(o(a[c]));return`${r}${i.join(n)}${s}`}}}),Fs=(t,e,n,r,s,o)=>{const a=[];for(;n-- >0;)a.push(new t(e,r,s)),r+=o;return a},Rs=(t,e=1,n=!0)=>{const r=n?(i,c,h,l)=>{!i&&(i=c);for(let u=c.length;u-- >0;)i[u]=t(c[u],h[u],l[u]);return i}:(i,c,h,l)=>{!i&&(i=l);for(let u=c.length;u-- >0;)i[u]=t(c[u],h[u],l[u]);return i},s=n?(i,c,h,l)=>(!i&&(i=c),i[0]=t(c[0],h[0],l[0]),i[1]=t(c[1],h[1],l[1]),i):(i,c,h,l)=>(!i&&(i=l),i[0]=t(c[0],h[0],l[0]),i[1]=t(c[1],h[1],l[1]),i),o=n?(i,c,h,l)=>(!i&&(i=c),i[0]=t(c[0],h[0],l[0]),i[1]=t(c[1],h[1],l[1]),i[2]=t(c[2],h[2],l[2]),i):(i,c,h,l)=>(!i&&(i=l),i[0]=t(c[0],h[0],l[0]),i[1]=t(c[1],h[1],l[1]),i[2]=t(c[2],h[2],l[2]),i),a=n?(i,c,h,l)=>(!i&&(i=c),i[0]=t(c[0],h[0],l[0]),i[1]=t(c[1],h[1],l[1]),i[2]=t(c[2],h[2],l[2]),i[3]=t(c[3],h[3],l[3]),i):(i,c,h,l)=>(!i&&(i=l),i[0]=t(c[0],h[0],l[0]),i[1]=t(c[1],h[1],l[1]),i[2]=t(c[2],h[2],l[2]),i[3]=t(c[3],h[3],l[3]),i);return[q(e,r,s,o,a),s,o,a]},[Io,zo,ko,vs]=Rs(j),Ss=vs,Bs=(t,e,n,r=!0,s=!0)=>{const o=n>0?r?function(){return this.buf[this.offset+n*this.stride]}:function(){return this.buf[this.offset+n]}:function(){return this.buf[this.offset]},a=n>0?r?function(i){this.buf[this.offset+n*this.stride]=i}:function(i){this.buf[this.offset+n]=i}:function(i){this.buf[this.offset]=i};s&&Object.defineProperty(t,n,{get:o,set:a,enumerable:!0}),Object.defineProperty(t,e,{get:o,set:a,enumerable:!0})},Cs=(t,e,n,r)=>e.forEach((s,o)=>Bs(t,s,o,n,r)),$s=Math.abs,Y=(t,e,n=W)=>$s(t-e)<=n,Ms=(t,e,n=W)=>t.length===e.length&&Y(t[0],e[0],n)&&Y(t[1],e[1],n),Us=(t,e,n=W)=>t.length===e.length&&Y(t[0],e[0],n)&&Y(t[1],e[1],n)&&Y(t[2],e[2],n),yn=(t,e,n=W)=>t.length===e.length&&Y(t[0],e[0],n)&&Y(t[1],e[1],n)&&Y(t[2],e[2],n)&&Y(t[3],e[3],n);q(0,(t,e,n=W)=>bt(t,"eqDelta")?t.eqDelta(e,n):bt(e,"eqDelta")?e.eqDelta(t,n):Os(t,e,t.length,n),Ms,Us,yn);const Os=(t,e,n,r=W,s=0,o=0,a=1,i=1)=>{for(;n>0;n--,s+=a,o+=i)if(!Y(t[s],e[o],r))return!1;return!0};function*Es(t,e,n,r){for(;e-- >0;)yield t[n],n+=r}const xn=1/2**32;class Is{float(e=1){return this.int()*xn*e}probability(e){return this.float()<e}norm(e=1){return(this.int()*xn-.5)*2*e}normMinMax(e,n){const r=this.minmax(e,n);return this.float()<.5?r:-r}minmax(e,n){return this.float()*(n-e)+e}minmaxInt(e,n){e|=0;const r=(n|0)-e;return r?e+this.int()%r:e}minmaxUint(e,n){e>>>=0;const r=(n>>>0)-e;return r?e+this.int()%r:e}}class zs extends Is{constructor(e){super(),this.rnd=e}float(e=1){return this.rnd()*e}norm(e=1){return(this.rnd()-.5)*2*e}int(){return this.rnd()*4294967296>>>0}}const ue=new zs(Math.random),ks=(t,e,n=ue)=>{const r=t.length;M(r>0,"no choices given");const s=e?t.map((a,i)=>[e[i]||0,a]).sort((a,i)=>i[0]-a[0]):t.map(a=>[1,a]),o=s.reduce((a,i)=>a+i[0],0);return o<=0&&console.warn("total weights <= 0"),()=>{const a=n.float(o);let i=o;for(let c=0;c<r;c++)if(i-=s[c][0],i<=a)return s[c][1]}},Gs=q(1,(t,e,n,r=ue)=>{!t&&(t=e);for(let s=e.length;s-- >0;)t[s]=r.minmax(e[s],n[s]);return t}),pn=Array.isArray,yt={},An=(t,e)=>{for(let n in e){const r=e[n];if(pn(r)){const[s,o,a,i]=r;e[n]=r.length===2?(c,h)=>o(c,s(c,h)):r.length===3?(c,h)=>a(c,o(c,s(c,h))):(c,h)=>i(c,a(c,o(c,s(c,h))))}}yt[t]={...yt[t],...e}},_n=(t,e,n,r)=>{const s=yt[n];M(!!s,`no conversions available for ${n}`);let o=s[r];return o?o(t,e):yt.rgb[r]?s.rgb(t,yt.rgb[r]([],e)):ae(`can\'t convert: ${r} -> ${n}`)},wn=(t,e)=>(t>>>e|t<<32-e)>>>0,Ns=t=>(t&3840)*4352|(t&240)*272|(t&15)*17,Ds=t=>((t&61440)*69632|(t&3840)*4352|(t&240)*272|(t&15)*17)>>>0;class st{constructor(e,n){this.mode=e,this.value=n}deref(){return this.value}}const Ts={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",grey:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32",transparent:"0000",rebeccapurple:"639"};let js={canvas:"fff",canvastext:"000",linktext:"001ee4",visitedtext:"4e2386",activetext:"eb3323",buttonface:"ddd",buttontext:"000",buttonborder:"000",field:"fff",fieldtext:"000",highlight:"bbd5fb",highlighttext:"000",mark:"000",marktext:"fff",graytext:"808080"};const N=(t,e,n,r)=>(!t&&(t=[]),t[0]=e,t[1]=n,t[2]=r,t),I=(t,e,n,r,s)=>(!t&&(t=[]),t[0]=e,t[1]=n,t[2]=r,t[3]=s,t),Nt=(t,e)=>I(t||[],(e>>>16&255)*H,(e>>>8&255)*H,(e&255)*H,(e>>>24)*H),Fn=(t,e)=>I(t||[],(e&255)*H,(e>>>8&255)*H,(e>>>16&255)*H,(e>>>24)*H),Ps=t=>{t=(ot(t)?t:t.deref()).toLowerCase();const e=Ts[t]||js[t];if(e||t[0]==="#")return new st("srgb",Nt([],Hs(e||t)));const n=t.split(/[(),/ ]+/),[r,s,o,a,i]=n;switch(M(n.length===5||n.length===6,`invalid color: ${t}`),r){case"rgb":case"rgba":return new st("srgb",[k(s,1,H,!0),k(o,1,H,!0),k(a,1,H,!0),ht(i)]);case"hsl":case"hsla":return new st("hsl",[de(s),Rn(o),Rn(a),ht(i)]);case"lab":return new st("lab50",[k(s),k(o,1.25),k(a,1.25),ht(i)]);case"lch":return new st(r,[k(s),k(o,1.5),de(a),ht(i)]);case"oklab":return new st(r,[k(s,1,1),k(o,.4,1),k(a,.4,1),ht(i)]);case"oklch":return new st(r,[k(s,1,1),k(o,.4,1),de(a),ht(i)]);default:ae(`color mode: ${r}`)}},qs={rad:P,grad:400,turn:1,deg:360},de=t=>{const e=/^(-?[0-9.]+)(deg|rad|grad|turn)?$/.exec(t);return M(!!e,`expected hue, got: ${t}`),U(parseFloat(e[1])/(qs[e[2]]||360))},ht=t=>t?k(t,1,1,!0):1,Rn=(t,e=!0)=>{M(/^([0-9.]+)%$/.test(t),`expected percentage, got: ${t}`);const n=parseFloat(t)/100;return e?F(n):n},k=(t,e=1,n=.01,r=!1)=>{M(/^-?[0-9.]+%?$/.test(t),`expected number or percentage, got: ${t}`);const s=parseFloat(t)*(t.endsWith("%")?.01*e:n);return r?F(s):s},Hs=t=>{const e=/^#?([0-9a-f]{3,8})$/i.exec(t);if(e){const n=e[1],r=parseInt(n,16);switch(n.length){case 3:return(Ns(r)|4278190080)>>>0;case 4:return wn(Ds(r),8);case 6:return(r|4278190080)>>>0;case 8:return wn(r,8)}}return fe(`invalid hex color: "${t}"`)},z=(t,e=1)=>t!=null?F(t):e,Ls=t=>{if(typeof t[0]=="number")switch(t.length){case 1:return t.push(0,0,1),[t];case 2:return t.push(0,1),[t];case 3:return t.push(1),[t];default:return[t]}return t},Dt=t=>{const e=t.channels||{},n=t.order,r=n.length;n.reduce((f,g)=>(f[g]={range:[0,1],...e[g]},f),e);const s=Object.freeze(n.map(f=>e[f].range[0])),o=Object.freeze(n.map(f=>e[f].range[1])),a=ct([],s),i=ct([],o);a[r-1]=1;const c=n.findIndex(f=>!!e[f].hue),h=class{constructor(f,g=0,p=1){this.offset=g,this.stride=p,this.buf=f||[0,0,0,0],this.offset=g,this.stride=p}buf;get mode(){return t.mode}get length(){return r}get range(){return[s,o]}get[Symbol.toStringTag](){return t.mode}get xyz(){return[this[0],this[1],this[2]]}[Symbol.iterator](){return Es(this.buf,this.length,this.offset,this.stride)}copy(){return new h(this.deref())}copyView(){return new h(this.buf,this.offset,this.stride)}empty(){return new h}deref(){return[this[0],this[1],this[2],this[3]]}set(f){return ct(this,f)}clamp(){return c>=0&&(this[c]=U(this[c])),Ss(null,this,s,o),this}eqDelta(f,g=W){return yn(this,f,g)}randomize(f){return Gs(this,a,i,f)}toJSON(){return this.deref()}toString(){return ws(4,4)(this)}};Cs(h.prototype,n),An(t.mode,t.from),An("rgb",{[t.mode]:t.toRgb});const l=(f,g,p)=>{const w=new h(...p);return g!==t.mode?_n(w,f,t.mode,g):w.set(f)},u=(f,...g)=>f==null?new h:ot(f)?u(Ps(f),...g):le(f)?ot(f.mode)?l(f,f.mode,g):new h(f,...g):bt(f,"deref")?l(f.deref(),f.mode,g):it(f)?g.length&&g.every(it)?new h(...Ls([f,...g])):l(Nt([],f),"srgb",g):fe(`can\'t create a ${t.mode} color from: ${f}`);return u.class=h,u.range=[s,o],u.random=(f,g,p,w)=>new h(g,p,w).randomize(f),u.mapBuffer=(f,g=f.length/r|0,p=0,w=1,S=r)=>Fs(h,f,g,p,w,S),u},ge=(t,e,n=1)=>(e=U(e)*6,I(t||[],F(Math.abs(e-3)-1),F(2-Math.abs(e-2)),F(2-Math.abs(e-4)),n)),vn=(t,e)=>{const n=e[0];let r=e[1];const s=e[2],o=ge(t||e,n,z(e[3])),a=he(o);return s<a?r*=s/a:a<1&&(r*=(1-s)/(1-a)),N(o,F((o[0]-a)*r+s),F((o[1]-a)*r+s),F((o[2]-a)*r+s))},Ws=(t,e,n=1)=>I(t||e,F(e[0]),F(e[1]),F(e[2]),z(e[3],n)),Tt=(t,e,n=1)=>I(t||e,U(e[0]),F(e[1]),F(e[2]),z(e[3],n)),Sn=(t,e)=>{t=Tt(t||e,e);const n=t[1],r=t[2];if(n<1e-6)return N(t,r,r,r);const s=t[0]*6%6,o=r*(1-n),a=1-Math.abs(s%2-1);let i=3*r*n/(1+a);const c=i*a+o;switch(i+=o,s|0){case 0:return N(t,i,c,o);case 1:return N(t,c,i,o);case 2:return N(t,o,i,c);case 3:return N(t,o,c,i);case 4:return N(t,c,o,i);case 5:return N(t,i,o,c);default:return N(t,o,o,o)}},Bn=(t,e)=>{const n=F(e[1]),r=F(e[2]);t=ge(t||e,e[0],z(e[3]));const s=(1-Math.abs(2*r-1))*n;return N(t,(t[0]-.5)*s+r,(t[1]-.5)*s+r,(t[2]-.5)*s+r)},me=(t,e)=>{t=Tt(t||e,e);const n=t[1],r=t[2];return ge(t,e[0],t[3]),N(t,((t[0]-1)*n+1)*r,((t[1]-1)*n+1)*r,((t[2]-1)*n+1)*r)},be=t=>t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055,ye=t=>t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4),jt=(t,e)=>I(t||e,ye(e[0]),ye(e[1]),ye(e[2]),z(e[3])),Vs=(t,e)=>jt(null,Nt(t,e)),Ys=(t,e)=>jt(null,Fn(t,e)),xe=(t,e=1)=>[Math.cos(t)*e,Math.sin(t)*e],Xs=t=>(t%=P,t<0?P+t:t),Cn=(t,e)=>Xs(Math.atan2(t,e)),pe=(t,e)=>{let{1:n,2:r}=e;r*=P;const s=z(e[3]);return n>0?I(t||e,e[0],Math.cos(r)*n,Math.sin(r)*n,s):I(t||e,e[0],0,0,s)},Ae=t=>{const e=t**3;return e>.008856?e:(t-16/116)/7.787},$n=(t,e,n=gs)=>{const r=(e[0]+.16)/1.16;return I(t||e,Ae(e[1]/5+r)*n[0],Ae(r)*n[1],Ae(r-e[2]/2)*n[2],z(e[3]))},Js=(t,e)=>$n(t,e,ms),_e=(t,e,n=0,r=0,s=1,o=1)=>t[n]*e[r]+t[n+s]*e[r+o]+t[n+2*s]*e[r+2*o],Pt=(t,e,n,r=!1)=>{const s=_e(e,n,0,0,3),o=_e(e,n,1,0,3),a=_e(e,n,2,0,3),i=z(n[3]);return r?I(t||n,F(s),F(o),F(a),i):I(t||n,s,o,a,i)},we=(t,e,n=us)=>Pt(t,n,e),Fe=(t,e)=>we(t,e,ds),xt=(t,e)=>we(null,$n(t,e)),Mn=(t,e)=>Fe(null,Js(t,e)),Ks=[4.0767416621,-1.2684380046,-.0041960863,-3.307711591,2.6097574011,-.7034186147,.2309699292,-.3413193965,1.707614701],Un=(t,{0:e,1:n,2:r,3:s})=>Pt(t,Ks,[(e+.3963377774*n+.2158037573*r)**3,(e-.1055613458*n-.0638541728*r)**3,(e-.0894841775*n-1.291485548*r)**3,s]),On=(t,e)=>e!==0?t/e:0,En=Dt({mode:"rgb",order:["r","g","b","alpha"],from:{abgr32:(t,e)=>Ys(t,e[0]),argb32:(t,e)=>Vs(t,e[0]),hcy:vn,hsi:Sn,hsl:Bn,hsv:me,lab50:xt,lab65:Mn,lch:[pe,xt],oklab:Un,rgb:ct,srgb:jt,xyy:[(t,e)=>{const{0:n,1:r,2:s}=e;return I(t||e,On(s*n,r),s,On(s*(1-n-r),r),z(e[3]))},Fe],xyz50:we,xyz65:Fe,ycc:(t,e,n=mn)=>{const r=e[0],s=(2-2*n[2])*e[1],o=(2-2*n[0])*e[2];return I(t||e,r+o,r-n[2]/n[1]*s-n[0]/n[1]*o,r+s,z(e[3]))}},toRgb:ct}),Zs=(t,e)=>{const n=he(En(t))+.05,r=he(En(e))+.05;return n>r?n/r:r/n},In=t=>{const e=Gt(U(t[0])*360),n=bn(F(t[1])),r=bn(F(t[2])),s=z(t[3]);return s<1?`hsla(${e},${n},${r},${Gt(s)})`:`hsl(${e},${n},${r})`},Qs=(t,e)=>{t=Tt(t||e,e);const n=t[1],r=t[2],s=(2-n)*r/2;return t[2]=s,t[1]=s&&s<1?n*r/(s<.5?s*2:2-s*2):n,t},ti=t=>In(Qs([],t)),zn="0123456789abcdef",Re=t=>zn[t>>>4&15]+zn[t&15],ei=t=>Re(t>>>8)+Re(t&255),ni=t=>Re(t>>>16)+ei(t),ve=dn((t,e,n="")=>{const r=cs("0",e);return s=>(s=(s>>>0).toString(t),n+(s.length<e?r.substring(s.length)+s:s))});ve(2,8),ve(2,16),ve(2,32);const kn=ni,Se=t=>{const e=t>>>24;return e<255?`rgba(${t>>16&255},${t>>8&255},${t&255},${Gt(e*H)})`:`#${kn(t&16777215)}`},ri=t=>(t&255)<<16|t>>16&255|t&4278255360,lt=(t,e)=>I(t||e,be(e[0]),be(e[1]),be(e[2]),z(e[3])),Be=(t,e=0)=>(t<0?0:t>1?1:t)*255+.5<<e,ft=t=>{const e=Be(t[0]),n=Be(t[1]),r=Be(t[2]),s=z(t[3]);return s<1?`rgba(${e},${n},${r},${Gt(s)})`:`#${kn(e<<16|n<<8|r)}`},Gn={abgr32:t=>Se(ri(t[0])),argb32:t=>Se(t[0]),hsl:In,hsv:ti,lab50:t=>ft(lt(null,xt([],t))),lab65:t=>ft(lt(null,Mn([],t))),lch:t=>ft(lt(null,xt(null,pe([],t)))),rgb:t=>ft(lt([],t)),srgb:ft};({...Gn});let si=Gn;const Nn=(t,e=si)=>{let n;return ot(t)?t:it(t)?Se(t):t.mode?(n=e[t.mode])?n(t):e.rgb(_n([],t,"rgb",t.mode)):ft(t)},ii=(t,e)=>{t=Tt(t||e,e);const n=t[1],r=t[2],s=2*r,o=(s+n*(1-Math.abs(s-1)))*.5;return t[1]=2*(o-r)/o,t[2]=o,t},oi=(t,e)=>{t=Ws(t||e,e);const n=t[1]<t[2]?[t[2],t[1],-1,2/3]:[t[1],t[2],0,-1/3],r=t[0]<n[0]?[n[0],n[1],n[3],t[0]]:[t[0],n[1],n[2],n[0]],s=r[0]-Math.min(r[1],r[3]);return N(t,F(Math.abs((r[3]-r[1])/(6*s+W)+r[2])),F(s),F(r[0]))},Ce=(t,e)=>(t=oi(t,e),t[1]/=t[2]+W,t),ai=Dt({mode:"hsv",channels:{h:{hue:!0}},order:["h","s","v","alpha"],from:{rgb:Ce,srgb:Ce,hsl:ii,lch:[pe,xt,lt,Ce]},toRgb:me}),qt=(t,e=1)=>{const n=(a,i,c)=>{!a&&(a=i);for(let h=i.length;h-- >0;)a[h]=t(i[h],c);return a},r=(a,i,c)=>(!a&&(a=i),a[0]=t(i[0],c),a[1]=t(i[1],c),a),s=(a,i,c)=>(!a&&(a=i),a[0]=t(i[0],c),a[1]=t(i[1],c),a[2]=t(i[2],c),a),o=(a,i,c)=>(!a&&(a=i),a[0]=t(i[0],c),a[1]=t(i[1],c),a[2]=t(i[2],c),a[3]=t(i[3],c),a);return[q(e,n,r,s,o),r,s,o]},[jo,Po,ci]=qt(Math.pow),hi=ci,li=[.4122214708,.2119034982,.0883024619,.5363325363,.6806995451,.2817188376,.0514459929,.1073969566,.6299787005],fi=(t,e)=>Pt(null,bs,hi(null,Pt(t,li,e),1/3)),Dn=(t,e)=>I(t||e,e[0],Math.hypot(e[1],e[2]),Cn(e[2],e[1])*Wr,z(e[3])),ui=Dt({mode:"oklch",channels:{c:{range:[0,.3225]}},order:["l","c","h","alpha"],from:{oklab:Dn,rgb:(t,e)=>Dn(null,fi(t,e))},toRgb:[(t,e)=>I(t||e,e[0],...xe(e[2]*P,e[1]),z(e[3])),Un]}),Tn=Dt({mode:"srgb",order:["r","g","b","alpha"],from:{abgr32:(t,e)=>Fn(t,e[0]),argb32:(t,e)=>Nt(t,e[0]),hcy:vn,hsi:Sn,hsl:Bn,hsv:me,rgb:lt},toRgb:jt}),di=(t,e)=>t===e?0:t==null?e==null?0:-1:e==null?t==null?0:1:typeof t.compare=="function"?t.compare(e):typeof e.compare=="function"?-e.compare(t):t<e?-1:t>e?1:0,gi=t=>typeof t=="function"?t:e=>e[t];function jn(t,e=di){const n=gi(t);return(r,s)=>e(n(r),n(s))}const mi=(t,e)=>e-t,$e=(t,e=1,n=!0)=>{const r=n?(i,c,h)=>{!i&&(i=c);for(let l=c.length;l-- >0;)i[l]=t(c[l],h[l]);return i}:(i,c,h)=>{!i&&(i=h);for(let l=c.length;l-- >0;)i[l]=t(c[l],h[l]);return i},s=n?(i,c,h)=>(!i&&(i=c),i[0]=t(c[0],h[0]),i[1]=t(c[1],h[1]),i):(i,c,h)=>(!i&&(i=h),i[0]=t(c[0],h[0]),i[1]=t(c[1],h[1]),i),o=n?(i,c,h)=>(!i&&(i=c),i[0]=t(c[0],h[0]),i[1]=t(c[1],h[1]),i[2]=t(c[2],h[2]),i):(i,c,h)=>(!i&&(i=h),i[0]=t(c[0],h[0]),i[1]=t(c[1],h[1]),i[2]=t(c[2],h[2]),i),a=n?(i,c,h)=>(!i&&(i=c),i[0]=t(c[0],h[0]),i[1]=t(c[1],h[1]),i[2]=t(c[2],h[2]),i[3]=t(c[3],h[3]),i):(i,c,h)=>(!i&&(i=h),i[0]=t(c[0],h[0]),i[1]=t(c[1],h[1]),i[2]=t(c[2],h[2]),i[3]=t(c[3],h[3]),i);return[q(e,r,s,o,a),s,o,a]},bi=(t,e)=>t+e,yi=(t,e)=>t*e,xi=(t,e)=>t-e,[pi,Ai]=$e(bi),Pn=pi,_i=Ai,wi=Object.freeze([0,0]),Fi=Object.freeze([0,0,0]),qn=Math.cos,Hn=Math.sin,Ln=q(1);Ln.add(2,(t,e,n=wi)=>_i(t||e,xe(e[1],e[0]),n)),Ln.add(3,(t,e,n=Fi)=>{const r=e[0],s=e[1],o=e[2],a=qn(s);return N(t||e,r*a*qn(o)+n[0],r*a*Hn(o)+n[1],r*Hn(s)+n[2])});const Ri=(t,e)=>{const n=[];for(let r of t)n.push(xe(r,e));return n},vi=t=>M(t.length>0,"no inputs given"),[Si]=qt(yi),Wn=Si,Bi=q(0,t=>{let e=0;for(let n=t.length;n-- >0;)e+=t[n];return e},t=>t[0]+t[1],t=>t[0]+t[1]+t[2],t=>t[0]+t[1]+t[2]+t[3]),Ci=(t,e)=>{vi(e),t=As(t||[],e[0]);for(let n=e.length;n-- >1;)Pn(t,t,e[n]);return Wn(t,t,1/e.length)},Me=t=>t.length>0?Bi(t)/t.length:0,[$i]=qt(xi),Mi=$i,Vn=(t,e)=>Mi(t,e,Me(e)),Ui=t=>Cn(t[1],t[0]),Oi=q(0,t=>{let e=0;for(let n=t.length;n-- >0;)e+=t[n]*t[n];return e},t=>t[0]*t[0]+t[1]*t[1],t=>t[0]*t[0]+t[1]*t[1]+t[2]*t[2],t=>t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3]),Ei=(t,e=!1,n=!1)=>{const r=~~n;return t.length>r?Oi(e?t:Vn([],t))/(t.length-r):0},Ue=(t,e=!1,n=!1)=>Math.sqrt(Ei(t,e,n)),Oe=t=>Ui(Ci([],Ri(t))),Ii=(t,e)=>{const n=Oe(e);!t&&(t=[]);for(let r=0,s=e.length;r<s;r++)t[r]=(e[r]-n+rn)%P;return Vn(null,t)},zi=(t,e)=>Ue(Ii([],t),!0,e);$e(Math.max);const ki=t=>{let e=-1/0;for(let n=t.length;n-- >0;)e=Math.max(e,t[n]);return e},Ee=t=>{if(!t.length)return 0;const e=t.length,n=e>>1;return t=[...t].sort((r,s)=>r-s),e&1?t[n]:(t[n-1]+t[n])*.5};$e(Math.min);const Gi=t=>{let e=1/0;for(let n=t.length;n-- >0;)e=Math.min(e,t[n]);return e},Ni=t=>{const[e,n]=ze(t);return{min:e,max:n,mean:Me(t),median:Ee(t),sd:Ue(t)}},Ie=(t,e)=>{const[n,r]=ze(t);return{min:n,max:r,mean:Me(t),median:Ee(t),sd:Ue(t),weighted:as(t,e)}},Di=t=>{const e=t.map(o=>o*P),n=U(Oe(e)/P),[r,s]=Ti(t,n);return{min:r,max:s,mean:n,median:ji(t,r,s),sd:zi(e)/P}},ze=t=>[Gi(t),ki(t)],Ti=(t,e)=>{const n=ze(t),[r,s]=n;return e<r||e>s?[t.reduce((o,a)=>{const i=U(e-a);return i<.5&&i>o[1]?[a,i]:o},[s,U(e-s)])[0],t.reduce((o,a)=>{const i=U(a-e);return i<.5&&i>o[1]?[a,i]:o},[r,U(r-e)])[0]]:n},ji=(t,e,n)=>{if(e<=n)return Ee(t);const r=t.length,s=r>>1,o=[...t].sort((c,h)=>c-h),a=o.findIndex(c=>c===e),i=o.slice(a).concat(o.slice(0,a));return r&1?i[s]:(i[s-1]+i[s])*.5},Pi=t=>typeof t=="function",qi=q(0,(t,e)=>{let n=0;for(let r=t.length;r-- >0;){const s=t[r]-e[r];n+=s*s}return n},(t,e)=>{const n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r},(t,e)=>{const n=t[0]-e[0],r=t[1]-e[1],s=t[2]-e[2];return n*n+r*r+s*s},(t,e)=>{const n=t[0]-e[0],r=t[1]-e[1],s=t[2]-e[2],o=t[3]-e[3];return n*n+r*r+s*s+o*o});class Hi{constructor(e){this.metric=e}to(e){return e*e}from(e){return Math.sqrt(e)}}const ke=new Hi(qi),Yn=(t,e,n=ke)=>{const r=Pi(n)?n:n.metric;let s=1/0,o=-1;for(let a=0,i=e.length;a<i;a++){const c=r(t,e[a]);c<s&&(s=c,o=a)}return o};q(0,(t,e)=>{for(let n=t.length;n-- >0;)t[n]=e;return t},(t,e)=>(t[0]=e,t[1]=e,t),(t,e)=>(t[0]=e,t[1]=e,t[2]=e,t),(t,e)=>(t[0]=e,t[1]=e,t[2]=e,t[3]=e,t));const Li=t=>Array(t).fill(0),Wi=t=>Array(t).fill(1),Vi=(t,e,n={})=>{let{dim:r=e[0].length,dist:s=ke,maxIter:o=32,strategy:a=Ki,exponent:i,initial:c,rnd:h}=n;const l=e.length,u=Array.isArray(c)?c:c?c(t,e,s,h):Yi(t,e,s,h,i);M(u.length>0,"missing initial centroids"),t=u.length;const f=new Uint32Array(l).fill(t);let g=!0;for(;g&&o-- >0&&(g=Xi(e,u,f,s),!!g);)for(let p=0;p<t;p++){const w=a(r);for(let $=0;$<l;$++)p===f[$]&&w.update(e[$]);const S=w.finish();S&&(u[p]=S)}return Ji(u,f)},Yi=(t,e,n=ke,r=ue,s=2)=>{const o=e.length;M(o>0,"missing samples"),t=Math.min(t,o);const a=[r.int()%o],i=[e[a[0]]],c=new Array(o).fill(0).map((l,u)=>u),h=n.metric;for(;a.length<t;){let l=0;const u=e.map(g=>{const p=n.from(h(g,i[Yn(g,i,n)]))**s;return l+=p,p});if(!l)break;let f;do f=ks(c,u,r)();while(a.includes(f));a.push(f),i.push(e[f])}return i},Xi=(t,e,n,r)=>{let s=!1;for(let o=t.length;o-- >0;){const a=Yn(t[o],e,r);a!==n[o]&&(n[o]=a,s=!0)}return s},Ji=(t,e)=>{const n=[];for(let r=0,s=e.length;r<s;r++){const o=e[r];(n[o]||(n[o]={id:o,centroid:t[o],items:[]})).items.push(r)}return n.filter(r=>!!r)},Ki=t=>{const e=Li(t);let n=0;return{update:r=>{Pn(e,e,r),n++},finish:()=>n?Wn(e,e,1/n):void 0}},Zi=(t,e)=>{const n=[];let r=0;for(let s of e)t(s,r)&&n.push(s),r++;return n},Xn=(t,e,n)=>{const r=n?.filter?Zi(n.filter,t):Array.isArray(t)?t:[...t];return r.length?Vi(Math.min(e,r.length),r,n).sort((s,o)=>o.items.length-s.items.length).map(s=>({color:[...s.centroid],area:s.items.length/r.length,ids:s.items})):[]},Ge=t=>typeof t?.[Symbol.iterator]=="function",Jn=(t,e)=>[t[0],t[1],e],Ne=Symbol(),Kn=()=>{},Ht=t=>bt(t,"xform")?t.xform():t,Qi=Rt(()=>"illegal arity"),De=t=>{throw new Qi(t)};class Lt{value;constructor(e){this.value=e}deref(){return this.value}}const ut=t=>t instanceof Lt,to=t=>t instanceof Lt?t:new Lt(t),pt=t=>t instanceof Lt?t.deref():t,eo=t=>t.length===2?[void 0,t[1]]:t.length===3?[t[1],t[2]]:De(t.length);function Wt(...t){const e=t[0],n=e[0],r=e[1],s=e[2];t=eo(t);const o=t[0]==null?n():t[0],a=t[1];return pt(r(bt(a,"$reduce")?a.$reduce(s,o):le(a)?no(s,o,a):ro(s,o,a)))}const no=(t,e,n)=>{for(let r=0,s=n.length;r<s;r++)if(e=t(e,n[r]),ut(e)){e=e.deref();break}return e},ro=(t,e,n)=>{for(let r of n)if(e=t(e,r),ut(e)){e=e.deref();break}return e},Te=(t,e)=>[t,vt,e],Vt=(t,e)=>{const n=e.length-1;return Ge(e[n])?e.length>1?Wt(t.apply(null,e.slice(0,n)),e[n]):Wt(t(),e[0]):void 0};function Zn(t){return t?[...t]:Te(()=>[],(e,n)=>(e.push(n),e))}function*so(t,e){const n=Ht(t)(Zn()),r=n[1],s=n[2];for(let o of e){const a=s([],o);if(ut(a)){yield*pt(r(a.deref()));return}a.length&&(yield*a)}yield*pt(r([]))}function*io(t,e){const n=Ht(t)([Kn,Kn,(r,s)=>s])[2];for(let r of e){let s=n(Ne,r);if(ut(s)){s=pt(s.deref()),s!==Ne&&(yield s);return}s!==Ne&&(yield s)}}function At(t,e){return Ge(e)?io(At(t),e):n=>{const r=n[2];return Jn(n,(s,o)=>r(s,t(o)))}}function Qn(t){return t?Wt(Qn(),t):Te(()=>-1/0,(e,n)=>Math.max(e,n))}const tr=t=>((t==null||!t[Symbol.iterator])&&fe(`value is not iterable: ${t}`),t),oo=t=>pn(t)?t:[...tr(t)],ao=t=>le(t)?t:[...tr(t)];function*co(...t){const e=t.length-1;if(e<0)return;const n=new Array(e+1).fill(0),r=t.map(ao),s=r.reduce((o,a)=>o*a.length,1);for(let o=0;o<s;o++){const a=[];for(let i=e;i>=0;i--){const c=r[i];let h=n[i];h===c.length&&(n[i]=h=0,i>0&&n[i-1]++),a[i]=c[h]}n[e]++,yield a}}function je(...t){return ho(je,Wt,t)}const ho=(t,e,n)=>{let r,s;switch(n.length){case 4:s=n[3],r=n[2];break;case 3:s=n[2];break;case 2:return At(o=>t(n[0],n[1],o));default:De(n.length)}return e(Ht(n[0])(n[1]),r,s)},[lo]=qt(an),fo=lo,er=(t,e,n)=>uo(F((n-t)/(e-t))),uo=t=>t*t*(3-2*t);function nr(...t){let[e,n,r,s,o,a,i,c,h,l]=t;switch(t.length){case 0:De(0);case 1:return e;case 2:return(...f)=>e(n(...f));case 3:return(...f)=>e(n(r(...f)));case 4:return(...f)=>e(n(r(s(...f))));case 5:return(...f)=>e(n(r(s(o(...f)))));case 6:return(...f)=>e(n(r(s(o(a(...f))))));case 7:return(...f)=>e(n(r(s(o(a(i(...f)))))));case 8:return(...f)=>e(n(r(s(o(a(i(c(...f))))))));case 9:return(...f)=>e(n(r(s(o(a(i(c(h(...f)))))))));case 10:default:const u=(...f)=>e(n(r(s(o(a(i(c(h(l(...f))))))))));return t.length===10?u:nr(u,...t.slice(10))}}function go(...t){return t=t.map(Ht),nr.apply(null,t)}function rr(...t){const e=Vt(rr,t);if(e!==void 0)return e;const[n=0,r=1]=t;return Te(()=>n,(s,o)=>s+r)}const mo=t=>t,bo=t=>({key:e=>e,group:Zn(),...t});function sr(...t){const e=Vt(sr,t);if(e!==void 0)return e;const n=bo(t[0]),[r,s,o]=n.group;return[()=>new Map,a=>{for(let i of a.keys())a.set(i,s(a.get(i)));return a},(a,i)=>{const c=n.key(i);return a.set(c,a.has(c)?o(a.get(c),i):o(r(),i))}]}function ir(...t){return Vt(ir,t)||sr({key:t[0]||mo,group:rr()})}function or(...t){const e=Vt(or,t);if(e!==void 0)return e;const[n,r,s]=ir(...t);let o=0;return[n,a=>{a=r(a);for(let i of a)a.set(i[0],i[1]/o);return a},(a,i)=>(o++,s(a,i))]}const yo=()=>t=>{const e=t[2];return Jn(t,(n,r)=>{if(r){for(let s of pt(r)||[])if(n=e(n,s),ut(n))break}return ut(r)?to(n):n})};function ar(t,e){return Ge(e)?so(ar(t),e):go(At(t),yo())}function*xo(t,e=1/0){for(;e-- >0;)yield t}const cr=(t,e=.2,n)=>{const r=oo(t),s=r.filter(u=>u[1]>=e),o=s.length/r.length,a=[...je(At(u=>an(u[0],1/12)%1),or(),s)].sort(jn(0)),i=[...ar(([u,f])=>(f*=50,f>=1?xo(u*P,f):null),a)];if(!i.length)return{hues:a,meanHue:0,temp:0,areaTemp:0,area:0};const c=Oe(i)/P,h=Ao(c,n),l=h*o;return{hues:a,meanHue:c,temp:h,areaTemp:l,area:o}},po=[.1,.6,.72,.92],Ao=(t,[e,n,r,s]=po)=>2*(t<2/3?er(n,e,t):er(r,s,t))-1,_o=(t,e)=>{let n=t.format!==at?t.as(at):t;e?.size&&(n=Ro(n,e.size));const r=n.as(tn),s=n.as(ss),o=Fo(n,e),a=o.map(h=>h.area),i=wo(o.map(h=>h.color),a,e?.minSat,e?.tempCoeffs),c=Ni(r.data);return{...i,img:n,imgGray:r,imgHsv:s,lumImg:c,temperature:cr(s,e?.minSat,e?.tempCoeffs),contrastImg:c.max-c.min}},wo=(t,e=Wi(t.length),n,r)=>{const s=t.map(f=>ys(f)),o=t.map(f=>Tn(f)),a=o.map(f=>ai(f)),i=o.map(f=>ui(f)),c=o.map(f=>Nn(f)),h=a.map(f=>f[0]),l=a.map(f=>f[1]),u=Ie(s,e);return{css:c,srgb:o,hsv:a,oklch:i,hue:Di(h),sat:Ie(l,e),chroma:Ie(i.map(f=>f[1]),e),lum:u,areas:e,contrast:u.max-u.min,colorContrast:ns(je(At(f=>Zs(...f)),Qn(),co(o,o)),1,21,0,1),temperature:cr(a,n,r)}},Fo=(t,{dominantFn:e=Xn,numColors:n=4,prec:r=.001}={})=>e(t,n).sort(jn("area",mi)).map(s=>(fo(null,s.color,r),s)),Ro=(t,e)=>{e=~~e;let n=t.width,r=t.height;return[n,r]=n>r?[e,~~Math.max(1,r/n*e)]:[~~Math.max(1,n/r*e),e],t.resize(n,r)};var vo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function So(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var n=function r(){var s=!1;try{s=this instanceof r}catch{}return s?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})}),n}var Pe={exports:{}};const hr=So(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));/**\n * [js-sha256]{@link https://github.com/emn178/js-sha256}\n *\n * @version 0.11.1\n * @author Chen, Yi-Cyuan [emn178@gmail.com]\n * @copyright Chen, Yi-Cyuan 2014-2025\n * @license MIT\n */var lr;function Bo(){return lr||(lr=1,(function(t){(function(){var e="input is invalid type",n=typeof window=="object",r=n?window:{};r.JS_SHA256_NO_WINDOW&&(n=!1);var s=!n&&typeof self=="object",o=!r.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node&&process.type!="renderer";o?r=vo:s&&(r=self);var a=!r.JS_SHA256_NO_COMMON_JS&&!0&&t.exports,i=!r.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",c="0123456789abcdef".split(""),h=[-2147483648,8388608,32768,128],l=[24,16,8,0],u=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],f=["hex","array","digest","arrayBuffer"],g=[];(r.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(d){return Object.prototype.toString.call(d)==="[object Array]"}),i&&(r.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(d){return typeof d=="object"&&d.buffer&&d.buffer.constructor===ArrayBuffer});var p=function(d,x){return function(A){return new C(x,!0).update(A)[d]()}},w=function(d){var x=p("hex",d);o&&(x=S(x,d)),x.create=function(){return new C(d)},x.update=function(_){return x.create().update(_)};for(var A=0;A<f.length;++A){var y=f[A];x[y]=p(y,d)}return x},S=function(d,x){var A=hr,y=hr.Buffer,_=x?"sha224":"sha256",b;y.from&&!r.JS_SHA256_NO_BUFFER_FROM?b=y.from:b=function(m){return new y(m)};var R=function(m){if(typeof m=="string")return A.createHash(_).update(m,"utf8").digest("hex");if(m==null)throw new Error(e);return m.constructor===ArrayBuffer&&(m=new Uint8Array(m)),Array.isArray(m)||ArrayBuffer.isView(m)||m.constructor===y?A.createHash(_).update(b(m)).digest("hex"):d(m)};return R},$=function(d,x){return function(A,y){return new J(A,x,!0).update(y)[d]()}},L=function(d){var x=$("hex",d);x.create=function(_){return new J(_,d)},x.update=function(_,b){return x.create(_).update(b)};for(var A=0;A<f.length;++A){var y=f[A];x[y]=$(y,d)}return x};function C(d,x){x?(g[0]=g[16]=g[1]=g[2]=g[3]=g[4]=g[5]=g[6]=g[7]=g[8]=g[9]=g[10]=g[11]=g[12]=g[13]=g[14]=g[15]=0,this.blocks=g):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],d?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=d}C.prototype.update=function(d){if(!this.finalized){var x,A=typeof d;if(A!=="string"){if(A==="object"){if(d===null)throw new Error(e);if(i&&d.constructor===ArrayBuffer)d=new Uint8Array(d);else if(!Array.isArray(d)&&(!i||!ArrayBuffer.isView(d)))throw new Error(e)}else throw new Error(e);x=!0}for(var y,_=0,b,R=d.length,m=this.blocks;_<R;){if(this.hashed&&(this.hashed=!1,m[0]=this.block,this.block=m[16]=m[1]=m[2]=m[3]=m[4]=m[5]=m[6]=m[7]=m[8]=m[9]=m[10]=m[11]=m[12]=m[13]=m[14]=m[15]=0),x)for(b=this.start;_<R&&b<64;++_)m[b>>>2]|=d[_]<<l[b++&3];else for(b=this.start;_<R&&b<64;++_)y=d.charCodeAt(_),y<128?m[b>>>2]|=y<<l[b++&3]:y<2048?(m[b>>>2]|=(192|y>>>6)<<l[b++&3],m[b>>>2]|=(128|y&63)<<l[b++&3]):y<55296||y>=57344?(m[b>>>2]|=(224|y>>>12)<<l[b++&3],m[b>>>2]|=(128|y>>>6&63)<<l[b++&3],m[b>>>2]|=(128|y&63)<<l[b++&3]):(y=65536+((y&1023)<<10|d.charCodeAt(++_)&1023),m[b>>>2]|=(240|y>>>18)<<l[b++&3],m[b>>>2]|=(128|y>>>12&63)<<l[b++&3],m[b>>>2]|=(128|y>>>6&63)<<l[b++&3],m[b>>>2]|=(128|y&63)<<l[b++&3]);this.lastByteIndex=b,this.bytes+=b-this.start,b>=64?(this.block=m[16],this.start=b-64,this.hash(),this.hashed=!0):this.start=b}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},C.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var d=this.blocks,x=this.lastByteIndex;d[16]=this.block,d[x>>>2]|=h[x&3],this.block=d[16],x>=56&&(this.hashed||this.hash(),d[0]=this.block,d[16]=d[1]=d[2]=d[3]=d[4]=d[5]=d[6]=d[7]=d[8]=d[9]=d[10]=d[11]=d[12]=d[13]=d[14]=d[15]=0),d[14]=this.hBytes<<3|this.bytes>>>29,d[15]=this.bytes<<3,this.hash()}},C.prototype.hash=function(){var d=this.h0,x=this.h1,A=this.h2,y=this.h3,_=this.h4,b=this.h5,R=this.h6,m=this.h7,v=this.blocks,O,D,T,et,B,nt,rt,_t,qe,He,Yt;for(O=16;O<64;++O)B=v[O-15],D=(B>>>7|B<<25)^(B>>>18|B<<14)^B>>>3,B=v[O-2],T=(B>>>17|B<<15)^(B>>>19|B<<13)^B>>>10,v[O]=v[O-16]+D+v[O-7]+T<<0;for(Yt=x&A,O=0;O<64;O+=4)this.first?(this.is224?(_t=300032,B=v[0]-1413257819,m=B-150054599<<0,y=B+24177077<<0):(_t=704751109,B=v[0]-210244248,m=B-1521486534<<0,y=B+143694565<<0),this.first=!1):(D=(d>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),T=(_>>>6|_<<26)^(_>>>11|_<<21)^(_>>>25|_<<7),_t=d&x,et=_t^d&A^Yt,rt=_&b^~_&R,B=m+T+rt+u[O]+v[O],nt=D+et,m=y+B<<0,y=B+nt<<0),D=(y>>>2|y<<30)^(y>>>13|y<<19)^(y>>>22|y<<10),T=(m>>>6|m<<26)^(m>>>11|m<<21)^(m>>>25|m<<7),qe=y&d,et=qe^y&x^_t,rt=m&_^~m&b,B=R+T+rt+u[O+1]+v[O+1],nt=D+et,R=A+B<<0,A=B+nt<<0,D=(A>>>2|A<<30)^(A>>>13|A<<19)^(A>>>22|A<<10),T=(R>>>6|R<<26)^(R>>>11|R<<21)^(R>>>25|R<<7),He=A&y,et=He^A&d^qe,rt=R&m^~R&_,B=b+T+rt+u[O+2]+v[O+2],nt=D+et,b=x+B<<0,x=B+nt<<0,D=(x>>>2|x<<30)^(x>>>13|x<<19)^(x>>>22|x<<10),T=(b>>>6|b<<26)^(b>>>11|b<<21)^(b>>>25|b<<7),Yt=x&A,et=Yt^x&y^He,rt=b&R^~b&m,B=_+T+rt+u[O+3]+v[O+3],nt=D+et,_=d+B<<0,d=B+nt<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+d<<0,this.h1=this.h1+x<<0,this.h2=this.h2+A<<0,this.h3=this.h3+y<<0,this.h4=this.h4+_<<0,this.h5=this.h5+b<<0,this.h6=this.h6+R<<0,this.h7=this.h7+m<<0},C.prototype.hex=function(){this.finalize();var d=this.h0,x=this.h1,A=this.h2,y=this.h3,_=this.h4,b=this.h5,R=this.h6,m=this.h7,v=c[d>>>28&15]+c[d>>>24&15]+c[d>>>20&15]+c[d>>>16&15]+c[d>>>12&15]+c[d>>>8&15]+c[d>>>4&15]+c[d&15]+c[x>>>28&15]+c[x>>>24&15]+c[x>>>20&15]+c[x>>>16&15]+c[x>>>12&15]+c[x>>>8&15]+c[x>>>4&15]+c[x&15]+c[A>>>28&15]+c[A>>>24&15]+c[A>>>20&15]+c[A>>>16&15]+c[A>>>12&15]+c[A>>>8&15]+c[A>>>4&15]+c[A&15]+c[y>>>28&15]+c[y>>>24&15]+c[y>>>20&15]+c[y>>>16&15]+c[y>>>12&15]+c[y>>>8&15]+c[y>>>4&15]+c[y&15]+c[_>>>28&15]+c[_>>>24&15]+c[_>>>20&15]+c[_>>>16&15]+c[_>>>12&15]+c[_>>>8&15]+c[_>>>4&15]+c[_&15]+c[b>>>28&15]+c[b>>>24&15]+c[b>>>20&15]+c[b>>>16&15]+c[b>>>12&15]+c[b>>>8&15]+c[b>>>4&15]+c[b&15]+c[R>>>28&15]+c[R>>>24&15]+c[R>>>20&15]+c[R>>>16&15]+c[R>>>12&15]+c[R>>>8&15]+c[R>>>4&15]+c[R&15];return this.is224||(v+=c[m>>>28&15]+c[m>>>24&15]+c[m>>>20&15]+c[m>>>16&15]+c[m>>>12&15]+c[m>>>8&15]+c[m>>>4&15]+c[m&15]),v},C.prototype.toString=C.prototype.hex,C.prototype.digest=function(){this.finalize();var d=this.h0,x=this.h1,A=this.h2,y=this.h3,_=this.h4,b=this.h5,R=this.h6,m=this.h7,v=[d>>>24&255,d>>>16&255,d>>>8&255,d&255,x>>>24&255,x>>>16&255,x>>>8&255,x&255,A>>>24&255,A>>>16&255,A>>>8&255,A&255,y>>>24&255,y>>>16&255,y>>>8&255,y&255,_>>>24&255,_>>>16&255,_>>>8&255,_&255,b>>>24&255,b>>>16&255,b>>>8&255,b&255,R>>>24&255,R>>>16&255,R>>>8&255,R&255];return this.is224||v.push(m>>>24&255,m>>>16&255,m>>>8&255,m&255),v},C.prototype.array=C.prototype.digest,C.prototype.arrayBuffer=function(){this.finalize();var d=new ArrayBuffer(this.is224?28:32),x=new DataView(d);return x.setUint32(0,this.h0),x.setUint32(4,this.h1),x.setUint32(8,this.h2),x.setUint32(12,this.h3),x.setUint32(16,this.h4),x.setUint32(20,this.h5),x.setUint32(24,this.h6),this.is224||x.setUint32(28,this.h7),d};function J(d,x,A){var y,_=typeof d;if(_==="string"){var b=[],R=d.length,m=0,v;for(y=0;y<R;++y)v=d.charCodeAt(y),v<128?b[m++]=v:v<2048?(b[m++]=192|v>>>6,b[m++]=128|v&63):v<55296||v>=57344?(b[m++]=224|v>>>12,b[m++]=128|v>>>6&63,b[m++]=128|v&63):(v=65536+((v&1023)<<10|d.charCodeAt(++y)&1023),b[m++]=240|v>>>18,b[m++]=128|v>>>12&63,b[m++]=128|v>>>6&63,b[m++]=128|v&63);d=b}else if(_==="object"){if(d===null)throw new Error(e);if(i&&d.constructor===ArrayBuffer)d=new Uint8Array(d);else if(!Array.isArray(d)&&(!i||!ArrayBuffer.isView(d)))throw new Error(e)}else throw new Error(e);d.length>64&&(d=new C(x,!0).update(d).array());var O=[],D=[];for(y=0;y<64;++y){var T=d[y]||0;O[y]=92^T,D[y]=54^T}C.call(this,x,A),this.update(D),this.oKeyPad=O,this.inner=!0,this.sharedMemory=A}J.prototype=new C,J.prototype.finalize=function(){if(C.prototype.finalize.call(this),this.inner){this.inner=!1;var d=this.array();C.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(d),C.prototype.finalize.call(this)}};var K=w();K.sha256=K,K.sha224=w(!0),K.sha256.hmac=L(),K.sha224.hmac=L(!0),a?t.exports=K:(r.sha256=K.sha256,r.sha224=K.sha224)})()})(Pe)),Pe.exports}Bo();/**\n * Options for extracting colors / evaluating lightness from an image.\n *\n * @typedef {Object} ImageAnalysisResult\n * @property {boolean} isDark - Whether the image is considered dark overall.\n * @property {boolean} isTransparent - Whether the image has any transparency.\n * @property {{ any: boolean, left: boolean, right: boolean, top: boolean, bottom: boolean }} transparencyInfo - More detailed transparency info.\n * @property {Array<{ color: string, area: number, isDark: boolean }>} dominantColors - Dominant colors extracted from the image.\n * @property {Array} dominantColors.<index>.color - The color value.\n * @property {Array} dominantColors.<index>.area - The area occupied by this color (0 - 1).\n * @property {Array} dominantColors.<index>.isDark - Whether this color is considered dark.\n *\n * @preserve\n *//**\n * Options for extracting colors / evaluating lightness from an image.\n *\n * @typedef {Object} ImageAnalysisSettings\n * @property {number} [numColors=2] - Number of dominant colors to return.\n * @property {number} [lightnessThreshold=0.5] - Threshold (0.0 - 1.0) used to decide if a color is considered "light".\n * @property {number} [yFrom=0.0] - Minimum Y (luminance) value (0.0 - 1.0) to include when evaluating lightness.\n * @property {number} [yTo=1.0] - Maximum Y (luminance) value (0.0 - 1.0) to include when evaluating lightness.\n * @property {number} [maxSize=320] - Maximum width/height to scale down the image to before analysis, for performance.\n * @property {number} [alphaThreshold=30] - Threhold (0-255) below which a pixel is considered "transparent" for the purposes of analysis.\n *\n * @preserve\n */const Co={numColors:3,lightnessThreshold:.5,yFrom:0,yTo:1,maxSize:320,alphaThreshold:30};/**\n * Check image transparency by analyzing pixel alpha values.\n *\n * @param {Uint8ClampedArray} imageData - The image data array containing RGBA values.\n * @param {number} w - The width of the image.\n * @param {number} h - The height of the image.\n * @param {ImageAnalysisSettings} [settings] - Optional settings to customize the transparency check.\n *\n * @return {{ any: boolean, left: boolean, right: boolean, top: boolean, bottom: boolean }} An object indicating transparency on different sides of the image.\n *\n * @preserve\n */const $o=(t,e,n,r={})=>{const{alphaThreshold:s}={...Co,...r},o={any:!0,left:!0,right:!0,top:!0,bottom:!0};let a={any:0,left:0,right:0,top:0,bottom:0};const i=Math.floor(.15*e),c=Math.floor((n>100?.05:.5)*n),h=Math.floor(e*n*.001);if(e>0&&n>0){for(let l=0;l<e;l++){const u=(0*e+l)*4+3;if(t[u]>s&&(a.top++,a.top>=i)){o.top=!1;break}}for(let l=0;l<e;l++){const u=((n-1)*e+l)*4+3;if(t[u]>s&&(a.bottom++,a.bottom>=i)){o.bottom=!1;break}}for(let l=0;l<n;l++){const u=(l*e+0)*4+3;if(t[u]>s&&(a.left++,a.left>=c)){o.left=!1;break}}for(let l=0;l<n;l++){const u=(l*e+(e-1))*4+3;if(t[u]>s&&(a.right++,a.right>=c)){o.right=!1;break}}if(!o.top&&!o.bottom&&!o.left&&!o.right){for(let l=3;l<t.length;l+=4)if(t[l]>s&&(a.any++,a.any>=h)){o.any=!1;break}}else o.any=!0}return o};/**\n * Determine if a color is considered "dark" based on its RGB values and a lightness threshold.\n *\n * @param {number} r - Red component (0-255).\n * @param {number} g - Green component (0-255).\n * @param {number} b - Blue component (0-255).\n * @param {number} [threshold=0.5] - Lightness threshold (0.0 - 1.0) below which the color is considered dark.\n *\n * @returns {boolean} True if the color is dark, false otherwise.\n *\n * @example\n * isColorDark(0, 0, 0); // true (black)\n * isColorDark(255, 255, 255); // false (white)\n * isColorDark(100, 100, 100, 0.4); // false (gray with higher threshold)\n *\n * @preserve\n */const Mo=(t,e,n,r=.5)=>(.299*t+.587*e+.114*n)/255<r;/**\n * Core analysis logic shared by both main thread and worker.\n *\n * @param {Object} options - Configuration options\n * @prop {Float32Array} buffer - Float32Array RGBA buffer (from floatBufferFromCanvas)\n * @prop {Uint8ClampedArray} imageData - Uint8ClampedArray (from getImageData)\n * @prop {number} width - Image width\n * @prop {number} height - Image height\n * @prop {ImageAnalysisSettings} settings - Analysis settings\n * @prop {boolean} skipTransparencyCheck - Boolean to skip transparency check\n *\n * @returns {ImageAnalysisResult}\n *\n * @preserve\n */const Uo=({buffer:t,imageData:e,width:n,height:r,settings:s,skipTransparencyCheck:o=!1})=>{const{numColors:a,lightnessThreshold:i}=s,c=_o(t,{numColors:a,dominantFn:(g,p)=>Xn(g,p,{filter:w=>Tn(w).alpha>0}),prec:.01}),{lumImg:h,srgb:l,areas:u}=c;let f=!1;return!o&&e&&(f=$o(e,n,r,s)),{isDark:h.mean<i,isTransparent:o?!1:f?.any,transparencyInfo:o?null:f,dominantColors:l.map(({r:g,g:p,b:w},S)=>({color:Nn([g,p,w]),area:u?.[S],isDark:Mo(g*255,p*255,w*255,i)}))}};self.onmessage=async t=>{const{imageBitmap:e,settings:n}=t.data;try{const r=await Oo(e,n);self.postMessage({success:!0,data:r})}catch(r){self.postMessage({success:!1,error:r.message,stack:r.stack})}};async function Oo(t,e){const r={...{numColors:3,lightnessThreshold:.5,yFrom:0,yTo:1,maxSize:320,alphaThreshold:30},...e},{yFrom:s,yTo:o,maxSize:a}=r,i=t.width,c=t.height;if(!i||!c)return!1;let h=1;(i>a||c>a)&&(h=Math.min(a/i,a/c));const l=Math.floor(i*h),u=Math.floor(c*h),f=0,g=Math.floor(s*c),p=Math.max(1,i),w=Math.max(1,Math.ceil((o-s)*c)),S=Math.max(1,l),$=Math.max(1,Math.ceil((o-s)*u)),L=new OffscreenCanvas(S,$);L.getContext("2d").drawImage(t,f,g,p,w,0,0,S,$);const J=ts(L,at),d=new OffscreenCanvas(l,u).getContext("2d");d.drawImage(t,0,0,i,c,0,0,l,u);const x=d.getImageData(0,0,l,u).data;return Uo({buffer:J,imageData:x,width:l,height:u,settings:r})}})();\n';
1
+ const workerInline = '(function(){"use strict";var w=(t=>(t[t.ALPHA=0]="ALPHA",t[t.BLUE=1]="BLUE",t[t.GREEN=2]="GREEN",t[t.RED=3]="RED",t))(w||{});const $e=["rotateCW","rotate180","rotateCCW"],Pn=(t,e=t,n,r={})=>{const s=document.createElement("canvas");return Ln(s,t,e,r.dpr),r.pixelated&&(s.style.imageRendering="pixelated"),{canvas:s,ctx:s.getContext("2d",r.ctx)}},jn=(t,e=t,n,r)=>Pn(t,e,n,{dpr:1,...r}),Ln=(t,e,n,r=window.devicePixelRatio||1)=>(r!==1&&(t.style.width=`${e}px`,t.style.height=`${n}px`),t.width=e*r,t.height=n*r,r),q=t=>typeof t=="number";function Hn(t,e,n,r){let s,i;if(q(t)){const c=jn(t,e,n,r);s=c.canvas,i=c.ctx}else s=t,i=s.getContext("2d");const a=i.getImageData(0,0,s.width,s.height),o=new Uint32Array(a.data.buffer);return{canvas:s,ctx:i,img:a,data:o}}const rt=(t,e,n)=>{n.configurable=!1},st=(t,e={})=>{const n=Reflect.ownKeys(t),r=Reflect.ownKeys(e),s=Symbol("isa");function i(a){for(let o of n){const c=Object.getOwnPropertyDescriptor(a.prototype,o);(!c||c.configurable)&&Object.defineProperty(a.prototype,o,{value:t[o],writable:!0})}return Object.defineProperty(a.prototype,s,{value:!0}),a}for(let a of r)Object.defineProperty(i,a,{value:e[a],enumerable:e.propertyIsEnumerable(a)});return Object.defineProperty(i,Symbol.hasInstance,{value:a=>!!a[s]}),i};st({order(){return[0]},includes(t){return t>=0&&t<this.size[0]},indexAt(t){return this.includes(t)?this.indexAtUnsafe(t):-1},indexAtUnsafe(t){return this.offset+(t|0)*this.stride[0]},getAt(t){return this.includes(t)?this.data[this.indexAtUnsafe(t)]:0},getAtUnsafe(t){return this.data[this.indexAtUnsafe(t)]},setAt(t,e){return this.includes(t)?(this.data[this.indexAtUnsafe(t)]=e,!0):!1},setAtUnsafe(t,e){return this.data[this.indexAtUnsafe(t)]=e,!0}});const Ce=st({order(){return Math.abs(this.stride[1])>Math.abs(this.stride[0])?[1,0]:[0,1]},includes(t,e){const n=this.size;return t>=0&&t<n[0]&&e>=0&&e<n[1]},indexAt(t,e){return this.includes(t,e)?this.indexAtUnsafe(t,e):-1},indexAtUnsafe(t,e){return this.offset+(t|0)*this.stride[0]+(e|0)*this.stride[1]},getAt(t,e){return this.includes(t,e)?this.data[this.indexAtUnsafe(t,e)]:0},getAtUnsafe(t,e){return this.data[this.indexAtUnsafe(t,e)]},setAt(t,e,n){return this.includes(t,e)?(this.data[this.indexAtUnsafe(t,e)]=n,!0):!1},setAtUnsafe(t,e,n){return this.data[this.indexAtUnsafe(t,e)]=n,!0}});st({order(){return ve(this.stride)},includes(t,e,n){const r=this.size;return t>=0&&t<r[0]&&e>=0&&e<r[1]&&n>=0&&n<r[2]},indexAt(t,e,n){return this.includes(t,e,n)?this.indexAtUnsafe(t,e,n):-1},indexAtUnsafe(t,e,n){const r=this.stride;return this.offset+(t|0)*r[0]+(e|0)*r[1]+(n|0)*r[2]},getAt(t,e,n){return this.includes(t,e,n)?this.data[this.indexAtUnsafe(t,e,n)]:0},getAtUnsafe(t,e,n){return this.data[this.indexAtUnsafe(t,e,n)]},setAt(t,e,n,r){return this.includes(t,e,n)?(this.data[this.indexAtUnsafe(t,e,n)]=r,!0):!1},setAtUnsafe(t,e,n,r){return this.data[this.indexAtUnsafe(t,e,n)]=r,!0}}),st({order(){return ve(this.stride)},includes(t,e,n,r){const s=this.size;return t>=0&&t<s[0]&&e>=0&&e<s[1]&&n>=0&&n<s[2]&&r>=0&&r<s[3]},indexAt(t,e,n,r){return this.includes(t,e,n,r)?this.indexAtUnsafe(t,e,n,r):-1},indexAtUnsafe(t,e,n,r){const s=this.stride;return this.offset+(t|0)*s[0]+(e|0)*s[1]+(n|0)*s[2]+(r|0)*s[3]},getAt(t,e,n,r){return this.includes(t,e,n,r)?this.data[this.indexAtUnsafe(t,e,n,r)]:0},getAtUnsafe(t,e,n,r){return this.data[this.indexAtUnsafe(t,e,n,r)]},setAt(t,e,n,r,s){return this.includes(t,e,n,r)?(this.data[this.indexAtUnsafe(t,e,n,r)]=s,!0):!1},setAtUnsafe(t,e,n,r,s){return this.data[this.indexAtUnsafe(t,e,n,r)]=s,!0}});const ve=t=>[...t].map((e,n)=>[e,n]).sort((e,n)=>Math.abs(n[0])-Math.abs(e[0])).map(e=>e[1]),P=t=>typeof t=="string",ot=(t,e=n=>n!==void 0?": "+n:"")=>class extends Error{origMessage;constructor(n){super(t(n)+e(n)),this.origMessage=n!==void 0?String(n):""}},Wn={};var Se={};const Yn=ot(()=>"Assertion failed"),_=(typeof process<"u"&&Se!==void 0?Se.UMBRELLA_ASSERTS:!Wn)?(t,e)=>{if(typeof t=="function"&&!t()||!t)throw new Yn(typeof e=="function"?e():e)}:()=>{},B=(t,e,n)=>t<e?e:t>n?n:t,y=t=>t<0?0:t>1?1:t,Be=(t,e,n,r,s)=>(t[0]=e,t[1]=n,t[2]=r,t[3]=s,t),Vn=(t,e)=>{const n=e[3];return Be(e,e[0]*n,e[1]*n,e[2]*n,n)},Xn=t=>{const e=(t>>>24)/255;return t&4278190080|(t>>>16&255)*e<<16|(t>>>8&255)*e<<8|(t&255)*e},Kn=(t,e)=>{const n=e[3];return n>0?Be(e,e[0]/n,e[1]/n,e[2]/n,n):e},Zn=t=>{const e=(t>>>24)/255;return e>0?(t&4278190080|Math.min(255,(t>>>16&255)/e)<<16|Math.min(255,(t>>>8&255)/e)<<8|Math.min(255,(t&255)/e))>>>0:t},Jn=t=>{const e=t[3];return t[0]<=e&&t[1]<=e||t[2]<=e},Qn=t=>{const e=t>>>24;return(t>>>16&255)<=e&&(t>>>8&255)<=e&&(t&255)<=e},ke=(t,e,n,r=1)=>_(t.length>=e*n*r,"pixel buffer too small"),Ge=(t,e,n)=>t?(Mt(t,e,n),t):new ImageData(e,n),Mt=(t,e,n)=>_(t.width===e&&t.height===n,"imagedata has wrong dimensions"),O=(t,e)=>{const n=t.channels[e];return _(n!=null,`invalid channel ID: ${e}`),n},tr=t=>_(!!t.alpha,"missing alpha channel"),it=t=>t,It=t=>((t>>>16&255)*29+(t>>>8&255)*150+(t&255)*76)/255,at=(t,e,n,r,s,i,a=0,o=0)=>(t|=0,e|=0,n|=0,r|=0,t<0&&(n+=t,a-=t,t=0),e<0&&(r+=e,o-=e,e=0),[t,e,B(n,0,s-t),B(r,0,i-e),a,o]),ct=(t,e,n={})=>{const r=t.width,s=e.width;let i,a,o,c,l,h;return[i,a,l,h]=at(n.sx||0,n.sy||0,n.w||r,n.h||t.height,r,t.height),[o,c,l,h,i,a]=at(n.dx||0,n.dy||0,l,h,s,e.height,i,a),{sx:i,sy:a,dx:o,dy:c,rw:l,rh:h}},er=(t,e,n)=>{for(let r=t.length;r-- >0;)t[r]=n(t[r],e)},nr=(t,e,n,r)=>{for(let s=t.length;s-- >0;)t[s]=r(t[s],n(e[s]))},rr=(t,e,n,r,s)=>{const i=~s;for(let a=t.length;a-- >0;)t[a]=t[a]&i|n(r(e[a]))&s},Me=(t,e,n)=>{const r=e.fromABGR,s=e.toABGR;for(let i=t.length;i-- >0;)t[i]=r(n(s(t[i])))},Ie=(t,e,n={})=>(e instanceof HTMLCanvasElement||e instanceof OffscreenCanvas?e.getContext("2d"):e).putImageData(t.toImageData(n.data),n.x||0,n.y||0),lt=t=>{const e=t.channels,n=e.reduce((a,o)=>(a[o]=3-o<<3,a),{}),r={...t,__float:!0,size:e.length,shift:n,range:[0,1],normalized:y,fromNormalized:it};if(t.convert)return Object.assign(r,t.convert),r;const s=(a,o)=>(y(a[o])*255+.5|0)<<n[e[o]],i=(a,o)=>(a>>>n[e[o]]&255)/255;switch(e.length){case 1:t.gray?or(r):sr(r,i,s);break;case 2:t.gray?ar(r,i):ir(r,i,s);break;case 3:cr(r,i,s);break;case 4:lr(r,i,s);break}return r},sr=(t,e,n)=>{t.toABGR=r=>{let s=t.alpha?0:4278190080;return s|=n(r,0),s>>>0},t.fromABGR=(r,s=[])=>(s[0]=e(r,0),s)},or=t=>{t.toABGR=e=>((y(e[0])*255+.5|0)*65793|4278190080)>>>0,t.fromABGR=(e,n=[])=>(n[0]=It(e)/255,n)},ir=(t,e,n)=>{t.toABGR=r=>{let s=t.alpha?0:4278190080;return s|=n(r,0),s|=n(r,1),s>>>0},t.fromABGR=(r,s=[])=>(s[0]=e(r,0),s[1]=e(r,1),s)},ar=(t,e)=>{const n=~~(t.channels[0]===w.ALPHA),r=n^1;t.toABGR=s=>{let i=(y(s[n])*255+.5|0)*65793;return i|=(s[r]*255+.5|0)<<24,i>>>0},t.fromABGR=(s,i=[])=>(i[n]=It(s)/255,i[r]=e(s,r),i)},cr=(t,e,n)=>{t.toABGR=r=>{let s=t.alpha?0:4278190080;return s|=n(r,0),s|=n(r,1),s|=n(r,2),s>>>0},t.fromABGR=(r,s=[])=>(s[0]=e(r,0),s[1]=e(r,1),s[2]=e(r,2),s)},lr=(t,e,n)=>{t.toABGR=r=>{let s=t.alpha?0:4278190080;return s|=n(r,0),s|=n(r,1),s|=n(r,2),s|=n(r,3),s>>>0},t.fromABGR=(r,s=[])=>(s[0]=e(r,0),s[1]=e(r,1),s[2]=e(r,2),s[3]=e(r,3),s)},Ue=lt({gray:!0,channels:[w.RED]}),hr={5120:"i8",5121:"u8",5122:"i16",5123:"u16",5124:"i32",5125:"u32",5126:"f32"},fr={f32:Float32Array,f64:Float64Array},ur={i8:Int8Array,i16:Int16Array,i32:Int32Array},dr={u8:Uint8Array,u8c:Uint8ClampedArray,u16:Uint16Array,u32:Uint32Array},gr={i64:BigInt64Array,u64:BigUint64Array},mr={...fr,...ur,...dr},yr=t=>{const e=hr[t];return e!==void 0?e:t};function ht(t,...e){const n=gr[t];return new(n||mr[yr(t)])(...e)}const br=t=>t>16?"u32":t>8?"u16":"u8",Ut=(t,e)=>e>0?`(${t} << ${e})`:e<0?`(${t} >>> ${-e})`:`${t}`,xt=(t,e)=>Ut(t,-e),xe=t=>`0x${t.toString(16)}`,Ar=t=>{const e=8-t,n=(1<<t)-1;return new Function("luma",`return (x) => ${xt("luma(x)",e)} & ${n};`)(It)},_r=t=>{let e;if(t!==8){const n=(1<<t)-1,r=255/n;e=`(((x & ${n}) * ${r}) | 0)`}else e="x";return new Function("x",`return 0xff000000 | (${e} * 0x010101);`)},pr=t=>new Function("x","return ("+t.map(e=>{const n=e.abgrShift+(8-e.size);return`(${xt("x",n)} & ${xe(e.maskA)})`}).join(" | ")+") >>> 0;"),wr=(t,e)=>{const n=t.map(s=>{if(s.size!==8){const i=s.mask0,a=255/i,o=xt("x",s.shift);return Ut(`((${o} & ${i}) * ${a})`,24-s.lane*8)}else return Ut(`(x & ${xe(s.maskA)})`,s.abgrShift)}).join(" | "),r=e?"":"0xff000000 | ";return new Function("x",`return (${r}${n}) >>> 0;`)},Rr=(t,e,n)=>{const r=1<<t.size,s=r-1,i=s<<n>>>0,a=~i>>>0,o=t.lane!=null?t.lane:e,c=h=>h>>>n&s,l=(h,u)=>h&a|(u&s)<<n;return{size:t.size,num:r,abgrShift:24-o*8-n,lane:o,shift:n,mask0:s,maskA:i,int:c,setInt:l,float:h=>c(h)/s,setFloat:(h,u)=>l(h,y(u)*s)}},ze=t=>{_(t.channels.length>0,"no channel specs given");const e=t.channels.reduce(([n,r],s,i)=>(r-=s.size,n.push(Rr(s,i,r)),[n,r]),[[],t.size])[0];return{__packed:!0,type:t.type,size:t.size,alpha:t.alpha||0,channels:e,fromABGR:t.fromABGR||pr(e),toABGR:t.toABGR||wr(e,!!t.alpha)}},zt=ze({type:"u32",size:32,alpha:8,channels:[{size:8,lane:w.ALPHA},{size:8,lane:w.BLUE},{size:8,lane:w.GREEN},{size:8,lane:w.RED}],fromABGR:it,toABGR:it}),Oe=Math.PI,k=Oe*2,$r=1/k;let I=1e-6;const Ee=(t,e,n,r,s,i)=>{const a=1-s,o=1-i;return t*a*o+e*s*o+n*a*i+r*s*i},X=(t,e,n,r,s)=>{r*=.5;const i=-.5*t+1.5*e-1.5*n+r,a=t-2.5*e+2*n-r,o=-.5*t+.5*n,c=e,l=s*s;return s*l*i+l*a+s*o+c},Fe=(t,e,n,r,s,i,a,o,c,l,h,u,f,d,g,m,b,A)=>X(X(t,e,n,r,b),X(s,i,a,o,b),X(c,l,h,u,b),X(f,d,g,m,b),A),ft=(t,e)=>t-e*Math.floor(t/e),p=t=>t-Math.floor(t),De=(t,e=1)=>Math.round(t/e)*e;function Ne(t,e="linear",n="clamp"){const r=!!t.format.__float,s=t.format.channels.length===1?"1":"",i=`${e[0]}${n[0]}${s}`,a=(r?{nc1:ut,nw1:dt,nr1:gt,nc:ut,nw:dt,nr:gt,lc1:o=>Ot(F(o)),lw1:o=>Ot(D(o)),lr1:o=>Ot(N(o)),lc:o=>Ft(o,ut(o)),lw:o=>Ft(o,dt(o)),lr:o=>Ft(o,gt(o)),cc1:o=>Nt(F(o)),cw1:o=>Nt(D(o)),cr1:o=>Nt(N(o)),cc:o=>qt(o,ut(o)),cw:o=>qt(o,dt(o)),cr:o=>qt(o,gt(o))}:{nc1:F,nw1:D,nr1:N,nc:F,nw:D,nr:N,lc1:o=>mt(F(o)),lw1:o=>mt(D(o)),lr1:o=>mt(N(o)),lc:o=>Et(o,F(o)),lw:o=>Et(o,D(o)),lr:o=>Et(o,N(o)),cc1:o=>Dt(o,F(o)),cw1:o=>Dt(o,D(o)),cr1:o=>Dt(o,N(o)),cc:o=>Tt(o,F(o)),cw:o=>Tt(o,D(o)),cr:o=>Tt(o,N(o))})[i];return _(!!a,`missing impl for ${i}`),a(t)}const F=({data:t,width:e,height:n})=>(r,s)=>r>=0&&r<e&&s>=0&&s<n?t[(s|0)*e+(r|0)]:0,D=({data:t,width:e,height:n})=>(r,s)=>t[ft(s|0,n)*e+ft(r|0,e)],N=({data:t,width:e,height:n})=>{const r=e-1,s=n-1;return(i,a)=>t[B(a|0,0,s)*e+B(i|0,0,r)]},ut=({data:t,width:e,height:n,stride:[r,s]})=>(i,a)=>{let o;return i>=0&&i<e&&a>=0&&a<n?(o=(a|0)*s+(i|0)*r,t.slice(o,o+r)):[0]},dt=({data:t,width:e,height:n,stride:[r,s]})=>(i,a)=>{let o=ft(a|0,n)*s+ft(i|0,e)*r;return t.slice(o,o+r)},gt=({data:t,width:e,height:n,stride:[r,s]})=>{const i=e-1,a=n-1;return(o,c)=>{let l=B(c|0,0,a)*s+B(o|0,0,i)*r;return t.slice(l,l+r)}},K=(t,e,n,r,s=4)=>Ee(t[r],t[r+s],t[r+2*s],t[r+3*s],e,n),mt=t=>(e,n)=>(e-=.5,n-=.5,Ee(t(e,n),t(e+1,n),t(e,n+1),t(e+1,n+1),p(e),p(n))),Ot=t=>(t=mt(t),(e,n)=>[t(e,n)]),Et=(t,e)=>{const{fromABGR:n,toABGR:r}=t.format,s=new Uint32Array(4),i=new Uint8Array(s.buffer);return(a,o)=>{a-=.5,o-=.5,s[0]=r(e(a,o)),s[1]=r(e(a+1,o)),s[2]=r(e(a,o+1)),s[3]=r(e(a+1,o+1));const c=p(a),l=p(o);return n(K(i,c,l,0)|K(i,c,l,1)<<8|K(i,c,l,2)<<16|K(i,c,l,3)<<24)>>>0}},Ft=({stride:[t]},e)=>{const n=new Float32Array(t*4);return(r,s)=>{r-=.5,s-=.5,n.set(e(r,s),0),n.set(e(r+1,s),t),n.set(e(r,s+1),t*2),n.set(e(r+1,s+1),t*3);const i=p(r),a=p(s);let o=[];for(let c=0;c<t;c++)o.push(K(n,i,a,c,t));return o}},Te=t=>(e,n)=>{e-=.5,n-=.5;const r=e-1,s=e+1,i=e+2,a=n-1,o=n+1,c=n+2;return Fe(t(r,a),t(e,a),t(s,a),t(i,a),t(r,n),t(e,n),t(s,n),t(i,n),t(r,o),t(e,o),t(s,o),t(i,o),t(r,c),t(e,c),t(s,c),t(i,c),p(e),p(n))},Dt=(t,e)=>{const n=t.format.channels[0].mask0;return e=Te(e),(r,s)=>B(e(r,s),0,n)},Nt=t=>(t=Te(t),(e,n)=>[t(e,n)]),qe=(t,e,n,r,s=4)=>Fe(t[r],t[r+s],t[r+2*s],t[r+3*s],t[r+4*s],t[r+5*s],t[r+6*s],t[r+7*s],t[r+8*s],t[r+9*s],t[r+10*s],t[r+11*s],t[r+12*s],t[r+13*s],t[r+14*s],t[r+15*s],e,n),yt=(t,e,n,r,s=4)=>B(qe(t,e,n,r,s),0,255),Tt=(t,e)=>{const{fromABGR:n,toABGR:r}=t.format,s=new Uint32Array(16),i=new Uint8Array(s.buffer);return(a,o)=>{a-=.5,o-=.5;const c=a-1,l=a+1,h=a+2,u=o-1,f=o+1,d=o+2,g=p(a),m=p(o);return s[0]=r(e(c,u)),s[1]=r(e(a,u)),s[2]=r(e(l,u)),s[3]=r(e(h,u)),s[4]=r(e(c,o)),s[5]=r(e(a,o)),s[6]=r(e(l,o)),s[7]=r(e(h,o)),s[8]=r(e(c,f)),s[9]=r(e(a,f)),s[10]=r(e(l,f)),s[11]=r(e(h,f)),s[12]=r(e(c,d)),s[13]=r(e(a,d)),s[14]=r(e(l,d)),s[15]=r(e(h,d)),n(yt(i,g,m,0)|yt(i,g,m,1)<<8|yt(i,g,m,2)<<16|yt(i,g,m,3)<<24)>>>0}},qt=({stride:[t]},e)=>{const n=new Float32Array(t*16);return(r,s)=>{r-=.5,s-=.5;const i=r-1,a=r+1,o=r+2,c=s-1,l=s+1,h=s+2,u=p(r),f=p(s);n.set(e(i,c),0),n.set(e(r,c),t),n.set(e(a,c),2*t),n.set(e(o,c),3*t),n.set(e(i,s),4*t),n.set(e(r,s),5*t),n.set(e(a,s),6*t),n.set(e(o,s),7*t),n.set(e(i,l),8*t),n.set(e(r,l),9*t),n.set(e(a,l),10*t),n.set(e(o,l),11*t),n.set(e(i,h),12*t),n.set(e(r,h),13*t),n.set(e(a,h),14*t),n.set(e(o,h),15*t);let d=[];for(let g=0;g<t;g++)d.push(qe(n,u,f,g,t));return d}};var Cr=Object.getOwnPropertyDescriptor,vr=(t,e,n,r)=>{for(var s=r>1?void 0:r?Cr(e,n):e,i=t.length-1,a;i>=0;i--)(a=t[i])&&(s=a(s)||s);return s};function Sr(...t){return t[0]instanceof U?t[0].as(t[1]):new U(...t)}const Br=(t,e=zt)=>{const{data:n}=Hn(t),r=t.width,s=t.height;let i;if(e===zt)i=n;else{i=ht(e.type,r*s);const a=n,o=e.fromABGR;for(let c=i.length;c-- >0;)i[c]=o(a[c])}return new U(r,s,e,i)};let U=class{size;stride;format;data;constructor(t,e,n=zt,r){this.size=[t,e],this.stride=[1,t],this.format=n.__packed?n:ze(n),this.data=r||ht(n.type,t*e)}get pixels(){return this.data}get width(){return this.size[0]}get height(){return this.size[1]}get offset(){return 0}get dim(){return 2}*[Symbol.iterator](){yield*this.data}as(t){if(!t.__float)return this.getRegion(0,0,this.width,this.height,t);const e=new v(this.width,this.height,t),{data:n,format:r,stride:[s]}=e,{data:i,format:a}=this;for(let o=i.length;o-- >0;)n.set(r.fromABGR(a.toABGR(i[o])),o*s);return e}copy(){const t=this.empty();return t.data.set(this.data),t}empty(){return new U(this.width,this.height,this.format)}order(){}includes(t,e){}indexAt(t,e){}indexAtUnsafe(t,e){}getAt(t,e){}getAtUnsafe(t,e){}setAt(t,e,n){}setAtUnsafe(t,e,n){}getChannelAt(t,e,n,r=!1){const s=O(this.format,n),i=this.getAt(t,e);return r?s.float(i):s.int(i)}setChannelAt(t,e,n,r,s=!1){const i=O(this.format,n),a=this.getAt(t,e);return s?i.setFloat(a,r):i.setInt(a,r),this}blend(t,e,n){let r=this.width,s=e.width;const{sx:i,sy:a,dx:o,dy:c,rw:l,rh:h}=ct(this,e,n);if(l<1||h<1)return e;const u=this.data,f=e.data,d=this.format.toABGR,g=e.format.toABGR,m=e.format.fromABGR;for(let b=(i|0)+(a|0)*r,A=(o|0)+(c|0)*s,E=0;E<h;E++,b+=r,A+=s)for(let z=0;z<l;z++)f[A+z]=m(t(d(u[b+z]),g(f[A+z])));return e}blit(t,e){let n=this.width,r=t.width;const{sx:s,sy:i,dx:a,dy:o,rw:c,rh:l}=ct(this,t,e);if(c<1||l<1)return t;const h=this.data,u=t.data,f=this.format.toABGR,d=t.format.fromABGR,g=this.format!==t.format?(m,b)=>{for(let A=0;A<c;A++)u[b+A]=d(f(h[m+A]))}:(m,b)=>u.set(h.subarray(m,m+c),b);for(let m=(s|0)+(i|0)*n,b=(a|0)+(o|0)*r,A=0;A<l;A++,m+=n,b+=r)g(m,b);return t}blitCanvas(t,e={}){Ie(this,t,e)}setImageData(t){Mt(t,this.width,this.height);const e=new Uint32Array(t.data.buffer),n=this.data,r=this.format.fromABGR;for(let s=e.length;s-- >0;)n[s]=r(e[s]);return this}toImageData(t){t=Ge(t,this.width,this.height);const e=new Uint32Array(t.data.buffer),n=this.data,r=this.format.toABGR;for(let s=e.length;s-- >0;)e[s]=r(n[s]);return t}getRegion(t,e,n,r,s){const[i,a,o,c]=at(t,e,n,r,this.width,this.height);if(!(o<1||c<1))return this.blit(new U(o,c,s||this.format),{sx:i,sy:a,w:o,h:c})}getChannel(t){const e=O(this.format,t),n=new U(this.width,this.height,{type:br(e.size),size:e.size,channels:[{size:e.size,lane:w.RED}],fromABGR:Ar(e.size),toABGR:_r(e.size)}),r=this.data,s=n.data,i=e.int;for(let a=r.length;a-- >0;)s[a]=i(r[a]);return n}setChannel(t,e){const n=O(this.format,t),r=this.data,s=n.setInt;if(q(e))er(r,e,s);else{const i=e.data,a=e.format.channels[0];ke(i,this.width,this.height),n.size===a.size?nr(r,i,a.int,s):rr(r,i,this.format.fromABGR,e.format.toABGR,n.maskA)}return this}invert(){const{data:t,format:e}=this,n=Math.pow(2,e.size-e.alpha)-1;for(let r=t.length;r-- >0;)t[r]^=n;return this}premultiply(){return tr(this.format),Me(this.data,this.format,Xn),this}postmultiply(){return Me(this.data,this.format,Zn),this}isPremultiplied(){const t=this.data,e=this.format.toABGR;for(let n=t.length;n-- >0;)if(!Qn(e(t[n])))return!1;return!0}forEach(t){const e=this.data;for(let n=e.length;n-- >0;)e[n]=t(e[n],n);return this}fill(t){this.data.fill(t)}flipX(){const{data:t,width:e}=this;for(let n=0;n<t.length;n+=e)t.subarray(n,n+e).reverse();return this}flipY(){const{data:t,width:e}=this,n=ht(this.format.type,e);for(let r=0,s=t.length-e;r<s;r+=e,s-=e)n.set(t.subarray(r,r+e)),t.copyWithin(r,s,s+e),t.set(n,s);return this}rotateByID(t){return t>0?this[$e[t-1]]():this}rotateCW(){const{width:t,height:e}=this,n=e-1;return this._rotate((r,s)=>r*e+n-s),this.size[0]=e,this.size[1]=t,this}rotateCCW(){const{width:t,height:e}=this,n=t-1;return this._rotate((r,s)=>(n-r)*e+s),this.size[0]=e,this.size[1]=t,this}rotate180(){const{width:t,height:e}=this,n=t-1,r=e-1;return this._rotate((s,i)=>(r-i)*t+n-s),this}scale(t,e="linear"){return _(t>0,"scale must be > 0"),this.resize(this.width*t,this.height*t,e)}resize(t,e,n="linear"){t|=0,e|=0,_(t>0&&e>0,"target width & height must be > 0");const r=Sr(t,e,this.format),s=r.data,i=t>0?this.width/t:0,a=e>0?this.height/e:0;n=P(n)?Ne(this,n,"repeat"):n;for(let o=0,c=0;o<e;o++){const l=o*a;for(let h=0;h<t;h++,c++)s[c]=n(h*i,l)}return r}upsize(){const{width:t,height:e,data:n}=this,r=new U(t*2,e*2,this.format),s=r.data;for(let i=0,a=0;i<e;i++)for(let o=0,c=i*t*4;o<t;o++,a++,c+=2)s[c]=n[a];return r}_rotate(t){const{data:e,format:n,width:r,height:s}=this,i=ht(n.type,r*s);for(let a=0;a<s;a++)for(let o=0;o<r;o++)i[t(o,a)]=e[a*r+o];this.data=i}};U=vr([Ce],U);var kr=Object.defineProperty,Gr=Object.getOwnPropertyDescriptor,Z=(t,e,n,r)=>{for(var s=r>1?void 0:r?Gr(e,n):e,i=t.length-1,a;i>=0;i--)(a=t[i])&&(s=(r?a(e,n,s):a(s))||s);return r&&s&&kr(e,n,s),s};function Pe(...t){return t[0]instanceof U?Mr(...t):new v(...t)}const Mr=(t,e)=>{const n=new v(t.width,t.height,e),{data:r,format:s,stride:[i]}=n,{data:a,format:o}=t;for(let c=a.length;c-- >0;)r.set(s.fromABGR(o.toABGR(a[c])),c*i);return n},Ir=(t,e=j)=>Br(t).as(e);let v=class{size;stride;format;data;__empty;constructor(t,e,n=j,r){this.size=[t,e],this.format=n.__float?n:lt(n);const s=this.format.channels.length;this.stride=[s,t*s],this.data=r||new Float32Array(t*e*s),this.__empty=Object.freeze(new Array(s).fill(0))}get pixels(){return this.data}get width(){return this.size[0]}get height(){return this.size[1]}get offset(){return 0}get dim(){return 2}*[Symbol.iterator](){const{data:t,stride:[e]}=this;for(let n=0,r=t.length;n<r;n+=e)yield t.subarray(n,n+e)}as(t){const{width:e,height:n,stride:[r],data:s,format:{size:i,normalized:a,toABGR:o}}=this;let c=0,l=0,h=s.length;if(t.__float){const u=t,f=new v(e,n,u),{data:d,stride:[g]}=f;if(i===1&&u.channels.length===1){const m=u.fromNormalized;for(;c<h;c+=r,l+=g)d[l]=m(a(s[c]))}else for(;c<h;c+=r,l+=g)d.set(u.fromABGR(o(s.subarray(c,c+r))),l);return f}else{const u=t,f=new U(e,n,u),d=f.data;if(i===1&&u.channels.length===1){const g=u.channels[0].setFloat;for(;c<h;c+=r,l++)d[l]=g(0,a(s[c]))}else for(;c<h;c+=r,l++)d[l]=u.fromABGR(o(s.subarray(c,c+r)));return f}}copy(){const t=this.empty();return t.data.set(this.data),t}empty(){return new v(this.width,this.height,this.format)}order(){}includes(t,e){}indexAt(t,e){}indexAtUnsafe(t,e){}getAt(t,e){return this.includes(t,e)?this.getAtUnsafe(t,e):this.__empty}getAtUnsafe(t,e){const n=this.indexAtUnsafe(t,e);return this.data.subarray(n,n+this.stride[0])}setAt(t,e,n){return this.includes(t,e)?(this.data.set(n,this.indexAtUnsafe(t,e)),!0):!1}setAtUnsafe(t,e,n){return this.data.set(n,this.indexAtUnsafe(t,e)),!0}getChannelAt(t,e,n){return O(this.format,n),this.includes(t,e)?this.data[this.indexAtUnsafe(t,e)+n]:void 0}setChannelAt(t,e,n,r){return O(this.format,n),this.includes(t,e)&&(this.data[this.indexAtUnsafe(t,e)+n]=r),this}getChannel(t){O(this.format,t);const{data:e,stride:[n]}=this,[r,s]=this.format.range,i=new Float32Array(this.width*this.height);for(let a=t,o=0,c=e.length;a<c;a+=n,o++)i[o]=B(e[a],r,s);return new v(this.width,this.height,Ue,i)}setChannel(t,e){O(this.format,t);const{data:n,stride:[r]}=this;if(q(e))for(let s=t,i=n.length;s<i;s+=r)n[s]=e;else{const{data:s,stride:[i]}=e;ke(s,this.width,this.height,i);for(let a=t,o=0,c=n.length;a<c;a+=r,o+=i)n[a]=s[o]}return this}blend(t,e,n){this.ensureFormat(e);const{sx:r,sy:s,dx:i,dy:a,rw:o,rh:c}=ct(this,e,n);if(o<1||c<1)return e;const l=this.data,h=e.data,[u,f]=this.stride,d=e.stride[1];for(let g=(r|0)*u+(s|0)*f,m=(i|0)*u+(a|0)*d,b=0;b<c;b++,g+=f,m+=d)for(let A=o,E=g,z=m;A-- >0;E+=u,z+=u){const Gt=h.subarray(z,z+u);t(Gt,l.subarray(E,E+u),Gt)}return e}blit(t,e){this.ensureFormat(t);const{sx:n,sy:r,dx:s,dy:i,rw:a,rh:o}=ct(this,t,e);if(a<1||o<1)return t;const c=this.data,l=t.data,[h,u]=this.stride,f=t.stride[1],d=a*h;for(let g=(n|0)*h+(r|0)*u,m=(s|0)*h+(i|0)*f,b=0;b<o;b++,g+=u,m+=f)l.set(c.subarray(g,g+d),m);return t}blitCanvas(t,e={}){Ie(this,t,e)}setImageData(t){Mt(t,this.width,this.height);const e=new Uint32Array(t.data.buffer),{data:n,format:{fromABGR:r},stride:[s]}=this,i=[];for(let a=e.length;a-- >0;)n.set(r(e[a],i),a*s);return this}toImageData(t){t=Ge(t,this.width,this.height);const e=new Uint32Array(t.data.buffer),{stride:[n],data:r,format:s}=this;for(let i=0,a=0,o=r.length;i<o;i+=n,a++)e[a]=s.toABGR(r.subarray(i,i+n));return t}getRegion(t,e,n,r){const[s,i,a,o]=at(t,e,n,r,this.width,this.height);if(!(a<1||o<1))return this.blit(new v(a,o,this.format),{sx:s,sy:i,w:a,h:o})}forEach(t){const{data:e,stride:[n]}=this;for(let r=0,s=0,i=e.length;r<i;r+=n,s++)e.set(t(e.subarray(r,r+n),s),r);return this}fill(t){_(t.length<=this.format.channels.length,"fill value has too many channels");const{data:e,stride:[n]}=this;for(let r=0,s=e.length;r<s;r+=n)e.set(t,r)}premultiply(){this.ensureRGBA();const{data:t,stride:[e]}=this;for(let n=0,r=t.length;n<r;n+=e)Vn(null,t.subarray(n,n+e));return this}postmultiply(){this.ensureRGBA();const{data:t,stride:[e]}=this;for(let n=0,r=t.length;n<r;n+=e)Kn(null,t.subarray(n,n+e));return this}isPremultiplied(){this.ensureRGBA();const{data:t,stride:[e]}=this;for(let n=0,r=t.length;n<r;n+=e)if(!Jn(t.subarray(n,n+e)))return!1;return!0}clamp(){const t=this.data,[e,n]=this.format.range;for(let r=t.length;r-- >0;)t[r]=B(t[r],e,n);return this}clampChannel(t){O(this.format,t);const{data:e,stride:[n]}=this,[r,s]=this.format.range;for(let i=t,a=e.length;i<a;i+=n)e[i]=B(e[i],r,s)}flipX(){const{data:t,width:e,height:n,stride:[r,s]}=this,i=new Float32Array(r),a=e-1,o=e>>>1;for(let c=0;c<n;c++)for(let l=0,h=c*s,u=h+a*r;l<o;l++,h+=r,u-=r)i.set(t.subarray(h,h+r)),t.copyWithin(h,u,u+r),t.set(i,u);return this}flipY(){const t=this.data,e=this.stride[1],n=new Float32Array(e);for(let r=0,s=t.length-e;r<s;r+=e,s-=e)n.set(t.subarray(r,r+e)),t.copyWithin(r,s,s+e),t.set(n,s);return this}rotateByID(t){return t>0?this[$e[t-1]]():this}rotateCW(){const{width:t,height:e}=this,n=e-1;return this._rotate((r,s)=>r*e+n-s),this.size[0]=e,this.size[1]=t,this}rotateCCW(){const{width:t,height:e}=this,n=t-1;return this._rotate((r,s)=>(n-r)*e+s),this.size[0]=e,this.size[1]=t,this}rotate180(){const{width:t,height:e}=this,n=t-1,r=e-1;return this._rotate((s,i)=>(r-i)*t+n-s),this}invert(){const{data:t,format:e,stride:[n]}=this;for(let r=0,s=t.length,i=e.alpha?n-1:n;r<s;r+=n)for(let a=0;a<i;a++)t[r+a]=1-t[r+a];return this}scale(t,e){return _(t>0,"scale must be > 0"),this.resize(this.width*t,this.height*t,e)}resize(t,e,n="linear"){t|=0,e|=0,_(t>0&&e>0,"target width & height must be > 0");const r=Pe(t,e,this.format),s=r.data,i=t>0?this.width/t:0,a=e>0?this.height/e:0,o=this.stride[0];n=P(n)?Ne(this,n,"repeat"):n;for(let c=0,l=0;c<e;c++){const h=c*a;for(let u=0;u<t;u++,l+=o)s.set(n(u*i,h),l)}return r}upsize(){const{width:t,height:e,data:n,stride:[r,s]}=this,i=r*2,a=Pe(t*2,e*2,this.format),o=a.data;for(let c=0,l=0;c<e;c++)for(let h=0,u=c*s*4;h<t;h++,l+=r,u+=i)o.set(n.subarray(l,l+r),u);return a}_rotate(t){const{data:e,width:n,height:r,stride:[s]}=this,i=new Float32Array(n*r*s);for(let a=0,o=0;a<r;a++)for(let c=0;c<n;c++,o+=s)i.set(e.subarray(o,o+s),t(c,a)*s);this.data=i}ensureFormat(t){_(t.format===this.format,"dest buffer format must be same as src")}ensureRGBA(){_(this.format===j,"require FLOAT_RGBA format")}};Z([rt],v.prototype,"getAt",1),Z([rt],v.prototype,"getAtUnsafe",1),Z([rt],v.prototype,"setAt",1),Z([rt],v.prototype,"setAtUnsafe",1),v=Z([Ce],v);const Ur=(t,e,n)=>(t-e)/(n-e),xr=(t,e,n,r,s)=>r+(s-r)*Ur(t,e,n),bt=Math.abs,zr=Math.min,Or=lt({alpha:!0,channels:[w.RED,w.GREEN,w.BLUE,w.ALPHA],convert:{fromABGR:(t,e=[])=>{const n=(t>>>24&255)/255,r=(t>>>16&255)/255,s=(t>>>8&255)/255,i=(t&255)/255;let a,o,c,l,h,u,f,d;s<r?(a=r,o=s,c=-1,l=2/3):(a=s,o=r,c=0,l=-1/3),i<a?(h=a,u=o,f=l,d=i):(h=i,u=o,f=c,d=a);const g=h-zr(u,d);return h=y(h),e[0]=y(bt((d-u)/(6*g+I)+f)),e[1]=y(g/(h+I)),e[2]=h,e[3]=n,e},toABGR:t=>{const e=t[0]*6,n=t[1],r=t[2]*255,s=t[3]*255,i=((y(bt(e-3)-1)-1)*n+1)*r,a=((y(2-bt(e-2))-1)*n+1)*r,o=((y(2-bt(e-4))-1)*n+1)*r;return(s<<24|o<<16|a<<8|i)>>>0}}}),j=lt({alpha:!0,channels:[w.RED,w.GREEN,w.BLUE,w.ALPHA]}),Er=ot(()=>"unsupported operation"),Pt=t=>{throw new Er(t)},G=(t=1,e,...n)=>{const r=[,,].concat(n),s=(...i)=>{const a=r[i[t].length]||e;return a?a(...i):Pt(`no impl for vec size ${i[t].length}`)};return s.add=(i,a)=>r[i]=a,s.default=i=>e=i,s.impl=i=>i!=null&&r[i]||e,s},Fr=(t,e)=>t[0]*e[0]+t[1]*e[1],jt=(t,e)=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2],Dr=G(0,(t,e)=>{let n=0;for(let r=t.length;r-- >0;)n+=t[r]*e[r];return n},Fr,jt,(t,e)=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]);function je(t,e=Object.create(null)){return(...n)=>{const r=JSON.stringify(n);return r!==void 0?r in e?e[r]:e[r]=t.apply(null,n):t.apply(null,n)}}function Le(t,e=Object.create(null)){return(...n)=>{const r=n.join("-");return r in e?e[r]:e[r]=t(...n)}}const Nr=Le((t,e)=>t.repeat(e)),He=je((t,e=!1)=>e?n=>Tr(n)||n.toFixed(t):n=>n.toFixed(t)),Tr=t=>isNaN(t)?"NaN":t===1/0?"+∞":t===-1/0?"-∞":void 0,qr=(t=0)=>e=>(e*100).toFixed(t)+"%",Pr=[.299,.587,.114],We=[.2126,.7152,.0722],jr=[3.1338561,-.9787684,.0719453,-1.6168667,1.9161415,-.2289914,-.4906146,.033454,1.4052427],Lr=[3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252],Hr=[.96422,1,.82521],Wr=[.95047,1,1.08883],Yr=[.2104542553,1.9779984951,.0259040371,.793617785,-2.428592205,.7827717662,-.0040720468,.4505937099,-.808675766];let At=He(3),Ye=qr(3);const M=1/255,Lt=(t,e=We)=>jt(t,e),Vr=t=>jt(t,Pr),Xr=(t,e)=>(!t&&(t=[]),t[0]=e[0],t[1]=e[1],t),Kr=(t,e)=>(!t&&(t=[]),t[0]=e[0],t[1]=e[1],t[2]=e[2],t),L=(t,e)=>(!t&&(t=[]),t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t),Zr=G(1,(t,e)=>{!t&&(t=[]);for(let n=e.length;n-- >0;)t[n]=e[n];return t},Xr,Kr,L),J=(t,e)=>typeof t?.[e]=="function",Ht=t=>t!=null&&typeof t!="function"&&t.length!==void 0,Jr=ot(()=>"illegal argument(s)"),Wt=t=>{throw new Jr(t)},Qr=je((t,e=3,n=",",r="[",s="]")=>{const i=typeof e=="number"?He(e):e;switch(t){case 1:return a=>`${r}${i(a[0])}${s}`;case 2:return a=>`${r}${i(a[0])}${n}${i(a[1])}${s}`;case 3:return a=>`${r}${i(a[0])}${n}${i(a[1])}${n}${i(a[2])}${s}`;case 4:return a=>`${r}${i(a[0])}${n}${i(a[1])}${n}${i(a[2])}${n}${i(a[3])}${s}`;default:return a=>{const o=[];for(let c=0;c<a.length;c++)o.push(i(a[c]));return`${r}${o.join(n)}${s}`}}}),ts=(t,e,n,r,s,i)=>{const a=[];for(;n-- >0;)a.push(new t(e,r,s)),r+=i;return a},es=(t,e=1,n=!0)=>{const r=n?(o,c,l,h)=>{!o&&(o=c);for(let u=c.length;u-- >0;)o[u]=t(c[u],l[u],h[u]);return o}:(o,c,l,h)=>{!o&&(o=h);for(let u=c.length;u-- >0;)o[u]=t(c[u],l[u],h[u]);return o},s=n?(o,c,l,h)=>(!o&&(o=c),o[0]=t(c[0],l[0],h[0]),o[1]=t(c[1],l[1],h[1]),o):(o,c,l,h)=>(!o&&(o=h),o[0]=t(c[0],l[0],h[0]),o[1]=t(c[1],l[1],h[1]),o),i=n?(o,c,l,h)=>(!o&&(o=c),o[0]=t(c[0],l[0],h[0]),o[1]=t(c[1],l[1],h[1]),o[2]=t(c[2],l[2],h[2]),o):(o,c,l,h)=>(!o&&(o=h),o[0]=t(c[0],l[0],h[0]),o[1]=t(c[1],l[1],h[1]),o[2]=t(c[2],l[2],h[2]),o),a=n?(o,c,l,h)=>(!o&&(o=c),o[0]=t(c[0],l[0],h[0]),o[1]=t(c[1],l[1],h[1]),o[2]=t(c[2],l[2],h[2]),o[3]=t(c[3],l[3],h[3]),o):(o,c,l,h)=>(!o&&(o=h),o[0]=t(c[0],l[0],h[0]),o[1]=t(c[1],l[1],h[1]),o[2]=t(c[2],l[2],h[2]),o[3]=t(c[3],l[3],h[3]),o);return[G(e,r,s,i,a),s,i,a]},[li,hi,fi,ns]=es(B),rs=ns,ss=(t,e,n,r=!0,s=!0)=>{const i=n>0?r?function(){return this.buf[this.offset+n*this.stride]}:function(){return this.buf[this.offset+n]}:function(){return this.buf[this.offset]},a=n>0?r?function(o){this.buf[this.offset+n*this.stride]=o}:function(o){this.buf[this.offset+n]=o}:function(o){this.buf[this.offset]=o};s&&Object.defineProperty(t,n,{get:i,set:a,enumerable:!0}),Object.defineProperty(t,e,{get:i,set:a,enumerable:!0})},os=(t,e,n,r)=>e.forEach((s,i)=>ss(t,s,i,n,r)),is=Math.abs,x=(t,e,n=I)=>is(t-e)<=n,as=(t,e,n=I)=>t.length===e.length&&x(t[0],e[0],n)&&x(t[1],e[1],n),cs=(t,e,n=I)=>t.length===e.length&&x(t[0],e[0],n)&&x(t[1],e[1],n)&&x(t[2],e[2],n),Ve=(t,e,n=I)=>t.length===e.length&&x(t[0],e[0],n)&&x(t[1],e[1],n)&&x(t[2],e[2],n)&&x(t[3],e[3],n);G(0,(t,e,n=I)=>J(t,"eqDelta")?t.eqDelta(e,n):J(e,"eqDelta")?e.eqDelta(t,n):ls(t,e,t.length,n),as,cs,Ve);const ls=(t,e,n,r=I,s=0,i=0,a=1,o=1)=>{for(;n>0;n--,s+=a,i+=o)if(!x(t[s],e[i],r))return!1;return!0};function*hs(t,e,n,r){for(;e-- >0;)yield t[n],n+=r}const Xe=1/2**32;class fs{float(e=1){return this.int()*Xe*e}probability(e){return this.float()<e}norm(e=1){return(this.int()*Xe-.5)*2*e}normMinMax(e,n){const r=this.minmax(e,n);return this.float()<.5?r:-r}minmax(e,n){return this.float()*(n-e)+e}minmaxInt(e,n){e|=0;const r=(n|0)-e;return r?e+this.int()%r:e}minmaxUint(e,n){e>>>=0;const r=(n>>>0)-e;return r?e+this.int()%r:e}}class us extends fs{constructor(e){super(),this.rnd=e}float(e=1){return this.rnd()*e}norm(e=1){return(this.rnd()-.5)*2*e}int(){return this.rnd()*4294967296>>>0}}const Yt=new us(Math.random),ds=(t,e,n=Yt)=>{const r=t.length;_(r>0,"no choices given");const s=e?t.map((a,o)=>[e[o]||0,a]).sort((a,o)=>o[0]-a[0]):t.map(a=>[1,a]),i=s.reduce((a,o)=>a+o[0],0);return i<=0&&console.warn("total weights <= 0"),()=>{const a=n.float(i);let o=i;for(let c=0;c<r;c++)if(o-=s[c][0],o<=a)return s[c][1]}},gs=G(1,(t,e,n,r=Yt)=>{!t&&(t=e);for(let s=e.length;s-- >0;)t[s]=r.minmax(e[s],n[s]);return t}),Ke=Array.isArray,Q={},Ze=(t,e)=>{for(let n in e){const r=e[n];if(Ke(r)){const[s,i,a,o]=r;e[n]=r.length===2?(c,l)=>i(c,s(c,l)):r.length===3?(c,l)=>a(c,i(c,s(c,l))):(c,l)=>o(c,a(c,i(c,s(c,l))))}}Q[t]={...Q[t],...e}},Je=(t,e,n,r)=>{const s=Q[n];_(!!s,`no conversions available for ${n}`);let i=s[r];return i?i(t,e):Q.rgb[r]?s.rgb(t,Q.rgb[r]([],e)):Pt(`can\'t convert: ${r} -> ${n}`)},Qe=(t,e)=>(t>>>e|t<<32-e)>>>0,ms=t=>(t&3840)*4352|(t&240)*272|(t&15)*17,ys=t=>((t&61440)*69632|(t&3840)*4352|(t&240)*272|(t&15)*17)>>>0;class T{constructor(e,n){this.mode=e,this.value=n}deref(){return this.value}}const bs={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",grey:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32",transparent:"0000",rebeccapurple:"639"};let As={canvas:"fff",canvastext:"000",linktext:"001ee4",visitedtext:"4e2386",activetext:"eb3323",buttonface:"ddd",buttontext:"000",buttonborder:"000",field:"fff",fieldtext:"000",highlight:"bbd5fb",highlighttext:"000",mark:"000",marktext:"fff",graytext:"808080"};const S=(t,e,n,r)=>(!t&&(t=[]),t[0]=e,t[1]=n,t[2]=r,t),R=(t,e,n,r,s)=>(!t&&(t=[]),t[0]=e,t[1]=n,t[2]=r,t[3]=s,t),_t=(t,e)=>R(t||[],(e>>>16&255)*M,(e>>>8&255)*M,(e&255)*M,(e>>>24)*M),tn=(t,e)=>R(t||[],(e&255)*M,(e>>>8&255)*M,(e>>>16&255)*M,(e>>>24)*M),_s=t=>{t=(P(t)?t:t.deref()).toLowerCase();const e=bs[t]||As[t];if(e||t[0]==="#")return new T("srgb",_t([],ws(e||t)));const n=t.split(/[(),/ ]+/),[r,s,i,a,o]=n;switch(_(n.length===5||n.length===6,`invalid color: ${t}`),r){case"rgb":case"rgba":return new T("srgb",[C(s,1,M,!0),C(i,1,M,!0),C(a,1,M,!0),H(o)]);case"hsl":case"hsla":return new T("hsl",[Vt(s),en(i),en(a),H(o)]);case"lab":return new T("lab50",[C(s),C(i,1.25),C(a,1.25),H(o)]);case"lch":return new T(r,[C(s),C(i,1.5),Vt(a),H(o)]);case"oklab":return new T(r,[C(s,1,1),C(i,.4,1),C(a,.4,1),H(o)]);case"oklch":return new T(r,[C(s,1,1),C(i,.4,1),Vt(a),H(o)]);default:Pt(`color mode: ${r}`)}},ps={rad:k,grad:400,turn:1,deg:360},Vt=t=>{const e=/^(-?[0-9.]+)(deg|rad|grad|turn)?$/.exec(t);return _(!!e,`expected hue, got: ${t}`),p(parseFloat(e[1])/(ps[e[2]]||360))},H=t=>t?C(t,1,1,!0):1,en=(t,e=!0)=>{_(/^([0-9.]+)%$/.test(t),`expected percentage, got: ${t}`);const n=parseFloat(t)/100;return e?y(n):n},C=(t,e=1,n=.01,r=!1)=>{_(/^-?[0-9.]+%?$/.test(t),`expected number or percentage, got: ${t}`);const s=parseFloat(t)*(t.endsWith("%")?.01*e:n);return r?y(s):s},ws=t=>{const e=/^#?([0-9a-f]{3,8})$/i.exec(t);if(e){const n=e[1],r=parseInt(n,16);switch(n.length){case 3:return(ms(r)|4278190080)>>>0;case 4:return Qe(ys(r),8);case 6:return(r|4278190080)>>>0;case 8:return Qe(r,8)}}return Wt(`invalid hex color: "${t}"`)},$=(t,e=1)=>t!=null?y(t):e,Rs=t=>{if(typeof t[0]=="number")switch(t.length){case 1:return t.push(0,0,1),[t];case 2:return t.push(0,1),[t];case 3:return t.push(1),[t];default:return[t]}return t},pt=t=>{const e=t.channels||{},n=t.order,r=n.length;n.reduce((f,d)=>(f[d]={range:[0,1],...e[d]},f),e);const s=Object.freeze(n.map(f=>e[f].range[0])),i=Object.freeze(n.map(f=>e[f].range[1])),a=L([],s),o=L([],i);a[r-1]=1;const c=n.findIndex(f=>!!e[f].hue),l=class{constructor(f,d=0,g=1){this.offset=d,this.stride=g,this.buf=f||[0,0,0,0],this.offset=d,this.stride=g}buf;get mode(){return t.mode}get length(){return r}get range(){return[s,i]}get[Symbol.toStringTag](){return t.mode}get xyz(){return[this[0],this[1],this[2]]}[Symbol.iterator](){return hs(this.buf,this.length,this.offset,this.stride)}copy(){return new l(this.deref())}copyView(){return new l(this.buf,this.offset,this.stride)}empty(){return new l}deref(){return[this[0],this[1],this[2],this[3]]}set(f){return L(this,f)}clamp(){return c>=0&&(this[c]=p(this[c])),rs(null,this,s,i),this}eqDelta(f,d=I){return Ve(this,f,d)}randomize(f){return gs(this,a,o,f)}toJSON(){return this.deref()}toString(){return Qr(4,4)(this)}};os(l.prototype,n),Ze(t.mode,t.from),Ze("rgb",{[t.mode]:t.toRgb});const h=(f,d,g)=>{const m=new l(...g);return d!==t.mode?Je(m,f,t.mode,d):m.set(f)},u=(f,...d)=>f==null?new l:P(f)?u(_s(f),...d):Ht(f)?P(f.mode)?h(f,f.mode,d):new l(f,...d):J(f,"deref")?h(f.deref(),f.mode,d):q(f)?d.length&&d.every(q)?new l(...Rs([f,...d])):h(_t([],f),"srgb",d):Wt(`can\'t create a ${t.mode} color from: ${f}`);return u.class=l,u.range=[s,i],u.random=(f,d,g,m)=>new l(d,g,m).randomize(f),u.mapBuffer=(f,d=f.length/r|0,g=0,m=1,b=r)=>ts(l,f,d,g,m,b),u},Xt=(t,e,n=1)=>(e=p(e)*6,R(t||[],y(Math.abs(e-3)-1),y(2-Math.abs(e-2)),y(2-Math.abs(e-4)),n)),nn=(t,e)=>{const n=e[0];let r=e[1];const s=e[2],i=Xt(t||e,n,$(e[3])),a=Lt(i);return s<a?r*=s/a:a<1&&(r*=(1-s)/(1-a)),S(i,y((i[0]-a)*r+s),y((i[1]-a)*r+s),y((i[2]-a)*r+s))},$s=(t,e,n=1)=>R(t||e,y(e[0]),y(e[1]),y(e[2]),$(e[3],n)),wt=(t,e,n=1)=>R(t||e,p(e[0]),y(e[1]),y(e[2]),$(e[3],n)),rn=(t,e)=>{t=wt(t||e,e);const n=t[1],r=t[2];if(n<1e-6)return S(t,r,r,r);const s=t[0]*6%6,i=r*(1-n),a=1-Math.abs(s%2-1);let o=3*r*n/(1+a);const c=o*a+i;switch(o+=i,s|0){case 0:return S(t,o,c,i);case 1:return S(t,c,o,i);case 2:return S(t,i,o,c);case 3:return S(t,i,c,o);case 4:return S(t,c,i,o);case 5:return S(t,o,i,c);default:return S(t,i,i,i)}},sn=(t,e)=>{const n=y(e[1]),r=y(e[2]);t=Xt(t||e,e[0],$(e[3]));const s=(1-Math.abs(2*r-1))*n;return S(t,(t[0]-.5)*s+r,(t[1]-.5)*s+r,(t[2]-.5)*s+r)},Kt=(t,e)=>{t=wt(t||e,e);const n=t[1],r=t[2];return Xt(t,e[0],t[3]),S(t,((t[0]-1)*n+1)*r,((t[1]-1)*n+1)*r,((t[2]-1)*n+1)*r)},Zt=t=>t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055,Jt=t=>t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4),Rt=(t,e)=>R(t||e,Jt(e[0]),Jt(e[1]),Jt(e[2]),$(e[3])),Cs=(t,e)=>Rt(null,_t(t,e)),vs=(t,e)=>Rt(null,tn(t,e)),Qt=(t,e=1)=>[Math.cos(t)*e,Math.sin(t)*e],Ss=t=>(t%=k,t<0?k+t:t),on=(t,e)=>Ss(Math.atan2(t,e)),te=(t,e)=>{let{1:n,2:r}=e;r*=k;const s=$(e[3]);return n>0?R(t||e,e[0],Math.cos(r)*n,Math.sin(r)*n,s):R(t||e,e[0],0,0,s)},ee=t=>{const e=t**3;return e>.008856?e:(t-16/116)/7.787},an=(t,e,n=Hr)=>{const r=(e[0]+.16)/1.16;return R(t||e,ee(e[1]/5+r)*n[0],ee(r)*n[1],ee(r-e[2]/2)*n[2],$(e[3]))},Bs=(t,e)=>an(t,e,Wr),ne=(t,e,n=0,r=0,s=1,i=1)=>t[n]*e[r]+t[n+s]*e[r+i]+t[n+2*s]*e[r+2*i],$t=(t,e,n,r=!1)=>{const s=ne(e,n,0,0,3),i=ne(e,n,1,0,3),a=ne(e,n,2,0,3),o=$(n[3]);return r?R(t||n,y(s),y(i),y(a),o):R(t||n,s,i,a,o)},re=(t,e,n=jr)=>$t(t,n,e),se=(t,e)=>re(t,e,Lr),tt=(t,e)=>re(null,an(t,e)),cn=(t,e)=>se(null,Bs(t,e)),ks=[4.0767416621,-1.2684380046,-.0041960863,-3.307711591,2.6097574011,-.7034186147,.2309699292,-.3413193965,1.707614701],ln=(t,{0:e,1:n,2:r,3:s})=>$t(t,ks,[(e+.3963377774*n+.2158037573*r)**3,(e-.1055613458*n-.0638541728*r)**3,(e-.0894841775*n-1.291485548*r)**3,s]),hn=(t,e)=>e!==0?t/e:0,fn=pt({mode:"rgb",order:["r","g","b","alpha"],from:{abgr32:(t,e)=>vs(t,e[0]),argb32:(t,e)=>Cs(t,e[0]),hcy:nn,hsi:rn,hsl:sn,hsv:Kt,lab50:tt,lab65:cn,lch:[te,tt],oklab:ln,rgb:L,srgb:Rt,xyy:[(t,e)=>{const{0:n,1:r,2:s}=e;return R(t||e,hn(s*n,r),s,hn(s*(1-n-r),r),$(e[3]))},se],xyz50:re,xyz65:se,ycc:(t,e,n=We)=>{const r=e[0],s=(2-2*n[2])*e[1],i=(2-2*n[0])*e[2];return R(t||e,r+i,r-n[2]/n[1]*s-n[0]/n[1]*i,r+s,$(e[3]))}},toRgb:L}),Gs=(t,e)=>{const n=Lt(fn(t))+.05,r=Lt(fn(e))+.05;return n>r?n/r:r/n},un=t=>{const e=At(p(t[0])*360),n=Ye(y(t[1])),r=Ye(y(t[2])),s=$(t[3]);return s<1?`hsla(${e},${n},${r},${At(s)})`:`hsl(${e},${n},${r})`},Ms=(t,e)=>{t=wt(t||e,e);const n=t[1],r=t[2],s=(2-n)*r/2;return t[2]=s,t[1]=s&&s<1?n*r/(s<.5?s*2:2-s*2):n,t},Is=t=>un(Ms([],t)),dn="0123456789abcdef",oe=t=>dn[t>>>4&15]+dn[t&15],Us=t=>oe(t>>>8)+oe(t&255),xs=t=>oe(t>>>16)+Us(t),ie=Le((t,e,n="")=>{const r=Nr("0",e);return s=>(s=(s>>>0).toString(t),n+(s.length<e?r.substring(s.length)+s:s))});ie(2,8),ie(2,16),ie(2,32);const gn=xs,ae=t=>{const e=t>>>24;return e<255?`rgba(${t>>16&255},${t>>8&255},${t&255},${At(e*M)})`:`#${gn(t&16777215)}`},zs=t=>(t&255)<<16|t>>16&255|t&4278255360,W=(t,e)=>R(t||e,Zt(e[0]),Zt(e[1]),Zt(e[2]),$(e[3])),ce=(t,e=0)=>(t<0?0:t>1?1:t)*255+.5<<e,Y=t=>{const e=ce(t[0]),n=ce(t[1]),r=ce(t[2]),s=$(t[3]);return s<1?`rgba(${e},${n},${r},${At(s)})`:`#${gn(e<<16|n<<8|r)}`},mn={abgr32:t=>ae(zs(t[0])),argb32:t=>ae(t[0]),hsl:un,hsv:Is,lab50:t=>Y(W(null,tt([],t))),lab65:t=>Y(W(null,cn([],t))),lch:t=>Y(W(null,tt(null,te([],t)))),rgb:t=>Y(W([],t)),srgb:Y};({...mn});let Os=mn;const yn=(t,e=Os)=>{let n;return P(t)?t:q(t)?ae(t):t.mode?(n=e[t.mode])?n(t):e.rgb(Je([],t,"rgb",t.mode)):Y(t)},Es=(t,e)=>{t=wt(t||e,e);const n=t[1],r=t[2],s=2*r,i=(s+n*(1-Math.abs(s-1)))*.5;return t[1]=2*(i-r)/i,t[2]=i,t},Fs=(t,e)=>{t=$s(t||e,e);const n=t[1]<t[2]?[t[2],t[1],-1,2/3]:[t[1],t[2],0,-1/3],r=t[0]<n[0]?[n[0],n[1],n[3],t[0]]:[t[0],n[1],n[2],n[0]],s=r[0]-Math.min(r[1],r[3]);return S(t,y(Math.abs((r[3]-r[1])/(6*s+I)+r[2])),y(s),y(r[0]))},le=(t,e)=>(t=Fs(t,e),t[1]/=t[2]+I,t),Ds=pt({mode:"hsv",channels:{h:{hue:!0}},order:["h","s","v","alpha"],from:{rgb:le,srgb:le,hsl:Es,lch:[te,tt,W,le]},toRgb:Kt}),Ct=(t,e=1)=>{const n=(a,o,c)=>{!a&&(a=o);for(let l=o.length;l-- >0;)a[l]=t(o[l],c);return a},r=(a,o,c)=>(!a&&(a=o),a[0]=t(o[0],c),a[1]=t(o[1],c),a),s=(a,o,c)=>(!a&&(a=o),a[0]=t(o[0],c),a[1]=t(o[1],c),a[2]=t(o[2],c),a),i=(a,o,c)=>(!a&&(a=o),a[0]=t(o[0],c),a[1]=t(o[1],c),a[2]=t(o[2],c),a[3]=t(o[3],c),a);return[G(e,n,r,s,i),r,s,i]},[yi,bi,Ns]=Ct(Math.pow),Ts=Ns,qs=[.4122214708,.2119034982,.0883024619,.5363325363,.6806995451,.2817188376,.0514459929,.1073969566,.6299787005],Ps=(t,e)=>$t(null,Yr,Ts(null,$t(t,qs,e),1/3)),bn=(t,e)=>R(t||e,e[0],Math.hypot(e[1],e[2]),on(e[2],e[1])*$r,$(e[3])),js=pt({mode:"oklch",channels:{c:{range:[0,.3225]}},order:["l","c","h","alpha"],from:{oklab:bn,rgb:(t,e)=>bn(null,Ps(t,e))},toRgb:[(t,e)=>R(t||e,e[0],...Qt(e[2]*k,e[1]),$(e[3])),ln]}),An=pt({mode:"srgb",order:["r","g","b","alpha"],from:{abgr32:(t,e)=>tn(t,e[0]),argb32:(t,e)=>_t(t,e[0]),hcy:nn,hsi:rn,hsl:sn,hsv:Kt,rgb:W},toRgb:Rt}),Ls=(t,e)=>t===e?0:t==null?e==null?0:-1:e==null?t==null?0:1:typeof t.compare=="function"?t.compare(e):typeof e.compare=="function"?-e.compare(t):t<e?-1:t>e?1:0,Hs=t=>typeof t=="function"?t:e=>e[t];function _n(t,e=Ls){const n=Hs(t);return(r,s)=>e(n(r),n(s))}const Ws=(t,e)=>e-t,he=(t,e=1,n=!0)=>{const r=n?(o,c,l)=>{!o&&(o=c);for(let h=c.length;h-- >0;)o[h]=t(c[h],l[h]);return o}:(o,c,l)=>{!o&&(o=l);for(let h=c.length;h-- >0;)o[h]=t(c[h],l[h]);return o},s=n?(o,c,l)=>(!o&&(o=c),o[0]=t(c[0],l[0]),o[1]=t(c[1],l[1]),o):(o,c,l)=>(!o&&(o=l),o[0]=t(c[0],l[0]),o[1]=t(c[1],l[1]),o),i=n?(o,c,l)=>(!o&&(o=c),o[0]=t(c[0],l[0]),o[1]=t(c[1],l[1]),o[2]=t(c[2],l[2]),o):(o,c,l)=>(!o&&(o=l),o[0]=t(c[0],l[0]),o[1]=t(c[1],l[1]),o[2]=t(c[2],l[2]),o),a=n?(o,c,l)=>(!o&&(o=c),o[0]=t(c[0],l[0]),o[1]=t(c[1],l[1]),o[2]=t(c[2],l[2]),o[3]=t(c[3],l[3]),o):(o,c,l)=>(!o&&(o=l),o[0]=t(c[0],l[0]),o[1]=t(c[1],l[1]),o[2]=t(c[2],l[2]),o[3]=t(c[3],l[3]),o);return[G(e,r,s,i,a),s,i,a]},Ys=(t,e)=>t+e,Vs=(t,e)=>t*e,Xs=(t,e)=>t-e,[Ks,Zs]=he(Ys),pn=Ks,Js=Zs,Qs=Object.freeze([0,0]),to=Object.freeze([0,0,0]),wn=Math.cos,Rn=Math.sin,$n=G(1);$n.add(2,(t,e,n=Qs)=>Js(t||e,Qt(e[1],e[0]),n)),$n.add(3,(t,e,n=to)=>{const r=e[0],s=e[1],i=e[2],a=wn(s);return S(t||e,r*a*wn(i)+n[0],r*a*Rn(i)+n[1],r*Rn(s)+n[2])});const eo=(t,e)=>{const n=[];for(let r of t)n.push(Qt(r,e));return n},no=t=>_(t.length>0,"no inputs given"),[ro]=Ct(Vs),Cn=ro,so=G(0,t=>{let e=0;for(let n=t.length;n-- >0;)e+=t[n];return e},t=>t[0]+t[1],t=>t[0]+t[1]+t[2],t=>t[0]+t[1]+t[2]+t[3]),oo=(t,e)=>{no(e),t=Zr(t||[],e[0]);for(let n=e.length;n-- >1;)pn(t,t,e[n]);return Cn(t,t,1/e.length)},fe=t=>t.length>0?so(t)/t.length:0,[io]=Ct(Xs),ao=io,vn=(t,e)=>ao(t,e,fe(e)),co=t=>on(t[1],t[0]),lo=G(0,t=>{let e=0;for(let n=t.length;n-- >0;)e+=t[n]*t[n];return e},t=>t[0]*t[0]+t[1]*t[1],t=>t[0]*t[0]+t[1]*t[1]+t[2]*t[2],t=>t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3]),ho=(t,e=!1,n=!1)=>{const r=~~n;return t.length>r?lo(e?t:vn([],t))/(t.length-r):0},ue=(t,e=!1,n=!1)=>Math.sqrt(ho(t,e,n)),de=t=>co(oo([],eo(t))),fo=(t,e)=>{const n=de(e);!t&&(t=[]);for(let r=0,s=e.length;r<s;r++)t[r]=(e[r]-n+Oe)%k;return vn(null,t)},uo=(t,e)=>ue(fo([],t),!0,e);he(Math.max);const go=t=>{let e=-1/0;for(let n=t.length;n-- >0;)e=Math.max(e,t[n]);return e},ge=t=>{if(!t.length)return 0;const e=t.length,n=e>>1;return t=[...t].sort((r,s)=>r-s),e&1?t[n]:(t[n-1]+t[n])*.5};he(Math.min);const mo=t=>{let e=1/0;for(let n=t.length;n-- >0;)e=Math.min(e,t[n]);return e},yo=t=>{const[e,n]=ye(t);return{min:e,max:n,mean:fe(t),median:ge(t),sd:ue(t)}},me=(t,e)=>{const[n,r]=ye(t);return{min:n,max:r,mean:fe(t),median:ge(t),sd:ue(t),weighted:Dr(t,e)}},bo=t=>{const e=t.map(i=>i*k),n=p(de(e)/k),[r,s]=Ao(t,n);return{min:r,max:s,mean:n,median:_o(t,r,s),sd:uo(e)/k}},ye=t=>[mo(t),go(t)],Ao=(t,e)=>{const n=ye(t),[r,s]=n;return e<r||e>s?[t.reduce((i,a)=>{const o=p(e-a);return o<.5&&o>i[1]?[a,o]:i},[s,p(e-s)])[0],t.reduce((i,a)=>{const o=p(a-e);return o<.5&&o>i[1]?[a,o]:i},[r,p(r-e)])[0]]:n},_o=(t,e,n)=>{if(e<=n)return ge(t);const r=t.length,s=r>>1,i=[...t].sort((c,l)=>c-l),a=i.findIndex(c=>c===e),o=i.slice(a).concat(i.slice(0,a));return r&1?o[s]:(o[s-1]+o[s])*.5},po=t=>typeof t=="function",wo=G(0,(t,e)=>{let n=0;for(let r=t.length;r-- >0;){const s=t[r]-e[r];n+=s*s}return n},(t,e)=>{const n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r},(t,e)=>{const n=t[0]-e[0],r=t[1]-e[1],s=t[2]-e[2];return n*n+r*r+s*s},(t,e)=>{const n=t[0]-e[0],r=t[1]-e[1],s=t[2]-e[2],i=t[3]-e[3];return n*n+r*r+s*s+i*i});class Ro{constructor(e){this.metric=e}to(e){return e*e}from(e){return Math.sqrt(e)}}const be=new Ro(wo),Sn=(t,e,n=be)=>{const r=po(n)?n:n.metric;let s=1/0,i=-1;for(let a=0,o=e.length;a<o;a++){const c=r(t,e[a]);c<s&&(s=c,i=a)}return i};G(0,(t,e)=>{for(let n=t.length;n-- >0;)t[n]=e;return t},(t,e)=>(t[0]=e,t[1]=e,t),(t,e)=>(t[0]=e,t[1]=e,t[2]=e,t),(t,e)=>(t[0]=e,t[1]=e,t[2]=e,t[3]=e,t));const $o=t=>Array(t).fill(0),Co=t=>Array(t).fill(1),vo=(t,e,n={})=>{let{dim:r=e[0].length,dist:s=be,maxIter:i=32,strategy:a=Go,exponent:o,initial:c,rnd:l}=n;const h=e.length,u=Array.isArray(c)?c:c?c(t,e,s,l):So(t,e,s,l,o);_(u.length>0,"missing initial centroids"),t=u.length;const f=new Uint32Array(h).fill(t);let d=!0;for(;d&&i-- >0&&(d=Bo(e,u,f,s),!!d);)for(let g=0;g<t;g++){const m=a(r);for(let A=0;A<h;A++)g===f[A]&&m.update(e[A]);const b=m.finish();b&&(u[g]=b)}return ko(u,f)},So=(t,e,n=be,r=Yt,s=2)=>{const i=e.length;_(i>0,"missing samples"),t=Math.min(t,i);const a=[r.int()%i],o=[e[a[0]]],c=new Array(i).fill(0).map((h,u)=>u),l=n.metric;for(;a.length<t;){let h=0;const u=e.map(d=>{const g=n.from(l(d,o[Sn(d,o,n)]))**s;return h+=g,g});if(!h)break;let f;do f=ds(c,u,r)();while(a.includes(f));a.push(f),o.push(e[f])}return o},Bo=(t,e,n,r)=>{let s=!1;for(let i=t.length;i-- >0;){const a=Sn(t[i],e,r);a!==n[i]&&(n[i]=a,s=!0)}return s},ko=(t,e)=>{const n=[];for(let r=0,s=e.length;r<s;r++){const i=e[r];(n[i]||(n[i]={id:i,centroid:t[i],items:[]})).items.push(r)}return n.filter(r=>!!r)},Go=t=>{const e=$o(t);let n=0;return{update:r=>{pn(e,e,r),n++},finish:()=>n?Cn(e,e,1/n):void 0}},Mo=(t,e)=>{const n=[];let r=0;for(let s of e)t(s,r)&&n.push(s),r++;return n},Bn=(t,e,n)=>{const r=n?.filter?Mo(n.filter,t):Array.isArray(t)?t:[...t];return r.length?vo(Math.min(e,r.length),r,n).sort((s,i)=>i.items.length-s.items.length).map(s=>({color:[...s.centroid],area:s.items.length/r.length,ids:s.items})):[]},Ae=t=>typeof t?.[Symbol.iterator]=="function",kn=(t,e)=>[t[0],t[1],e],_e=Symbol(),Gn=()=>{},vt=t=>J(t,"xform")?t.xform():t,Io=ot(()=>"illegal arity"),pe=t=>{throw new Io(t)};class St{value;constructor(e){this.value=e}deref(){return this.value}}const V=t=>t instanceof St,Uo=t=>t instanceof St?t:new St(t),et=t=>t instanceof St?t.deref():t,xo=t=>t.length===2?[void 0,t[1]]:t.length===3?[t[1],t[2]]:pe(t.length);function Bt(...t){const e=t[0],n=e[0],r=e[1],s=e[2];t=xo(t);const i=t[0]==null?n():t[0],a=t[1];return et(r(J(a,"$reduce")?a.$reduce(s,i):Ht(a)?zo(s,i,a):Oo(s,i,a)))}const zo=(t,e,n)=>{for(let r=0,s=n.length;r<s;r++)if(e=t(e,n[r]),V(e)){e=e.deref();break}return e},Oo=(t,e,n)=>{for(let r of n)if(e=t(e,r),V(e)){e=e.deref();break}return e},we=(t,e)=>[t,it,e],kt=(t,e)=>{const n=e.length-1;return Ae(e[n])?e.length>1?Bt(t.apply(null,e.slice(0,n)),e[n]):Bt(t(),e[0]):void 0};function Mn(t){return t?[...t]:we(()=>[],(e,n)=>(e.push(n),e))}function*Eo(t,e){const n=vt(t)(Mn()),r=n[1],s=n[2];for(let i of e){const a=s([],i);if(V(a)){yield*et(r(a.deref()));return}a.length&&(yield*a)}yield*et(r([]))}function*Fo(t,e){const n=vt(t)([Gn,Gn,(r,s)=>s])[2];for(let r of e){let s=n(_e,r);if(V(s)){s=et(s.deref()),s!==_e&&(yield s);return}s!==_e&&(yield s)}}function nt(t,e){return Ae(e)?Fo(nt(t),e):n=>{const r=n[2];return kn(n,(s,i)=>r(s,t(i)))}}function In(t){return t?Bt(In(),t):we(()=>-1/0,(e,n)=>Math.max(e,n))}const Un=t=>((t==null||!t[Symbol.iterator])&&Wt(`value is not iterable: ${t}`),t),Do=t=>Ke(t)?t:[...Un(t)],No=t=>Ht(t)?t:[...Un(t)];function*To(...t){const e=t.length-1;if(e<0)return;const n=new Array(e+1).fill(0),r=t.map(No),s=r.reduce((i,a)=>i*a.length,1);for(let i=0;i<s;i++){const a=[];for(let o=e;o>=0;o--){const c=r[o];let l=n[o];l===c.length&&(n[o]=l=0,o>0&&n[o-1]++),a[o]=c[l]}n[e]++,yield a}}function Re(...t){return qo(Re,Bt,t)}const qo=(t,e,n)=>{let r,s;switch(n.length){case 4:s=n[3],r=n[2];break;case 3:s=n[2];break;case 2:return nt(i=>t(n[0],n[1],i));default:pe(n.length)}return e(vt(n[0])(n[1]),r,s)},[Po]=Ct(De),jo=Po,xn=(t,e,n)=>Lo(y((n-t)/(e-t))),Lo=t=>t*t*(3-2*t);function zn(...t){let[e,n,r,s,i,a,o,c,l,h]=t;switch(t.length){case 0:pe(0);case 1:return e;case 2:return(...f)=>e(n(...f));case 3:return(...f)=>e(n(r(...f)));case 4:return(...f)=>e(n(r(s(...f))));case 5:return(...f)=>e(n(r(s(i(...f)))));case 6:return(...f)=>e(n(r(s(i(a(...f))))));case 7:return(...f)=>e(n(r(s(i(a(o(...f)))))));case 8:return(...f)=>e(n(r(s(i(a(o(c(...f))))))));case 9:return(...f)=>e(n(r(s(i(a(o(c(l(...f)))))))));case 10:default:const u=(...f)=>e(n(r(s(i(a(o(c(l(h(...f))))))))));return t.length===10?u:zn(u,...t.slice(10))}}function Ho(...t){return t=t.map(vt),zn.apply(null,t)}function On(...t){const e=kt(On,t);if(e!==void 0)return e;const[n=0,r=1]=t;return we(()=>n,(s,i)=>s+r)}const Wo=t=>t,Yo=t=>({key:e=>e,group:Mn(),...t});function En(...t){const e=kt(En,t);if(e!==void 0)return e;const n=Yo(t[0]),[r,s,i]=n.group;return[()=>new Map,a=>{for(let o of a.keys())a.set(o,s(a.get(o)));return a},(a,o)=>{const c=n.key(o);return a.set(c,a.has(c)?i(a.get(c),o):i(r(),o))}]}function Fn(...t){return kt(Fn,t)||En({key:t[0]||Wo,group:On()})}function Dn(...t){const e=kt(Dn,t);if(e!==void 0)return e;const[n,r,s]=Fn(...t);let i=0;return[n,a=>{a=r(a);for(let o of a)a.set(o[0],o[1]/i);return a},(a,o)=>(i++,s(a,o))]}const Vo=()=>t=>{const e=t[2];return kn(t,(n,r)=>{if(r){for(let s of et(r)||[])if(n=e(n,s),V(n))break}return V(r)?Uo(n):n})};function Nn(t,e){return Ae(e)?Eo(Nn(t),e):Ho(nt(t),Vo())}function*Xo(t,e=1/0){for(;e-- >0;)yield t}const Tn=(t,e=.2,n)=>{const r=Do(t),s=r.filter(u=>u[1]>=e),i=s.length/r.length,a=[...Re(nt(u=>De(u[0],1/12)%1),Dn(),s)].sort(_n(0)),o=[...Nn(([u,f])=>(f*=50,f>=1?Xo(u*k,f):null),a)];if(!o.length)return{hues:a,meanHue:0,temp:0,areaTemp:0,area:0};const c=de(o)/k,l=Zo(c,n),h=l*i;return{hues:a,meanHue:c,temp:l,areaTemp:h,area:i}},Ko=[.1,.6,.72,.92],Zo=(t,[e,n,r,s]=Ko)=>2*(t<2/3?xn(n,e,t):xn(r,s,t))-1,Jo=(t,e)=>{let n=t.format!==j?t.as(j):t;e?.size&&(n=ei(n,e.size));const r=n.as(Ue),s=n.as(Or),i=ti(n,e),a=i.map(l=>l.area),o=Qo(i.map(l=>l.color),a,e?.minSat,e?.tempCoeffs),c=yo(r.data);return{...o,img:n,imgGray:r,imgHsv:s,lumImg:c,temperature:Tn(s,e?.minSat,e?.tempCoeffs),contrastImg:c.max-c.min}},Qo=(t,e=Co(t.length),n,r)=>{const s=t.map(f=>Vr(f)),i=t.map(f=>An(f)),a=i.map(f=>Ds(f)),o=i.map(f=>js(f)),c=i.map(f=>yn(f)),l=a.map(f=>f[0]),h=a.map(f=>f[1]),u=me(s,e);return{css:c,srgb:i,hsv:a,oklch:o,hue:bo(l),sat:me(h,e),chroma:me(o.map(f=>f[1]),e),lum:u,areas:e,contrast:u.max-u.min,colorContrast:xr(Re(nt(f=>Gs(...f)),In(),To(i,i)),1,21,0,1),temperature:Tn(a,n,r)}},ti=(t,{dominantFn:e=Bn,numColors:n=4,prec:r=.001}={})=>e(t,n).sort(_n("area",Ws)).map(s=>(jo(null,s.color,r),s)),ei=(t,e)=>{e=~~e;let n=t.width,r=t.height;return[n,r]=n>r?[e,~~Math.max(1,r/n*e)]:[~~Math.max(1,n/r*e),e],t.resize(n,r)};/**\n * Options for extracting colors / evaluating lightness from an image.\n *\n * @typedef {Object} ImageAnalysisResult\n * @property {boolean} isDark - Whether the image is considered dark overall.\n * @property {boolean} isTransparent - Whether the image has any transparency.\n * @property {{ any: boolean, left: boolean, right: boolean, top: boolean, bottom: boolean }} transparencyInfo - More detailed transparency info.\n * @property {Array<{ color: string, area: number, isDark: boolean }>} dominantColors - Dominant colors extracted from the image.\n * @property {Array} dominantColors.<index>.color - The color value.\n * @property {Array} dominantColors.<index>.area - The area occupied by this color (0 - 1).\n * @property {Array} dominantColors.<index>.isDark - Whether this color is considered dark.\n *\n * @preserve\n *//**\n * Options for extracting colors / evaluating lightness from an image.\n *\n * @typedef {Object} ImageAnalysisSettings\n * @property {number} [numColors=2] - Number of dominant colors to return.\n * @property {number} [lightnessThreshold=0.5] - Threshold (0.0 - 1.0) used to decide if a color is considered "light".\n * @property {number} [yFrom=0.0] - Minimum Y (luminance) value (0.0 - 1.0) to include when evaluating lightness.\n * @property {number} [yTo=1.0] - Maximum Y (luminance) value (0.0 - 1.0) to include when evaluating lightness.\n * @property {number} [maxSize=320] - Maximum width/height to scale down the image to before analysis, for performance.\n * @property {number} [alphaThreshold=30] - Threhold (0-255) below which a pixel is considered "transparent" for the purposes of analysis.\n *\n * @preserve\n */const ni={numColors:3,lightnessThreshold:.5,yFrom:0,yTo:1,maxSize:320,alphaThreshold:30};/**\n * Check image transparency by analyzing pixel alpha values.\n *\n * @param {Uint8ClampedArray} imageData - The image data array containing RGBA values.\n * @param {number} w - The width of the image.\n * @param {number} h - The height of the image.\n * @param {ImageAnalysisSettings} [settings] - Optional settings to customize the transparency check.\n *\n * @return {{ any: boolean, left: boolean, right: boolean, top: boolean, bottom: boolean }} An object indicating transparency on different sides of the image.\n *\n * @preserve\n */const ri=(t,e,n,r={})=>{const{alphaThreshold:s}={...ni,...r},i={any:!0,left:!0,right:!0,top:!0,bottom:!0};let a={any:0,left:0,right:0,top:0,bottom:0};const o=Math.floor(.15*e),c=Math.floor((n>100?.05:.5)*n),l=Math.floor(e*n*.001);if(e>0&&n>0){for(let h=0;h<e;h++){const u=(0*e+h)*4+3;if(t[u]>s&&(a.top++,a.top>=o)){i.top=!1;break}}for(let h=0;h<e;h++){const u=((n-1)*e+h)*4+3;if(t[u]>s&&(a.bottom++,a.bottom>=o)){i.bottom=!1;break}}for(let h=0;h<n;h++){const u=(h*e+0)*4+3;if(t[u]>s&&(a.left++,a.left>=c)){i.left=!1;break}}for(let h=0;h<n;h++){const u=(h*e+(e-1))*4+3;if(t[u]>s&&(a.right++,a.right>=c)){i.right=!1;break}}if(!i.top&&!i.bottom&&!i.left&&!i.right){for(let h=3;h<t.length;h+=4)if(t[h]>s&&(a.any++,a.any>=l)){i.any=!1;break}}else i.any=!0}return i};/**\n * Determine if a color is considered "dark" based on its RGB values and a lightness threshold.\n *\n * @param {number} r - Red component (0-255).\n * @param {number} g - Green component (0-255).\n * @param {number} b - Blue component (0-255).\n * @param {number} [threshold=0.5] - Lightness threshold (0.0 - 1.0) below which the color is considered dark.\n *\n * @returns {boolean} True if the color is dark, false otherwise.\n *\n * @example\n * isColorDark(0, 0, 0); // true (black)\n * isColorDark(255, 255, 255); // false (white)\n * isColorDark(100, 100, 100, 0.4); // false (gray with higher threshold)\n *\n * @preserve\n */const si=(t,e,n,r=.5)=>(.299*t+.587*e+.114*n)/255<r;/**\n * Core analysis logic shared by both main thread and worker.\n *\n * @param {Object} options - Configuration options\n * @prop {Float32Array} buffer - Float32Array RGBA buffer (from floatBufferFromCanvas)\n * @prop {Uint8ClampedArray} imageData - Uint8ClampedArray (from getImageData)\n * @prop {number} width - Image width\n * @prop {number} height - Image height\n * @prop {ImageAnalysisSettings} settings - Analysis settings\n * @prop {boolean} skipTransparencyCheck - Boolean to skip transparency check\n *\n * @returns {ImageAnalysisResult}\n *\n * @preserve\n */const oi=({buffer:t,imageData:e,width:n,height:r,settings:s,skipTransparencyCheck:i=!1})=>{const{numColors:a,lightnessThreshold:o}=s,c=Jo(t,{numColors:a,dominantFn:(d,g)=>Bn(d,g,{filter:m=>An(m).alpha>0}),prec:.01}),{lumImg:l,srgb:h,areas:u}=c;let f=!1;return!i&&e&&(f=ri(e,n,r,s)),{isDark:l.mean<o,isTransparent:i?!1:f?.any,transparencyInfo:i?null:f,dominantColors:h.map(({r:d,g,b:m},b)=>({color:yn([d,g,m]),area:u?.[b],isDark:si(d*255,g*255,m*255,o)}))}};self.onmessage=async t=>{const{imageBitmap:e,settings:n}=t.data;try{const r=await ii(e,n);self.postMessage({success:!0,data:r})}catch(r){self.postMessage({success:!1,error:r.message,stack:r.stack})}};async function ii(t,e){const r={...{numColors:3,lightnessThreshold:.5,yFrom:0,yTo:1,maxSize:320,alphaThreshold:30},...e},{yFrom:s,yTo:i,maxSize:a}=r,o=t.width,c=t.height;if(!o||!c)return!1;let l=1;(o>a||c>a)&&(l=Math.min(a/o,a/c));const h=Math.floor(o*l),u=Math.floor(c*l),f=0,d=Math.floor(s*c),g=Math.max(1,o),m=Math.max(1,Math.ceil((i-s)*c)),b=Math.max(1,h),A=Math.max(1,Math.ceil((i-s)*u)),E=new OffscreenCanvas(b,A);E.getContext("2d").drawImage(t,f,d,g,m,0,0,b,A);const Gt=Ir(E,j),qn=new OffscreenCanvas(h,u).getContext("2d");qn.drawImage(t,0,0,o,c,0,0,h,u);const ai=qn.getImageData(0,0,h,u).data;return oi({buffer:Gt,imageData:ai,width:h,height:u,settings:r})}})();\n';
2
2
  export {
3
3
  workerInline as default
4
4
  };
@@ -1,19 +1,19 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { e as $880e95eb8b93ba9a$export$ecf600387e221c37, m as $ae20dd8cbca75726$export$d6daf82dcd84e87c, f as $e1995378a142960e$export$18af5c7a9e9b3664, h as $e1995378a142960e$export$fb8073518f34e6ec, j as $7135fc7d473fd974$export$4feb769f8ddf26c5, n as $7135fc7d473fd974$export$a164736487e3f0ae, g as $e1995378a142960e$export$bf788dd355e3a401, o as $23b9f4fcf0fe224b$export$d68d59712b04d9d1, p as $7135fc7d473fd974$export$90e00781bc59d8f9 } from "../../SelectionManager-D77bfEbg.js";
2
+ import { e as $880e95eb8b93ba9a$export$ecf600387e221c37, m as $ae20dd8cbca75726$export$d6daf82dcd84e87c, f as $e1995378a142960e$export$18af5c7a9e9b3664, h as $e1995378a142960e$export$fb8073518f34e6ec, j as $7135fc7d473fd974$export$4feb769f8ddf26c5, n as $7135fc7d473fd974$export$a164736487e3f0ae, g as $e1995378a142960e$export$bf788dd355e3a401, o as $23b9f4fcf0fe224b$export$d68d59712b04d9d1, p as $7135fc7d473fd974$export$90e00781bc59d8f9 } from "../../SelectionManager-B6-b5NM2.js";
3
3
  import { k as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c, b as $3ef42575df84b30b$export$9d1611c77c2fe928, d as $bdb11010cef70236$export$f680877a34711e37, l as $df56164dff5785e2$export$4338b53315abf666, h as $64fa3d84918910a7$export$4d86445c2cf5e3, i as $64fa3d84918910a7$export$2881499e37b75b9a, a as $64fa3d84918910a7$export$29f1550f4b0d4415, $ as $64fa3d84918910a7$export$fabf2dc03a41866e } from "../../utils-cvK1vxO7.js";
4
4
  import { $ as $1d5b8b8664671ef2$export$c9549807523555e0 } from "../../SelectionIndicator-D7WMzeAW.js";
5
- import { $ as $c8a5a149f625efcf$export$758399f318e6385a } from "../../SharedElementTransition-BjRNHsjx.js";
5
+ import { $ as $c8a5a149f625efcf$export$758399f318e6385a } from "../../SharedElementTransition-fML-zIv6.js";
6
6
  import { $ as $f39a9eba43920ace$export$86427a43e3e48ebb } from "../../Hidden-rE6uR-lr.js";
7
7
  import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "../../filterDOMProps-D2C6R0DK.js";
8
- import { b as $cdc5a6778b766db2$export$a9d04c5684123369 } from "../../useListState-DZycqxCn.js";
8
+ import { b as $cdc5a6778b766db2$export$a9d04c5684123369 } from "../../useListState-RdLrYsMP.js";
9
9
  import React__default, { useState, useMemo, useRef, useEffect, forwardRef, useContext, createContext, isValidElement, useId, cloneElement } from "react";
10
- import { a as $ea8dcbcb9ea1b556$export$7e924b3091a3bd18 } from "../../usePress-BCEPS3hl.js";
10
+ import { a as $ea8dcbcb9ea1b556$export$7e924b3091a3bd18 } from "../../usePress-DJskZBH9.js";
11
11
  import { $ as $f645667febf57a63$export$4c014de7c8940b4c, w as $6179b936705e76d3$export$ae780daf29e6d456 } from "../../useHover-BRDW3y7-.js";
12
12
  import { $ as $313b98861ee5dd6c$export$d6875122194c7b44 } from "../../useLabels-Cdxi6JSa.js";
13
13
  import { a as $9bf71ea28793e738$export$2d6ec8fc375ceafa } from "../../FocusScope-B5vxRkHm.js";
14
14
  import { $ as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7 } from "../../context-DMOmz986.js";
15
15
  import { a as $f7dceffc5ad7768b$export$4e328f61c538687f } from "../../useFocusRing-Cgm0R4Cf.js";
16
- import { $ as $a0d645289fe9b86b$export$e7f05e985daf4b5f } from "../../useSingleSelectListState-BFZEfeqI.js";
16
+ import { $ as $a0d645289fe9b86b$export$e7f05e985daf4b5f } from "../../useSingleSelectListState-n0AVMr3Y.js";
17
17
  import { s as sprintf } from "../../sprintf-DmNrJSYG.js";
18
18
  import { _ as __ } from "../../default-i18n-DBm-GqWM.js";
19
19
  import { c as clsx } from "../../lite-DVmmD_-j.js";
@@ -3,7 +3,7 @@ import { a as $64fa3d84918910a7$export$29f1550f4b0d4415, l as $df56164dff5785e2$
3
3
  import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "../../filterDOMProps-D2C6R0DK.js";
4
4
  import React__default, { forwardRef, createContext } from "react";
5
5
  import { $ as $3017fa7ffdddec74$export$8042c6c013fd5226 } from "../../useToggleState-CzN79ary.js";
6
- import { $ as $d2c8e2b0480f3f34$export$cbe85ee05b554577 } from "../../useToggle-DNoP2bvV.js";
6
+ import { $ as $d2c8e2b0480f3f34$export$cbe85ee05b554577 } from "../../useToggle-DSBDAfdw.js";
7
7
  import { a as $f7dceffc5ad7768b$export$4e328f61c538687f } from "../../useFocusRing-Cgm0R4Cf.js";
8
8
  import { w as $6179b936705e76d3$export$ae780daf29e6d456 } from "../../useHover-BRDW3y7-.js";
9
9
  import { $ as $5c3e21d68f1c4674$export$439d29a4e110a164 } from "../../VisuallyHidden-CgnIuZJ2.js";
@@ -4,7 +4,7 @@ import { $ as $1d5b8b8664671ef2$export$c9549807523555e0 } from "../../SelectionI
4
4
  import React__default, { createContext, forwardRef, useContext } from "react";
5
5
  import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "../../filterDOMProps-D2C6R0DK.js";
6
6
  import { $ as $3017fa7ffdddec74$export$8042c6c013fd5226 } from "../../useToggleState-CzN79ary.js";
7
- import { $ as $701a24aa0da5b062$export$ea18c227d4417cc3 } from "../../useButton-B2EaQJT_.js";
7
+ import { $ as $701a24aa0da5b062$export$ea18c227d4417cc3 } from "../../useButton-v9ngEj50.js";
8
8
  import { a as $f7dceffc5ad7768b$export$4e328f61c538687f } from "../../useFocusRing-Cgm0R4Cf.js";
9
9
  import { w as $6179b936705e76d3$export$ae780daf29e6d456 } from "../../useHover-BRDW3y7-.js";
10
10
  import { c as cva } from "../../index-Dq3gT5pW.js";
@@ -1,11 +1,11 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { $ as $fc909762b330b746$export$61c6a8c84e605fb6, a as $d3f049242431219c$export$45fda7c47f93fd48, c as $2a41e45df1593e64$export$d39e1813b3bdd0e1, b as $d3f049242431219c$export$6d3443f2c48bfc20, d as $44f671af83e7d9e0$export$2de4954e8ae13b9f, e as $44f671af83e7d9e0$export$746d02f47f4d381 } from "../../OverlayArrow-DDfa8khI.js";
2
+ import { $ as $fc909762b330b746$export$61c6a8c84e605fb6, a as $d3f049242431219c$export$45fda7c47f93fd48, c as $2a41e45df1593e64$export$d39e1813b3bdd0e1, b as $d3f049242431219c$export$6d3443f2c48bfc20, d as $44f671af83e7d9e0$export$2de4954e8ae13b9f, e as $44f671af83e7d9e0$export$746d02f47f4d381 } from "../../OverlayArrow-DraDOoRn.js";
3
3
  import { n as $b5e257d569688ac6$export$535bd6ca7f90a273, b as $3ef42575df84b30b$export$9d1611c77c2fe928, d as $bdb11010cef70236$export$f680877a34711e37, i as $64fa3d84918910a7$export$2881499e37b75b9a, a as $64fa3d84918910a7$export$29f1550f4b0d4415, h as $64fa3d84918910a7$export$4d86445c2cf5e3 } from "../../utils-cvK1vxO7.js";
4
4
  import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "../../filterDOMProps-D2C6R0DK.js";
5
5
  import { w as $6179b936705e76d3$export$ae780daf29e6d456, $ as $f645667febf57a63$export$4c014de7c8940b4c, u as $507fabe10e71c6fb$export$630ff653c5ada6a9, l as $507fabe10e71c6fb$export$b9b3dfddab17db27, y as $f645667febf57a63$export$13f3202a3e5ddd5 } from "../../useHover-BRDW3y7-.js";
6
6
  import React__default, { useContext, useState, useMemo, useRef, useEffect, forwardRef, createContext } from "react";
7
7
  import { a as $96b38030c423d352$export$9fc1347d4195ccb3 } from "../../PortalProvider---wyKpMr.js";
8
- import { $ as $dbSRa$reactdom } from "../../index-DjyEH0Gg.js";
8
+ import { $ as $dbSRa$reactdom } from "../../index-D8-Zjpbd.js";
9
9
  import { c as clsx } from "../../lite-DVmmD_-j.js";
10
10
  const $f57aed4a881a3485$var$Context = /* @__PURE__ */ React__default.createContext(null);
11
11
  function $f57aed4a881a3485$export$178405afcd8c5eb(props) {
@@ -1,4 +1,4 @@
1
- import { s as sha256Exports } from "./sha256-C56UDWfQ.js";
1
+ import { cyrb64Hash } from "./utilities/hash.js";
2
2
  var Lane = /* @__PURE__ */ ((Lane2) => {
3
3
  Lane2[Lane2["ALPHA"] = 0] = "ALPHA";
4
4
  Lane2[Lane2["BLUE"] = 1] = "BLUE";
@@ -3955,7 +3955,7 @@ const defaultAnalysisSettings = {
3955
3955
  const analyzeImage = (image, rawSettings) => {
3956
3956
  const settings = { ...defaultAnalysisSettings, ...rawSettings };
3957
3957
  const { yFrom, yTo, maxSize } = settings;
3958
- const cacheKey = `es-uic-img-analysis-${sha256Exports.sha256(image.src)}`;
3958
+ const cacheKey = `es-uic-img-analysis-${cyrb64Hash(image.src)}`;
3959
3959
  if (localStorage?.getItem(cacheKey)) {
3960
3960
  return JSON.parse(localStorage.getItem(cacheKey));
3961
3961
  }
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { forwardRef, useContext, useLayoutEffect, useRef, useState, useMemo, useCallback, createContext } from "react";
3
- import { r as reactDomExports } from "./index-DjyEH0Gg.js";
3
+ import { r as reactDomExports } from "./index-D8-Zjpbd.js";
4
4
  function _typeof(o) {
5
5
  "@babel/helpers - typeof";
6
6
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
@@ -1,5 +1,7 @@
1
- import { a as getDefaultExportFromCjs } from "./_commonjsHelpers-BhWcALO8.js";
2
1
  import React__default from "react";
2
+ function getDefaultExportFromCjs(x) {
3
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
4
+ }
3
5
  var reactDom = { exports: {} };
4
6
  var reactDom_production_min = {};
5
7
  var scheduler = { exports: {} };
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import React__default, { useLayoutEffect, useEffect, useRef, useMemo, useCallback, useState, createContext, memo, useReducer, useContext } from "react";
3
- import { r as reactDomExports } from "./index-DjyEH0Gg.js";
3
+ import { r as reactDomExports } from "./index-D8-Zjpbd.js";
4
4
  import { c as clsx } from "./lite-DVmmD_-j.js";
5
5
  function useCombinedRefs() {
6
6
  for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
@@ -1,8 +1,8 @@
1
- import { a as _objectWithoutProperties, b as _slicedToArray, h as handleInputChange, d as _objectSpread2, e as _defineProperty, _ as _extends } from "./index-641ee5b8.esm-DiwvO-RP.js";
1
+ import { a as _objectWithoutProperties, b as _slicedToArray, h as handleInputChange, d as _objectSpread2, e as _defineProperty, _ as _extends } from "./index-641ee5b8.esm-DVp0njHa.js";
2
2
  import * as React from "react";
3
3
  import { useRef, useState, useEffect, useCallback, forwardRef } from "react";
4
- import { u as useStateManager, S as Select } from "./Select-ef7c0426.esm-BJmjGGzK.js";
5
- import "./index-DjyEH0Gg.js";
4
+ import { u as useStateManager, S as Select } from "./Select-ef7c0426.esm-CmTkSxDx.js";
5
+ import "./index-D8-Zjpbd.js";
6
6
  var _excluded = ["defaultOptions", "cacheOptions", "loadOptions", "options", "isLoading", "onInputChange", "filterOption"];
7
7
  function useAsync(_ref) {
8
8
  var _ref$defaultOptions = _ref.defaultOptions, propsDefaultOptions = _ref$defaultOptions === void 0 ? false : _ref$defaultOptions, _ref$cacheOptions = _ref.cacheOptions, cacheOptions = _ref$cacheOptions === void 0 ? false : _ref$cacheOptions, propsLoadOptions = _ref.loadOptions;
@@ -1,8 +1,8 @@
1
- import { u as useStateManager, S as Select } from "./Select-ef7c0426.esm-BJmjGGzK.js";
2
- import { _ as _extends } from "./index-641ee5b8.esm-DiwvO-RP.js";
1
+ import { u as useStateManager, S as Select } from "./Select-ef7c0426.esm-CmTkSxDx.js";
2
+ import { _ as _extends } from "./index-641ee5b8.esm-DVp0njHa.js";
3
3
  import * as React from "react";
4
4
  import { forwardRef } from "react";
5
- import "./index-DjyEH0Gg.js";
5
+ import "./index-D8-Zjpbd.js";
6
6
  var StateManagedSelect = /* @__PURE__ */ forwardRef(function(props, ref) {
7
7
  var baseSelectProps = useStateManager(props);
8
8
  return /* @__PURE__ */ React.createElement(Select, _extends({