@refraction-ui/react 0.4.0 → 0.4.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.
- package/dist/index.cjs +841 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +796 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
package/dist/index.cjs
CHANGED
|
@@ -7114,6 +7114,798 @@ var VideoPlayer = React11__namespace.forwardRef(
|
|
|
7114
7114
|
);
|
|
7115
7115
|
VideoPlayer.displayName = "VideoPlayer";
|
|
7116
7116
|
|
|
7117
|
+
// ../voice-pill/dist/index.js
|
|
7118
|
+
var DEFAULT_VOICE_PILL_SPEAKER = "ai";
|
|
7119
|
+
var DEFAULT_VOICE_PILL_POSITION = "bottom-center";
|
|
7120
|
+
function formatNumber(value) {
|
|
7121
|
+
return Number(value.toFixed(3)).toString();
|
|
7122
|
+
}
|
|
7123
|
+
function getRawSpeaker(speaker) {
|
|
7124
|
+
const value = String(speaker ?? DEFAULT_VOICE_PILL_SPEAKER).trim();
|
|
7125
|
+
return value.length > 0 ? value : DEFAULT_VOICE_PILL_SPEAKER;
|
|
7126
|
+
}
|
|
7127
|
+
function clampVoicePillIntensity(intensity = 0) {
|
|
7128
|
+
const value = Number(intensity);
|
|
7129
|
+
if (!Number.isFinite(value)) {
|
|
7130
|
+
return 0;
|
|
7131
|
+
}
|
|
7132
|
+
return Math.min(1, Math.max(0, value));
|
|
7133
|
+
}
|
|
7134
|
+
function getVoicePillSpeakerKey(speaker) {
|
|
7135
|
+
const normalized = getRawSpeaker(speaker).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
7136
|
+
return normalized.length > 0 ? normalized : DEFAULT_VOICE_PILL_SPEAKER;
|
|
7137
|
+
}
|
|
7138
|
+
function getVoicePillSpeakerLabel(speaker) {
|
|
7139
|
+
const raw = getRawSpeaker(speaker);
|
|
7140
|
+
const key = getVoicePillSpeakerKey(raw);
|
|
7141
|
+
if (key === "ai") return "AI";
|
|
7142
|
+
if (key === "user") return "User";
|
|
7143
|
+
return raw;
|
|
7144
|
+
}
|
|
7145
|
+
function getVoicePillInitials(speaker) {
|
|
7146
|
+
const key = getVoicePillSpeakerKey(speaker);
|
|
7147
|
+
if (key === "ai") return "AI";
|
|
7148
|
+
if (key === "user") return "U";
|
|
7149
|
+
const initials = getVoicePillSpeakerLabel(speaker).split(/[\s_-]+/).map((part) => part.charAt(0)).filter(Boolean).join("").slice(0, 2).toUpperCase();
|
|
7150
|
+
return initials.length > 0 ? initials : "V";
|
|
7151
|
+
}
|
|
7152
|
+
function getVoicePillPosition(position) {
|
|
7153
|
+
return position ?? DEFAULT_VOICE_PILL_POSITION;
|
|
7154
|
+
}
|
|
7155
|
+
function getVoicePillAriaLabel(props) {
|
|
7156
|
+
const parts = [`${getVoicePillSpeakerLabel(props.speaker)}: ${props.label}`];
|
|
7157
|
+
if (props.sub) {
|
|
7158
|
+
parts.push(props.sub);
|
|
7159
|
+
}
|
|
7160
|
+
if (props.muted) {
|
|
7161
|
+
parts.push("muted");
|
|
7162
|
+
}
|
|
7163
|
+
return parts.join(", ");
|
|
7164
|
+
}
|
|
7165
|
+
function getVoicePillPulseStyle(intensity, muted = false) {
|
|
7166
|
+
const clamped = clampVoicePillIntensity(intensity);
|
|
7167
|
+
const visualIntensity = muted ? 0 : clamped;
|
|
7168
|
+
const ringOpacity = visualIntensity === 0 ? 0 : 0.12 + visualIntensity * 0.42;
|
|
7169
|
+
const ringScale = 1 + visualIntensity * 0.35;
|
|
7170
|
+
const duration = visualIntensity === 0 ? 1800 : Math.round(1700 - visualIntensity * 700);
|
|
7171
|
+
return {
|
|
7172
|
+
"--rfr-voice-pill-intensity": formatNumber(clamped),
|
|
7173
|
+
"--rfr-voice-pill-visual-intensity": formatNumber(visualIntensity),
|
|
7174
|
+
"--rfr-voice-pill-ring-opacity": formatNumber(ringOpacity),
|
|
7175
|
+
"--rfr-voice-pill-ring-scale": formatNumber(ringScale),
|
|
7176
|
+
"--rfr-voice-pill-pulse-duration": `${duration}ms`,
|
|
7177
|
+
"--rfr-voice-pill-pulse-delay": `-${Math.round(duration / 2)}ms`
|
|
7178
|
+
};
|
|
7179
|
+
}
|
|
7180
|
+
function createVoicePill(props) {
|
|
7181
|
+
const {
|
|
7182
|
+
speaker: speakerProp,
|
|
7183
|
+
label,
|
|
7184
|
+
sub,
|
|
7185
|
+
intensity: intensityProp,
|
|
7186
|
+
muted: mutedProp = false,
|
|
7187
|
+
onToggleMute,
|
|
7188
|
+
position: positionProp
|
|
7189
|
+
} = props;
|
|
7190
|
+
const speaker = getVoicePillSpeakerLabel(speakerProp);
|
|
7191
|
+
const speakerKey = getVoicePillSpeakerKey(speakerProp);
|
|
7192
|
+
const intensity = clampVoicePillIntensity(intensityProp);
|
|
7193
|
+
const muted = Boolean(mutedProp);
|
|
7194
|
+
const visualIntensity = muted ? 0 : intensity;
|
|
7195
|
+
const position = getVoicePillPosition(positionProp);
|
|
7196
|
+
function toggleMute() {
|
|
7197
|
+
onToggleMute?.();
|
|
7198
|
+
}
|
|
7199
|
+
const ariaProps = {
|
|
7200
|
+
role: "status",
|
|
7201
|
+
"aria-live": "polite",
|
|
7202
|
+
"aria-atomic": true,
|
|
7203
|
+
"aria-label": getVoicePillAriaLabel({ speaker: speakerProp, label, sub, muted })
|
|
7204
|
+
};
|
|
7205
|
+
const toggleMuteAriaProps = {
|
|
7206
|
+
"aria-label": muted ? "Unmute voice" : "Mute voice",
|
|
7207
|
+
"aria-pressed": muted
|
|
7208
|
+
};
|
|
7209
|
+
const dataAttributes = {
|
|
7210
|
+
"data-speaker": speakerKey,
|
|
7211
|
+
"data-muted": String(muted),
|
|
7212
|
+
"data-position": position,
|
|
7213
|
+
"data-intensity": formatNumber(intensity),
|
|
7214
|
+
"data-active": String(visualIntensity > 0)
|
|
7215
|
+
};
|
|
7216
|
+
return {
|
|
7217
|
+
speaker,
|
|
7218
|
+
speakerKey,
|
|
7219
|
+
label,
|
|
7220
|
+
sub,
|
|
7221
|
+
intensity,
|
|
7222
|
+
visualIntensity,
|
|
7223
|
+
muted,
|
|
7224
|
+
position,
|
|
7225
|
+
initials: getVoicePillInitials(speakerProp),
|
|
7226
|
+
toggleMute,
|
|
7227
|
+
ariaProps,
|
|
7228
|
+
toggleMuteAriaProps,
|
|
7229
|
+
dataAttributes,
|
|
7230
|
+
style: getVoicePillPulseStyle(intensity, muted)
|
|
7231
|
+
};
|
|
7232
|
+
}
|
|
7233
|
+
var voicePillTokens = {
|
|
7234
|
+
name: "voice-pill",
|
|
7235
|
+
tokens: {
|
|
7236
|
+
bg: { variable: "--rfr-voice-pill-bg", fallback: "hsl(var(--background))" },
|
|
7237
|
+
fg: { variable: "--rfr-voice-pill-fg", fallback: "hsl(var(--foreground))" },
|
|
7238
|
+
border: { variable: "--rfr-voice-pill-border", fallback: "hsl(var(--border))" },
|
|
7239
|
+
accent: { variable: "--rfr-voice-pill-accent", fallback: "hsl(var(--primary))" },
|
|
7240
|
+
accentFg: {
|
|
7241
|
+
variable: "--rfr-voice-pill-accent-foreground",
|
|
7242
|
+
fallback: "hsl(var(--primary-foreground))"
|
|
7243
|
+
}
|
|
7244
|
+
}
|
|
7245
|
+
};
|
|
7246
|
+
var voicePillRootStyles = "inline-flex min-w-0 max-w-[min(calc(100vw-2rem),22rem)] items-center gap-3 rounded-full border border-border bg-background px-3 py-2 text-foreground shadow-lg ring-1 ring-border/50 transition-opacity data-[muted=true]:opacity-80";
|
|
7247
|
+
var voicePillSpeakerStyles = "[--rfr-voice-pill-accent:hsl(var(--primary))] [--rfr-voice-pill-accent-foreground:hsl(var(--primary-foreground))] data-[speaker=user]:[--rfr-voice-pill-accent:hsl(var(--accent-foreground))] data-[speaker=user]:[--rfr-voice-pill-accent-foreground:hsl(var(--accent))] data-[muted=true]:[--rfr-voice-pill-accent:hsl(var(--muted-foreground))]";
|
|
7248
|
+
var voicePillPositionVariants = cva({
|
|
7249
|
+
base: "fixed z-50",
|
|
7250
|
+
variants: {
|
|
7251
|
+
position: {
|
|
7252
|
+
"top-start": "top-[calc(env(safe-area-inset-top)+1rem)] left-[calc(env(safe-area-inset-left)+1rem)]",
|
|
7253
|
+
"top-center": "top-[calc(env(safe-area-inset-top)+1rem)] left-1/2 -translate-x-1/2",
|
|
7254
|
+
"top-end": "top-[calc(env(safe-area-inset-top)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)]",
|
|
7255
|
+
"bottom-start": "bottom-[calc(env(safe-area-inset-bottom)+1rem)] left-[calc(env(safe-area-inset-left)+1rem)]",
|
|
7256
|
+
"bottom-center": "bottom-[calc(env(safe-area-inset-bottom)+1rem)] left-1/2 -translate-x-1/2",
|
|
7257
|
+
"bottom-end": "bottom-[calc(env(safe-area-inset-bottom)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)]",
|
|
7258
|
+
"left-start": "left-[calc(env(safe-area-inset-left)+1rem)] top-[calc(env(safe-area-inset-top)+1rem)]",
|
|
7259
|
+
"left-center": "left-[calc(env(safe-area-inset-left)+1rem)] top-1/2 -translate-y-1/2",
|
|
7260
|
+
"left-end": "left-[calc(env(safe-area-inset-left)+1rem)] bottom-[calc(env(safe-area-inset-bottom)+1rem)]",
|
|
7261
|
+
"right-start": "right-[calc(env(safe-area-inset-right)+1rem)] top-[calc(env(safe-area-inset-top)+1rem)]",
|
|
7262
|
+
"right-center": "right-[calc(env(safe-area-inset-right)+1rem)] top-1/2 -translate-y-1/2",
|
|
7263
|
+
"right-end": "right-[calc(env(safe-area-inset-right)+1rem)] bottom-[calc(env(safe-area-inset-bottom)+1rem)]"
|
|
7264
|
+
}
|
|
7265
|
+
},
|
|
7266
|
+
defaultVariants: {
|
|
7267
|
+
position: "bottom-center"
|
|
7268
|
+
}
|
|
7269
|
+
});
|
|
7270
|
+
var voicePillAvatarWrapStyles = "relative flex h-10 w-10 shrink-0 items-center justify-center";
|
|
7271
|
+
var voicePillPulseRingStyles = "pointer-events-none absolute inset-0 rounded-full border border-[var(--rfr-voice-pill-accent)] opacity-[var(--rfr-voice-pill-ring-opacity)] motion-safe:animate-ping motion-reduce:animate-none";
|
|
7272
|
+
var voicePillAvatarStyles = "relative z-10 flex h-10 w-10 items-center justify-center overflow-hidden rounded-full bg-[var(--rfr-voice-pill-accent)] text-[var(--rfr-voice-pill-accent-foreground)] text-xs font-semibold uppercase";
|
|
7273
|
+
var voicePillTextStyles = "min-w-0 flex-1";
|
|
7274
|
+
var voicePillLabelStyles = "block truncate text-sm font-medium leading-tight";
|
|
7275
|
+
var voicePillSubStyles = "block truncate text-xs leading-tight text-muted-foreground";
|
|
7276
|
+
var voicePillMuteButtonStyles = "inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-border text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";
|
|
7277
|
+
|
|
7278
|
+
// ../react-voice-pill/dist/index.js
|
|
7279
|
+
var VoicePill = React11__namespace.forwardRef(
|
|
7280
|
+
({
|
|
7281
|
+
speaker,
|
|
7282
|
+
label,
|
|
7283
|
+
sub,
|
|
7284
|
+
intensity,
|
|
7285
|
+
muted,
|
|
7286
|
+
onToggleMute,
|
|
7287
|
+
position,
|
|
7288
|
+
avatar,
|
|
7289
|
+
className,
|
|
7290
|
+
style,
|
|
7291
|
+
...props
|
|
7292
|
+
}, ref) => {
|
|
7293
|
+
const api = createVoicePill({
|
|
7294
|
+
speaker,
|
|
7295
|
+
label,
|
|
7296
|
+
sub,
|
|
7297
|
+
intensity,
|
|
7298
|
+
muted,
|
|
7299
|
+
onToggleMute,
|
|
7300
|
+
position
|
|
7301
|
+
});
|
|
7302
|
+
const mergedStyle = {
|
|
7303
|
+
...api.style,
|
|
7304
|
+
...style
|
|
7305
|
+
};
|
|
7306
|
+
const pulseStyle = {
|
|
7307
|
+
animationDuration: "var(--rfr-voice-pill-pulse-duration)",
|
|
7308
|
+
transform: "scale(var(--rfr-voice-pill-ring-scale))"
|
|
7309
|
+
};
|
|
7310
|
+
const delayedPulseStyle = {
|
|
7311
|
+
...pulseStyle,
|
|
7312
|
+
animationDelay: "var(--rfr-voice-pill-pulse-delay)"
|
|
7313
|
+
};
|
|
7314
|
+
return React11__namespace.createElement(
|
|
7315
|
+
"div",
|
|
7316
|
+
{
|
|
7317
|
+
...props,
|
|
7318
|
+
...api.ariaProps,
|
|
7319
|
+
...api.dataAttributes,
|
|
7320
|
+
ref,
|
|
7321
|
+
className: cn(
|
|
7322
|
+
voicePillPositionVariants({ position: api.position }),
|
|
7323
|
+
voicePillRootStyles,
|
|
7324
|
+
voicePillSpeakerStyles,
|
|
7325
|
+
className
|
|
7326
|
+
),
|
|
7327
|
+
style: mergedStyle
|
|
7328
|
+
},
|
|
7329
|
+
React11__namespace.createElement(
|
|
7330
|
+
"span",
|
|
7331
|
+
{
|
|
7332
|
+
className: voicePillAvatarWrapStyles,
|
|
7333
|
+
"aria-hidden": true
|
|
7334
|
+
},
|
|
7335
|
+
api.visualIntensity > 0 && React11__namespace.createElement("span", {
|
|
7336
|
+
className: voicePillPulseRingStyles,
|
|
7337
|
+
style: pulseStyle
|
|
7338
|
+
}),
|
|
7339
|
+
api.visualIntensity > 0 && React11__namespace.createElement("span", {
|
|
7340
|
+
className: voicePillPulseRingStyles,
|
|
7341
|
+
style: delayedPulseStyle
|
|
7342
|
+
}),
|
|
7343
|
+
React11__namespace.createElement(
|
|
7344
|
+
"span",
|
|
7345
|
+
{ className: voicePillAvatarStyles },
|
|
7346
|
+
avatar ?? api.initials
|
|
7347
|
+
)
|
|
7348
|
+
),
|
|
7349
|
+
React11__namespace.createElement(
|
|
7350
|
+
"span",
|
|
7351
|
+
{ className: voicePillTextStyles },
|
|
7352
|
+
React11__namespace.createElement("span", { className: voicePillLabelStyles }, api.label),
|
|
7353
|
+
api.sub && React11__namespace.createElement("span", { className: voicePillSubStyles }, api.sub)
|
|
7354
|
+
),
|
|
7355
|
+
onToggleMute && React11__namespace.createElement(
|
|
7356
|
+
"button",
|
|
7357
|
+
{
|
|
7358
|
+
type: "button",
|
|
7359
|
+
className: voicePillMuteButtonStyles,
|
|
7360
|
+
onClick: api.toggleMute,
|
|
7361
|
+
...api.toggleMuteAriaProps
|
|
7362
|
+
},
|
|
7363
|
+
renderMuteIcon(api.muted)
|
|
7364
|
+
)
|
|
7365
|
+
);
|
|
7366
|
+
}
|
|
7367
|
+
);
|
|
7368
|
+
VoicePill.displayName = "VoicePill";
|
|
7369
|
+
function renderMuteIcon(muted) {
|
|
7370
|
+
return React11__namespace.createElement(
|
|
7371
|
+
"svg",
|
|
7372
|
+
{
|
|
7373
|
+
"aria-hidden": true,
|
|
7374
|
+
className: "h-4 w-4",
|
|
7375
|
+
fill: "none",
|
|
7376
|
+
stroke: "currentColor",
|
|
7377
|
+
strokeLinecap: "round",
|
|
7378
|
+
strokeLinejoin: "round",
|
|
7379
|
+
strokeWidth: 2,
|
|
7380
|
+
viewBox: "0 0 24 24"
|
|
7381
|
+
},
|
|
7382
|
+
React11__namespace.createElement("path", {
|
|
7383
|
+
d: "M4 9v6h4l5 4V5L8 9H4Z"
|
|
7384
|
+
}),
|
|
7385
|
+
muted ? React11__namespace.createElement(
|
|
7386
|
+
React11__namespace.Fragment,
|
|
7387
|
+
null,
|
|
7388
|
+
React11__namespace.createElement("path", { d: "m19 9-4 4" }),
|
|
7389
|
+
React11__namespace.createElement("path", { d: "m15 9 4 4" })
|
|
7390
|
+
) : React11__namespace.createElement(
|
|
7391
|
+
React11__namespace.Fragment,
|
|
7392
|
+
null,
|
|
7393
|
+
React11__namespace.createElement("path", { d: "M16 8.5a4 4 0 0 1 0 7" }),
|
|
7394
|
+
React11__namespace.createElement("path", { d: "M18.5 6a7 7 0 0 1 0 12" })
|
|
7395
|
+
)
|
|
7396
|
+
);
|
|
7397
|
+
}
|
|
7398
|
+
|
|
7399
|
+
// ../waveform/dist/index.js
|
|
7400
|
+
var DEFAULT_WAVEFORM_BAR_COUNT = 48;
|
|
7401
|
+
var DEFAULT_WAVEFORM_COLOR = "var(--accent-2)";
|
|
7402
|
+
var DEFAULT_WAVEFORM_HEIGHT = 80;
|
|
7403
|
+
var DEFAULT_WAVEFORM_INTENSITY = 1;
|
|
7404
|
+
var DEFAULT_WAVEFORM_SMOOTHING = 0.8;
|
|
7405
|
+
var MAX_BAR_COUNT = 1024;
|
|
7406
|
+
var MAX_INTENSITY = 1;
|
|
7407
|
+
function normalizeBarCount(value) {
|
|
7408
|
+
if (value == null || !Number.isFinite(value)) return DEFAULT_WAVEFORM_BAR_COUNT;
|
|
7409
|
+
return Math.min(MAX_BAR_COUNT, Math.max(1, Math.round(value)));
|
|
7410
|
+
}
|
|
7411
|
+
function normalizeSmoothing(value) {
|
|
7412
|
+
if (value == null || !Number.isFinite(value)) return DEFAULT_WAVEFORM_SMOOTHING;
|
|
7413
|
+
return Math.min(0.99, Math.max(0, value));
|
|
7414
|
+
}
|
|
7415
|
+
function normalizeIntensity(value) {
|
|
7416
|
+
if (value == null || !Number.isFinite(value)) return DEFAULT_WAVEFORM_INTENSITY;
|
|
7417
|
+
return Math.min(MAX_INTENSITY, Math.max(0, value));
|
|
7418
|
+
}
|
|
7419
|
+
function normalizeWaveformConfig(props = {}) {
|
|
7420
|
+
return {
|
|
7421
|
+
variant: props.variant ?? "bars",
|
|
7422
|
+
intensity: normalizeIntensity(props.intensity),
|
|
7423
|
+
height: props.height ?? DEFAULT_WAVEFORM_HEIGHT,
|
|
7424
|
+
width: props.width ?? "100%",
|
|
7425
|
+
barCount: normalizeBarCount(props.barCount),
|
|
7426
|
+
smoothing: normalizeSmoothing(props.smoothing),
|
|
7427
|
+
color: props.color ?? DEFAULT_WAVEFORM_COLOR,
|
|
7428
|
+
paused: props.paused ?? false
|
|
7429
|
+
};
|
|
7430
|
+
}
|
|
7431
|
+
function isWaveformSampleInput(value) {
|
|
7432
|
+
return value instanceof Float32Array || Array.isArray(value);
|
|
7433
|
+
}
|
|
7434
|
+
function createSilentSamples(count = DEFAULT_WAVEFORM_BAR_COUNT) {
|
|
7435
|
+
return new Float32Array(normalizeBarCount(count));
|
|
7436
|
+
}
|
|
7437
|
+
function createIntensitySamples(intensity = DEFAULT_WAVEFORM_INTENSITY, count = DEFAULT_WAVEFORM_BAR_COUNT) {
|
|
7438
|
+
const normalizedIntensity = normalizeIntensity(intensity);
|
|
7439
|
+
const normalizedCount = normalizeBarCount(count);
|
|
7440
|
+
const samples = new Float32Array(normalizedCount);
|
|
7441
|
+
if (normalizedIntensity === 0) return samples;
|
|
7442
|
+
for (let i = 0; i < normalizedCount; i += 1) {
|
|
7443
|
+
const progress = normalizedCount <= 1 ? 0.5 : i / (normalizedCount - 1);
|
|
7444
|
+
const envelope = 0.35 + Math.sin(progress * Math.PI) * 0.65;
|
|
7445
|
+
const carrier = Math.sin(progress * Math.PI * 6);
|
|
7446
|
+
samples[i] = carrier * envelope * normalizedIntensity;
|
|
7447
|
+
}
|
|
7448
|
+
return samples;
|
|
7449
|
+
}
|
|
7450
|
+
function normalizeWaveformSamples(input, targetCount) {
|
|
7451
|
+
const sourceLength = input?.length ?? 0;
|
|
7452
|
+
if (sourceLength === 0) {
|
|
7453
|
+
return targetCount == null ? new Float32Array() : createSilentSamples(targetCount);
|
|
7454
|
+
}
|
|
7455
|
+
const normalized = new Float32Array(sourceLength);
|
|
7456
|
+
let maxAbs = 0;
|
|
7457
|
+
for (let i = 0; i < sourceLength; i += 1) {
|
|
7458
|
+
const value = Number(input?.[i]);
|
|
7459
|
+
const sample = Number.isFinite(value) ? value : 0;
|
|
7460
|
+
normalized[i] = sample;
|
|
7461
|
+
maxAbs = Math.max(maxAbs, Math.abs(sample));
|
|
7462
|
+
}
|
|
7463
|
+
const divisor = maxAbs > 1 ? maxAbs : 1;
|
|
7464
|
+
for (let i = 0; i < normalized.length; i += 1) {
|
|
7465
|
+
normalized[i] = clamp(normalized[i] / divisor, -1, 1);
|
|
7466
|
+
}
|
|
7467
|
+
if (targetCount == null || targetCount === normalized.length) {
|
|
7468
|
+
return normalized;
|
|
7469
|
+
}
|
|
7470
|
+
return resampleWaveformSamples(normalized, targetCount);
|
|
7471
|
+
}
|
|
7472
|
+
function resampleWaveformSamples(samples, targetCount) {
|
|
7473
|
+
const count = normalizeBarCount(targetCount);
|
|
7474
|
+
const sourceLength = samples.length;
|
|
7475
|
+
if (sourceLength === 0) return createSilentSamples(count);
|
|
7476
|
+
if (sourceLength === count) return Float32Array.from(samples);
|
|
7477
|
+
const output = new Float32Array(count);
|
|
7478
|
+
for (let i = 0; i < count; i += 1) {
|
|
7479
|
+
const start = i * sourceLength / count;
|
|
7480
|
+
const end = (i + 1) * sourceLength / count;
|
|
7481
|
+
const firstIndex = Math.floor(start);
|
|
7482
|
+
const lastIndex = Math.max(firstIndex + 1, Math.ceil(end));
|
|
7483
|
+
let total = 0;
|
|
7484
|
+
let values = 0;
|
|
7485
|
+
for (let j = firstIndex; j < lastIndex && j < sourceLength; j += 1) {
|
|
7486
|
+
total += Number(samples[j]);
|
|
7487
|
+
values += 1;
|
|
7488
|
+
}
|
|
7489
|
+
output[i] = values > 0 ? total / values : Number(samples[Math.min(firstIndex, sourceLength - 1)]);
|
|
7490
|
+
}
|
|
7491
|
+
return output;
|
|
7492
|
+
}
|
|
7493
|
+
function smoothWaveformSamples(previous, next, smoothing = DEFAULT_WAVEFORM_SMOOTHING) {
|
|
7494
|
+
if (previous == null || previous.length === 0) {
|
|
7495
|
+
return Float32Array.from(next);
|
|
7496
|
+
}
|
|
7497
|
+
const amount = normalizeSmoothing(smoothing);
|
|
7498
|
+
const output = new Float32Array(next.length);
|
|
7499
|
+
for (let i = 0; i < next.length; i += 1) {
|
|
7500
|
+
const previousValue = Number(previous[i] ?? next[i]);
|
|
7501
|
+
output[i] = previousValue * amount + Number(next[i]) * (1 - amount);
|
|
7502
|
+
}
|
|
7503
|
+
return output;
|
|
7504
|
+
}
|
|
7505
|
+
function scaleWaveformSamples(samples, intensity = DEFAULT_WAVEFORM_INTENSITY) {
|
|
7506
|
+
const amount = normalizeIntensity(intensity);
|
|
7507
|
+
const output = new Float32Array(samples.length);
|
|
7508
|
+
for (let i = 0; i < samples.length; i += 1) {
|
|
7509
|
+
output[i] = clamp(Number(samples[i]) * amount, -1, 1);
|
|
7510
|
+
}
|
|
7511
|
+
return output;
|
|
7512
|
+
}
|
|
7513
|
+
function getWaveformPeak(samples) {
|
|
7514
|
+
let peak = 0;
|
|
7515
|
+
for (let i = 0; i < samples.length; i += 1) {
|
|
7516
|
+
peak = Math.max(peak, Math.abs(Number(samples[i]) || 0));
|
|
7517
|
+
}
|
|
7518
|
+
return Math.min(1, peak);
|
|
7519
|
+
}
|
|
7520
|
+
function toCssDimension(value) {
|
|
7521
|
+
if (value == null) return void 0;
|
|
7522
|
+
return typeof value === "number" ? `${value}px` : value;
|
|
7523
|
+
}
|
|
7524
|
+
function createWaveform(props = {}) {
|
|
7525
|
+
const config = normalizeWaveformConfig(props);
|
|
7526
|
+
const inputSamples = props.samples ?? (isWaveformSampleInput(props.source) ? props.source : void 0);
|
|
7527
|
+
const samples = inputSamples == null ? createIntensitySamples(config.intensity, config.barCount) : normalizeWaveformSamples(inputSamples, config.barCount);
|
|
7528
|
+
return {
|
|
7529
|
+
config,
|
|
7530
|
+
samples,
|
|
7531
|
+
ariaProps: {
|
|
7532
|
+
role: "img",
|
|
7533
|
+
"aria-label": "Audio waveform"
|
|
7534
|
+
},
|
|
7535
|
+
dataAttributes: {
|
|
7536
|
+
"data-variant": config.variant,
|
|
7537
|
+
"data-paused": String(config.paused)
|
|
7538
|
+
},
|
|
7539
|
+
getSamples(barCount = config.barCount) {
|
|
7540
|
+
return inputSamples == null ? createIntensitySamples(config.intensity, barCount) : normalizeWaveformSamples(inputSamples, barCount);
|
|
7541
|
+
}
|
|
7542
|
+
};
|
|
7543
|
+
}
|
|
7544
|
+
function clamp(value, min, max) {
|
|
7545
|
+
return Math.min(max, Math.max(min, value));
|
|
7546
|
+
}
|
|
7547
|
+
function prepareWaveformCanvas(canvas, size) {
|
|
7548
|
+
const width = Math.max(1, Math.floor(size.width));
|
|
7549
|
+
const height = Math.max(1, Math.floor(size.height));
|
|
7550
|
+
const pixelRatio = Math.max(1, size.pixelRatio ?? 1);
|
|
7551
|
+
const pixelWidth = Math.floor(width * pixelRatio);
|
|
7552
|
+
const pixelHeight = Math.floor(height * pixelRatio);
|
|
7553
|
+
if (canvas.width !== pixelWidth) {
|
|
7554
|
+
canvas.width = pixelWidth;
|
|
7555
|
+
}
|
|
7556
|
+
if (canvas.height !== pixelHeight) {
|
|
7557
|
+
canvas.height = pixelHeight;
|
|
7558
|
+
}
|
|
7559
|
+
const context = canvas.getContext("2d");
|
|
7560
|
+
if (!context) return null;
|
|
7561
|
+
context.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);
|
|
7562
|
+
return context;
|
|
7563
|
+
}
|
|
7564
|
+
function drawWaveform(context, samples, size, options = {}) {
|
|
7565
|
+
const width = Math.max(1, Math.floor(size.width));
|
|
7566
|
+
const height = Math.max(1, Math.floor(size.height));
|
|
7567
|
+
const variant = options.variant ?? "bars";
|
|
7568
|
+
const color = options.color ?? DEFAULT_WAVEFORM_COLOR;
|
|
7569
|
+
const intensity = normalizeIntensity(options.intensity ?? DEFAULT_WAVEFORM_INTENSITY);
|
|
7570
|
+
const barCount = normalizeBarCount(options.barCount);
|
|
7571
|
+
context.clearRect(0, 0, width, height);
|
|
7572
|
+
applyCanvasColor(context, color);
|
|
7573
|
+
if (variant === "line") {
|
|
7574
|
+
drawLine(context, samples, width, height, intensity);
|
|
7575
|
+
return;
|
|
7576
|
+
}
|
|
7577
|
+
if (variant === "rings") {
|
|
7578
|
+
drawRings(context, samples, width, height, intensity);
|
|
7579
|
+
return;
|
|
7580
|
+
}
|
|
7581
|
+
drawBars(context, samples, width, height, intensity, barCount);
|
|
7582
|
+
}
|
|
7583
|
+
function drawBars(context, samples, width, height, intensity, barCount) {
|
|
7584
|
+
const bars = scaleWaveformSamples(resampleWaveformSamples(samples, barCount), intensity);
|
|
7585
|
+
const slotWidth = width / bars.length;
|
|
7586
|
+
const barWidth = Math.max(1, slotWidth * 0.64);
|
|
7587
|
+
const center = height / 2;
|
|
7588
|
+
for (let i = 0; i < bars.length; i += 1) {
|
|
7589
|
+
const value = Math.abs(bars[i]);
|
|
7590
|
+
const barHeight = Math.max(value * height, value > 0 ? 1 : 0);
|
|
7591
|
+
const x = i * slotWidth + (slotWidth - barWidth) / 2;
|
|
7592
|
+
const y = center - barHeight / 2;
|
|
7593
|
+
context.fillRect(x, y, barWidth, barHeight);
|
|
7594
|
+
}
|
|
7595
|
+
}
|
|
7596
|
+
function drawLine(context, samples, width, height, intensity) {
|
|
7597
|
+
const lineSamples = scaleWaveformSamples(samples, intensity);
|
|
7598
|
+
const center = height / 2;
|
|
7599
|
+
const amplitude = height * 0.45;
|
|
7600
|
+
context.beginPath();
|
|
7601
|
+
for (let i = 0; i < lineSamples.length; i += 1) {
|
|
7602
|
+
const x = lineSamples.length <= 1 ? width / 2 : i / (lineSamples.length - 1) * width;
|
|
7603
|
+
const y = center - Number(lineSamples[i]) * amplitude;
|
|
7604
|
+
if (i === 0) {
|
|
7605
|
+
context.moveTo(x, y);
|
|
7606
|
+
} else {
|
|
7607
|
+
context.lineTo(x, y);
|
|
7608
|
+
}
|
|
7609
|
+
}
|
|
7610
|
+
context.lineWidth = Math.max(1.5, Math.min(width, height) * 0.025);
|
|
7611
|
+
context.lineCap = "round";
|
|
7612
|
+
context.lineJoin = "round";
|
|
7613
|
+
context.stroke();
|
|
7614
|
+
}
|
|
7615
|
+
function drawRings(context, samples, width, height, intensity) {
|
|
7616
|
+
const peak = getWaveformPeak(scaleWaveformSamples(samples, intensity));
|
|
7617
|
+
const minDimension = Math.min(width, height);
|
|
7618
|
+
const centerX = width / 2;
|
|
7619
|
+
const centerY = height / 2;
|
|
7620
|
+
const ringCount = 3;
|
|
7621
|
+
const baseRadius = minDimension * 0.16;
|
|
7622
|
+
const radiusStep = minDimension * 0.13;
|
|
7623
|
+
context.save();
|
|
7624
|
+
context.lineWidth = Math.max(1.5, minDimension * 0.018);
|
|
7625
|
+
for (let i = 0; i < ringCount; i += 1) {
|
|
7626
|
+
const progress = (i + 1) / ringCount;
|
|
7627
|
+
const pulse = peak * minDimension * 0.1 * progress;
|
|
7628
|
+
const radius = baseRadius + radiusStep * i + pulse;
|
|
7629
|
+
context.globalAlpha = 0.28 + progress * 0.34;
|
|
7630
|
+
context.beginPath();
|
|
7631
|
+
context.arc(centerX, centerY, radius, 0, Math.PI * 2);
|
|
7632
|
+
context.stroke();
|
|
7633
|
+
}
|
|
7634
|
+
context.restore();
|
|
7635
|
+
}
|
|
7636
|
+
function applyCanvasColor(context, color) {
|
|
7637
|
+
try {
|
|
7638
|
+
context.fillStyle = color;
|
|
7639
|
+
context.strokeStyle = color;
|
|
7640
|
+
} catch {
|
|
7641
|
+
context.fillStyle = "#000";
|
|
7642
|
+
context.strokeStyle = "#000";
|
|
7643
|
+
}
|
|
7644
|
+
}
|
|
7645
|
+
var waveformVariants = cva({
|
|
7646
|
+
base: "relative block overflow-hidden",
|
|
7647
|
+
variants: {
|
|
7648
|
+
variant: {
|
|
7649
|
+
bars: "",
|
|
7650
|
+
line: "",
|
|
7651
|
+
rings: ""
|
|
7652
|
+
}
|
|
7653
|
+
},
|
|
7654
|
+
defaultVariants: {
|
|
7655
|
+
variant: "bars"
|
|
7656
|
+
}
|
|
7657
|
+
});
|
|
7658
|
+
var waveformCanvasVariants = cva({
|
|
7659
|
+
base: "block h-full w-full"
|
|
7660
|
+
});
|
|
7661
|
+
var Waveform = React11__namespace.forwardRef(
|
|
7662
|
+
({
|
|
7663
|
+
source,
|
|
7664
|
+
samples,
|
|
7665
|
+
intensity,
|
|
7666
|
+
variant,
|
|
7667
|
+
height,
|
|
7668
|
+
width,
|
|
7669
|
+
barCount,
|
|
7670
|
+
smoothing,
|
|
7671
|
+
color,
|
|
7672
|
+
paused,
|
|
7673
|
+
className,
|
|
7674
|
+
style,
|
|
7675
|
+
...props
|
|
7676
|
+
}, ref) => {
|
|
7677
|
+
const rootRef = React11__namespace.useRef(null);
|
|
7678
|
+
const canvasRef = React11__namespace.useRef(null);
|
|
7679
|
+
const previousSamplesRef = React11__namespace.useRef(null);
|
|
7680
|
+
const mediaAnalyserRef = React11__namespace.useRef(null);
|
|
7681
|
+
const floatBufferRef = React11__namespace.useRef(null);
|
|
7682
|
+
const byteBufferRef = React11__namespace.useRef(null);
|
|
7683
|
+
const prefersReducedMotion = usePrefersReducedMotion();
|
|
7684
|
+
const api = createWaveform({
|
|
7685
|
+
source,
|
|
7686
|
+
samples,
|
|
7687
|
+
intensity,
|
|
7688
|
+
variant,
|
|
7689
|
+
height,
|
|
7690
|
+
width,
|
|
7691
|
+
barCount,
|
|
7692
|
+
smoothing,
|
|
7693
|
+
color,
|
|
7694
|
+
paused
|
|
7695
|
+
});
|
|
7696
|
+
const rootStyle = React11__namespace.useMemo(
|
|
7697
|
+
() => ({
|
|
7698
|
+
...style,
|
|
7699
|
+
width: toCssDimension(width) ?? style?.width ?? "100%",
|
|
7700
|
+
height: toCssDimension(height) ?? style?.height ?? `${api.config.height}px`,
|
|
7701
|
+
"--waveform-color": api.config.color
|
|
7702
|
+
}),
|
|
7703
|
+
[api.config.color, api.config.height, height, style, width]
|
|
7704
|
+
);
|
|
7705
|
+
const setRootRef = React11__namespace.useCallback(
|
|
7706
|
+
(node) => {
|
|
7707
|
+
rootRef.current = node;
|
|
7708
|
+
if (typeof ref === "function") {
|
|
7709
|
+
ref(node);
|
|
7710
|
+
} else if (ref) {
|
|
7711
|
+
ref.current = node;
|
|
7712
|
+
}
|
|
7713
|
+
},
|
|
7714
|
+
[ref]
|
|
7715
|
+
);
|
|
7716
|
+
React11__namespace.useEffect(() => {
|
|
7717
|
+
if (!isMediaStreamSource(source)) {
|
|
7718
|
+
mediaAnalyserRef.current = null;
|
|
7719
|
+
return;
|
|
7720
|
+
}
|
|
7721
|
+
if (typeof window === "undefined") return;
|
|
7722
|
+
const AudioContextClass = window.AudioContext ?? window.webkitAudioContext;
|
|
7723
|
+
if (!AudioContextClass) return;
|
|
7724
|
+
const audioContext = new AudioContextClass();
|
|
7725
|
+
const analyser = audioContext.createAnalyser();
|
|
7726
|
+
const streamSource = audioContext.createMediaStreamSource(source);
|
|
7727
|
+
analyser.smoothingTimeConstant = normalizeSmoothing(api.config.smoothing);
|
|
7728
|
+
streamSource.connect(analyser);
|
|
7729
|
+
mediaAnalyserRef.current = analyser;
|
|
7730
|
+
return () => {
|
|
7731
|
+
mediaAnalyserRef.current = null;
|
|
7732
|
+
streamSource.disconnect();
|
|
7733
|
+
analyser.disconnect();
|
|
7734
|
+
if (audioContext.state !== "closed") {
|
|
7735
|
+
void audioContext.close();
|
|
7736
|
+
}
|
|
7737
|
+
};
|
|
7738
|
+
}, [api.config.smoothing, source]);
|
|
7739
|
+
React11__namespace.useEffect(() => {
|
|
7740
|
+
if (isAnalyserSource(source)) {
|
|
7741
|
+
source.smoothingTimeConstant = normalizeSmoothing(api.config.smoothing);
|
|
7742
|
+
}
|
|
7743
|
+
}, [api.config.smoothing, source]);
|
|
7744
|
+
React11__namespace.useEffect(() => {
|
|
7745
|
+
const root = rootRef.current;
|
|
7746
|
+
const canvas = canvasRef.current;
|
|
7747
|
+
if (!root || !canvas) return;
|
|
7748
|
+
let size = measureWaveform(root, api.config.width, api.config.height);
|
|
7749
|
+
let frame = null;
|
|
7750
|
+
let disposed = false;
|
|
7751
|
+
const cancelFrame = () => {
|
|
7752
|
+
if (frame == null) return;
|
|
7753
|
+
if (typeof window.requestAnimationFrame === "function") {
|
|
7754
|
+
window.cancelAnimationFrame(frame);
|
|
7755
|
+
} else {
|
|
7756
|
+
clearTimeout(frame);
|
|
7757
|
+
}
|
|
7758
|
+
frame = null;
|
|
7759
|
+
};
|
|
7760
|
+
const readSamples = () => {
|
|
7761
|
+
if (samples != null) {
|
|
7762
|
+
return normalizeWaveformSamples(samples, api.config.barCount);
|
|
7763
|
+
}
|
|
7764
|
+
if (isWaveformSampleInput(source)) {
|
|
7765
|
+
return normalizeWaveformSamples(source, api.config.barCount);
|
|
7766
|
+
}
|
|
7767
|
+
const analyser = isAnalyserSource(source) ? source : mediaAnalyserRef.current;
|
|
7768
|
+
if (analyser) {
|
|
7769
|
+
return readAnalyserSamples(analyser, api.config.barCount, floatBufferRef, byteBufferRef);
|
|
7770
|
+
}
|
|
7771
|
+
return createIntensitySamples(api.config.intensity, api.config.barCount);
|
|
7772
|
+
};
|
|
7773
|
+
const draw = () => {
|
|
7774
|
+
const context = prepareWaveformCanvas(canvas, {
|
|
7775
|
+
...size,
|
|
7776
|
+
pixelRatio: window.devicePixelRatio || 1
|
|
7777
|
+
});
|
|
7778
|
+
if (!context) return;
|
|
7779
|
+
const nextSamples = readSamples();
|
|
7780
|
+
const renderedSamples = smoothWaveformSamples(
|
|
7781
|
+
previousSamplesRef.current ?? void 0,
|
|
7782
|
+
nextSamples,
|
|
7783
|
+
api.config.smoothing
|
|
7784
|
+
);
|
|
7785
|
+
previousSamplesRef.current = renderedSamples;
|
|
7786
|
+
drawWaveform(context, renderedSamples, size, {
|
|
7787
|
+
variant: api.config.variant,
|
|
7788
|
+
color: resolveCanvasColor(root, api.config.color),
|
|
7789
|
+
intensity: api.config.intensity,
|
|
7790
|
+
barCount: api.config.barCount
|
|
7791
|
+
});
|
|
7792
|
+
};
|
|
7793
|
+
const schedule = () => {
|
|
7794
|
+
if (disposed || api.config.paused || prefersReducedMotion) return;
|
|
7795
|
+
if (typeof window.requestAnimationFrame === "function") {
|
|
7796
|
+
frame = window.requestAnimationFrame(tick);
|
|
7797
|
+
} else {
|
|
7798
|
+
frame = window.setTimeout(() => tick(), 16);
|
|
7799
|
+
}
|
|
7800
|
+
};
|
|
7801
|
+
const tick = () => {
|
|
7802
|
+
draw();
|
|
7803
|
+
schedule();
|
|
7804
|
+
};
|
|
7805
|
+
draw();
|
|
7806
|
+
schedule();
|
|
7807
|
+
const observer = typeof ResizeObserver === "function" ? new ResizeObserver(() => {
|
|
7808
|
+
size = measureWaveform(root, api.config.width, api.config.height);
|
|
7809
|
+
draw();
|
|
7810
|
+
}) : null;
|
|
7811
|
+
observer?.observe(root);
|
|
7812
|
+
return () => {
|
|
7813
|
+
disposed = true;
|
|
7814
|
+
cancelFrame();
|
|
7815
|
+
observer?.disconnect();
|
|
7816
|
+
};
|
|
7817
|
+
}, [
|
|
7818
|
+
api.config.barCount,
|
|
7819
|
+
api.config.color,
|
|
7820
|
+
api.config.height,
|
|
7821
|
+
api.config.intensity,
|
|
7822
|
+
api.config.paused,
|
|
7823
|
+
api.config.smoothing,
|
|
7824
|
+
api.config.variant,
|
|
7825
|
+
api.config.width,
|
|
7826
|
+
prefersReducedMotion,
|
|
7827
|
+
samples,
|
|
7828
|
+
source
|
|
7829
|
+
]);
|
|
7830
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7831
|
+
"div",
|
|
7832
|
+
{
|
|
7833
|
+
ref: setRootRef,
|
|
7834
|
+
className: cn(waveformVariants({ variant: api.config.variant }), className),
|
|
7835
|
+
style: rootStyle,
|
|
7836
|
+
...api.ariaProps,
|
|
7837
|
+
...api.dataAttributes,
|
|
7838
|
+
...props,
|
|
7839
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
7840
|
+
"canvas",
|
|
7841
|
+
{
|
|
7842
|
+
ref: canvasRef,
|
|
7843
|
+
className: waveformCanvasVariants(),
|
|
7844
|
+
"aria-hidden": "true",
|
|
7845
|
+
"data-waveform-canvas": ""
|
|
7846
|
+
}
|
|
7847
|
+
)
|
|
7848
|
+
}
|
|
7849
|
+
);
|
|
7850
|
+
}
|
|
7851
|
+
);
|
|
7852
|
+
Waveform.displayName = "Waveform";
|
|
7853
|
+
function usePrefersReducedMotion() {
|
|
7854
|
+
const [prefersReducedMotion, setPrefersReducedMotion] = React11__namespace.useState(false);
|
|
7855
|
+
React11__namespace.useEffect(() => {
|
|
7856
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
7857
|
+
return;
|
|
7858
|
+
}
|
|
7859
|
+
const media = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
7860
|
+
const update = () => setPrefersReducedMotion(media.matches);
|
|
7861
|
+
update();
|
|
7862
|
+
media.addEventListener?.("change", update);
|
|
7863
|
+
return () => {
|
|
7864
|
+
media.removeEventListener?.("change", update);
|
|
7865
|
+
};
|
|
7866
|
+
}, []);
|
|
7867
|
+
return prefersReducedMotion;
|
|
7868
|
+
}
|
|
7869
|
+
function readAnalyserSamples(analyser, barCount, floatBufferRef, byteBufferRef) {
|
|
7870
|
+
if (typeof analyser.getFloatTimeDomainData === "function") {
|
|
7871
|
+
const length2 = Math.max(1, analyser.fftSize || analyser.frequencyBinCount || barCount);
|
|
7872
|
+
if (floatBufferRef.current?.length !== length2) {
|
|
7873
|
+
floatBufferRef.current = new Float32Array(length2);
|
|
7874
|
+
}
|
|
7875
|
+
analyser.getFloatTimeDomainData(floatBufferRef.current);
|
|
7876
|
+
return normalizeWaveformSamples(floatBufferRef.current, barCount);
|
|
7877
|
+
}
|
|
7878
|
+
const length = Math.max(1, analyser.frequencyBinCount || barCount);
|
|
7879
|
+
if (byteBufferRef.current?.length !== length) {
|
|
7880
|
+
byteBufferRef.current = new Uint8Array(length);
|
|
7881
|
+
}
|
|
7882
|
+
analyser.getByteFrequencyData(byteBufferRef.current);
|
|
7883
|
+
return normalizeWaveformSamples(Array.from(byteBufferRef.current), barCount);
|
|
7884
|
+
}
|
|
7885
|
+
function measureWaveform(element, width, height) {
|
|
7886
|
+
const rect = element.getBoundingClientRect();
|
|
7887
|
+
const fallbackWidth = typeof width === "number" ? width : 300;
|
|
7888
|
+
const fallbackHeight = typeof height === "number" ? height : 80;
|
|
7889
|
+
return {
|
|
7890
|
+
width: Math.max(1, Math.round(rect.width || element.clientWidth || fallbackWidth)),
|
|
7891
|
+
height: Math.max(1, Math.round(rect.height || element.clientHeight || fallbackHeight))
|
|
7892
|
+
};
|
|
7893
|
+
}
|
|
7894
|
+
function resolveCanvasColor(element, color) {
|
|
7895
|
+
const variableMatch = color.match(/^var\((--[^),\s]+)(?:,[^)]+)?\)$/);
|
|
7896
|
+
if (!variableMatch || typeof window.getComputedStyle !== "function") {
|
|
7897
|
+
return color;
|
|
7898
|
+
}
|
|
7899
|
+
const value = window.getComputedStyle(element).getPropertyValue(variableMatch[1]).trim();
|
|
7900
|
+
return value || color;
|
|
7901
|
+
}
|
|
7902
|
+
function isAnalyserSource(value) {
|
|
7903
|
+
return value != null && typeof value.frequencyBinCount === "number" && (typeof value.getFloatTimeDomainData === "function" || typeof value.getByteFrequencyData === "function");
|
|
7904
|
+
}
|
|
7905
|
+
function isMediaStreamSource(value) {
|
|
7906
|
+
return value != null && typeof value.getTracks === "function";
|
|
7907
|
+
}
|
|
7908
|
+
|
|
7117
7909
|
// ../progress-display/dist/index.js
|
|
7118
7910
|
function createProgressDisplay(props) {
|
|
7119
7911
|
const { stats, badges } = props;
|
|
@@ -8067,7 +8859,7 @@ function VersionSelector({
|
|
|
8067
8859
|
VersionSelector.displayName = "VersionSelector";
|
|
8068
8860
|
|
|
8069
8861
|
// ../resizable-layout/dist/index.js
|
|
8070
|
-
function
|
|
8862
|
+
function clamp2(value, min, max) {
|
|
8071
8863
|
return Math.min(Math.max(value, min), max);
|
|
8072
8864
|
}
|
|
8073
8865
|
function createResizableLayout(props = {}) {
|
|
@@ -8122,9 +8914,9 @@ function createResizableLayout(props = {}) {
|
|
|
8122
8914
|
if (j >= sizes.length) return;
|
|
8123
8915
|
const totalAvailable = sizesBeforeResize[i] + sizesBeforeResize[j];
|
|
8124
8916
|
let newSizeI = sizesBeforeResize[i] + delta;
|
|
8125
|
-
newSizeI =
|
|
8917
|
+
newSizeI = clamp2(newSizeI, getMinSize(i), getMaxSize(i));
|
|
8126
8918
|
let newSizeJ = totalAvailable - newSizeI;
|
|
8127
|
-
newSizeJ =
|
|
8919
|
+
newSizeJ = clamp2(newSizeJ, getMinSize(j), getMaxSize(j));
|
|
8128
8920
|
newSizeI = totalAvailable - newSizeJ;
|
|
8129
8921
|
sizes[i] = newSizeI;
|
|
8130
8922
|
sizes[j] = newSizeJ;
|
|
@@ -12928,6 +13720,13 @@ exports.CommandItem = CommandItem;
|
|
|
12928
13720
|
exports.CommandList = CommandList;
|
|
12929
13721
|
exports.CommandSeparator = CommandSeparator;
|
|
12930
13722
|
exports.ContentProtection = ContentProtection;
|
|
13723
|
+
exports.DEFAULT_VOICE_PILL_POSITION = DEFAULT_VOICE_PILL_POSITION;
|
|
13724
|
+
exports.DEFAULT_VOICE_PILL_SPEAKER = DEFAULT_VOICE_PILL_SPEAKER;
|
|
13725
|
+
exports.DEFAULT_WAVEFORM_BAR_COUNT = DEFAULT_WAVEFORM_BAR_COUNT;
|
|
13726
|
+
exports.DEFAULT_WAVEFORM_COLOR = DEFAULT_WAVEFORM_COLOR;
|
|
13727
|
+
exports.DEFAULT_WAVEFORM_HEIGHT = DEFAULT_WAVEFORM_HEIGHT;
|
|
13728
|
+
exports.DEFAULT_WAVEFORM_INTENSITY = DEFAULT_WAVEFORM_INTENSITY;
|
|
13729
|
+
exports.DEFAULT_WAVEFORM_SMOOTHING = DEFAULT_WAVEFORM_SMOOTHING;
|
|
12931
13730
|
exports.DataTable = DataTable;
|
|
12932
13731
|
exports.DatePicker = DatePicker;
|
|
12933
13732
|
exports.DeviceFrame = DeviceFrame;
|
|
@@ -13050,6 +13849,8 @@ exports.TooltipTrigger = TooltipTrigger;
|
|
|
13050
13849
|
exports.TypewriterText = TypewriterText;
|
|
13051
13850
|
exports.VersionSelector = VersionSelector;
|
|
13052
13851
|
exports.VideoPlayer = VideoPlayer;
|
|
13852
|
+
exports.VoicePill = VoicePill;
|
|
13853
|
+
exports.Waveform = Waveform;
|
|
13053
13854
|
exports.altHintState = altHintState;
|
|
13054
13855
|
exports.animatedTextVariants = animatedTextVariants;
|
|
13055
13856
|
exports.avatarFallbackVariants = avatarFallbackVariants;
|
|
@@ -13080,6 +13881,7 @@ exports.cellVariants = cellVariants;
|
|
|
13080
13881
|
exports.checkIconPath = checkIconPath;
|
|
13081
13882
|
exports.checkboxTokens = checkboxTokens;
|
|
13082
13883
|
exports.checkboxVariants = checkboxVariants;
|
|
13884
|
+
exports.clampVoicePillIntensity = clampVoicePillIntensity;
|
|
13083
13885
|
exports.codeEditorTokens = codeEditorTokens;
|
|
13084
13886
|
exports.codeEditorVariants = codeEditorVariants;
|
|
13085
13887
|
exports.collapsibleContentVariants = collapsibleContentVariants;
|
|
@@ -13095,9 +13897,14 @@ exports.commandItemVariants = commandItemVariants;
|
|
|
13095
13897
|
exports.commandVariants = commandVariants;
|
|
13096
13898
|
exports.contentProtectionVariants = contentProtectionVariants;
|
|
13097
13899
|
exports.controlsVariants = controlsVariants;
|
|
13900
|
+
exports.createIntensitySamples = createIntensitySamples;
|
|
13901
|
+
exports.createSilentSamples = createSilentSamples;
|
|
13902
|
+
exports.createVoicePill = createVoicePill;
|
|
13903
|
+
exports.createWaveform = createWaveform;
|
|
13098
13904
|
exports.dayVariants = dayVariants;
|
|
13099
13905
|
exports.deviceFrameVariants = deviceFrameVariants;
|
|
13100
13906
|
exports.dialogContentVariants = dialogContentVariants;
|
|
13907
|
+
exports.drawWaveform = drawWaveform;
|
|
13101
13908
|
exports.editorVariants = editorVariants;
|
|
13102
13909
|
exports.emojiPickerContainerStyles = emojiPickerContainerStyles;
|
|
13103
13910
|
exports.emojiPickerEmojiButtonStyles = emojiPickerEmojiButtonStyles;
|
|
@@ -13116,6 +13923,13 @@ exports.formatTimestamp = formatTimestamp;
|
|
|
13116
13923
|
exports.getAssignableRoles = getAssignableRoles;
|
|
13117
13924
|
exports.getDefaultPortal = getDefaultPortal;
|
|
13118
13925
|
exports.getInitials = getInitials;
|
|
13926
|
+
exports.getVoicePillAriaLabel = getVoicePillAriaLabel;
|
|
13927
|
+
exports.getVoicePillInitials = getVoicePillInitials;
|
|
13928
|
+
exports.getVoicePillPosition = getVoicePillPosition;
|
|
13929
|
+
exports.getVoicePillPulseStyle = getVoicePillPulseStyle;
|
|
13930
|
+
exports.getVoicePillSpeakerKey = getVoicePillSpeakerKey;
|
|
13931
|
+
exports.getVoicePillSpeakerLabel = getVoicePillSpeakerLabel;
|
|
13932
|
+
exports.getWaveformPeak = getWaveformPeak;
|
|
13119
13933
|
exports.globalShortcutRegistry = globalShortcutRegistry;
|
|
13120
13934
|
exports.hasAllRoles = hasAllRoles;
|
|
13121
13935
|
exports.hasAnyRole = hasAnyRole;
|
|
@@ -13128,6 +13942,7 @@ exports.inputGroupTokens = inputGroupTokens;
|
|
|
13128
13942
|
exports.inputGroupVariants = inputGroupVariants;
|
|
13129
13943
|
exports.inputVariants = inputVariants;
|
|
13130
13944
|
exports.installPromptVariants = installPromptVariants;
|
|
13945
|
+
exports.isWaveformSampleInput = isWaveformSampleInput;
|
|
13131
13946
|
exports.latestBadgeVariants = latestBadgeVariants;
|
|
13132
13947
|
exports.markdownRendererTokens = markdownRendererTokens;
|
|
13133
13948
|
exports.menuContentVariants = menuContentVariants;
|
|
@@ -13139,6 +13954,11 @@ exports.mobileNavTriggerVariants = mobileNavTriggerVariants;
|
|
|
13139
13954
|
exports.mobileNavVariants = mobileNavVariants;
|
|
13140
13955
|
exports.navLinkVariants = navLinkVariants;
|
|
13141
13956
|
exports.navbarVariants = navbarVariants;
|
|
13957
|
+
exports.normalizeBarCount = normalizeBarCount;
|
|
13958
|
+
exports.normalizeIntensity = normalizeIntensity;
|
|
13959
|
+
exports.normalizeSmoothing = normalizeSmoothing;
|
|
13960
|
+
exports.normalizeWaveformConfig = normalizeWaveformConfig;
|
|
13961
|
+
exports.normalizeWaveformSamples = normalizeWaveformSamples;
|
|
13142
13962
|
exports.optionVariants = optionVariants;
|
|
13143
13963
|
exports.otpInputContainerVariants = otpInputContainerVariants;
|
|
13144
13964
|
exports.otpInputSlotVariants = otpInputSlotVariants;
|
|
@@ -13147,6 +13967,7 @@ exports.overlayStyles = overlayStyles;
|
|
|
13147
13967
|
exports.overlayVariants = overlayVariants;
|
|
13148
13968
|
exports.playerVariants = playerVariants;
|
|
13149
13969
|
exports.popoverContentVariants = popoverContentVariants;
|
|
13970
|
+
exports.prepareWaveformCanvas = prepareWaveformCanvas;
|
|
13150
13971
|
exports.previewVariants = previewVariants;
|
|
13151
13972
|
exports.progressBarVariants = progressBarVariants;
|
|
13152
13973
|
exports.proseVariants = proseVariants;
|
|
@@ -13158,11 +13979,13 @@ exports.reactionBarStyles = reactionBarStyles;
|
|
|
13158
13979
|
exports.reactionCountStyles = reactionCountStyles;
|
|
13159
13980
|
exports.reactionEmojiStyles = reactionEmojiStyles;
|
|
13160
13981
|
exports.reactionPillVariants = reactionPillVariants;
|
|
13982
|
+
exports.resampleWaveformSamples = resampleWaveformSamples;
|
|
13161
13983
|
exports.resizableDividerVariants = resizableDividerVariants;
|
|
13162
13984
|
exports.resizableLayoutTokens = resizableLayoutTokens;
|
|
13163
13985
|
exports.resizableLayoutVariants = resizableLayoutVariants;
|
|
13164
13986
|
exports.resizablePaneVariants = resizablePaneVariants;
|
|
13165
13987
|
exports.rowVariants = rowVariants;
|
|
13988
|
+
exports.scaleWaveformSamples = scaleWaveformSamples;
|
|
13166
13989
|
exports.searchBarVariants = searchBarVariants;
|
|
13167
13990
|
exports.searchResultVariants = searchResultVariants;
|
|
13168
13991
|
exports.selectContentVariants = selectContentVariants;
|
|
@@ -13182,6 +14005,7 @@ exports.slideTypeBadgeVariants = slideTypeBadgeVariants;
|
|
|
13182
14005
|
exports.slideViewerProgressBarVariants = slideViewerProgressBarVariants;
|
|
13183
14006
|
exports.slideViewerTokens = slideViewerTokens;
|
|
13184
14007
|
exports.slideViewerVariants = slideViewerVariants;
|
|
14008
|
+
exports.smoothWaveformSamples = smoothWaveformSamples;
|
|
13185
14009
|
exports.statCardVariants = statCardVariants;
|
|
13186
14010
|
exports.statsGridVariants = statsGridVariants;
|
|
13187
14011
|
exports.statusContainerStyles = statusContainerStyles;
|
|
@@ -13203,6 +14027,7 @@ exports.threadContentStyles = threadContentStyles;
|
|
|
13203
14027
|
exports.threadMessageStyles = threadMessageStyles;
|
|
13204
14028
|
exports.threadReactionsStyles = threadReactionsStyles;
|
|
13205
14029
|
exports.threadTimestampStyles = threadTimestampStyles;
|
|
14030
|
+
exports.toCssDimension = toCssDimension;
|
|
13206
14031
|
exports.toastVariants = toastVariants;
|
|
13207
14032
|
exports.toolbarVariants = toolbarVariants;
|
|
13208
14033
|
exports.tooltipContentVariants = tooltipContentVariants;
|
|
@@ -13213,6 +14038,19 @@ exports.useShortcut = useShortcut;
|
|
|
13213
14038
|
exports.useToast = useToast;
|
|
13214
14039
|
exports.versionSelectorOptionVariants = versionSelectorOptionVariants;
|
|
13215
14040
|
exports.versionSelectorVariants = versionSelectorVariants;
|
|
14041
|
+
exports.voicePillAvatarStyles = voicePillAvatarStyles;
|
|
14042
|
+
exports.voicePillAvatarWrapStyles = voicePillAvatarWrapStyles;
|
|
14043
|
+
exports.voicePillLabelStyles = voicePillLabelStyles;
|
|
14044
|
+
exports.voicePillMuteButtonStyles = voicePillMuteButtonStyles;
|
|
14045
|
+
exports.voicePillPositionVariants = voicePillPositionVariants;
|
|
14046
|
+
exports.voicePillPulseRingStyles = voicePillPulseRingStyles;
|
|
14047
|
+
exports.voicePillRootStyles = voicePillRootStyles;
|
|
14048
|
+
exports.voicePillSpeakerStyles = voicePillSpeakerStyles;
|
|
14049
|
+
exports.voicePillSubStyles = voicePillSubStyles;
|
|
14050
|
+
exports.voicePillTextStyles = voicePillTextStyles;
|
|
14051
|
+
exports.voicePillTokens = voicePillTokens;
|
|
13216
14052
|
exports.watermarkVariants = watermarkVariants;
|
|
14053
|
+
exports.waveformCanvasVariants = waveformCanvasVariants;
|
|
14054
|
+
exports.waveformVariants = waveformVariants;
|
|
13217
14055
|
//# sourceMappingURL=index.cjs.map
|
|
13218
14056
|
//# sourceMappingURL=index.cjs.map
|