@haoduo-icon/memory 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/pkg-index.js ADDED
@@ -0,0 +1,679 @@
1
+ // node_modules/min-mphash/dist/index.js
2
+ function _define_property(obj, key, value) {
3
+ if (key in obj)
4
+ Object.defineProperty(obj, key, {
5
+ value,
6
+ enumerable: true,
7
+ configurable: true,
8
+ writable: true
9
+ });
10
+ else
11
+ obj[key] = value;
12
+ return obj;
13
+ }
14
+ function readVarInt(buffer, offset) {
15
+ let val = 0;
16
+ let shift = 0;
17
+ let bytes = 0;
18
+ while (true) {
19
+ const b = buffer[offset + bytes];
20
+ val |= (127 & b) << shift;
21
+ bytes++;
22
+ if ((128 & b) === 0)
23
+ break;
24
+ shift += 7;
25
+ }
26
+ return {
27
+ value: val,
28
+ bytes
29
+ };
30
+ }
31
+ var CBOR = {
32
+ encodeInt(val, buffer) {
33
+ const major = 0;
34
+ if (val < 24)
35
+ buffer.push(major | val);
36
+ else if (val <= 255)
37
+ buffer.push(24 | major, val);
38
+ else if (val <= 65535)
39
+ buffer.push(25 | major, val >> 8, 255 & val);
40
+ else
41
+ buffer.push(26 | major, val >>> 24 & 255, val >>> 16 & 255, val >>> 8 & 255, 255 & val);
42
+ },
43
+ encodeBytes(bytes, buffer) {
44
+ const major = 64;
45
+ const len = bytes.byteLength;
46
+ if (len < 24)
47
+ buffer.push(major | len);
48
+ else if (len <= 255)
49
+ buffer.push(24 | major, len);
50
+ else if (len <= 65535)
51
+ buffer.push(25 | major, len >> 8, 255 & len);
52
+ else
53
+ buffer.push(26 | major, len >>> 24 & 255, len >>> 16 & 255, len >>> 8 & 255, 255 & len);
54
+ for (let i = 0;i < len; i++)
55
+ buffer.push(bytes[i]);
56
+ },
57
+ encodeNull(buffer) {
58
+ buffer.push(246);
59
+ },
60
+ encodeArrayHead(len, buffer) {
61
+ const major = 128;
62
+ if (len < 24)
63
+ buffer.push(major | len);
64
+ },
65
+ decode(view, offsetRef) {
66
+ const byte = view.getUint8(offsetRef.current++);
67
+ const major = 224 & byte;
68
+ const additional = 31 & byte;
69
+ let val = 0;
70
+ if (additional < 24)
71
+ val = additional;
72
+ else if (additional === 24) {
73
+ val = view.getUint8(offsetRef.current);
74
+ offsetRef.current += 1;
75
+ } else if (additional === 25) {
76
+ val = view.getUint16(offsetRef.current, false);
77
+ offsetRef.current += 2;
78
+ } else if (additional === 26) {
79
+ val = view.getUint32(offsetRef.current, false);
80
+ offsetRef.current += 4;
81
+ } else
82
+ throw new Error("Unsupported CBOR size");
83
+ if (major === 0)
84
+ return val;
85
+ if (major === 64) {
86
+ const len = val;
87
+ const buf = new Uint8Array(view.buffer.slice(view.byteOffset + offsetRef.current, view.byteOffset + offsetRef.current + len));
88
+ offsetRef.current += len;
89
+ return buf;
90
+ }
91
+ if (major === 128) {
92
+ const len = val;
93
+ const arr = [];
94
+ for (let i = 0;i < len; i++)
95
+ arr.push(CBOR.decode(view, offsetRef));
96
+ return arr;
97
+ }
98
+ if (byte === 246)
99
+ return null;
100
+ throw new Error(`Unknown CBOR type: ${byte.toString(16)}`);
101
+ }
102
+ };
103
+ var INT_TO_MODE = [
104
+ "none",
105
+ "4",
106
+ "8",
107
+ "16",
108
+ "32",
109
+ "2"
110
+ ];
111
+ function dictFromCBOR(bin) {
112
+ const view = new DataView(bin.buffer, bin.byteOffset, bin.byteLength);
113
+ const offsetRef = {
114
+ current: 0
115
+ };
116
+ const arr = CBOR.decode(view, offsetRef);
117
+ if (!Array.isArray(arr) || arr.length < 7)
118
+ throw new Error("Invalid CBOR format");
119
+ const [n, m, seed0, bucketSizes, seedStream, modeInt, fpRaw, seedZeroBitmap, hashSeed] = arr;
120
+ const validationMode = INT_TO_MODE[modeInt] || "none";
121
+ let fingerprints;
122
+ if (fpRaw && validationMode !== "none") {
123
+ if (validationMode === "2" || validationMode === "4" || validationMode === "8")
124
+ fingerprints = fpRaw;
125
+ else if (validationMode === "16")
126
+ fingerprints = new Uint16Array(fpRaw.buffer, fpRaw.byteOffset, fpRaw.byteLength / 2);
127
+ else if (validationMode === "32")
128
+ fingerprints = new Uint32Array(fpRaw.buffer, fpRaw.byteOffset, fpRaw.byteLength / 4);
129
+ }
130
+ return {
131
+ n,
132
+ m,
133
+ seed0,
134
+ hashSeed: hashSeed || 0,
135
+ bucketSizes,
136
+ seedStream,
137
+ validationMode,
138
+ fingerprints,
139
+ seedZeroBitmap: seedZeroBitmap || undefined
140
+ };
141
+ }
142
+ async function decompressIBinary(data) {
143
+ const stream = new Blob([
144
+ data
145
+ ]).stream().pipeThrough(new DecompressionStream("gzip"));
146
+ return new Uint8Array(await new Response(stream).arrayBuffer());
147
+ }
148
+ class BitReader {
149
+ read(bits) {
150
+ let value = 0;
151
+ for (let i = 0;i < bits; i++) {
152
+ if (this.byteOffset >= this.buffer.length)
153
+ return 0;
154
+ const bit = this.buffer[this.byteOffset] >> this.bitOffset & 1;
155
+ value |= bit << i;
156
+ this.bitOffset++;
157
+ if (this.bitOffset === 8) {
158
+ this.byteOffset++;
159
+ this.bitOffset = 0;
160
+ }
161
+ }
162
+ return value;
163
+ }
164
+ constructor(buffer) {
165
+ _define_property(this, "buffer", undefined);
166
+ _define_property(this, "byteOffset", 0);
167
+ _define_property(this, "bitOffset", 0);
168
+ this.buffer = buffer;
169
+ }
170
+ }
171
+ function readBitsAt(buffer, bitOffset, bitLength) {
172
+ let value = 0;
173
+ let currentBit = bitOffset;
174
+ for (let i = 0;i < bitLength; i++) {
175
+ const byteIdx = currentBit >>> 3;
176
+ const bitIdx = 7 & currentBit;
177
+ if (byteIdx >= buffer.length)
178
+ return 0;
179
+ const bit = buffer[byteIdx] >> bitIdx & 1;
180
+ value |= bit << i;
181
+ currentBit++;
182
+ }
183
+ return value;
184
+ }
185
+ function MinMPHash_define_property(obj, key, value) {
186
+ if (key in obj)
187
+ Object.defineProperty(obj, key, {
188
+ value,
189
+ enumerable: true,
190
+ configurable: true,
191
+ writable: true
192
+ });
193
+ else
194
+ obj[key] = value;
195
+ return obj;
196
+ }
197
+ class MinMPHash {
198
+ static async fromCompressed(data) {
199
+ const decompressed = await decompressIBinary(data);
200
+ return new MinMPHash(decompressed);
201
+ }
202
+ hash(input) {
203
+ if (this.n === 0)
204
+ return -1;
205
+ const h1 = murmurHash3_32(input, this.hashSeed);
206
+ const h2 = murmurHash3_32(input, ~this.hashSeed);
207
+ const h0 = (scramble(h1, this.seed0) ^ h2) >>> 0;
208
+ const bIdx = Math.floor(h0 / 4294967296 * this.m);
209
+ const offset = this.offsets[bIdx];
210
+ const nextOffset = this.offsets[bIdx + 1];
211
+ const bucketSize = nextOffset - offset;
212
+ if (bucketSize === 0)
213
+ return -1;
214
+ let resultIdx = 0;
215
+ if (bucketSize === 1)
216
+ resultIdx = offset;
217
+ else {
218
+ const s = this.seeds[bIdx];
219
+ const h = (scramble(h1, s) ^ h2) >>> 0;
220
+ resultIdx = offset + h % bucketSize;
221
+ }
222
+ if (this.validationMode !== "none" && this.fingerprints) {
223
+ const fpHash = murmurHash3_32(input, MinMPHash.FP_SEED);
224
+ if (this.validationMode === "2") {
225
+ const expectedFp2 = 3 & fpHash;
226
+ const byteIdx = resultIdx >>> 2;
227
+ const shift = (3 & resultIdx) << 1;
228
+ if ((this.fingerprints[byteIdx] >>> shift & 3) !== expectedFp2)
229
+ return -1;
230
+ } else if (this.validationMode === "4") {
231
+ const expectedFp4 = 15 & fpHash;
232
+ const byteIdx = resultIdx >>> 1;
233
+ const storedByte = this.fingerprints[byteIdx];
234
+ const storedFp4 = (1 & resultIdx) === 0 ? 15 & storedByte : storedByte >>> 4 & 15;
235
+ if (storedFp4 !== expectedFp4)
236
+ return -1;
237
+ } else if (this.validationMode === "8") {
238
+ if (this.fingerprints[resultIdx] !== (255 & fpHash))
239
+ return -1;
240
+ } else if (this.validationMode === "16") {
241
+ if (this.fingerprints[resultIdx] !== (65535 & fpHash))
242
+ return -1;
243
+ } else if (this.fingerprints[resultIdx] !== fpHash >>> 0)
244
+ return -1;
245
+ }
246
+ return resultIdx;
247
+ }
248
+ constructor(dict) {
249
+ MinMPHash_define_property(this, "n", undefined);
250
+ MinMPHash_define_property(this, "m", undefined);
251
+ MinMPHash_define_property(this, "seed0", undefined);
252
+ MinMPHash_define_property(this, "hashSeed", undefined);
253
+ MinMPHash_define_property(this, "offsets", undefined);
254
+ MinMPHash_define_property(this, "seeds", undefined);
255
+ MinMPHash_define_property(this, "validationMode", undefined);
256
+ MinMPHash_define_property(this, "fingerprints", null);
257
+ if (dict instanceof Uint8Array)
258
+ dict = dictFromCBOR(dict);
259
+ this.n = dict.n;
260
+ this.m = dict.m;
261
+ this.seed0 = dict.seed0;
262
+ this.hashSeed = dict.hashSeed || 0;
263
+ this.validationMode = dict.validationMode || "none";
264
+ if (this.n === 0) {
265
+ this.offsets = new Uint32Array(0);
266
+ this.seeds = new Int32Array(0);
267
+ return;
268
+ }
269
+ this.offsets = new Uint32Array(this.m + 1);
270
+ let currentOffset = 0;
271
+ for (let i = 0;i < this.m; i++) {
272
+ this.offsets[i] = currentOffset;
273
+ const byte = dict.bucketSizes[i >>> 1];
274
+ const len = 1 & i ? byte >>> 4 : 15 & byte;
275
+ currentOffset += len;
276
+ }
277
+ this.offsets[this.m] = currentOffset;
278
+ this.seeds = new Int32Array(this.m);
279
+ let ptr = 0;
280
+ const buf = dict.seedStream;
281
+ const bitmap = dict.seedZeroBitmap;
282
+ for (let i = 0;i < this.m; i++) {
283
+ let isZero = false;
284
+ if (bitmap) {
285
+ if ((bitmap[i >>> 3] & 1 << (7 & i)) !== 0)
286
+ isZero = true;
287
+ }
288
+ if (isZero)
289
+ this.seeds[i] = 0;
290
+ else {
291
+ let result = 0;
292
+ let shift = 0;
293
+ while (true) {
294
+ const byte = buf[ptr++];
295
+ result |= (127 & byte) << shift;
296
+ if ((128 & byte) === 0)
297
+ break;
298
+ shift += 7;
299
+ }
300
+ this.seeds[i] = result;
301
+ }
302
+ }
303
+ if (this.validationMode !== "none" && dict.fingerprints) {
304
+ const raw = dict.fingerprints;
305
+ if (this.validationMode === "2" || this.validationMode === "4" || this.validationMode === "8")
306
+ this.fingerprints = raw instanceof Uint8Array ? raw : new Uint8Array(raw);
307
+ else if (this.validationMode === "16")
308
+ this.fingerprints = raw instanceof Uint16Array ? raw : new Uint16Array(raw);
309
+ else
310
+ this.fingerprints = raw instanceof Uint32Array ? raw : new Uint32Array(raw);
311
+ }
312
+ }
313
+ }
314
+ MinMPHash_define_property(MinMPHash, "FP_SEED", 305441741);
315
+ function scramble(k, seed) {
316
+ k ^= seed;
317
+ k = Math.imul(k, 2246822507);
318
+ k ^= k >>> 13;
319
+ k = Math.imul(k, 3266489909);
320
+ k ^= k >>> 16;
321
+ return k >>> 0;
322
+ }
323
+ function murmurHash3_32(key, seed) {
324
+ let h1 = seed;
325
+ const c1 = 3432918353;
326
+ const c2 = 461845907;
327
+ for (let i = 0;i < key.length; i++) {
328
+ let k1 = key.charCodeAt(i);
329
+ k1 = Math.imul(k1, c1);
330
+ k1 = k1 << 15 | k1 >>> 17;
331
+ k1 = Math.imul(k1, c2);
332
+ h1 ^= k1;
333
+ h1 = h1 << 13 | h1 >>> 19;
334
+ h1 = Math.imul(h1, 5) + 3864292196;
335
+ }
336
+ h1 ^= key.length;
337
+ h1 ^= h1 >>> 16;
338
+ h1 = Math.imul(h1, 2246822507);
339
+ h1 ^= h1 >>> 13;
340
+ h1 = Math.imul(h1, 3266489909);
341
+ h1 ^= h1 >>> 16;
342
+ return h1 >>> 0;
343
+ }
344
+ function MinMPLookup_define_property(obj, key, value) {
345
+ if (key in obj)
346
+ Object.defineProperty(obj, key, {
347
+ value,
348
+ enumerable: true,
349
+ configurable: true,
350
+ writable: true
351
+ });
352
+ else
353
+ obj[key] = value;
354
+ return obj;
355
+ }
356
+ function deserializeLookupDict(data) {
357
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
358
+ let offset = 0;
359
+ const decoder = new TextDecoder;
360
+ const readU32 = () => {
361
+ const val = view.getUint32(offset, false);
362
+ offset += 4;
363
+ return val;
364
+ };
365
+ const mphLen = readU32();
366
+ const mmpHashDictBin = data.subarray(offset, offset + mphLen);
367
+ offset += mphLen;
368
+ const keysCount = readU32();
369
+ const keys = [];
370
+ for (let i = 0;i < keysCount; i++) {
371
+ const kLen = readU32();
372
+ const kBytes = data.subarray(offset, offset + kLen);
373
+ offset += kLen;
374
+ keys.push(decoder.decode(kBytes));
375
+ }
376
+ const sectionLen = readU32();
377
+ if (sectionLen === 4294967295) {
378
+ const bitsPerKey = readU32();
379
+ const dataLen = readU32();
380
+ const valueToKeyIndexes = data.subarray(offset, offset + dataLen);
381
+ offset += dataLen;
382
+ const colMapLen = readU32();
383
+ let collisionMap;
384
+ if (colMapLen > 0) {
385
+ const colBytes = data.subarray(offset, offset + colMapLen);
386
+ offset += colMapLen;
387
+ collisionMap = new Map;
388
+ let cOffset = 0;
389
+ const { value: count, bytes: b1 } = readVarInt(colBytes, cOffset);
390
+ cOffset += b1;
391
+ let prevHash = 0;
392
+ for (let i = 0;i < count; i++) {
393
+ const { value: deltaHash, bytes: b2 } = readVarInt(colBytes, cOffset);
394
+ cOffset += b2;
395
+ const h = prevHash + deltaHash;
396
+ prevHash = h;
397
+ const { value: kCount, bytes: b3 } = readVarInt(colBytes, cOffset);
398
+ cOffset += b3;
399
+ const kIndices = [];
400
+ let prevKey = 0;
401
+ for (let j = 0;j < kCount; j++) {
402
+ const { value: deltaKey, bytes: b4 } = readVarInt(colBytes, cOffset);
403
+ cOffset += b4;
404
+ const k = prevKey + deltaKey;
405
+ prevKey = k;
406
+ kIndices.push(k);
407
+ }
408
+ collisionMap.set(h, kIndices);
409
+ }
410
+ }
411
+ return {
412
+ mmpHashDictBin,
413
+ keys,
414
+ valueToKeyIndexes,
415
+ bitsPerKey,
416
+ collisionMap
417
+ };
418
+ }
419
+ {
420
+ const hashBytesLen = sectionLen;
421
+ const hashBytes = data.subarray(offset, offset + hashBytesLen);
422
+ offset += hashBytesLen;
423
+ const keyToHashes = [];
424
+ let hOffset = 0;
425
+ for (let i = 0;i < keysCount; i++) {
426
+ const { value: count, bytes: b1 } = readVarInt(hashBytes, hOffset);
427
+ hOffset += b1;
428
+ if (count === 0) {
429
+ keyToHashes.push(new Uint32Array(0));
430
+ continue;
431
+ }
432
+ const bits = hashBytes[hOffset];
433
+ hOffset += 1;
434
+ const totalBits = bits * count;
435
+ const packedBytesLen = Math.ceil(totalBits / 8);
436
+ const packedData = hashBytes.subarray(hOffset, hOffset + packedBytesLen);
437
+ hOffset += packedBytesLen;
438
+ const br = new BitReader(packedData);
439
+ const hashes = new Uint32Array(count);
440
+ let prev = 0;
441
+ for (let j = 0;j < count; j++) {
442
+ const delta = br.read(bits);
443
+ prev += delta;
444
+ hashes[j] = prev;
445
+ }
446
+ keyToHashes.push(hashes);
447
+ }
448
+ return {
449
+ mmpHashDictBin,
450
+ keys,
451
+ keyToHashes
452
+ };
453
+ }
454
+ }
455
+
456
+ class MinMPLookup {
457
+ static async fromCompressed(data) {
458
+ const decompressed = await decompressIBinary(data);
459
+ const dict = deserializeLookupDict(decompressed);
460
+ return new MinMPLookup(dict);
461
+ }
462
+ static fromBinary(data) {
463
+ const dict = deserializeLookupDict(data);
464
+ return new MinMPLookup(dict);
465
+ }
466
+ buildInvertedIndex() {
467
+ if (!this.dict.keyToHashes)
468
+ return;
469
+ const n = this.mph.n;
470
+ this._invertedIndex = Array.from({
471
+ length: n
472
+ }, () => []);
473
+ for (let i = 0;i < this.dict.keys.length; i++) {
474
+ const hashes = this.dict.keyToHashes[i];
475
+ for (let j = 0;j < hashes.length; j++) {
476
+ const h = hashes[j];
477
+ if (h < n)
478
+ this._invertedIndex[h].push(i);
479
+ }
480
+ }
481
+ }
482
+ query(value) {
483
+ if (this.dict.valueToKeyIndexes && this.dict.bitsPerKey) {
484
+ const h = this.mph.hash(value);
485
+ if (h < 0 || h >= this.mph.n)
486
+ return null;
487
+ const keyIdx = readBitsAt(this.dict.valueToKeyIndexes, h * this.dict.bitsPerKey, this.dict.bitsPerKey);
488
+ if (keyIdx === this.dict.keys.length) {
489
+ if (this.dict.collisionMap && this.dict.collisionMap.has(h)) {
490
+ const indices = this.dict.collisionMap.get(h);
491
+ return indices.length > 0 ? this.dict.keys[indices[0]] : null;
492
+ }
493
+ return null;
494
+ }
495
+ if (keyIdx >= this.dict.keys.length)
496
+ return null;
497
+ return this.dict.keys[keyIdx];
498
+ }
499
+ const keys = this.queryAll(value);
500
+ return keys && keys.length > 0 ? keys[0] : null;
501
+ }
502
+ queryAll(value) {
503
+ if (this.dict.valueToKeyIndexes && this.dict.bitsPerKey) {
504
+ const h = this.mph.hash(value);
505
+ if (h < 0 || h >= this.mph.n)
506
+ return null;
507
+ const keyIdx = readBitsAt(this.dict.valueToKeyIndexes, h * this.dict.bitsPerKey, this.dict.bitsPerKey);
508
+ if (keyIdx === this.dict.keys.length) {
509
+ if (this.dict.collisionMap && this.dict.collisionMap.has(h)) {
510
+ const indices = this.dict.collisionMap.get(h);
511
+ return indices.map((i) => this.dict.keys[i]);
512
+ }
513
+ return null;
514
+ }
515
+ if (keyIdx >= this.dict.keys.length)
516
+ return null;
517
+ return [
518
+ this.dict.keys[keyIdx]
519
+ ];
520
+ }
521
+ const idx = this.mph.hash(value);
522
+ if (idx < 0 || !this._invertedIndex)
523
+ return null;
524
+ if (idx >= this._invertedIndex.length)
525
+ return null;
526
+ const keyIndices = this._invertedIndex[idx];
527
+ if (keyIndices.length === 0)
528
+ return null;
529
+ const results = [];
530
+ for (const keyIdx of keyIndices)
531
+ results.push(this.dict.keys[keyIdx]);
532
+ return results.length > 0 ? results : null;
533
+ }
534
+ keys() {
535
+ return this.dict.keys;
536
+ }
537
+ constructor(dict) {
538
+ MinMPLookup_define_property(this, "mph", undefined);
539
+ MinMPLookup_define_property(this, "dict", undefined);
540
+ MinMPLookup_define_property(this, "_invertedIndex", null);
541
+ if (dict instanceof Uint8Array)
542
+ dict = deserializeLookupDict(dict);
543
+ this.dict = dict;
544
+ this.mph = new MinMPHash(dict.mmpHashDictBin);
545
+ if (dict.keyToHashes)
546
+ this.buildInvertedIndex();
547
+ }
548
+ }
549
+
550
+ // scripts/core.ts
551
+ var GLOBAL_REGISTRY_KEY = "__HD_ICONS_REGISTRY__";
552
+ function getRegistry() {
553
+ if (typeof window !== "undefined") {
554
+ if (!window[GLOBAL_REGISTRY_KEY]) {
555
+ window[GLOBAL_REGISTRY_KEY] = new Map;
556
+ }
557
+ return window[GLOBAL_REGISTRY_KEY];
558
+ } else {
559
+ if (!globalThis[GLOBAL_REGISTRY_KEY]) {
560
+ globalThis[GLOBAL_REGISTRY_KEY] = new Map;
561
+ }
562
+ return globalThis[GLOBAL_REGISTRY_KEY];
563
+ }
564
+ }
565
+ function register(pkg, data) {
566
+ const registry = getRegistry();
567
+ if (!registry.has(pkg)) {
568
+ registry.set(pkg, {
569
+ lookupData: data.lookup,
570
+ baseUrl: data.baseUrl,
571
+ chunks: data.chunks
572
+ });
573
+ if (typeof window !== "undefined") {
574
+ window.dispatchEvent(new CustomEvent("hd-icon-registered", { detail: { pkg } }));
575
+ }
576
+ }
577
+ }
578
+
579
+ class HdIcon extends HTMLElement {
580
+ static get observedAttributes() {
581
+ return ["icon"];
582
+ }
583
+ _use;
584
+ constructor() {
585
+ super();
586
+ this.innerHTML = `<svg width="1em" height="1em" fill="currentColor" style="display: inline-block; vertical-align: middle; overflow: hidden;"><use width="100%" height="100%"></use></svg>`;
587
+ this._use = this.querySelector("use");
588
+ }
589
+ attributeChangedCallback(name, oldValue, newValue) {
590
+ if (name === "icon" && newValue !== oldValue) {
591
+ this.render();
592
+ }
593
+ }
594
+ connectedCallback() {
595
+ this.render();
596
+ if (typeof window !== "undefined") {
597
+ window.addEventListener("hd-icon-registered", this.handleRegistration);
598
+ }
599
+ }
600
+ disconnectedCallback() {
601
+ if (typeof window !== "undefined") {
602
+ window.removeEventListener("hd-icon-registered", this.handleRegistration);
603
+ }
604
+ }
605
+ handleRegistration = (e) => {
606
+ const detail = e.detail;
607
+ const iconKey = this.getAttribute("icon");
608
+ if (iconKey && iconKey.startsWith(detail.pkg + ":")) {
609
+ this.render();
610
+ }
611
+ };
612
+ async render() {
613
+ const iconKey = this.getAttribute("icon");
614
+ if (!iconKey)
615
+ return;
616
+ const [pkg, name] = iconKey.split(":");
617
+ if (!pkg || !name) {
618
+ console.warn(`[hd-icon] Invalid icon format: "${iconKey}". Expected "pkg:name".`);
619
+ return;
620
+ }
621
+ const registry = getRegistry().get(pkg);
622
+ if (!registry) {
623
+ return;
624
+ }
625
+ if (!registry._lookupInstance) {
626
+ let lookupData = registry.lookupData;
627
+ if (typeof lookupData === "string") {
628
+ const binaryString = atob(lookupData);
629
+ const bytes = new Uint8Array(binaryString.length);
630
+ for (let i = 0;i < binaryString.length; i++) {
631
+ bytes[i] = binaryString.charCodeAt(i);
632
+ }
633
+ lookupData = bytes;
634
+ registry.lookupData = lookupData;
635
+ }
636
+ registry._lookupInstance = new MinMPLookup(lookupData);
637
+ }
638
+ const chunkFile = registry._lookupInstance.query(name);
639
+ if (!chunkFile) {
640
+ console.warn(`[hd-icon] Icon "${name}" not found in package "${pkg}".`);
641
+ return;
642
+ }
643
+ const symbolId = `hd-icon-${pkg}-${name}`;
644
+ let url = chunkFile;
645
+ if (registry.chunks && registry.chunks[chunkFile]) {
646
+ url = registry.chunks[chunkFile];
647
+ } else if (registry.baseUrl) {
648
+ try {
649
+ url = new URL(chunkFile, registry.baseUrl).href;
650
+ } catch (e) {
651
+ console.warn(`[hd-icon] Failed to resolve icon URL: ${chunkFile} relative to ${registry.baseUrl}`, e);
652
+ }
653
+ }
654
+ this._use.setAttribute("href", `${url}#${symbolId}`);
655
+ }
656
+ }
657
+ if (typeof customElements !== "undefined" && !customElements.get("hd-icon")) {
658
+ customElements.define("hd-icon", HdIcon);
659
+ }
660
+ if (typeof window !== "undefined") {
661
+ window.IconPkg = { register, HdIcon };
662
+ }
663
+
664
+ // iconpkg/memory/src-index.ts
665
+ var lookup = "AAADeIkZAosYgxrifNzzWEJWdXWVRFZUKHVEJ5ZDdRZkZCeHZGYHUVNaeDdUIyZWdHNXEINkZVYUVFMidhxyWBSJdUZiZKYkRWJHMlM4Zkg3FwVYhVwKFOMBBAVK/AgCjAIIDBDCCAELFB4EuwFeoEECDAxdpQEVOwI+2gFfyQENDmkD9QFMBQPqISLJAl9+Bx8nBhQXAgrkAQFihQEKAtYDAyVXEAUaBgkGGgQCHUecOQKMAdQHFhNHTWWbAR4CAQ0DClTRGxUGAjcKAQIhvQx6S2AHiAHHBBECWQKLEQ3PW8kMTvvxImJU1xLBSZWXKMPB/ZbIYB/k8Z4A1+54XtFTpxfZHhdUw1Uwex8qrIi/phwPUNX0VTVO4IGGqttLkn3pFeISY94KmfJLh/JEqY3V99OsaK80q/l7zkv1JnqOzbEaTZEpJNmq1nBlxd7YvL029GMKQOuetqW8YpBpvnat6/LRcWNlAdAB34M7R7o1iNT7c4qsgxfsqCwfuYkDqg/PPpGaUzPbqdBzC9dm25Kk5AMK/322qdLXvs1TygV3epMT2J5py+qouWD15OyYLPjrrYzFmD24/YLKOSPSLJBq99EDCmOVR0ZK293SMT+o+/qGBT7rV6Kyb1BFkmF3CRYAC6J0vWLJZRutYm23NKj8p0BhO6uBaHIYz0RlJXKE9sfPDN0Mfda7v1Lm31mU/Uyk/Ef2obPhcZxZamP5wfmV3jM4NCDKx8QbotVMlaOfbBX6O+atEWIkb4U/qZqpfZVCNCo5a5+NssZsab4nJk2BSvCBufc0aYdIinL5rn+c8UUWnICqrVUaoN+oPl9PxOXLpd4t2fL+MKZ7XWdZeXM3nX4OlV/T+DKoHLnHH3FwBWF5QoLW0axAC/BLPoG3Yxn6AOR4NTwF/tqWjRrtHYOAoXcPbG99HIzvaZDs8+YkHM0qXtHX0EHzyE6d+4YovOi9XUTPoD6ODHUPZQPnCdHtdxt8coJPceYyUVBcmJS4GJiM+/Jbf2BnDVqSRknSsbZpwOi2+dtGqbPhvuwbMmf0DQOrkBunhUdBlgRCNJdwZ5nCaURE9ErKVdJMpl/l6BFNY0OCdfYU1PKbg//2IGEIPLGO06ro3UXVN68gyXIlF6tS1pecgOHenR6svqXVbXXMnItAGgx5UQABICAIGAAKMIQAggBgQYICAAAAAAQAAAANbWVtb3J5LTAxLnN2ZwAAAA1tZW1vcnktMDIuc3ZnAAAADW1lbW9yeS0wMy5zdmcAAAANbWVtb3J5LTA0LnN2Z/////8AAAADAAAA9RCEKJAgaAASScikKJmUKEqASJASKZIiAQgyRBCQAIigIECgBBAwJIoCKEoUJEokBYCiQcGSCJMUBYgEQQgCBVIkIMAiKBg2KQgSBUmAbAuQBAiACRCiQJAQYRICSJCSJIESIEIiAFCCQRGWCYOCCAIgCVEWSMmSYIGiRZOmBEEUSYIkKYAkBRKGTFCCBBAUJQKyCEmkDAAEIEGCCFIAKVgAJIgyCBCSRFMQKIEkJVKiJYIEIYoSTEASZIECBRCiRAAQSRKAKBESKZIGCYiEIME0QUskJEgEKIOmYcsQSAAiQEogJQgEAYCCSIiyQBGARZiiAUoAAAAAAA==";
666
+ var chunks = {
667
+ "memory-01.svg": new URL("./memory-01.svg", import.meta.url).href,
668
+ "memory-02.svg": new URL("./memory-02.svg", import.meta.url).href,
669
+ "memory-03.svg": new URL("./memory-03.svg", import.meta.url).href,
670
+ "memory-04.svg": new URL("./memory-04.svg", import.meta.url).href
671
+ };
672
+ register("memory", {
673
+ lookup,
674
+ chunks,
675
+ baseUrl: import.meta.url
676
+ });
677
+ export {
678
+ HdIcon
679
+ };