uitheme-web 1.1.0 → 1.2.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 CHANGED
@@ -98,48 +98,84 @@ function ThemeToggle() {
98
98
  - [TanStack Start Setup Guide](../../docs/tanstack-start-setup.md) - Isomorphic rendering, hydration-safe patterns
99
99
  - [Vite React SPA Setup Guide](../../docs/vite-setup.md) - Client-side setup, flash prevention, routing
100
100
 
101
+ ## Animated mode and palette changes
102
+
103
+ Use `switchColorTheme`, `toggleColorTheme`, or `createColorThemeToggle` for animated palettes. `setTheme` and `setColorTheme` remain immediate setters. Every provider and the standalone hook accepts the same transition options:
104
+
105
+ ```tsx
106
+ const { toggleTheme, switchColorTheme } = useTheme({
107
+ colorThemes: ['default', 'ocean', 'rose'],
108
+ });
109
+
110
+ <button onClick={(event) => void toggleTheme({
111
+ element: event.currentTarget,
112
+ animationOff: event.detail === 0,
113
+ })}>Toggle mode</button>
114
+
115
+ <button onClick={(event) => void switchColorTheme('ocean', {
116
+ element: event.currentTarget,
117
+ animationOff: event.detail === 0,
118
+ })}>Ocean palette</button>
119
+ ```
120
+
121
+ `element` uses the trigger's center. `origin: { x, y }` overrides it with viewport-relative **CSS pixels**, without multiplying by `devicePixelRatio`. Without either option, the hook uses its existing button `ref`; attach a shared ref to only one trigger. Slide transitions need no trigger. Boolean calls such as `toggleTheme(true)` still disable animation.
122
+
123
+ `ThemeTransitionInput` is `boolean | { element?: Element | null; origin?: { x: number; y: number }; animationOff?: boolean }`. Color helpers now return `Promise<void>`; existing fire-and-forget calls still work. `toggleColorTheme` and `createColorThemeToggle('ocean')` can be used directly as `onClick`, reading the clicked element and skipping keyboard motion.
124
+
125
+ The default is 400 ms with `cubic-bezier(0.32, 0.72, 0, 1)`: a steep curve for a full-viewport reveal. Explicit durations are respected at every display size. `blurAmount` is now a feather width in CSS pixels, capped at 20 px; the gradient softens the edge without blurring the page content. Unsupported browsers, failed/skipped captures, missing circle origins, and reduced motion apply the theme without a reveal. New requests interrupt older transitions; CSS transitions are suppressed only during library-owned captures and playback.
126
+
127
+ Core consumers can call `runThemeTransition(update, config)` to handle capture, scoped styles, interruption, and cleanup. The React hook uses this runner internally. Low-level animation helpers should be called **after** `transition.ready` with caller-managed pseudo-element styles. They return native `Animation` handles; cancel them when done. `styleId` remains accepted for compatibility; the native animation path no longer creates a timer-owned stylesheet with that ID.
128
+
129
+ [Research, browser verification, and performance evidence](../../docs/theme-transition-verification.md).
130
+
101
131
  ## API Reference
102
132
 
103
133
  ### Shared Hook Return (All Providers)
104
134
 
105
135
  All providers expose the same hook interface:
106
136
 
107
- | Property | Type | Description |
108
- | ---------------------- | ------------------------------------------------------- | ---------------------------------- |
109
- | theme | Theme | Current theme |
110
- | colorTheme | ColorTheme | Current color theme |
111
- | resolvedTheme | 'light' \| 'dark' | Resolved theme (system → actual) |
112
- | systemTheme | 'light' \| 'dark' | OS theme preference |
113
- | ref | RefObject<HTMLElement> | Ref for animation origin |
114
- | setTheme | (theme: Theme) => void | Set theme instantly |
115
- | setColorTheme | (colorTheme: ColorTheme) => void | Set color theme |
116
- | switchTheme | (theme: Theme, animationOff?: boolean) => Promise<void> | Switch with animation |
117
- | switchColorTheme | (colorTheme: string) => void | Switch color theme with animation |
118
- | toggleTheme | (animationOff?: boolean) => Promise<void> | Toggle light/dark |
119
- | toggleLightTheme | (animationOff?: boolean) => Promise<void> | Toggle to light |
120
- | toggleDarkTheme | (animationOff?: boolean) => Promise<void> | Toggle to dark |
121
- | toggleColorTheme | () => void | Toggle between color themes |
122
- | createColorThemeToggle | (colorTheme: string) => () => void | Create color theme toggle |
123
- | isColorThemeActive | (colorTheme: string) => boolean | Check if color theme active |
124
- | switchThemeFromElement | (theme: Theme, element: HTMLElement) => Promise<void> | Switch with animation from element |
137
+ | Property | Type | Description |
138
+ | ---------------------- | --------------------------------------------------------------------- | ---------------------------------- |
139
+ | theme | Theme | Current theme |
140
+ | colorTheme | ColorTheme | Current color theme |
141
+ | resolvedTheme | 'light' \| 'dark' | Resolved theme (system → actual) |
142
+ | systemTheme | 'light' \| 'dark' | OS theme preference |
143
+ | ref | RefObject<HTMLElement> | Ref for animation origin |
144
+ | setTheme | (theme: Theme) => void | Set theme instantly |
145
+ | setColorTheme | (colorTheme: ColorTheme) => void | Set color theme |
146
+ | switchTheme | (theme: Theme, options?: ThemeTransitionInput) => Promise<void> | Switch with animation |
147
+ | switchColorTheme | (colorTheme: string, options?: ThemeTransitionInput) => Promise<void> | Switch color theme with animation |
148
+ | toggleTheme | (options?: ThemeTransitionInput) => Promise<void> | Toggle light/dark |
149
+ | toggleLightTheme | (options?: ThemeTransitionInput) => Promise<void> | Toggle to light |
150
+ | toggleDarkTheme | (options?: ThemeTransitionInput) => Promise<void> | Toggle to dark |
151
+ | toggleColorTheme | ColorThemeToggle | Toggle between color themes |
152
+ | createColorThemeToggle | (colorTheme: string) => ColorThemeToggle | Create color theme toggle |
153
+ | isColorThemeActive | (colorTheme: string) => boolean | Check if color theme active |
154
+ | switchThemeFromElement | (theme: Theme, element: HTMLElement) => Promise<void> | Switch with animation from element |
125
155
 
126
156
  ### Provider Props
127
157
 
128
- | Prop | UITheme | NextUITheme | TanStackUITheme | ViteUITheme | Type | Default |
129
- | ------------------------- | ------- | ----------- | --------------- | ----------- | ------------------ | --------------------------- |
130
- | defaultTheme | ✓ | ✓ | ✓ | ✓ | Theme | 'system' |
131
- | defaultColorTheme | ✓ | ✓ | ✓ | ✓ | ColorTheme | 'default' |
132
- | themes | ✓ | ✓ | ✓ | ✓ | Theme[] | ['light', 'dark', 'system'] |
133
- | colorThemes | ✓ | ✓ | ✓ | ✓ | ColorTheme[] | ['default'] |
134
- | animationType | ✓ | ✓ | ✓ | ✓ | ThemeAnimationType | CIRCLE |
135
- | duration | ✓ | ✓ | ✓ | ✓ | number | 500 |
136
- | storageKey | ✓ | ✓ | ✓ | ✓ | string | varies |
137
- | colorStorageKey | ✓ | ✓ | ✓ | ✓ | string | varies |
138
- | nonce | ✗ | ✓ | ✗ | ✗ | string | - |
139
- | disablePreHydrationScript | ✗ | ✓ | ✗ | ✗ | boolean | false |
140
- | disableTransitionOnChange | ✗ | ✗ | ✗ | ✓ | boolean | false |
141
- | onThemeChange | ✓ | ✓ | ✓ | ✓ | function | - |
142
- | onColorThemeChange | ✓ | ✓ | ✓ | ✓ | function | - |
158
+ | Prop | UITheme | NextUITheme | TanStackUITheme | ViteUITheme | Type | Default |
159
+ | ------------------------- | ------- | ----------- | --------------- | ----------- | ------------------- | --------------------------- |
160
+ | defaultTheme | ✓ | ✓ | ✓ | ✓ | Theme | 'system' |
161
+ | defaultColorTheme | ✓ | ✓ | ✓ | ✓ | ColorTheme | 'default' |
162
+ | themes | ✓ | ✓ | ✓ | ✓ | Theme[] | ['light', 'dark', 'system'] |
163
+ | colorThemes | ✓ | ✓ | ✓ | ✓ | ColorTheme[] | ['default'] |
164
+ | animationType | ✓ | ✓ | ✓ | ✓ | ThemeAnimationType | CIRCLE |
165
+ | clipPathDirection | ✓ | ✓ | ✓ | ✓ | TransitionDirection | 'top-left' |
166
+ | animationPosition | ✓ | ✓ | ✓ | ✓ | AnimationPosition | trigger / center fallback |
167
+ | logo | ✓ | ✓ | ✓ | ✓ | string (SVG URL) | - |
168
+ | logoWidth | ✓ | ✓ | ✓ | ✓ | number or "auto" | 96 / aspect ratio |
169
+ | logoHeight | ✓ | ✓ | ✓ | ✓ | number or "auto" | aspect ratio |
170
+ | gradientWidth | ✓ | ✓ | ✓ | ✓ | number (CSS px) | 80 |
171
+ | duration | ✓ | ✓ | ✓ | ✓ | number | 400 |
172
+ | storageKey | ✓ | ✓ | ✓ | ✓ | string | varies |
173
+ | colorStorageKey | ✓ | ✓ | ✓ | ✓ | string | varies |
174
+ | nonce | ✗ | ✓ | ✗ | ✗ | string | - |
175
+ | disablePreHydrationScript | ✗ | ✓ | ✗ | ✗ | boolean | false |
176
+ | disableTransitionOnChange | ✗ | ✗ | ✗ | ✓ | boolean | false |
177
+ | onThemeChange | ✓ | ✓ | ✓ | ✓ | function | - |
178
+ | onColorThemeChange | ✓ | ✓ | ✓ | ✓ | function | - |
143
179
 
144
180
  ### Components
145
181
 
@@ -191,10 +227,10 @@ Define theme variables in your global CSS file:
191
227
  <details>
192
228
  <summary>Browser Support</summary>
193
229
 
194
- - View Transitions API: Chrome 111+, Edge 111+
195
- - Fallback: All modern browsers with CSS transitions
230
+ - Animated reveals require View Transitions and animation of transition pseudo-elements.
231
+ - Fallback: unsupported browsers apply the theme immediately.
196
232
  - Reduced Motion: Respects prefers-reduced-motion
197
- - Framework Support: React 16.8+ (hooks required)
233
+ - Framework Support: React 18+
198
234
 
199
235
  </details>
200
236
 
@@ -203,6 +239,70 @@ Define theme variables in your global CSS file:
203
239
 
204
240
  ### Animation Control
205
241
 
242
+ Choose `CIRCLE`, `BLUR_CIRCLE`, `SLIDE`, `CLIP_PATH`, `POLYGON_GRADIENT`,
243
+ `TRIANGLE`, or `SVG_LOGO` from `ThemeAnimationType`. All effects also apply to
244
+ animated color-palette changes. GIF effects are not included.
245
+
246
+ ```tsx
247
+ import { ThemeAnimationType, UIThemeProvider } from 'uitheme-web/react';
248
+
249
+ <UIThemeProvider
250
+ animationType={ThemeAnimationType.CLIP_PATH}
251
+ clipPathDirection="top-right"
252
+ duration={400}
253
+ >
254
+ <App />
255
+ </UIThemeProvider>;
256
+ ```
257
+
258
+ `CLIP_PATH` is a sharp polygon wipe; `POLYGON_GRADIENT` feathers its leading edge.
259
+ Both accept `clipPathDirection` in clockwise order: `top-left`, `top`,
260
+ `top-right`, `right`, `bottom-right`, `bottom`, `bottom-left`, `left`.
261
+ `POLYGON_GRADIENT` also accepts `gradientWidth` (default: 80 CSS pixels, capped
262
+ relative to the mask size).
263
+
264
+ For circle, blurred circle, or triangle effects, `animationPosition` can be
265
+ any of those eight positions, `center`, or `trigger`. The trigger uses the clicked
266
+ element or attached ref. Triangle effects fall back to the viewport
267
+ center when no trigger is available. An explicit per-call `origin` takes precedence.
268
+
269
+ ### SVG logo transition
270
+
271
+ Pass a self-contained SVG file URL, such as `/brand.svg`, a bundler asset import,
272
+ or a blob URL created from a file input. The SVG is displayed at a fixed size in
273
+ the viewport center while a circular theme reveal expands underneath it. The
274
+ logo stays still and fades out over the final 15% of the transition.
275
+
276
+ ```tsx
277
+ <UIThemeProvider
278
+ animationType={ThemeAnimationType.SVG_LOGO}
279
+ logo="/brand.svg"
280
+ logoWidth={120}
281
+ duration={600}
282
+ >
283
+ <App />
284
+ </UIThemeProvider>
285
+ ```
286
+
287
+ `logoWidth` and `logoHeight` accept positive CSS-pixel dimensions or `"auto"`. Either dimension
288
+ alone preserves the SVG aspect ratio; both dimensions define a box with
289
+ `object-fit: contain`. Without either, width defaults to 96 px. The SVG effect
290
+ always uses the viewport center, including when a trigger or another animation
291
+ position is provided. The logo retains its artwork colors.
292
+
293
+ The hook preloads and decodes the logo before capture. If it is still loading,
294
+ invalid, unavailable, or not an SVG, that toggle uses the circle effect instead
295
+ of waiting. Core consumers can `await preloadThemeLogo(url)` before starting a
296
+ transition. Use transparent backgrounds and a suitable `viewBox`; preserve the
297
+ logo's intrinsic aspect ratio. SVG markup is loaded as an image, never inserted
298
+ into the page.
299
+
300
+ These options work with all four providers, `useTheme`, `UIThemeSwitcher`, and
301
+ `UIThemeSelector`. Reduced motion applies the theme immediately.
302
+
303
+ See [animation options and browser verification](../../docs/theme-animation-options.md)
304
+ for the effect gallery, research, and testing boundaries.
305
+
206
306
  ```tsx
207
307
  const { switchTheme, toggleTheme } = useUITheme();
208
308
 
@@ -242,3 +342,16 @@ const { theme, toggleTheme, ref } = useTheme({
242
342
  ## License
243
343
 
244
344
  MIT
345
+
346
+ Use `logoLight` and `logoDark` together instead of `logo` to select the current theme’s asset: `logoDark` for dark-to-light, `logoLight` for light-to-dark. Use a light or white `logoDark` on the dark interface and a dark or black `logoLight` on the light interface. Both are required; combining the pair with `logo` is rejected.
347
+
348
+ When one dimension is set and the other omitted, the omitted dimension defaults to `"auto"` and preserves the SVG aspect ratio. Explicit `"auto"` for both uses the SVG’s intrinsic size. With both omitted, the existing 96 px default width is preserved.
349
+
350
+ All built-in controls share the active state from any of the four providers.
351
+ Outside a provider, they own their standalone state. Keyboard selection inside
352
+ the dropdown portal skips moving reveals.
353
+
354
+ `useHydrated()` is exported from `uitheme-web/react`. For TanStack server/cookie
355
+ callbacks, use `onServerError={(error) => ...}` to observe failed notifications;
356
+ otherwise failures are reported through `console.error` without unhandled promise
357
+ rejections.
@@ -0,0 +1,12 @@
1
+ import {q as q$1,r,f,g as g$1,a,o,p,j,k as k$1,l,m,n}from'./chunk-WFG34KG5.js';var A=(r=>(r.CIRCLE="circle",r.BLUR_CIRCLE="blur-circle",r.SLIDE="slide",r.CLIP_PATH="clip-path",r.POLYGON_GRADIENT="polygon-gradient",r.TRIANGLE="triangle",r.SVG_LOGO="svg-logo",r))(A||{}),D=["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"];var O=e=>{if(e.logoLight!==void 0||e.logoDark!==void 0){if(!e.logoLight||!e.logoDark)throw new Error("logoLight and logoDark must both be provided.");if(e.logo!==void 0)throw new Error("Use logo or the logoLight/logoDark pair, not both.");return {logoLight:e.logoLight,logoDark:e.logoDark}}return {logo:e.logo}},E=0,S=e=>{let t=I(e.logo);if(!t)return;let n=e.logoWidth!=="auto"&&e.logoWidth&&Number.isFinite(e.logoWidth)&&e.logoWidth>0?e.logoWidth:void 0,o=e.logoHeight!=="auto"&&e.logoHeight&&Number.isFinite(e.logoHeight)&&e.logoHeight>0?e.logoHeight:void 0,a=n??(o?o*t.aspectRatio:e.logoWidth==="auto"||e.logoHeight==="auto"?t.naturalWidth:96),i=o??a/t.aspectRatio,s=`ui-theme-logo-${++E}`,r=document.createElement("img");r.src=t.image,r.alt="",r.setAttribute("aria-hidden","true"),r.setAttribute("data-ui-theme-logo",""),r.style.cssText=`position:fixed;left:calc(50% - ${a/2}px);top:calc(50% - ${i/2}px);width:${a}px;height:${i}px;max-width:none;max-height:none;object-fit:contain;display:block;margin:0;padding:0;border:0;transform:none;pointer-events:none;z-index:2147483647;view-transition-name:${s};`;let m=document.createElement("style");return m.setAttribute("data-ui-theme-logo-style",""),m.textContent=`
2
+ @keyframes ${s}-fade { 0%, 85% { opacity:1; } 100% { opacity:0; } }
3
+ html[data-ui-theme-transition]::view-transition-group(${s}) {
4
+ z-index:2;
5
+ animation:${s}-fade ${e.duration}ms linear both;
6
+ }
7
+ html[data-ui-theme-transition]::view-transition-old(${s}) { display:none; }
8
+ html[data-ui-theme-transition]::view-transition-new(${s}) {
9
+ animation:none; mix-blend-mode:normal;
10
+ }
11
+ `,document.head.appendChild(m),document.documentElement.appendChild(r),{element:r,style:m}},u=new Map,k=e=>{if(typeof window>"u")return Promise.resolve();let t=u.get(e);if(t)return t.loading;let n={loading:Promise.resolve()};return u.set(e,n),n.loading=(async()=>{let o=new AbortController,a=setTimeout(()=>o.abort(),2e3);try{let i=await fetch(e,{signal:o.signal});if(!i.ok)return;let s=await i.text(),r=new DOMParser().parseFromString(s,"image/svg+xml");if(r.querySelector("parsererror")||r.documentElement.localName!=="svg"||r.documentElement.namespaceURI!=="http://www.w3.org/2000/svg")return;let m=`data:image/svg+xml,${encodeURIComponent(s)}`,l=new Image;l.src=m,await l.decode(),l.naturalWidth>0&&l.naturalHeight>0&&(n.ready={image:m,naturalWidth:l.naturalWidth,aspectRatio:l.naturalWidth/l.naturalHeight});}catch{}finally{clearTimeout(a);}})(),n.loading},I=e=>e?u.get(e)?.ready:void 0;var g=new WeakMap,G=async(e,t)=>{if(typeof document>"u"){e();return}let n$1=g.get(document);n$1?.transition?.skipTransition(),n$1?.animation?.cancel(),n$1?.logo?.element.remove(),n$1?.logo?.style.remove();let o$1={updateDone:Promise.resolve()};g.set(document,o$1);let a$1=()=>{o$1.animation?.cancel(),o$1.logo?.element.remove(),o$1.logo?.style.remove(),g.get(document)===o$1&&(g.delete(document),document.documentElement.removeAttribute("data-ui-theme-transition"));};o$1.updateDone=(async()=>{if(n$1&&await n$1.updateDone.catch(()=>{}),g.get(document)!==o$1||!t||!f()||g$1()||document.visibilityState==="hidden"){e();return}a(),document.documentElement.setAttribute("data-ui-theme-transition",""),t.animationType==="svg-logo"&&(o$1.logo=S(t));let i;try{i=document.startViewTransition(e);}catch{e();return}o$1.transition=i,i.ready.catch(()=>{}),i.finished.then(a$1,a$1),await i.updateCallbackDone;})();try{await o$1.updateDone;let i=o$1.transition;if(!i){a$1();return}try{await i.ready;}catch{a$1();return}if(g.get(document)!==o$1){i.skipTransition();return}if(!t)return;try{o$1.animation=t.animationType==="slide"?o(t):t.animationType==="blur-circle"?p(t):t.animationType==="clip-path"?j(t):t.animationType==="polygon-gradient"?k$1(t):t.animationType==="triangle"?l(t):t.animationType==="svg-logo"?m(t):n(t),o$1.animation.finished.catch(()=>{});let s=o$1.animation.effect;!(o$1.animation instanceof CSSAnimation)&&(!(s instanceof KeyframeEffect)||s.pseudoElement!=="::view-transition-new(root)")&&(i.skipTransition(),a$1());}catch{i.skipTransition(),a$1();}}catch(i){throw a$1(),i}};var d=typeof window<"u",$=(e=q$1,t=["light","dark","system"],n="system")=>{if(!d)return n;let o;try{o=localStorage.getItem(e);}catch{return n}return t.find(a=>a===o)??n},q=(e,t=q$1)=>{d&&localStorage.setItem(t,e);},V=(e=r,t=["default"],n="default")=>{if(!d)return n;let o;try{o=localStorage.getItem(e);}catch{return n}return o&&t.includes(o)?o:n},M=(e,t=r)=>{d&&localStorage.setItem(t,e);};
12
+ export{A as a,D as b,O as c,k as d,G as e,$ as f,q as g,V as h,M as i};
@@ -0,0 +1,12 @@
1
+ 'use strict';var chunkW4YFUPGE_cjs=require('./chunk-W4YFUPGE.cjs');var A=(r=>(r.CIRCLE="circle",r.BLUR_CIRCLE="blur-circle",r.SLIDE="slide",r.CLIP_PATH="clip-path",r.POLYGON_GRADIENT="polygon-gradient",r.TRIANGLE="triangle",r.SVG_LOGO="svg-logo",r))(A||{}),D=["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"];var O=e=>{if(e.logoLight!==void 0||e.logoDark!==void 0){if(!e.logoLight||!e.logoDark)throw new Error("logoLight and logoDark must both be provided.");if(e.logo!==void 0)throw new Error("Use logo or the logoLight/logoDark pair, not both.");return {logoLight:e.logoLight,logoDark:e.logoDark}}return {logo:e.logo}},E=0,S=e=>{let t=I(e.logo);if(!t)return;let n=e.logoWidth!=="auto"&&e.logoWidth&&Number.isFinite(e.logoWidth)&&e.logoWidth>0?e.logoWidth:void 0,o=e.logoHeight!=="auto"&&e.logoHeight&&Number.isFinite(e.logoHeight)&&e.logoHeight>0?e.logoHeight:void 0,a=n??(o?o*t.aspectRatio:e.logoWidth==="auto"||e.logoHeight==="auto"?t.naturalWidth:96),i=o??a/t.aspectRatio,s=`ui-theme-logo-${++E}`,r=document.createElement("img");r.src=t.image,r.alt="",r.setAttribute("aria-hidden","true"),r.setAttribute("data-ui-theme-logo",""),r.style.cssText=`position:fixed;left:calc(50% - ${a/2}px);top:calc(50% - ${i/2}px);width:${a}px;height:${i}px;max-width:none;max-height:none;object-fit:contain;display:block;margin:0;padding:0;border:0;transform:none;pointer-events:none;z-index:2147483647;view-transition-name:${s};`;let m=document.createElement("style");return m.setAttribute("data-ui-theme-logo-style",""),m.textContent=`
2
+ @keyframes ${s}-fade { 0%, 85% { opacity:1; } 100% { opacity:0; } }
3
+ html[data-ui-theme-transition]::view-transition-group(${s}) {
4
+ z-index:2;
5
+ animation:${s}-fade ${e.duration}ms linear both;
6
+ }
7
+ html[data-ui-theme-transition]::view-transition-old(${s}) { display:none; }
8
+ html[data-ui-theme-transition]::view-transition-new(${s}) {
9
+ animation:none; mix-blend-mode:normal;
10
+ }
11
+ `,document.head.appendChild(m),document.documentElement.appendChild(r),{element:r,style:m}},u=new Map,k=e=>{if(typeof window>"u")return Promise.resolve();let t=u.get(e);if(t)return t.loading;let n={loading:Promise.resolve()};return u.set(e,n),n.loading=(async()=>{let o=new AbortController,a=setTimeout(()=>o.abort(),2e3);try{let i=await fetch(e,{signal:o.signal});if(!i.ok)return;let s=await i.text(),r=new DOMParser().parseFromString(s,"image/svg+xml");if(r.querySelector("parsererror")||r.documentElement.localName!=="svg"||r.documentElement.namespaceURI!=="http://www.w3.org/2000/svg")return;let m=`data:image/svg+xml,${encodeURIComponent(s)}`,l=new Image;l.src=m,await l.decode(),l.naturalWidth>0&&l.naturalHeight>0&&(n.ready={image:m,naturalWidth:l.naturalWidth,aspectRatio:l.naturalWidth/l.naturalHeight});}catch{}finally{clearTimeout(a);}})(),n.loading},I=e=>e?u.get(e)?.ready:void 0;var g=new WeakMap,G=async(e,t)=>{if(typeof document>"u"){e();return}let n=g.get(document);n?.transition?.skipTransition(),n?.animation?.cancel(),n?.logo?.element.remove(),n?.logo?.style.remove();let o={updateDone:Promise.resolve()};g.set(document,o);let a=()=>{o.animation?.cancel(),o.logo?.element.remove(),o.logo?.style.remove(),g.get(document)===o&&(g.delete(document),document.documentElement.removeAttribute("data-ui-theme-transition"));};o.updateDone=(async()=>{if(n&&await n.updateDone.catch(()=>{}),g.get(document)!==o||!t||!chunkW4YFUPGE_cjs.f()||chunkW4YFUPGE_cjs.g()||document.visibilityState==="hidden"){e();return}chunkW4YFUPGE_cjs.a(),document.documentElement.setAttribute("data-ui-theme-transition",""),t.animationType==="svg-logo"&&(o.logo=S(t));let i;try{i=document.startViewTransition(e);}catch{e();return}o.transition=i,i.ready.catch(()=>{}),i.finished.then(a,a),await i.updateCallbackDone;})();try{await o.updateDone;let i=o.transition;if(!i){a();return}try{await i.ready;}catch{a();return}if(g.get(document)!==o){i.skipTransition();return}if(!t)return;try{o.animation=t.animationType==="slide"?chunkW4YFUPGE_cjs.o(t):t.animationType==="blur-circle"?chunkW4YFUPGE_cjs.p(t):t.animationType==="clip-path"?chunkW4YFUPGE_cjs.j(t):t.animationType==="polygon-gradient"?chunkW4YFUPGE_cjs.k(t):t.animationType==="triangle"?chunkW4YFUPGE_cjs.l(t):t.animationType==="svg-logo"?chunkW4YFUPGE_cjs.m(t):chunkW4YFUPGE_cjs.n(t),o.animation.finished.catch(()=>{});let s=o.animation.effect;!(o.animation instanceof CSSAnimation)&&(!(s instanceof KeyframeEffect)||s.pseudoElement!=="::view-transition-new(root)")&&(i.skipTransition(),a());}catch{i.skipTransition(),a();}}catch(i){throw a(),i}};var d=typeof window<"u",$=(e=chunkW4YFUPGE_cjs.q,t=["light","dark","system"],n="system")=>{if(!d)return n;let o;try{o=localStorage.getItem(e);}catch{return n}return t.find(a=>a===o)??n},q=(e,t=chunkW4YFUPGE_cjs.q)=>{d&&localStorage.setItem(t,e);},V=(e=chunkW4YFUPGE_cjs.r,t=["default"],n="default")=>{if(!d)return n;let o;try{o=localStorage.getItem(e);}catch{return n}return o&&t.includes(o)?o:n},M=(e,t=chunkW4YFUPGE_cjs.r)=>{d&&localStorage.setItem(t,e);};
12
+ exports.a=A;exports.b=D;exports.c=O;exports.d=k;exports.e=G;exports.f=$;exports.g=q;exports.h=V;exports.i=M;
@@ -0,0 +1,18 @@
1
+ 'use strict';var x=typeof window<"u",k=()=>{if(!x||document.getElementById("ui-theme-base-style"))return;let t=document.createElement("style");t.id="ui-theme-base-style",t.textContent=`
2
+ html[data-ui-theme-transition]::view-transition-group(root),
3
+ html[data-ui-theme-transition]::view-transition-old(root),
4
+ html[data-ui-theme-transition]::view-transition-new(root) {
5
+ animation: none;
6
+ }
7
+ html[data-ui-theme-transition]::view-transition-old(root),
8
+ html[data-ui-theme-transition]::view-transition-new(root) {
9
+ mix-blend-mode: normal;
10
+ }
11
+ html[data-ui-theme-transition],
12
+ html[data-ui-theme-transition] *,
13
+ html[data-ui-theme-transition] *::before,
14
+ html[data-ui-theme-transition] *::after {
15
+ transition: none !important;
16
+ }
17
+ `,document.head.appendChild(t);},E=t=>`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="-50 -50 100 100"><defs>${`<filter id="blur"><feGaussianBlur stdDeviation="${t}" /></filter>`}</defs><circle cx="0" cy="0" r="25" fill="white" filter="url(%23blur)"/></svg>')`,C=()=>x&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",M=t=>t==="system"?C():t==="dark"?"dark":"light",R=t=>t==="system"?"system":t==="dark"?"dark":"light",T=()=>x&&document.startViewTransition instanceof Function,P=()=>x&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,D=t=>{switch(t){case "left":return {a:-100,b:0};case "right":return {a:100,b:0};case "top":return {a:0,b:-100};case "bottom":return {a:0,b:100};case "top-left":return {a:-100,b:-100};case "top-right":return {a:100,b:-100};case "bottom-left":return {a:-100,b:100};case "bottom-right":return {a:100,b:100};default:return {a:-100,b:0}}},y=()=>{let t=getComputedStyle(document.documentElement,"::view-transition-new(root)"),n=Math.max(window.innerWidth,parseFloat(t.width)||0),e=Math.max(window.innerHeight,parseFloat(t.height)||0);return {width:n,height:e}},w=(t,n)=>{let{width:e,height:o}=y();return Math.hypot(Math.max(Math.abs(t),Math.abs(e-t)),Math.max(Math.abs(n),Math.abs(o-n)))+1},L=t=>{let n=t.includes("left")?0:t.includes("right")?window.innerWidth:window.innerWidth/2,e=t.includes("top")?0:t.includes("bottom")?window.innerHeight:window.innerHeight/2;return {x:n,y:e}},S=0,h=(t,n)=>{let e=document.documentElement.animate(n,{duration:t.duration,easing:t.easing,fill:"both",pseudoElement:"::view-transition-new(root)"}),o=e.effect;if(!(o instanceof KeyframeEffect))return e;let i=o.getKeyframes(),d=i.some(c=>"clipPath"in c)?"clipPath":i.some(c=>"maskImage"in c)?"maskImage":"transform";if(getComputedStyle(document.documentElement,"::view-transition-new(root)")[d]!=="none")return e;let l=e.playState==="paused",s=e.currentTime;e.cancel(),e.finished.catch(()=>{});let a=`ui-theme-reveal-${++S}`,r=document.createElement("style"),m=i.map(c=>{let $=Object.entries(c).filter(([u])=>!["offset","computedOffset","easing","composite"].includes(u)).map(([u,A])=>`${u.replace(/[A-Z]/g,v=>`-${v.toLowerCase()}`)}:${A};`).join("");return `${c.computedOffset*100}%{${$}}`}).join("");r.textContent=`@keyframes ${a}{${m}}html[data-ui-theme-transition]::view-transition-new(root){animation:${a} ${t.duration}ms ${t.easing} both;}`,document.head.appendChild(r);let f=getComputedStyle(document.documentElement,"::view-transition-new(root)").animationName,p=document.getAnimations().find(c=>c instanceof CSSAnimation&&c.animationName===f);if(!p)throw r.remove(),new Error("Transition pseudo animations are unavailable");return l&&(p.pause(),p.currentTime=s),p.finished.then(()=>r.remove(),()=>r.remove()),p},O=t=>{let n=t.clipPathDirection??"top-left",e={"top-left":"polygon(-1% -1%, 101% -101%, -101% 101%, -1% -1%)",top:"polygon(-1% -1%, 101% -1%, 101% -1%, -1% -1%)","top-right":"polygon(101% -1%, 201% 101%, -1% -101%, 101% -1%)",right:"polygon(101% -1%, 101% 101%, 101% 101%, 101% -1%)","bottom-right":"polygon(101% 101%, -1% 201%, 201% -1%, 101% 101%)",bottom:"polygon(101% 101%, -1% 101%, -1% 101%, 101% 101%)","bottom-left":"polygon(-1% 101%, -101% -1%, 101% 201%, -1% 101%)",left:"polygon(-1% 101%, -1% -1%, -1% -1%, -1% 101%)"},o={"top-left":"polygon(-1% -1%, 201% -1%, -1% 201%, -1% -1%)",top:"polygon(-1% -1%, 101% -1%, 101% 101%, -1% 101%)","top-right":"polygon(101% -1%, 101% 201%, -101% -1%, 101% -1%)",right:"polygon(101% -1%, 101% 101%, -1% 101%, -1% -1%)","bottom-right":"polygon(101% 101%, -101% 101%, 101% -101%, 101% 101%)",bottom:"polygon(101% 101%, -1% 101%, -1% -1%, 101% -1%)","bottom-left":"polygon(-1% 101%, -1% -101%, 201% 101%, -1% 101%)",left:"polygon(-1% 101%, -1% -1%, 101% -1%, 101% 101%)"};return h(t,{clipPath:[e[n],o[n]]})},_=t=>{let n=t.clipPathDirection??"top-left",{width:e,height:o}=y(),i=n.includes("-"),d=n.includes("left"),g=n.includes("top"),l=n==="left"||n==="right",s=d?0:n.includes("right")?1:.5,a=g?0:n.includes("bottom")?1:.5,r=i||l?e*3:e,m=i||!l?o*3:o,f=i?`${s*100},${a*100} ${(1-s)*100},${a*100} ${s*100},${(1-a)*100}`:"0,0 100,0 100,100 0,100",p=i?r*m/Math.hypot(r,m):l?r:m,$=1-Math.max(0,Math.min(t.gradientWidth??80,p*.2))/p,u=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><defs><linearGradient id="edge" x1="${s*100}" y1="${a*100}" x2="${100*(i?.5:l?1-s:s)}" y2="${100*(i?.5:l?a:1-a)}" gradientUnits="userSpaceOnUse"><stop offset="${$}" stop-color="black"/><stop offset="1" stop-color="black" stop-opacity="0"/></linearGradient></defs><polygon points="${f}" fill="url(#edge)"/></svg>`;return h(t,{maskImage:[`url("data:image/svg+xml,${encodeURIComponent(u)}")`,`url("data:image/svg+xml,${encodeURIComponent(u)}")`],maskMode:["alpha","alpha"],maskRepeat:["no-repeat","no-repeat"],maskSize:[i?"0px 0px":l?`0px ${m}px`:`${r}px 0px`,`${r}px ${m}px`],maskPosition:[`${s*e}px ${a*o}px`,`${s*(e-r)}px ${a*(o-m)}px`]})},F=t=>{let{x:n,y:e}=t,o=w(n,e),i=Math.sqrt(3)*o;return h(t,{clipPath:[`polygon(${n}px ${e}px, ${n}px ${e}px, ${n}px ${e}px)`,`polygon(${n}px ${e-2*o}px, ${n+i}px ${e+o}px, ${n-i}px ${e+o}px)`]})},I=t=>{let{width:n,height:e}=y();return b({...t,x:n/2,y:e/2})},b=t=>{let{x:n,y:e}=t;return h(t,{clipPath:[`circle(0px at ${n}px ${e}px)`,`circle(${w(n,e)}px at ${n}px ${e}px)`]})},U=t=>{let{a:n=-100,b:e=0,x:o=0,y:i=0}=t;return h(t,{transform:[`translate(${n}%, ${e}%)`,`translate(${o}%, ${i}%)`]})},B=t=>{let{x:n,y:e,blurAmount:o}=t;if(o<=0)return b(t);let i=Math.min(o,20),d=w(n,e)+i,g=d*2;return h(t,{maskImage:[`radial-gradient(closest-side, #000 calc(100% - ${i}px), transparent 100%)`,`radial-gradient(closest-side, #000 calc(100% - ${i}px), transparent 100%)`],maskRepeat:["no-repeat","no-repeat"],maskSize:["0px 0px",`${g}px ${g}px`],maskPosition:[`${n}px ${e}px`,`${n-d}px ${e-d}px`]})};var N="theme",K="color-theme",z="dark",j="theme-",H=400,W="cubic-bezier(0.32, 0.72, 0, 1)",Y=2,q="ui-theme-style";
18
+ exports.a=k;exports.b=E;exports.c=C;exports.d=M;exports.e=R;exports.f=T;exports.g=P;exports.h=D;exports.i=L;exports.j=O;exports.k=_;exports.l=F;exports.m=I;exports.n=b;exports.o=U;exports.p=B;exports.q=N;exports.r=K;exports.s=z;exports.t=j;exports.u=H;exports.v=W;exports.w=Y;exports.x=q;
@@ -0,0 +1,18 @@
1
+ var x=typeof window<"u",k=()=>{if(!x||document.getElementById("ui-theme-base-style"))return;let t=document.createElement("style");t.id="ui-theme-base-style",t.textContent=`
2
+ html[data-ui-theme-transition]::view-transition-group(root),
3
+ html[data-ui-theme-transition]::view-transition-old(root),
4
+ html[data-ui-theme-transition]::view-transition-new(root) {
5
+ animation: none;
6
+ }
7
+ html[data-ui-theme-transition]::view-transition-old(root),
8
+ html[data-ui-theme-transition]::view-transition-new(root) {
9
+ mix-blend-mode: normal;
10
+ }
11
+ html[data-ui-theme-transition],
12
+ html[data-ui-theme-transition] *,
13
+ html[data-ui-theme-transition] *::before,
14
+ html[data-ui-theme-transition] *::after {
15
+ transition: none !important;
16
+ }
17
+ `,document.head.appendChild(t);},E=t=>`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="-50 -50 100 100"><defs>${`<filter id="blur"><feGaussianBlur stdDeviation="${t}" /></filter>`}</defs><circle cx="0" cy="0" r="25" fill="white" filter="url(%23blur)"/></svg>')`,C=()=>x&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",M=t=>t==="system"?C():t==="dark"?"dark":"light",R=t=>t==="system"?"system":t==="dark"?"dark":"light",T=()=>x&&document.startViewTransition instanceof Function,P=()=>x&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,D=t=>{switch(t){case "left":return {a:-100,b:0};case "right":return {a:100,b:0};case "top":return {a:0,b:-100};case "bottom":return {a:0,b:100};case "top-left":return {a:-100,b:-100};case "top-right":return {a:100,b:-100};case "bottom-left":return {a:-100,b:100};case "bottom-right":return {a:100,b:100};default:return {a:-100,b:0}}},y=()=>{let t=getComputedStyle(document.documentElement,"::view-transition-new(root)"),n=Math.max(window.innerWidth,parseFloat(t.width)||0),e=Math.max(window.innerHeight,parseFloat(t.height)||0);return {width:n,height:e}},w=(t,n)=>{let{width:e,height:o}=y();return Math.hypot(Math.max(Math.abs(t),Math.abs(e-t)),Math.max(Math.abs(n),Math.abs(o-n)))+1},L=t=>{let n=t.includes("left")?0:t.includes("right")?window.innerWidth:window.innerWidth/2,e=t.includes("top")?0:t.includes("bottom")?window.innerHeight:window.innerHeight/2;return {x:n,y:e}},S=0,h=(t,n)=>{let e=document.documentElement.animate(n,{duration:t.duration,easing:t.easing,fill:"both",pseudoElement:"::view-transition-new(root)"}),o=e.effect;if(!(o instanceof KeyframeEffect))return e;let i=o.getKeyframes(),d=i.some(c=>"clipPath"in c)?"clipPath":i.some(c=>"maskImage"in c)?"maskImage":"transform";if(getComputedStyle(document.documentElement,"::view-transition-new(root)")[d]!=="none")return e;let l=e.playState==="paused",s=e.currentTime;e.cancel(),e.finished.catch(()=>{});let a=`ui-theme-reveal-${++S}`,r=document.createElement("style"),m=i.map(c=>{let $=Object.entries(c).filter(([u])=>!["offset","computedOffset","easing","composite"].includes(u)).map(([u,A])=>`${u.replace(/[A-Z]/g,v=>`-${v.toLowerCase()}`)}:${A};`).join("");return `${c.computedOffset*100}%{${$}}`}).join("");r.textContent=`@keyframes ${a}{${m}}html[data-ui-theme-transition]::view-transition-new(root){animation:${a} ${t.duration}ms ${t.easing} both;}`,document.head.appendChild(r);let f=getComputedStyle(document.documentElement,"::view-transition-new(root)").animationName,p=document.getAnimations().find(c=>c instanceof CSSAnimation&&c.animationName===f);if(!p)throw r.remove(),new Error("Transition pseudo animations are unavailable");return l&&(p.pause(),p.currentTime=s),p.finished.then(()=>r.remove(),()=>r.remove()),p},O=t=>{let n=t.clipPathDirection??"top-left",e={"top-left":"polygon(-1% -1%, 101% -101%, -101% 101%, -1% -1%)",top:"polygon(-1% -1%, 101% -1%, 101% -1%, -1% -1%)","top-right":"polygon(101% -1%, 201% 101%, -1% -101%, 101% -1%)",right:"polygon(101% -1%, 101% 101%, 101% 101%, 101% -1%)","bottom-right":"polygon(101% 101%, -1% 201%, 201% -1%, 101% 101%)",bottom:"polygon(101% 101%, -1% 101%, -1% 101%, 101% 101%)","bottom-left":"polygon(-1% 101%, -101% -1%, 101% 201%, -1% 101%)",left:"polygon(-1% 101%, -1% -1%, -1% -1%, -1% 101%)"},o={"top-left":"polygon(-1% -1%, 201% -1%, -1% 201%, -1% -1%)",top:"polygon(-1% -1%, 101% -1%, 101% 101%, -1% 101%)","top-right":"polygon(101% -1%, 101% 201%, -101% -1%, 101% -1%)",right:"polygon(101% -1%, 101% 101%, -1% 101%, -1% -1%)","bottom-right":"polygon(101% 101%, -101% 101%, 101% -101%, 101% 101%)",bottom:"polygon(101% 101%, -1% 101%, -1% -1%, 101% -1%)","bottom-left":"polygon(-1% 101%, -1% -101%, 201% 101%, -1% 101%)",left:"polygon(-1% 101%, -1% -1%, 101% -1%, 101% 101%)"};return h(t,{clipPath:[e[n],o[n]]})},_=t=>{let n=t.clipPathDirection??"top-left",{width:e,height:o}=y(),i=n.includes("-"),d=n.includes("left"),g=n.includes("top"),l=n==="left"||n==="right",s=d?0:n.includes("right")?1:.5,a=g?0:n.includes("bottom")?1:.5,r=i||l?e*3:e,m=i||!l?o*3:o,f=i?`${s*100},${a*100} ${(1-s)*100},${a*100} ${s*100},${(1-a)*100}`:"0,0 100,0 100,100 0,100",p=i?r*m/Math.hypot(r,m):l?r:m,$=1-Math.max(0,Math.min(t.gradientWidth??80,p*.2))/p,u=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><defs><linearGradient id="edge" x1="${s*100}" y1="${a*100}" x2="${100*(i?.5:l?1-s:s)}" y2="${100*(i?.5:l?a:1-a)}" gradientUnits="userSpaceOnUse"><stop offset="${$}" stop-color="black"/><stop offset="1" stop-color="black" stop-opacity="0"/></linearGradient></defs><polygon points="${f}" fill="url(#edge)"/></svg>`;return h(t,{maskImage:[`url("data:image/svg+xml,${encodeURIComponent(u)}")`,`url("data:image/svg+xml,${encodeURIComponent(u)}")`],maskMode:["alpha","alpha"],maskRepeat:["no-repeat","no-repeat"],maskSize:[i?"0px 0px":l?`0px ${m}px`:`${r}px 0px`,`${r}px ${m}px`],maskPosition:[`${s*e}px ${a*o}px`,`${s*(e-r)}px ${a*(o-m)}px`]})},F=t=>{let{x:n,y:e}=t,o=w(n,e),i=Math.sqrt(3)*o;return h(t,{clipPath:[`polygon(${n}px ${e}px, ${n}px ${e}px, ${n}px ${e}px)`,`polygon(${n}px ${e-2*o}px, ${n+i}px ${e+o}px, ${n-i}px ${e+o}px)`]})},I=t=>{let{width:n,height:e}=y();return b({...t,x:n/2,y:e/2})},b=t=>{let{x:n,y:e}=t;return h(t,{clipPath:[`circle(0px at ${n}px ${e}px)`,`circle(${w(n,e)}px at ${n}px ${e}px)`]})},U=t=>{let{a:n=-100,b:e=0,x:o=0,y:i=0}=t;return h(t,{transform:[`translate(${n}%, ${e}%)`,`translate(${o}%, ${i}%)`]})},B=t=>{let{x:n,y:e,blurAmount:o}=t;if(o<=0)return b(t);let i=Math.min(o,20),d=w(n,e)+i,g=d*2;return h(t,{maskImage:[`radial-gradient(closest-side, #000 calc(100% - ${i}px), transparent 100%)`,`radial-gradient(closest-side, #000 calc(100% - ${i}px), transparent 100%)`],maskRepeat:["no-repeat","no-repeat"],maskSize:["0px 0px",`${g}px ${g}px`],maskPosition:[`${n}px ${e}px`,`${n-d}px ${e-d}px`]})};var N="theme",K="color-theme",z="dark",j="theme-",H=400,W="cubic-bezier(0.32, 0.72, 0, 1)",Y=2,q="ui-theme-style";
18
+ export{k as a,E as b,C as c,M as d,R as e,T as f,P as g,D as h,L as i,O as j,_ as k,F as l,I as m,b as n,U as o,B as p,N as q,K as r,z as s,j as t,H as u,W as v,Y as w,q as x};