tweakit 0.1.0 → 0.3.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/README.md +11 -0
- package/dist/tweaks/bezier-WUBSS72H.js +1 -0
- package/dist/tweaks/chunk-DPJ7YRTN.js +1 -0
- package/dist/tweaks/chunk-GC5PWSSX.js +1 -0
- package/dist/tweaks/colour-ZTCDZ2NN.js +1 -0
- package/dist/tweaks/core.js +1 -1
- package/dist/tweaks/gradient-54DF4XNE.js +1 -0
- package/dist/tweaks/image-IR5QKXT4.js +1 -0
- package/dist/tweaks/interval-KXOP2WEL.js +1 -0
- package/dist/tweaks/monitor-5K5VMRAL.js +2 -0
- package/dist/tweaks/plot-3WWIZG7H.js +2 -0
- package/dist/tweaks/point-RPJKP5YR.js +1 -0
- package/dist/tweaks/spring-TPWZKO7B.js +1 -0
- package/dist/tweaks/tabs-AVAHPF5A.js +1 -0
- package/dist/tweaks.css +1 -1
- package/dist/tweaks.css.d.ts +3 -0
- package/dist/tweaks.js +4 -3
- package/dist/types/tweaks/core.d.ts +4 -4
- package/dist/types/tweaks/enhance.d.ts +1 -0
- package/dist/types/tweaks/panel.d.ts +2 -0
- package/dist/types/tweaks/standalone.d.ts +3 -0
- package/dist/types/tweaks/types.d.ts +126 -2
- package/package.json +16 -8
- package/dist/tweaks/bezier-ZSQNFANZ.js +0 -1
- package/dist/tweaks/chunk-EVLD7DUH.js +0 -1
- package/dist/tweaks/chunk-GJESM23Q.js +0 -1
- package/dist/tweaks/colour-W46T6NIC.js +0 -1
- package/dist/tweaks/gradient-YEKTFEP4.js +0 -1
- package/dist/tweaks/image-VKNBVMVK.js +0 -1
- package/dist/tweaks/interval-7OUK7M7J.js +0 -1
- package/dist/tweaks/monitor-CY7CABK6.js +0 -2
- package/dist/tweaks/plot-X5IZM3QU.js +0 -2
- package/dist/tweaks/point-23BHLSGI.js +0 -1
- package/dist/tweaks/spring-Z2SKXUVV.js +0 -1
- package/dist/tweaks/tabs-CGHJ2VS2.js +0 -1
- package/dist/types/tweaks/controls/bezier.d.ts +0 -1
- package/dist/types/tweaks/controls/colour.d.ts +0 -14
- package/dist/types/tweaks/controls/gradient.d.ts +0 -1
- package/dist/types/tweaks/controls/image.d.ts +0 -1
- package/dist/types/tweaks/controls/interval.d.ts +0 -1
- package/dist/types/tweaks/controls/monitor.d.ts +0 -1
- package/dist/types/tweaks/controls/plot.d.ts +0 -1
- package/dist/types/tweaks/controls/point.d.ts +0 -1
- package/dist/types/tweaks/controls/spring.d.ts +0 -1
- package/dist/types/tweaks/controls/tabs.d.ts +0 -1
- package/dist/types/tweaks/shared.d.ts +0 -77
- package/dist/types/tweaks/single.d.ts +0 -12
- package/dist/types/wide-gamut.d.ts +0 -121
|
@@ -16,6 +16,9 @@ export type GradientInterpolation = "srgb" | "hsl" | "hwb" | "oklch" | "oklab" |
|
|
|
16
16
|
export type Get = (key: string) => unknown;
|
|
17
17
|
/** Per-control extras that can ride on any object-form value. */
|
|
18
18
|
export interface ControlOptions {
|
|
19
|
+
/** The label shown for this control, in place of the title-cased key; `""` shows no label.
|
|
20
|
+
* Honored by every verbose `{ type }` form (in a plain folder object, `label` is a child). */
|
|
21
|
+
label?: string;
|
|
19
22
|
/** Show/hide this control based on other values. */
|
|
20
23
|
render?: (get: Get) => boolean;
|
|
21
24
|
/** Grey-out + lock this control (static, or derived from other values). */
|
|
@@ -53,7 +56,6 @@ export type SchemaObject = {
|
|
|
53
56
|
} | {
|
|
54
57
|
type: "color";
|
|
55
58
|
value?: string;
|
|
56
|
-
label?: string;
|
|
57
59
|
} | {
|
|
58
60
|
type: "text";
|
|
59
61
|
value?: string;
|
|
@@ -67,10 +69,16 @@ export type SchemaObject = {
|
|
|
67
69
|
step?: number;
|
|
68
70
|
} | {
|
|
69
71
|
type: "spring";
|
|
72
|
+
mode?: "time" | "physics";
|
|
73
|
+
visualDuration?: number;
|
|
74
|
+
bounce?: number;
|
|
70
75
|
stiffness?: number;
|
|
71
76
|
damping?: number;
|
|
72
77
|
mass?: number;
|
|
73
78
|
value?: {
|
|
79
|
+
mode?: "time" | "physics";
|
|
80
|
+
visualDuration?: number;
|
|
81
|
+
bounce?: number;
|
|
74
82
|
stiffness?: number;
|
|
75
83
|
damping?: number;
|
|
76
84
|
mass?: number;
|
|
@@ -96,6 +104,7 @@ export type SchemaObject = {
|
|
|
96
104
|
stops: GradientStop[];
|
|
97
105
|
interpolation?: GradientInterpolation;
|
|
98
106
|
} | Array<GradientStop | [string, number]>;
|
|
107
|
+
stops?: Array<GradientStop | [string, number]>;
|
|
99
108
|
} | {
|
|
100
109
|
type: "plot";
|
|
101
110
|
expr?: string;
|
|
@@ -106,9 +115,10 @@ export type SchemaObject = {
|
|
|
106
115
|
yMax?: number;
|
|
107
116
|
samples?: number;
|
|
108
117
|
editable?: boolean;
|
|
118
|
+
min?: number;
|
|
119
|
+
max?: number;
|
|
109
120
|
} | {
|
|
110
121
|
type: "fpsgraph";
|
|
111
|
-
label?: string;
|
|
112
122
|
} | {
|
|
113
123
|
type: "monitor";
|
|
114
124
|
get?: () => number | string;
|
|
@@ -224,6 +234,26 @@ export interface TweaksOptions {
|
|
|
224
234
|
export type Params = Record<string, any> & {
|
|
225
235
|
_last?: string;
|
|
226
236
|
};
|
|
237
|
+
/** The whole-panel state `toJSON()` returns / `fromJSON()` accepts: every control value
|
|
238
|
+
* (nested to mirror folders/tabs) plus UI state — which folders are collapsed and which
|
|
239
|
+
* tab is active. JSON-safe; persist it however you like. Both `values` and `ui` are
|
|
240
|
+
* optional on the way in, so `fromJSON({ values })` restores values only and
|
|
241
|
+
* `fromJSON({ ui })` restores chrome only. (Panel collapse + floating position are not
|
|
242
|
+
* captured — position has its own `opts.persist` channel.) */
|
|
243
|
+
export interface PanelState {
|
|
244
|
+
/** Every control value, **nested** to mirror folders/tabs (e.g. `{ shadow: { radius: 16 } }`)
|
|
245
|
+
* — not the dotted form `set()`/`setMany()` take. `fromJSON` matches by that nested path and
|
|
246
|
+
* skips keys with no matching control. Normally you pass back what `toJSON()` produced. */
|
|
247
|
+
values?: Record<string, any>;
|
|
248
|
+
ui?: {
|
|
249
|
+
/** Folder collapse state → `true` when collapsed. Keys are the folder's path with each
|
|
250
|
+
* segment JSON-pointer-escaped (`.`→`~0`, `~`→`~1`) then joined by `.` — injective, so a
|
|
251
|
+
* literal dot in a key can't collide with the nesting separator. Treat keys as opaque. */
|
|
252
|
+
folders?: Record<string, boolean>;
|
|
253
|
+
/** Active tab → the active page's key, under the tabs control's path (escaped as above). */
|
|
254
|
+
tabs?: Record<string, string | null>;
|
|
255
|
+
};
|
|
256
|
+
}
|
|
227
257
|
/** The panel object `tweaks()` returns. */
|
|
228
258
|
export interface Panel {
|
|
229
259
|
/** The panel root element — append it to the DOM. */
|
|
@@ -238,8 +268,25 @@ export interface Panel {
|
|
|
238
268
|
* ("folder.child", "tabs.page.child"); a bare key also reaches a nested control
|
|
239
269
|
* when it's unambiguous. A key matching no control is stored on `params` as-is. */
|
|
240
270
|
set(key: string, value: unknown): void;
|
|
271
|
+
/** Set several controls at once — a flat map of keys (dotted for nested controls), e.g.
|
|
272
|
+
* `setMany({ "shadow.radius": 28, blur: 48 })`. Resolves each key like `set()`, then fires
|
|
273
|
+
* listeners + persists ONCE for the whole batch, where N separate `set()` calls would fire
|
|
274
|
+
* N times. Unknown / ambiguous / reserved keys warn and are skipped. */
|
|
275
|
+
setMany(values: Record<string, unknown>): void;
|
|
241
276
|
/** Reset every control to its default (or run `opts.onReset`). */
|
|
242
277
|
reset(): void;
|
|
278
|
+
/** Serialize the whole panel — every control value plus UI state (collapsed folders,
|
|
279
|
+
* active tabs) — to a plain JSON-safe object, independent of localStorage/presets. Hand
|
|
280
|
+
* it to your own storage: a file, a query string / share link, a server. `JSON.stringify`
|
|
281
|
+
* on the panel calls this too. Most meaningful once `ready` (lazy controls have built). */
|
|
282
|
+
toJSON(): PanelState;
|
|
283
|
+
/** Restore a panel from a `toJSON()` object: values are applied where their path still
|
|
284
|
+
* exists (missing ones skipped, like loading a preset), then folder/tab UI state. Fires
|
|
285
|
+
* listeners once. Both halves are optional — pass `{ values }` to restore values only, or
|
|
286
|
+
* `{ ui }` to restore chrome only. The value restore is undoable (one history step); the
|
|
287
|
+
* UI restore is intentionally outside undo, so a Cmd-Z reverts values without thrashing
|
|
288
|
+
* folders/tabs. */
|
|
289
|
+
fromJSON(state: PanelState): void;
|
|
243
290
|
/** Re-theme the panel live; `null` reverts to the default. */
|
|
244
291
|
setTheme(theme?: Theme | null): void;
|
|
245
292
|
/** Save the current values as a named preset (needs `opts.persist`). */
|
|
@@ -261,4 +308,81 @@ export interface Control {
|
|
|
261
308
|
el: HTMLElement;
|
|
262
309
|
set(value: unknown): void;
|
|
263
310
|
get(): unknown;
|
|
311
|
+
/** Release any loop the control owns (the monitor's poll, the FPS graph's rAF). Only
|
|
312
|
+
* the live controls supply it; the panel calls it from `destroy()`. */
|
|
313
|
+
destroy?(): void;
|
|
314
|
+
}
|
|
315
|
+
/** Options for `mountControl(host, value, opts?)` — one control, no panel. */
|
|
316
|
+
export interface MountOptions {
|
|
317
|
+
/** The key passed to `onChange` and used to derive the label when none is given (default `"value"`). */
|
|
318
|
+
key?: string;
|
|
319
|
+
/** The label shown on the control; `""` shows none (the host page already has one). Wins over
|
|
320
|
+
* the title-cased key and over a verbose form's own `label`. */
|
|
321
|
+
label?: string;
|
|
322
|
+
/** Fired with the new value whenever the control changes — by hand or through `set()`. */
|
|
323
|
+
onChange?: (value: unknown, key: string) => void;
|
|
324
|
+
}
|
|
325
|
+
/** The handle `mountControl()` returns. */
|
|
326
|
+
export interface MountedControl {
|
|
327
|
+
/** The wrapper (`.tw-control`) the control lives in, already appended to the host and
|
|
328
|
+
* stable from creation — it carries the kit's tokens, so the control renders outside a
|
|
329
|
+
* panel. On the code-split build a lazily-loaded control fills it in once `ready` resolves. */
|
|
330
|
+
el: HTMLElement;
|
|
331
|
+
/** Apply a value — the control updates AND `onChange` fires (when the value actually
|
|
332
|
+
* changed). Before `ready`, the value is queued and applied once the control builds. */
|
|
333
|
+
set(value: unknown): void;
|
|
334
|
+
/** The current value (the queued or schema value before `ready`; `undefined` for a
|
|
335
|
+
* valueless control such as a button). */
|
|
336
|
+
get(): unknown;
|
|
337
|
+
/** Remove the control from the host and release anything it owns. */
|
|
338
|
+
destroy(): void;
|
|
339
|
+
/** Resolves with this handle once the control has built — immediately on the single-file build. */
|
|
340
|
+
ready: Promise<MountedControl>;
|
|
341
|
+
}
|
|
342
|
+
/** The notations the colour picker edits in (its mode dropdown). The emitted value follows
|
|
343
|
+
* the mode: `hex` gives `#rrggbb`, the wide-gamut modes give a CSS colour like `oklch(…)`. */
|
|
344
|
+
export type ColorMode = "hex" | "srgb" | "css" | "hsl" | "hwb" | "oklch" | "oklab" | "lch" | "lab" | "p3" | "rec2020";
|
|
345
|
+
/** Options for `createColorPicker(opts?)` — the picker body alone, no trigger row. */
|
|
346
|
+
export interface ColorPickerOptions {
|
|
347
|
+
/** The colour it opens on — any CSS colour string (default `#7c5cff`). */
|
|
348
|
+
value?: string;
|
|
349
|
+
/** The notation it opens in (default `oklch`). */
|
|
350
|
+
mode?: ColorMode;
|
|
351
|
+
/** Fired with the new colour string whenever it changes — by hand or through `set()`. */
|
|
352
|
+
onChange?: (value: string) => void;
|
|
353
|
+
}
|
|
354
|
+
/** The handle `createColorPicker()` returns. Bring your own trigger: append `el` to a popover
|
|
355
|
+
* or a panel of your own; the kit owns the editor surface and the gamut math. */
|
|
356
|
+
export interface ColorPicker {
|
|
357
|
+
/** The picker's root (`.tw-color-picker`), stable from creation; it carries the kit's tokens,
|
|
358
|
+
* so the picker renders anywhere. On the code-split build the editor fills it in once the
|
|
359
|
+
* colour chunk has loaded. */
|
|
360
|
+
el: HTMLElement;
|
|
361
|
+
/** Apply a colour — the picker updates AND `onChange` fires (when the colour actually changed). */
|
|
362
|
+
set(value: string): void;
|
|
363
|
+
/** The current colour, serialized in the picker's mode. */
|
|
364
|
+
get(): string;
|
|
365
|
+
/** The current notation. */
|
|
366
|
+
mode(): ColorMode;
|
|
367
|
+
/** Switch notation — formatting only, nothing fires. */
|
|
368
|
+
setMode(mode: ColorMode): void;
|
|
369
|
+
/** Re-rasterize and re-place the thumbs. It reflows itself a frame after creation; call
|
|
370
|
+
* this when you show it later (a popover opening) or after it resizes. */
|
|
371
|
+
reflow(): void;
|
|
372
|
+
/** Remove the picker from the DOM. */
|
|
373
|
+
destroy(): void;
|
|
374
|
+
/** Resolves with this handle once the editor has built — immediately on the single-file build. */
|
|
375
|
+
ready: Promise<ColorPicker>;
|
|
376
|
+
}
|
|
377
|
+
/** `detail` of the `tw:change` event a `[data-tw]` host dispatches (bubbling) whenever its
|
|
378
|
+
* control changes — `key` is the host's `data-key` (or its label), `value` the new value,
|
|
379
|
+
* also written to the host's `data-value`. */
|
|
380
|
+
export interface TwChangeDetail {
|
|
381
|
+
key: string;
|
|
382
|
+
value: unknown;
|
|
383
|
+
}
|
|
384
|
+
declare global {
|
|
385
|
+
interface HTMLElementEventMap {
|
|
386
|
+
"tw:change": CustomEvent<TwChangeDetail>;
|
|
387
|
+
}
|
|
264
388
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tweakit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
|
+
"main": "./dist/tweaks.js",
|
|
6
|
+
"types": "./dist/types/tweaks/core.d.ts",
|
|
5
7
|
"description": "A dependency-free, code-split real-time parameter panel — sliders, toggles, a wide-gamut OKLCH colour picker, curve editors and more, from a plain schema.",
|
|
6
8
|
"license": "MIT",
|
|
7
9
|
"author": "Ryan Kiley",
|
|
@@ -30,28 +32,34 @@
|
|
|
30
32
|
"prepublishOnly": "node build.mjs && node --test \"test/*.test.mjs\"",
|
|
31
33
|
"serve": "node build.mjs && python3 -m http.server 4330 --directory dist"
|
|
32
34
|
},
|
|
33
|
-
"types": "./dist/types/tweaks/single.d.ts",
|
|
34
35
|
"exports": {
|
|
35
36
|
".": {
|
|
36
|
-
"types": "./dist/types/tweaks/
|
|
37
|
-
"import": "./dist/tweaks.js"
|
|
37
|
+
"types": "./dist/types/tweaks/core.d.ts",
|
|
38
|
+
"import": "./dist/tweaks.js",
|
|
39
|
+
"default": "./dist/tweaks.js"
|
|
38
40
|
},
|
|
39
41
|
"./core": {
|
|
40
42
|
"types": "./dist/types/tweaks/core.d.ts",
|
|
41
|
-
"import": "./dist/tweaks/core.js"
|
|
43
|
+
"import": "./dist/tweaks/core.js",
|
|
44
|
+
"default": "./dist/tweaks/core.js"
|
|
45
|
+
},
|
|
46
|
+
"./css": {
|
|
47
|
+
"types": "./dist/tweaks.css.d.ts",
|
|
48
|
+
"default": "./dist/tweaks.css"
|
|
42
49
|
},
|
|
43
|
-
"./
|
|
50
|
+
"./package.json": "./package.json"
|
|
44
51
|
},
|
|
45
52
|
"files": [
|
|
46
53
|
"dist/tweaks",
|
|
47
54
|
"dist/tweaks.js",
|
|
48
55
|
"dist/tweaks.css",
|
|
56
|
+
"dist/tweaks.css.d.ts",
|
|
49
57
|
"dist/types",
|
|
50
58
|
"THIRD-PARTY-NOTICES.md"
|
|
51
59
|
],
|
|
52
60
|
"devDependencies": {
|
|
53
61
|
"esbuild": "^0.28.0",
|
|
54
|
-
"jsdom": "^
|
|
55
|
-
"typescript": "^
|
|
62
|
+
"jsdom": "^30.1.2",
|
|
63
|
+
"typescript": "^7.0.2"
|
|
56
64
|
}
|
|
57
65
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{M as K,O,b as N,j as C,k as a,l as L,q as k,r as q,u as J}from"./chunk-GJESM23Q.js";function U(Y,M){let P=[.25,.1,.25,1],s=Array.isArray(Y.value)&&Y.value.length===4?Y.value.map(Number):P.slice();s.some(e=>!Number.isFinite(e))&&(s=P.slice());let d=-.25,A=1.25,R=A-d,l=8,B=C("div","tw-bezier"),b=C("div","tw-bezier-graph"),m=a("svg","tw-bezier-svg");m.setAttribute("preserveAspectRatio","none");let X=a("line","tw-bezier-guide"),G=a("line","tw-bezier-guide"),H=a("line","tw-bezier-diag"),W=a("line","tw-bezier-ctl"),S=a("line","tw-bezier-ctl"),I=a("path","tw-bezier-curve");m.append(X,G,H,W,S,I);let g=L("tw-bezier-handle");g.setAttribute("aria-label","Control point 1");let f=L("tw-bezier-handle");f.setAttribute("aria-label","Control point 2"),b.append(m,g,f);let T=C("div","tw-fields tw-bezier-fields");B.append(b,T);let p=0,z=0,$=e=>l+e*(p-2*l),F=e=>z-l-(e-d)/R*(z-2*l),w=(e,i,t,o,r)=>{e.setAttribute("x1",i),e.setAttribute("y1",t),e.setAttribute("x2",o),e.setAttribute("y2",r)},h=()=>{if(p=b.offsetWidth,z=b.offsetHeight,p<2)return;m.setAttribute("viewBox",`0 0 ${p} ${z}`);let[e,i,t,o]=s,r=$(0),n=F(0),c=$(1),u=F(1),y=$(e),x=F(i),v=$(t),D=F(o);w(X,l,n,p-l,n),w(G,l,u,p-l,u),w(H,r,n,c,u),w(W,r,n,y,x),w(S,c,u,v,D),I.setAttribute("d",`M${r},${n} C${y},${x} ${v},${D} ${c},${u}`),g.style.left=y+"px",g.style.top=x+"px",f.style.left=v+"px",f.style.top=D+"px"},E=[{label:"X1",i:0,lo:0,hi:1},{label:"Y1",i:1,lo:d,hi:A},{label:"X2",i:2,lo:0,hi:1},{label:"Y2",i:3,lo:d,hi:A}],Q=E.map(e=>{let i=K({label:e.label,value:s[e.i],step:.01,min:e.lo,max:e.hi},t=>{s[e.i]=t,h(),M(s.slice())});return T.append(i.el),i}),V=()=>Q.forEach((e,i)=>e.set(s[E[i].i])),j=(e,i)=>{let t=null,o=0,r=0,n=1;J(e,{onDown:c=>{c.preventDefault(),t=b.getBoundingClientRect(),o=b.offsetWidth||t.width,r=b.offsetHeight||t.height,n=t.width/o,e.classList.add("is-dragging"),e.focus({focusVisible:!1})},onMove:c=>{let u=(c.clientX-t.left)/n,y=(c.clientY-t.top)/n,x=N((u-l)/(o-2*l),0,1),v=N(d+(r-l-y)/(r-2*l)*R,d,A);s[i*2]=+x.toFixed(2),s[i*2+1]=+v.toFixed(2),h(),V(),M(s.slice())},onEnd:()=>{t=null,e.classList.remove("is-dragging")}})};return j(g,0),j(f,1),k(h),q(B,[[window,"resize"],[window,"tw-reflow"]],h),{el:B,set:e=>{if(Array.isArray(e)&&e.length===4){let i=e.map(Number);if(i.some(t=>!Number.isFinite(t)))return;s=i.map((t,o)=>N(t,E[o].lo,E[o].hi)),h(),V()}},get:()=>s.slice()}}O("cubicbezier",U);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{E as Ut,L as jt,M as qt,O as Jt,b as f,j as x,m as zt,t as Vt,v as mt,w as gt}from"./chunk-GJESM23Q.js";var N0=180/Math.PI,xt=Math.PI/180,A=(t,e)=>[t[0][0]*e[0]+t[0][1]*e[1]+t[0][2]*e[2],t[1][0]*e[0]+t[1][1]*e[1]+t[1][2]*e[2],t[2][0]*e[0]+t[2][1]*e[1]+t[2][2]*e[2]],r0=(t,e)=>{let n=[[0,0,0],[0,0,0],[0,0,0]];for(let o=0;o<3;o++)for(let s=0;s<3;s++)n[o][s]=t[o][0]*e[0][s]+t[o][1]*e[1][s]+t[o][2]*e[2][s];return n},M=t=>t==null||Number.isNaN(t)?0:t,H0=(t,e,n)=>Math.min(n,Math.max(e,t)),ft=t=>{let e=Math.abs(t);return e<=.04045?t/12.92:Math.sign(t)*((e+.055)/1.055)**2.4},q=t=>{let e=Math.abs(t);return e<=.0031308?t*12.92:Math.sign(t)*(1.055*e**(1/2.4)-.055)},kt=1.09929682680944,c0=.018053968510807,B0=t=>{let e=Math.abs(t);return e<c0*4.5?t/4.5:Math.sign(t)*((e+kt-1)/kt)**(1/.45)},Ht=t=>{let e=Math.abs(t);return e<c0?t*4.5:Math.sign(t)*(kt*e**.45-(kt-1))},l0=1/512,D0=t=>{let e=Math.abs(t);return e<=l0*16?t/16:Math.sign(t)*e**1.8},I0=t=>{let e=Math.abs(t);return e>=l0?Math.sign(t)*e**(1/1.8):16*t},Ot=[[.41239079926595934,.357584339383878,.1804807884018343],[.21263900587151027,.715168678767756,.07219231536073371],[.01933081871559182,.11919477979462598,.9505321522496607]],ot=[[3.2409699419045226,-1.537383177570094,-.4986107602930034],[-.9692436362808796,1.8759675015077202,.04155505740717559],[.05563007969699366,-.20397695888897652,1.0569715142428786]],F0=[[.4865709486482162,.26566769316909306,.19821728523436247],[.2289745640697488,.6917385218365064,.079286914093745],[0,.04511338185890264,1.043944368900976]],Bt=[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]],G0=[[.6369580483012914,.14461690358620832,.16888097516417205],[.2627002120112671,.6779980715188708,.05930171646986196],[0,.028072693049087428,1.060985057710791]],Dt=[[1.7166511879712674,-.35567078377639233,-.25336628137365974],[-.6666843518324892,1.6164812366349395,.01576854581391113],[.017639857445310783,-.042770613257808524,.9421031212354738]],P0=[[.7977604896723027,.13518583717574031,.0313493495815248],[.2880711282292934,.7118432178101014,8565396060525902e-20],[0,0,.8251046025104601]],X0=[[1.3457989731028281,-.25558010007997534,-.05110628506753401],[-.5446224939028347,1.5082327413132781,.02053603239147973],[0,0,1.2119675456389454]],i0=[[1.0479298208405488,.022946793341019088,-.05019222954313557],[.029627815688159344,.990434484573249,-.01707382502938514],[-.009243058152591178,.015055144896577895,.7518742899580008]],h0=[[.9554734527042182,-.023098536874261423,.0632593086610217],[-.028369706963208136,1.0099954580058226,.021041398966943008],[.012314001688319899,-.020507696433477912,1.3303659366080753]],Y0=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],It=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],Z0=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],y=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],dt=216/24389,st=24389/27,J=[.3457/.3585,1,(1-.3457-.3585)/.3585],U=(t,e,n)=>A(n,[e(t[0]),e(t[1]),e(t[2])]),j=(t,e,n)=>{let o=A(n,t);return[e(o[0]),e(o[1]),e(o[2])]},Qt=t=>{let e=A(y,t);return A(It,[e[0]**3,e[1]**3,e[2]**3])},t0=t=>{let e=A(Y0,t);return A(Z0,[Math.cbrt(e[0]),Math.cbrt(e[1]),Math.cbrt(e[2])])};function e0(t){let[e,n,o]=t,s=(e+16)/116,a=n/500+s,r=s-o/200,u=a**3>dt?a**3:(116*a-16)/st,i=e>st*dt?s**3:e/st,p=r**3>dt?r**3:(116*r-16)/st;return A(h0,[u*J[0],i*J[1],p*J[2]])}function n0(t){let e=A(i0,t),n=r=>r>dt?Math.cbrt(r):(st*r+16)/116,o=n(e[0]/J[0]),s=n(e[1]/J[1]),a=n(e[2]/J[2]);return[116*s-16,500*(o-s),200*(s-a)]}var wt=t=>{let e=Math.hypot(t[1],t[2]),n=Math.atan2(t[2],t[1])*N0;return n<0&&(n+=360),[t[0],e,n]},Mt=t=>[t[0],t[1]*Math.cos(t[2]*xt),t[1]*Math.sin(t[2]*xt)];function u0(t){let e=((Number.isNaN(t[0])?0:t[0])%360+360)%360,n=t[1]/100,o=t[2]/100,s=a=>{let r=(a+e/30)%12,u=n*Math.min(o,1-o);return o-u*Math.max(-1,Math.min(r-3,9-r,1))};return[s(0),s(8),s(4)]}function p0(t){let e=Math.max(...t),n=Math.min(...t),o=e-n;if(o===0)return NaN;let s;return e===t[0]?s=(t[1]-t[2])/o+(t[1]<t[2]?6:0):e===t[1]?s=(t[2]-t[0])/o+2:s=(t[0]-t[1])/o+4,s*60}function W0(t){let e=Math.max(...t),n=Math.min(...t),o=(n+e)/2,s=p0(t),a=e===n||o===0||o===1?0:(e-o)/Math.min(o,1-o);return a<0&&(s+=180,a=-a),s>=360&&(s-=360),[s,a*100,o*100]}function K0(t){let e=t[1]/100,n=t[2]/100;if(e+n>=1){let a=e/(e+n);return[a,a,a]}let o=u0([t[0],100,50]),s=1-e-n;return[o[0]*s+e,o[1]*s+e,o[2]*s+e]}var z0=t=>[p0(t),Math.min(...t)*100,(1-Math.max(...t))*100];function V0(t,e){switch(e){case"srgb":return U(t,ft,Ot);case"p3":return U(t,ft,F0);case"rec2020":return U(t,B0,G0);case"prophoto-rgb":return A(h0,U(t,D0,P0));case"oklab":return Qt(t);case"oklch":return Qt(Mt(t));case"lab":return e0(t);case"lch":return e0(Mt(t));case"hsl":return U(u0(t),ft,Ot);case"hwb":return U(K0(t),ft,Ot)}}function U0(t,e){switch(e){case"srgb":return j(t,q,ot);case"p3":return j(t,q,Bt);case"rec2020":return j(t,Ht,Dt);case"prophoto-rgb":return j(A(i0,t),I0,X0);case"oklab":return t0(t);case"oklch":return wt(t0(t));case"lab":return n0(t);case"lch":return wt(n0(t));case"hsl":return W0(j(t,q,ot));case"hwb":return z0(j(t,q,ot))}}function w(t,e,n){return e===n?[t[0],t[1],t[2]]:e==="oklch"&&n==="oklab"?Mt(t):e==="oklab"&&n==="oklch"?wt(t):e==="lch"&&n==="lab"?Mt(t):e==="lab"&&n==="lch"?wt(t):U0(V0(t,e),n)}var Q=75e-6;function Nt(t,e){return w(t,"oklch",e).every(o=>o>=-Q&&o<=1+Q)}var s0=t=>t.map(e=>Math.min(1,Math.max(0,e))),o0=(t,e)=>Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]);function $t(t,e){if(Nt(t,e))return w(t,"oklch",e);let n=t[0];if(n>=1)return[1,1,1];if(n<=0)return[0,0,0];let o=.02,s=1e-4,a=[t[0],t[1],t[2]],r=0,u=t[1],i=!0,p=s0(w(a,"oklch",e));if(o0(w(p,e,"oklab"),w(t,"oklch","oklab"))<o)return p;for(;u-r>s;){let h=(r+u)/2;a[1]=h;let g=w(a,"oklch",e);if(i&&g.every(_=>_>=-Q&&_<=1+Q)){r=h;continue}p=s0(g);let b=o0(w(p,e,"oklab"),w(a,"oklch","oklab"));if(b<o){if(o-b<s)return p;i=!1,r=h}else u=h}return p}function at(t,e){let n=t*xt,o=Math.cos(n),s=Math.sin(n),a=o*y[0][1]+s*y[0][2],r=o*y[1][1]+s*y[1][2],u=o*y[2][1]+s*y[2][2],i=r0(e==="p3"?Bt:e==="rec2020"?Dt:ot,It),p=e==="rec2020"?Ht:q,h=-Q,g=1+Q;return(b,_)=>{let T=b+_*a,E=b+_*r,k=b+_*u,$=T**3,v=E**3,H=k**3,C=p(i[0][0]*$+i[0][1]*v+i[0][2]*H);if(C<h||C>g)return!1;let tt=p(i[1][0]*$+i[1][1]*v+i[1][2]*H);if(tt<h||tt>g)return!1;let Z=p(i[2][0]*$+i[2][1]*v+i[2][2]*H);return Z>=h&&Z<=g}}function b0(t,e){let n=t*xt,o=Math.cos(n),s=Math.sin(n),a=o*y[0][1]+s*y[0][2],r=o*y[1][1]+s*y[1][2],u=o*y[2][1]+s*y[2][2],i=r0(e==="p3"?Bt:e==="rec2020"?Dt:ot,It),p=e==="rec2020"?Ht:q;return(h,g,b)=>{let _=h+g*a,T=h+g*r,E=h+g*u,k=_**3,$=T**3,v=E**3;b[0]=p(i[0][0]*k+i[0][1]*$+i[0][2]*v),b[1]=p(i[1][0]*k+i[1][1]*$+i[1][2]*v),b[2]=p(i[2][0]*k+i[2][1]*$+i[2][2]*v)}}function rt(t,e,n=.5){if(!t(e,0))return 0;let o=0;for(let s=0;s<16;s++){let a=(o+n)/2;t(e,a)?o=a:n=a}return o}var X=t=>Math.round(Math.min(1,Math.max(0,t))*255).toString(16).padStart(2,"0"),j0=t=>`#${X(t[0])}${X(t[1])}${X(t[2])}`,_t=(t,e,n)=>j0($t([t,e,n],"srgb"));function m0(t){let e=String(t).replace("#","").trim();if(e.length===3&&(e=e.split("").map(o=>o+o).join("")),e.length<6)return[.7,.1,280];let n=[parseInt(e.slice(0,2),16)/255,parseInt(e.slice(2,4),16)/255,parseInt(e.slice(4,6),16)/255];return w(n,"srgb","oklch").map(M)}var vt=["hex","srgb","css","hsl","hwb","oklch","oklab","lch","lab","p3","rec2020"],g0={hex:"HEX",srgb:"RGB",css:"CSS",hsl:"HSL",hwb:"HWB",oklch:"OKLCH",oklab:"OKLab",lch:"LCH",lab:"Lab",p3:"P3",rec2020:"Rec2020"},f0=["srgb","css","hsl","hwb","hex"],Ft=t=>!f0.includes(t),d0=t=>t==="hex"||t==="css"?"srgb":t,q0={hex:"srgb",srgb:"srgb",css:"srgb",hsl:"hsl",hwb:"hwb",oklch:"oklch",oklab:"oklab",lch:"lch",lab:"lab",p3:"display-p3",rec2020:"rec2020"},he=t=>q0[t]||"oklch",J0={srgb:"srgb",hsl:"hsl",hwb:"hwb",oklch:"oklch",oklab:"oklab",lch:"lch",lab:"lab","display-p3":"p3",rec2020:"rec2020"},ue=t=>J0[t]||"oklch",Q0=.5,ct={oklch:[{k:"L",min:0,max:100,step:1,scale:100},{k:"C",min:0,max:Q0,step:.01,scale:1},{k:"H",min:0,max:360,step:1,scale:1}],oklab:[{k:"L",min:0,max:100,step:1,scale:100},{k:"a",min:-.4,max:.4,step:.01,scale:1},{k:"b",min:-.4,max:.4,step:.01,scale:1}],lch:[{k:"L",min:0,max:100,step:1,scale:1},{k:"C",min:0,max:150,step:1,scale:1},{k:"H",min:0,max:360,step:1,scale:1}],lab:[{k:"L",min:0,max:100,step:1,scale:1},{k:"a",min:-125,max:125,step:1,scale:1},{k:"b",min:-125,max:125,step:1,scale:1}],srgb:[{k:"R",min:0,max:255,step:1,scale:255},{k:"G",min:0,max:255,step:1,scale:255},{k:"B",min:0,max:255,step:1,scale:255}],css:[{k:"R",min:0,max:255,step:1,scale:255},{k:"G",min:0,max:255,step:1,scale:255},{k:"B",min:0,max:255,step:1,scale:255}],hsl:[{k:"H",min:0,max:360,step:1,scale:1},{k:"S",min:0,max:100,step:1,scale:1},{k:"L",min:0,max:100,step:1,scale:1}],hwb:[{k:"H",min:0,max:360,step:1,scale:1},{k:"W",min:0,max:100,step:1,scale:1},{k:"B",min:0,max:100,step:1,scale:1}],p3:[{k:"R",min:0,max:1,step:.01,scale:1},{k:"G",min:0,max:1,step:.01,scale:1},{k:"B",min:0,max:1,step:.01,scale:1}],rec2020:[{k:"R",min:0,max:1,step:.01,scale:1},{k:"G",min:0,max:1,step:.01,scale:1},{k:"B",min:0,max:1,step:.01,scale:1}]},te=t=>t>=1?0:t>=.1?1:t>=.01?2:3,x0=(t,e,n)=>e==="oklch"?[t[0],t[1],t[2]]:f0.includes(n)?e==="srgb"?$t(t,"srgb"):w($t(t,"srgb"),"srgb",e):w(t,"oklch",e);function Ct(t,e){let n=x0(t,d0(e),e);return ct[e].map((o,s)=>{let a=M(n[s])*o.scale;return H0(Math.abs(a)<.5*o.step?0:a,o.min,o.max)})}function k0(t,e,n,o){let s=d0(e),a=x0(t,s,e).map(M);a[n]=o/ct[e][n].scale;let r=w(a,s,"oklch");return[M(r[0]),M(r[1]),M(r[2])]}function w0(t,e){if(!Ft(e))return"sRGB";let n=$t(t,"srgb");return Math.max(...n)<.03||Math.min(...n)>.97||Nt(t,"srgb")?"sRGB":Nt(t,"p3")?"P3":"wide"}function Gt(t,e){if(e==="hex")return _t(t[0],t[1],t[2]);let n=ct[e],o=Ct(t,e),s=a=>o[a].toFixed(te(n[a].step));return e==="css"?`${s(0)}, ${s(1)}, ${s(2)}`:e==="oklch"||e==="oklab"||e==="lch"||e==="lab"?`${s(0)}% ${s(1)} ${s(2)}`:e==="hsl"||e==="hwb"?`${s(0)} ${s(1)}% ${s(2)}%`:`${s(0)} ${s(1)} ${s(2)}`}var a0=(t,e)=>e==="hex"?t:e==="srgb"?`rgb(${t})`:e==="css"?`rgba(${t}, 1)`:e==="hsl"?`hsl(${t})`:e==="hwb"?`hwb(${t})`:e==="p3"?`color(display-p3 ${t})`:e==="rec2020"?`color(rec2020 ${t})`:`${e}(${t})`;function M0(t,e,n){let o=M(n);if(e==="hex")return _t(t[0],t[1],t[2])+(o<.999?X(o):"");let s=Gt(t,e);if(o>=.999)return a0(s,e);let a=+o.toFixed(3);return e==="css"?`rgba(${s}, ${a})`:a0(`${s} / ${a}`,e)}var _0=(()=>{try{return document.createElement("canvas").getContext("2d",{colorSpace:"display-p3"})?.getContextAttributes?.().colorSpace==="display-p3"}catch{return!1}})(),Pt=_0?{colorSpace:"display-p3"}:{},ee=_0?"p3":"srgb",Et=(t,e)=>{let n=t.length-1,o=Math.max(0,Math.min(n,e*n)),s=Math.floor(o),a=o-s;return t[s]*(1-a)+t[Math.min(s+1,n)]*a},ne=(t,e)=>{let n=at(t,e),o=new Float64Array(128);for(let s=0;s<128;s++)o[s]=rt(n,s/127);return o},se="repeating-conic-gradient(#6b6b6b 0% 25%, #9a9a9a 0% 50%) 0 0 / 8px 8px",oe={srgb:"srgb","display-p3":"p3",rec2020:"rec2020","prophoto-rgb":"prophoto-rgb"},$0=t=>{let e=/^([+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?)(deg|grad|rad|turn)$/i.exec(t);if(!e)return M(parseFloat(t));let n=parseFloat(e[1]);return e[2].toLowerCase()==="turn"?n*360:e[2].toLowerCase()==="grad"?n*.9:e[2].toLowerCase()==="rad"?n*180/Math.PI:n};function Y(t){if(t=String(t??"").trim(),/^#?([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)){let u=t.replace("#",""),i=1;u.length===4?(i=parseInt(u[3]+u[3],16)/255,u=u.slice(0,3)):u.length===8&&(i=parseInt(u.slice(6,8),16)/255,u=u.slice(0,6));let[p,h,g]=m0("#"+u);return[p,h,g,i]}let e=t.match(/^(oklch|oklab|lch|lab|color)\(\s*([^)]*?)\s*\)$/i);if(e){let u=e[1].toLowerCase(),[i,p]=e[2].split("/").map(k=>k.trim()),h=i.split(/\s+/).filter(Boolean),g=u;if(u==="color"&&(g=oe[(h[0]||"").toLowerCase()],h=h.slice(1),!g))return[.7,.1,280,1];let b=(k,$=1)=>!k||k==="none"?0:M(parseFloat(k))*(/%$/.test(k)?$:1),_=p?f(b(p,.01),0,1):1,T=u==="lab"?[f(b(h[0]),0,100),b(h[1],1.25),b(h[2],1.25)]:u==="lch"?[f(b(h[0]),0,100),Math.max(0,b(h[1],1.5)),$0(h[2]||"0")]:u==="color"?[b(h[0],.01),b(h[1],.01),b(h[2],.01)]:u==="oklab"?[f(b(h[0],.01),0,1),b(h[1],.004),b(h[2],.004)]:[f(b(h[0],.01),0,1),Math.max(0,b(h[1],.004)),$0(h[2]||"0")],E=g==="oklch"?T:w(T,g,"oklch");return[M(E[0]),M(E[1]),(M(E[2])%360+360)%360,_]}let n=Y._c2d||(Y._c2d=document.createElement("canvas").getContext("2d"));n.fillStyle="#000",n.fillStyle=t;let o=n.fillStyle;if(o[0]==="#")return Y(o);let s=o.match(/^rgba?\(([^)]*)\)/i),a=((s?s[1]:"").match(/-?[\d.]+(?:e[+-]?\d+)?/gi)||[0,0,0]).map(Number),r=w([a[0]/255,a[1]/255,a[2]/255],"srgb","oklch");return[M(r[0]),M(r[1]),M(r[2]),a[3]!=null?f(M(a[3]),0,1):1]}function ae(t,e){let[n,o,s,a]=Y(t.value||"#7c5cff"),r=vt.includes(t.mode)?t.mode:"oklch",u=NaN,i=null,p=[],h=NaN,g="",b=()=>M0([n,o,s],r,a),_=x("div","tw-color-body"),T=x("div","tw-wg-area"),E=document.createElement("canvas");E.className="tw-wg-canvas";let k=x("div","tw-wg-thumb");T.append(E,k);let $=x("div","tw-wg-hue"),v=document.createElement("canvas");v.className="tw-wg-hue-canvas";let H=x("div","tw-wg-hue-thumb");$.append(v,H);let C=x("div","tw-wg-alpha"),tt=x("div","tw-wg-alpha-grad"),Z=x("div","tw-wg-hue-thumb");C.append(tt,Z),C.tabIndex=0,C.setAttribute("role","slider"),C.setAttribute("aria-label","Alpha"),C.setAttribute("aria-valuemin","0"),C.setAttribute("aria-valuemax","1");let Xt=x("div","tw-color-mode-row"),B=x("select","tw-color-mode");B.setAttribute("aria-label","Color mode"),vt.forEach(c=>{let l=document.createElement("option");l.value=c,l.textContent=g0[c],B.append(l)}),B.value=r;let Yt=x("span","tw-color-gamut");Xt.append(B,Yt);let D=x("div","tw-color-channels");_.append(T,$,C,Xt,D);let L=E.getContext("2d",Pt),Zt=v.getContext("2d"),W=document.createElement("canvas"),v0=W.getContext("2d",Pt),Lt=null,lt=()=>{let c=T.getBoundingClientRect(),l=Math.round(c.width),m=Math.round(c.height);if(l<2)return;let d=window.devicePixelRatio||1,S=Ft(r)?"p3":"srgb",O=ne(s,S);i=O;let N=Math.round(l*d),ht=Math.round(m*d),F=Math.max(1,Math.round(N/4)),z=Math.max(1,Math.round(ht/4));(W.width!==F||W.height!==z)&&(W.width=F,W.height=z,Lt=new ImageData(F,z,Pt));let ut=Lt.data,S0=z>1?1/(z-1):0,R0=F>1?1/(F-1):0,A0=b0(s,ee),pt=[0,0,0];for(let G=0;G<z;G++){let bt=1-G*S0,St=Et(O,bt);for(let P=0;P<F;P++){A0(bt,P*R0*St,pt);let V=(G*F+P)*4;ut[V]=Math.round(f(pt[0],0,1)*255),ut[V+1]=Math.round(f(pt[1],0,1)*255),ut[V+2]=Math.round(f(pt[2],0,1)*255),ut[V+3]=255}}if(v0.putImageData(Lt,0,0),E.width=N,E.height=ht,L.imageSmoothingEnabled=!0,L.drawImage(W,0,0,N,ht),S!=="srgb"){let G=(bt,St,P,V)=>{let O0=at(s,bt),Rt=[];for(let R=0;R<=100;R++){let nt=R/100,At=Et(O,nt);if(At<=0)continue;let Kt=rt(O0,nt,At);Kt<=0||Rt.push([Math.min(Kt/At*N,N-P*d/2),(1-nt)*ht])}Rt.length<2||(L.save(),L.strokeStyle=St,L.lineWidth=P*d,L.lineJoin=L.lineCap="round",L.setLineDash(V.map(R=>R*d)),L.beginPath(),Rt.forEach((R,nt)=>nt?L.lineTo(R[0],R[1]):L.moveTo(R[0],R[1])),L.stroke(),L.restore())};G("srgb","rgba(255,255,255,0.7)",1.5,[]),G("p3","rgba(255,255,255,0.4)",1,[3,3])}u=s},yt=.7,Wt=0,C0=()=>{let c=$.getBoundingClientRect(),l=Math.max(1,Math.round(c.width)),m=Math.max(1,Math.round(c.height));if(l<2||l===Wt&&v.width===l)return;Wt=l,v.width=l,v.height=m;let d=yt;for(let S=0;S<l;S++){let O=S/(l-1)*360,N=w([d,rt(at(O,"srgb"),d),O],"oklch","srgb");Zt.fillStyle=`rgb(${f(N[0]*255,0,255)|0},${f(N[1]*255,0,255)|0},${f(N[2]*255,0,255)|0})`,Zt.fillRect(S,0,1,m)}},I=()=>{let c=i?Et(i,n):.4,l=d=>`${f(d,0,1)*100}%`,m=(d,S)=>{let O=f(d,0,1);return`calc(${O*100}% + ${(.5-O)*S}px)`};if(k.style.left=l(c>0?o/c:0),k.style.top=l(1-n),H.style.left=m(s/360,16),Z.style.left=m(a,16),C.setAttribute("aria-valuenow",String(+a.toFixed(2))),tt.style.background=`linear-gradient(to right, oklch(${n} ${o} ${s} / 0), oklch(${n} ${o} ${s}))`,k.style.background=`oklch(${n} ${o} ${s})`,Z.style.background=`linear-gradient(oklch(${n} ${o} ${s} / ${a}), oklch(${n} ${o} ${s} / ${a})), var(--tw-dropdown-bg)`,s!==h){let d=w([yt,rt(at(s,"srgb"),yt),s],"oklch","srgb");g=`rgb(${f(d[0]*255,0,255)|0} ${f(d[1]*255,0,255)|0} ${f(d[2]*255,0,255)|0})`,h=s}H.style.background=g},et=()=>{if(Yt.textContent=w0([n,o,s],r),r==="hex"){let c=D.querySelector(".tw-color-chan-input");c&&document.activeElement!==c&&(c.value=_t(n,o,s)+(a<.999?X(a):""))}else{let c=Ct([n,o,s],r);p.forEach((l,m)=>{l.el.contains(document.activeElement)||l.set(c[m])})}},E0=()=>{C0(),lt(),I()},K=()=>e(b()),it=c=>{c&&s!==u&<(),I(),et()},Tt=()=>{if(D.replaceChildren(),p=[],r==="hex"){D.classList.add("tw-color-channels--hex");let c=x("div","tw-color-chan"),l=x("input","tw-color-chan-input");l.type="text",l.spellcheck=!1,l.setAttribute("aria-label","Hex color"),Vt(l),l.addEventListener("change",()=>{let m=l.value.trim();/^#?([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(m)&&([n,o,s,a]=Y(m),it(!0),K())}),l.addEventListener("keydown",m=>{m.key==="Enter"&&l.blur()}),c.append(zt("span","tw-color-chan-label","HEX"),l),D.append(c)}else{D.classList.remove("tw-color-channels--hex");let c=Ct([n,o,s],r);ct[r].forEach((l,m)=>{let d=qt({label:l.k,value:c[m],min:l.min,max:l.max,step:l.step},S=>{[n,o,s]=k0([n,o,s],r,m,f(S,l.min,l.max)),it(!0),K()});p.push(d),D.append(d.el)})}et()},L0=c=>gt(c,T);mt(T,c=>{let[l,m]=L0(c);n=1-m,o=l*(i?Et(i,n):.4),I(),et(),K()});let y0=c=>gt(c,$)[0]*360;mt($,c=>{s=y0(c),it(!0),K()});let T0=c=>gt(c,C)[0];return mt(C,c=>{a=T0(c),I(),et(),K()}),C.addEventListener("keydown",c=>{let l=c.shiftKey?.1:.01,m=a;switch(c.key){case"ArrowRight":case"ArrowUp":m+=l;break;case"ArrowLeft":case"ArrowDown":m-=l;break;case"Home":m=0;break;case"End":m=1;break;default:return}c.preventDefault(),a=f(m,0,1),I(),et(),K()}),B.addEventListener("change",()=>{r=B.value,Tt(),lt(),I(),t.onMode&&t.onMode()}),Tt(),{el:_,set:c=>{let l=document.activeElement;l&&_.contains(l)&&l.blur(),[n,o,s,a]=Y(c),it(!0)},get:()=>b(),mode:()=>r,setMode:c=>{c===r||!vt.includes(c)||(r=c,B.value=c,Tt(),lt(),I())},reflow:E0,swatchCss:()=>`linear-gradient(oklch(${n} ${o} ${s} / ${a}), oklch(${n} ${o} ${s} / ${a})), ${se}`,valueText:()=>Gt([n,o,s],r)+(a<.999?r==="hex"?X(a):` / ${+a.toFixed(2)}`:"")}}function re(t,e){let{root:n,trigger:o,right:s}=jt("tw-color",t.label||"Colour"),a=x("span","tw-trigger-chip tw-color-swatch"),r=x("span","tw-trigger-value");s.append(a,r);let u=x("div","tw-color-pop"),i=()=>{a.style.background=p.swatchCss(),r.textContent=p.valueText()},p=ae({value:t.value,onMode:()=>i()},h=>{i(),e(h)});return u.append(p.el),n.append(u),Ut(n,o,u,{width:240,fallbackH:340,gap:6,onOpen:p.reflow,onReflow:p.reflow}),i(),{el:n,set:h=>{p.set(h),i()},get:()=>p.get()}}var ge=(t,e,n,o)=>o<.999?`oklch(${+t.toFixed(4)} ${+e.toFixed(4)} ${+n.toFixed(2)} / ${+o.toFixed(3)})`:`oklch(${+t.toFixed(4)} ${+e.toFixed(4)} ${+n.toFixed(2)})`;Jt("color",re);export{he as a,ue as b,se as c,Y as d,ae as e,ge as f};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var S=t=>t.replace(/([A-Z])/g," $1").replace(/^./,e=>e.toUpperCase()).trim(),g=(t,e,n)=>Math.min(n,Math.max(e,t)),K=t=>typeof t=="string"&&(/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t.trim())||/^(oklch|oklab|rgba?|hsla?|hwb|lab|lch|color)\(/i.test(t.trim())),E=t=>{let e=String(t),n=/e-(\d+)$/i.exec(e);if(n)return Number(n[1])+(e.split("e")[0].split(".")[1]||"").length;let r=e.indexOf(".");return r===-1?0:e.length-r-1},F=(t,e,n)=>n>0?Number((e+Math.round((t-e)/n)*n).toFixed(E(n))):t,U=(t,e)=>{let n=e-t;return n<=1?.01:n<=10?.1:n<=100?1:10},Y=t=>t>=0?[0,t<=1?1:t*3||100]:[t>=-1?-1:t*3,0],L=t=>t==null?void 0:typeof t=="object"?t.value:t,I=t=>t==null?"":typeof t=="string"?S(t):typeof t=="object"?t.label??String(t.value):String(t),P="http://www.w3.org/2000/svg",p=(t,e,n)=>{let r=document.createElement(t);return e&&(r.className=e),n!=null&&(r.innerHTML=n),r},Z=(t,e)=>{let n=document.createElementNS(P,t);return e&&n.setAttribute("class",e),n},A=(t,e)=>{let n=p("button",t,e);return n.type="button",n},k=(t,e,n)=>{let r=p(t,e);return r.textContent=n,r},J=(t,e)=>getComputedStyle(t).getPropertyValue(e).trim(),Q=t=>{let e=getComputedStyle(t),n=r=>e.getPropertyValue(r).trim();return n("--tw-accent")||n("--tw-text-primary")||"#fff"},N=t=>["pointerdown","pointermove","pointerup"].forEach(e=>t.addEventListener(e,n=>n.stopPropagation())),tt=t=>{requestAnimationFrame(t),document.fonts&&document.fonts.ready&&document.fonts.ready.then(t)},et=(t,e,n)=>{let r=o=>{if(!t.isConnected)return i();n(o)},i=()=>e.forEach(([o,s])=>o.removeEventListener(s,r));return e.forEach(([o,s])=>o.addEventListener(s,r)),i},nt=(t,e)=>{t.addEventListener("pointerenter",()=>{t.classList.add("is-hover"),e&&e()}),t.addEventListener("pointerleave",()=>t.classList.remove("is-hover"))},y=!1;typeof document<"u"&&(document.addEventListener("pointerdown",()=>{y=!0},!0),document.addEventListener("keydown",()=>{y=!1},!0));var R=t=>{t.addEventListener("focus",()=>t.classList.toggle("tw-focus-quiet",y)),t.addEventListener("blur",()=>t.classList.remove("tw-focus-quiet"))};function T(t,{onDown:e,onMove:n,onEnd:r}={}){let i=null,o=s=>{i===null||s.pointerId!==i||(i=null,r&&r(s))};t.addEventListener("pointerdown",s=>{if(!(s.button!==0||i!==null)){i=s.pointerId;try{t.setPointerCapture(s.pointerId)}catch{}e&&e(s)}}),t.addEventListener("pointermove",s=>{if(s.pointerId===i){if(s.buttons===0)return o(s);n&&n(s)}}),t.addEventListener("pointerup",o),t.addEventListener("pointercancel",o),t.addEventListener("lostpointercapture",o)}var rt=(t,e)=>T(t,{onDown:n=>{t.classList.add("is-grabbing"),e(n)},onMove:e,onEnd:()=>t.classList.remove("is-grabbing")}),it=(t,e)=>{let n=e.getBoundingClientRect();return[g((t.clientX-n.left)/n.width,0,1),g((t.clientY-n.top)/n.height,0,1)]},ot=(t,e,n=1/0)=>{let r=t.getBoundingClientRect(),i=Math.min(window.devicePixelRatio||1,n);return t.width=r.width*i,t.height=r.height*i,e.setTransform(i,0,0,i,0,0),[r.width,r.height]},O=(t,e,{width:n,fallbackH:r=300,gap:i=6,align:o="start",prefer:s="below"}={})=>{let c=t.getBoundingClientRect();n==="match"&&(e.style.width=c.width+"px");let w=n==="match"?c.width:e.offsetWidth||n||0,m=o==="end"?c.right-w:o==="center"?c.left+c.width/2-w/2:c.left;e.style.left=Math.max(8,Math.min(m,window.innerWidth-w-8))+"px";let f=e.offsetHeight||r,d=window.innerHeight-c.bottom,l=c.top,a=f+12,u=d>=a,v=l>=a,M=(s==="above"?v||!u&&l>=d:!u&&(v||l>d))?c.top-f-i:c.bottom+i;e.style.top=g(M,i,window.innerHeight-f-i)+"px"},$={accent:"--tw-accent",onAccent:"--tw-on-accent",base:"--tw-base",dropdownBg:"--tw-dropdown-bg",surface:"--tw-surface",surfaceHover:"--tw-surface-hover",surfaceActive:"--tw-surface-active",border:"--tw-border",borderHover:"--tw-border-hover",selection:"--tw-selection",title:"--tw-text-root",section:"--tw-text-section",text:"--tw-text-primary",label:"--tw-text-label",textMuted:"--tw-text-secondary",textFaint:"--tw-text-tertiary",focus:"--tw-text-focus",success:"--tw-success",danger:"--tw-danger",shadow:"--tw-shadow-dropdown",shadowPanel:"--tw-shadow-panel",shadowPanelLifted:"--tw-shadow-panel-lifted",font:"--tw-font-sans",fontMono:"--tw-font-mono",radius:"--tw-radius",density:"--tw-row-height"},H=new Set(["radius","density"]),b=t=>(t/=255,t<=.03928?t/12.92:((t+.055)/1.055)**2.4),X=t=>{t=String(t).trim();let e=/^#([0-9a-f]{3})$/i.exec(t);if(e)return e[1].split("").map(n=>parseInt(n+n,16));if(e=/^#([0-9a-f]{6})$/i.exec(t),e)return[0,2,4].map(n=>parseInt(e[1].slice(n,n+2),16));if(e=/^rgba?\(([^)]+)\)/i.exec(t),e){let n=e[1].split(/[\s,/]+/).filter(Boolean).map(parseFloat);return[n[0],n[1],n[2]]}return null},_=t=>{let e=X(t);if(!e||e.some(r=>!Number.isFinite(r)))return"#ffffff";let n=.2126*b(e[0])+.7152*b(e[1])+.0722*b(e[2]);return 1.05/(n+.05)>=(n+.05)/.0571?"#ffffff":"#161616"},st=t=>{if(!t||typeof t!="object")return null;let e={};for(let[n,r]of Object.entries(t)){if(n.startsWith("--")){e[n]=String(r);continue}let i=$[n];i&&(e[i]=H.has(n)&&typeof r=="number"?`${r}px`:String(r))}return e["--tw-accent"]&&!e["--tw-on-accent"]&&(e["--tw-on-accent"]=_(e["--tw-accent"])),Object.keys(e).length?e:null},V=(t,e)=>{if(t){if(t._twAppliedVars)for(let n of t._twAppliedVars)t.style.removeProperty(n);if(t._twAppliedVars=e?Object.keys(e):null,e)for(let n in e)t.style.setProperty(n,e[n])}},B=(t,e)=>{let n=e?.closest('[data-tw-scheme="light"]')?"light":e?.closest('[data-tw-scheme="dark"]')?"dark":null;n?t.setAttribute("data-tw-scheme",n):t.removeAttribute("data-tw-scheme")},x=(t,e)=>{V(t,e?.closest(".tw-panel")?._twTheme),B(t,e)},h=null,at=()=>{h&&h()};function ct(t,e,n,r={}){let i=!1,o=null;n.classList.add("tw-portal"),n.addEventListener("pointerdown",u=>e.closest(".tw-panel")?._twEditPointer?.(u),!0),N(n);let s=()=>O(e,n,{width:r.width,fallbackH:r.fallbackH,gap:r.gap,align:r.align}),c=()=>{if(i){if(!t.isConnected)return a();s(),r.onReflow&&r.onReflow()}},w=u=>{!t.contains(u.target)&&!n.contains(u.target)&&a()},m=u=>{u.key==="Escape"&&i&&(a(),e.focus())},f=()=>x(n,t),d=u=>{u.every(v=>v.target===n)||f()},l=()=>{h&&h!==a&&h(),h=a,i=!0,t.classList.add("is-open"),e.setAttribute("aria-expanded","true"),document.body.appendChild(n),x(n,t),window.addEventListener("tw-retheme",f),typeof MutationObserver=="function"&&(o=new MutationObserver(d),o.observe(document.documentElement,{subtree:!0,attributes:!0,attributeFilter:["data-tw-scheme"]})),s(),requestAnimationFrame(()=>{n.classList.add("is-open"),r.onOpen&&r.onOpen(),s()}),requestAnimationFrame(function u(){if(i){if(!t.isConnected)return a();requestAnimationFrame(u)}}),setTimeout(()=>document.addEventListener("pointerdown",w,!0),0),document.addEventListener("keydown",m),window.addEventListener("scroll",c,!0),window.addEventListener("resize",c)},a=()=>{h===a&&(h=null),n.contains(document.activeElement)&&e.focus(),i=!1,t.classList.remove("is-open"),n.classList.remove("is-open"),e.setAttribute("aria-expanded","false"),document.removeEventListener("pointerdown",w,!0),document.removeEventListener("keydown",m),window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c),window.removeEventListener("tw-retheme",f),o&&(o.disconnect(),o=null),setTimeout(()=>{i||n.remove()},200)};return e.addEventListener("click",()=>i?a():l()),{open:l,close:a,isOpen:()=>i,reflow:c}}var lt=(t,e)=>{if(t=t.toLowerCase(),t.includes(e))return!0;if(e.length<3)return!1;let n=e.length,r=t.length,i=new Array(r+1).fill(0);for(let o=1;o<=n;o++){let s=[o];for(let c=1;c<=r;c++)s[c]=Math.min(i[c]+1,s[c-1]+1,i[c-1]+(e[o-1]===t[c-1]?0:1));i=s}return Math.min(...i)<=(e.length<6?1:2)},j=typeof matchMedia=="function"?matchMedia("(prefers-reduced-motion: reduce)"):{matches:!1},z=(t,e)=>{j.matches||typeof t.animate!="function"||(t.style.transformOrigin=e>0?"left center":"right center",t.animate([{transform:"scaleX(1)"},{transform:"scaleX(1.18)"},{transform:"scaleX(1)"}],{duration:300,easing:"cubic-bezier(0.22, 1, 0.36, 1)"}))},dt=(t,e,n)=>{let r=t.querySelector('[data-active="true"]');if(!r)return;let i=r.offsetLeft,o=r.offsetWidth,s=parseFloat(e.style.left);e.style.left=i+"px",e.style.width=o+"px",n&&Number.isFinite(s)&&s!==i&&z(e,i>s?1:-1)},ut=(t,e)=>t.forEach(n=>{let r=n.dataset.value===String(e);n.dataset.active=String(r),n.setAttribute("aria-checked",String(r)),n.tabIndex=r?0:-1}),ft=(t,e,n)=>{let r=A(t);return r.setAttribute("role","radio"),r.textContent=I(e),r.dataset.value=L(e),r._twVal=L(e),r.addEventListener("click",()=>n(r._twVal)),r},wt=(t,e,n,r=0)=>{switch(t){case"ArrowRight":return(e+1)%n;case"ArrowLeft":return(e-1+n)%n;case"ArrowDown":return r<0?-1:r?e+r<n?e+r:e:(e+1)%n;case"ArrowUp":return r<0?-1:r?e-r>=0?e-r:e:(e-1+n)%n;case"Home":return 0;case"End":return n-1}return-1},mt=(t,e)=>{let n=p("div",t),r=A("tw-trigger");r.setAttribute("aria-expanded","false");let i=p("span","tw-trigger-right");return r.append(k("span","tw-trigger-label",e),i),n.append(r),{root:n,trigger:r,right:i}};function D(){let t=null,e=0,n=0,r=0;return{show(i,o,s){t=p("div","tw-grab-guide tw-portal"),t.innerHTML='<span class="tw-grab-line"></span><span class="tw-grab-dot"></span><span class="tw-grab-arrow"></span><span class="tw-grab-bubble"></span>',e=o,n=i,r=s??i,t.children[1].style.cssText=`left:${i}px;top:${e}px`,document.body.appendChild(t)},move(i,o){t&&(t.children[0].style.cssText=`left:${Math.min(n,i)}px;top:${e}px;width:${Math.abs(i-n)}px`,t.children[2].style.cssText=`left:${i}px;top:${e}px;transform:translate(-50%,-50%) scaleX(${i>=n?1:-1})`,t.children[3].style.cssText=`left:${r}px;top:${e-16}px`,t.children[3].textContent=o)},hide(){t&&(t.remove(),t=null)}}}function G(t,e,n,r,i,o){let s=0,c=0,w=null,m=1,f=D();t.addEventListener("pointerdown",l=>{if(l.button!==0||w!==null)return;l.preventDefault(),w=l.pointerId,s=l.clientX,c=r(),m=1,t.classList.add("is-dragging");try{t.setPointerCapture(l.pointerId)}catch{}let a=e.getBoundingClientRect();f.show(l.clientX,a.top+a.height/2,a.left+a.width/2),f.move(l.clientX,o())}),t.addEventListener("pointermove",l=>{if(l.pointerId!==w)return;if(l.buttons===0){d(l);return}let a=l.shiftKey?10:l.altKey?.1:1;a!==m&&(m=a,s=l.clientX,c=r()),i(c+(l.clientX-s)*n*a),f.move(l.clientX,o())});let d=l=>{w===null||l.pointerId!==w||(w=null,t.classList.remove("is-dragging"),f.hide())};t.addEventListener("pointerup",d),t.addEventListener("pointercancel",d),t.addEventListener("lostpointercapture",d)}function pt(t,e){let n=Number.isFinite(+t.step)&&+t.step>0?+t.step:1,r=E(n),i=+t.min,o=+t.max;if(Number.isFinite(i)&&Number.isFinite(o)&&o<i){let a=i;i=o,o=a}let s=a=>{let u=F(a,Number.isFinite(i)?i:0,n);return t.soft||(Number.isFinite(i)&&(u=Math.max(i,u)),Number.isFinite(o)&&(u=Math.min(o,u))),u},c=s(Number.isFinite(+t.value)?+t.value:0),w=p("div",t.row?"tw-row":"tw-field"),m=p("div","tw-num-wrap"),f=p("span","tw-num-grab",W);f.setAttribute("aria-hidden","true"),f.title="Drag to adjust";let d=p("input","tw-num");d.type="text",d.inputMode="decimal",d.setAttribute("aria-label",t.label),d.value=c.toFixed(r),R(d),m.append(f,d),w.append(k("span",t.row?"tw-row-label":"tw-field-label",t.label),m);let l=(a,u=!0)=>{a=+a,Number.isFinite(a)&&(c=s(a),d.value=c.toFixed(r),u&&e&&e(c))};return d.addEventListener("change",()=>{let a=parseFloat(d.value);l(isNaN(a)?c:a)}),d.addEventListener("keydown",a=>{a.key==="Enter"&&d.blur()}),G(f,m,n,()=>c,l,()=>d.value),{el:w,set:a=>l(a,!1),get:()=>c}}var W='<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true"><path d="M6 4v8M10 4v8"/></svg>',ht=t=>({el:t,set:()=>{},get:()=>{}}),C={},vt=(t,e)=>{C[t]=e},bt=t=>C[t];export{S as a,g as b,K as c,E as d,F as e,U as f,Y as g,L as h,I as i,p as j,Z as k,A as l,k as m,J as n,Q as o,N as p,tt as q,et as r,nt as s,R as t,T as u,rt as v,it as w,ot as x,O as y,st as z,V as A,B,x as C,at as D,ct as E,lt as F,j as G,dt as H,ut as I,ft as J,wt as K,mt as L,pt as M,ht as N,vt as O,bt as P};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as a,d as b,e as c,f as d}from"./chunk-EVLD7DUH.js";import"./chunk-GJESM23Q.js";export{a as CHECKER,c as createPickerBody,d as oklchStr,b as parseColor};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as Y,b as P,c as z,d as L,e as U,f as V}from"./chunk-EVLD7DUH.js";import{E as j,L as K,O as N,b as p,j as g,l as D,u as X}from"./chunk-GJESM23Q.js";var st='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg>',q=a=>a&&!Array.isArray(a)&&typeof a.interpolation=="string"?a.interpolation:null;function J(a){let C=[{color:"oklch(0.72 0.19 25)",pos:0},{color:"oklch(0.72 0.16 280)",pos:1}],s=((Array.isArray(a)?a:a&&Array.isArray(a.stops)?a.stops:null)||[]).map(c=>Array.isArray(c)?{color:String(c[0]),pos:p(+c[1]||0,0,1)}:c&&typeof c=="object"?{color:String(c.color),pos:p(+c.pos||0,0,1)}:null).filter(Boolean);return s.length>=2?s:C}function lt(a,C){let l=J(a.value),s=l[0],{root:c,trigger:Q,right:T}=K("tw-gradient",a.label||"Gradient"),R=g("span","tw-gradient-count"),F=g("span","tw-trigger-chip tw-gradient-preview");T.append(R,F);let k=g("div","tw-color-pop tw-gradient-pop"),H=g("div","tw-gradient-bar-row"),E=g("div","tw-gradient-bar"),I=g("div","tw-gradient-grad"),h=g("div","tw-gradient-rail");E.append(I,h);let m=D("tw-gradient-add",st);m.title="Add a stop after the selected one",m.setAttribute("aria-label","Add a colour stop after the selected one"),H.append(E,m);let v=()=>[...l].sort((t,o)=>t.pos-o.pos),W=()=>v().map(t=>`${t.color} ${(t.pos*100).toFixed(1)}%`).join(", "),O=()=>Y(u.mode()),Z=()=>`linear-gradient(in ${O()} to right, ${W()})`,d=()=>{let t=Z();I.style.background=t,F.style.background=`${t}, ${z}`},A=()=>{R.textContent=`${l.length} stop${l.length===1?"":"s"}`},_=()=>({stops:v().map(t=>({color:t.color,pos:+t.pos.toFixed(4)})),interpolation:O()}),w=()=>C(_()),x=t=>[...h.children].find(o=>o._stop===t),u=U({value:s.color,mode:P(q(a.value)||"oklab"),onMode:()=>{d(),w()}},t=>{s.color=t,x(s)?.style.setProperty("--stop",t),d(),w()});k.append(H,u.el),c.append(k);let tt=()=>{for(let t of h.children)t.dataset.sel=String(t._stop===s)},M=()=>{h.replaceChildren();for(let t of l){let o=D("tw-gradient-stop");o._stop=t,o.style.left=t.pos*100+"%",o.style.setProperty("--stop",t.color),o.dataset.sel=String(t===s),o.setAttribute("aria-label","Colour stop");let n=!1;X(o,{onDown:e=>{e.preventDefault(),e.stopPropagation(),o.focus({focusVisible:!1}),$(t,!1),n=!1},onMove:e=>{let r=h.getBoundingClientRect();t.pos=p((e.clientX-r.left)/(r.width||1),0,1),o.style.left=t.pos*100+"%",d(),w(),n=l.length>2&&(e.clientY<r.top-24||e.clientY>r.bottom+24),o.dataset.removing=String(n)},onEnd:()=>{n?B(t):o.dataset.removing="false"}}),o.addEventListener("dblclick",e=>{e.preventDefault(),B(t)}),o.addEventListener("keydown",e=>{let r=e.key==="ArrowLeft"?-1:e.key==="ArrowRight"?1:0;r&&(e.preventDefault(),t.pos=p(t.pos+r*(e.shiftKey?.1:.01),0,1),o.style.left=t.pos*100+"%",d(),w())}),h.append(o)}},$=(t,o)=>{t!==s&&(u.set(t.color),s=t),o?M():tt()},ot=t=>{let o=h.getBoundingClientRect();return p((t-o.left)/(o.width||1),0,1)},et=t=>{let o=v(),n=o[0],e=o[o.length-1];for(let f=0;f<o.length-1;f++)if(t>=o[f].pos&&t<=o[f+1].pos){n=o[f],e=o[f+1];break}let r=e.pos>n.pos?p((t-n.pos)/(e.pos-n.pos),0,1):0,i=L(n.color),y=L(e.color),S=f=>f[1]<1e-4,b=y[2]-i[2];b>180?b-=360:b<-180&&(b+=360),(S(i)||S(y))&&(b=0);let nt=(((S(i)&&!S(y)?y[2]:i[2])+b*r)%360+360)%360;return V(i[0]+(y[0]-i[0])*r,i[1]+(y[1]-i[1])*r,nt,i[3]+(y[3]-i[3])*r)},B=t=>{if(l.length<=2)return;let o=l.indexOf(t);if(o<0)return;l.splice(o,1);let n=s===t?l[Math.max(0,o-1)]:s;d(),$(n,!0),A(),w(),x(s)?.focus()},G=t=>{let o={color:et(t),pos:p(t,0,1)};return l.push(o),d(),$(o,!0),A(),w(),o},rt=()=>{let t=v(),o=t.indexOf(s);o<0&&(o=0);let n=o<t.length-1?(t[o].pos+t[o+1].pos)/2:o>0?(t[o-1].pos+t[o].pos)/2:p(t[o].pos+.1,0,1);G(n)};return m.addEventListener("click",t=>{t.stopPropagation(),rt()}),E.addEventListener("dblclick",t=>{t.target.closest(".tw-gradient-stop")||(t.preventDefault(),G(ot(t.clientX)))}),k.tabIndex=-1,k.addEventListener("keydown",t=>{(t.key==="Delete"||t.key==="Backspace")&&!/^(input|textarea|select)$/i.test(t.target.tagName)&&l.length>2&&(t.preventDefault(),B(s))}),j(c,Q,k,{width:260,fallbackH:392,gap:6,onOpen:()=>u.reflow(),onReflow:()=>u.reflow()}),M(),d(),A(),{el:c,set:t=>{let o=q(t);o&&u.setMode(P(o));let n=J(t).sort((e,r)=>e.pos-r.pos);if(n.length===l.length)v().forEach((e,r)=>{e.color=n[r].color,e.pos=n[r].pos;let i=x(e);i&&(i.style.left=e.pos*100+"%",i.style.setProperty("--stop",e.color))});else{let e=s.pos;l=n,s=l.reduce((r,i)=>Math.abs(i.pos-e)<Math.abs(r.pos-e)?i:r,l[0]),M()}d(),A(),u.set(s.color)},get:()=>_()}}N("gradient",lt);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{O as f,j as s,l as g,m as u}from"./chunk-GJESM23Q.js";function m(o,v){let t=o.value||"",a=s("div","tw-row tw-image-row"),n=g("tw-image-drop");n.setAttribute("aria-label",`${o.label}: choose an image`);let d=s("span","tw-image-thumb"),c=s("span","tw-image-text");n.append(d,c);let r=s("input","tw-image-input");r.type="file",r.accept="image/*",a.append(u("span","tw-row-label",o.label),n,r);let i=()=>{n.dataset.set=t?"true":"false",d.style.backgroundImage=t?`url("${t}")`:"",c.textContent=t?"Replace":"Drop or choose"},p=e=>{if(!e||!e.type.startsWith("image/"))return;let l=new FileReader;l.onload=()=>{t=String(l.result),i(),v(t)},l.readAsDataURL(e)};return n.addEventListener("click",()=>r.click()),r.addEventListener("change",()=>{r.files[0]&&p(r.files[0])}),a.addEventListener("dragover",e=>{e.preventDefault(),a.dataset.over="true"}),a.addEventListener("dragleave",()=>{a.dataset.over="false"}),a.addEventListener("drop",e=>{e.preventDefault(),a.dataset.over="false",e.dataTransfer.files[0]&&p(e.dataTransfer.files[0])}),i(),{el:a,set:e=>{t=e||"",i()},get:()=>t}}f("image",m);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{O as G,b as c,d as z,e as B,f as O,j as m,m as T,q as U,r as V,s as j}from"./chunk-GJESM23Q.js";function tt(d,J){let M=d.label,i=+d.min,n=+d.max,f=+d.step,x=+(d.value&&d.value[0]),L=+(d.value&&d.value[1]);if(Number.isFinite(i)||(i=Number.isFinite(x)?x:0),Number.isFinite(n)||(n=Number.isFinite(L)?L:1),n<i){let t=i;i=n,n=t}(!(f>0)||f>n-i)&&(f=O(i,n));let I=z(f),w=t=>B(t,i,f),s=c(w(Number.isFinite(x)?x:i),i,n),r=c(w(Number.isFinite(L)?L:n),i,n);if(s>r){let t=s;s=r,r=t}let g=m("div","tw-slider-wrap"),l=m("div","tw-slider tw-interval"),k=m("div","tw-slider-fill"),p=m("div","tw-slider-handle"),v=m("div","tw-slider-handle"),N=T("span","tw-slider-label",M),y=m("span","tw-slider-value");l.append(k,p,v,N,y),g.append(l),[["minimum",p],["maximum",v]].forEach(([t,e])=>{e.tabIndex=0,e.setAttribute("role","slider"),e.setAttribute("aria-label",`${M} ${t}`),e.setAttribute("aria-valuemin",String(i)),e.setAttribute("aria-valuemax",String(n))});let A=t=>(t-i)/(n-i||1)*100,b=()=>{let t=A(s),e=A(r);k.style.left=t+"%",k.style.width=Math.max(0,e-t)+"%",p.style.left=`clamp(5px, calc(${t}% - 1.5px), calc(100% - 9px))`,v.style.left=`clamp(5px, calc(${e}% - 1.5px), calc(100% - 9px))`,y.textContent=`${s.toFixed(I)} \u2013 ${r.toFixed(I)}`,p.setAttribute("aria-valuenow",String(s)),v.setAttribute("aria-valuenow",String(r));let a=g.offsetWidth;if(a){let o=N.offsetLeft,Y=o+N.offsetWidth,D=y.offsetLeft,Z=D+y.offsetWidth,X=_=>{let K=_/100*a,P=K-1.5,q=K+1.5;return P<Y&&q>o||P<Z&&q>D};p.classList.toggle("is-dodge",X(A(s))),v.classList.toggle("is-dodge",X(A(r)))}};b();let S=()=>J([s,r]),W=t=>{s=c(Math.min(w(t),r),i,n),b()},$=t=>{r=c(Math.max(w(t),s),i,n),b()},u=null,C=1,h=null,E=null,Q=t=>{let e=g.offsetWidth||u.width,a=c((t-u.left)/C/e,0,1);return c(i+a*(n-i),i,n)},R=t=>{let e=Q(t);h||(h=e<s?"lo":e>r?"hi":Math.abs(e-s)<=Math.abs(e-r)?"lo":"hi"),h==="lo"?W(e):$(e),S()};l.addEventListener("pointerdown",t=>{if(!(t.button!==0||u)){t.preventDefault();try{t.target.setPointerCapture(t.pointerId)}catch{}E=t.pointerId,u=g.getBoundingClientRect(),C=u.width/(g.offsetWidth||u.width),l.classList.add("is-active","is-dragging"),h=null,R(t.clientX),(h==="lo"?p:v).focus({focusVisible:!1})}}),l.addEventListener("pointermove",t=>{if(!(!u||t.pointerId!==E)){if(t.buttons===0){F();return}R(t.clientX)}});let F=t=>{t&&t.pointerId!==E||(u=null,h=null,E=null,l.classList.remove("is-active","is-dragging"))};l.addEventListener("pointerup",F),l.addEventListener("pointercancel",F),l.addEventListener("lostpointercapture",F),j(l,b),U(b),V(l,[[window,"resize"],[window,"tw-reflow"]],b);let H=t=>e=>{let a=e.shiftKey?10:1,o=t==="lo"?s:r;switch(e.key){case"ArrowRight":case"ArrowUp":o+=f*a;break;case"ArrowLeft":case"ArrowDown":o-=f*a;break;case"Home":o=t==="lo"?i:s;break;case"End":o=t==="lo"?r:n;break;default:return}e.preventDefault(),t==="lo"?W(o):$(o),S()};return p.addEventListener("keydown",H("lo")),v.addEventListener("keydown",H("hi")),{el:g,set:t=>{if(Array.isArray(t)){let e=+t[0],a=+t[1];if(!Number.isFinite(e)||!Number.isFinite(a))return;s=c(w(Math.min(e,a)),i,n),r=c(w(Math.max(e,a)),i,n),b()}},get:()=>[s,r]}}G("interval",tt);
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{N as M,O as P,b as R,j as I,m as L,o as q,x as S}from"./chunk-GJESM23Q.js";function J(t){let N=I("div","tw-fps"),k=L("span","tw-fps-val","\u2014"),d=document.createElement("canvas");d.className="tw-fps-canvas",N.append(L("span","tw-fps-label",t.label||"FPS"),k,d);let s=d.getContext("2d"),m=80,i=new Array(m).fill(0),C=120,w=0,r=0,b=0,v=0,E=0,y=!1,a=()=>{[v,E]=S(d,s,2)},l=()=>{if(v){s.clearRect(0,0,v,E),s.strokeStyle=q(N),s.lineWidth=1.5,s.lineJoin="round",s.beginPath();for(let o=0;o<m;o++){let u=i[(w+o)%m],h=o/(m-1)*v,g=E-Math.min(u/C,1)*E;o?s.lineTo(h,g):s.moveTo(h,g)}s.stroke()}},p=o=>{if(!d.isConnected){if(y){window.removeEventListener("resize",a),window.removeEventListener("tw-reflow",a),b=0;return}r=0,b=requestAnimationFrame(p);return}if(y||(y=!0,a()),r){let u=1e3/(o-r);i[w]=u,w=(w+1)%m,k.textContent=Math.round(u),l()}r=o,b=requestAnimationFrame(p)};return requestAnimationFrame(()=>{a(),b=requestAnimationFrame(p)}),window.addEventListener("resize",a),window.addEventListener("tw-reflow",a),M(N)}function W(t){let N=typeof t.get=="function"?t.get:()=>t.value,k=Math.max(30,Number.isFinite(+t.interval)?+t.interval:200),d;try{d=N()}catch{}let s=typeof d=="number",m=t.view==="graph"||s&&t.graph!==!1&&t.view!=="text"&&t.rows==null,i=I("div","tw-fps tw-monitor"),C=L("span","tw-fps-val","\u2014");i.append(L("span","tw-fps-label",t.label||"Monitor"),C);let w=0,r=()=>{},b=!1,v=e=>typeof e=="number"?Number.isInteger(e)?String(e):e.toFixed(t.decimals??2):String(e),E=()=>{w&&clearInterval(w),w=0,window.removeEventListener("resize",r),window.removeEventListener("tw-reflow",r)},y=e=>{w=setInterval(()=>{if(!i.isConnected){b&&E();return}b=!0;let c;try{c=N()}catch{return}e(c)},k)};if(!m&&t.rows){C.remove();let e=Math.max(1,Math.floor(+t.rows)||1),c=I("pre","tw-monitor-buffer");c.style.setProperty("--tw-monitor-rows",e),i.append(c);let F=[];return y(z=>{for(F.push(v(z));F.length>e;)F.shift();c.textContent=F.join(`
|
|
2
|
-
`)}),M(i)}if(!m)return y(e=>{C.textContent=v(e)}),M(i);let a=document.createElement("canvas");a.className="tw-fps-canvas",i.append(a);let l=a.getContext("2d"),p=80,o=new Array(p).fill(NaN),u=0,h=0,g=0;r=()=>{[h,g]=S(a,l,2)};let T=()=>{if(h||r(),!h)return;let e=t.min,c=t.max;if(e==null||c==null){let n=1/0,f=-1/0;for(let x of o)Number.isNaN(x)||(x<n&&(n=x),x>f&&(f=x));n===1/0?(n=0,f=1):n===f&&(n-=.5,f+=.5);let A=(f-n)*.1;e==null&&(e=n-A),c==null&&(c=f+A)}let F=c-e||1;l.clearRect(0,0,h,g),l.strokeStyle=q(i),l.lineWidth=1.5,l.lineJoin="round",l.beginPath();let z=!1;for(let n=0;n<p;n++){let f=o[(u+n)%p];if(Number.isNaN(f))continue;let A=n/(p-1)*h,x=g-R((f-e)/F,0,1)*g;z?l.lineTo(A,x):(l.moveTo(A,x),z=!0)}l.stroke()};return y(e=>{typeof e=="number"&&(o[u]=e,u=(u+1)%p,C.textContent=v(e),T())}),requestAnimationFrame(()=>{r(),T()}),window.addEventListener("resize",r),window.addEventListener("tw-reflow",r),M(i)}P("fpsgraph",J);P("monitor",W);
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{O as Z,b as $,j as m,k as P,m as B,q as H,r as Y}from"./chunk-GJESM23Q.js";var W=Object.assign(Object.create(null),{sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,atan2:Math.atan2,sinh:Math.sinh,cosh:Math.cosh,tanh:Math.tanh,sqrt:Math.sqrt,cbrt:Math.cbrt,abs:Math.abs,exp:Math.exp,log:Math.log,ln:Math.log,log10:Math.log10,log2:Math.log2,floor:Math.floor,ceil:Math.ceil,round:Math.round,sign:Math.sign,trunc:Math.trunc,min:Math.min,max:Math.max,pow:Math.pow,hypot:Math.hypot,mod:(i,f)=>i%f,clamp:(i,f,o)=>Math.min(Math.max(i,f),o)}),D=Object.assign(Object.create(null),{pi:Math.PI,e:Math.E,tau:Math.PI*2,phi:(1+Math.sqrt(5))/2});function j(i){if(typeof i!="string"||!i.trim()||i.length>512)return null;let f=i,o=[],p=/\d*\.?\d+(?:[eE][+-]?\d+)?/y,x=/[A-Za-z_]\w*/y,u=0;for(;u<f.length;){let t=f[u];if(t===" "||t===" "||t===`
|
|
2
|
-
`){u++;continue}if(t>="0"&&t<="9"||t==="."&&f[u+1]>="0"&&f[u+1]<="9"){p.lastIndex=u;let n=p.exec(f);if(!n||n.index!==u)return null;o.push({t:"num",v:parseFloat(n[0])}),u=p.lastIndex;continue}if(t>="A"&&t<="Z"||t>="a"&&t<="z"||t==="_"){x.lastIndex=u;let n=x.exec(f);o.push({t:"id",v:n[0]}),u=x.lastIndex;continue}if(t==="*"&&f[u+1]==="*"){o.push({t:"op",v:"^"}),u+=2;continue}if("+-*/%^".includes(t)){o.push({t:"op",v:t}),u++;continue}if(t==="("){o.push({t:"lp"}),u++;continue}if(t===")"){o.push({t:"rp"}),u++;continue}if(t===","){o.push({t:"comma"}),u++;continue}return null}if(!o.length)return null;let b=0,e=()=>o[b],c=t=>{let n=o[b];return!n||t&&n.t!==t?null:(b++,n)},d=()=>{let t=g();if(!t)return null;for(;e()&&e().t==="op"&&(e().v==="+"||e().v==="-");){let n=c("op").v,l=g();if(!l)return null;let a=t;t=n==="+"?s=>a(s)+l(s):s=>a(s)-l(s)}return t},g=()=>{let t=M();if(!t)return null;for(;e()&&e().t==="op"&&(e().v==="*"||e().v==="/"||e().v==="%");){let n=c("op").v,l=M();if(!l)return null;let a=t;t=n==="*"?s=>a(s)*l(s):n==="/"?s=>a(s)/l(s):s=>a(s)%l(s)}return t},M=()=>{if(e()&&e().t==="op"&&(e().v==="-"||e().v==="+")){let t=c("op").v,n=M();return n?t==="-"?l=>-n(l):n:null}return k()},k=()=>{let t=I();if(!t)return null;if(e()&&e().t==="op"&&e().v==="^"){c("op");let n=M();return n?l=>Math.pow(t(l),n(l)):null}return t},I=()=>{let t=e();if(!t)return null;if(t.t==="num")return c("num"),()=>t.v;if(t.t==="lp"){c("lp");let n=d();return!n||!c("rp")?null:n}if(t.t==="id"){c("id");let n=t.v.toLowerCase();if(e()&&e().t==="lp"){let l=W[n];if(!l)return null;c("lp");let a=[];if(e()&&e().t!=="rp")do{let s=d();if(!s)return null;a.push(s)}while(c("comma"));return c("rp")?s=>l(...a.map(y=>y(s))):null}if(n==="x")return l=>l;if(n in D){let l=D[n];return()=>l}return null}return null},N=d();return N&&b===o.length?N:null}function X(i,f){let o=Number(i.xMin),p=Number(i.xMax);if(Number.isFinite(o)||(o=-10),Number.isFinite(p)||(p=10),p<o){let a=o;o=p,p=a}p===o&&(o-=1,p+=1);let x=Math.max(2,Math.min(4096,i.samples|0||256)),u=Number.isFinite(i.yMin)&&Number.isFinite(i.yMax)&&+i.yMax>+i.yMin,b=i.editable!==!1&&!i.fn,e=i.expr!=null?String(i.expr):"",c=typeof i.fn=="function"?i.fn:j(e),d=m("div","tw-plot");i.label&&d.append(B("div","tw-plot-label",i.label));let g=m("div","tw-plot-graph"),M=P("svg","tw-plot-svg");M.setAttribute("preserveAspectRatio","none");let k=P("line","tw-plot-axis"),I=P("line","tw-plot-axis"),N=P("path","tw-plot-curve");M.append(k,I,N),g.append(M),d.append(g);let t=null;if(b){let a=m("div","tw-plot-field");t=m("input","tw-plot-input"),t.type="text",t.value=e,t.spellcheck=!1,t.autocapitalize="off",t.autocomplete="off",t.setAttribute("aria-label",`${i.label||"Plot"} \u2014 expression in x`),a.append(m("span","tw-plot-fx","y ="),t),d.append(a)}let n=6,l=()=>{let a=g.getBoundingClientRect(),s=a.width,y=a.height;if(s<2)return;M.setAttribute("viewBox",`0 0 ${s} ${y}`);let O=typeof c=="function",z=[],v=1/0,A=-1/0;if(O)for(let r=0;r<x;r++){let w=o+(p-o)*(r/(x-1)),h;try{h=c(w)}catch{h=NaN}z.push(h),Number.isFinite(h)&&(h<v&&(v=h),h>A&&(A=h))}let F=i.yMin,L=i.yMax;if(!u)if(!Number.isFinite(v)||v===A){let r=Number.isFinite(v)?v:0;F=r-1,L=r+1}else{let r=(A-v)*.12;F=v-r,L=A+r}let C=r=>n+(r-o)/(p-o)*(s-2*n),E=r=>y-n-(r-F)/(L-F)*(y-2*n),_=(r,w,h,S,U,T)=>{r.style.display=T?"":"none",T&&(r.setAttribute("x1",w),r.setAttribute("y1",h),r.setAttribute("x2",S),r.setAttribute("y2",U))};_(k,n,E(0),s-n,E(0),F<=0&&L>=0),_(I,C(0),n,C(0),y-n,o<=0&&p>=0);let q="",R=!1;if(O)for(let r=0;r<x;r++){let w=z[r];if(!Number.isFinite(w)){R=!1;continue}let h=C(o+(p-o)*(r/(x-1))),S=$(E(w),-1e4,1e4);q+=(R?"L":"M")+h.toFixed(1)+","+S.toFixed(1)+" ",R=!0}N.setAttribute("d",q),d.classList.toggle("is-invalid",b&&!O)};return b&&t.addEventListener("input",()=>{e=t.value;let a=j(e);a?c=a:c=null,l(),f(e)}),H(l),Y(d,[[window,"resize"],[window,"tw-reflow"]],l),{el:d,get:()=>e,set:a=>{a!=null&&(e=String(a),t&&(t.value=e),i.fn||(c=j(e)),l())}}}Z("plot",X);export{j as compileExpr};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{E as L,L as V,M as q,O as z,b as R,d as X,j as n,k as P,v as $,w as B}from"./chunk-GJESM23Q.js";function N(s,G){let o=s.components,{root:m,trigger:I,right:J}=V("tw-point",s.label||"Point"),Y=n("span","tw-trigger-value"),k=n("div","tw-trigger-chip tw-point-preview"),l=n("div","tw-point-preview-dot");k.append(l),J.append(Y,k);let b=n("div","tw-color-pop tw-point-pop"),h=n("div","tw-point-body");b.append(h);let E=s.pad!==!1&&o.length>=2,O=o[0],S=o[1],x=O?.min??-1,A=O?.max??1,f=S?.min??-1,F=S?.max??1,w=(t,e,c)=>c>e?R((t-e)/(c-e),0,1):.5,r=null,u=null,a=null;if(E){r=n("div","tw-pad"),u=n("div","tw-pad-thumb");let t=P("svg","tw-pad-line");t.setAttribute("viewBox","0 0 100 100"),t.setAttribute("preserveAspectRatio","none"),a=P("line"),t.append(a);let e=w(0,f,F);a.setAttribute("x1",w(0,x,A)*100),a.setAttribute("y1",(s.invertY?e:1-e)*100),r.append(n("div","tw-pad-axis tw-pad-axis-x"),n("div","tw-pad-axis tw-pad-axis-y"),t,u),h.append(r)}let D=n("div","tw-fields");h.append(D);let d=()=>{C(),M()},T=()=>G(j()),i=o.map(t=>{let e=q({label:t.label,value:t.value??0,step:t.step??1,min:t.min,max:t.max},()=>{d(),T()});return D.append(e.el),e}),j=()=>Object.fromEntries(o.map((t,e)=>[t.key,i[e].get()])),K=(t,e)=>(+t).toFixed(X(e??1)),M=()=>{Y.textContent=o.map((t,e)=>K(i[e].get(),t.step)).join(", ")},C=()=>{l.style.left="50%",l.style.top="50%"};if(E){let e=p=>`calc(${(p*100).toFixed(2)}% + ${((.5-p)*5).toFixed(2)}px)`;C=()=>{let p=w(i[0].get(),x,A),y=w(i[1].get(),f,F),v=s.invertY?y:1-y,g=p*100,H=v*100;u.style.left=g+"%",u.style.top=H+"%",l.style.left=e(p),l.style.top=e(v),a.setAttribute("x2",g),a.setAttribute("y2",H)},$(r,p=>{let[y,v]=B(p,r),g=s.invertY?v:1-v;i[0].set(x+y*(A-x)),i[1].set(f+g*(F-f)),d(),T()})}return m.append(b),L(m,I,b,{width:216,fallbackH:240,gap:6,onOpen:d}),d(),{el:m,set:t=>{t&&o.forEach((e,c)=>{t[e.key]!=null&&i[c].set(t[e.key])}),d()},get:j}}z("point",N);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{M as y,O as L,b as R,j as T,n as q,o as A,q as P,r as X,u as _}from"./chunk-GJESM23Q.js";function F(v,b,m,w=64){let e=Math.sqrt(v/m),s=b/(2*Math.sqrt(v*m)),c=Math.min(2.2,9/Math.max(s*e,.5)),d=[];for(let p=0;p<w;p++){let t=p/(w-1)*c,o;if(s<1-1e-4){let l=e*Math.sqrt(1-s*s);o=1-Math.exp(-s*e*t)*(Math.cos(l*t)+s*e/l*Math.sin(l*t))}else if(s<=1+1e-4)o=1-Math.exp(-e*t)*(1+e*t);else{let l=Math.sqrt(s*s-1),r=e*(s+l),g=e*(s-l);o=1-(r*Math.exp(-g*t)-g*Math.exp(-r*t))/(r-g)}d.push(o)}return d}function I(v,b){let m=(n,a,i)=>Number.isFinite(+n)?Math.max(a,+n):i,w=n=>({stiffness:m(n.stiffness,1,300),damping:m(n.damping,.5,26),mass:m(n.mass,.1,1)}),e=w({stiffness:300,damping:26,mass:1,...v.value||{}}),s=T("div","tw-spring"),c=T("div","tw-spring-viz"),d=document.createElement("canvas");d.className="tw-spring-canvas",c.append(d);let p=T("div","tw-fields");s.append(c,p);let t=d.getContext("2d"),o=()=>{let n=c.getBoundingClientRect(),a=Math.max(1,Math.round(n.width)),i=Math.max(1,Math.round(n.height));if(a<2)return;let f=window.devicePixelRatio||1;d.width=a*f,d.height=i*f,t.setTransform(f,0,0,f,0,0),t.clearRect(0,0,a,i);let C=F(e.stiffness,e.damping,e.mass,Math.max(160,Math.round(a*f))),B=Math.max(1.05,...C),M=6,E=u=>M+u/(C.length-1)*(a-2*M),x=u=>i-M-u/B*(i-2*M);t.strokeStyle=q(s,"--tw-surface-active")||"rgba(255,255,255,0.1)",t.lineWidth=1,t.beginPath(),t.moveTo(M,x(1)),t.lineTo(a-M,x(1)),t.stroke(),t.strokeStyle=A(s),t.lineWidth=1.5,t.lineJoin=t.lineCap="round",t.beginPath(),C.forEach((u,S)=>S?t.lineTo(E(S),x(u)):t.moveTo(E(S),x(u))),t.stroke()},l=()=>b({...e}),r={};[["stiffness","Stiffness",1],["damping","Damping",.5],["mass","Mass",.1]].forEach(([n,a,i])=>{r[n]=y({label:a,value:e[n],step:i,min:i},f=>{e[n]=f,o(),l()}),p.append(r[n].el)});let g=1,N=500,z=1,k=40,h=null,D=n=>{if(!h)return;let a=R((n.clientX-h.left)/h.width,0,1),i=R((n.clientY-h.top)/h.height,0,1);e.stiffness=Math.round(g+a*(N-g)),e.damping=Math.round((z+i*(k-z))*10)/10,r.stiffness.set(e.stiffness),r.damping.set(e.damping),o(),l()};return _(c,{onDown:n=>{n.preventDefault(),h=c.getBoundingClientRect(),c.classList.add("is-dragging"),D(n)},onMove:D,onEnd:()=>{h=null,c.classList.remove("is-dragging")}}),P(o),X(d,[[window,"resize"],[window,"tw-reflow"],[matchMedia("(prefers-color-scheme: dark)"),"change"],[window,"tw-retheme"]],o),{el:s,set:n=>{e=w({...e,...n||{}}),Object.keys(r).forEach(a=>r[a].set(e[a])),o()},get:()=>({...e})}}L("spring",I);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{H as w,K as f,O as A,j as r,m as v,q as g}from"./chunk-GJESM23Q.js";var S=0;function $(m){let o=`tw-tabs-${++S}`,b=r("div","tw-tabs"),s=r("div","tw-tabs-bar");s.setAttribute("role","tablist");let c=r("div","tw-tabs-pill");s.append(c);let l=r("div","tw-tabs-pages"),d=[],i=m.pages.map((a,e)=>{let t=v("button","tw-tabs-tab",a.title);t.type="button",t.setAttribute("role","tab"),t.dataset.active=String(e===0),t.setAttribute("aria-selected",String(e===0)),t.tabIndex=e===0?0:-1,t.id=`${o}-tab-${e}`,t.setAttribute("aria-controls",`${o}-page-${e}`);let n=r("div","tw-tabs-page tw-controls");return n.dataset.active=String(e===0),n.setAttribute("role","tabpanel"),n.id=`${o}-page-${e}`,n.setAttribute("aria-labelledby",t.id),d.push(n),l.append(n),t.addEventListener("click",()=>u(e)),s.append(t),t});b.append(s,l);let p=a=>w(s,c,a);function u(a){i.forEach((e,t)=>{e.dataset.active=String(t===a),e.setAttribute("aria-selected",String(t===a)),e.tabIndex=t===a?0:-1}),d.forEach((e,t)=>e.dataset.active=String(t===a)),p(!0),requestAnimationFrame(()=>window.dispatchEvent(new Event("tw-reflow")))}return s.addEventListener("keydown",a=>{let e=i.findIndex(n=>n.dataset.active==="true");if(e<0)return;let t=f(a.key,e,i.length,-1);t<0||(a.preventDefault(),u(t),i[t].focus())}),g(p),{el:b,bodies:d}}A("tabs",$);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
declare const CHECKER = "repeating-conic-gradient(#6b6b6b 0% 25%, #9a9a9a 0% 50%) 0 0 / 8px 8px";
|
|
2
|
-
declare function parseColor(str: any): any[];
|
|
3
|
-
declare function createPickerBody(meta: any, onChange: any): {
|
|
4
|
-
el: any;
|
|
5
|
-
set: (v: any) => void;
|
|
6
|
-
get: () => any;
|
|
7
|
-
mode: () => any;
|
|
8
|
-
setMode: (m: any) => void;
|
|
9
|
-
reflow: () => void;
|
|
10
|
-
swatchCss: () => string;
|
|
11
|
-
valueText: () => string;
|
|
12
|
-
};
|
|
13
|
-
declare const oklchStr: (L: any, C: any, H: any, A: any) => string;
|
|
14
|
-
export { createPickerBody, parseColor, oklchStr, CHECKER };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function compileExpr(src: any): any;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
declare const titleCase: (s: any) => any;
|
|
2
|
-
declare const clamp: (v: any, lo: any, hi: any) => number;
|
|
3
|
-
declare const isColorStr: (v: any) => boolean;
|
|
4
|
-
declare const stepPrecision: (step: any) => number;
|
|
5
|
-
declare const roundToStep: (v: any, min: any, step: any) => any;
|
|
6
|
-
declare const inferStep: (min: any, max: any) => 1 | 0.1 | 0.01 | 10;
|
|
7
|
-
declare const defaultRange: (v: any) => number[];
|
|
8
|
-
declare const optValue: (o: any) => any;
|
|
9
|
-
declare const optLabel: (o: any) => any;
|
|
10
|
-
declare const el: (tag: string, cls?: string, html?: string) => any;
|
|
11
|
-
declare const svgEl: (tag: string, cls?: string) => any;
|
|
12
|
-
declare const btn: (cls: string, html?: string) => any;
|
|
13
|
-
declare const txt: (tag: string, cls: string, text: any) => any;
|
|
14
|
-
declare const cssVar: (node: any, name: any) => string;
|
|
15
|
-
declare const accentColor: (node: any) => string;
|
|
16
|
-
declare const stopPointerLeak: (node: any) => void;
|
|
17
|
-
declare const onReady: (fn: any) => void;
|
|
18
|
-
declare const onLive: (owner: any, targets: Array<[any, string]>, fn: (e?: any) => void) => () => void;
|
|
19
|
-
declare const wireHoverClass: (el: any, onEnter: any) => void;
|
|
20
|
-
declare const quietFocus: (input: any) => void;
|
|
21
|
-
declare function dragGesture(node: any, { onDown, onMove, onEnd }?: {
|
|
22
|
-
onDown?: (e: any) => void;
|
|
23
|
-
onMove?: (e: any) => void;
|
|
24
|
-
onEnd?: (e: any) => void;
|
|
25
|
-
}): void;
|
|
26
|
-
declare const grabSurface: (surface: any, set: any) => void;
|
|
27
|
-
declare const boxFrac: (e: any, box: any) => number[];
|
|
28
|
-
declare const fitCanvas: (canvas: any, ctx: any, maxDpr?: number) => any[];
|
|
29
|
-
export declare const placeBelow: (trigger: any, pop: any, { width, fallbackH, gap, align, prefer }?: {
|
|
30
|
-
width?: number | "match";
|
|
31
|
-
fallbackH?: number;
|
|
32
|
-
gap?: number;
|
|
33
|
-
align?: "start" | "end" | "center";
|
|
34
|
-
prefer?: "above" | "below";
|
|
35
|
-
}) => void;
|
|
36
|
-
declare const resolveTheme: (theme: any) => {};
|
|
37
|
-
declare const applyThemeVars: (node: any, vars: any) => void;
|
|
38
|
-
declare const carryScheme: (portal: any, anchor: any) => void;
|
|
39
|
-
declare const carrySkin: (portal: any, anchor: any) => void;
|
|
40
|
-
declare const closeActivePopover: () => void;
|
|
41
|
-
declare function popover(root: any, trigger: any, pop: any, opts?: {
|
|
42
|
-
width?: number | "match";
|
|
43
|
-
fallbackH?: number;
|
|
44
|
-
gap?: number;
|
|
45
|
-
align?: "start" | "end";
|
|
46
|
-
onOpen?: () => void;
|
|
47
|
-
onReflow?: () => void;
|
|
48
|
-
}): {
|
|
49
|
-
open: () => void;
|
|
50
|
-
close: () => void;
|
|
51
|
-
isOpen: () => boolean;
|
|
52
|
-
reflow: () => void;
|
|
53
|
-
};
|
|
54
|
-
declare const fuzzyMatch: (text: any, q: any) => boolean;
|
|
55
|
-
declare const REDUCE_MOTION: any;
|
|
56
|
-
declare const measurePill: (container: any, pill: any, animate?: any) => void;
|
|
57
|
-
declare const setRadioActive: (btns: any, value: any) => any;
|
|
58
|
-
declare const radioButton: (cls: any, o: any, onPick: any) => any;
|
|
59
|
-
declare const navIndex: (key: any, i: any, n: any, cols?: number) => any;
|
|
60
|
-
declare const triggerRow: (cls: string, label: string) => {
|
|
61
|
-
root: any;
|
|
62
|
-
trigger: any;
|
|
63
|
-
right: any;
|
|
64
|
-
};
|
|
65
|
-
declare function numField(spec: any, onChange: any): {
|
|
66
|
-
el: any;
|
|
67
|
-
set: (val: any) => void;
|
|
68
|
-
get: () => any;
|
|
69
|
-
};
|
|
70
|
-
declare const blade: (el: any) => {
|
|
71
|
-
el: any;
|
|
72
|
-
set: () => void;
|
|
73
|
-
get: () => any;
|
|
74
|
-
};
|
|
75
|
-
export declare const registerControl: (type: any, ctor: any) => void;
|
|
76
|
-
export declare const getControl: (type: any) => any;
|
|
77
|
-
export { titleCase, clamp, isColorStr, stepPrecision, roundToStep, inferStep, defaultRange, optValue, optLabel, el, btn, txt, svgEl, cssVar, accentColor, stopPointerLeak, onReady, onLive, wireHoverClass, dragGesture, boxFrac, fitCanvas, popover, closeActivePopover, resolveTheme, applyThemeVars, carryScheme, carrySkin, fuzzyMatch, setRadioActive, radioButton, navIndex, triggerRow, numField, blade, quietFocus, measurePill, grabSurface, REDUCE_MOTION, };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import "./controls/colour.js";
|
|
2
|
-
import "./controls/gradient.js";
|
|
3
|
-
import "./controls/interval.js";
|
|
4
|
-
import "./controls/tabs.js";
|
|
5
|
-
import "./controls/image.js";
|
|
6
|
-
import "./controls/monitor.js";
|
|
7
|
-
import "./controls/spring.js";
|
|
8
|
-
import "./controls/bezier.js";
|
|
9
|
-
import "./controls/point.js";
|
|
10
|
-
import "./controls/plot.js";
|
|
11
|
-
export { tweaks, enhance } from "./core.js";
|
|
12
|
-
export type { Schema, SchemaValue, SchemaObject, ControlOptions, Option, GradientStop, Get, TweaksOptions, Theme, Params, Panel, Control } from "./types.js";
|