@engineerplaybook/design-system 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1121 @@
1
+ import ie, { useState as p, useRef as ce, forwardRef as q, createElement as O, useEffect as de, memo as xe, useMemo as me } from "react";
2
+ var I = { exports: {} }, w = {};
3
+ /**
4
+ * @license React
5
+ * react-jsx-runtime.production.js
6
+ *
7
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
8
+ *
9
+ * This source code is licensed under the MIT license found in the
10
+ * LICENSE file in the root directory of this source tree.
11
+ */
12
+ var Y;
13
+ function ue() {
14
+ if (Y) return w;
15
+ Y = 1;
16
+ var r = Symbol.for("react.transitional.element"), o = Symbol.for("react.fragment");
17
+ function n(l, s, i) {
18
+ var d = null;
19
+ if (i !== void 0 && (d = "" + i), s.key !== void 0 && (d = "" + s.key), "key" in s) {
20
+ i = {};
21
+ for (var x in s)
22
+ x !== "key" && (i[x] = s[x]);
23
+ } else i = s;
24
+ return s = i.ref, {
25
+ $$typeof: r,
26
+ type: l,
27
+ key: d,
28
+ ref: s !== void 0 ? s : null,
29
+ props: i
30
+ };
31
+ }
32
+ return w.Fragment = o, w.jsx = n, w.jsxs = n, w;
33
+ }
34
+ var E = {};
35
+ /**
36
+ * @license React
37
+ * react-jsx-runtime.development.js
38
+ *
39
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
40
+ *
41
+ * This source code is licensed under the MIT license found in the
42
+ * LICENSE file in the root directory of this source tree.
43
+ */
44
+ var H;
45
+ function he() {
46
+ return H || (H = 1, process.env.NODE_ENV !== "production" && function() {
47
+ function r(t) {
48
+ if (t == null) return null;
49
+ if (typeof t == "function")
50
+ return t.$$typeof === ne ? null : t.displayName || t.name || null;
51
+ if (typeof t == "string") return t;
52
+ switch (t) {
53
+ case T:
54
+ return "Fragment";
55
+ case G:
56
+ return "Profiler";
57
+ case X:
58
+ return "StrictMode";
59
+ case te:
60
+ return "Suspense";
61
+ case re:
62
+ return "SuspenseList";
63
+ case ae:
64
+ return "Activity";
65
+ }
66
+ if (typeof t == "object")
67
+ switch (typeof t.tag == "number" && console.error(
68
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
69
+ ), t.$$typeof) {
70
+ case Z:
71
+ return "Portal";
72
+ case K:
73
+ return t.displayName || "Context";
74
+ case Q:
75
+ return (t._context.displayName || "Context") + ".Consumer";
76
+ case ee:
77
+ var a = t.render;
78
+ return t = t.displayName, t || (t = a.displayName || a.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
79
+ case se:
80
+ return a = t.displayName || null, a !== null ? a : r(t.type) || "Memo";
81
+ case R:
82
+ a = t._payload, t = t._init;
83
+ try {
84
+ return r(t(a));
85
+ } catch {
86
+ }
87
+ }
88
+ return null;
89
+ }
90
+ function o(t) {
91
+ return "" + t;
92
+ }
93
+ function n(t) {
94
+ try {
95
+ o(t);
96
+ var a = !1;
97
+ } catch {
98
+ a = !0;
99
+ }
100
+ if (a) {
101
+ a = console;
102
+ var c = a.error, m = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
103
+ return c.call(
104
+ a,
105
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
106
+ m
107
+ ), o(t);
108
+ }
109
+ }
110
+ function l(t) {
111
+ if (t === T) return "<>";
112
+ if (typeof t == "object" && t !== null && t.$$typeof === R)
113
+ return "<...>";
114
+ try {
115
+ var a = r(t);
116
+ return a ? "<" + a + ">" : "<...>";
117
+ } catch {
118
+ return "<...>";
119
+ }
120
+ }
121
+ function s() {
122
+ var t = S.A;
123
+ return t === null ? null : t.getOwner();
124
+ }
125
+ function i() {
126
+ return Error("react-stack-top-frame");
127
+ }
128
+ function d(t) {
129
+ if ($.call(t, "key")) {
130
+ var a = Object.getOwnPropertyDescriptor(t, "key").get;
131
+ if (a && a.isReactWarning) return !1;
132
+ }
133
+ return t.key !== void 0;
134
+ }
135
+ function x(t, a) {
136
+ function c() {
137
+ z || (z = !0, console.error(
138
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
139
+ a
140
+ ));
141
+ }
142
+ c.isReactWarning = !0, Object.defineProperty(t, "key", {
143
+ get: c,
144
+ configurable: !0
145
+ });
146
+ }
147
+ function b() {
148
+ var t = r(this.type);
149
+ return L[t] || (L[t] = !0, console.error(
150
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
151
+ )), t = this.props.ref, t !== void 0 ? t : null;
152
+ }
153
+ function j(t, a, c, m, _, M) {
154
+ var u = c.ref;
155
+ return t = {
156
+ $$typeof: h,
157
+ type: t,
158
+ key: a,
159
+ props: c,
160
+ _owner: m
161
+ }, (u !== void 0 ? u : null) !== null ? Object.defineProperty(t, "ref", {
162
+ enumerable: !1,
163
+ get: b
164
+ }) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
165
+ configurable: !1,
166
+ enumerable: !1,
167
+ writable: !0,
168
+ value: 0
169
+ }), Object.defineProperty(t, "_debugInfo", {
170
+ configurable: !1,
171
+ enumerable: !1,
172
+ writable: !0,
173
+ value: null
174
+ }), Object.defineProperty(t, "_debugStack", {
175
+ configurable: !1,
176
+ enumerable: !1,
177
+ writable: !0,
178
+ value: _
179
+ }), Object.defineProperty(t, "_debugTask", {
180
+ configurable: !1,
181
+ enumerable: !1,
182
+ writable: !0,
183
+ value: M
184
+ }), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
185
+ }
186
+ function f(t, a, c, m, _, M) {
187
+ var u = a.children;
188
+ if (u !== void 0)
189
+ if (m)
190
+ if (oe(u)) {
191
+ for (m = 0; m < u.length; m++)
192
+ v(u[m]);
193
+ Object.freeze && Object.freeze(u);
194
+ } else
195
+ console.error(
196
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
197
+ );
198
+ else v(u);
199
+ if ($.call(a, "key")) {
200
+ u = r(t);
201
+ var k = Object.keys(a).filter(function(le) {
202
+ return le !== "key";
203
+ });
204
+ m = 0 < k.length ? "{key: someKey, " + k.join(": ..., ") + ": ...}" : "{key: someKey}", V[u + m] || (k = 0 < k.length ? "{" + k.join(": ..., ") + ": ...}" : "{}", console.error(
205
+ `A props object containing a "key" prop is being spread into JSX:
206
+ let props = %s;
207
+ <%s {...props} />
208
+ React keys must be passed directly to JSX without using spread:
209
+ let props = %s;
210
+ <%s key={someKey} {...props} />`,
211
+ m,
212
+ u,
213
+ k,
214
+ u
215
+ ), V[u + m] = !0);
216
+ }
217
+ if (u = null, c !== void 0 && (n(c), u = "" + c), d(a) && (n(a.key), u = "" + a.key), "key" in a) {
218
+ c = {};
219
+ for (var A in a)
220
+ A !== "key" && (c[A] = a[A]);
221
+ } else c = a;
222
+ return u && x(
223
+ c,
224
+ typeof t == "function" ? t.displayName || t.name || "Unknown" : t
225
+ ), j(
226
+ t,
227
+ u,
228
+ c,
229
+ s(),
230
+ _,
231
+ M
232
+ );
233
+ }
234
+ function v(t) {
235
+ N(t) ? t._store && (t._store.validated = 1) : typeof t == "object" && t !== null && t.$$typeof === R && (t._payload.status === "fulfilled" ? N(t._payload.value) && t._payload.value._store && (t._payload.value._store.validated = 1) : t._store && (t._store.validated = 1));
236
+ }
237
+ function N(t) {
238
+ return typeof t == "object" && t !== null && t.$$typeof === h;
239
+ }
240
+ var y = ie, h = Symbol.for("react.transitional.element"), Z = Symbol.for("react.portal"), T = Symbol.for("react.fragment"), X = Symbol.for("react.strict_mode"), G = Symbol.for("react.profiler"), Q = Symbol.for("react.consumer"), K = Symbol.for("react.context"), ee = Symbol.for("react.forward_ref"), te = Symbol.for("react.suspense"), re = Symbol.for("react.suspense_list"), se = Symbol.for("react.memo"), R = Symbol.for("react.lazy"), ae = Symbol.for("react.activity"), ne = Symbol.for("react.client.reference"), S = y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, $ = Object.prototype.hasOwnProperty, oe = Array.isArray, C = console.createTask ? console.createTask : function() {
241
+ return null;
242
+ };
243
+ y = {
244
+ react_stack_bottom_frame: function(t) {
245
+ return t();
246
+ }
247
+ };
248
+ var z, L = {}, F = y.react_stack_bottom_frame.bind(
249
+ y,
250
+ i
251
+ )(), D = C(l(i)), V = {};
252
+ E.Fragment = T, E.jsx = function(t, a, c) {
253
+ var m = 1e4 > S.recentlyCreatedOwnerStacks++;
254
+ return f(
255
+ t,
256
+ a,
257
+ c,
258
+ !1,
259
+ m ? Error("react-stack-top-frame") : F,
260
+ m ? C(l(t)) : D
261
+ );
262
+ }, E.jsxs = function(t, a, c) {
263
+ var m = 1e4 > S.recentlyCreatedOwnerStacks++;
264
+ return f(
265
+ t,
266
+ a,
267
+ c,
268
+ !0,
269
+ m ? Error("react-stack-top-frame") : F,
270
+ m ? C(l(t)) : D
271
+ );
272
+ };
273
+ }()), E;
274
+ }
275
+ process.env.NODE_ENV === "production" ? I.exports = ue() : I.exports = he();
276
+ var e = I.exports;
277
+ const Je = () => {
278
+ const [r, o] = p(!1), n = ce(!1), [l, s] = p(!1), i = async () => {
279
+ for (o(!0), n.current = !1; !n.current; )
280
+ await new Promise((x) => setTimeout(x, 0));
281
+ o(!1);
282
+ }, d = () => {
283
+ n.current = !0;
284
+ };
285
+ return /* @__PURE__ */ e.jsxs("section", { className: "bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden font-sans", children: [
286
+ /* @__PURE__ */ e.jsxs("div", { className: "p-6 border-b border-gray-100 bg-gray-50/50", children: [
287
+ /* @__PURE__ */ e.jsx("h3", { className: "text-xl font-bold text-gray-900 mb-2 flex items-center gap-2", children: '☕ The "Starbucks Queue" Simulator' }),
288
+ /* @__PURE__ */ e.jsxs("p", { className: "text-gray-600 text-sm", children: [
289
+ "JavaScript is ",
290
+ /* @__PURE__ */ e.jsx("strong", { children: "Single Threaded" }),
291
+ ". If a heavy task blocks the main thread, the browser cannot respond to clicks, typing, or rendering updates."
292
+ ] })
293
+ ] }),
294
+ /* @__PURE__ */ e.jsxs("div", { className: "p-6 grid lg:grid-cols-2 gap-8 items-start", children: [
295
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-6", children: [
296
+ /* @__PURE__ */ e.jsxs("div", { className: "bg-amber-50 p-6 rounded-xl border border-amber-100", children: [
297
+ /* @__PURE__ */ e.jsx("div", { className: "flex gap-4 mb-4", children: r ? /* @__PURE__ */ e.jsx(
298
+ "button",
299
+ {
300
+ onClick: d,
301
+ className: "flex-1 py-3 px-4 bg-red-600 text-white font-bold rounded-lg shadow-sm hover:bg-red-700 transition-all active:scale-95 animate-pulse",
302
+ children: "⏹️ Stop Process"
303
+ }
304
+ ) : /* @__PURE__ */ e.jsx(
305
+ "button",
306
+ {
307
+ onClick: i,
308
+ className: "flex-1 py-3 px-4 bg-green-600 text-white font-bold rounded-lg shadow-sm hover:bg-green-700 transition-all active:scale-95",
309
+ children: "▶️ Start Heavy Process"
310
+ }
311
+ ) }),
312
+ /* @__PURE__ */ e.jsxs("div", { className: "bg-white p-4 rounded-lg border border-amber-200", children: [
313
+ /* @__PURE__ */ e.jsx("label", { className: "text-xs font-bold text-gray-400 uppercase tracking-widest mb-2 block", children: "INTERACTIVITY TEST" }),
314
+ /* @__PURE__ */ e.jsx(
315
+ "input",
316
+ {
317
+ type: "text",
318
+ placeholder: r ? "🚫 I can't type..." : "✍️ Type here to test responsiveness...",
319
+ className: `w-full px-3 py-2 rounded border transition-colors text-sm ${r ? "bg-red-50 border-red-200 cursor-not-allowed placeholder-red-400" : "bg-white border-gray-300 focus:border-amber-500 focus:ring-1 focus:ring-amber-500"}`
320
+ }
321
+ ),
322
+ /* @__PURE__ */ e.jsx("p", { className: "text-xs text-gray-400 mt-2 text-center", children: r ? "Notice the lag? The Main Thread is busy!" : "Silky smooth. The Main Thread is free." })
323
+ ] })
324
+ ] }),
325
+ /* @__PURE__ */ e.jsx(
326
+ "button",
327
+ {
328
+ onClick: () => s(!l),
329
+ className: "text-sm font-medium text-blue-600 hover:text-blue-800 flex items-center gap-1",
330
+ children: l ? "▼ Hide Explanation" : "▶ How It Works (Pseudo-code)"
331
+ }
332
+ ),
333
+ l && /* @__PURE__ */ e.jsx("div", { className: "bg-gray-900 rounded-lg p-4 text-xs font-mono text-gray-300 overflow-x-auto", children: `// ❌ The Problem: Blocking the Main Thread
334
+ function heavyTask() {
335
+ while (true) {
336
+ // This loop never ends!
337
+ // Browser cannot Paint, Click, or Type.
338
+ }
339
+ }
340
+
341
+ // ✅ The Simulator (What's happening now):
342
+ async function energeticJank() {
343
+ while (shouldContinue) {
344
+ const start = Date.now();
345
+ // 1. Block thread for 500ms
346
+ while (Date.now() - start < 500) {
347
+ // Burn CPU 🔥
348
+ }
349
+ // 2. Yield briefly (allows you to click Stop)
350
+ await new Promise(r => setTimeout(r, 0));
351
+ }
352
+ }` })
353
+ ] }),
354
+ /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col items-center justify-center p-6 bg-gray-50 rounded-xl border border-gray-100 min-h-[300px]", children: [
355
+ /* @__PURE__ */ e.jsxs("div", { className: "relative w-48 h-48 flex items-center justify-center bg-white rounded-full border-4 border-gray-100 shadow-sm", children: [
356
+ /* @__PURE__ */ e.jsx("div", { className: `text-8xl transition-all duration-300 ${r ? "text-red-200 rotate-12" : "text-amber-400 animate-spin"}`, children: "⚙️" }),
357
+ /* @__PURE__ */ e.jsx("div", { className: "absolute inset-0 flex items-center justify-center flex-col", children: r ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
358
+ /* @__PURE__ */ e.jsx("div", { className: "text-4xl mb-1 animate-pulse", children: "🛑" }),
359
+ /* @__PURE__ */ e.jsx("span", { className: "bg-red-100 text-red-700 text-[10px] font-bold px-2 py-1 rounded-full border border-red-200", children: "BLOCKED" })
360
+ ] }) : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
361
+ /* @__PURE__ */ e.jsx("div", { className: "text-4xl mb-1", children: "☕" }),
362
+ /* @__PURE__ */ e.jsx("span", { className: "bg-green-100 text-green-700 text-[10px] font-bold px-2 py-1 rounded-full border border-green-200", children: "IDLE" })
363
+ ] }) })
364
+ ] }),
365
+ /* @__PURE__ */ e.jsxs("div", { className: "mt-6 text-center", children: [
366
+ /* @__PURE__ */ e.jsx("div", { className: "text-xs font-bold text-gray-400 uppercase tracking-widest mb-1", children: "THREAD STATUS" }),
367
+ /* @__PURE__ */ e.jsx("div", { className: `font-mono font-bold text-lg ${r ? "text-red-600" : "text-green-600"}`, children: r ? "FPS: ~1 (Laggy)" : "FPS: 60 (Smooth)" })
368
+ ] })
369
+ ] })
370
+ ] })
371
+ ] });
372
+ };
373
+ /**
374
+ * @license lucide-react v0.563.0 - ISC
375
+ *
376
+ * This source code is licensed under the ISC license.
377
+ * See the LICENSE file in the root directory of this source tree.
378
+ */
379
+ const B = (...r) => r.filter((o, n, l) => !!o && o.trim() !== "" && l.indexOf(o) === n).join(" ").trim();
380
+ /**
381
+ * @license lucide-react v0.563.0 - ISC
382
+ *
383
+ * This source code is licensed under the ISC license.
384
+ * See the LICENSE file in the root directory of this source tree.
385
+ */
386
+ const pe = (r) => r.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
387
+ /**
388
+ * @license lucide-react v0.563.0 - ISC
389
+ *
390
+ * This source code is licensed under the ISC license.
391
+ * See the LICENSE file in the root directory of this source tree.
392
+ */
393
+ const ge = (r) => r.replace(
394
+ /^([A-Z])|[\s-_]+(\w)/g,
395
+ (o, n, l) => l ? l.toUpperCase() : n.toLowerCase()
396
+ );
397
+ /**
398
+ * @license lucide-react v0.563.0 - ISC
399
+ *
400
+ * This source code is licensed under the ISC license.
401
+ * See the LICENSE file in the root directory of this source tree.
402
+ */
403
+ const U = (r) => {
404
+ const o = ge(r);
405
+ return o.charAt(0).toUpperCase() + o.slice(1);
406
+ };
407
+ /**
408
+ * @license lucide-react v0.563.0 - ISC
409
+ *
410
+ * This source code is licensed under the ISC license.
411
+ * See the LICENSE file in the root directory of this source tree.
412
+ */
413
+ var be = {
414
+ xmlns: "http://www.w3.org/2000/svg",
415
+ width: 24,
416
+ height: 24,
417
+ viewBox: "0 0 24 24",
418
+ fill: "none",
419
+ stroke: "currentColor",
420
+ strokeWidth: 2,
421
+ strokeLinecap: "round",
422
+ strokeLinejoin: "round"
423
+ };
424
+ /**
425
+ * @license lucide-react v0.563.0 - ISC
426
+ *
427
+ * This source code is licensed under the ISC license.
428
+ * See the LICENSE file in the root directory of this source tree.
429
+ */
430
+ const fe = (r) => {
431
+ for (const o in r)
432
+ if (o.startsWith("aria-") || o === "role" || o === "title")
433
+ return !0;
434
+ return !1;
435
+ };
436
+ /**
437
+ * @license lucide-react v0.563.0 - ISC
438
+ *
439
+ * This source code is licensed under the ISC license.
440
+ * See the LICENSE file in the root directory of this source tree.
441
+ */
442
+ const ye = q(
443
+ ({
444
+ color: r = "currentColor",
445
+ size: o = 24,
446
+ strokeWidth: n = 2,
447
+ absoluteStrokeWidth: l,
448
+ className: s = "",
449
+ children: i,
450
+ iconNode: d,
451
+ ...x
452
+ }, b) => O(
453
+ "svg",
454
+ {
455
+ ref: b,
456
+ ...be,
457
+ width: o,
458
+ height: o,
459
+ stroke: r,
460
+ strokeWidth: l ? Number(n) * 24 / Number(o) : n,
461
+ className: B("lucide", s),
462
+ ...!i && !fe(x) && { "aria-hidden": "true" },
463
+ ...x
464
+ },
465
+ [
466
+ ...d.map(([j, f]) => O(j, f)),
467
+ ...Array.isArray(i) ? i : [i]
468
+ ]
469
+ )
470
+ );
471
+ /**
472
+ * @license lucide-react v0.563.0 - ISC
473
+ *
474
+ * This source code is licensed under the ISC license.
475
+ * See the LICENSE file in the root directory of this source tree.
476
+ */
477
+ const g = (r, o) => {
478
+ const n = q(
479
+ ({ className: l, ...s }, i) => O(ye, {
480
+ ref: i,
481
+ iconNode: o,
482
+ className: B(
483
+ `lucide-${pe(U(r))}`,
484
+ `lucide-${r}`,
485
+ l
486
+ ),
487
+ ...s
488
+ })
489
+ );
490
+ return n.displayName = U(r), n;
491
+ };
492
+ /**
493
+ * @license lucide-react v0.563.0 - ISC
494
+ *
495
+ * This source code is licensed under the ISC license.
496
+ * See the LICENSE file in the root directory of this source tree.
497
+ */
498
+ const je = [
499
+ [
500
+ "path",
501
+ {
502
+ d: "M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",
503
+ key: "169zse"
504
+ }
505
+ ]
506
+ ], W = g("activity", je);
507
+ /**
508
+ * @license lucide-react v0.563.0 - ISC
509
+ *
510
+ * This source code is licensed under the ISC license.
511
+ * See the LICENSE file in the root directory of this source tree.
512
+ */
513
+ const ve = [
514
+ [
515
+ "path",
516
+ {
517
+ d: "M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",
518
+ key: "lc1i9w"
519
+ }
520
+ ],
521
+ ["path", { d: "m7 16.5-4.74-2.85", key: "1o9zyk" }],
522
+ ["path", { d: "m7 16.5 5-3", key: "va8pkn" }],
523
+ ["path", { d: "M7 16.5v5.17", key: "jnp8gn" }],
524
+ [
525
+ "path",
526
+ {
527
+ d: "M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",
528
+ key: "8zsnat"
529
+ }
530
+ ],
531
+ ["path", { d: "m17 16.5-5-3", key: "8arw3v" }],
532
+ ["path", { d: "m17 16.5 4.74-2.85", key: "8rfmw" }],
533
+ ["path", { d: "M17 16.5v5.17", key: "k6z78m" }],
534
+ [
535
+ "path",
536
+ {
537
+ d: "M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",
538
+ key: "1xygjf"
539
+ }
540
+ ],
541
+ ["path", { d: "M12 8 7.26 5.15", key: "1vbdud" }],
542
+ ["path", { d: "m12 8 4.74-2.85", key: "3rx089" }],
543
+ ["path", { d: "M12 13.5V8", key: "1io7kd" }]
544
+ ], Ne = g("boxes", ve);
545
+ /**
546
+ * @license lucide-react v0.563.0 - ISC
547
+ *
548
+ * This source code is licensed under the ISC license.
549
+ * See the LICENSE file in the root directory of this source tree.
550
+ */
551
+ const ke = [
552
+ ["path", { d: "M12 18V5", key: "adv99a" }],
553
+ ["path", { d: "M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4", key: "1e3is1" }],
554
+ ["path", { d: "M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5", key: "1gqd8o" }],
555
+ ["path", { d: "M17.997 5.125a4 4 0 0 1 2.526 5.77", key: "iwvgf7" }],
556
+ ["path", { d: "M18 18a4 4 0 0 0 2-7.464", key: "efp6ie" }],
557
+ ["path", { d: "M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517", key: "1gq6am" }],
558
+ ["path", { d: "M6 18a4 4 0 0 1-2-7.464", key: "k1g0md" }],
559
+ ["path", { d: "M6.003 5.125a4 4 0 0 0-2.526 5.77", key: "q97ue3" }]
560
+ ], P = g("brain", ke);
561
+ /**
562
+ * @license lucide-react v0.563.0 - ISC
563
+ *
564
+ * This source code is licensed under the ISC license.
565
+ * See the LICENSE file in the root directory of this source tree.
566
+ */
567
+ const we = [
568
+ ["path", { d: "M21.801 10A10 10 0 1 1 17 3.335", key: "yps3ct" }],
569
+ ["path", { d: "m9 11 3 3L22 4", key: "1pflzl" }]
570
+ ], Ee = g("circle-check-big", we);
571
+ /**
572
+ * @license lucide-react v0.563.0 - ISC
573
+ *
574
+ * This source code is licensed under the ISC license.
575
+ * See the LICENSE file in the root directory of this source tree.
576
+ */
577
+ const _e = [
578
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
579
+ ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
580
+ ["path", { d: "m9 9 6 6", key: "z0biqf" }]
581
+ ], Te = g("circle-x", _e);
582
+ /**
583
+ * @license lucide-react v0.563.0 - ISC
584
+ *
585
+ * This source code is licensed under the ISC license.
586
+ * See the LICENSE file in the root directory of this source tree.
587
+ */
588
+ const Re = [
589
+ ["path", { d: "M12 6v6l4 2", key: "mmk7yg" }],
590
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]
591
+ ], Se = g("clock", Re);
592
+ /**
593
+ * @license lucide-react v0.563.0 - ISC
594
+ *
595
+ * This source code is licensed under the ISC license.
596
+ * See the LICENSE file in the root directory of this source tree.
597
+ */
598
+ const Ce = [
599
+ ["path", { d: "m16 18 6-6-6-6", key: "eg8j8" }],
600
+ ["path", { d: "m8 6-6 6 6 6", key: "ppft3o" }]
601
+ ], Me = g("code", Ce);
602
+ /**
603
+ * @license lucide-react v0.563.0 - ISC
604
+ *
605
+ * This source code is licensed under the ISC license.
606
+ * See the LICENSE file in the root directory of this source tree.
607
+ */
608
+ const Ae = [
609
+ [
610
+ "path",
611
+ {
612
+ d: "M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",
613
+ key: "zw3jo"
614
+ }
615
+ ],
616
+ [
617
+ "path",
618
+ {
619
+ d: "M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",
620
+ key: "1wduqc"
621
+ }
622
+ ],
623
+ [
624
+ "path",
625
+ {
626
+ d: "M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",
627
+ key: "kqbvx6"
628
+ }
629
+ ]
630
+ ], Pe = g("layers", Ae);
631
+ /**
632
+ * @license lucide-react v0.563.0 - ISC
633
+ *
634
+ * This source code is licensed under the ISC license.
635
+ * See the LICENSE file in the root directory of this source tree.
636
+ */
637
+ const Oe = [
638
+ [
639
+ "path",
640
+ {
641
+ d: "M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",
642
+ key: "1gvzjb"
643
+ }
644
+ ],
645
+ ["path", { d: "M9 18h6", key: "x1upvd" }],
646
+ ["path", { d: "M10 22h4", key: "ceow96" }]
647
+ ], Ie = g("lightbulb", Oe);
648
+ /**
649
+ * @license lucide-react v0.563.0 - ISC
650
+ *
651
+ * This source code is licensed under the ISC license.
652
+ * See the LICENSE file in the root directory of this source tree.
653
+ */
654
+ const $e = [
655
+ ["path", { d: "M3 5h.01", key: "18ugdj" }],
656
+ ["path", { d: "M3 12h.01", key: "nlz23k" }],
657
+ ["path", { d: "M3 19h.01", key: "noohij" }],
658
+ ["path", { d: "M8 5h13", key: "1pao27" }],
659
+ ["path", { d: "M8 12h13", key: "1za7za" }],
660
+ ["path", { d: "M8 19h13", key: "m83p4d" }]
661
+ ], ze = g("list", $e);
662
+ /**
663
+ * @license lucide-react v0.563.0 - ISC
664
+ *
665
+ * This source code is licensed under the ISC license.
666
+ * See the LICENSE file in the root directory of this source tree.
667
+ */
668
+ const Le = [
669
+ ["path", { d: "M14 4.1 12 6", key: "ita8i4" }],
670
+ ["path", { d: "m5.1 8-2.9-.8", key: "1go3kf" }],
671
+ ["path", { d: "m6 12-1.9 2", key: "mnht97" }],
672
+ ["path", { d: "M7.2 2.2 8 5.1", key: "1cfko1" }],
673
+ [
674
+ "path",
675
+ {
676
+ d: "M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",
677
+ key: "s0h3yz"
678
+ }
679
+ ]
680
+ ], Fe = g("mouse-pointer-click", Le);
681
+ /**
682
+ * @license lucide-react v0.563.0 - ISC
683
+ *
684
+ * This source code is licensed under the ISC license.
685
+ * See the LICENSE file in the root directory of this source tree.
686
+ */
687
+ const De = [
688
+ ["path", { d: "M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8", key: "1p45f6" }],
689
+ ["path", { d: "M21 3v5h-5", key: "1q7to0" }]
690
+ ], Ve = g("rotate-cw", De);
691
+ /**
692
+ * @license lucide-react v0.563.0 - ISC
693
+ *
694
+ * This source code is licensed under the ISC license.
695
+ * See the LICENSE file in the root directory of this source tree.
696
+ */
697
+ const Ye = [
698
+ [
699
+ "path",
700
+ {
701
+ d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",
702
+ key: "wmoenq"
703
+ }
704
+ ],
705
+ ["path", { d: "M12 9v4", key: "juzpu7" }],
706
+ ["path", { d: "M12 17h.01", key: "p32p05" }]
707
+ ], He = g("triangle-alert", Ye);
708
+ /**
709
+ * @license lucide-react v0.563.0 - ISC
710
+ *
711
+ * This source code is licensed under the ISC license.
712
+ * See the LICENSE file in the root directory of this source tree.
713
+ */
714
+ const Ue = [
715
+ [
716
+ "path",
717
+ {
718
+ d: "M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",
719
+ key: "1xq2db"
720
+ }
721
+ ]
722
+ ], We = g("zap", Ue), Ze = () => {
723
+ const [r, o] = p(!1), [n, l] = p(0), [s, i] = p(!1);
724
+ return /* @__PURE__ */ e.jsxs("div", { className: "bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden font-sans", children: [
725
+ /* @__PURE__ */ e.jsxs("div", { className: "p-6 border-b border-gray-100 bg-gray-50/50", children: [
726
+ /* @__PURE__ */ e.jsxs("h3", { className: "text-xl font-bold text-gray-900 mb-2 flex items-center gap-2", children: [
727
+ /* @__PURE__ */ e.jsx(Pe, { className: "text-blue-600", size: 24 }),
728
+ " Virtualization Strategy"
729
+ ] }),
730
+ /* @__PURE__ */ e.jsx("p", { className: "text-gray-600 text-sm", children: "Rendering 10,000 items crashes the browser. Virtualization only renders what is currently visible matches the viewport (plus a small buffer)." })
731
+ ] }),
732
+ /* @__PURE__ */ e.jsxs("div", { className: "p-6 grid md:grid-cols-[280px_1fr] gap-8", children: [
733
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-6", children: [
734
+ /* @__PURE__ */ e.jsxs("div", { className: "bg-blue-50 p-6 rounded-xl border border-blue-100", children: [
735
+ /* @__PURE__ */ e.jsxs("h4", { className: "font-bold text-blue-900 mb-2 flex items-center gap-2", children: [
736
+ /* @__PURE__ */ e.jsx(ze, { size: 20 }),
737
+ " List Demo"
738
+ ] }),
739
+ /* @__PURE__ */ e.jsxs("p", { className: "text-xs text-blue-700 mb-4", children: [
740
+ "Toggle between rendering ",
741
+ /* @__PURE__ */ e.jsx("strong", { children: "10,000 Nodes" }),
742
+ " (Laggy) vs ",
743
+ /* @__PURE__ */ e.jsx("strong", { children: "~20 Nodes" }),
744
+ " (Smooth)."
745
+ ] }),
746
+ /* @__PURE__ */ e.jsxs(
747
+ "div",
748
+ {
749
+ className: "flex items-center gap-3 bg-white p-3 rounded-lg border border-blue-200 cursor-pointer hover:border-blue-300 transition-colors",
750
+ onClick: () => {
751
+ o(!r), l(0);
752
+ },
753
+ children: [
754
+ /* @__PURE__ */ e.jsx(
755
+ "input",
756
+ {
757
+ type: "checkbox",
758
+ checked: r,
759
+ readOnly: !0,
760
+ className: "w-5 h-5 text-blue-600 rounded focus:ring-blue-500 cursor-pointer"
761
+ }
762
+ ),
763
+ /* @__PURE__ */ e.jsx("span", { className: "text-sm font-bold text-gray-700 select-none", children: "Enable Virtualization" })
764
+ ]
765
+ }
766
+ )
767
+ ] }),
768
+ /* @__PURE__ */ e.jsx(
769
+ "button",
770
+ {
771
+ onClick: () => i(!s),
772
+ className: "text-sm font-medium text-gray-500 hover:text-gray-800 flex items-center gap-1 transition-colors",
773
+ children: s ? "▼ Hide Code" : "▶ How It Works (Math)"
774
+ }
775
+ ),
776
+ s && /* @__PURE__ */ e.jsx("div", { className: "bg-gray-900 rounded-lg p-4 text-xs font-mono text-gray-300 overflow-x-auto shadow-inner", children: `// 🧮 The Math of Windowing:
777
+
778
+ // 1. Where are we?
779
+ const startIndex = Math.floor(scrollTop / 35px);
780
+
781
+ // 2. How many fit?
782
+ const visibleCount = Math.ceil(height / 35px);
783
+
784
+ // 3. Render ONLY that slice
785
+ const items = allItems.slice(
786
+ startIndex,
787
+ startIndex + visibleCount + buffer
788
+ );
789
+
790
+ // 4. Fake the scroll height so scrollbar works
791
+ <div style={{ height: totalItems * 35px }} />` })
792
+ ] }),
793
+ /* @__PURE__ */ e.jsxs("div", { children: [
794
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between mb-2", children: [
795
+ /* @__PURE__ */ e.jsx("h5", { className: "font-bold text-gray-900 text-sm flex items-center gap-2", children: r ? /* @__PURE__ */ e.jsxs("span", { className: "text-green-600 flex items-center gap-1", children: [
796
+ /* @__PURE__ */ e.jsx(Ee, { size: 16 }),
797
+ " Optimized"
798
+ ] }) : /* @__PURE__ */ e.jsxs("span", { className: "text-red-600 flex items-center gap-1", children: [
799
+ /* @__PURE__ */ e.jsx(Te, { size: 16 }),
800
+ " Unoptimized"
801
+ ] }) }),
802
+ /* @__PURE__ */ e.jsx("div", { className: "text-xs font-mono text-gray-500", children: r ? "~10 DOM Nodes" : "10,000 DOM Nodes" })
803
+ ] }),
804
+ /* @__PURE__ */ e.jsx(
805
+ "div",
806
+ {
807
+ className: "border border-gray-200 rounded-lg overflow-auto relative bg-white shadow-inner",
808
+ style: { height: "320px" },
809
+ onScroll: (d) => l(d.currentTarget.scrollTop),
810
+ children: r ? (
811
+ // VIRTUALIZED LIST
812
+ /* @__PURE__ */ e.jsx("div", { style: { height: `${1e4 * 35}px`, position: "relative" }, children: (() => {
813
+ const j = Math.floor(n / 35), f = Math.min(1e4, j + Math.ceil(320 / 35)), v = Math.max(0, j - 5), N = Math.min(1e4, f + 5), y = [];
814
+ for (let h = v; h < N; h++)
815
+ y.push(
816
+ /* @__PURE__ */ e.jsxs(
817
+ "div",
818
+ {
819
+ className: "absolute top-0 left-0 w-full h-[35px] border-b border-gray-50 px-4 flex items-center justify-between text-sm text-gray-600 hover:bg-blue-50 transition-colors",
820
+ style: { transform: `translateY(${h * 35}px)` },
821
+ children: [
822
+ /* @__PURE__ */ e.jsxs("span", { children: [
823
+ "Item #",
824
+ h + 1
825
+ ] }),
826
+ /* @__PURE__ */ e.jsx("span", { className: "text-[10px] bg-gray-100 px-2 rounded-full text-gray-500", children: "Virtual" })
827
+ ]
828
+ },
829
+ h
830
+ )
831
+ );
832
+ return y;
833
+ })() })
834
+ ) : (
835
+ // HEAVY LIST (Render All)
836
+ /* @__PURE__ */ e.jsx("div", { children: Array.from({ length: 1e4 }).map((d, x) => /* @__PURE__ */ e.jsxs(
837
+ "div",
838
+ {
839
+ className: "h-[35px] border-b border-gray-50 px-4 flex items-center justify-between text-sm text-gray-600 hover:bg-red-50 transition-colors",
840
+ children: [
841
+ /* @__PURE__ */ e.jsxs("span", { children: [
842
+ "Item #",
843
+ x + 1
844
+ ] }),
845
+ /* @__PURE__ */ e.jsx("span", { className: "text-[10px] bg-red-100 text-red-700 px-2 rounded-full", children: "Heavy" })
846
+ ]
847
+ },
848
+ x
849
+ )) })
850
+ )
851
+ }
852
+ ),
853
+ /* @__PURE__ */ e.jsxs("div", { className: "mt-3 flex justify-between items-center bg-gray-50 p-3 rounded-lg border border-gray-100", children: [
854
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 text-xs", children: [
855
+ /* @__PURE__ */ e.jsx(Fe, { size: 14, className: "text-gray-400" }),
856
+ /* @__PURE__ */ e.jsx("span", { className: "text-gray-600", children: "Try scrolling fast!" })
857
+ ] }),
858
+ /* @__PURE__ */ e.jsx("span", { className: `text-xs font-bold ${r ? "text-green-600" : "text-red-500"}`, children: r ? "🚀 60 FPS Scrolling" : "🐌 Initial Lag / Scrolling Jitter" })
859
+ ] })
860
+ ] })
861
+ ] })
862
+ ] });
863
+ }, Xe = () => {
864
+ const [r, o] = p(0), [n, l] = p(!1), [s, i] = p(!1);
865
+ return de(() => {
866
+ if (!n) return;
867
+ let d;
868
+ const x = () => {
869
+ o((b) => b + 1), d = requestAnimationFrame(x);
870
+ };
871
+ return x(), () => cancelAnimationFrame(d);
872
+ }, [n]), /* @__PURE__ */ e.jsxs("section", { className: "bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden font-sans", children: [
873
+ /* @__PURE__ */ e.jsxs("div", { className: "p-6 border-b border-gray-100 bg-gray-50/50", children: [
874
+ /* @__PURE__ */ e.jsxs("h3", { className: "text-xl font-bold text-gray-900 mb-2 flex items-center gap-2", children: [
875
+ /* @__PURE__ */ e.jsx(W, { className: "text-blue-600", size: 24 }),
876
+ ' The "Renders are Bad" Myth'
877
+ ] }),
878
+ /* @__PURE__ */ e.jsxs("p", { className: "text-gray-600 text-sm", children: [
879
+ "React is fast. JavaScript blocking the main thread is what makes it feel slow. Let's prove that updating state ",
880
+ /* @__PURE__ */ e.jsx("strong", { children: "60 times per second" }),
881
+ " provides a smooth experience."
882
+ ] })
883
+ ] }),
884
+ /* @__PURE__ */ e.jsxs("div", { className: "p-6 grid md:grid-cols-2 gap-8 items-center", children: [
885
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-6", children: [
886
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-baseline gap-2", children: [
887
+ /* @__PURE__ */ e.jsx("div", { className: `text-7xl font-mono font-bold tabular-nums tracking-tighter transition-colors ${n ? "text-blue-600" : "text-gray-300"}`, children: r }),
888
+ /* @__PURE__ */ e.jsx("span", { className: "text-sm font-bold text-gray-400 uppercase tracking-widest", children: "Renders" })
889
+ ] }),
890
+ /* @__PURE__ */ e.jsx(
891
+ "button",
892
+ {
893
+ onClick: () => l(!n),
894
+ className: `w-full py-4 px-6 rounded-xl font-bold text-lg transition-all shadow-lg transform hover:-translate-y-1 flex items-center justify-center gap-2 ${n ? "bg-red-500 text-white shadow-red-500/30" : "bg-blue-600 text-white shadow-blue-500/30"}`,
895
+ children: n ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
896
+ /* @__PURE__ */ e.jsx(He, { size: 20 }),
897
+ " Stop The Madness"
898
+ ] }) : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
899
+ /* @__PURE__ */ e.jsx(We, { size: 20 }),
900
+ " Start Fast Renders"
901
+ ] })
902
+ }
903
+ ),
904
+ /* @__PURE__ */ e.jsxs("p", { className: "text-xs text-gray-500 text-center", children: [
905
+ "Updating state via ",
906
+ /* @__PURE__ */ e.jsx("code", { children: "requestAnimationFrame" }),
907
+ " (~16ms)"
908
+ ] }),
909
+ /* @__PURE__ */ e.jsx(
910
+ "button",
911
+ {
912
+ onClick: () => i(!s),
913
+ className: "text-sm font-medium text-gray-500 hover:text-gray-800 flex items-center gap-1 mx-auto",
914
+ children: s ? "▼ Hide Code" : "▶ How It Works"
915
+ }
916
+ )
917
+ ] }),
918
+ /* @__PURE__ */ e.jsx("div", { className: "space-y-4", children: s ? /* @__PURE__ */ e.jsxs("div", { className: "bg-gray-900 rounded-lg p-5 text-xs font-mono text-gray-300 shadow-inner overflow-hidden relative", children: [
919
+ /* @__PURE__ */ e.jsx("div", { className: "absolute top-2 right-2 text-gray-600", children: /* @__PURE__ */ e.jsx(Me, { size: 16 }) }),
920
+ `// 🚀 This runs 60 times/sec
921
+ // React handles this EASILY.
922
+
923
+ useEffect(() => {
924
+ const animate = () => {
925
+ // 1. Update State
926
+ setCount(c => c + 1);
927
+
928
+ // 2. Schedule next frame
929
+ requestAnimationFrame(animate);
930
+ };
931
+ animate();
932
+ }, []);`
933
+ ] }) : /* @__PURE__ */ e.jsxs("div", { className: "bg-blue-50 p-6 rounded-xl border border-blue-100 text-blue-800 text-sm leading-relaxed relative", children: [
934
+ /* @__PURE__ */ e.jsx("div", { className: "absolute -top-3 -right-3 bg-blue-100 p-2 rounded-full", children: /* @__PURE__ */ e.jsx(W, { size: 20, className: "text-blue-600" }) }),
935
+ /* @__PURE__ */ e.jsx("p", { className: "mb-2", children: /* @__PURE__ */ e.jsx("strong", { children: "Wait, isn't re-rendering bad?" }) }),
936
+ /* @__PURE__ */ e.jsx("p", { className: "mb-2", children: "Not necessarily! React's Virtual DOM diffing is extremely optimized." }),
937
+ /* @__PURE__ */ e.jsxs("p", { children: [
938
+ "The problem usually isn't ",
939
+ /* @__PURE__ */ e.jsx("em", { children: "rendering" }),
940
+ " - it's ",
941
+ /* @__PURE__ */ e.jsx("strong", { children: "Computation" }),
942
+ ". If `render()` takes 50ms, then 60fps is impossible. But if `render()` is cheap, you can do it all day."
943
+ ] })
944
+ ] }) })
945
+ ] })
946
+ ] });
947
+ }, J = ({ label: r }) => /* @__PURE__ */ e.jsxs("div", { className: "p-4 border border-gray-200 rounded-lg bg-gray-50 flex items-center justify-between", children: [
948
+ /* @__PURE__ */ e.jsxs("div", { children: [
949
+ /* @__PURE__ */ e.jsx("span", { className: "font-bold text-gray-700", children: r }),
950
+ /* @__PURE__ */ e.jsxs("div", { className: "text-xs text-red-500 font-mono mt-1 flex items-center gap-1", children: [
951
+ /* @__PURE__ */ e.jsx(Se, { size: 12 }),
952
+ " Rendered: ",
953
+ (/* @__PURE__ */ new Date()).toLocaleTimeString().split(" ")[0]
954
+ ] })
955
+ ] }),
956
+ /* @__PURE__ */ e.jsx("span", { className: "px-2 py-1 bg-gray-200 rounded text-xs text-gray-600 font-medium", children: "I am slow 🐌" })
957
+ ] }), qe = xe(J), Ge = () => {
958
+ const [r, o] = p(0), [n, l] = p(!1), [s, i] = p(!1), [d, x] = p(10), [b, j] = p(!1), [f, v] = p(!1), N = (h) => h * 2, y = me(() => N(d), [d, b ? "enabled" : Date.now()]);
959
+ return /* @__PURE__ */ e.jsxs("section", { className: "space-y-8 font-sans", children: [
960
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between bg-indigo-50 p-6 rounded-xl border border-indigo-100", children: [
961
+ /* @__PURE__ */ e.jsxs("div", { children: [
962
+ /* @__PURE__ */ e.jsxs("h3", { className: "text-xl font-bold text-indigo-900 mb-2 flex items-center gap-2", children: [
963
+ /* @__PURE__ */ e.jsx(P, { className: "text-indigo-600", size: 24 }),
964
+ " Interactive Optimizations"
965
+ ] }),
966
+ /* @__PURE__ */ e.jsxs("p", { className: "text-indigo-700 text-sm", children: [
967
+ "Memoization is about ",
968
+ /* @__PURE__ */ e.jsx("strong", { children: "Caching" }),
969
+ ". Don't re-do work if the inputs haven't changed."
970
+ ] })
971
+ ] }),
972
+ /* @__PURE__ */ e.jsx(
973
+ "button",
974
+ {
975
+ onClick: () => v(!f),
976
+ className: "text-sm font-bold text-indigo-600 hover:text-indigo-800 flex items-center gap-1 bg-white px-4 py-2 rounded-lg shadow-sm border border-indigo-200",
977
+ children: f ? "▼ Hide Logic" : "▶ How It Works"
978
+ }
979
+ )
980
+ ] }),
981
+ /* @__PURE__ */ e.jsxs("div", { className: "grid md:grid-cols-2 gap-8", children: [
982
+ /* @__PURE__ */ e.jsxs("div", { className: "bg-white p-8 rounded-2xl shadow-sm border border-gray-200 flex flex-col h-full", children: [
983
+ /* @__PURE__ */ e.jsxs("div", { className: "mb-6", children: [
984
+ /* @__PURE__ */ e.jsxs("h4", { className: "text-xl font-bold text-purple-600 mb-2 flex items-center gap-2", children: [
985
+ /* @__PURE__ */ e.jsx(Ne, { size: 20 }),
986
+ " React.memo"
987
+ ] }),
988
+ /* @__PURE__ */ e.jsx("p", { className: "text-gray-600 text-sm", children: "Prevents a child component from re-rendering if its props haven't changed." })
989
+ ] }),
990
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-6 flex-1", children: [
991
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between p-4 bg-purple-50 rounded-xl", children: [
992
+ /* @__PURE__ */ e.jsxs("div", { children: [
993
+ /* @__PURE__ */ e.jsx("div", { className: "text-sm font-bold text-purple-900", children: "Parent State Updates" }),
994
+ /* @__PURE__ */ e.jsx("div", { className: "text-xs text-purple-700", children: "Clicking button forces Parent render" })
995
+ ] }),
996
+ /* @__PURE__ */ e.jsxs(
997
+ "button",
998
+ {
999
+ onClick: () => o((h) => h + 1),
1000
+ className: "px-4 py-2 bg-purple-600 text-white rounded-lg font-bold shadow hover:bg-purple-700 active:scale-95 transition-all flex items-center gap-2",
1001
+ children: [
1002
+ /* @__PURE__ */ e.jsx(Ve, { size: 16 }),
1003
+ " Force Render (",
1004
+ r,
1005
+ ")"
1006
+ ]
1007
+ }
1008
+ )
1009
+ ] }),
1010
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-3 bg-white p-3 rounded-lg border border-purple-100 cursor-pointer", onClick: () => l(!n), children: [
1011
+ /* @__PURE__ */ e.jsx(
1012
+ "input",
1013
+ {
1014
+ type: "checkbox",
1015
+ checked: n,
1016
+ readOnly: !0,
1017
+ className: "w-5 h-5 text-purple-600 rounded focus:ring-purple-500 cursor-pointer"
1018
+ }
1019
+ ),
1020
+ /* @__PURE__ */ e.jsxs("div", { className: "text-sm font-bold text-gray-700 select-none", children: [
1021
+ "Enable ",
1022
+ /* @__PURE__ */ e.jsx("code", { className: "bg-gray-100 px-1 rounded text-purple-600", children: "React.memo" })
1023
+ ] })
1024
+ ] }),
1025
+ /* @__PURE__ */ e.jsxs("div", { className: "pt-4 border-t border-gray-100", children: [
1026
+ /* @__PURE__ */ e.jsx("p", { className: "text-xs font-bold text-gray-400 uppercase tracking-widest mb-2", children: "CHILD COMPONENT" }),
1027
+ n ? /* @__PURE__ */ e.jsx(qe, { label: "I am Memoized (Stable)" }) : /* @__PURE__ */ e.jsx(J, { label: "I am NOT Memoized" })
1028
+ ] })
1029
+ ] }),
1030
+ f && /* @__PURE__ */ e.jsx("div", { className: "mt-4 bg-gray-900 rounded-lg p-3 text-xs font-mono text-gray-300", children: `const Child = React.memo((props) => {
1031
+ // Only re-renders if
1032
+ // prevProps !== nextProps
1033
+ return <div>{props.label}</div>;
1034
+ });` })
1035
+ ] }),
1036
+ /* @__PURE__ */ e.jsxs("div", { className: `p-8 rounded-2xl shadow-sm border transition-colors duration-300 flex flex-col h-full ${s ? "bg-gray-900 border-gray-700" : "bg-white border-gray-200"}`, children: [
1037
+ /* @__PURE__ */ e.jsxs("div", { className: "mb-6", children: [
1038
+ /* @__PURE__ */ e.jsxs("h4", { className: `text-xl font-bold mb-2 flex items-center gap-2 ${s ? "text-blue-400" : "text-blue-600"}`, children: [
1039
+ /* @__PURE__ */ e.jsx(P, { size: 20 }),
1040
+ " useMemo"
1041
+ ] }),
1042
+ /* @__PURE__ */ e.jsx("p", { className: `text-sm ${s ? "text-gray-400" : "text-gray-600"}`, children: "Caches a heavy calculation result. It only re-runs if dependencies change." })
1043
+ ] }),
1044
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-6 flex-1", children: [
1045
+ /* @__PURE__ */ e.jsxs("div", { className: `p-4 rounded-xl flex items-center justify-between ${s ? "bg-gray-800" : "bg-blue-50"}`, children: [
1046
+ /* @__PURE__ */ e.jsxs("div", { children: [
1047
+ /* @__PURE__ */ e.jsx("div", { className: `text-sm font-bold ${s ? "text-gray-200" : "text-blue-900"}`, children: "Unrelated State" }),
1048
+ /* @__PURE__ */ e.jsx("div", { className: `text-xs ${s ? "text-gray-500" : "text-blue-700"}`, children: "Toggling theme triggers render." })
1049
+ ] }),
1050
+ /* @__PURE__ */ e.jsx(
1051
+ "button",
1052
+ {
1053
+ onClick: () => i(!s),
1054
+ className: `px-4 py-2 rounded-lg font-bold shadow transition-all flex items-center gap-2 ${s ? "bg-gray-700 text-white hover:bg-gray-600" : "bg-white text-blue-600 hover:bg-blue-100"}`,
1055
+ children: s ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1056
+ /* @__PURE__ */ e.jsx(Ie, { size: 16 }),
1057
+ " Light"
1058
+ ] }) : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1059
+ /* @__PURE__ */ e.jsx(P, { size: 16 }),
1060
+ " Dark"
1061
+ ] })
1062
+ }
1063
+ )
1064
+ ] }),
1065
+ /* @__PURE__ */ e.jsxs("div", { className: `flex items-center gap-3 p-3 rounded-lg border cursor-pointer ${s ? "bg-gray-800 border-gray-700" : "bg-white border-gray-100"}`, onClick: () => j(!b), children: [
1066
+ /* @__PURE__ */ e.jsx(
1067
+ "input",
1068
+ {
1069
+ type: "checkbox",
1070
+ checked: b,
1071
+ readOnly: !0,
1072
+ className: "w-5 h-5 text-blue-600 rounded focus:ring-blue-500 cursor-pointer"
1073
+ }
1074
+ ),
1075
+ /* @__PURE__ */ e.jsxs("div", { className: `text-sm font-bold select-none ${s ? "text-gray-300" : "text-gray-700"}`, children: [
1076
+ "Enable ",
1077
+ /* @__PURE__ */ e.jsx("code", { className: `px-1 rounded ${s ? "bg-gray-700 text-blue-400" : "bg-gray-100 text-blue-600"}`, children: "useMemo" })
1078
+ ] })
1079
+ ] }),
1080
+ /* @__PURE__ */ e.jsxs("div", { className: `pt-4 border-t ${s ? "border-gray-800" : "border-gray-100"}`, children: [
1081
+ /* @__PURE__ */ e.jsx("p", { className: "text-xs font-bold text-gray-400 uppercase tracking-widest mb-2", children: "EXPENSIVE CALCULATION" }),
1082
+ /* @__PURE__ */ e.jsxs("div", { className: `p-4 rounded-lg flex flex-col gap-2 ${s ? "bg-gray-800" : "bg-gray-50"}`, children: [
1083
+ /* @__PURE__ */ e.jsxs("div", { className: "flex justify-between items-center", children: [
1084
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
1085
+ /* @__PURE__ */ e.jsxs("span", { className: `text-sm ${s ? "text-gray-300" : "text-gray-600"}`, children: [
1086
+ "Input: ",
1087
+ d
1088
+ ] }),
1089
+ /* @__PURE__ */ e.jsx(
1090
+ "button",
1091
+ {
1092
+ onClick: () => x((h) => h + 1),
1093
+ className: "px-2 py-0.5 bg-gray-200 rounded text-xs hover:bg-gray-300 font-bold text-gray-700",
1094
+ children: "+"
1095
+ }
1096
+ )
1097
+ ] }),
1098
+ /* @__PURE__ */ e.jsxs("span", { className: "font-mono font-bold text-green-500", children: [
1099
+ "Result: ",
1100
+ y
1101
+ ] })
1102
+ ] }),
1103
+ /* @__PURE__ */ e.jsx("div", { className: `text-xs ${s ? "text-gray-500" : "text-gray-400"}`, children: "(Simulated 100ms lag on calculation)" }),
1104
+ !b && /* @__PURE__ */ e.jsx("div", { className: "text-xs text-red-500 bg-red-50 p-2 rounded border border-red-100 font-bold", children: "⚠️ Lagged during Theme Toggle!" })
1105
+ ] })
1106
+ ] })
1107
+ ] }),
1108
+ f && /* @__PURE__ */ e.jsx("div", { className: "mt-4 bg-gray-900 rounded-lg p-3 text-xs font-mono text-gray-300", children: `const value = useMemo(() => {
1109
+ // 🐢 Heavy Math (100ms)
1110
+ return calculate(input);
1111
+ }, [input]); // 👈 Only runs if 'input' changes` })
1112
+ ] })
1113
+ ] })
1114
+ ] });
1115
+ };
1116
+ export {
1117
+ Je as JankSimulator,
1118
+ Ge as MemoizationLab,
1119
+ Xe as RenderVisualizer,
1120
+ Ze as VirtualList
1121
+ };