+24
README.md
+24
README.md
···
1
+
# locator_colour
2
+
3
+
[](https://hex.pm/packages/locator_colour)
4
+
[](https://hexdocs.pm/locator_colour/)
5
+
6
+
```sh
7
+
gleam add locator_colour@1
8
+
```
9
+
```gleam
10
+
import locator_colour
11
+
12
+
pub fn main() {
13
+
// TODO: An example of the project in use
14
+
}
15
+
```
16
+
17
+
Further documentation can be found at <https://hexdocs.pm/locator_colour>.
18
+
19
+
## Development
20
+
21
+
```sh
22
+
gleam run # Run the project
23
+
gleam test # Run the tests
24
+
```
+24
gleam.toml
+24
gleam.toml
···
1
+
name = "locator_colour"
2
+
version = "1.0.0"
3
+
target = "javascript"
4
+
runtime = "bun"
5
+
6
+
# Fill out these fields if you intend to generate HTML documentation or publish
7
+
# your project to the Hex package manager.
8
+
#
9
+
# description = ""
10
+
# licences = ["Apache-2.0"]
11
+
# repository = { type = "github", user = "", repo = "" }
12
+
# links = [{ title = "Website", href = "" }]
13
+
#
14
+
# For a full reference of all the available options, you can have a look at
15
+
# https://gleam.run/writing-gleam/gleam-toml/.
16
+
17
+
[dependencies]
18
+
gleam_stdlib = ">= 0.44.0 and < 2.0.0"
19
+
bigi = ">= 3.2.1 and < 4.0.0"
20
+
lustre = ">= 4.6.4 and < 5.0.0"
21
+
22
+
[dev-dependencies]
23
+
gleeunit = ">= 1.0.0 and < 2.0.0"
24
+
lustre_dev_tools = ">= 1.7.0 and < 2.0.0"
+15
index.html
+15
index.html
···
1
+
<!doctype html>
2
+
<html lang="en">
3
+
<head>
4
+
<meta charset="UTF-8" />
5
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+
7
+
<title>🎨 Locator Bar Colour Generator</title>
8
+
9
+
<script type="module" src="/priv/static/locator_colour.min.mjs"></script>
10
+
</head>
11
+
12
+
<body style="margin: 0px">
13
+
<div id="app"></div>
14
+
</body>
15
+
</html>
+50
manifest.toml
+50
manifest.toml
···
1
+
# This file was generated by Gleam
2
+
# You typically do not need to edit this file
3
+
4
+
packages = [
5
+
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
6
+
{ name = "bigi", version = "3.2.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "bigi", source = "hex", outer_checksum = "13AA60457C0001DB27E4B79518D3F77816115C07A952F6C9C74B715F49481B46" },
7
+
{ name = "directories", version = "1.1.0", build_tools = ["gleam"], requirements = ["envoy", "gleam_stdlib", "platform", "simplifile"], otp_app = "directories", source = "hex", outer_checksum = "BDA521A4EB9EE3A7894F0DC863797878E91FF5C7826F7084B2E731E208BDB076" },
8
+
{ name = "envoy", version = "1.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "envoy", source = "hex", outer_checksum = "95FD059345AA982E89A0B6E2A3BF1CF43E17A7048DCD85B5B65D3B9E4E39D359" },
9
+
{ name = "exception", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "exception", source = "hex", outer_checksum = "F5580D584F16A20B7FCDCABF9E9BE9A2C1F6AC4F9176FA6DD0B63E3B20D450AA" },
10
+
{ name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" },
11
+
{ name = "fs", version = "11.4.1", build_tools = ["rebar3"], requirements = [], otp_app = "fs", source = "hex", outer_checksum = "DD00A61D89EAC01D16D3FC51D5B0EB5F0722EF8E3C1A3A547CD086957F3260A9" },
12
+
{ name = "gleam_community_ansi", version = "1.4.3", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_regexp", "gleam_stdlib"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "8A62AE9CC6EA65BEA630D95016D6C07E4F9973565FA3D0DE68DC4200D8E0DD27" },
13
+
{ name = "gleam_community_colour", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_json", "gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "FDD6AC62C6EC8506C005949A4FCEF032038191D5EAAEC3C9A203CD53AE956ACA" },
14
+
{ name = "gleam_crypto", version = "1.5.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_crypto", source = "hex", outer_checksum = "917BC8B87DBD584830E3B389CBCAB140FFE7CB27866D27C6D0FB87A9ECF35602" },
15
+
{ name = "gleam_deque", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_deque", source = "hex", outer_checksum = "64D77068931338CF0D0CB5D37522C3E3CCA7CB7D6C5BACB41648B519CC0133C7" },
16
+
{ name = "gleam_erlang", version = "0.34.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "0C38F2A128BAA0CEF17C3000BD2097EB80634E239CE31A86400C4416A5D0FDCC" },
17
+
{ name = "gleam_http", version = "4.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "0A62451FC85B98062E0907659D92E6A89F5F3C0FBE4AB8046C99936BF6F91DBC" },
18
+
{ name = "gleam_httpc", version = "4.1.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_http", "gleam_stdlib"], otp_app = "gleam_httpc", source = "hex", outer_checksum = "1A38507AF26CACA145248733688703EADCB734EA971D4E34FB97B7613DECF132" },
19
+
{ name = "gleam_json", version = "2.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "C55C5C2B318533A8072D221C5E06E5A75711C129E420DD1CE463342106012E5D" },
20
+
{ name = "gleam_otp", version = "0.16.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "50DA1539FC8E8FA09924EB36A67A2BBB0AD6B27BCDED5A7EF627057CF69D035E" },
21
+
{ name = "gleam_package_interface", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_json", "gleam_stdlib"], otp_app = "gleam_package_interface", source = "hex", outer_checksum = "C2D2CA097831D27A20DAFA62D44F5D1B12E8470272337FD133368ACA4969A317" },
22
+
{ name = "gleam_regexp", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_regexp", source = "hex", outer_checksum = "9C215C6CA84A5B35BB934A9B61A9A306EC743153BE2B0425A0D032E477B062A9" },
23
+
{ name = "gleam_stdlib", version = "0.59.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "F8FEE9B35797301994B81AF75508CF87C328FE1585558B0FFD188DC2B32EAA95" },
24
+
{ name = "gleam_yielder", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_yielder", source = "hex", outer_checksum = "8E4E4ECFA7982859F430C57F549200C7749823C106759F4A19A78AEA6687717A" },
25
+
{ name = "gleeunit", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "0E6C83834BA65EDCAAF4FE4FB94AC697D9262D83E6F58A750D63C9F6C8A9D9FF" },
26
+
{ name = "glint", version = "1.2.1", build_tools = ["gleam"], requirements = ["gleam_community_ansi", "gleam_community_colour", "gleam_stdlib", "snag"], otp_app = "glint", source = "hex", outer_checksum = "2214C7CEFDE457CEE62140C3D4899B964E05236DA74E4243DFADF4AF29C382BB" },
27
+
{ name = "glisten", version = "7.0.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib", "logging", "telemetry"], otp_app = "glisten", source = "hex", outer_checksum = "1A53CF9FB3231A93FF7F1BD519A43DC968C1722F126CDD278403A78725FC5189" },
28
+
{ name = "gramps", version = "3.0.1", build_tools = ["gleam"], requirements = ["gleam_crypto", "gleam_erlang", "gleam_http", "gleam_stdlib"], otp_app = "gramps", source = "hex", outer_checksum = "59194B3980110B403EE6B75330DB82CDE05FC8138491C2EAEACBC7AAEF30B2E8" },
29
+
{ name = "hpack_erl", version = "0.3.0", build_tools = ["rebar3"], requirements = [], otp_app = "hpack", source = "hex", outer_checksum = "D6137D7079169D8C485C6962DFE261AF5B9EF60FBC557344511C1E65E3D95FB0" },
30
+
{ name = "logging", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "logging", source = "hex", outer_checksum = "1098FBF10B54B44C2C7FDF0B01C1253CAFACDACABEFB4B0D027803246753E06D" },
31
+
{ name = "lustre", version = "4.6.4", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib"], otp_app = "lustre", source = "hex", outer_checksum = "CC59564624A4A1D855B5FEB55D979A072B328D0368E82A1639F180840D6288E9" },
32
+
{ name = "lustre_dev_tools", version = "1.7.0", build_tools = ["gleam"], requirements = ["argv", "filepath", "fs", "gleam_community_ansi", "gleam_crypto", "gleam_deque", "gleam_erlang", "gleam_http", "gleam_httpc", "gleam_json", "gleam_otp", "gleam_package_interface", "gleam_regexp", "gleam_stdlib", "glint", "glisten", "lustre", "mist", "repeatedly", "simplifile", "term_size", "tom", "wisp"], otp_app = "lustre_dev_tools", source = "hex", outer_checksum = "7C904F8D69A30240914A17009CD5BB9CE39CDEB31E6CFB7CF4579476CB66C7A4" },
33
+
{ name = "marceau", version = "1.3.0", build_tools = ["gleam"], requirements = [], otp_app = "marceau", source = "hex", outer_checksum = "2D1C27504BEF45005F5DFB18591F8610FB4BFA91744878210BDC464412EC44E9" },
34
+
{ name = "mist", version = "4.0.7", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_http", "gleam_otp", "gleam_stdlib", "gleam_yielder", "glisten", "gramps", "hpack_erl", "logging"], otp_app = "mist", source = "hex", outer_checksum = "F7D15A1E3232E124C7CE31900253633434E59B34ED0E99F273DEE61CDB573CDD" },
35
+
{ name = "platform", version = "1.0.0", build_tools = ["gleam"], requirements = [], otp_app = "platform", source = "hex", outer_checksum = "8339420A95AD89AAC0F82F4C3DB8DD401041742D6C3F46132A8739F6AEB75391" },
36
+
{ name = "repeatedly", version = "2.1.2", build_tools = ["gleam"], requirements = [], otp_app = "repeatedly", source = "hex", outer_checksum = "93AE1938DDE0DC0F7034F32C1BF0D4E89ACEBA82198A1FE21F604E849DA5F589" },
37
+
{ name = "simplifile", version = "2.2.1", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "C88E0EE2D509F6D86EB55161D631657675AA7684DAB83822F7E59EB93D9A60E3" },
38
+
{ name = "snag", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "snag", source = "hex", outer_checksum = "7E9F06390040EB5FAB392CE642771484136F2EC103A92AE11BA898C8167E6E17" },
39
+
{ name = "telemetry", version = "1.3.0", build_tools = ["rebar3"], requirements = [], otp_app = "telemetry", source = "hex", outer_checksum = "7015FC8919DBE63764F4B4B87A95B7C0996BD539E0D499BE6EC9D7F3875B79E6" },
40
+
{ name = "term_size", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "term_size", source = "hex", outer_checksum = "D00BD2BC8FB3EBB7E6AE076F3F1FF2AC9D5ED1805F004D0896C784D06C6645F1" },
41
+
{ name = "tom", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "tom", source = "hex", outer_checksum = "0910EE688A713994515ACAF1F486A4F05752E585B9E3209D8F35A85B234C2719" },
42
+
{ name = "wisp", version = "1.6.0", build_tools = ["gleam"], requirements = ["directories", "exception", "gleam_crypto", "gleam_erlang", "gleam_http", "gleam_json", "gleam_stdlib", "logging", "marceau", "mist", "simplifile"], otp_app = "wisp", source = "hex", outer_checksum = "AE1C568FE30718C358D3B37666DF0A0743ECD96094AD98C9F4921475075F660A" },
43
+
]
44
+
45
+
[requirements]
46
+
bigi = { version = ">= 3.2.1 and < 4.0.0" }
47
+
gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" }
48
+
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
49
+
lustre = { version = ">= 4.6.4 and < 5.0.0" }
50
+
lustre_dev_tools = { version = ">= 1.7.0 and < 2.0.0" }
+8
priv/static/locator_colour.min.mjs
+8
priv/static/locator_colour.min.mjs
···
1
+
var a=class{withFields(t){let r=Object.keys(this).map(n=>n in t?t[n]:this[n]);return new this.constructor(...r)}},N=class{static fromArray(t,r){let n=r||new ve;for(let i=t.length-1;i>=0;--i)n=new _e(t[i],n);return n}[Symbol.iterator](){return new $t(this)}toArray(){return[...this]}atLeastLength(t){let r=this;for(;t-- >0&&r;)r=r.tail;return r!==void 0}hasLength(t){let r=this;for(;t-- >0&&r;)r=r.tail;return t===-1&&r instanceof ve}countLength(){let t=this,r=0;for(;t;)t=t.tail,r++;return r-1}};function v(e,t){return new _e(e,t)}function c(e,t){return N.fromArray(e,t)}var $t=class{#e;constructor(t){this.#e=t}next(){if(this.#e instanceof ve)return{done:!0};{let{head:t,tail:r}=this.#e;return this.#e=r,{value:t,done:!1}}}},ve=class extends N{},_e=class extends N{constructor(t,r){super(),this.head=t,this.tail=r}},O=class{bitSize;byteSize;bitOffset;rawBuffer;constructor(t,r,n){if(!(t instanceof Uint8Array))throw globalThis.Error("BitArray can only be constructed from a Uint8Array");if(this.bitSize=r??t.length*8,this.byteSize=Math.trunc((this.bitSize+7)/8),this.bitOffset=n??0,this.bitSize<0)throw globalThis.Error(`BitArray bit size is invalid: ${this.bitSize}`);if(this.bitOffset<0||this.bitOffset>7)throw globalThis.Error(`BitArray bit offset is invalid: ${this.bitOffset}`);if(t.length!==Math.trunc((this.bitOffset+this.bitSize+7)/8))throw globalThis.Error("BitArray buffer length is invalid");this.rawBuffer=t}byteAt(t){if(!(t<0||t>=this.byteSize))return he(this.rawBuffer,this.bitOffset,t)}equals(t){if(this.bitSize!==t.bitSize)return!1;let r=Math.trunc(this.bitSize/8);if(this.bitOffset===0&&t.bitOffset===0){for(let i=0;i<r;i++)if(this.rawBuffer[i]!==t.rawBuffer[i])return!1;let n=this.bitSize%8;if(n){let i=8-n;if(this.rawBuffer[r]>>i!==t.rawBuffer[r]>>i)return!1}}else{for(let i=0;i<r;i++){let o=he(this.rawBuffer,this.bitOffset,i),s=he(t.rawBuffer,t.bitOffset,i);if(o!==s)return!1}let n=this.bitSize%8;if(n){let i=he(this.rawBuffer,this.bitOffset,r),o=he(t.rawBuffer,t.bitOffset,r),s=8-n;if(i>>s!==o>>s)return!1}}return!0}get buffer(){if(lr("buffer","Use BitArray.byteAt() or BitArray.rawBuffer instead"),this.bitOffset!==0||this.bitSize%8!==0)throw new globalThis.Error("BitArray.buffer does not support unaligned bit arrays");return this.rawBuffer}get length(){if(lr("length","Use BitArray.bitSize or BitArray.byteSize instead"),this.bitOffset!==0||this.bitSize%8!==0)throw new globalThis.Error("BitArray.length does not support unaligned bit arrays");return this.rawBuffer.length}};function he(e,t,r){if(t===0)return e[r]??0;{let n=e[r]<<t&255,i=e[r+1]>>8-t;return n|i}}var Be=class{constructor(t){this.value=t}},ur={};function lr(e,t){ur[e]||(console.warn(`Deprecated BitArray.${e} property used in JavaScript FFI code. ${t}.`),ur[e]=!0)}function xe(e,t,r){if(r??=e.bitSize,pr(e,t,r),t===r)return new O(new Uint8Array);if(t===0&&r===e.bitSize)return e;t+=e.bitOffset,r+=e.bitOffset;let n=Math.trunc(t/8),o=Math.trunc((r+7)/8)-n,s;return n===0&&o===e.rawBuffer.byteLength?s=e.rawBuffer:s=new Uint8Array(e.rawBuffer.buffer,e.rawBuffer.byteOffset+n,o),new O(s,r-t,t%8)}function cr(e,t,r,n,i){if(pr(e,t,r),t===r)return 0;t+=e.bitOffset,r+=e.bitOffset;let o=t%8===0,s=r%8===0;if(o&&s)return ln(e,t/8,r/8,n,i);let u=r-t,l=Math.trunc(t/8),f=Math.trunc((r-1)/8);if(l==f){let p=255>>t%8,h=(8-r%8)%8,_=(e.rawBuffer[l]&p)>>h;if(i){let $=2**(u-1);_>=$&&(_-=$*2)}return _}return u<=53?an(e.rawBuffer,t,r,n,i):pn(e.rawBuffer,t,r,n,i)}function He(e){if(e.length===0)return new O(new Uint8Array);if(e.length===1){let s=e[0];return s instanceof O?s:s instanceof Uint8Array?new O(s):new O(new Uint8Array(e))}let t=0,r=!0;for(let s of e)s instanceof O?(t+=s.bitSize,r=!1):s instanceof Uint8Array?(t+=s.byteLength*8,r=!1):t+=8;if(r)return new O(new Uint8Array(e));let n=new Uint8Array(Math.trunc((t+7)/8)),i=0;for(let s of e){let u=i%8===0;if(s instanceof O)if(u&&s.bitOffset===0){n.set(s.rawBuffer,i/8),i+=s.bitSize;let l=s.bitSize%8;if(l!==0){let f=Math.trunc(i/8);n[f]>>=8-l,n[f]<<=8-l}}else o(s.rawBuffer,s.bitSize,s.bitOffset);else s instanceof Uint8Array?u?(n.set(s,i/8),i+=s.byteLength*8):o(s,s.byteLength*8,0):u?(n[i/8]=s,i+=8):o(new Uint8Array([s]),8,0)}function o(s,u,l){if(u===0)return;let f=Math.trunc(u+7/8),p=i%8,h=8-p,_=Math.trunc(i/8);for(let $=0;$<f;$++){let x=he(s,l,$);u<8&&(x>>=8-u,x<<=8-u),n[_]|=x>>p;let E=u-Math.max(0,u-h);if(u-=E,i+=E,u===0)break;n[++_]=x<<h,E=u-Math.max(0,u-p),u-=E,i+=E}}return new O(n,t)}function ar(e,t,r){if(t<=0)return new Uint8Array;if(t===8)return new Uint8Array([e]);if(t<8)return e<<=8-t,new O(new Uint8Array([e]),t);let n=new Uint8Array(Math.trunc((t+7)/8)),i=t%8,o=8-i;if(t<=32)if(r){let s=n.length-1;for(i&&(n[s--]=e<<o&255,e>>=i);s>=0;s--)n[s]=e,e>>=8}else{let s=0,u=Math.trunc(t/8);for(;s<u;s++)n[s]=e,e>>=8;i&&(n[s]=e<<o)}else{let s=BigInt(i),u=BigInt(o),l=BigInt(e);if(r){let f=n.length-1;for(i&&(n[f--]=Number(l<<u),l>>=s);f>=0;f--)n[f]=Number(l),l>>=8n}else{let f=0,p=Math.trunc(t/8);for(;f<p;f++)n[f]=Number(l),l>>=8n;i&&(n[f]=Number(l<<u))}}return i?new O(n,t):n}function ln(e,t,r,n,i){return r-t<=6?fn(e.rawBuffer,t,r,n,i):cn(e.rawBuffer,t,r,n,i)}function fn(e,t,r,n,i){let o=r-t,s=0;if(n)for(let u=t;u<r;u++)s*=256,s+=e[u];else for(let u=r-1;u>=t;u--)s*=256,s+=e[u];if(i){let u=2**(o*8-1);s>=u&&(s-=u*2)}return s}function cn(e,t,r,n,i){let o=r-t,s=0n;if(n)for(let u=t;u<r;u++)s*=256n,s+=BigInt(e[u]);else for(let u=r-1;u>=t;u--)s*=256n,s+=BigInt(e[u]);if(i){let u=1n<<BigInt(o*8-1);s>=u&&(s-=u*2n)}return Number(s)}function an(e,t,r,n,i){let o=t%8===0,s=r-t,u=Math.trunc(t/8),l=0;if(n){if(!o){let f=8-t%8;l=e[u++]&(1<<f)-1,s-=f}for(;s>=8;)l*=256,l+=e[u++],s-=8;s>0&&(l*=2**s,l+=e[u]>>8-s)}else if(o){let f=r-t,p=1;for(;f>=8;)l+=e[u++]*p,p*=256,f-=8;l+=(e[u]>>8-f)*p}else{let f=t%8,p=8-f,h=r-t,_=1;for(;h>=8;){let $=e[u]<<f|e[u+1]>>p;l+=($&255)*_,_*=256,h-=8,u++}if(h>0){let $=h-Math.max(0,h-p),x=(e[u]&(1<<p)-1)>>p-$;h-=$,h>0&&(x*=2**h,x+=e[u+1]>>8-h),l+=x*_}}if(i){let f=2**(r-t-1);l>=f&&(l-=f*2)}return l}function pn(e,t,r,n,i){let o=t%8===0,s=r-t,u=Math.trunc(t/8),l=0n;if(n){if(!o){let f=8-t%8;l=BigInt(e[u++]&(1<<f)-1),s-=f}for(;s>=8;)l*=256n,l+=BigInt(e[u++]),s-=8;s>0&&(l<<=BigInt(s),l+=BigInt(e[u]>>8-s))}else if(o){let f=r-t,p=0n;for(;f>=8;)l+=BigInt(e[u++])<<p,p+=8n,f-=8;l+=BigInt(e[u]>>8-f)<<p}else{let f=t%8,p=8-f,h=r-t,_=0n;for(;h>=8;){let $=e[u]<<f|e[u+1]>>p;l+=BigInt($&255)<<_,_+=8n,h-=8,u++}if(h>0){let $=h-Math.max(0,h-p),x=(e[u]&(1<<p)-1)>>p-$;h-=$,h>0&&(x<<=h,x+=e[u+1]>>8-h),l+=BigInt(x)<<_}}if(i){let f=2n**BigInt(r-t-1);l>=f&&(l-=f*2n)}return Number(l)}function pr(e,t,r){if(t<0||t>e.bitSize||r<t||r>e.bitSize){let n=`Invalid bit array slice: start = ${t}, end = ${r}, bit size = ${e.bitSize}`;throw new globalThis.Error(n)}}var $e=class e extends a{static isResult(t){return t instanceof e}},d=class extends $e{constructor(t){super(),this[0]=t}isOk(){return!0}},m=class extends $e{constructor(t){super(),this[0]=t}isOk(){return!1}};function y(e,t){let r=[e,t];for(;r.length;){let n=r.pop(),i=r.pop();if(n===i)continue;if(!fr(n)||!fr(i)||!gn(n,i)||mn(n,i)||hn(n,i)||_n(n,i)||$n(n,i)||xn(n,i)||wn(n,i))return!1;let s=Object.getPrototypeOf(n);if(s!==null&&typeof s.equals=="function")try{if(n.equals(i))continue;return!1}catch{}let[u,l]=dn(n);for(let f of u(n))r.push(l(n,f),l(i,f))}return!0}function dn(e){if(e instanceof Map)return[t=>t.keys(),(t,r)=>t.get(r)];{let t=e instanceof globalThis.Error?["message"]:[];return[r=>[...t,...Object.keys(r)],(r,n)=>r[n]]}}function mn(e,t){return e instanceof Date&&(e>t||e<t)}function hn(e,t){return!(e instanceof O)&&e.buffer instanceof ArrayBuffer&&e.BYTES_PER_ELEMENT&&!(e.byteLength===t.byteLength&&e.every((r,n)=>r===t[n]))}function _n(e,t){return Array.isArray(e)&&e.length!==t.length}function $n(e,t){return e instanceof Map&&e.size!==t.size}function xn(e,t){return e instanceof Set&&(e.size!=t.size||[...e].some(r=>!t.has(r)))}function wn(e,t){return e instanceof RegExp&&(e.source!==t.source||e.flags!==t.flags)}function fr(e){return typeof e=="object"&&e!==null}function gn(e,t){return typeof e!="object"&&typeof t!="object"&&(!e||!t)||[Promise,WeakSet,WeakMap,Function].some(n=>e instanceof n)?!1:e.constructor===t.constructor}function ee(e,t){return t===0?0:e/t}function Ae(e,t,r,n,i,o){let s=new globalThis.Error(i);s.gleam_error=e,s.module=t,s.line=r,s.function=n,s.fn=n;for(let u in o)s[u]=o[u];return s}var q=class extends a{},R=class extends a{},W=class extends a{};var L=class extends a{constructor(t){super(),this[0]=t}},S=class extends a{};function dr(e,t){if(e instanceof L){let r=e[0];return new d(r)}else return new m(t)}function ge(e,t,r){return mr(t,r,e)}function yn(e,t){for(;;){let r=e,n=t;if(r.hasLength(0))return n;{let i=r.head;e=r.tail,t=v(i,n)}}}function bn(e,t){for(;;){let r=e,n=t;if(r.hasLength(0))return yn(n,c([]));{let i=r.head[0];e=r.tail,t=v(i,n)}}}function wt(e){return bn(Je(e),c([]))}function Sn(e,t){for(;;){let r=e,n=t;if(r.hasLength(0))return n;{let i=r.head;e=r.tail,t=v(i,n)}}}function ze(e){return Sn(e,c([]))}function jn(e,t,r){for(;;){let n=e,i=t,o=r;if(n.hasLength(0))return ze(o);{let s=n.head;e=n.tail,t=i,r=v(i(s),o)}}}function ue(e,t){return jn(e,t,c([]))}function te(e,t,r){for(;;){let n=e,i=t,o=r;if(n.hasLength(0))return i;{let s=n.head;e=n.tail,t=o(i,s),r=o}}}function vn(e,t,r,n){for(;;){let i=e,o=t,s=r,u=n;if(i.hasLength(0))return o;{let l=i.head;e=i.tail,t=s(o,l,u),r=s,n=u+1}}}function gt(e,t,r){return vn(e,t,r,0)}function yt(e,t){for(;;){let r=e,n=t;if(n>0){let o=Ye(r);if(o.isOk())e=o[0][1],t=n-1;else return r}else return r}}function Te(e,t){if(e.isOk()){let r=e[0];return new d(t(r))}else{let r=e[0];return new m(r)}}function bt(e,t){if(e.isOk()){let r=e[0];return new d(r)}else{let r=e[0];return new m(t(r))}}function ye(e,t){if(e.isOk()){let r=e[0];return t(r)}else{let r=e[0];return new m(r)}}function G(e,t){return e.isOk()?e[0]:t}var ne=class extends a{constructor(t,r,n){super(),this.expected=t,this.found=r,this.path=n}};function Wn(e,t){return bt(e,r=>ue(r,t))}function xr(e){return Lt(e)}function wr(e){return t=>{if(e.hasLength(0))return new m(c([new ne("another type",ce(t),c([]))]));{let r=e.head,n=e.tail,i=r(t);if(i.isOk()){let o=i[0];return new d(o)}else return wr(n)(t)}}}function Gn(e,t){let r=t,n=wr(c([Lt,s=>Te(gr(s),z)])),i=(()=>{let s=n(r);if(s.isOk())return s[0];{let u=c(["<",ce(r),">"]),l=Ce(u);return l}})(),o=e;return new ne(o.expected,o.found,v(i,e.path))}function Ot(e,t){return r=>{let n=new ne("field","nothing",c([]));return ye(yr(r,e),i=>{let s=dr(i,c([n])),u=ye(s,t);return Wn(u,l=>Gn(l,e))})}}var br=new WeakMap,St=new DataView(new ArrayBuffer(8)),jt=0;function vt(e){let t=br.get(e);if(t!==void 0)return t;let r=jt++;return jt===2147483647&&(jt=0),br.set(e,r),r}function Bt(e,t){return e^t+2654435769+(e<<6)+(e>>2)|0}function Et(e){let t=0,r=e.length;for(let n=0;n<r;n++)t=Math.imul(31,t)+e.charCodeAt(n)|0;return t}function Or(e){St.setFloat64(0,e);let t=St.getInt32(0),r=St.getInt32(4);return Math.imul(73244475,t>>16^t)^r}function Hn(e){return Et(e.toString())}function Jn(e){let t=Object.getPrototypeOf(e);if(t!==null&&typeof t.hashCode=="function")try{let n=e.hashCode(e);if(typeof n=="number")return n}catch{}if(e instanceof Promise||e instanceof WeakSet||e instanceof WeakMap)return vt(e);if(e instanceof Date)return Or(e.getTime());let r=0;if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),Array.isArray(e)||e instanceof Uint8Array)for(let n=0;n<e.length;n++)r=Math.imul(31,r)+U(e[n])|0;else if(e instanceof Set)e.forEach(n=>{r=r+U(n)|0});else if(e instanceof Map)e.forEach((n,i)=>{r=r+Bt(U(n),U(i))|0});else{let n=Object.keys(e);for(let i=0;i<n.length;i++){let o=n[i],s=e[o];r=r+Bt(U(s),Et(o))|0}}return r}function U(e){if(e===null)return 1108378658;if(e===void 0)return 1108378659;if(e===!0)return 1108378657;if(e===!1)return 1108378656;switch(typeof e){case"number":return Or(e);case"string":return Et(e);case"bigint":return Hn(e);case"object":return Jn(e);case"symbol":return vt(e);case"function":return vt(e);default:return 0}}var Y=5,zt=Math.pow(2,Y),Vn=zt-1,Xn=zt/2,Yn=zt/4,C=0,X=1,M=2,ae=3,Ct={type:M,bitmap:0,array:[]};function Ie(e,t){return e>>>t&Vn}function Ze(e,t){return 1<<Ie(e,t)}function Kn(e){return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),e=e+(e>>4)&252645135,e+=e>>8,e+=e>>16,e&127}function Tt(e,t){return Kn(e&t-1)}function D(e,t,r){let n=e.length,i=new Array(n);for(let o=0;o<n;++o)i[o]=e[o];return i[t]=r,i}function Zn(e,t,r){let n=e.length,i=new Array(n+1),o=0,s=0;for(;o<t;)i[s++]=e[o++];for(i[s++]=r;o<n;)i[s++]=e[o++];return i}function At(e,t){let r=e.length,n=new Array(r-1),i=0,o=0;for(;i<t;)n[o++]=e[i++];for(++i;i<r;)n[o++]=e[i++];return n}function Lr(e,t,r,n,i,o){let s=U(t);if(s===n)return{type:ae,hash:s,array:[{type:C,k:t,v:r},{type:C,k:i,v:o}]};let u={val:!1};return Ne(It(Ct,e,s,t,r,u),e,n,i,o,u)}function Ne(e,t,r,n,i,o){switch(e.type){case X:return Qn(e,t,r,n,i,o);case M:return It(e,t,r,n,i,o);case ae:return ei(e,t,r,n,i,o)}}function Qn(e,t,r,n,i,o){let s=Ie(r,t),u=e.array[s];if(u===void 0)return o.val=!0,{type:X,size:e.size+1,array:D(e.array,s,{type:C,k:n,v:i})};if(u.type===C)return y(n,u.k)?i===u.v?e:{type:X,size:e.size,array:D(e.array,s,{type:C,k:n,v:i})}:(o.val=!0,{type:X,size:e.size,array:D(e.array,s,Lr(t+Y,u.k,u.v,r,n,i))});let l=Ne(u,t+Y,r,n,i,o);return l===u?e:{type:X,size:e.size,array:D(e.array,s,l)}}function It(e,t,r,n,i,o){let s=Ze(r,t),u=Tt(e.bitmap,s);if((e.bitmap&s)!==0){let l=e.array[u];if(l.type!==C){let p=Ne(l,t+Y,r,n,i,o);return p===l?e:{type:M,bitmap:e.bitmap,array:D(e.array,u,p)}}let f=l.k;return y(n,f)?i===l.v?e:{type:M,bitmap:e.bitmap,array:D(e.array,u,{type:C,k:n,v:i})}:(o.val=!0,{type:M,bitmap:e.bitmap,array:D(e.array,u,Lr(t+Y,f,l.v,r,n,i))})}else{let l=e.array.length;if(l>=Xn){let f=new Array(32),p=Ie(r,t);f[p]=It(Ct,t+Y,r,n,i,o);let h=0,_=e.bitmap;for(let $=0;$<32;$++){if((_&1)!==0){let x=e.array[h++];f[$]=x}_=_>>>1}return{type:X,size:l+1,array:f}}else{let f=Zn(e.array,u,{type:C,k:n,v:i});return o.val=!0,{type:M,bitmap:e.bitmap|s,array:f}}}}function ei(e,t,r,n,i,o){if(r===e.hash){let s=Nt(e,n);if(s!==-1)return e.array[s].v===i?e:{type:ae,hash:r,array:D(e.array,s,{type:C,k:n,v:i})};let u=e.array.length;return o.val=!0,{type:ae,hash:r,array:D(e.array,u,{type:C,k:n,v:i})}}return Ne({type:M,bitmap:Ze(e.hash,t),array:[e]},t,r,n,i,o)}function Nt(e,t){let r=e.array.length;for(let n=0;n<r;n++)if(y(t,e.array[n].k))return n;return-1}function Ke(e,t,r,n){switch(e.type){case X:return ti(e,t,r,n);case M:return ri(e,t,r,n);case ae:return ni(e,n)}}function ti(e,t,r,n){let i=Ie(r,t),o=e.array[i];if(o!==void 0){if(o.type!==C)return Ke(o,t+Y,r,n);if(y(n,o.k))return o}}function ri(e,t,r,n){let i=Ze(r,t);if((e.bitmap&i)===0)return;let o=Tt(e.bitmap,i),s=e.array[o];if(s.type!==C)return Ke(s,t+Y,r,n);if(y(n,s.k))return s}function ni(e,t){let r=Nt(e,t);if(!(r<0))return e.array[r]}function qt(e,t,r,n){switch(e.type){case X:return ii(e,t,r,n);case M:return si(e,t,r,n);case ae:return oi(e,n)}}function ii(e,t,r,n){let i=Ie(r,t),o=e.array[i];if(o===void 0)return e;let s;if(o.type===C){if(!y(o.k,n))return e}else if(s=qt(o,t+Y,r,n),s===o)return e;if(s===void 0){if(e.size<=Yn){let u=e.array,l=new Array(e.size-1),f=0,p=0,h=0;for(;f<i;){let _=u[f];_!==void 0&&(l[p]=_,h|=1<<f,++p),++f}for(++f;f<u.length;){let _=u[f];_!==void 0&&(l[p]=_,h|=1<<f,++p),++f}return{type:M,bitmap:h,array:l}}return{type:X,size:e.size-1,array:D(e.array,i,s)}}return{type:X,size:e.size,array:D(e.array,i,s)}}function si(e,t,r,n){let i=Ze(r,t);if((e.bitmap&i)===0)return e;let o=Tt(e.bitmap,i),s=e.array[o];if(s.type!==C){let u=qt(s,t+Y,r,n);return u===s?e:u!==void 0?{type:M,bitmap:e.bitmap,array:D(e.array,o,u)}:e.bitmap===i?void 0:{type:M,bitmap:e.bitmap^i,array:At(e.array,o)}}return y(n,s.k)?e.bitmap===i?void 0:{type:M,bitmap:e.bitmap^i,array:At(e.array,o)}:e}function oi(e,t){let r=Nt(e,t);if(r<0)return e;if(e.array.length!==1)return{type:ae,hash:e.hash,array:At(e.array,r)}}function Sr(e,t){if(e===void 0)return;let r=e.array,n=r.length;for(let i=0;i<n;i++){let o=r[i];if(o!==void 0){if(o.type===C){t(o.v,o.k);continue}Sr(o,t)}}}var K=class e{static fromObject(t){let r=Object.keys(t),n=e.new();for(let i=0;i<r.length;i++){let o=r[i];n=n.set(o,t[o])}return n}static fromMap(t){let r=e.new();return t.forEach((n,i)=>{r=r.set(i,n)}),r}static new(){return new e(void 0,0)}constructor(t,r){this.root=t,this.size=r}get(t,r){if(this.root===void 0)return r;let n=Ke(this.root,0,U(t),t);return n===void 0?r:n.v}set(t,r){let n={val:!1},i=this.root===void 0?Ct:this.root,o=Ne(i,0,U(t),t,r,n);return o===this.root?this:new e(o,n.val?this.size+1:this.size)}delete(t){if(this.root===void 0)return this;let r=qt(this.root,0,U(t),t);return r===this.root?this:r===void 0?e.new():new e(r,this.size-1)}has(t){return this.root===void 0?!1:Ke(this.root,0,U(t),t)!==void 0}entries(){if(this.root===void 0)return[];let t=[];return this.forEach((r,n)=>t.push([n,r])),t}forEach(t){Sr(this.root,t)}hashCode(){let t=0;return this.forEach((r,n)=>{t=t+Bt(U(r),U(n))|0}),t}equals(t){if(!(t instanceof e)||this.size!==t.size)return!1;try{return this.forEach((r,n)=>{if(!y(t.get(n,!r),r))throw kr}),!0}catch(r){if(r===kr)return!1;throw r}}},kr=Symbol();var Ar=void 0,jr={};function z(e){return e.toString()}function Er(e,t){return e.toString(t).toUpperCase()}var vr;function li(e){if(globalThis.Intl&&Intl.Segmenter)return vr||=new Intl.Segmenter,vr.segment(e)[Symbol.iterator]()}function Ye(e){let t,r=li(e);return r?t=r.next().value?.segment:t=e.match(/./su)?.[0],t?new d([t,e.slice(t.length)]):new m(Ar)}function Ce(e){let t="";for(let r of e)t=t+r;return t}var zr=[" "," ",`
2
+
`,"\v","\f","\r","\x85","\u2028","\u2029"].join(""),To=new RegExp(`^[${zr}]*`),Io=new RegExp(`[${zr}]*$`);function le(e){return Math.floor(e)}function Mt(e){return Math.round(e)}function V(){return K.new()}function Je(e){return N.fromArray(e.entries())}function Ee(e,t){let r=e.get(t,jr);return r===jr?new m(Ar):new d(r)}function mr(e,t,r){return r.set(e,t)}function ce(e){if(typeof e=="string")return"String";if(typeof e=="boolean")return"Bool";if(e instanceof $e)return"Result";if(e instanceof N)return"List";if(e instanceof O)return"BitArray";if(e instanceof K)return"Dict";if(Number.isInteger(e))return"Int";if(Array.isArray(e))return`Tuple of ${e.length} elements`;if(typeof e=="number")return"Float";if(e===null)return"Null";if(e===void 0)return"Nil";{let t=typeof e;return t.charAt(0).toUpperCase()+t.slice(1)}}function Ut(e,t){return fi(e,ce(t))}function fi(e,t){return new m(N.fromArray([new ne(e,t,N.fromArray([]))]))}function Lt(e){return typeof e=="string"?new d(e):Ut("String",e)}function gr(e){return Number.isInteger(e)?new d(e):Ut("Int",e)}function yr(e,t){let r=()=>Ut("Dict",e);if(e instanceof K||e instanceof WeakMap||e instanceof Map){let n=Ee(e,t);return new d(n.isOk()?new L(n[0]):new S)}else return e===null?r():Object.getPrototypeOf(e)==Object.prototype?Br(e,t,()=>new d(new S)):Br(e,t,r)}function Br(e,t,r){try{return t in e?new d(new L(e[t])):r()}catch{return r()}}function ai(e){return-1*e}function b(e){return e>=0?Mt(e):0-Mt(ai(e))}function Qe(e){return Er(e,16)}function Ft(e,t,r){return e?t:r()}var Rt=class extends a{constructor(t){super(),this.all=t}};function Wt(){return new Rt(c([]))}var pe=class extends a{constructor(t){super(),this.content=t}},j=class extends a{constructor(t,r,n,i,o,s,u){super(),this.key=t,this.namespace=r,this.tag=n,this.attrs=i,this.children=o,this.self_closing=s,this.void=u}},qe=class extends a{constructor(t){super(),this.subtree=t}},Oe=class extends a{constructor(t,r,n){super(),this[0]=t,this[1]=r,this.as_property=n}},Me=class extends a{constructor(t,r){super(),this[0]=t,this[1]=r}};function ki(e){if(e instanceof Oe)return new m(void 0);{let t=e[0],r=e[1],n=yt(t,2);return new d([n,r])}}function Oi(e,t,r){return gt(e,t,(n,i,o)=>{let s=r+"-"+z(o);return Ir(i,n,s)})}function Ir(e,t,r){for(;;){let n=e,i=t,o=r;if(n instanceof pe)return i;if(n instanceof qe){let s=n.subtree;e=s(),t=i,r=o}else{let s=n.attrs,u=n.children,l=te(s,i,(f,p)=>{let h=ki(p);if(h.isOk()){let _=h[0][0],$=h[0][1];return ge(f,o+"-"+_,$)}else return f});return Oi(u,l,o)}}}function Nr(e){return Ir(e,V(),"0")}function Ht(e,t){return new Oe(e,t,!1)}function Mr(e,t){return new Me("on"+e,t)}function H(e){return Ht("style",te(e,"",(t,r)=>{let n=r[0],i=r[1];return t+n+":"+i+";"}))}function Ur(e){return Ht("value",e)}function Dr(e){return Ht("href",e)}function ie(e,t,r){return e==="area"?new j("","",e,t,c([]),!1,!0):e==="base"?new j("","",e,t,c([]),!1,!0):e==="br"?new j("","",e,t,c([]),!1,!0):e==="col"?new j("","",e,t,c([]),!1,!0):e==="embed"?new j("","",e,t,c([]),!1,!0):e==="hr"?new j("","",e,t,c([]),!1,!0):e==="img"?new j("","",e,t,c([]),!1,!0):e==="input"?new j("","",e,t,c([]),!1,!0):e==="link"?new j("","",e,t,c([]),!1,!0):e==="meta"?new j("","",e,t,c([]),!1,!0):e==="param"?new j("","",e,t,c([]),!1,!0):e==="source"?new j("","",e,t,c([]),!1,!0):e==="track"?new j("","",e,t,c([]),!1,!0):e==="wbr"?new j("","",e,t,c([]),!1,!0):new j("","",e,t,r,!1,!1)}function Fr(e){return new pe(e)}function Pr(){return new pe("")}var Vt=class extends a{constructor(t){super(),this.dict=t}};function Wr(){return new Vt(V())}var et=class extends a{constructor(t){super(),this[0]=t}},tt=class extends a{constructor(t,r){super(),this[0]=t,this[1]=r}},rt=class extends a{constructor(t,r){super(),this[0]=t,this[1]=r}};function Gr(e){return y(e.created,V())&&y(e.removed,Wr())&&y(e.updated,V())}var nt=class extends a{constructor(t){super(),this[0]=t}},it=class extends a{constructor(t,r){super(),this[0]=t,this[1]=r}},Ue=class extends a{constructor(t){super(),this[0]=t}},Z=class extends a{constructor(t){super(),this[0]=t}},De=class extends a{constructor(t,r){super(),this[0]=t,this[1]=r}},st=class extends a{constructor(t,r){super(),this[0]=t,this[1]=r}};var Fe=class extends a{},ot=class extends a{constructor(t,r){super(),this[0]=t,this[1]=r}},ut=class extends a{constructor(t){super(),this[0]=t}},lt=class extends a{constructor(t){super(),this[0]=t}};globalThis.customElements&&!globalThis.customElements.get("lustre-fragment")&&globalThis.customElements.define("lustre-fragment",class extends HTMLElement{constructor(){super()}});function Xt(e,t,r){let n,i=[{prev:e,next:t,parent:e.parentNode}];for(;i.length;){let{prev:o,next:s,parent:u}=i.pop();for(;s.subtree!==void 0;)s=s.subtree();if(s.content!==void 0)if(o)if(o.nodeType===Node.TEXT_NODE)o.textContent!==s.content&&(o.textContent=s.content),n??=o;else{let l=document.createTextNode(s.content);u.replaceChild(l,o),n??=l}else{let l=document.createTextNode(s.content);u.appendChild(l),n??=l}else if(s.tag!==void 0){let l=Bi({prev:o,next:s,dispatch:r,stack:i});o?o!==l&&u.replaceChild(l,o):u.appendChild(l),n??=l}}return n}function Bi({prev:e,next:t,dispatch:r,stack:n}){let i=t.namespace||"http://www.w3.org/1999/xhtml",o=e&&e.nodeType===Node.ELEMENT_NODE&&e.localName===t.tag&&e.namespaceURI===(t.namespace||"http://www.w3.org/1999/xhtml"),s=o?e:i?document.createElementNS(i,t.tag):document.createElement(t.tag),u;if(Pe.has(s))u=Pe.get(s);else{let w=new Map;Pe.set(s,w),u=w}let l=o?new Set(u.keys()):null,f=o?new Set(Array.from(e.attributes,w=>w.name)):null,p=null,h=null,_=null;if(o&&t.tag==="textarea"){let w=t.children[Symbol.iterator]().next().value?.content;w!==void 0&&(s.value=w)}let $=[];for(let w of t.attrs){let g=w[0],k=w[1];if(w.as_property)s[g]!==k&&(s[g]=k),o&&f.delete(g);else if(g.startsWith("on")){let B=g.slice(2),P=r(k,B==="input");u.has(B)||s.addEventListener(B,Re),u.set(B,P),o&&l.delete(B)}else if(g.startsWith("data-lustre-on-")){let B=g.slice(15),P=r(Ai);u.has(B)||s.addEventListener(B,Re),u.set(B,P),s.setAttribute(g,k),o&&(l.delete(B),f.delete(g))}else g.startsWith("delegate:data-")||g.startsWith("delegate:aria-")?(s.setAttribute(g,k),$.push([g.slice(10),k])):g==="class"?p=p===null?k:p+" "+k:g==="style"?h=h===null?k:h+k:g==="dangerous-unescaped-html"?_=k:(s.getAttribute(g)!==k&&s.setAttribute(g,k),(g==="value"||g==="selected")&&(s[g]=k),o&&f.delete(g))}if(p!==null&&(s.setAttribute("class",p),o&&f.delete("class")),h!==null&&(s.setAttribute("style",h),o&&f.delete("style")),o){for(let w of f)s.removeAttribute(w);for(let w of l)u.delete(w),s.removeEventListener(w,Re)}if(t.tag==="slot"&&window.queueMicrotask(()=>{for(let w of s.assignedElements())for(let[g,k]of $)w.hasAttribute(g)||w.setAttribute(g,k)}),t.key!==void 0&&t.key!=="")s.setAttribute("data-lustre-key",t.key);else if(_!==null)return s.innerHTML=_,s;let x=s.firstChild,E=null,J=null,se=null,I=ft(t).next().value;if(o&&I!==void 0&&I.key!==void 0&&I.key!==""){E=new Set,J=Hr(e),se=Hr(t);for(let w of ft(t))x=Ei(x,w,s,n,se,J,E)}else for(let w of ft(t))n.unshift({prev:x,next:w,parent:s}),x=x?.nextSibling;for(;x;){let w=x.nextSibling;s.removeChild(x),x=w}return s}var Pe=new WeakMap;function Re(e){let t=e.currentTarget;if(!Pe.has(t)){t.removeEventListener(e.type,Re);return}let r=Pe.get(t);if(!r.has(e.type)){t.removeEventListener(e.type,Re);return}r.get(e.type)(e)}function Ai(e){let t=e.currentTarget,r=t.getAttribute(`data-lustre-on-${e.type}`),n=JSON.parse(t.getAttribute("data-lustre-data")||"{}"),i=JSON.parse(t.getAttribute("data-lustre-include")||"[]");switch(e.type){case"input":case"change":i.push("target.value");break}return{tag:r,data:i.reduce((o,s)=>{let u=s.split(".");for(let l=0,f=o,p=e;l<u.length;l++)l===u.length-1?f[u[l]]=p[u[l]]:(f[u[l]]??={},p=p[u[l]],f=f[u[l]]);return o},{data:n})}}function Hr(e){let t=new Map;if(e)for(let r of ft(e)){let n=r?.key||r?.getAttribute?.("data-lustre-key");n&&t.set(n,r)}return t}function Ei(e,t,r,n,i,o,s){for(;e&&!i.has(e.getAttribute("data-lustre-key"));){let l=e.nextSibling;r.removeChild(e),e=l}if(o.size===0)return n.unshift({prev:e,next:t,parent:r}),e=e?.nextSibling,e;if(s.has(t.key))return console.warn(`Duplicate key found in Lustre vnode: ${t.key}`),n.unshift({prev:null,next:t,parent:r}),e;s.add(t.key);let u=o.get(t.key);if(!u&&!e)return n.unshift({prev:null,next:t,parent:r}),e;if(!u&&e!==null){let l=document.createTextNode("");return r.insertBefore(l,e),n.unshift({prev:l,next:t,parent:r}),e}return!u||u===e?(n.unshift({prev:e,next:t,parent:r}),e=e?.nextSibling,e):(r.insertBefore(u,e),n.unshift({prev:u,next:t,parent:r}),e)}function*ft(e){for(let t of e.children)yield*Jr(t)}function*Jr(e){e.subtree!==void 0?yield*Jr(e.subtree()):yield e}var Yt=class e{static start({init:t,update:r,view:n},i,o){if(!Zt())return new m(new We);let s=i instanceof HTMLElement?i:document.querySelector(i);if(!s)return new m(new ct(i));let u=new e(s,t(o),r,n);return new d(l=>u.send(l))}constructor(t,[r,n],i,o){this.root=t,this.#e=r,this.#s=i,this.#r=o,this.#t=window.setTimeout(()=>this.#n(n.all.toArray(),!0),0)}root;send(t){if(t instanceof Ue){if(t[0]instanceof lt){this.#t=window.clearTimeout(this.#t),this.#i=[],this.#e=t[0][0];let r=this.#r(this.#e),n=(o,s=!1)=>u=>{let l=o(u);l instanceof d&&this.send(new Z(l[0],s))},i=this.root.firstChild??this.root.appendChild(document.createTextNode(""));Xt(i,r,n)}}else if(t instanceof Z){let r=t[0],n=t[1]??!1;this.#i.push(r),n?(this.#t=window.clearTimeout(this.#t),this.#n()):this.#t||(this.#t=window.setTimeout(()=>this.#n()))}else if(t instanceof De){let r=t[0],n=t[1];this.root.dispatchEvent(new CustomEvent(r,{detail:n,bubbles:!0,composed:!0}))}else if(t instanceof Fe)for(this.#t=window.clearTimeout(this.#t),this.#e=null,this.#s=null,this.#r=null,this.#i=null;this.root.firstChild;)this.root.firstChild.remove()}#e;#s;#r;#i=[];#t;#n(t=[]){this.#t=void 0,this.#o(t);let r=this.#r(this.#e),n=(o,s=!1)=>u=>{let l=o(u);l instanceof d&&this.send(new Z(l[0],s))},i=this.root.firstChild??this.root.appendChild(document.createTextNode(""));Xt(i,r,n)}#o(t=[]){for(;this.#i.length>0;){let r=this.#i.shift(),[n,i]=this.#s(this.#e,r);t=t.concat(i.all.toArray()),this.#e=n}for(;t.length>0;){let r=t.shift(),n=u=>this.send(new Z(u)),i=(u,l)=>this.root.dispatchEvent(new CustomEvent(u,{detail:l,bubbles:!0,composed:!0})),o=()=>{},s=this.root;r({dispatch:n,emit:i,select:o,root:s})}this.#i.length>0&&this.#o(t)}},Vr=Yt.start;var Kt=class e{static start({init:t,update:r,view:n,on_attribute_change:i},o){let s=new e(t(o),r,n,i);return new d(u=>s.send(u))}constructor([t,r],n,i,o){this.#e=t,this.#s=n,this.#i=i,this.#t=i(t),this.#l=o,this.#n=new Map,this.#o=Nr(this.#t),this.#u(r.all.toArray())}send(t){if(t instanceof nt){for(let r of t[0]){let n=this.#l.get(r[0]);if(!n)continue;let i=n(r[1]);i instanceof m||this.#r.push(i)}this.#u()}else if(t instanceof it)this.#r=this.#r.concat(t[0].toArray()),this.#u(t[1].all.toArray());else if(!(t instanceof Ue))if(t instanceof Z)this.#r.push(t[0]),this.#u();else if(t instanceof De){let r=new tt(t[0],t[1]);for(let[n,i]of this.#n)i(r)}else if(t instanceof st){let r=this.#o.get(t[0]);if(!r)return;let n=r(t[1]);if(n instanceof m)return;this.#r.push(n[0]),this.#u()}else if(t instanceof ot){let r=wt(this.#l),n=new rt(r,this.#t);this.#n=this.#n.set(t[0],t[1]),t[1](n)}else t instanceof ut&&(this.#n=this.#n.delete(t[0]))}#e;#s;#r;#i;#t;#n;#o;#l;#u(t=[]){this.#f(t);let r=this.#i(this.#e),n=elements(this.#t,r);if(!Gr(n)){let i=new et(n);for(let[o,s]of this.#n)s(i)}this.#t=r,this.#o=n.handlers}#f(t=[]){for(;this.#r.length>0;){let r=this.#r.shift(),[n,i]=this.#s(this.#e,r);t=t.concat(i.all.toArray()),this.#e=n}for(;t.length>0;)t.shift()({dispatch:u=>this.send(new Z(u)),emit:(u,l)=>this.root.dispatchEvent(new CustomEvent(u,{detail:l,bubbles:!0,composed:!0})),select:()=>{},root:null});this.#r.length>0&&this.#f(t)}},zi=Kt.start,Zt=()=>globalThis.window&&window.document;var Qt=class extends a{constructor(t,r,n,i){super(),this.init=t,this.update=r,this.view=n,this.on_attribute_change=i}};var ct=class extends a{constructor(t){super(),this.selector=t}},We=class extends a{};function Ci(e,t,r){return new Qt(e,t,r,new S)}function Xr(e,t,r){return Ci(o=>[e(o),Wt()],(o,s)=>[t(o,s),Wt()],r)}function Yr(e,t,r){return Ft(!Zt(),new m(new We),()=>Vr(e,t,r))}function Le(e){return Fr(e)}function Kr(e,t){return ie("h1",e,t)}function at(e,t){return ie("div",e,t)}function Zr(e,t){return ie("p",e,t)}function Qr(e,t){return ie("a",e,t)}function er(e,t){return ie("code",e,t)}function en(e){return ie("input",e,c([]))}function Ni(e,t){return Mr(e,t)}function qi(e){let t=e;return Ot("target",Ot("value",xr))(t)}function tn(e){return Ni("input",t=>{let r=qi(t);return Te(r,e)})}function Se(e){return BigInt(e)}function pt(e,t,r){if(e.bitSize%8!==0)return new m(void 0);let n=0n;if(t instanceof de)for(let i=0;i<e.byteSize;i++)n=n*256n+BigInt(e.byteAt(i));else for(let i=e.byteSize-1;i>=0;i--)n=n*256n+BigInt(e.byteAt(i));if(r instanceof me){let o=2n**(BigInt(e.byteSize)*8n-1n);n>=o&&(n-=o*2n)}return new d(n)}function F(e){return e>Number.MAX_SAFE_INTEGER||e<Number.MIN_SAFE_INTEGER?new m(void 0):new d(Number(e))}function tr(e,t){return e<t?new q:e>t?new W:new R}function je(e,t){return e-t}function Ge(e,t){return e&t}function dt(e,t){return e^t}function mt(e,t){return e>>BigInt(t)}var de=class extends a{},me=class extends a{};function rr(e,t){return tr(e,t)instanceof q?t:e}function nr(e,t){return tr(e,t)instanceof q?e:t}function ir(e,t){return BigInt.asIntN(32,e>>BigInt(t))}function rn(e,t){return BigInt.asUintN(t,e)}var sr=class extends a{constructor(t,r,n,i){super(),this.a=t,this.r=r,this.g=n,this.b=i}};function Di(e){let r=ir(e,24);return rn(r,8)}function Fi(e){let r=mt(e,16);return Ge(r,Se(255))}function Pi(e){let r=mt(e,8);return Ge(r,Se(255))}function Ri(e){return Ge(e,Se(255))}function nn(e,t,r,n){return new sr(e,t,r,n)}function sn(e,t){let r=Fi(e),n=Pi(e),i=Ri(e),o=Di(e),s=rr(rr(r,n),i),u=nr(nr(r,n),i),l=(()=>{let _=F(je(s,u));return G(_,0)})(),f=y(s,Se(0))?0:ee(l,(()=>{let $=F(s);return G($,0)})()),p=(()=>{if(f===0)return 0;{let $=ee((()=>{let I=F(je(s,r));return G(I,0)})(),l),x=ee((()=>{let I=F(je(s,n));return G(I,0)})(),l),E=ee((()=>{let I=F(je(s,i));return G(I,0)})(),l),J=ee((()=>{if(y(s,r)){let I=s;return E-x}else if(y(s,n)){let I=s;return 2+$-E}else return 4+x-$})(),6);return J<0?J+1:J}})();if(f===0)return nn(ht((()=>{let $=F(o);return G($,255)})(),"src/locator_colour/colour.gleam",94),ht(b(t*255),"src/locator_colour/colour.gleam",95),ht(b(t*255),"src/locator_colour/colour.gleam",96),ht(b(t*255),"src/locator_colour/colour.gleam",97));{let _=(p-le(p))*6,$=_-le(_),x=t*(1-f),E=t*(1-f*$),J=t*(1-f*(1-$)),se=(()=>{let k=(()=>{let P=le(_);return b(P)})();return k===0?[b(t*255),b(J*255),b(x*255)]:k===1?[b(E*255),b(t*255),b(x*255)]:k===2?[b(x*255),b(t*255),b(J*255)]:k===3?[b(x*255),b(E*255),b(t*255)]:k===4?[b(J*255),b(x*255),b(t*255)]:k===5?[b(t*255),b(x*255),b(E*255)]:[(()=>{let P=F(r);return G(P,696969)})(),(()=>{let P=F(n);return G(P,696969)})(),(()=>{let P=F(i);return G(P,696969)})()]})(),I=se[0],w=se[1],g=se[2];return nn((()=>{let B=F(o);return G(B,255)})(),I,w,g)}}function Wi(e){let t=ir(e,32);return dt(e,t)}function Gi(e){let t=e==="0"?0:e==="1"?1:e==="2"?2:e==="3"?3:e==="4"?4:e==="5"?5:e==="6"?6:e==="7"?7:e==="8"?8:e==="9"?9:e==="a"||e==="A"?10:e==="b"||e==="B"?11:e==="c"||e==="C"?12:e==="d"||e==="D"?13:e==="e"||e==="E"?14:e==="f"||e==="F"?15:16;if(t===16)return new m(void 0);{let r=t;return new d(r)}}function Hi(e,t,r){for(;;){let n=e,i=t,o=r,s=Ye(n);if(!s.isOk()&&!s[0]&&i===32)return new d(o);if(s.isOk()&&s[0][0]==="-"&&i<32)e=s[0][1],t=i,r=o;else if(s.isOk()&&i<32){let u=s[0][0],l=s[0][1],f=Gi(u);if(f.isOk()){let p=f[0];e=l,t=i+1,r=He([o,ar(p,4,!0)])}else return new m(void 0)}else return new m(void 0)}}function Ji(e){return Hi(e,0,He([]))}function on(e){let t=Ji(e);if(t.isOk()&&t[0].bitSize==128){let r=xe(t[0],0,64),n=xe(t[0],64,128);return ye(pt(r,new de,new me),i=>ye(pt(n,new de,new me),o=>{let s=dt(i,o),u=Wi(s);return new d(u)}))}else return new m(void 0)}function ht(e,t,r){let n="\x1B[90m",i="\x1B[39m",o=`${t}:${r}`,s=Q(e);if(typeof process=="object"&&process.stderr?.write){let u=`${n}${o}${i}
3
+
${s}
4
+
`;process.stderr.write(u)}else if(typeof Deno=="object"){let u=`${n}${o}${i}
5
+
${s}
6
+
`;Deno.stderr.writeSync(new TextEncoder().encode(u))}else{let u=`${o}
7
+
${s}`;console.log(u)}return e}function Vi(e){let t='"';for(let r=0;r<e.length;r++){let n=e[r];n==`
8
+
`?t+="\\n":n=="\r"?t+="\\r":n==" "?t+="\\t":n=="\f"?t+="\\f":n=="\\"?t+="\\\\":n=='"'?t+='\\"':n<" "||n>"~"&&n<"\xA0"?t+="\\u{"+n.charCodeAt(0).toString(16).toUpperCase().padStart(4,"0")+"}":t+=n}return t+='"',t}function Xi(e){let t="dict.from_list([",r=!0,n=[];return e.forEach((i,o)=>{n.push([o,i])}),n.sort(),n.forEach(([i,o])=>{r||(t=t+", "),t=t+"#("+Q(i)+", "+Q(o)+")",r=!1}),t+"])"}function Yi(e){let t=Object.keys(e).map(r=>{let n=Q(e[r]);return isNaN(parseInt(r))?`${r}: ${n}`:n}).join(", ");return t?`${e.constructor.name}(${t})`:e.constructor.name}function Ki(e){let t=Object.getPrototypeOf(e)?.constructor?.name||"Object",r=[];for(let o of Object.keys(e))r.push(`${Q(o)}: ${Q(e[o])}`);let n=r.length?" "+r.join(", ")+" ":"";return`//js(${t==="Object"?"":t+" "}{${n}})`}function Q(e){let t=typeof e;if(e===!0)return"True";if(e===!1)return"False";if(e===null)return"//js(null)";if(e===void 0)return"Nil";if(t==="string")return Vi(e);if(t==="bigint"||t==="number")return e.toString();if(Array.isArray(e))return`#(${e.map(Q).join(", ")})`;if(e instanceof N)return`[${e.toArray().map(Q).join(", ")}]`;if(e instanceof Be)return`//utfcodepoint(${String.fromCodePoint(e.value)})`;if(e instanceof O)return Zi(e);if(e instanceof a)return Yi(e);if(Qi(e))return Xi(e);if(e instanceof Set)return`//js(Set(${[...e].map(Q).join(", ")}))`;if(e instanceof RegExp)return`//js(${e})`;if(e instanceof Date)return`//js(Date("${e.toISOString()}"))`;if(e instanceof Function){let r=[];for(let n of Array(e.length).keys())r.push(String.fromCharCode(n+97));return`//fn(${r.join(", ")}) { ... }`}return Ki(e)}function Zi(e){let t=e.bitOffset+8*Math.trunc(e.bitSize/8),r=xe(e,e.bitOffset,t),n=e.bitSize%8;if(n>0){let i=cr(e,t,e.bitSize,!1,!1),o=Array.from(r.rawBuffer),s=`${i}:size(${n})`;return o.length===0?`<<${s}>>`:`<<${Array.from(r.rawBuffer).join(", ")}, ${s}>>`}else return`<<${Array.from(r.rawBuffer).join(", ")}>>`}function Qi(e){try{return e instanceof K}catch{return!1}}var _t=class extends a{constructor(t,r){super(),this.uuid=t,this.colour=r}},or=class extends a{constructor(t){super(),this.uuid=t}};function ts(e){return new _t("",new S)}function rs(e,t){{let r=t.uuid;return new _t(r,(()=>{let n=on(r);if(n.isOk()){let i=n[0];return new L(sn(i,.9))}else return new S})())}}function ns(e){return at(c([H(c([["width","100vw"],["height","100vh"],["display","flex"],["flex-direction","column"],["justify-content","center"],["align-items","center"],(()=>{let t=e.colour;if(t instanceof L){let r=t[0];return["background-color","rgb("+z(r.r)+","+z(r.g)+","+z(r.b)+")"]}else return["",""]})()]))]),c([at(c([H(c([["display","flex"],["flex-direction","column"],["justify-content","center"],["align-items","center"],["background-color","#303446"],["color","#c6d0f5"],["border","2px solid #ca9ee6"],["padding","1em"],["border-radius","1em"]]))]),c([Kr(c([H(c([["margin","0"]]))]),c([Le("Enter UUID:")])),en(c([H(c([["width","22em"],["height","2em"],["text-align","center"],["border","none"],["border-radius","1em"],["background-color","#51576d"],["margin","1em"],["color","#c6d0f5"]])),Ur(e.uuid),tn(t=>new or(t))])),Qr(c([Dr("https://namemc.com/"),H(c([["color","#8caaee"]]))]),c([Le("Find UUID here")])),(()=>{let t=e.colour;if(t instanceof S&&e.uuid!=="")return Zr(c([H(c([["color","#e78284"]]))]),c([Le("Invalid UUID")]));if(t instanceof L){let r=t[0];return at(c([H(c([["margin-top","1em"],["display","flex"],["flex-direction","column"],["gap","4px"],["justify-content","center"],["align-items","center"]]))]),c([er(c([H(c([["padding","4px"],["border-radius","0.5em"],["background-color","#51576d"],["width","fit-content"]]))]),c([Le("rgb("+z(r.r)+","+z(r.g)+","+z(r.b)+")")])),er(c([H(c([["padding","4px"],["border-radius","0.5em"],["background-color","#51576d"],["width","fit-content"]]))]),c([Le("#"+Qe(r.r)+Qe(r.g)+Qe(r.b))]))]))}else return Pr()})()]))]))}function un(){let e=Xr(ts,rs,ns),t=Yr(e,"#app",void 0);if(!t.isOk())throw Ae("let_assert","locator_colour",167,"main","Pattern match failed, no pattern matched the value.",{value:t});return new d(void 0)}un();
+3648
priv/static/locator_colour.mjs
+3648
priv/static/locator_colour.mjs
···
1
+
// build/dev/javascript/prelude.mjs
2
+
var CustomType = class {
3
+
withFields(fields) {
4
+
let properties = Object.keys(this).map(
5
+
(label) => label in fields ? fields[label] : this[label]
6
+
);
7
+
return new this.constructor(...properties);
8
+
}
9
+
};
10
+
var List = class {
11
+
static fromArray(array3, tail) {
12
+
let t = tail || new Empty();
13
+
for (let i = array3.length - 1; i >= 0; --i) {
14
+
t = new NonEmpty(array3[i], t);
15
+
}
16
+
return t;
17
+
}
18
+
[Symbol.iterator]() {
19
+
return new ListIterator(this);
20
+
}
21
+
toArray() {
22
+
return [...this];
23
+
}
24
+
// @internal
25
+
atLeastLength(desired) {
26
+
let current = this;
27
+
while (desired-- > 0 && current) current = current.tail;
28
+
return current !== void 0;
29
+
}
30
+
// @internal
31
+
hasLength(desired) {
32
+
let current = this;
33
+
while (desired-- > 0 && current) current = current.tail;
34
+
return desired === -1 && current instanceof Empty;
35
+
}
36
+
// @internal
37
+
countLength() {
38
+
let current = this;
39
+
let length2 = 0;
40
+
while (current) {
41
+
current = current.tail;
42
+
length2++;
43
+
}
44
+
return length2 - 1;
45
+
}
46
+
};
47
+
function prepend(element2, tail) {
48
+
return new NonEmpty(element2, tail);
49
+
}
50
+
function toList(elements2, tail) {
51
+
return List.fromArray(elements2, tail);
52
+
}
53
+
var ListIterator = class {
54
+
#current;
55
+
constructor(current) {
56
+
this.#current = current;
57
+
}
58
+
next() {
59
+
if (this.#current instanceof Empty) {
60
+
return { done: true };
61
+
} else {
62
+
let { head, tail } = this.#current;
63
+
this.#current = tail;
64
+
return { value: head, done: false };
65
+
}
66
+
}
67
+
};
68
+
var Empty = class extends List {
69
+
};
70
+
var NonEmpty = class extends List {
71
+
constructor(head, tail) {
72
+
super();
73
+
this.head = head;
74
+
this.tail = tail;
75
+
}
76
+
};
77
+
var BitArray = class {
78
+
/**
79
+
* The size in bits of this bit array's data.
80
+
*
81
+
* @type {number}
82
+
*/
83
+
bitSize;
84
+
/**
85
+
* The size in bytes of this bit array's data. If this bit array doesn't store
86
+
* a whole number of bytes then this value is rounded up.
87
+
*
88
+
* @type {number}
89
+
*/
90
+
byteSize;
91
+
/**
92
+
* The number of unused high bits in the first byte of this bit array's
93
+
* buffer prior to the start of its data. The value of any unused high bits is
94
+
* undefined.
95
+
*
96
+
* The bit offset will be in the range 0-7.
97
+
*
98
+
* @type {number}
99
+
*/
100
+
bitOffset;
101
+
/**
102
+
* The raw bytes that hold this bit array's data.
103
+
*
104
+
* If `bitOffset` is not zero then there are unused high bits in the first
105
+
* byte of this buffer.
106
+
*
107
+
* If `bitOffset + bitSize` is not a multiple of 8 then there are unused low
108
+
* bits in the last byte of this buffer.
109
+
*
110
+
* @type {Uint8Array}
111
+
*/
112
+
rawBuffer;
113
+
/**
114
+
* Constructs a new bit array from a `Uint8Array`, an optional size in
115
+
* bits, and an optional bit offset.
116
+
*
117
+
* If no bit size is specified it is taken as `buffer.length * 8`, i.e. all
118
+
* bytes in the buffer make up the new bit array's data.
119
+
*
120
+
* If no bit offset is specified it defaults to zero, i.e. there are no unused
121
+
* high bits in the first byte of the buffer.
122
+
*
123
+
* @param {Uint8Array} buffer
124
+
* @param {number} [bitSize]
125
+
* @param {number} [bitOffset]
126
+
*/
127
+
constructor(buffer, bitSize, bitOffset) {
128
+
if (!(buffer instanceof Uint8Array)) {
129
+
throw globalThis.Error(
130
+
"BitArray can only be constructed from a Uint8Array"
131
+
);
132
+
}
133
+
this.bitSize = bitSize ?? buffer.length * 8;
134
+
this.byteSize = Math.trunc((this.bitSize + 7) / 8);
135
+
this.bitOffset = bitOffset ?? 0;
136
+
if (this.bitSize < 0) {
137
+
throw globalThis.Error(`BitArray bit size is invalid: ${this.bitSize}`);
138
+
}
139
+
if (this.bitOffset < 0 || this.bitOffset > 7) {
140
+
throw globalThis.Error(
141
+
`BitArray bit offset is invalid: ${this.bitOffset}`
142
+
);
143
+
}
144
+
if (buffer.length !== Math.trunc((this.bitOffset + this.bitSize + 7) / 8)) {
145
+
throw globalThis.Error("BitArray buffer length is invalid");
146
+
}
147
+
this.rawBuffer = buffer;
148
+
}
149
+
/**
150
+
* Returns a specific byte in this bit array. If the byte index is out of
151
+
* range then `undefined` is returned.
152
+
*
153
+
* When returning the final byte of a bit array with a bit size that's not a
154
+
* multiple of 8, the content of the unused low bits are undefined.
155
+
*
156
+
* @param {number} index
157
+
* @returns {number | undefined}
158
+
*/
159
+
byteAt(index3) {
160
+
if (index3 < 0 || index3 >= this.byteSize) {
161
+
return void 0;
162
+
}
163
+
return bitArrayByteAt(this.rawBuffer, this.bitOffset, index3);
164
+
}
165
+
/** @internal */
166
+
equals(other) {
167
+
if (this.bitSize !== other.bitSize) {
168
+
return false;
169
+
}
170
+
const wholeByteCount = Math.trunc(this.bitSize / 8);
171
+
if (this.bitOffset === 0 && other.bitOffset === 0) {
172
+
for (let i = 0; i < wholeByteCount; i++) {
173
+
if (this.rawBuffer[i] !== other.rawBuffer[i]) {
174
+
return false;
175
+
}
176
+
}
177
+
const trailingBitsCount = this.bitSize % 8;
178
+
if (trailingBitsCount) {
179
+
const unusedLowBitCount = 8 - trailingBitsCount;
180
+
if (this.rawBuffer[wholeByteCount] >> unusedLowBitCount !== other.rawBuffer[wholeByteCount] >> unusedLowBitCount) {
181
+
return false;
182
+
}
183
+
}
184
+
} else {
185
+
for (let i = 0; i < wholeByteCount; i++) {
186
+
const a2 = bitArrayByteAt(this.rawBuffer, this.bitOffset, i);
187
+
const b = bitArrayByteAt(other.rawBuffer, other.bitOffset, i);
188
+
if (a2 !== b) {
189
+
return false;
190
+
}
191
+
}
192
+
const trailingBitsCount = this.bitSize % 8;
193
+
if (trailingBitsCount) {
194
+
const a2 = bitArrayByteAt(
195
+
this.rawBuffer,
196
+
this.bitOffset,
197
+
wholeByteCount
198
+
);
199
+
const b = bitArrayByteAt(
200
+
other.rawBuffer,
201
+
other.bitOffset,
202
+
wholeByteCount
203
+
);
204
+
const unusedLowBitCount = 8 - trailingBitsCount;
205
+
if (a2 >> unusedLowBitCount !== b >> unusedLowBitCount) {
206
+
return false;
207
+
}
208
+
}
209
+
}
210
+
return true;
211
+
}
212
+
/**
213
+
* Returns this bit array's internal buffer.
214
+
*
215
+
* @deprecated Use `BitArray.byteAt()` or `BitArray.rawBuffer` instead.
216
+
*
217
+
* @returns {Uint8Array}
218
+
*/
219
+
get buffer() {
220
+
bitArrayPrintDeprecationWarning(
221
+
"buffer",
222
+
"Use BitArray.byteAt() or BitArray.rawBuffer instead"
223
+
);
224
+
if (this.bitOffset !== 0 || this.bitSize % 8 !== 0) {
225
+
throw new globalThis.Error(
226
+
"BitArray.buffer does not support unaligned bit arrays"
227
+
);
228
+
}
229
+
return this.rawBuffer;
230
+
}
231
+
/**
232
+
* Returns the length in bytes of this bit array's internal buffer.
233
+
*
234
+
* @deprecated Use `BitArray.bitSize` or `BitArray.byteSize` instead.
235
+
*
236
+
* @returns {number}
237
+
*/
238
+
get length() {
239
+
bitArrayPrintDeprecationWarning(
240
+
"length",
241
+
"Use BitArray.bitSize or BitArray.byteSize instead"
242
+
);
243
+
if (this.bitOffset !== 0 || this.bitSize % 8 !== 0) {
244
+
throw new globalThis.Error(
245
+
"BitArray.length does not support unaligned bit arrays"
246
+
);
247
+
}
248
+
return this.rawBuffer.length;
249
+
}
250
+
};
251
+
function bitArrayByteAt(buffer, bitOffset, index3) {
252
+
if (bitOffset === 0) {
253
+
return buffer[index3] ?? 0;
254
+
} else {
255
+
const a2 = buffer[index3] << bitOffset & 255;
256
+
const b = buffer[index3 + 1] >> 8 - bitOffset;
257
+
return a2 | b;
258
+
}
259
+
}
260
+
var UtfCodepoint = class {
261
+
constructor(value3) {
262
+
this.value = value3;
263
+
}
264
+
};
265
+
var isBitArrayDeprecationMessagePrinted = {};
266
+
function bitArrayPrintDeprecationWarning(name, message) {
267
+
if (isBitArrayDeprecationMessagePrinted[name]) {
268
+
return;
269
+
}
270
+
console.warn(
271
+
`Deprecated BitArray.${name} property used in JavaScript FFI code. ${message}.`
272
+
);
273
+
isBitArrayDeprecationMessagePrinted[name] = true;
274
+
}
275
+
function bitArraySlice(bitArray, start3, end) {
276
+
end ??= bitArray.bitSize;
277
+
bitArrayValidateRange(bitArray, start3, end);
278
+
if (start3 === end) {
279
+
return new BitArray(new Uint8Array());
280
+
}
281
+
if (start3 === 0 && end === bitArray.bitSize) {
282
+
return bitArray;
283
+
}
284
+
start3 += bitArray.bitOffset;
285
+
end += bitArray.bitOffset;
286
+
const startByteIndex = Math.trunc(start3 / 8);
287
+
const endByteIndex = Math.trunc((end + 7) / 8);
288
+
const byteLength = endByteIndex - startByteIndex;
289
+
let buffer;
290
+
if (startByteIndex === 0 && byteLength === bitArray.rawBuffer.byteLength) {
291
+
buffer = bitArray.rawBuffer;
292
+
} else {
293
+
buffer = new Uint8Array(
294
+
bitArray.rawBuffer.buffer,
295
+
bitArray.rawBuffer.byteOffset + startByteIndex,
296
+
byteLength
297
+
);
298
+
}
299
+
return new BitArray(buffer, end - start3, start3 % 8);
300
+
}
301
+
function bitArraySliceToInt(bitArray, start3, end, isBigEndian, isSigned) {
302
+
bitArrayValidateRange(bitArray, start3, end);
303
+
if (start3 === end) {
304
+
return 0;
305
+
}
306
+
start3 += bitArray.bitOffset;
307
+
end += bitArray.bitOffset;
308
+
const isStartByteAligned = start3 % 8 === 0;
309
+
const isEndByteAligned = end % 8 === 0;
310
+
if (isStartByteAligned && isEndByteAligned) {
311
+
return intFromAlignedSlice(
312
+
bitArray,
313
+
start3 / 8,
314
+
end / 8,
315
+
isBigEndian,
316
+
isSigned
317
+
);
318
+
}
319
+
const size = end - start3;
320
+
const startByteIndex = Math.trunc(start3 / 8);
321
+
const endByteIndex = Math.trunc((end - 1) / 8);
322
+
if (startByteIndex == endByteIndex) {
323
+
const mask2 = 255 >> start3 % 8;
324
+
const unusedLowBitCount = (8 - end % 8) % 8;
325
+
let value3 = (bitArray.rawBuffer[startByteIndex] & mask2) >> unusedLowBitCount;
326
+
if (isSigned) {
327
+
const highBit = 2 ** (size - 1);
328
+
if (value3 >= highBit) {
329
+
value3 -= highBit * 2;
330
+
}
331
+
}
332
+
return value3;
333
+
}
334
+
if (size <= 53) {
335
+
return intFromUnalignedSliceUsingNumber(
336
+
bitArray.rawBuffer,
337
+
start3,
338
+
end,
339
+
isBigEndian,
340
+
isSigned
341
+
);
342
+
} else {
343
+
return intFromUnalignedSliceUsingBigInt(
344
+
bitArray.rawBuffer,
345
+
start3,
346
+
end,
347
+
isBigEndian,
348
+
isSigned
349
+
);
350
+
}
351
+
}
352
+
function toBitArray(segments) {
353
+
if (segments.length === 0) {
354
+
return new BitArray(new Uint8Array());
355
+
}
356
+
if (segments.length === 1) {
357
+
const segment = segments[0];
358
+
if (segment instanceof BitArray) {
359
+
return segment;
360
+
}
361
+
if (segment instanceof Uint8Array) {
362
+
return new BitArray(segment);
363
+
}
364
+
return new BitArray(new Uint8Array(
365
+
/** @type {number[]} */
366
+
segments
367
+
));
368
+
}
369
+
let bitSize = 0;
370
+
let areAllSegmentsNumbers = true;
371
+
for (const segment of segments) {
372
+
if (segment instanceof BitArray) {
373
+
bitSize += segment.bitSize;
374
+
areAllSegmentsNumbers = false;
375
+
} else if (segment instanceof Uint8Array) {
376
+
bitSize += segment.byteLength * 8;
377
+
areAllSegmentsNumbers = false;
378
+
} else {
379
+
bitSize += 8;
380
+
}
381
+
}
382
+
if (areAllSegmentsNumbers) {
383
+
return new BitArray(new Uint8Array(
384
+
/** @type {number[]} */
385
+
segments
386
+
));
387
+
}
388
+
const buffer = new Uint8Array(Math.trunc((bitSize + 7) / 8));
389
+
let cursor = 0;
390
+
for (let segment of segments) {
391
+
const isCursorByteAligned = cursor % 8 === 0;
392
+
if (segment instanceof BitArray) {
393
+
if (isCursorByteAligned && segment.bitOffset === 0) {
394
+
buffer.set(segment.rawBuffer, cursor / 8);
395
+
cursor += segment.bitSize;
396
+
const trailingBitsCount = segment.bitSize % 8;
397
+
if (trailingBitsCount !== 0) {
398
+
const lastByteIndex = Math.trunc(cursor / 8);
399
+
buffer[lastByteIndex] >>= 8 - trailingBitsCount;
400
+
buffer[lastByteIndex] <<= 8 - trailingBitsCount;
401
+
}
402
+
} else {
403
+
appendUnalignedBits(
404
+
segment.rawBuffer,
405
+
segment.bitSize,
406
+
segment.bitOffset
407
+
);
408
+
}
409
+
} else if (segment instanceof Uint8Array) {
410
+
if (isCursorByteAligned) {
411
+
buffer.set(segment, cursor / 8);
412
+
cursor += segment.byteLength * 8;
413
+
} else {
414
+
appendUnalignedBits(segment, segment.byteLength * 8, 0);
415
+
}
416
+
} else {
417
+
if (isCursorByteAligned) {
418
+
buffer[cursor / 8] = segment;
419
+
cursor += 8;
420
+
} else {
421
+
appendUnalignedBits(new Uint8Array([segment]), 8, 0);
422
+
}
423
+
}
424
+
}
425
+
function appendUnalignedBits(unalignedBits, size, offset) {
426
+
if (size === 0) {
427
+
return;
428
+
}
429
+
const byteSize = Math.trunc(size + 7 / 8);
430
+
const highBitsCount = cursor % 8;
431
+
const lowBitsCount = 8 - highBitsCount;
432
+
let byteIndex = Math.trunc(cursor / 8);
433
+
for (let i = 0; i < byteSize; i++) {
434
+
let byte = bitArrayByteAt(unalignedBits, offset, i);
435
+
if (size < 8) {
436
+
byte >>= 8 - size;
437
+
byte <<= 8 - size;
438
+
}
439
+
buffer[byteIndex] |= byte >> highBitsCount;
440
+
let appendedBitsCount = size - Math.max(0, size - lowBitsCount);
441
+
size -= appendedBitsCount;
442
+
cursor += appendedBitsCount;
443
+
if (size === 0) {
444
+
break;
445
+
}
446
+
buffer[++byteIndex] = byte << lowBitsCount;
447
+
appendedBitsCount = size - Math.max(0, size - highBitsCount);
448
+
size -= appendedBitsCount;
449
+
cursor += appendedBitsCount;
450
+
}
451
+
}
452
+
return new BitArray(buffer, bitSize);
453
+
}
454
+
function sizedInt(value3, size, isBigEndian) {
455
+
if (size <= 0) {
456
+
return new Uint8Array();
457
+
}
458
+
if (size === 8) {
459
+
return new Uint8Array([value3]);
460
+
}
461
+
if (size < 8) {
462
+
value3 <<= 8 - size;
463
+
return new BitArray(new Uint8Array([value3]), size);
464
+
}
465
+
const buffer = new Uint8Array(Math.trunc((size + 7) / 8));
466
+
const trailingBitsCount = size % 8;
467
+
const unusedBitsCount = 8 - trailingBitsCount;
468
+
if (size <= 32) {
469
+
if (isBigEndian) {
470
+
let i = buffer.length - 1;
471
+
if (trailingBitsCount) {
472
+
buffer[i--] = value3 << unusedBitsCount & 255;
473
+
value3 >>= trailingBitsCount;
474
+
}
475
+
for (; i >= 0; i--) {
476
+
buffer[i] = value3;
477
+
value3 >>= 8;
478
+
}
479
+
} else {
480
+
let i = 0;
481
+
const wholeByteCount = Math.trunc(size / 8);
482
+
for (; i < wholeByteCount; i++) {
483
+
buffer[i] = value3;
484
+
value3 >>= 8;
485
+
}
486
+
if (trailingBitsCount) {
487
+
buffer[i] = value3 << unusedBitsCount;
488
+
}
489
+
}
490
+
} else {
491
+
const bigTrailingBitsCount = BigInt(trailingBitsCount);
492
+
const bigUnusedBitsCount = BigInt(unusedBitsCount);
493
+
let bigValue = BigInt(value3);
494
+
if (isBigEndian) {
495
+
let i = buffer.length - 1;
496
+
if (trailingBitsCount) {
497
+
buffer[i--] = Number(bigValue << bigUnusedBitsCount);
498
+
bigValue >>= bigTrailingBitsCount;
499
+
}
500
+
for (; i >= 0; i--) {
501
+
buffer[i] = Number(bigValue);
502
+
bigValue >>= 8n;
503
+
}
504
+
} else {
505
+
let i = 0;
506
+
const wholeByteCount = Math.trunc(size / 8);
507
+
for (; i < wholeByteCount; i++) {
508
+
buffer[i] = Number(bigValue);
509
+
bigValue >>= 8n;
510
+
}
511
+
if (trailingBitsCount) {
512
+
buffer[i] = Number(bigValue << bigUnusedBitsCount);
513
+
}
514
+
}
515
+
}
516
+
if (trailingBitsCount) {
517
+
return new BitArray(buffer, size);
518
+
}
519
+
return buffer;
520
+
}
521
+
function intFromAlignedSlice(bitArray, start3, end, isBigEndian, isSigned) {
522
+
const byteSize = end - start3;
523
+
if (byteSize <= 6) {
524
+
return intFromAlignedSliceUsingNumber(
525
+
bitArray.rawBuffer,
526
+
start3,
527
+
end,
528
+
isBigEndian,
529
+
isSigned
530
+
);
531
+
} else {
532
+
return intFromAlignedSliceUsingBigInt(
533
+
bitArray.rawBuffer,
534
+
start3,
535
+
end,
536
+
isBigEndian,
537
+
isSigned
538
+
);
539
+
}
540
+
}
541
+
function intFromAlignedSliceUsingNumber(buffer, start3, end, isBigEndian, isSigned) {
542
+
const byteSize = end - start3;
543
+
let value3 = 0;
544
+
if (isBigEndian) {
545
+
for (let i = start3; i < end; i++) {
546
+
value3 *= 256;
547
+
value3 += buffer[i];
548
+
}
549
+
} else {
550
+
for (let i = end - 1; i >= start3; i--) {
551
+
value3 *= 256;
552
+
value3 += buffer[i];
553
+
}
554
+
}
555
+
if (isSigned) {
556
+
const highBit = 2 ** (byteSize * 8 - 1);
557
+
if (value3 >= highBit) {
558
+
value3 -= highBit * 2;
559
+
}
560
+
}
561
+
return value3;
562
+
}
563
+
function intFromAlignedSliceUsingBigInt(buffer, start3, end, isBigEndian, isSigned) {
564
+
const byteSize = end - start3;
565
+
let value3 = 0n;
566
+
if (isBigEndian) {
567
+
for (let i = start3; i < end; i++) {
568
+
value3 *= 256n;
569
+
value3 += BigInt(buffer[i]);
570
+
}
571
+
} else {
572
+
for (let i = end - 1; i >= start3; i--) {
573
+
value3 *= 256n;
574
+
value3 += BigInt(buffer[i]);
575
+
}
576
+
}
577
+
if (isSigned) {
578
+
const highBit = 1n << BigInt(byteSize * 8 - 1);
579
+
if (value3 >= highBit) {
580
+
value3 -= highBit * 2n;
581
+
}
582
+
}
583
+
return Number(value3);
584
+
}
585
+
function intFromUnalignedSliceUsingNumber(buffer, start3, end, isBigEndian, isSigned) {
586
+
const isStartByteAligned = start3 % 8 === 0;
587
+
let size = end - start3;
588
+
let byteIndex = Math.trunc(start3 / 8);
589
+
let value3 = 0;
590
+
if (isBigEndian) {
591
+
if (!isStartByteAligned) {
592
+
const leadingBitsCount = 8 - start3 % 8;
593
+
value3 = buffer[byteIndex++] & (1 << leadingBitsCount) - 1;
594
+
size -= leadingBitsCount;
595
+
}
596
+
while (size >= 8) {
597
+
value3 *= 256;
598
+
value3 += buffer[byteIndex++];
599
+
size -= 8;
600
+
}
601
+
if (size > 0) {
602
+
value3 *= 2 ** size;
603
+
value3 += buffer[byteIndex] >> 8 - size;
604
+
}
605
+
} else {
606
+
if (isStartByteAligned) {
607
+
let size2 = end - start3;
608
+
let scale = 1;
609
+
while (size2 >= 8) {
610
+
value3 += buffer[byteIndex++] * scale;
611
+
scale *= 256;
612
+
size2 -= 8;
613
+
}
614
+
value3 += (buffer[byteIndex] >> 8 - size2) * scale;
615
+
} else {
616
+
const highBitsCount = start3 % 8;
617
+
const lowBitsCount = 8 - highBitsCount;
618
+
let size2 = end - start3;
619
+
let scale = 1;
620
+
while (size2 >= 8) {
621
+
const byte = buffer[byteIndex] << highBitsCount | buffer[byteIndex + 1] >> lowBitsCount;
622
+
value3 += (byte & 255) * scale;
623
+
scale *= 256;
624
+
size2 -= 8;
625
+
byteIndex++;
626
+
}
627
+
if (size2 > 0) {
628
+
const lowBitsUsed = size2 - Math.max(0, size2 - lowBitsCount);
629
+
let trailingByte = (buffer[byteIndex] & (1 << lowBitsCount) - 1) >> lowBitsCount - lowBitsUsed;
630
+
size2 -= lowBitsUsed;
631
+
if (size2 > 0) {
632
+
trailingByte *= 2 ** size2;
633
+
trailingByte += buffer[byteIndex + 1] >> 8 - size2;
634
+
}
635
+
value3 += trailingByte * scale;
636
+
}
637
+
}
638
+
}
639
+
if (isSigned) {
640
+
const highBit = 2 ** (end - start3 - 1);
641
+
if (value3 >= highBit) {
642
+
value3 -= highBit * 2;
643
+
}
644
+
}
645
+
return value3;
646
+
}
647
+
function intFromUnalignedSliceUsingBigInt(buffer, start3, end, isBigEndian, isSigned) {
648
+
const isStartByteAligned = start3 % 8 === 0;
649
+
let size = end - start3;
650
+
let byteIndex = Math.trunc(start3 / 8);
651
+
let value3 = 0n;
652
+
if (isBigEndian) {
653
+
if (!isStartByteAligned) {
654
+
const leadingBitsCount = 8 - start3 % 8;
655
+
value3 = BigInt(buffer[byteIndex++] & (1 << leadingBitsCount) - 1);
656
+
size -= leadingBitsCount;
657
+
}
658
+
while (size >= 8) {
659
+
value3 *= 256n;
660
+
value3 += BigInt(buffer[byteIndex++]);
661
+
size -= 8;
662
+
}
663
+
if (size > 0) {
664
+
value3 <<= BigInt(size);
665
+
value3 += BigInt(buffer[byteIndex] >> 8 - size);
666
+
}
667
+
} else {
668
+
if (isStartByteAligned) {
669
+
let size2 = end - start3;
670
+
let shift = 0n;
671
+
while (size2 >= 8) {
672
+
value3 += BigInt(buffer[byteIndex++]) << shift;
673
+
shift += 8n;
674
+
size2 -= 8;
675
+
}
676
+
value3 += BigInt(buffer[byteIndex] >> 8 - size2) << shift;
677
+
} else {
678
+
const highBitsCount = start3 % 8;
679
+
const lowBitsCount = 8 - highBitsCount;
680
+
let size2 = end - start3;
681
+
let shift = 0n;
682
+
while (size2 >= 8) {
683
+
const byte = buffer[byteIndex] << highBitsCount | buffer[byteIndex + 1] >> lowBitsCount;
684
+
value3 += BigInt(byte & 255) << shift;
685
+
shift += 8n;
686
+
size2 -= 8;
687
+
byteIndex++;
688
+
}
689
+
if (size2 > 0) {
690
+
const lowBitsUsed = size2 - Math.max(0, size2 - lowBitsCount);
691
+
let trailingByte = (buffer[byteIndex] & (1 << lowBitsCount) - 1) >> lowBitsCount - lowBitsUsed;
692
+
size2 -= lowBitsUsed;
693
+
if (size2 > 0) {
694
+
trailingByte <<= size2;
695
+
trailingByte += buffer[byteIndex + 1] >> 8 - size2;
696
+
}
697
+
value3 += BigInt(trailingByte) << shift;
698
+
}
699
+
}
700
+
}
701
+
if (isSigned) {
702
+
const highBit = 2n ** BigInt(end - start3 - 1);
703
+
if (value3 >= highBit) {
704
+
value3 -= highBit * 2n;
705
+
}
706
+
}
707
+
return Number(value3);
708
+
}
709
+
function bitArrayValidateRange(bitArray, start3, end) {
710
+
if (start3 < 0 || start3 > bitArray.bitSize || end < start3 || end > bitArray.bitSize) {
711
+
const msg = `Invalid bit array slice: start = ${start3}, end = ${end}, bit size = ${bitArray.bitSize}`;
712
+
throw new globalThis.Error(msg);
713
+
}
714
+
}
715
+
var Result = class _Result extends CustomType {
716
+
// @internal
717
+
static isResult(data) {
718
+
return data instanceof _Result;
719
+
}
720
+
};
721
+
var Ok = class extends Result {
722
+
constructor(value3) {
723
+
super();
724
+
this[0] = value3;
725
+
}
726
+
// @internal
727
+
isOk() {
728
+
return true;
729
+
}
730
+
};
731
+
var Error = class extends Result {
732
+
constructor(detail) {
733
+
super();
734
+
this[0] = detail;
735
+
}
736
+
// @internal
737
+
isOk() {
738
+
return false;
739
+
}
740
+
};
741
+
function isEqual(x, y) {
742
+
let values2 = [x, y];
743
+
while (values2.length) {
744
+
let a2 = values2.pop();
745
+
let b = values2.pop();
746
+
if (a2 === b) continue;
747
+
if (!isObject(a2) || !isObject(b)) return false;
748
+
let unequal = !structurallyCompatibleObjects(a2, b) || unequalDates(a2, b) || unequalBuffers(a2, b) || unequalArrays(a2, b) || unequalMaps(a2, b) || unequalSets(a2, b) || unequalRegExps(a2, b);
749
+
if (unequal) return false;
750
+
const proto = Object.getPrototypeOf(a2);
751
+
if (proto !== null && typeof proto.equals === "function") {
752
+
try {
753
+
if (a2.equals(b)) continue;
754
+
else return false;
755
+
} catch {
756
+
}
757
+
}
758
+
let [keys2, get] = getters(a2);
759
+
for (let k of keys2(a2)) {
760
+
values2.push(get(a2, k), get(b, k));
761
+
}
762
+
}
763
+
return true;
764
+
}
765
+
function getters(object3) {
766
+
if (object3 instanceof Map) {
767
+
return [(x) => x.keys(), (x, y) => x.get(y)];
768
+
} else {
769
+
let extra = object3 instanceof globalThis.Error ? ["message"] : [];
770
+
return [(x) => [...extra, ...Object.keys(x)], (x, y) => x[y]];
771
+
}
772
+
}
773
+
function unequalDates(a2, b) {
774
+
return a2 instanceof Date && (a2 > b || a2 < b);
775
+
}
776
+
function unequalBuffers(a2, b) {
777
+
return !(a2 instanceof BitArray) && a2.buffer instanceof ArrayBuffer && a2.BYTES_PER_ELEMENT && !(a2.byteLength === b.byteLength && a2.every((n, i) => n === b[i]));
778
+
}
779
+
function unequalArrays(a2, b) {
780
+
return Array.isArray(a2) && a2.length !== b.length;
781
+
}
782
+
function unequalMaps(a2, b) {
783
+
return a2 instanceof Map && a2.size !== b.size;
784
+
}
785
+
function unequalSets(a2, b) {
786
+
return a2 instanceof Set && (a2.size != b.size || [...a2].some((e) => !b.has(e)));
787
+
}
788
+
function unequalRegExps(a2, b) {
789
+
return a2 instanceof RegExp && (a2.source !== b.source || a2.flags !== b.flags);
790
+
}
791
+
function isObject(a2) {
792
+
return typeof a2 === "object" && a2 !== null;
793
+
}
794
+
function structurallyCompatibleObjects(a2, b) {
795
+
if (typeof a2 !== "object" && typeof b !== "object" && (!a2 || !b))
796
+
return false;
797
+
let nonstructural = [Promise, WeakSet, WeakMap, Function];
798
+
if (nonstructural.some((c) => a2 instanceof c)) return false;
799
+
return a2.constructor === b.constructor;
800
+
}
801
+
function divideFloat(a2, b) {
802
+
if (b === 0) {
803
+
return 0;
804
+
} else {
805
+
return a2 / b;
806
+
}
807
+
}
808
+
function makeError(variant, module, line, fn, message, extra) {
809
+
let error = new globalThis.Error(message);
810
+
error.gleam_error = variant;
811
+
error.module = module;
812
+
error.line = line;
813
+
error.function = fn;
814
+
error.fn = fn;
815
+
for (let k in extra) error[k] = extra[k];
816
+
return error;
817
+
}
818
+
819
+
// build/dev/javascript/gleam_stdlib/gleam/order.mjs
820
+
var Lt = class extends CustomType {
821
+
};
822
+
var Eq = class extends CustomType {
823
+
};
824
+
var Gt = class extends CustomType {
825
+
};
826
+
827
+
// build/dev/javascript/gleam_stdlib/gleam/option.mjs
828
+
var Some = class extends CustomType {
829
+
constructor(x0) {
830
+
super();
831
+
this[0] = x0;
832
+
}
833
+
};
834
+
var None = class extends CustomType {
835
+
};
836
+
function to_result(option, e) {
837
+
if (option instanceof Some) {
838
+
let a2 = option[0];
839
+
return new Ok(a2);
840
+
} else {
841
+
return new Error(e);
842
+
}
843
+
}
844
+
845
+
// build/dev/javascript/gleam_stdlib/gleam/dict.mjs
846
+
function insert(dict2, key, value3) {
847
+
return map_insert(key, value3, dict2);
848
+
}
849
+
function reverse_and_concat(loop$remaining, loop$accumulator) {
850
+
while (true) {
851
+
let remaining = loop$remaining;
852
+
let accumulator = loop$accumulator;
853
+
if (remaining.hasLength(0)) {
854
+
return accumulator;
855
+
} else {
856
+
let first2 = remaining.head;
857
+
let rest = remaining.tail;
858
+
loop$remaining = rest;
859
+
loop$accumulator = prepend(first2, accumulator);
860
+
}
861
+
}
862
+
}
863
+
function do_keys_loop(loop$list, loop$acc) {
864
+
while (true) {
865
+
let list2 = loop$list;
866
+
let acc = loop$acc;
867
+
if (list2.hasLength(0)) {
868
+
return reverse_and_concat(acc, toList([]));
869
+
} else {
870
+
let key = list2.head[0];
871
+
let rest = list2.tail;
872
+
loop$list = rest;
873
+
loop$acc = prepend(key, acc);
874
+
}
875
+
}
876
+
}
877
+
function keys(dict2) {
878
+
return do_keys_loop(map_to_list(dict2), toList([]));
879
+
}
880
+
881
+
// build/dev/javascript/gleam_stdlib/gleam/list.mjs
882
+
function reverse_and_prepend(loop$prefix, loop$suffix) {
883
+
while (true) {
884
+
let prefix = loop$prefix;
885
+
let suffix = loop$suffix;
886
+
if (prefix.hasLength(0)) {
887
+
return suffix;
888
+
} else {
889
+
let first$1 = prefix.head;
890
+
let rest$1 = prefix.tail;
891
+
loop$prefix = rest$1;
892
+
loop$suffix = prepend(first$1, suffix);
893
+
}
894
+
}
895
+
}
896
+
function reverse(list2) {
897
+
return reverse_and_prepend(list2, toList([]));
898
+
}
899
+
function map_loop(loop$list, loop$fun, loop$acc) {
900
+
while (true) {
901
+
let list2 = loop$list;
902
+
let fun = loop$fun;
903
+
let acc = loop$acc;
904
+
if (list2.hasLength(0)) {
905
+
return reverse(acc);
906
+
} else {
907
+
let first$1 = list2.head;
908
+
let rest$1 = list2.tail;
909
+
loop$list = rest$1;
910
+
loop$fun = fun;
911
+
loop$acc = prepend(fun(first$1), acc);
912
+
}
913
+
}
914
+
}
915
+
function map(list2, fun) {
916
+
return map_loop(list2, fun, toList([]));
917
+
}
918
+
function fold(loop$list, loop$initial, loop$fun) {
919
+
while (true) {
920
+
let list2 = loop$list;
921
+
let initial = loop$initial;
922
+
let fun = loop$fun;
923
+
if (list2.hasLength(0)) {
924
+
return initial;
925
+
} else {
926
+
let first$1 = list2.head;
927
+
let rest$1 = list2.tail;
928
+
loop$list = rest$1;
929
+
loop$initial = fun(initial, first$1);
930
+
loop$fun = fun;
931
+
}
932
+
}
933
+
}
934
+
function index_fold_loop(loop$over, loop$acc, loop$with, loop$index) {
935
+
while (true) {
936
+
let over = loop$over;
937
+
let acc = loop$acc;
938
+
let with$ = loop$with;
939
+
let index3 = loop$index;
940
+
if (over.hasLength(0)) {
941
+
return acc;
942
+
} else {
943
+
let first$1 = over.head;
944
+
let rest$1 = over.tail;
945
+
loop$over = rest$1;
946
+
loop$acc = with$(acc, first$1, index3);
947
+
loop$with = with$;
948
+
loop$index = index3 + 1;
949
+
}
950
+
}
951
+
}
952
+
function index_fold(list2, initial, fun) {
953
+
return index_fold_loop(list2, initial, fun, 0);
954
+
}
955
+
956
+
// build/dev/javascript/gleam_stdlib/gleam/string.mjs
957
+
function drop_start(loop$string, loop$num_graphemes) {
958
+
while (true) {
959
+
let string4 = loop$string;
960
+
let num_graphemes = loop$num_graphemes;
961
+
let $ = num_graphemes > 0;
962
+
if (!$) {
963
+
return string4;
964
+
} else {
965
+
let $1 = pop_grapheme(string4);
966
+
if ($1.isOk()) {
967
+
let string$1 = $1[0][1];
968
+
loop$string = string$1;
969
+
loop$num_graphemes = num_graphemes - 1;
970
+
} else {
971
+
return string4;
972
+
}
973
+
}
974
+
}
975
+
}
976
+
977
+
// build/dev/javascript/gleam_stdlib/gleam/result.mjs
978
+
function map2(result, fun) {
979
+
if (result.isOk()) {
980
+
let x = result[0];
981
+
return new Ok(fun(x));
982
+
} else {
983
+
let e = result[0];
984
+
return new Error(e);
985
+
}
986
+
}
987
+
function map_error(result, fun) {
988
+
if (result.isOk()) {
989
+
let x = result[0];
990
+
return new Ok(x);
991
+
} else {
992
+
let error = result[0];
993
+
return new Error(fun(error));
994
+
}
995
+
}
996
+
function try$(result, fun) {
997
+
if (result.isOk()) {
998
+
let x = result[0];
999
+
return fun(x);
1000
+
} else {
1001
+
let e = result[0];
1002
+
return new Error(e);
1003
+
}
1004
+
}
1005
+
function unwrap(result, default$) {
1006
+
if (result.isOk()) {
1007
+
let v = result[0];
1008
+
return v;
1009
+
} else {
1010
+
return default$;
1011
+
}
1012
+
}
1013
+
1014
+
// build/dev/javascript/gleam_stdlib/gleam/dynamic.mjs
1015
+
var DecodeError = class extends CustomType {
1016
+
constructor(expected, found, path) {
1017
+
super();
1018
+
this.expected = expected;
1019
+
this.found = found;
1020
+
this.path = path;
1021
+
}
1022
+
};
1023
+
function map_errors(result, f) {
1024
+
return map_error(
1025
+
result,
1026
+
(_capture) => {
1027
+
return map(_capture, f);
1028
+
}
1029
+
);
1030
+
}
1031
+
function string(data) {
1032
+
return decode_string(data);
1033
+
}
1034
+
function do_any(decoders) {
1035
+
return (data) => {
1036
+
if (decoders.hasLength(0)) {
1037
+
return new Error(
1038
+
toList([new DecodeError("another type", classify_dynamic(data), toList([]))])
1039
+
);
1040
+
} else {
1041
+
let decoder = decoders.head;
1042
+
let decoders$1 = decoders.tail;
1043
+
let $ = decoder(data);
1044
+
if ($.isOk()) {
1045
+
let decoded = $[0];
1046
+
return new Ok(decoded);
1047
+
} else {
1048
+
return do_any(decoders$1)(data);
1049
+
}
1050
+
}
1051
+
};
1052
+
}
1053
+
function push_path(error, name) {
1054
+
let name$1 = identity(name);
1055
+
let decoder = do_any(
1056
+
toList([
1057
+
decode_string,
1058
+
(x) => {
1059
+
return map2(decode_int(x), to_string);
1060
+
}
1061
+
])
1062
+
);
1063
+
let name$2 = (() => {
1064
+
let $ = decoder(name$1);
1065
+
if ($.isOk()) {
1066
+
let name$22 = $[0];
1067
+
return name$22;
1068
+
} else {
1069
+
let _pipe = toList(["<", classify_dynamic(name$1), ">"]);
1070
+
let _pipe$1 = concat(_pipe);
1071
+
return identity(_pipe$1);
1072
+
}
1073
+
})();
1074
+
let _record = error;
1075
+
return new DecodeError(
1076
+
_record.expected,
1077
+
_record.found,
1078
+
prepend(name$2, error.path)
1079
+
);
1080
+
}
1081
+
function field(name, inner_type) {
1082
+
return (value3) => {
1083
+
let missing_field_error = new DecodeError("field", "nothing", toList([]));
1084
+
return try$(
1085
+
decode_field(value3, name),
1086
+
(maybe_inner) => {
1087
+
let _pipe = maybe_inner;
1088
+
let _pipe$1 = to_result(_pipe, toList([missing_field_error]));
1089
+
let _pipe$2 = try$(_pipe$1, inner_type);
1090
+
return map_errors(
1091
+
_pipe$2,
1092
+
(_capture) => {
1093
+
return push_path(_capture, name);
1094
+
}
1095
+
);
1096
+
}
1097
+
);
1098
+
};
1099
+
}
1100
+
1101
+
// build/dev/javascript/gleam_stdlib/dict.mjs
1102
+
var referenceMap = /* @__PURE__ */ new WeakMap();
1103
+
var tempDataView = /* @__PURE__ */ new DataView(
1104
+
/* @__PURE__ */ new ArrayBuffer(8)
1105
+
);
1106
+
var referenceUID = 0;
1107
+
function hashByReference(o) {
1108
+
const known = referenceMap.get(o);
1109
+
if (known !== void 0) {
1110
+
return known;
1111
+
}
1112
+
const hash = referenceUID++;
1113
+
if (referenceUID === 2147483647) {
1114
+
referenceUID = 0;
1115
+
}
1116
+
referenceMap.set(o, hash);
1117
+
return hash;
1118
+
}
1119
+
function hashMerge(a2, b) {
1120
+
return a2 ^ b + 2654435769 + (a2 << 6) + (a2 >> 2) | 0;
1121
+
}
1122
+
function hashString(s) {
1123
+
let hash = 0;
1124
+
const len = s.length;
1125
+
for (let i = 0; i < len; i++) {
1126
+
hash = Math.imul(31, hash) + s.charCodeAt(i) | 0;
1127
+
}
1128
+
return hash;
1129
+
}
1130
+
function hashNumber(n) {
1131
+
tempDataView.setFloat64(0, n);
1132
+
const i = tempDataView.getInt32(0);
1133
+
const j = tempDataView.getInt32(4);
1134
+
return Math.imul(73244475, i >> 16 ^ i) ^ j;
1135
+
}
1136
+
function hashBigInt(n) {
1137
+
return hashString(n.toString());
1138
+
}
1139
+
function hashObject(o) {
1140
+
const proto = Object.getPrototypeOf(o);
1141
+
if (proto !== null && typeof proto.hashCode === "function") {
1142
+
try {
1143
+
const code2 = o.hashCode(o);
1144
+
if (typeof code2 === "number") {
1145
+
return code2;
1146
+
}
1147
+
} catch {
1148
+
}
1149
+
}
1150
+
if (o instanceof Promise || o instanceof WeakSet || o instanceof WeakMap) {
1151
+
return hashByReference(o);
1152
+
}
1153
+
if (o instanceof Date) {
1154
+
return hashNumber(o.getTime());
1155
+
}
1156
+
let h = 0;
1157
+
if (o instanceof ArrayBuffer) {
1158
+
o = new Uint8Array(o);
1159
+
}
1160
+
if (Array.isArray(o) || o instanceof Uint8Array) {
1161
+
for (let i = 0; i < o.length; i++) {
1162
+
h = Math.imul(31, h) + getHash(o[i]) | 0;
1163
+
}
1164
+
} else if (o instanceof Set) {
1165
+
o.forEach((v) => {
1166
+
h = h + getHash(v) | 0;
1167
+
});
1168
+
} else if (o instanceof Map) {
1169
+
o.forEach((v, k) => {
1170
+
h = h + hashMerge(getHash(v), getHash(k)) | 0;
1171
+
});
1172
+
} else {
1173
+
const keys2 = Object.keys(o);
1174
+
for (let i = 0; i < keys2.length; i++) {
1175
+
const k = keys2[i];
1176
+
const v = o[k];
1177
+
h = h + hashMerge(getHash(v), hashString(k)) | 0;
1178
+
}
1179
+
}
1180
+
return h;
1181
+
}
1182
+
function getHash(u) {
1183
+
if (u === null) return 1108378658;
1184
+
if (u === void 0) return 1108378659;
1185
+
if (u === true) return 1108378657;
1186
+
if (u === false) return 1108378656;
1187
+
switch (typeof u) {
1188
+
case "number":
1189
+
return hashNumber(u);
1190
+
case "string":
1191
+
return hashString(u);
1192
+
case "bigint":
1193
+
return hashBigInt(u);
1194
+
case "object":
1195
+
return hashObject(u);
1196
+
case "symbol":
1197
+
return hashByReference(u);
1198
+
case "function":
1199
+
return hashByReference(u);
1200
+
default:
1201
+
return 0;
1202
+
}
1203
+
}
1204
+
var SHIFT = 5;
1205
+
var BUCKET_SIZE = Math.pow(2, SHIFT);
1206
+
var MASK = BUCKET_SIZE - 1;
1207
+
var MAX_INDEX_NODE = BUCKET_SIZE / 2;
1208
+
var MIN_ARRAY_NODE = BUCKET_SIZE / 4;
1209
+
var ENTRY = 0;
1210
+
var ARRAY_NODE = 1;
1211
+
var INDEX_NODE = 2;
1212
+
var COLLISION_NODE = 3;
1213
+
var EMPTY = {
1214
+
type: INDEX_NODE,
1215
+
bitmap: 0,
1216
+
array: []
1217
+
};
1218
+
function mask(hash, shift) {
1219
+
return hash >>> shift & MASK;
1220
+
}
1221
+
function bitpos(hash, shift) {
1222
+
return 1 << mask(hash, shift);
1223
+
}
1224
+
function bitcount(x) {
1225
+
x -= x >> 1 & 1431655765;
1226
+
x = (x & 858993459) + (x >> 2 & 858993459);
1227
+
x = x + (x >> 4) & 252645135;
1228
+
x += x >> 8;
1229
+
x += x >> 16;
1230
+
return x & 127;
1231
+
}
1232
+
function index(bitmap, bit) {
1233
+
return bitcount(bitmap & bit - 1);
1234
+
}
1235
+
function cloneAndSet(arr, at, val) {
1236
+
const len = arr.length;
1237
+
const out = new Array(len);
1238
+
for (let i = 0; i < len; ++i) {
1239
+
out[i] = arr[i];
1240
+
}
1241
+
out[at] = val;
1242
+
return out;
1243
+
}
1244
+
function spliceIn(arr, at, val) {
1245
+
const len = arr.length;
1246
+
const out = new Array(len + 1);
1247
+
let i = 0;
1248
+
let g = 0;
1249
+
while (i < at) {
1250
+
out[g++] = arr[i++];
1251
+
}
1252
+
out[g++] = val;
1253
+
while (i < len) {
1254
+
out[g++] = arr[i++];
1255
+
}
1256
+
return out;
1257
+
}
1258
+
function spliceOut(arr, at) {
1259
+
const len = arr.length;
1260
+
const out = new Array(len - 1);
1261
+
let i = 0;
1262
+
let g = 0;
1263
+
while (i < at) {
1264
+
out[g++] = arr[i++];
1265
+
}
1266
+
++i;
1267
+
while (i < len) {
1268
+
out[g++] = arr[i++];
1269
+
}
1270
+
return out;
1271
+
}
1272
+
function createNode(shift, key1, val1, key2hash, key2, val2) {
1273
+
const key1hash = getHash(key1);
1274
+
if (key1hash === key2hash) {
1275
+
return {
1276
+
type: COLLISION_NODE,
1277
+
hash: key1hash,
1278
+
array: [
1279
+
{ type: ENTRY, k: key1, v: val1 },
1280
+
{ type: ENTRY, k: key2, v: val2 }
1281
+
]
1282
+
};
1283
+
}
1284
+
const addedLeaf = { val: false };
1285
+
return assoc(
1286
+
assocIndex(EMPTY, shift, key1hash, key1, val1, addedLeaf),
1287
+
shift,
1288
+
key2hash,
1289
+
key2,
1290
+
val2,
1291
+
addedLeaf
1292
+
);
1293
+
}
1294
+
function assoc(root, shift, hash, key, val, addedLeaf) {
1295
+
switch (root.type) {
1296
+
case ARRAY_NODE:
1297
+
return assocArray(root, shift, hash, key, val, addedLeaf);
1298
+
case INDEX_NODE:
1299
+
return assocIndex(root, shift, hash, key, val, addedLeaf);
1300
+
case COLLISION_NODE:
1301
+
return assocCollision(root, shift, hash, key, val, addedLeaf);
1302
+
}
1303
+
}
1304
+
function assocArray(root, shift, hash, key, val, addedLeaf) {
1305
+
const idx = mask(hash, shift);
1306
+
const node = root.array[idx];
1307
+
if (node === void 0) {
1308
+
addedLeaf.val = true;
1309
+
return {
1310
+
type: ARRAY_NODE,
1311
+
size: root.size + 1,
1312
+
array: cloneAndSet(root.array, idx, { type: ENTRY, k: key, v: val })
1313
+
};
1314
+
}
1315
+
if (node.type === ENTRY) {
1316
+
if (isEqual(key, node.k)) {
1317
+
if (val === node.v) {
1318
+
return root;
1319
+
}
1320
+
return {
1321
+
type: ARRAY_NODE,
1322
+
size: root.size,
1323
+
array: cloneAndSet(root.array, idx, {
1324
+
type: ENTRY,
1325
+
k: key,
1326
+
v: val
1327
+
})
1328
+
};
1329
+
}
1330
+
addedLeaf.val = true;
1331
+
return {
1332
+
type: ARRAY_NODE,
1333
+
size: root.size,
1334
+
array: cloneAndSet(
1335
+
root.array,
1336
+
idx,
1337
+
createNode(shift + SHIFT, node.k, node.v, hash, key, val)
1338
+
)
1339
+
};
1340
+
}
1341
+
const n = assoc(node, shift + SHIFT, hash, key, val, addedLeaf);
1342
+
if (n === node) {
1343
+
return root;
1344
+
}
1345
+
return {
1346
+
type: ARRAY_NODE,
1347
+
size: root.size,
1348
+
array: cloneAndSet(root.array, idx, n)
1349
+
};
1350
+
}
1351
+
function assocIndex(root, shift, hash, key, val, addedLeaf) {
1352
+
const bit = bitpos(hash, shift);
1353
+
const idx = index(root.bitmap, bit);
1354
+
if ((root.bitmap & bit) !== 0) {
1355
+
const node = root.array[idx];
1356
+
if (node.type !== ENTRY) {
1357
+
const n = assoc(node, shift + SHIFT, hash, key, val, addedLeaf);
1358
+
if (n === node) {
1359
+
return root;
1360
+
}
1361
+
return {
1362
+
type: INDEX_NODE,
1363
+
bitmap: root.bitmap,
1364
+
array: cloneAndSet(root.array, idx, n)
1365
+
};
1366
+
}
1367
+
const nodeKey = node.k;
1368
+
if (isEqual(key, nodeKey)) {
1369
+
if (val === node.v) {
1370
+
return root;
1371
+
}
1372
+
return {
1373
+
type: INDEX_NODE,
1374
+
bitmap: root.bitmap,
1375
+
array: cloneAndSet(root.array, idx, {
1376
+
type: ENTRY,
1377
+
k: key,
1378
+
v: val
1379
+
})
1380
+
};
1381
+
}
1382
+
addedLeaf.val = true;
1383
+
return {
1384
+
type: INDEX_NODE,
1385
+
bitmap: root.bitmap,
1386
+
array: cloneAndSet(
1387
+
root.array,
1388
+
idx,
1389
+
createNode(shift + SHIFT, nodeKey, node.v, hash, key, val)
1390
+
)
1391
+
};
1392
+
} else {
1393
+
const n = root.array.length;
1394
+
if (n >= MAX_INDEX_NODE) {
1395
+
const nodes = new Array(32);
1396
+
const jdx = mask(hash, shift);
1397
+
nodes[jdx] = assocIndex(EMPTY, shift + SHIFT, hash, key, val, addedLeaf);
1398
+
let j = 0;
1399
+
let bitmap = root.bitmap;
1400
+
for (let i = 0; i < 32; i++) {
1401
+
if ((bitmap & 1) !== 0) {
1402
+
const node = root.array[j++];
1403
+
nodes[i] = node;
1404
+
}
1405
+
bitmap = bitmap >>> 1;
1406
+
}
1407
+
return {
1408
+
type: ARRAY_NODE,
1409
+
size: n + 1,
1410
+
array: nodes
1411
+
};
1412
+
} else {
1413
+
const newArray = spliceIn(root.array, idx, {
1414
+
type: ENTRY,
1415
+
k: key,
1416
+
v: val
1417
+
});
1418
+
addedLeaf.val = true;
1419
+
return {
1420
+
type: INDEX_NODE,
1421
+
bitmap: root.bitmap | bit,
1422
+
array: newArray
1423
+
};
1424
+
}
1425
+
}
1426
+
}
1427
+
function assocCollision(root, shift, hash, key, val, addedLeaf) {
1428
+
if (hash === root.hash) {
1429
+
const idx = collisionIndexOf(root, key);
1430
+
if (idx !== -1) {
1431
+
const entry = root.array[idx];
1432
+
if (entry.v === val) {
1433
+
return root;
1434
+
}
1435
+
return {
1436
+
type: COLLISION_NODE,
1437
+
hash,
1438
+
array: cloneAndSet(root.array, idx, { type: ENTRY, k: key, v: val })
1439
+
};
1440
+
}
1441
+
const size = root.array.length;
1442
+
addedLeaf.val = true;
1443
+
return {
1444
+
type: COLLISION_NODE,
1445
+
hash,
1446
+
array: cloneAndSet(root.array, size, { type: ENTRY, k: key, v: val })
1447
+
};
1448
+
}
1449
+
return assoc(
1450
+
{
1451
+
type: INDEX_NODE,
1452
+
bitmap: bitpos(root.hash, shift),
1453
+
array: [root]
1454
+
},
1455
+
shift,
1456
+
hash,
1457
+
key,
1458
+
val,
1459
+
addedLeaf
1460
+
);
1461
+
}
1462
+
function collisionIndexOf(root, key) {
1463
+
const size = root.array.length;
1464
+
for (let i = 0; i < size; i++) {
1465
+
if (isEqual(key, root.array[i].k)) {
1466
+
return i;
1467
+
}
1468
+
}
1469
+
return -1;
1470
+
}
1471
+
function find(root, shift, hash, key) {
1472
+
switch (root.type) {
1473
+
case ARRAY_NODE:
1474
+
return findArray(root, shift, hash, key);
1475
+
case INDEX_NODE:
1476
+
return findIndex(root, shift, hash, key);
1477
+
case COLLISION_NODE:
1478
+
return findCollision(root, key);
1479
+
}
1480
+
}
1481
+
function findArray(root, shift, hash, key) {
1482
+
const idx = mask(hash, shift);
1483
+
const node = root.array[idx];
1484
+
if (node === void 0) {
1485
+
return void 0;
1486
+
}
1487
+
if (node.type !== ENTRY) {
1488
+
return find(node, shift + SHIFT, hash, key);
1489
+
}
1490
+
if (isEqual(key, node.k)) {
1491
+
return node;
1492
+
}
1493
+
return void 0;
1494
+
}
1495
+
function findIndex(root, shift, hash, key) {
1496
+
const bit = bitpos(hash, shift);
1497
+
if ((root.bitmap & bit) === 0) {
1498
+
return void 0;
1499
+
}
1500
+
const idx = index(root.bitmap, bit);
1501
+
const node = root.array[idx];
1502
+
if (node.type !== ENTRY) {
1503
+
return find(node, shift + SHIFT, hash, key);
1504
+
}
1505
+
if (isEqual(key, node.k)) {
1506
+
return node;
1507
+
}
1508
+
return void 0;
1509
+
}
1510
+
function findCollision(root, key) {
1511
+
const idx = collisionIndexOf(root, key);
1512
+
if (idx < 0) {
1513
+
return void 0;
1514
+
}
1515
+
return root.array[idx];
1516
+
}
1517
+
function without(root, shift, hash, key) {
1518
+
switch (root.type) {
1519
+
case ARRAY_NODE:
1520
+
return withoutArray(root, shift, hash, key);
1521
+
case INDEX_NODE:
1522
+
return withoutIndex(root, shift, hash, key);
1523
+
case COLLISION_NODE:
1524
+
return withoutCollision(root, key);
1525
+
}
1526
+
}
1527
+
function withoutArray(root, shift, hash, key) {
1528
+
const idx = mask(hash, shift);
1529
+
const node = root.array[idx];
1530
+
if (node === void 0) {
1531
+
return root;
1532
+
}
1533
+
let n = void 0;
1534
+
if (node.type === ENTRY) {
1535
+
if (!isEqual(node.k, key)) {
1536
+
return root;
1537
+
}
1538
+
} else {
1539
+
n = without(node, shift + SHIFT, hash, key);
1540
+
if (n === node) {
1541
+
return root;
1542
+
}
1543
+
}
1544
+
if (n === void 0) {
1545
+
if (root.size <= MIN_ARRAY_NODE) {
1546
+
const arr = root.array;
1547
+
const out = new Array(root.size - 1);
1548
+
let i = 0;
1549
+
let j = 0;
1550
+
let bitmap = 0;
1551
+
while (i < idx) {
1552
+
const nv = arr[i];
1553
+
if (nv !== void 0) {
1554
+
out[j] = nv;
1555
+
bitmap |= 1 << i;
1556
+
++j;
1557
+
}
1558
+
++i;
1559
+
}
1560
+
++i;
1561
+
while (i < arr.length) {
1562
+
const nv = arr[i];
1563
+
if (nv !== void 0) {
1564
+
out[j] = nv;
1565
+
bitmap |= 1 << i;
1566
+
++j;
1567
+
}
1568
+
++i;
1569
+
}
1570
+
return {
1571
+
type: INDEX_NODE,
1572
+
bitmap,
1573
+
array: out
1574
+
};
1575
+
}
1576
+
return {
1577
+
type: ARRAY_NODE,
1578
+
size: root.size - 1,
1579
+
array: cloneAndSet(root.array, idx, n)
1580
+
};
1581
+
}
1582
+
return {
1583
+
type: ARRAY_NODE,
1584
+
size: root.size,
1585
+
array: cloneAndSet(root.array, idx, n)
1586
+
};
1587
+
}
1588
+
function withoutIndex(root, shift, hash, key) {
1589
+
const bit = bitpos(hash, shift);
1590
+
if ((root.bitmap & bit) === 0) {
1591
+
return root;
1592
+
}
1593
+
const idx = index(root.bitmap, bit);
1594
+
const node = root.array[idx];
1595
+
if (node.type !== ENTRY) {
1596
+
const n = without(node, shift + SHIFT, hash, key);
1597
+
if (n === node) {
1598
+
return root;
1599
+
}
1600
+
if (n !== void 0) {
1601
+
return {
1602
+
type: INDEX_NODE,
1603
+
bitmap: root.bitmap,
1604
+
array: cloneAndSet(root.array, idx, n)
1605
+
};
1606
+
}
1607
+
if (root.bitmap === bit) {
1608
+
return void 0;
1609
+
}
1610
+
return {
1611
+
type: INDEX_NODE,
1612
+
bitmap: root.bitmap ^ bit,
1613
+
array: spliceOut(root.array, idx)
1614
+
};
1615
+
}
1616
+
if (isEqual(key, node.k)) {
1617
+
if (root.bitmap === bit) {
1618
+
return void 0;
1619
+
}
1620
+
return {
1621
+
type: INDEX_NODE,
1622
+
bitmap: root.bitmap ^ bit,
1623
+
array: spliceOut(root.array, idx)
1624
+
};
1625
+
}
1626
+
return root;
1627
+
}
1628
+
function withoutCollision(root, key) {
1629
+
const idx = collisionIndexOf(root, key);
1630
+
if (idx < 0) {
1631
+
return root;
1632
+
}
1633
+
if (root.array.length === 1) {
1634
+
return void 0;
1635
+
}
1636
+
return {
1637
+
type: COLLISION_NODE,
1638
+
hash: root.hash,
1639
+
array: spliceOut(root.array, idx)
1640
+
};
1641
+
}
1642
+
function forEach(root, fn) {
1643
+
if (root === void 0) {
1644
+
return;
1645
+
}
1646
+
const items = root.array;
1647
+
const size = items.length;
1648
+
for (let i = 0; i < size; i++) {
1649
+
const item = items[i];
1650
+
if (item === void 0) {
1651
+
continue;
1652
+
}
1653
+
if (item.type === ENTRY) {
1654
+
fn(item.v, item.k);
1655
+
continue;
1656
+
}
1657
+
forEach(item, fn);
1658
+
}
1659
+
}
1660
+
var Dict = class _Dict {
1661
+
/**
1662
+
* @template V
1663
+
* @param {Record<string,V>} o
1664
+
* @returns {Dict<string,V>}
1665
+
*/
1666
+
static fromObject(o) {
1667
+
const keys2 = Object.keys(o);
1668
+
let m = _Dict.new();
1669
+
for (let i = 0; i < keys2.length; i++) {
1670
+
const k = keys2[i];
1671
+
m = m.set(k, o[k]);
1672
+
}
1673
+
return m;
1674
+
}
1675
+
/**
1676
+
* @template K,V
1677
+
* @param {Map<K,V>} o
1678
+
* @returns {Dict<K,V>}
1679
+
*/
1680
+
static fromMap(o) {
1681
+
let m = _Dict.new();
1682
+
o.forEach((v, k) => {
1683
+
m = m.set(k, v);
1684
+
});
1685
+
return m;
1686
+
}
1687
+
static new() {
1688
+
return new _Dict(void 0, 0);
1689
+
}
1690
+
/**
1691
+
* @param {undefined | Node<K,V>} root
1692
+
* @param {number} size
1693
+
*/
1694
+
constructor(root, size) {
1695
+
this.root = root;
1696
+
this.size = size;
1697
+
}
1698
+
/**
1699
+
* @template NotFound
1700
+
* @param {K} key
1701
+
* @param {NotFound} notFound
1702
+
* @returns {NotFound | V}
1703
+
*/
1704
+
get(key, notFound) {
1705
+
if (this.root === void 0) {
1706
+
return notFound;
1707
+
}
1708
+
const found = find(this.root, 0, getHash(key), key);
1709
+
if (found === void 0) {
1710
+
return notFound;
1711
+
}
1712
+
return found.v;
1713
+
}
1714
+
/**
1715
+
* @param {K} key
1716
+
* @param {V} val
1717
+
* @returns {Dict<K,V>}
1718
+
*/
1719
+
set(key, val) {
1720
+
const addedLeaf = { val: false };
1721
+
const root = this.root === void 0 ? EMPTY : this.root;
1722
+
const newRoot = assoc(root, 0, getHash(key), key, val, addedLeaf);
1723
+
if (newRoot === this.root) {
1724
+
return this;
1725
+
}
1726
+
return new _Dict(newRoot, addedLeaf.val ? this.size + 1 : this.size);
1727
+
}
1728
+
/**
1729
+
* @param {K} key
1730
+
* @returns {Dict<K,V>}
1731
+
*/
1732
+
delete(key) {
1733
+
if (this.root === void 0) {
1734
+
return this;
1735
+
}
1736
+
const newRoot = without(this.root, 0, getHash(key), key);
1737
+
if (newRoot === this.root) {
1738
+
return this;
1739
+
}
1740
+
if (newRoot === void 0) {
1741
+
return _Dict.new();
1742
+
}
1743
+
return new _Dict(newRoot, this.size - 1);
1744
+
}
1745
+
/**
1746
+
* @param {K} key
1747
+
* @returns {boolean}
1748
+
*/
1749
+
has(key) {
1750
+
if (this.root === void 0) {
1751
+
return false;
1752
+
}
1753
+
return find(this.root, 0, getHash(key), key) !== void 0;
1754
+
}
1755
+
/**
1756
+
* @returns {[K,V][]}
1757
+
*/
1758
+
entries() {
1759
+
if (this.root === void 0) {
1760
+
return [];
1761
+
}
1762
+
const result = [];
1763
+
this.forEach((v, k) => result.push([k, v]));
1764
+
return result;
1765
+
}
1766
+
/**
1767
+
*
1768
+
* @param {(val:V,key:K)=>void} fn
1769
+
*/
1770
+
forEach(fn) {
1771
+
forEach(this.root, fn);
1772
+
}
1773
+
hashCode() {
1774
+
let h = 0;
1775
+
this.forEach((v, k) => {
1776
+
h = h + hashMerge(getHash(v), getHash(k)) | 0;
1777
+
});
1778
+
return h;
1779
+
}
1780
+
/**
1781
+
* @param {unknown} o
1782
+
* @returns {boolean}
1783
+
*/
1784
+
equals(o) {
1785
+
if (!(o instanceof _Dict) || this.size !== o.size) {
1786
+
return false;
1787
+
}
1788
+
try {
1789
+
this.forEach((v, k) => {
1790
+
if (!isEqual(o.get(k, !v), v)) {
1791
+
throw unequalDictSymbol;
1792
+
}
1793
+
});
1794
+
return true;
1795
+
} catch (e) {
1796
+
if (e === unequalDictSymbol) {
1797
+
return false;
1798
+
}
1799
+
throw e;
1800
+
}
1801
+
}
1802
+
};
1803
+
var unequalDictSymbol = /* @__PURE__ */ Symbol();
1804
+
1805
+
// build/dev/javascript/gleam_stdlib/gleam_stdlib.mjs
1806
+
var Nil = void 0;
1807
+
var NOT_FOUND = {};
1808
+
function identity(x) {
1809
+
return x;
1810
+
}
1811
+
function to_string(term) {
1812
+
return term.toString();
1813
+
}
1814
+
function int_to_base_string(int3, base) {
1815
+
return int3.toString(base).toUpperCase();
1816
+
}
1817
+
var segmenter = void 0;
1818
+
function graphemes_iterator(string4) {
1819
+
if (globalThis.Intl && Intl.Segmenter) {
1820
+
segmenter ||= new Intl.Segmenter();
1821
+
return segmenter.segment(string4)[Symbol.iterator]();
1822
+
}
1823
+
}
1824
+
function pop_grapheme(string4) {
1825
+
let first2;
1826
+
const iterator = graphemes_iterator(string4);
1827
+
if (iterator) {
1828
+
first2 = iterator.next().value?.segment;
1829
+
} else {
1830
+
first2 = string4.match(/./su)?.[0];
1831
+
}
1832
+
if (first2) {
1833
+
return new Ok([first2, string4.slice(first2.length)]);
1834
+
} else {
1835
+
return new Error(Nil);
1836
+
}
1837
+
}
1838
+
function concat(xs) {
1839
+
let result = "";
1840
+
for (const x of xs) {
1841
+
result = result + x;
1842
+
}
1843
+
return result;
1844
+
}
1845
+
var unicode_whitespaces = [
1846
+
" ",
1847
+
// Space
1848
+
" ",
1849
+
// Horizontal tab
1850
+
"\n",
1851
+
// Line feed
1852
+
"\v",
1853
+
// Vertical tab
1854
+
"\f",
1855
+
// Form feed
1856
+
"\r",
1857
+
// Carriage return
1858
+
"\x85",
1859
+
// Next line
1860
+
"\u2028",
1861
+
// Line separator
1862
+
"\u2029"
1863
+
// Paragraph separator
1864
+
].join("");
1865
+
var trim_start_regex = /* @__PURE__ */ new RegExp(
1866
+
`^[${unicode_whitespaces}]*`
1867
+
);
1868
+
var trim_end_regex = /* @__PURE__ */ new RegExp(`[${unicode_whitespaces}]*$`);
1869
+
function floor(float4) {
1870
+
return Math.floor(float4);
1871
+
}
1872
+
function round2(float4) {
1873
+
return Math.round(float4);
1874
+
}
1875
+
function new_map() {
1876
+
return Dict.new();
1877
+
}
1878
+
function map_to_list(map4) {
1879
+
return List.fromArray(map4.entries());
1880
+
}
1881
+
function map_get(map4, key) {
1882
+
const value3 = map4.get(key, NOT_FOUND);
1883
+
if (value3 === NOT_FOUND) {
1884
+
return new Error(Nil);
1885
+
}
1886
+
return new Ok(value3);
1887
+
}
1888
+
function map_insert(key, value3, map4) {
1889
+
return map4.set(key, value3);
1890
+
}
1891
+
function classify_dynamic(data) {
1892
+
if (typeof data === "string") {
1893
+
return "String";
1894
+
} else if (typeof data === "boolean") {
1895
+
return "Bool";
1896
+
} else if (data instanceof Result) {
1897
+
return "Result";
1898
+
} else if (data instanceof List) {
1899
+
return "List";
1900
+
} else if (data instanceof BitArray) {
1901
+
return "BitArray";
1902
+
} else if (data instanceof Dict) {
1903
+
return "Dict";
1904
+
} else if (Number.isInteger(data)) {
1905
+
return "Int";
1906
+
} else if (Array.isArray(data)) {
1907
+
return `Tuple of ${data.length} elements`;
1908
+
} else if (typeof data === "number") {
1909
+
return "Float";
1910
+
} else if (data === null) {
1911
+
return "Null";
1912
+
} else if (data === void 0) {
1913
+
return "Nil";
1914
+
} else {
1915
+
const type = typeof data;
1916
+
return type.charAt(0).toUpperCase() + type.slice(1);
1917
+
}
1918
+
}
1919
+
function decoder_error(expected, got) {
1920
+
return decoder_error_no_classify(expected, classify_dynamic(got));
1921
+
}
1922
+
function decoder_error_no_classify(expected, got) {
1923
+
return new Error(
1924
+
List.fromArray([new DecodeError(expected, got, List.fromArray([]))])
1925
+
);
1926
+
}
1927
+
function decode_string(data) {
1928
+
return typeof data === "string" ? new Ok(data) : decoder_error("String", data);
1929
+
}
1930
+
function decode_int(data) {
1931
+
return Number.isInteger(data) ? new Ok(data) : decoder_error("Int", data);
1932
+
}
1933
+
function decode_field(value3, name) {
1934
+
const not_a_map_error = () => decoder_error("Dict", value3);
1935
+
if (value3 instanceof Dict || value3 instanceof WeakMap || value3 instanceof Map) {
1936
+
const entry = map_get(value3, name);
1937
+
return new Ok(entry.isOk() ? new Some(entry[0]) : new None());
1938
+
} else if (value3 === null) {
1939
+
return not_a_map_error();
1940
+
} else if (Object.getPrototypeOf(value3) == Object.prototype) {
1941
+
return try_get_field(value3, name, () => new Ok(new None()));
1942
+
} else {
1943
+
return try_get_field(value3, name, not_a_map_error);
1944
+
}
1945
+
}
1946
+
function try_get_field(value3, field2, or_else) {
1947
+
try {
1948
+
return field2 in value3 ? new Ok(new Some(value3[field2])) : or_else();
1949
+
} catch {
1950
+
return or_else();
1951
+
}
1952
+
}
1953
+
1954
+
// build/dev/javascript/gleam_stdlib/gleam/float.mjs
1955
+
function negate(x) {
1956
+
return -1 * x;
1957
+
}
1958
+
function round(x) {
1959
+
let $ = x >= 0;
1960
+
if ($) {
1961
+
return round2(x);
1962
+
} else {
1963
+
return 0 - round2(negate(x));
1964
+
}
1965
+
}
1966
+
1967
+
// build/dev/javascript/gleam_stdlib/gleam/int.mjs
1968
+
function to_base16(x) {
1969
+
return int_to_base_string(x, 16);
1970
+
}
1971
+
1972
+
// build/dev/javascript/gleam_stdlib/gleam/bool.mjs
1973
+
function guard(requirement, consequence, alternative) {
1974
+
if (requirement) {
1975
+
return consequence;
1976
+
} else {
1977
+
return alternative();
1978
+
}
1979
+
}
1980
+
1981
+
// build/dev/javascript/lustre/lustre/effect.mjs
1982
+
var Effect = class extends CustomType {
1983
+
constructor(all) {
1984
+
super();
1985
+
this.all = all;
1986
+
}
1987
+
};
1988
+
function none() {
1989
+
return new Effect(toList([]));
1990
+
}
1991
+
1992
+
// build/dev/javascript/lustre/lustre/internals/vdom.mjs
1993
+
var Text = class extends CustomType {
1994
+
constructor(content) {
1995
+
super();
1996
+
this.content = content;
1997
+
}
1998
+
};
1999
+
var Element = class extends CustomType {
2000
+
constructor(key, namespace, tag, attrs, children2, self_closing, void$) {
2001
+
super();
2002
+
this.key = key;
2003
+
this.namespace = namespace;
2004
+
this.tag = tag;
2005
+
this.attrs = attrs;
2006
+
this.children = children2;
2007
+
this.self_closing = self_closing;
2008
+
this.void = void$;
2009
+
}
2010
+
};
2011
+
var Map2 = class extends CustomType {
2012
+
constructor(subtree) {
2013
+
super();
2014
+
this.subtree = subtree;
2015
+
}
2016
+
};
2017
+
var Attribute = class extends CustomType {
2018
+
constructor(x0, x1, as_property) {
2019
+
super();
2020
+
this[0] = x0;
2021
+
this[1] = x1;
2022
+
this.as_property = as_property;
2023
+
}
2024
+
};
2025
+
var Event = class extends CustomType {
2026
+
constructor(x0, x1) {
2027
+
super();
2028
+
this[0] = x0;
2029
+
this[1] = x1;
2030
+
}
2031
+
};
2032
+
function attribute_to_event_handler(attribute2) {
2033
+
if (attribute2 instanceof Attribute) {
2034
+
return new Error(void 0);
2035
+
} else {
2036
+
let name = attribute2[0];
2037
+
let handler = attribute2[1];
2038
+
let name$1 = drop_start(name, 2);
2039
+
return new Ok([name$1, handler]);
2040
+
}
2041
+
}
2042
+
function do_element_list_handlers(elements2, handlers2, key) {
2043
+
return index_fold(
2044
+
elements2,
2045
+
handlers2,
2046
+
(handlers3, element2, index3) => {
2047
+
let key$1 = key + "-" + to_string(index3);
2048
+
return do_handlers(element2, handlers3, key$1);
2049
+
}
2050
+
);
2051
+
}
2052
+
function do_handlers(loop$element, loop$handlers, loop$key) {
2053
+
while (true) {
2054
+
let element2 = loop$element;
2055
+
let handlers2 = loop$handlers;
2056
+
let key = loop$key;
2057
+
if (element2 instanceof Text) {
2058
+
return handlers2;
2059
+
} else if (element2 instanceof Map2) {
2060
+
let subtree = element2.subtree;
2061
+
loop$element = subtree();
2062
+
loop$handlers = handlers2;
2063
+
loop$key = key;
2064
+
} else {
2065
+
let attrs = element2.attrs;
2066
+
let children2 = element2.children;
2067
+
let handlers$1 = fold(
2068
+
attrs,
2069
+
handlers2,
2070
+
(handlers3, attr) => {
2071
+
let $ = attribute_to_event_handler(attr);
2072
+
if ($.isOk()) {
2073
+
let name = $[0][0];
2074
+
let handler = $[0][1];
2075
+
return insert(handlers3, key + "-" + name, handler);
2076
+
} else {
2077
+
return handlers3;
2078
+
}
2079
+
}
2080
+
);
2081
+
return do_element_list_handlers(children2, handlers$1, key);
2082
+
}
2083
+
}
2084
+
}
2085
+
function handlers(element2) {
2086
+
return do_handlers(element2, new_map(), "0");
2087
+
}
2088
+
2089
+
// build/dev/javascript/lustre/lustre/attribute.mjs
2090
+
function attribute(name, value3) {
2091
+
return new Attribute(name, identity(value3), false);
2092
+
}
2093
+
function on(name, handler) {
2094
+
return new Event("on" + name, handler);
2095
+
}
2096
+
function style(properties) {
2097
+
return attribute(
2098
+
"style",
2099
+
fold(
2100
+
properties,
2101
+
"",
2102
+
(styles, _use1) => {
2103
+
let name$1 = _use1[0];
2104
+
let value$1 = _use1[1];
2105
+
return styles + name$1 + ":" + value$1 + ";";
2106
+
}
2107
+
)
2108
+
);
2109
+
}
2110
+
function value(val) {
2111
+
return attribute("value", val);
2112
+
}
2113
+
function href(uri) {
2114
+
return attribute("href", uri);
2115
+
}
2116
+
2117
+
// build/dev/javascript/lustre/lustre/element.mjs
2118
+
function element(tag, attrs, children2) {
2119
+
if (tag === "area") {
2120
+
return new Element("", "", tag, attrs, toList([]), false, true);
2121
+
} else if (tag === "base") {
2122
+
return new Element("", "", tag, attrs, toList([]), false, true);
2123
+
} else if (tag === "br") {
2124
+
return new Element("", "", tag, attrs, toList([]), false, true);
2125
+
} else if (tag === "col") {
2126
+
return new Element("", "", tag, attrs, toList([]), false, true);
2127
+
} else if (tag === "embed") {
2128
+
return new Element("", "", tag, attrs, toList([]), false, true);
2129
+
} else if (tag === "hr") {
2130
+
return new Element("", "", tag, attrs, toList([]), false, true);
2131
+
} else if (tag === "img") {
2132
+
return new Element("", "", tag, attrs, toList([]), false, true);
2133
+
} else if (tag === "input") {
2134
+
return new Element("", "", tag, attrs, toList([]), false, true);
2135
+
} else if (tag === "link") {
2136
+
return new Element("", "", tag, attrs, toList([]), false, true);
2137
+
} else if (tag === "meta") {
2138
+
return new Element("", "", tag, attrs, toList([]), false, true);
2139
+
} else if (tag === "param") {
2140
+
return new Element("", "", tag, attrs, toList([]), false, true);
2141
+
} else if (tag === "source") {
2142
+
return new Element("", "", tag, attrs, toList([]), false, true);
2143
+
} else if (tag === "track") {
2144
+
return new Element("", "", tag, attrs, toList([]), false, true);
2145
+
} else if (tag === "wbr") {
2146
+
return new Element("", "", tag, attrs, toList([]), false, true);
2147
+
} else {
2148
+
return new Element("", "", tag, attrs, children2, false, false);
2149
+
}
2150
+
}
2151
+
function text(content) {
2152
+
return new Text(content);
2153
+
}
2154
+
function none2() {
2155
+
return new Text("");
2156
+
}
2157
+
2158
+
// build/dev/javascript/gleam_stdlib/gleam/set.mjs
2159
+
var Set2 = class extends CustomType {
2160
+
constructor(dict2) {
2161
+
super();
2162
+
this.dict = dict2;
2163
+
}
2164
+
};
2165
+
function new$2() {
2166
+
return new Set2(new_map());
2167
+
}
2168
+
2169
+
// build/dev/javascript/lustre/lustre/internals/patch.mjs
2170
+
var Diff = class extends CustomType {
2171
+
constructor(x0) {
2172
+
super();
2173
+
this[0] = x0;
2174
+
}
2175
+
};
2176
+
var Emit = class extends CustomType {
2177
+
constructor(x0, x1) {
2178
+
super();
2179
+
this[0] = x0;
2180
+
this[1] = x1;
2181
+
}
2182
+
};
2183
+
var Init = class extends CustomType {
2184
+
constructor(x0, x1) {
2185
+
super();
2186
+
this[0] = x0;
2187
+
this[1] = x1;
2188
+
}
2189
+
};
2190
+
function is_empty_element_diff(diff2) {
2191
+
return isEqual(diff2.created, new_map()) && isEqual(
2192
+
diff2.removed,
2193
+
new$2()
2194
+
) && isEqual(diff2.updated, new_map());
2195
+
}
2196
+
2197
+
// build/dev/javascript/lustre/lustre/internals/runtime.mjs
2198
+
var Attrs = class extends CustomType {
2199
+
constructor(x0) {
2200
+
super();
2201
+
this[0] = x0;
2202
+
}
2203
+
};
2204
+
var Batch = class extends CustomType {
2205
+
constructor(x0, x1) {
2206
+
super();
2207
+
this[0] = x0;
2208
+
this[1] = x1;
2209
+
}
2210
+
};
2211
+
var Debug = class extends CustomType {
2212
+
constructor(x0) {
2213
+
super();
2214
+
this[0] = x0;
2215
+
}
2216
+
};
2217
+
var Dispatch = class extends CustomType {
2218
+
constructor(x0) {
2219
+
super();
2220
+
this[0] = x0;
2221
+
}
2222
+
};
2223
+
var Emit2 = class extends CustomType {
2224
+
constructor(x0, x1) {
2225
+
super();
2226
+
this[0] = x0;
2227
+
this[1] = x1;
2228
+
}
2229
+
};
2230
+
var Event2 = class extends CustomType {
2231
+
constructor(x0, x1) {
2232
+
super();
2233
+
this[0] = x0;
2234
+
this[1] = x1;
2235
+
}
2236
+
};
2237
+
var Shutdown = class extends CustomType {
2238
+
};
2239
+
var Subscribe = class extends CustomType {
2240
+
constructor(x0, x1) {
2241
+
super();
2242
+
this[0] = x0;
2243
+
this[1] = x1;
2244
+
}
2245
+
};
2246
+
var Unsubscribe = class extends CustomType {
2247
+
constructor(x0) {
2248
+
super();
2249
+
this[0] = x0;
2250
+
}
2251
+
};
2252
+
var ForceModel = class extends CustomType {
2253
+
constructor(x0) {
2254
+
super();
2255
+
this[0] = x0;
2256
+
}
2257
+
};
2258
+
2259
+
// build/dev/javascript/lustre/vdom.ffi.mjs
2260
+
if (globalThis.customElements && !globalThis.customElements.get("lustre-fragment")) {
2261
+
globalThis.customElements.define(
2262
+
"lustre-fragment",
2263
+
class LustreFragment extends HTMLElement {
2264
+
constructor() {
2265
+
super();
2266
+
}
2267
+
}
2268
+
);
2269
+
}
2270
+
function morph(prev, next, dispatch) {
2271
+
let out;
2272
+
let stack = [{ prev, next, parent: prev.parentNode }];
2273
+
while (stack.length) {
2274
+
let { prev: prev2, next: next2, parent } = stack.pop();
2275
+
while (next2.subtree !== void 0) next2 = next2.subtree();
2276
+
if (next2.content !== void 0) {
2277
+
if (!prev2) {
2278
+
const created = document.createTextNode(next2.content);
2279
+
parent.appendChild(created);
2280
+
out ??= created;
2281
+
} else if (prev2.nodeType === Node.TEXT_NODE) {
2282
+
if (prev2.textContent !== next2.content) prev2.textContent = next2.content;
2283
+
out ??= prev2;
2284
+
} else {
2285
+
const created = document.createTextNode(next2.content);
2286
+
parent.replaceChild(created, prev2);
2287
+
out ??= created;
2288
+
}
2289
+
} else if (next2.tag !== void 0) {
2290
+
const created = createElementNode({
2291
+
prev: prev2,
2292
+
next: next2,
2293
+
dispatch,
2294
+
stack
2295
+
});
2296
+
if (!prev2) {
2297
+
parent.appendChild(created);
2298
+
} else if (prev2 !== created) {
2299
+
parent.replaceChild(created, prev2);
2300
+
}
2301
+
out ??= created;
2302
+
}
2303
+
}
2304
+
return out;
2305
+
}
2306
+
function createElementNode({ prev, next, dispatch, stack }) {
2307
+
const namespace = next.namespace || "http://www.w3.org/1999/xhtml";
2308
+
const canMorph = prev && prev.nodeType === Node.ELEMENT_NODE && prev.localName === next.tag && prev.namespaceURI === (next.namespace || "http://www.w3.org/1999/xhtml");
2309
+
const el = canMorph ? prev : namespace ? document.createElementNS(namespace, next.tag) : document.createElement(next.tag);
2310
+
let handlersForEl;
2311
+
if (!registeredHandlers.has(el)) {
2312
+
const emptyHandlers = /* @__PURE__ */ new Map();
2313
+
registeredHandlers.set(el, emptyHandlers);
2314
+
handlersForEl = emptyHandlers;
2315
+
} else {
2316
+
handlersForEl = registeredHandlers.get(el);
2317
+
}
2318
+
const prevHandlers = canMorph ? new Set(handlersForEl.keys()) : null;
2319
+
const prevAttributes = canMorph ? new Set(Array.from(prev.attributes, (a2) => a2.name)) : null;
2320
+
let className = null;
2321
+
let style2 = null;
2322
+
let innerHTML = null;
2323
+
if (canMorph && next.tag === "textarea") {
2324
+
const innertText = next.children[Symbol.iterator]().next().value?.content;
2325
+
if (innertText !== void 0) el.value = innertText;
2326
+
}
2327
+
const delegated = [];
2328
+
for (const attr of next.attrs) {
2329
+
const name = attr[0];
2330
+
const value3 = attr[1];
2331
+
if (attr.as_property) {
2332
+
if (el[name] !== value3) el[name] = value3;
2333
+
if (canMorph) prevAttributes.delete(name);
2334
+
} else if (name.startsWith("on")) {
2335
+
const eventName = name.slice(2);
2336
+
const callback = dispatch(value3, eventName === "input");
2337
+
if (!handlersForEl.has(eventName)) {
2338
+
el.addEventListener(eventName, lustreGenericEventHandler);
2339
+
}
2340
+
handlersForEl.set(eventName, callback);
2341
+
if (canMorph) prevHandlers.delete(eventName);
2342
+
} else if (name.startsWith("data-lustre-on-")) {
2343
+
const eventName = name.slice(15);
2344
+
const callback = dispatch(lustreServerEventHandler);
2345
+
if (!handlersForEl.has(eventName)) {
2346
+
el.addEventListener(eventName, lustreGenericEventHandler);
2347
+
}
2348
+
handlersForEl.set(eventName, callback);
2349
+
el.setAttribute(name, value3);
2350
+
if (canMorph) {
2351
+
prevHandlers.delete(eventName);
2352
+
prevAttributes.delete(name);
2353
+
}
2354
+
} else if (name.startsWith("delegate:data-") || name.startsWith("delegate:aria-")) {
2355
+
el.setAttribute(name, value3);
2356
+
delegated.push([name.slice(10), value3]);
2357
+
} else if (name === "class") {
2358
+
className = className === null ? value3 : className + " " + value3;
2359
+
} else if (name === "style") {
2360
+
style2 = style2 === null ? value3 : style2 + value3;
2361
+
} else if (name === "dangerous-unescaped-html") {
2362
+
innerHTML = value3;
2363
+
} else {
2364
+
if (el.getAttribute(name) !== value3) el.setAttribute(name, value3);
2365
+
if (name === "value" || name === "selected") el[name] = value3;
2366
+
if (canMorph) prevAttributes.delete(name);
2367
+
}
2368
+
}
2369
+
if (className !== null) {
2370
+
el.setAttribute("class", className);
2371
+
if (canMorph) prevAttributes.delete("class");
2372
+
}
2373
+
if (style2 !== null) {
2374
+
el.setAttribute("style", style2);
2375
+
if (canMorph) prevAttributes.delete("style");
2376
+
}
2377
+
if (canMorph) {
2378
+
for (const attr of prevAttributes) {
2379
+
el.removeAttribute(attr);
2380
+
}
2381
+
for (const eventName of prevHandlers) {
2382
+
handlersForEl.delete(eventName);
2383
+
el.removeEventListener(eventName, lustreGenericEventHandler);
2384
+
}
2385
+
}
2386
+
if (next.tag === "slot") {
2387
+
window.queueMicrotask(() => {
2388
+
for (const child of el.assignedElements()) {
2389
+
for (const [name, value3] of delegated) {
2390
+
if (!child.hasAttribute(name)) {
2391
+
child.setAttribute(name, value3);
2392
+
}
2393
+
}
2394
+
}
2395
+
});
2396
+
}
2397
+
if (next.key !== void 0 && next.key !== "") {
2398
+
el.setAttribute("data-lustre-key", next.key);
2399
+
} else if (innerHTML !== null) {
2400
+
el.innerHTML = innerHTML;
2401
+
return el;
2402
+
}
2403
+
let prevChild = el.firstChild;
2404
+
let seenKeys = null;
2405
+
let keyedChildren = null;
2406
+
let incomingKeyedChildren = null;
2407
+
let firstChild = children(next).next().value;
2408
+
if (canMorph && firstChild !== void 0 && // Explicit checks are more verbose but truthy checks force a bunch of comparisons
2409
+
// we don't care about: it's never gonna be a number etc.
2410
+
firstChild.key !== void 0 && firstChild.key !== "") {
2411
+
seenKeys = /* @__PURE__ */ new Set();
2412
+
keyedChildren = getKeyedChildren(prev);
2413
+
incomingKeyedChildren = getKeyedChildren(next);
2414
+
for (const child of children(next)) {
2415
+
prevChild = diffKeyedChild(
2416
+
prevChild,
2417
+
child,
2418
+
el,
2419
+
stack,
2420
+
incomingKeyedChildren,
2421
+
keyedChildren,
2422
+
seenKeys
2423
+
);
2424
+
}
2425
+
} else {
2426
+
for (const child of children(next)) {
2427
+
stack.unshift({ prev: prevChild, next: child, parent: el });
2428
+
prevChild = prevChild?.nextSibling;
2429
+
}
2430
+
}
2431
+
while (prevChild) {
2432
+
const next2 = prevChild.nextSibling;
2433
+
el.removeChild(prevChild);
2434
+
prevChild = next2;
2435
+
}
2436
+
return el;
2437
+
}
2438
+
var registeredHandlers = /* @__PURE__ */ new WeakMap();
2439
+
function lustreGenericEventHandler(event2) {
2440
+
const target = event2.currentTarget;
2441
+
if (!registeredHandlers.has(target)) {
2442
+
target.removeEventListener(event2.type, lustreGenericEventHandler);
2443
+
return;
2444
+
}
2445
+
const handlersForEventTarget = registeredHandlers.get(target);
2446
+
if (!handlersForEventTarget.has(event2.type)) {
2447
+
target.removeEventListener(event2.type, lustreGenericEventHandler);
2448
+
return;
2449
+
}
2450
+
handlersForEventTarget.get(event2.type)(event2);
2451
+
}
2452
+
function lustreServerEventHandler(event2) {
2453
+
const el = event2.currentTarget;
2454
+
const tag = el.getAttribute(`data-lustre-on-${event2.type}`);
2455
+
const data = JSON.parse(el.getAttribute("data-lustre-data") || "{}");
2456
+
const include = JSON.parse(el.getAttribute("data-lustre-include") || "[]");
2457
+
switch (event2.type) {
2458
+
case "input":
2459
+
case "change":
2460
+
include.push("target.value");
2461
+
break;
2462
+
}
2463
+
return {
2464
+
tag,
2465
+
data: include.reduce(
2466
+
(data2, property) => {
2467
+
const path = property.split(".");
2468
+
for (let i = 0, o = data2, e = event2; i < path.length; i++) {
2469
+
if (i === path.length - 1) {
2470
+
o[path[i]] = e[path[i]];
2471
+
} else {
2472
+
o[path[i]] ??= {};
2473
+
e = e[path[i]];
2474
+
o = o[path[i]];
2475
+
}
2476
+
}
2477
+
return data2;
2478
+
},
2479
+
{ data }
2480
+
)
2481
+
};
2482
+
}
2483
+
function getKeyedChildren(el) {
2484
+
const keyedChildren = /* @__PURE__ */ new Map();
2485
+
if (el) {
2486
+
for (const child of children(el)) {
2487
+
const key = child?.key || child?.getAttribute?.("data-lustre-key");
2488
+
if (key) keyedChildren.set(key, child);
2489
+
}
2490
+
}
2491
+
return keyedChildren;
2492
+
}
2493
+
function diffKeyedChild(prevChild, child, el, stack, incomingKeyedChildren, keyedChildren, seenKeys) {
2494
+
while (prevChild && !incomingKeyedChildren.has(prevChild.getAttribute("data-lustre-key"))) {
2495
+
const nextChild = prevChild.nextSibling;
2496
+
el.removeChild(prevChild);
2497
+
prevChild = nextChild;
2498
+
}
2499
+
if (keyedChildren.size === 0) {
2500
+
stack.unshift({ prev: prevChild, next: child, parent: el });
2501
+
prevChild = prevChild?.nextSibling;
2502
+
return prevChild;
2503
+
}
2504
+
if (seenKeys.has(child.key)) {
2505
+
console.warn(`Duplicate key found in Lustre vnode: ${child.key}`);
2506
+
stack.unshift({ prev: null, next: child, parent: el });
2507
+
return prevChild;
2508
+
}
2509
+
seenKeys.add(child.key);
2510
+
const keyedChild = keyedChildren.get(child.key);
2511
+
if (!keyedChild && !prevChild) {
2512
+
stack.unshift({ prev: null, next: child, parent: el });
2513
+
return prevChild;
2514
+
}
2515
+
if (!keyedChild && prevChild !== null) {
2516
+
const placeholder = document.createTextNode("");
2517
+
el.insertBefore(placeholder, prevChild);
2518
+
stack.unshift({ prev: placeholder, next: child, parent: el });
2519
+
return prevChild;
2520
+
}
2521
+
if (!keyedChild || keyedChild === prevChild) {
2522
+
stack.unshift({ prev: prevChild, next: child, parent: el });
2523
+
prevChild = prevChild?.nextSibling;
2524
+
return prevChild;
2525
+
}
2526
+
el.insertBefore(keyedChild, prevChild);
2527
+
stack.unshift({ prev: keyedChild, next: child, parent: el });
2528
+
return prevChild;
2529
+
}
2530
+
function* children(element2) {
2531
+
for (const child of element2.children) {
2532
+
yield* forceChild(child);
2533
+
}
2534
+
}
2535
+
function* forceChild(element2) {
2536
+
if (element2.subtree !== void 0) {
2537
+
yield* forceChild(element2.subtree());
2538
+
} else {
2539
+
yield element2;
2540
+
}
2541
+
}
2542
+
2543
+
// build/dev/javascript/lustre/lustre.ffi.mjs
2544
+
var LustreClientApplication = class _LustreClientApplication {
2545
+
/**
2546
+
* @template Flags
2547
+
*
2548
+
* @param {object} app
2549
+
* @param {(flags: Flags) => [Model, Lustre.Effect<Msg>]} app.init
2550
+
* @param {(msg: Msg, model: Model) => [Model, Lustre.Effect<Msg>]} app.update
2551
+
* @param {(model: Model) => Lustre.Element<Msg>} app.view
2552
+
* @param {string | HTMLElement} selector
2553
+
* @param {Flags} flags
2554
+
*
2555
+
* @returns {Gleam.Ok<(action: Lustre.Action<Lustre.Client, Msg>>) => void>}
2556
+
*/
2557
+
static start({ init: init3, update: update2, view: view2 }, selector, flags) {
2558
+
if (!is_browser()) return new Error(new NotABrowser());
2559
+
const root = selector instanceof HTMLElement ? selector : document.querySelector(selector);
2560
+
if (!root) return new Error(new ElementNotFound(selector));
2561
+
const app = new _LustreClientApplication(root, init3(flags), update2, view2);
2562
+
return new Ok((action) => app.send(action));
2563
+
}
2564
+
/**
2565
+
* @param {Element} root
2566
+
* @param {[Model, Lustre.Effect<Msg>]} init
2567
+
* @param {(model: Model, msg: Msg) => [Model, Lustre.Effect<Msg>]} update
2568
+
* @param {(model: Model) => Lustre.Element<Msg>} view
2569
+
*
2570
+
* @returns {LustreClientApplication}
2571
+
*/
2572
+
constructor(root, [init3, effects], update2, view2) {
2573
+
this.root = root;
2574
+
this.#model = init3;
2575
+
this.#update = update2;
2576
+
this.#view = view2;
2577
+
this.#tickScheduled = window.setTimeout(
2578
+
() => this.#tick(effects.all.toArray(), true),
2579
+
0
2580
+
);
2581
+
}
2582
+
/** @type {Element} */
2583
+
root;
2584
+
/**
2585
+
* @param {Lustre.Action<Lustre.Client, Msg>} action
2586
+
*
2587
+
* @returns {void}
2588
+
*/
2589
+
send(action) {
2590
+
if (action instanceof Debug) {
2591
+
if (action[0] instanceof ForceModel) {
2592
+
this.#tickScheduled = window.clearTimeout(this.#tickScheduled);
2593
+
this.#queue = [];
2594
+
this.#model = action[0][0];
2595
+
const vdom = this.#view(this.#model);
2596
+
const dispatch = (handler, immediate = false) => (event2) => {
2597
+
const result = handler(event2);
2598
+
if (result instanceof Ok) {
2599
+
this.send(new Dispatch(result[0], immediate));
2600
+
}
2601
+
};
2602
+
const prev = this.root.firstChild ?? this.root.appendChild(document.createTextNode(""));
2603
+
morph(prev, vdom, dispatch);
2604
+
}
2605
+
} else if (action instanceof Dispatch) {
2606
+
const msg = action[0];
2607
+
const immediate = action[1] ?? false;
2608
+
this.#queue.push(msg);
2609
+
if (immediate) {
2610
+
this.#tickScheduled = window.clearTimeout(this.#tickScheduled);
2611
+
this.#tick();
2612
+
} else if (!this.#tickScheduled) {
2613
+
this.#tickScheduled = window.setTimeout(() => this.#tick());
2614
+
}
2615
+
} else if (action instanceof Emit2) {
2616
+
const event2 = action[0];
2617
+
const data = action[1];
2618
+
this.root.dispatchEvent(
2619
+
new CustomEvent(event2, {
2620
+
detail: data,
2621
+
bubbles: true,
2622
+
composed: true
2623
+
})
2624
+
);
2625
+
} else if (action instanceof Shutdown) {
2626
+
this.#tickScheduled = window.clearTimeout(this.#tickScheduled);
2627
+
this.#model = null;
2628
+
this.#update = null;
2629
+
this.#view = null;
2630
+
this.#queue = null;
2631
+
while (this.root.firstChild) {
2632
+
this.root.firstChild.remove();
2633
+
}
2634
+
}
2635
+
}
2636
+
/** @type {Model} */
2637
+
#model;
2638
+
/** @type {(model: Model, msg: Msg) => [Model, Lustre.Effect<Msg>]} */
2639
+
#update;
2640
+
/** @type {(model: Model) => Lustre.Element<Msg>} */
2641
+
#view;
2642
+
/** @type {Array<Msg>} */
2643
+
#queue = [];
2644
+
/** @type {number | undefined} */
2645
+
#tickScheduled;
2646
+
/**
2647
+
* @param {Lustre.Effect<Msg>[]} effects
2648
+
*/
2649
+
#tick(effects = []) {
2650
+
this.#tickScheduled = void 0;
2651
+
this.#flush(effects);
2652
+
const vdom = this.#view(this.#model);
2653
+
const dispatch = (handler, immediate = false) => (event2) => {
2654
+
const result = handler(event2);
2655
+
if (result instanceof Ok) {
2656
+
this.send(new Dispatch(result[0], immediate));
2657
+
}
2658
+
};
2659
+
const prev = this.root.firstChild ?? this.root.appendChild(document.createTextNode(""));
2660
+
morph(prev, vdom, dispatch);
2661
+
}
2662
+
#flush(effects = []) {
2663
+
while (this.#queue.length > 0) {
2664
+
const msg = this.#queue.shift();
2665
+
const [next, effect] = this.#update(this.#model, msg);
2666
+
effects = effects.concat(effect.all.toArray());
2667
+
this.#model = next;
2668
+
}
2669
+
while (effects.length > 0) {
2670
+
const effect = effects.shift();
2671
+
const dispatch = (msg) => this.send(new Dispatch(msg));
2672
+
const emit2 = (event2, data) => this.root.dispatchEvent(
2673
+
new CustomEvent(event2, {
2674
+
detail: data,
2675
+
bubbles: true,
2676
+
composed: true
2677
+
})
2678
+
);
2679
+
const select = () => {
2680
+
};
2681
+
const root = this.root;
2682
+
effect({ dispatch, emit: emit2, select, root });
2683
+
}
2684
+
if (this.#queue.length > 0) {
2685
+
this.#flush(effects);
2686
+
}
2687
+
}
2688
+
};
2689
+
var start = LustreClientApplication.start;
2690
+
var LustreServerApplication = class _LustreServerApplication {
2691
+
static start({ init: init3, update: update2, view: view2, on_attribute_change }, flags) {
2692
+
const app = new _LustreServerApplication(
2693
+
init3(flags),
2694
+
update2,
2695
+
view2,
2696
+
on_attribute_change
2697
+
);
2698
+
return new Ok((action) => app.send(action));
2699
+
}
2700
+
constructor([model, effects], update2, view2, on_attribute_change) {
2701
+
this.#model = model;
2702
+
this.#update = update2;
2703
+
this.#view = view2;
2704
+
this.#html = view2(model);
2705
+
this.#onAttributeChange = on_attribute_change;
2706
+
this.#renderers = /* @__PURE__ */ new Map();
2707
+
this.#handlers = handlers(this.#html);
2708
+
this.#tick(effects.all.toArray());
2709
+
}
2710
+
send(action) {
2711
+
if (action instanceof Attrs) {
2712
+
for (const attr of action[0]) {
2713
+
const decoder = this.#onAttributeChange.get(attr[0]);
2714
+
if (!decoder) continue;
2715
+
const msg = decoder(attr[1]);
2716
+
if (msg instanceof Error) continue;
2717
+
this.#queue.push(msg);
2718
+
}
2719
+
this.#tick();
2720
+
} else if (action instanceof Batch) {
2721
+
this.#queue = this.#queue.concat(action[0].toArray());
2722
+
this.#tick(action[1].all.toArray());
2723
+
} else if (action instanceof Debug) {
2724
+
} else if (action instanceof Dispatch) {
2725
+
this.#queue.push(action[0]);
2726
+
this.#tick();
2727
+
} else if (action instanceof Emit2) {
2728
+
const event2 = new Emit(action[0], action[1]);
2729
+
for (const [_, renderer] of this.#renderers) {
2730
+
renderer(event2);
2731
+
}
2732
+
} else if (action instanceof Event2) {
2733
+
const handler = this.#handlers.get(action[0]);
2734
+
if (!handler) return;
2735
+
const msg = handler(action[1]);
2736
+
if (msg instanceof Error) return;
2737
+
this.#queue.push(msg[0]);
2738
+
this.#tick();
2739
+
} else if (action instanceof Subscribe) {
2740
+
const attrs = keys(this.#onAttributeChange);
2741
+
const patch = new Init(attrs, this.#html);
2742
+
this.#renderers = this.#renderers.set(action[0], action[1]);
2743
+
action[1](patch);
2744
+
} else if (action instanceof Unsubscribe) {
2745
+
this.#renderers = this.#renderers.delete(action[0]);
2746
+
}
2747
+
}
2748
+
#model;
2749
+
#update;
2750
+
#queue;
2751
+
#view;
2752
+
#html;
2753
+
#renderers;
2754
+
#handlers;
2755
+
#onAttributeChange;
2756
+
#tick(effects = []) {
2757
+
this.#flush(effects);
2758
+
const vdom = this.#view(this.#model);
2759
+
const diff2 = elements(this.#html, vdom);
2760
+
if (!is_empty_element_diff(diff2)) {
2761
+
const patch = new Diff(diff2);
2762
+
for (const [_, renderer] of this.#renderers) {
2763
+
renderer(patch);
2764
+
}
2765
+
}
2766
+
this.#html = vdom;
2767
+
this.#handlers = diff2.handlers;
2768
+
}
2769
+
#flush(effects = []) {
2770
+
while (this.#queue.length > 0) {
2771
+
const msg = this.#queue.shift();
2772
+
const [next, effect] = this.#update(this.#model, msg);
2773
+
effects = effects.concat(effect.all.toArray());
2774
+
this.#model = next;
2775
+
}
2776
+
while (effects.length > 0) {
2777
+
const effect = effects.shift();
2778
+
const dispatch = (msg) => this.send(new Dispatch(msg));
2779
+
const emit2 = (event2, data) => this.root.dispatchEvent(
2780
+
new CustomEvent(event2, {
2781
+
detail: data,
2782
+
bubbles: true,
2783
+
composed: true
2784
+
})
2785
+
);
2786
+
const select = () => {
2787
+
};
2788
+
const root = null;
2789
+
effect({ dispatch, emit: emit2, select, root });
2790
+
}
2791
+
if (this.#queue.length > 0) {
2792
+
this.#flush(effects);
2793
+
}
2794
+
}
2795
+
};
2796
+
var start_server_application = LustreServerApplication.start;
2797
+
var is_browser = () => globalThis.window && window.document;
2798
+
2799
+
// build/dev/javascript/lustre/lustre.mjs
2800
+
var App = class extends CustomType {
2801
+
constructor(init3, update2, view2, on_attribute_change) {
2802
+
super();
2803
+
this.init = init3;
2804
+
this.update = update2;
2805
+
this.view = view2;
2806
+
this.on_attribute_change = on_attribute_change;
2807
+
}
2808
+
};
2809
+
var ElementNotFound = class extends CustomType {
2810
+
constructor(selector) {
2811
+
super();
2812
+
this.selector = selector;
2813
+
}
2814
+
};
2815
+
var NotABrowser = class extends CustomType {
2816
+
};
2817
+
function application(init3, update2, view2) {
2818
+
return new App(init3, update2, view2, new None());
2819
+
}
2820
+
function simple(init3, update2, view2) {
2821
+
let init$1 = (flags) => {
2822
+
return [init3(flags), none()];
2823
+
};
2824
+
let update$1 = (model, msg) => {
2825
+
return [update2(model, msg), none()];
2826
+
};
2827
+
return application(init$1, update$1, view2);
2828
+
}
2829
+
function start2(app, selector, flags) {
2830
+
return guard(
2831
+
!is_browser(),
2832
+
new Error(new NotABrowser()),
2833
+
() => {
2834
+
return start(app, selector, flags);
2835
+
}
2836
+
);
2837
+
}
2838
+
2839
+
// build/dev/javascript/lustre/lustre/element/html.mjs
2840
+
function text2(content) {
2841
+
return text(content);
2842
+
}
2843
+
function h1(attrs, children2) {
2844
+
return element("h1", attrs, children2);
2845
+
}
2846
+
function div(attrs, children2) {
2847
+
return element("div", attrs, children2);
2848
+
}
2849
+
function p(attrs, children2) {
2850
+
return element("p", attrs, children2);
2851
+
}
2852
+
function a(attrs, children2) {
2853
+
return element("a", attrs, children2);
2854
+
}
2855
+
function code(attrs, children2) {
2856
+
return element("code", attrs, children2);
2857
+
}
2858
+
function input(attrs) {
2859
+
return element("input", attrs, toList([]));
2860
+
}
2861
+
2862
+
// build/dev/javascript/lustre/lustre/event.mjs
2863
+
function on2(name, handler) {
2864
+
return on(name, handler);
2865
+
}
2866
+
function value2(event2) {
2867
+
let _pipe = event2;
2868
+
return field("target", field("value", string))(
2869
+
_pipe
2870
+
);
2871
+
}
2872
+
function on_input(msg) {
2873
+
return on2(
2874
+
"input",
2875
+
(event2) => {
2876
+
let _pipe = value2(event2);
2877
+
return map2(_pipe, msg);
2878
+
}
2879
+
);
2880
+
}
2881
+
2882
+
// build/dev/javascript/bigi/bigi_ffi.mjs
2883
+
function from(int3) {
2884
+
return BigInt(int3);
2885
+
}
2886
+
function from_bytes(bit_array2, endianness, signedness) {
2887
+
if (bit_array2.bitSize % 8 !== 0) {
2888
+
return new Error(void 0);
2889
+
}
2890
+
let value3 = 0n;
2891
+
if (endianness instanceof BigEndian) {
2892
+
for (let i = 0; i < bit_array2.byteSize; i++) {
2893
+
value3 = value3 * 256n + BigInt(bit_array2.byteAt(i));
2894
+
}
2895
+
} else {
2896
+
for (let i = bit_array2.byteSize - 1; i >= 0; i--) {
2897
+
value3 = value3 * 256n + BigInt(bit_array2.byteAt(i));
2898
+
}
2899
+
}
2900
+
if (signedness instanceof Signed) {
2901
+
const byteSize = BigInt(bit_array2.byteSize);
2902
+
const highBit = 2n ** (byteSize * 8n - 1n);
2903
+
if (value3 >= highBit) {
2904
+
value3 -= highBit * 2n;
2905
+
}
2906
+
}
2907
+
return new Ok(value3);
2908
+
}
2909
+
function to(bigint) {
2910
+
if (bigint > Number.MAX_SAFE_INTEGER || bigint < Number.MIN_SAFE_INTEGER) {
2911
+
return new Error(void 0);
2912
+
} else {
2913
+
return new Ok(Number(bigint));
2914
+
}
2915
+
}
2916
+
function compare3(a2, b) {
2917
+
if (a2 < b) {
2918
+
return new Lt();
2919
+
} else if (a2 > b) {
2920
+
return new Gt();
2921
+
} else {
2922
+
return new Eq();
2923
+
}
2924
+
}
2925
+
function subtract(a2, b) {
2926
+
return a2 - b;
2927
+
}
2928
+
function bitwise_and2(a2, b) {
2929
+
return a2 & b;
2930
+
}
2931
+
function bitwise_exclusive_or2(a2, b) {
2932
+
return a2 ^ b;
2933
+
}
2934
+
function bitwise_shift_right2(a2, b) {
2935
+
return a2 >> BigInt(b);
2936
+
}
2937
+
2938
+
// build/dev/javascript/bigi/bigi.mjs
2939
+
var BigEndian = class extends CustomType {
2940
+
};
2941
+
var Signed = class extends CustomType {
2942
+
};
2943
+
function max(a2, b) {
2944
+
let $ = compare3(a2, b);
2945
+
if ($ instanceof Lt) {
2946
+
return b;
2947
+
} else {
2948
+
return a2;
2949
+
}
2950
+
}
2951
+
function min(a2, b) {
2952
+
let $ = compare3(a2, b);
2953
+
if ($ instanceof Lt) {
2954
+
return a2;
2955
+
} else {
2956
+
return b;
2957
+
}
2958
+
}
2959
+
2960
+
// build/dev/javascript/locator_colour/locator_colour/ffi.mjs
2961
+
function zero_fill_bitwise_shift_right(x, y) {
2962
+
return BigInt.asIntN(32, x >> BigInt(y));
2963
+
}
2964
+
function to_unsigned(int3, bits) {
2965
+
return BigInt.asUintN(bits, int3);
2966
+
}
2967
+
2968
+
// build/dev/javascript/locator_colour/locator_colour/colour.mjs
2969
+
var Colour = class extends CustomType {
2970
+
constructor(a2, r, g, b) {
2971
+
super();
2972
+
this.a = a2;
2973
+
this.r = r;
2974
+
this.g = g;
2975
+
this.b = b;
2976
+
}
2977
+
};
2978
+
function alpha(i) {
2979
+
let _pipe = i;
2980
+
let _pipe$1 = zero_fill_bitwise_shift_right(_pipe, 24);
2981
+
return to_unsigned(_pipe$1, 8);
2982
+
}
2983
+
function red(i) {
2984
+
let _pipe = i;
2985
+
let _pipe$1 = bitwise_shift_right2(_pipe, 16);
2986
+
return bitwise_and2(
2987
+
_pipe$1,
2988
+
(() => {
2989
+
let _pipe$2 = 255;
2990
+
return from(_pipe$2);
2991
+
})()
2992
+
);
2993
+
}
2994
+
function green(i) {
2995
+
let _pipe = i;
2996
+
let _pipe$1 = bitwise_shift_right2(_pipe, 8);
2997
+
return bitwise_and2(
2998
+
_pipe$1,
2999
+
(() => {
3000
+
let _pipe$2 = 255;
3001
+
return from(_pipe$2);
3002
+
})()
3003
+
);
3004
+
}
3005
+
function blue(i) {
3006
+
let _pipe = i;
3007
+
return bitwise_and2(
3008
+
_pipe,
3009
+
(() => {
3010
+
let _pipe$1 = 255;
3011
+
return from(_pipe$1);
3012
+
})()
3013
+
);
3014
+
}
3015
+
function colour(a2, r, g, b) {
3016
+
return new Colour(a2, r, g, b);
3017
+
}
3018
+
function generate_colour(uuid, f) {
3019
+
let j = red(uuid);
3020
+
let k = green(uuid);
3021
+
let l = blue(uuid);
3022
+
let m = alpha(uuid);
3023
+
let n = max(max(j, k), l);
3024
+
let o = min(min(j, k), l);
3025
+
let g = identity(
3026
+
(() => {
3027
+
let _pipe = to(subtract(n, o));
3028
+
return unwrap(_pipe, 0);
3029
+
})()
3030
+
);
3031
+
let h = (() => {
3032
+
let $2 = !isEqual(
3033
+
n,
3034
+
(() => {
3035
+
let _pipe = 0;
3036
+
return from(_pipe);
3037
+
})()
3038
+
);
3039
+
if ($2) {
3040
+
return divideFloat(
3041
+
g,
3042
+
identity(
3043
+
(() => {
3044
+
let _pipe = to(n);
3045
+
return unwrap(_pipe, 0);
3046
+
})()
3047
+
)
3048
+
);
3049
+
} else {
3050
+
return 0;
3051
+
}
3052
+
})();
3053
+
let p2 = (() => {
3054
+
let $2 = h === 0;
3055
+
if ($2) {
3056
+
return 0;
3057
+
} else {
3058
+
let q = divideFloat(
3059
+
identity(
3060
+
(() => {
3061
+
let _pipe = to(subtract(n, j));
3062
+
return unwrap(_pipe, 0);
3063
+
})()
3064
+
),
3065
+
g
3066
+
);
3067
+
let r = divideFloat(
3068
+
identity(
3069
+
(() => {
3070
+
let _pipe = to(subtract(n, k));
3071
+
return unwrap(_pipe, 0);
3072
+
})()
3073
+
),
3074
+
g
3075
+
);
3076
+
let s = divideFloat(
3077
+
identity(
3078
+
(() => {
3079
+
let _pipe = to(subtract(n, l));
3080
+
return unwrap(_pipe, 0);
3081
+
})()
3082
+
),
3083
+
g
3084
+
);
3085
+
let p3 = divideFloat(
3086
+
(() => {
3087
+
if (isEqual(n, j)) {
3088
+
let n$1 = n;
3089
+
return s - r;
3090
+
} else if (isEqual(n, k)) {
3091
+
let n$1 = n;
3092
+
return 2 + q - s;
3093
+
} else {
3094
+
return 4 + r - q;
3095
+
}
3096
+
})(),
3097
+
6
3098
+
);
3099
+
let $1 = p3 < 0;
3100
+
if ($1) {
3101
+
return p3 + 1;
3102
+
} else {
3103
+
return p3;
3104
+
}
3105
+
}
3106
+
})();
3107
+
let $ = h === 0;
3108
+
if ($) {
3109
+
return colour(
3110
+
echo(
3111
+
(() => {
3112
+
let _pipe = m;
3113
+
let _pipe$1 = to(_pipe);
3114
+
return unwrap(_pipe$1, 255);
3115
+
})(),
3116
+
"src/locator_colour/colour.gleam",
3117
+
94
3118
+
),
3119
+
echo(round(f * 255), "src/locator_colour/colour.gleam", 95),
3120
+
echo(round(f * 255), "src/locator_colour/colour.gleam", 96),
3121
+
echo(round(f * 255), "src/locator_colour/colour.gleam", 97)
3122
+
);
3123
+
} else {
3124
+
let q = (p2 - floor(p2)) * 6;
3125
+
let r = q - floor(q);
3126
+
let s = f * (1 - h);
3127
+
let t = f * (1 - h * r);
3128
+
let u = f * (1 - h * (1 - r));
3129
+
let $1 = (() => {
3130
+
let $2 = (() => {
3131
+
let _pipe = q;
3132
+
let _pipe$1 = floor(_pipe);
3133
+
return round(_pipe$1);
3134
+
})();
3135
+
if ($2 === 0) {
3136
+
return [
3137
+
round(f * 255),
3138
+
round(u * 255),
3139
+
round(s * 255)
3140
+
];
3141
+
} else if ($2 === 1) {
3142
+
return [
3143
+
round(t * 255),
3144
+
round(f * 255),
3145
+
round(s * 255)
3146
+
];
3147
+
} else if ($2 === 2) {
3148
+
return [
3149
+
round(s * 255),
3150
+
round(f * 255),
3151
+
round(u * 255)
3152
+
];
3153
+
} else if ($2 === 3) {
3154
+
return [
3155
+
round(s * 255),
3156
+
round(t * 255),
3157
+
round(f * 255)
3158
+
];
3159
+
} else if ($2 === 4) {
3160
+
return [
3161
+
round(u * 255),
3162
+
round(s * 255),
3163
+
round(f * 255)
3164
+
];
3165
+
} else if ($2 === 5) {
3166
+
return [
3167
+
round(f * 255),
3168
+
round(s * 255),
3169
+
round(t * 255)
3170
+
];
3171
+
} else {
3172
+
return [
3173
+
(() => {
3174
+
let _pipe = j;
3175
+
let _pipe$1 = to(_pipe);
3176
+
return unwrap(_pipe$1, 696969);
3177
+
})(),
3178
+
(() => {
3179
+
let _pipe = k;
3180
+
let _pipe$1 = to(_pipe);
3181
+
return unwrap(_pipe$1, 696969);
3182
+
})(),
3183
+
(() => {
3184
+
let _pipe = l;
3185
+
let _pipe$1 = to(_pipe);
3186
+
return unwrap(_pipe$1, 696969);
3187
+
})()
3188
+
];
3189
+
}
3190
+
})();
3191
+
let j$1 = $1[0];
3192
+
let k$1 = $1[1];
3193
+
let l$1 = $1[2];
3194
+
return colour(
3195
+
(() => {
3196
+
let _pipe = m;
3197
+
let _pipe$1 = to(_pipe);
3198
+
return unwrap(_pipe$1, 255);
3199
+
})(),
3200
+
j$1,
3201
+
k$1,
3202
+
l$1
3203
+
);
3204
+
}
3205
+
}
3206
+
function hash_int(value3) {
3207
+
let inner = zero_fill_bitwise_shift_right(value3, 32);
3208
+
let xor = bitwise_exclusive_or2(value3, inner);
3209
+
return xor;
3210
+
}
3211
+
function hex_to_int(c) {
3212
+
let i = (() => {
3213
+
if (c === "0") {
3214
+
return 0;
3215
+
} else if (c === "1") {
3216
+
return 1;
3217
+
} else if (c === "2") {
3218
+
return 2;
3219
+
} else if (c === "3") {
3220
+
return 3;
3221
+
} else if (c === "4") {
3222
+
return 4;
3223
+
} else if (c === "5") {
3224
+
return 5;
3225
+
} else if (c === "6") {
3226
+
return 6;
3227
+
} else if (c === "7") {
3228
+
return 7;
3229
+
} else if (c === "8") {
3230
+
return 8;
3231
+
} else if (c === "9") {
3232
+
return 9;
3233
+
} else if (c === "a") {
3234
+
return 10;
3235
+
} else if (c === "A") {
3236
+
return 10;
3237
+
} else if (c === "b") {
3238
+
return 11;
3239
+
} else if (c === "B") {
3240
+
return 11;
3241
+
} else if (c === "c") {
3242
+
return 12;
3243
+
} else if (c === "C") {
3244
+
return 12;
3245
+
} else if (c === "d") {
3246
+
return 13;
3247
+
} else if (c === "D") {
3248
+
return 13;
3249
+
} else if (c === "e") {
3250
+
return 14;
3251
+
} else if (c === "E") {
3252
+
return 14;
3253
+
} else if (c === "f") {
3254
+
return 15;
3255
+
} else if (c === "F") {
3256
+
return 15;
3257
+
} else {
3258
+
return 16;
3259
+
}
3260
+
})();
3261
+
if (i === 16) {
3262
+
return new Error(void 0);
3263
+
} else {
3264
+
let x = i;
3265
+
return new Ok(x);
3266
+
}
3267
+
}
3268
+
function to_bitstring_help(loop$str, loop$index, loop$acc) {
3269
+
while (true) {
3270
+
let str = loop$str;
3271
+
let index3 = loop$index;
3272
+
let acc = loop$acc;
3273
+
let $ = pop_grapheme(str);
3274
+
if (!$.isOk() && !$[0] && index3 === 32) {
3275
+
return new Ok(acc);
3276
+
} else if ($.isOk() && $[0][0] === "-" && index3 < 32) {
3277
+
let rest = $[0][1];
3278
+
loop$str = rest;
3279
+
loop$index = index3;
3280
+
loop$acc = acc;
3281
+
} else if ($.isOk() && index3 < 32) {
3282
+
let c = $[0][0];
3283
+
let rest = $[0][1];
3284
+
let $1 = hex_to_int(c);
3285
+
if ($1.isOk()) {
3286
+
let i = $1[0];
3287
+
loop$str = rest;
3288
+
loop$index = index3 + 1;
3289
+
loop$acc = toBitArray([acc, sizedInt(i, 4, true)]);
3290
+
} else {
3291
+
return new Error(void 0);
3292
+
}
3293
+
} else {
3294
+
return new Error(void 0);
3295
+
}
3296
+
}
3297
+
}
3298
+
function to_bit_array_helper(str) {
3299
+
return to_bitstring_help(str, 0, toBitArray([]));
3300
+
}
3301
+
function hash_code(uuid) {
3302
+
let $ = (() => {
3303
+
let _pipe = uuid;
3304
+
return to_bit_array_helper(_pipe);
3305
+
})();
3306
+
if ($.isOk() && $[0].bitSize == 128) {
3307
+
let msb = bitArraySlice($[0], 0, 64);
3308
+
let lsb = bitArraySlice($[0], 64, 128);
3309
+
return try$(
3310
+
from_bytes(msb, new BigEndian(), new Signed()),
3311
+
(msb2) => {
3312
+
return try$(
3313
+
from_bytes(lsb, new BigEndian(), new Signed()),
3314
+
(lsb2) => {
3315
+
let xor = bitwise_exclusive_or2(msb2, lsb2);
3316
+
let hash = hash_int(xor);
3317
+
return new Ok(hash);
3318
+
}
3319
+
);
3320
+
}
3321
+
);
3322
+
} else {
3323
+
return new Error(void 0);
3324
+
}
3325
+
}
3326
+
function echo(value3, file, line) {
3327
+
const grey = "\x1B[90m";
3328
+
const reset_color = "\x1B[39m";
3329
+
const file_line = `${file}:${line}`;
3330
+
const string_value = echo$inspect(value3);
3331
+
if (typeof process === "object" && process.stderr?.write) {
3332
+
const string4 = `${grey}${file_line}${reset_color}
3333
+
${string_value}
3334
+
`;
3335
+
process.stderr.write(string4);
3336
+
} else if (typeof Deno === "object") {
3337
+
const string4 = `${grey}${file_line}${reset_color}
3338
+
${string_value}
3339
+
`;
3340
+
Deno.stderr.writeSync(new TextEncoder().encode(string4));
3341
+
} else {
3342
+
const string4 = `${file_line}
3343
+
${string_value}`;
3344
+
console.log(string4);
3345
+
}
3346
+
return value3;
3347
+
}
3348
+
function echo$inspectString(str) {
3349
+
let new_str = '"';
3350
+
for (let i = 0; i < str.length; i++) {
3351
+
let char = str[i];
3352
+
if (char == "\n") new_str += "\\n";
3353
+
else if (char == "\r") new_str += "\\r";
3354
+
else if (char == " ") new_str += "\\t";
3355
+
else if (char == "\f") new_str += "\\f";
3356
+
else if (char == "\\") new_str += "\\\\";
3357
+
else if (char == '"') new_str += '\\"';
3358
+
else if (char < " " || char > "~" && char < "\xA0") {
3359
+
new_str += "\\u{" + char.charCodeAt(0).toString(16).toUpperCase().padStart(4, "0") + "}";
3360
+
} else {
3361
+
new_str += char;
3362
+
}
3363
+
}
3364
+
new_str += '"';
3365
+
return new_str;
3366
+
}
3367
+
function echo$inspectDict(map4) {
3368
+
let body = "dict.from_list([";
3369
+
let first2 = true;
3370
+
let key_value_pairs = [];
3371
+
map4.forEach((value3, key) => {
3372
+
key_value_pairs.push([key, value3]);
3373
+
});
3374
+
key_value_pairs.sort();
3375
+
key_value_pairs.forEach(([key, value3]) => {
3376
+
if (!first2) body = body + ", ";
3377
+
body = body + "#(" + echo$inspect(key) + ", " + echo$inspect(value3) + ")";
3378
+
first2 = false;
3379
+
});
3380
+
return body + "])";
3381
+
}
3382
+
function echo$inspectCustomType(record) {
3383
+
const props = Object.keys(record).map((label) => {
3384
+
const value3 = echo$inspect(record[label]);
3385
+
return isNaN(parseInt(label)) ? `${label}: ${value3}` : value3;
3386
+
}).join(", ");
3387
+
return props ? `${record.constructor.name}(${props})` : record.constructor.name;
3388
+
}
3389
+
function echo$inspectObject(v) {
3390
+
const name = Object.getPrototypeOf(v)?.constructor?.name || "Object";
3391
+
const props = [];
3392
+
for (const k of Object.keys(v)) {
3393
+
props.push(`${echo$inspect(k)}: ${echo$inspect(v[k])}`);
3394
+
}
3395
+
const body = props.length ? " " + props.join(", ") + " " : "";
3396
+
const head = name === "Object" ? "" : name + " ";
3397
+
return `//js(${head}{${body}})`;
3398
+
}
3399
+
function echo$inspect(v) {
3400
+
const t = typeof v;
3401
+
if (v === true) return "True";
3402
+
if (v === false) return "False";
3403
+
if (v === null) return "//js(null)";
3404
+
if (v === void 0) return "Nil";
3405
+
if (t === "string") return echo$inspectString(v);
3406
+
if (t === "bigint" || t === "number") return v.toString();
3407
+
if (Array.isArray(v)) return `#(${v.map(echo$inspect).join(", ")})`;
3408
+
if (v instanceof List) return `[${v.toArray().map(echo$inspect).join(", ")}]`;
3409
+
if (v instanceof UtfCodepoint) return `//utfcodepoint(${String.fromCodePoint(v.value)})`;
3410
+
if (v instanceof BitArray) return echo$inspectBitArray(v);
3411
+
if (v instanceof CustomType) return echo$inspectCustomType(v);
3412
+
if (echo$isDict(v)) return echo$inspectDict(v);
3413
+
if (v instanceof Set) return `//js(Set(${[...v].map(echo$inspect).join(", ")}))`;
3414
+
if (v instanceof RegExp) return `//js(${v})`;
3415
+
if (v instanceof Date) return `//js(Date("${v.toISOString()}"))`;
3416
+
if (v instanceof Function) {
3417
+
const args = [];
3418
+
for (const i of Array(v.length).keys()) args.push(String.fromCharCode(i + 97));
3419
+
return `//fn(${args.join(", ")}) { ... }`;
3420
+
}
3421
+
return echo$inspectObject(v);
3422
+
}
3423
+
function echo$inspectBitArray(bitArray) {
3424
+
let endOfAlignedBytes = bitArray.bitOffset + 8 * Math.trunc(bitArray.bitSize / 8);
3425
+
let alignedBytes = bitArraySlice(bitArray, bitArray.bitOffset, endOfAlignedBytes);
3426
+
let remainingUnalignedBits = bitArray.bitSize % 8;
3427
+
if (remainingUnalignedBits > 0) {
3428
+
let remainingBits = bitArraySliceToInt(bitArray, endOfAlignedBytes, bitArray.bitSize, false, false);
3429
+
let alignedBytesArray = Array.from(alignedBytes.rawBuffer);
3430
+
let suffix = `${remainingBits}:size(${remainingUnalignedBits})`;
3431
+
if (alignedBytesArray.length === 0) {
3432
+
return `<<${suffix}>>`;
3433
+
} else {
3434
+
return `<<${Array.from(alignedBytes.rawBuffer).join(", ")}, ${suffix}>>`;
3435
+
}
3436
+
} else {
3437
+
return `<<${Array.from(alignedBytes.rawBuffer).join(", ")}>>`;
3438
+
}
3439
+
}
3440
+
function echo$isDict(value3) {
3441
+
try {
3442
+
return value3 instanceof Dict;
3443
+
} catch {
3444
+
return false;
3445
+
}
3446
+
}
3447
+
3448
+
// build/dev/javascript/locator_colour/locator_colour.mjs
3449
+
var Model2 = class extends CustomType {
3450
+
constructor(uuid, colour2) {
3451
+
super();
3452
+
this.uuid = uuid;
3453
+
this.colour = colour2;
3454
+
}
3455
+
};
3456
+
var UserUpdatedUUID = class extends CustomType {
3457
+
constructor(uuid) {
3458
+
super();
3459
+
this.uuid = uuid;
3460
+
}
3461
+
};
3462
+
function init2(_) {
3463
+
return new Model2("", new None());
3464
+
}
3465
+
function update(_, msg) {
3466
+
{
3467
+
let uuid = msg.uuid;
3468
+
return new Model2(
3469
+
uuid,
3470
+
(() => {
3471
+
let $ = hash_code(uuid);
3472
+
if ($.isOk()) {
3473
+
let hash = $[0];
3474
+
return new Some(generate_colour(hash, 0.9));
3475
+
} else {
3476
+
return new None();
3477
+
}
3478
+
})()
3479
+
);
3480
+
}
3481
+
}
3482
+
function view(model) {
3483
+
return div(
3484
+
toList([
3485
+
style(
3486
+
toList([
3487
+
["width", "100vw"],
3488
+
["height", "100vh"],
3489
+
["display", "flex"],
3490
+
["flex-direction", "column"],
3491
+
["justify-content", "center"],
3492
+
["align-items", "center"],
3493
+
(() => {
3494
+
let $ = model.colour;
3495
+
if ($ instanceof Some) {
3496
+
let colour2 = $[0];
3497
+
return [
3498
+
"background-color",
3499
+
"rgb(" + to_string(colour2.r) + "," + to_string(
3500
+
colour2.g
3501
+
) + "," + to_string(colour2.b) + ")"
3502
+
];
3503
+
} else {
3504
+
return ["", ""];
3505
+
}
3506
+
})()
3507
+
])
3508
+
)
3509
+
]),
3510
+
toList([
3511
+
div(
3512
+
toList([
3513
+
style(
3514
+
toList([
3515
+
["display", "flex"],
3516
+
["flex-direction", "column"],
3517
+
["justify-content", "center"],
3518
+
["align-items", "center"],
3519
+
["background-color", "#303446"],
3520
+
["color", "#c6d0f5"],
3521
+
["border", "2px solid #ca9ee6"],
3522
+
["padding", "1em"],
3523
+
["border-radius", "1em"]
3524
+
])
3525
+
)
3526
+
]),
3527
+
toList([
3528
+
h1(
3529
+
toList([style(toList([["margin", "0"]]))]),
3530
+
toList([text2("Enter UUID:")])
3531
+
),
3532
+
input(
3533
+
toList([
3534
+
style(
3535
+
toList([
3536
+
["width", "22em"],
3537
+
["height", "2em"],
3538
+
["text-align", "center"],
3539
+
["border", "none"],
3540
+
["border-radius", "1em"],
3541
+
["background-color", "#51576d"],
3542
+
["margin", "1em"],
3543
+
["color", "#c6d0f5"]
3544
+
])
3545
+
),
3546
+
value(model.uuid),
3547
+
on_input((var0) => {
3548
+
return new UserUpdatedUUID(var0);
3549
+
})
3550
+
])
3551
+
),
3552
+
a(
3553
+
toList([
3554
+
href("https://namemc.com/"),
3555
+
style(toList([["color", "#8caaee"]]))
3556
+
]),
3557
+
toList([text2("Find UUID here")])
3558
+
),
3559
+
(() => {
3560
+
let $ = model.colour;
3561
+
if ($ instanceof None && model.uuid !== "") {
3562
+
return p(
3563
+
toList([style(toList([["color", "#e78284"]]))]),
3564
+
toList([text2("Invalid UUID")])
3565
+
);
3566
+
} else if ($ instanceof Some) {
3567
+
let colour2 = $[0];
3568
+
return div(
3569
+
toList([
3570
+
style(
3571
+
toList([
3572
+
["margin-top", "1em"],
3573
+
["display", "flex"],
3574
+
["flex-direction", "column"],
3575
+
["gap", "4px"],
3576
+
["justify-content", "center"],
3577
+
["align-items", "center"]
3578
+
])
3579
+
)
3580
+
]),
3581
+
toList([
3582
+
code(
3583
+
toList([
3584
+
style(
3585
+
toList([
3586
+
["padding", "4px"],
3587
+
["border-radius", "0.5em"],
3588
+
["background-color", "#51576d"],
3589
+
["width", "fit-content"]
3590
+
])
3591
+
)
3592
+
]),
3593
+
toList([
3594
+
text2(
3595
+
"rgb(" + to_string(colour2.r) + "," + to_string(
3596
+
colour2.g
3597
+
) + "," + to_string(colour2.b) + ")"
3598
+
)
3599
+
])
3600
+
),
3601
+
code(
3602
+
toList([
3603
+
style(
3604
+
toList([
3605
+
["padding", "4px"],
3606
+
["border-radius", "0.5em"],
3607
+
["background-color", "#51576d"],
3608
+
["width", "fit-content"]
3609
+
])
3610
+
)
3611
+
]),
3612
+
toList([
3613
+
text2(
3614
+
"#" + to_base16(colour2.r) + to_base16(
3615
+
colour2.g
3616
+
) + to_base16(colour2.b)
3617
+
)
3618
+
])
3619
+
)
3620
+
])
3621
+
);
3622
+
} else {
3623
+
return none2();
3624
+
}
3625
+
})()
3626
+
])
3627
+
)
3628
+
])
3629
+
);
3630
+
}
3631
+
function main() {
3632
+
let app = simple(init2, update, view);
3633
+
let $ = start2(app, "#app", void 0);
3634
+
if (!$.isOk()) {
3635
+
throw makeError(
3636
+
"let_assert",
3637
+
"locator_colour",
3638
+
167,
3639
+
"main",
3640
+
"Pattern match failed, no pattern matched the value.",
3641
+
{ value: $ }
3642
+
);
3643
+
}
3644
+
return new Ok(void 0);
3645
+
}
3646
+
3647
+
// build/.lustre/entry.mjs
3648
+
main();
+169
src/locator_colour.gleam
+169
src/locator_colour.gleam
···
1
+
import gleam/int
2
+
import lustre
3
+
import lustre/attribute
4
+
import lustre/element
5
+
import lustre/element/html
6
+
import lustre/event
7
+
8
+
import gleam/option.{type Option, None, Some}
9
+
import locator_colour/colour
10
+
11
+
pub type Model {
12
+
Model(uuid: String, colour: Option(colour.Colour))
13
+
}
14
+
15
+
pub type Msg {
16
+
UserUpdatedUUID(uuid: String)
17
+
}
18
+
19
+
fn init(_flags) -> Model {
20
+
Model("", None)
21
+
}
22
+
23
+
fn update(_model: Model, msg: Msg) -> Model {
24
+
case msg {
25
+
UserUpdatedUUID(uuid) ->
26
+
Model(uuid:, colour: case colour.hash_code(uuid) {
27
+
Ok(hash) -> Some(colour.generate_colour(hash, 0.9))
28
+
_ -> None
29
+
})
30
+
}
31
+
}
32
+
33
+
pub fn view(model: Model) -> element.Element(Msg) {
34
+
html.div(
35
+
[
36
+
attribute.style([
37
+
#("width", "100vw"),
38
+
#("height", "100vh"),
39
+
#("display", "flex"),
40
+
#("flex-direction", "column"),
41
+
#("justify-content", "center"),
42
+
#("align-items", "center"),
43
+
case model.colour {
44
+
Some(colour) -> #(
45
+
"background-color",
46
+
"rgb("
47
+
<> int.to_string(colour.r)
48
+
<> ","
49
+
<> int.to_string(colour.g)
50
+
<> ","
51
+
<> int.to_string(colour.b)
52
+
<> ")",
53
+
)
54
+
None -> #("", "")
55
+
},
56
+
]),
57
+
],
58
+
[
59
+
html.div(
60
+
[
61
+
attribute.style([
62
+
#("display", "flex"),
63
+
#("flex-direction", "column"),
64
+
#("justify-content", "center"),
65
+
#("align-items", "center"),
66
+
#("background-color", "#303446"),
67
+
#("color", "#c6d0f5"),
68
+
#("border", "2px solid #ca9ee6"),
69
+
#("padding", "1em"),
70
+
#("border-radius", "1em"),
71
+
]),
72
+
],
73
+
[
74
+
html.h1([attribute.style([#("margin", "0")])], [
75
+
html.text("Enter UUID:"),
76
+
]),
77
+
html.input([
78
+
attribute.style([
79
+
#("width", "22em"),
80
+
#("height", "2em"),
81
+
#("text-align", "center"),
82
+
#("border", "none"),
83
+
#("border-radius", "1em"),
84
+
#("background-color", "#51576d"),
85
+
#("margin", "1em"),
86
+
#("color", "#c6d0f5"),
87
+
]),
88
+
attribute.value(model.uuid),
89
+
event.on_input(UserUpdatedUUID),
90
+
]),
91
+
html.a(
92
+
[
93
+
attribute.href("https://namemc.com/"),
94
+
attribute.style([#("color", "#8caaee")]),
95
+
],
96
+
[html.text("Find UUID here")],
97
+
),
98
+
case model.colour {
99
+
None if model.uuid != "" ->
100
+
html.p([attribute.style([#("color", "#e78284")])], [
101
+
html.text("Invalid UUID"),
102
+
])
103
+
Some(colour) ->
104
+
html.div(
105
+
[
106
+
attribute.style([
107
+
#("margin-top", "1em"),
108
+
#("display", "flex"),
109
+
#("flex-direction", "column"),
110
+
#("gap", "4px"),
111
+
#("justify-content", "center"),
112
+
#("align-items", "center"),
113
+
]),
114
+
],
115
+
[
116
+
html.code(
117
+
[
118
+
attribute.style([
119
+
#("padding", "4px"),
120
+
#("border-radius", "0.5em"),
121
+
#("background-color", "#51576d"),
122
+
#("width", "fit-content"),
123
+
]),
124
+
],
125
+
[
126
+
html.text(
127
+
"rgb("
128
+
<> int.to_string(colour.r)
129
+
<> ","
130
+
<> int.to_string(colour.g)
131
+
<> ","
132
+
<> int.to_string(colour.b)
133
+
<> ")",
134
+
),
135
+
],
136
+
),
137
+
html.code(
138
+
[
139
+
attribute.style([
140
+
#("padding", "4px"),
141
+
#("border-radius", "0.5em"),
142
+
#("background-color", "#51576d"),
143
+
#("width", "fit-content"),
144
+
]),
145
+
],
146
+
[
147
+
html.text(
148
+
"#"
149
+
<> int.to_base16(colour.r)
150
+
<> int.to_base16(colour.g)
151
+
<> int.to_base16(colour.b),
152
+
),
153
+
],
154
+
),
155
+
],
156
+
)
157
+
_ -> element.none()
158
+
},
159
+
],
160
+
),
161
+
],
162
+
)
163
+
}
164
+
165
+
pub fn main() {
166
+
let app = lustre.simple(init, update, view)
167
+
let assert Ok(_) = lustre.start(app, "#app", Nil)
168
+
Ok(Nil)
169
+
}
+215
src/locator_colour/colour.gleam
+215
src/locator_colour/colour.gleam
···
1
+
import bigi.{type BigInt}
2
+
import gleam/bit_array
3
+
import gleam/float
4
+
import gleam/int
5
+
import gleam/result
6
+
import gleam/string
7
+
8
+
@external(javascript, "./ffi.mjs", "zero_fill_bitwise_shift_right")
9
+
pub fn zero_fill_bitwise_shift_right(x: BigInt, y: Int) -> BigInt {
10
+
todo
11
+
}
12
+
13
+
@external(javascript, "./ffi.mjs", "to_signed")
14
+
pub fn to_signed(int: BigInt, bits: Int) -> BigInt {
15
+
todo
16
+
}
17
+
18
+
@external(javascript, "./ffi.mjs", "to_unsigned")
19
+
pub fn to_unsigned(int: BigInt, bits: Int) -> BigInt {
20
+
todo
21
+
}
22
+
23
+
pub fn alpha(i: BigInt) -> BigInt {
24
+
i
25
+
|> zero_fill_bitwise_shift_right(24)
26
+
|> to_unsigned(8)
27
+
}
28
+
29
+
pub fn red(i: BigInt) -> BigInt {
30
+
i
31
+
|> bigi.bitwise_shift_right(16)
32
+
|> bigi.bitwise_and(255 |> bigi.from_int)
33
+
}
34
+
35
+
pub fn green(i: BigInt) -> BigInt {
36
+
i
37
+
|> bigi.bitwise_shift_right(8)
38
+
|> bigi.bitwise_and(255 |> bigi.from_int)
39
+
}
40
+
41
+
pub fn blue(i: BigInt) -> BigInt {
42
+
i
43
+
|> bigi.bitwise_and(255 |> bigi.from_int)
44
+
}
45
+
46
+
// pub type Colour {
47
+
// Colour(alpha: Int, red: Int, green: Int, blue: Int)
48
+
// }
49
+
50
+
pub type Colour {
51
+
Colour(a: Int, r: Int, g: Int, b: Int)
52
+
}
53
+
54
+
pub fn generate_colour(uuid: BigInt, f: Float) -> Colour {
55
+
let j = red(uuid)
56
+
let k = green(uuid)
57
+
let l = blue(uuid)
58
+
let m = alpha(uuid)
59
+
let n = bigi.max(bigi.max(j, k), l)
60
+
let o = bigi.min(bigi.min(j, k), l)
61
+
let g = int.to_float(bigi.to_int(bigi.subtract(n, o)) |> result.unwrap(0))
62
+
let h = case n != 0 |> bigi.from_int() {
63
+
True -> g /. int.to_float(bigi.to_int(n) |> result.unwrap(0))
64
+
False -> 0.0
65
+
}
66
+
67
+
let p = case h == 0.0 {
68
+
True -> 0.0
69
+
False -> {
70
+
let q =
71
+
int.to_float(bigi.to_int(bigi.subtract(n, j)) |> result.unwrap(0)) /. g
72
+
let r =
73
+
int.to_float(bigi.to_int(bigi.subtract(n, k)) |> result.unwrap(0)) /. g
74
+
let s =
75
+
int.to_float(bigi.to_int(bigi.subtract(n, l)) |> result.unwrap(0)) /. g
76
+
let p =
77
+
case n {
78
+
n if n == j -> s -. r
79
+
n if n == k -> 2.0 +. q -. s
80
+
_ -> 4.0 +. r -. q
81
+
}
82
+
/. 6.0
83
+
84
+
case p <. 0.0 {
85
+
True -> p +. 1.0
86
+
False -> p
87
+
}
88
+
}
89
+
}
90
+
91
+
case h == 0.0 {
92
+
True ->
93
+
colour(
94
+
echo m |> bigi.to_int() |> result.unwrap(255),
95
+
echo float.round(f *. 255.0),
96
+
echo float.round(f *. 255.0),
97
+
echo float.round(f *. 255.0),
98
+
)
99
+
False -> {
100
+
let q = { p -. float.floor(p) } *. 6.0
101
+
let r = q -. float.floor(q)
102
+
let s = f *. { 1.0 -. h }
103
+
let t = f *. { 1.0 -. h *. r }
104
+
let u = f *. { 1.0 -. h *. { 1.0 -. r } }
105
+
let #(j, k, l) = case q |> float.floor() |> float.round() {
106
+
0 -> #(
107
+
float.round(f *. 255.0),
108
+
float.round(u *. 255.0),
109
+
float.round(s *. 255.0),
110
+
)
111
+
1 -> #(
112
+
float.round(t *. 255.0),
113
+
float.round(f *. 255.0),
114
+
float.round(s *. 255.0),
115
+
)
116
+
2 -> #(
117
+
float.round(s *. 255.0),
118
+
float.round(f *. 255.0),
119
+
float.round(u *. 255.0),
120
+
)
121
+
3 -> #(
122
+
float.round(s *. 255.0),
123
+
float.round(t *. 255.0),
124
+
float.round(f *. 255.0),
125
+
)
126
+
4 -> #(
127
+
float.round(u *. 255.0),
128
+
float.round(s *. 255.0),
129
+
float.round(f *. 255.0),
130
+
)
131
+
5 -> #(
132
+
float.round(f *. 255.0),
133
+
float.round(s *. 255.0),
134
+
float.round(t *. 255.0),
135
+
)
136
+
_ -> #(
137
+
j |> bigi.to_int() |> result.unwrap(696_969),
138
+
k |> bigi.to_int() |> result.unwrap(696_969),
139
+
l |> bigi.to_int() |> result.unwrap(696_969),
140
+
)
141
+
}
142
+
colour(m |> bigi.to_int() |> result.unwrap(255), j, k, l)
143
+
}
144
+
}
145
+
}
146
+
147
+
pub fn colour(a: Int, r: Int, g: Int, b: Int) -> Colour {
148
+
Colour(a:, r:, g:, b:)
149
+
}
150
+
151
+
pub fn hash_int(value: BigInt) -> BigInt {
152
+
let inner = zero_fill_bitwise_shift_right(value, 32)
153
+
let xor = bigi.bitwise_exclusive_or(value, inner)
154
+
xor
155
+
}
156
+
157
+
fn to_bit_array_helper(str: String) -> Result(BitArray, Nil) {
158
+
to_bitstring_help(str, 0, <<>>)
159
+
}
160
+
161
+
fn hex_to_int(c: String) -> Result(Int, Nil) {
162
+
let i = case c {
163
+
"0" -> 0
164
+
"1" -> 1
165
+
"2" -> 2
166
+
"3" -> 3
167
+
"4" -> 4
168
+
"5" -> 5
169
+
"6" -> 6
170
+
"7" -> 7
171
+
"8" -> 8
172
+
"9" -> 9
173
+
"a" | "A" -> 10
174
+
"b" | "B" -> 11
175
+
"c" | "C" -> 12
176
+
"d" | "D" -> 13
177
+
"e" | "E" -> 14
178
+
"f" | "F" -> 15
179
+
_ -> 16
180
+
}
181
+
case i {
182
+
16 -> Error(Nil)
183
+
x -> Ok(x)
184
+
}
185
+
}
186
+
187
+
fn to_bitstring_help(
188
+
str: String,
189
+
index: Int,
190
+
acc: BitArray,
191
+
) -> Result(BitArray, Nil) {
192
+
case string.pop_grapheme(str) {
193
+
Error(Nil) if index == 32 -> Ok(acc)
194
+
Ok(#("-", rest)) if index < 32 -> to_bitstring_help(rest, index, acc)
195
+
Ok(#(c, rest)) if index < 32 ->
196
+
case hex_to_int(c) {
197
+
Ok(i) -> to_bitstring_help(rest, index + 1, <<acc:bits, i:size(4)>>)
198
+
Error(_) -> Error(Nil)
199
+
}
200
+
_ -> Error(Nil)
201
+
}
202
+
}
203
+
204
+
pub fn hash_code(uuid: String) -> Result(BigInt, Nil) {
205
+
case uuid |> to_bit_array_helper() {
206
+
Ok(<<msb:bits-size(64), lsb:bits-size(64)>>) -> {
207
+
use msb <- result.try(bigi.from_bytes(msb, bigi.BigEndian, bigi.Signed))
208
+
use lsb <- result.try(bigi.from_bytes(lsb, bigi.BigEndian, bigi.Signed))
209
+
let xor = bigi.bitwise_exclusive_or(msb, lsb)
210
+
let hash = hash_int(xor)
211
+
Ok(hash)
212
+
}
213
+
_ -> Error(Nil)
214
+
}
215
+
}
+11
src/locator_colour/ffi.mjs
+11
src/locator_colour/ffi.mjs