Skip to main content

euv_example/state/
impl.rs

1use super::*;
2
3/// Lazy constructor for `ReactiveSignals`.
4impl ReactiveSignals {
5    /// Materializes the `/reactive` counter and derived `computed!` memo on first access.
6    ///
7    /// # Returns
8    ///
9    /// - `Self` - Initialized `/reactive` signal group.
10    #[must_use]
11    pub(crate) fn create() -> Self {
12        let counter: Signal<i32> = Signal::new(1);
13        let doubled: Memo<i32> = computed!((counter) -> i32 => move |n: i32| n * 2);
14        Self { counter, doubled }
15    }
16}
17
18/// Lazy constructor for `RenderWindowSignals`.
19impl RenderWindowSignals {
20    /// Materializes the `/render` and `/window` OS capability signals on first access.
21    ///
22    /// # Arguments
23    ///
24    /// - `usize` - Default host platform selector index.
25    ///
26    /// # Returns
27    ///
28    /// - `Self` - Initialized `/render` and `/window` signal group.
29    #[must_use]
30    pub(crate) fn create(default_plat_idx: usize) -> Self {
31        Self {
32            render_mode_index: Signal::new(0),
33            demo_fps_cap_index: Signal::new(0),
34            fullscreen: Signal::new(false),
35            island_active: Signal::new(false),
36            island_progress: Signal::new(25),
37            camera_perm_status: Signal::new(DEFAULT_CAMERA_PERM.to_string()),
38            protocol_status: Signal::new(DEFAULT_PROTOCOL_STATUS.to_string()),
39            a11y_announcements: Signal::new(0),
40            haptic_pulses: Signal::new(0),
41            os_target_platform_idx: Signal::new(default_plat_idx),
42            island_mode_idx: Signal::new(0),
43            system_notifications: Signal::new(vec![(
44                DEFAULT_SYS_NOTIF_TITLE.to_string(),
45                DEFAULT_SYS_NOTIF_BODY.to_string(),
46            )]),
47            permission_statuses: Signal::new(vec![PermissionStatus::NotDetermined; 14]),
48        }
49    }
50}
51
52/// Lazy constructor for `FormsSignals`.
53impl FormsSignals {
54    /// Materializes the `/forms` interactive control signals on first access.
55    ///
56    /// # Returns
57    ///
58    /// - `Self` - Initialized `/forms` signal group.
59    #[must_use]
60    pub(crate) fn create() -> Self {
61        Self {
62            username: Signal::new(DEFAULT_USERNAME.to_string()),
63            bio: Signal::new(DEFAULT_BIO_TEXT.to_string()),
64            stepper_value: Signal::new(4),
65            radio_index: Signal::new(1),
66            slider_value: Signal::new(65.0),
67            select_index: Signal::new(0),
68            select_open: Signal::new(false),
69            rating_value: Signal::new(4),
70            pin_toggled: Signal::new(false),
71            hardware_accel: Signal::new(true),
72            agree_terms: Signal::new(true),
73            active_tab: Signal::new(0),
74            page_index: Signal::new(1),
75            step_index: Signal::new(1),
76            accordion_open: Signal::new(Some(0)),
77            picker_color: Signal::new(Color::hex(0x2563EB)),
78            picker_time: Signal::new((14, 30)),
79            tag_items: Signal::new(vec![
80                DEFAULT_TAG_RUST.to_string(),
81                DEFAULT_TAG_NATIVE.to_string(),
82                DEFAULT_TAG_WASM.to_string(),
83            ]),
84            tree_selected: Signal::new(None),
85            breadcrumb_active: Signal::new(2),
86        }
87    }
88}
89
90/// Lazy constructor for `OverlaysSignals`.
91impl OverlaysSignals {
92    /// Materializes the `/overlays` modal, drawer, sheet, and toast signals on first access.
93    ///
94    /// # Returns
95    ///
96    /// - `Self` - Initialized `/overlays` signal group.
97    #[must_use]
98    pub(crate) fn create() -> Self {
99        Self {
100            modal_open: Signal::new(false),
101            drawer_open: Signal::new(false),
102            sheet_open: Signal::new(false),
103            popover_open: Signal::new(false),
104            dropdown_open: Signal::new(false),
105            dropdown_selected: Signal::new(None),
106            toast_visible: Signal::new(false),
107            notif_visible: Signal::new(false),
108            loading_active: Signal::new(false),
109        }
110    }
111}
112
113/// Lazy constructor for `DataSignals`.
114impl DataSignals {
115    /// Materializes the `/data` virtualized list scroll signal on first access.
116    ///
117    /// # Returns
118    ///
119    /// - `Self` - Initialized `/data` signal group.
120    #[must_use]
121    pub(crate) fn create() -> Self {
122        Self {
123            list_scroll_y: Signal::new(640.0),
124        }
125    }
126}
127
128/// Lazy constructor and shared-cell accessor for `Engine3dSignals`.
129impl Engine3dSignals {
130    /// Materializes the `/game3d` quality, ray-tracing, lighting, and camera control signals on first access.
131    ///
132    /// # Returns
133    ///
134    /// - `Self` - Initialized `/game3d` signal group.
135    #[must_use]
136    pub(crate) fn create() -> Self {
137        Self {
138            engine3d_quality: Signal::new(RenderQualityConfig::from_preset(
139                QualityPreset::Cinematic,
140            )),
141            engine3d_preset_idx: Signal::new(4),
142            engine3d_rt_idx: Signal::new(3),
143            engine3d_res_scale: Signal::new(100.0),
144            engine3d_time_of_day: Signal::new(17.2),
145            engine3d_import_queue: Signal::new(0),
146            engine3d_import_status: Signal::new(DEFAULT_ENGINE3D_STATUS.to_string()),
147            engine3d_camera_mode: Signal::new(0),
148        }
149    }
150
151    /// Returns the cached `Engine3dSignals` inside `cell`, materializing it once inside `owner_scope` on first call.
152    ///
153    /// # Arguments
154    ///
155    /// - `&Cell<Option<Self>>` - Shared lazy signal cell.
156    /// - `Scope` - Root ownership scope keeping materialized signals alive across page unmounts.
157    ///
158    /// # Returns
159    ///
160    /// - `Self` - Active `/game3d` signal group.
161    #[must_use]
162    pub(crate) fn get_or_init(cell: &Cell<Option<Self>>, owner_scope: Scope) -> Self {
163        if let Some(existing) = cell.get() {
164            return existing;
165        }
166        let created: Self = owner_scope.enter(Self::create);
167        cell.set(Some(created));
168        created
169    }
170}
171
172/// Lazy constructor and shared-cell accessor for `DynamicSignals`.
173impl DynamicSignals {
174    /// Materializes the `/dynamic` OTA and WASM control signals on first access.
175    ///
176    /// # Returns
177    ///
178    /// - `Self` - Initialized `/dynamic` signal group.
179    #[must_use]
180    pub(crate) fn create() -> Self {
181        Self {
182            sibling_counter: Signal::new(0),
183            dynamic_action_log: Signal::new(DEFAULT_DYNAMIC_ACTION_LOG.to_string()),
184            wasm_offline: Signal::new(false),
185            wasm_fault_status: Signal::new(DEFAULT_WASM_STATUS.to_string()),
186            wasm_bg_task: Signal::new(None),
187        }
188    }
189
190    /// Returns the cached `DynamicSignals` inside `cell`, materializing it once inside `owner_scope` on first call.
191    ///
192    /// # Arguments
193    ///
194    /// - `&Cell<Option<Self>>` - Shared lazy signal cell.
195    /// - `Scope` - Root ownership scope keeping materialized signals alive across global WASM slot swaps.
196    ///
197    /// # Returns
198    ///
199    /// - `Self` - Active `/dynamic` signal group.
200    #[must_use]
201    pub(crate) fn get_or_init(cell: &Cell<Option<Self>>, owner_scope: Scope) -> Self {
202        if let Some(existing) = cell.get() {
203            return existing;
204        }
205        let created: Self = owner_scope.enter(Self::create);
206        cell.set(Some(created));
207        created
208    }
209}
210
211/// Lazy constructor for `LabSignals`.
212impl LabSignals {
213    /// Materializes the `/lab` shadcn/ui component gallery and edge-case signals on first access.
214    ///
215    /// # Returns
216    ///
217    /// - `Self` - Initialized `/lab` signal group.
218    #[must_use]
219    pub(crate) fn create() -> Self {
220        Self {
221            alert_dialog_open: Signal::new(false),
222            alert_dialog_confirmed: Signal::new(false),
223            collapsible_open: Signal::new(true),
224            toggle_group_index: Signal::new(0),
225            otp_code: Signal::new(DEFAULT_OTP_CODE.to_string()),
226            command_query: Signal::new(String::new()),
227            command_selected: Signal::new(Some(0)),
228            hover_card_open: Signal::new(false),
229            calendar_day: Signal::new(25),
230            menubar_active: Signal::new(None),
231            carousel_index: Signal::new(0),
232            lab_combobox_query: Signal::new(String::new()),
233            lab_combobox_selected: Signal::new(0),
234            lab_combobox_open: Signal::new(false),
235            lab_table_filter: Signal::new(String::new()),
236            lab_table_sort_asc: Signal::new(true),
237            lab_table_selected: Signal::new(Some(0)),
238            lab_date_day: Signal::new(26),
239            lab_date_open: Signal::new(false),
240            lab_input_group_val: Signal::new(DEFAULT_INPUT_GROUP_VAL.to_string()),
241            lab_native_select_idx: Signal::new(0),
242            lab_nav_menu_active: Signal::new(None),
243            lab_split_ratio: Signal::new(0.45),
244            lab_block_scroll_chain: Signal::new(false),
245            lab_stop_click_bubble: Signal::new(true),
246            lab_parent_clicks: Signal::new(0),
247            lab_child_clicks: Signal::new(0),
248            lab_resize_preserve_count: Signal::new(1),
249            lab_rtl_mode: Signal::new(false),
250        }
251    }
252}
253
254/// Lazy constructor for `MediaSignals`.
255impl MediaSignals {
256    /// Materializes the `/media` Media Studio playback signals on first access.
257    ///
258    /// # Returns
259    ///
260    /// - `Self` - Initialized `/media` signal group.
261    #[must_use]
262    pub(crate) fn create() -> Self {
263        Self {
264            media_gif: Signal::new(GifAnimation::default()),
265            media_live: Signal::new(LivePhotoAsset::default()),
266            media_video: Signal::new(VideoTrack::default()),
267            media_audio: Signal::new(AudioTrack::default()),
268            media_pdf: Signal::new(PdfDocument::default()),
269            media_html_link_log: Signal::new(DEFAULT_MEDIA_LINK_LOG.to_string()),
270            media_loading: Signal::new(false),
271            media_bg_task: Signal::new(None),
272        }
273    }
274}
275
276/// Lazy constructor for `MarkdownSignals`.
277impl MarkdownSignals {
278    /// Materializes the `/markdown` Markdown & Code Studio signals on first access.
279    ///
280    /// # Returns
281    ///
282    /// - `Self` - Initialized `/markdown` signal group.
283    #[must_use]
284    pub(crate) fn create() -> Self {
285        Self {
286            markdown_copy_log: Signal::new(DEFAULT_MD_COPY_LOG.to_string()),
287            markdown_link_log: Signal::new(DEFAULT_MD_LINK_LOG.to_string()),
288            markdown_tasks_toggled: Signal::new(0),
289            markdown_lang_tab: Signal::new(0),
290            markdown_selectable: Signal::new(true),
291        }
292    }
293}
294
295/// Lazy constructor for `StressSignals`.
296impl StressSignals {
297    /// Materializes the `/stress` interactive UI stress benchmark signals on first access.
298    ///
299    /// # Returns
300    ///
301    /// - `Self` - Initialized `/stress` signal group.
302    #[must_use]
303    pub(crate) fn create() -> Self {
304        Self {
305            stress_results: Signal::new(Vec::new()),
306            stress_summary: Signal::new(STRESS_SUMMARY_READY.to_string()),
307        }
308    }
309}
310
311/// Lazy constructor for `ChartsSignals`.
312impl ChartsSignals {
313    /// Materializes the `/charts` ECharts Studio filter and readout signals on first access.
314    ///
315    /// # Returns
316    ///
317    /// - `Self` - Initialized `/charts` signal group.
318    #[must_use]
319    pub(crate) fn create() -> Self {
320        Self {
321            charts_category_idx: Signal::new(0),
322            charts_event_log: Signal::new(CHARTS_EVENT_READY.to_string()),
323        }
324    }
325}
326
327/// Lazy constructor for `WaterSignals`.
328impl WaterSignals {
329    /// Materializes the `/water` liquid physics control and telemetry signals on first access.
330    ///
331    /// # Returns
332    ///
333    /// - `Self` - Initialized `/water` signal group.
334    #[must_use]
335    pub(crate) fn create() -> Self {
336        Self {
337            fill_pct: Signal::new(FLUID_DEFAULT_FILL_RATIO * 100.0),
338            viscosity_idx: Signal::new(0),
339            buoyant_enabled: Signal::new(true),
340            fullscreen_open: Signal::new(false),
341            sensor_perm_status: Signal::new(WATER_PERM_DESKTOP_STATUS.to_string()),
342            stats: Signal::new(GyroLiquidStats::default()),
343        }
344    }
345}
346
347/// Lazy scene creation and zero-boot-cost handle accessors for `LazyWaterScene`.
348impl LazyWaterScene {
349    /// Creates a zero-allocation lazy placeholder bound to shared `scene_cell` and `signals_cell`.
350    ///
351    /// # Arguments
352    ///
353    /// - `Rc<RefCell<Option<GyroLiquidGameScene>>>` - Shared cell lazily storing the active liquid scene.
354    /// - `Rc<Cell<Option<WaterSignals>>>` - Shared cell storing `/water` reactive signals.
355    ///
356    /// # Returns
357    ///
358    /// - `Self` - Uninitialized lazy liquid scene wrapper.
359    #[must_use]
360    pub(crate) fn create_deferred(
361        scene_cell: Rc<RefCell<Option<GyroLiquidGameScene>>>,
362        signals_cell: Rc<Cell<Option<WaterSignals>>>,
363    ) -> Self {
364        Self {
365            scene_cell,
366            signals_cell,
367        }
368    }
369
370    /// Returns the active `GyroLiquidGameScene`, initializing it lazily on first access.
371    ///
372    /// # Arguments
373    ///
374    /// - `&Self` - Lazy water scene reference.
375    ///
376    /// # Returns
377    ///
378    /// - `GyroLiquidGameScene` - Active shareable liquid physics scene handle.
379    #[must_use]
380    pub(crate) fn ensure_scene(&self) -> GyroLiquidGameScene {
381        if let Some(existing) = self.get_scene_cell().borrow().as_ref() {
382            return existing.clone();
383        }
384        let created: GyroLiquidGameScene = GyroLiquidGameScene::default();
385        *self.get_scene_cell().borrow_mut() = Some(created.clone());
386        created
387    }
388}
389
390/// `GameScene` delegation forwarding fixed physics steps and zero-copy optical rendering to the lazily initialized `GyroLiquidGameScene`.
391impl GameScene for LazyWaterScene {
392    /// Steps the SI PBF liquid simulation and mirrors live `GyroLiquidStats` into `/water` signals.
393    ///
394    /// # Arguments
395    ///
396    /// - `&Self` - Mutable lazy water scene wrapper.
397    /// - `f32` - Fixed simulation timestep in seconds.
398    /// - `&InputState` - Real-time polled pointer and keyboard input state.
399    fn fixed_update(&mut self, dt: f32, input: &InputState) {
400        let mut scene: GyroLiquidGameScene = self.ensure_scene();
401        scene.fixed_update(dt, input);
402        if let Some(sig) = self.get_signals_cell().get() {
403            let _: bool = sig.get_stats().set_if_changed(scene.stats());
404        }
405    }
406
407    /// Renders the optical liquid frame into `ctx` and mirrors updated frame timings into `/water` signals.
408    ///
409    /// # Arguments
410    ///
411    /// - `&Self` - Mutable lazy water scene wrapper.
412    /// - `f32` - Interpolation alpha in `[0.0, 1.0]`.
413    /// - `&mut GameRenderContext<'_>` - Active viewport draw surface.
414    fn render(&mut self, alpha: f32, ctx: &mut GameRenderContext<'_>) {
415        let mut scene: GyroLiquidGameScene = self.ensure_scene();
416        scene.render(alpha, ctx);
417        if let Some(sig) = self.get_signals_cell().get() {
418            let _: bool = sig.get_stats().set_if_changed(scene.stats());
419        }
420    }
421}
422
423/// Construction, lazy signal accessors, async preloaders, and lifecycle helpers for `ShowcaseState`.
424impl ShowcaseState {
425    /// Initializes a minimal-boot `ShowcaseState` using a fresh `DynamicUpdateHub` and synchronous lazy route hydration.
426    ///
427    /// # Returns
428    ///
429    /// - `Self` - Initialized reactive showcase state.
430    #[must_use]
431    pub fn new() -> Self {
432        Self::new_with_hub(DynamicUpdateHub::new(), false)
433    }
434
435    /// Initializes a minimal-boot `ShowcaseState` bound directly to `hub` without allocating discarded hubs or managers.
436    ///
437    /// # Arguments
438    ///
439    /// - `DynamicUpdateHub` - Active `App` dynamic update hub to attach directly.
440    /// - `bool` - When `true`, offloads heavy `/media`, `/dynamic`, and `/game3d` route payloads onto background worker threads on native targets.
441    ///
442    /// # Returns
443    ///
444    /// - `Self` - Initialized reactive showcase state with only core shell signals allocated at boot.
445    #[must_use]
446    pub fn new_with_hub(hub: DynamicUpdateHub, bg_workers: bool) -> Self {
447        let (state_scope, _): (Scope, ()) = Scope::run(|_: Scope| {});
448        let arena: DemoPhysicsScene = DemoPhysicsScene::create_lazy_arena();
449        let game_host: GameEngineHost = GameEngineHost::new(arena, 1.0 / 60.0);
450        game_host.set_paused(true);
451        let engine3d_signals: Rc<Cell<Option<Engine3dSignals>>> = Rc::new(Cell::new(None));
452        let bg_workers_enabled: Rc<Cell<bool>> = Rc::new(Cell::new(bg_workers));
453        let scene3d: DemoOpenWorld3DScene = DemoOpenWorld3DScene::create_lazy_city_deferred(
454            engine3d_signals.clone(),
455            state_scope,
456            bg_workers_enabled.clone(),
457        );
458        let game3d_host: GameEngineHost = GameEngineHost::new(scene3d, 1.0 / 60.0);
459        game3d_host.set_paused(true);
460        let water_scene_cell: Rc<RefCell<Option<GyroLiquidGameScene>>> =
461            Rc::new(RefCell::new(None));
462        let water_signals: Rc<Cell<Option<WaterSignals>>> = Rc::new(Cell::new(None));
463        let lazy_water: LazyWaterScene =
464            LazyWaterScene::create_deferred(water_scene_cell.clone(), water_signals.clone());
465        let water_host: GameEngineHost = GameEngineHost::new(lazy_water, 1.0 / 60.0);
466        water_host.set_paused(true);
467        let router: EuvRouter = EuvRouter::new(ROUTE_OVERVIEW)
468            .with_default_retention(PageRetention::Freeze)
469            .with_dynamic_hub(hub.clone());
470        let wasm_registry: RegistryWasmFetcher = RegistryWasmFetcher::default();
471        let wasm_manager: WasmDynamicManager = WasmDynamicManager::new(
472            hub.clone(),
473            Rc::new(wasm_registry.clone()),
474            WasmSandboxConfig::default(),
475        );
476        let (
477            default_active_backend,
478            default_rec_backend,
479            default_cpu_mirror,
480            default_timing,
481            default_upload,
482        ): (&str, &str, bool, &str, &str) =
483            Self::default_adaptive_render_profile(current_platform());
484        let state: Self = Self {
485            route: Signal::new(ROUTE_OVERVIEW.to_string()),
486            state_scope,
487            theme: UiThemeState::new(active_feature_scheme(), ThemeMode::Light),
488            game_host,
489            game3d_host,
490            water_host,
491            water_scene_cell,
492            dynamic_hub: hub,
493            wasm_registry,
494            wasm_manager,
495            cmd_palette_open: Signal::new(false),
496            cmd_palette_query: Signal::new(String::new()),
497            auto_hide_chrome: Signal::new(true),
498            show_fps_hud: Signal::new(true),
499            swipe_routing: Signal::new(true),
500            reduced_motion: Signal::new(false),
501            adaptive_auto_switch: Signal::new(false),
502            adaptive_active_backend: Signal::new(default_active_backend.to_string()),
503            adaptive_recommended_backend: Signal::new(default_rec_backend.to_string()),
504            adaptive_cpu_mirror_active: Signal::new(default_cpu_mirror),
505            adaptive_present_timing_source: Signal::new(default_timing.to_string()),
506            adaptive_upload_strategy: Signal::new(default_upload.to_string()),
507            adaptive_handoff_attempts: Signal::new(0),
508            adaptive_handoff_successes: Signal::new(0),
509            adaptive_handoff_aborts: Signal::new(0),
510            router,
511            router_ready: Rc::new(Cell::new(false)),
512            lifecycle_mounts: Signal::new(0),
513            lifecycle_freezes: Signal::new(0),
514            lifecycle_resumes: Signal::new(0),
515            lifecycle_destroys: Signal::new(0),
516            lifecycle_last_event: Signal::new(DEFAULT_LIFECYCLE_BOOT.to_string()),
517            system_event_log: Signal::new(vec![DEFAULT_SYS_EVENT_LOG.to_string()]),
518            system_event_count: Signal::new(0),
519            bg_frozen: Signal::new(false),
520            bg_freeze_count: Signal::new(0),
521            bg_restore_count: Signal::new(0),
522            bg_snap_game2d_running: Rc::new(Cell::new(false)),
523            bg_snap_game3d_running: Rc::new(Cell::new(false)),
524            bg_snap_water_running: Rc::new(Cell::new(false)),
525            bg_snap_gif_playing: Rc::new(Cell::new(false)),
526            bg_snap_live_playing: Rc::new(Cell::new(false)),
527            bg_snap_video_playing: Rc::new(Cell::new(false)),
528            bg_snap_audio_playing: Rc::new(Cell::new(false)),
529            media_loaded: Rc::new(Cell::new(false)),
530            wasm_registry_loaded: Rc::new(Cell::new(false)),
531            stress_loaded: Rc::new(Cell::new(false)),
532            charts_loaded: Rc::new(Cell::new(false)),
533            bg_workers_enabled,
534            default_host_plat_idx: Rc::new(Cell::new(0)),
535            reactive_signals: Rc::new(Cell::new(None)),
536            render_window_signals: Rc::new(Cell::new(None)),
537            forms_signals: Rc::new(Cell::new(None)),
538            overlays_signals: Rc::new(Cell::new(None)),
539            data_signals: Rc::new(Cell::new(None)),
540            engine3d_signals,
541            dynamic_signals: Rc::new(Cell::new(None)),
542            lab_signals: Rc::new(Cell::new(None)),
543            media_signals: Rc::new(Cell::new(None)),
544            markdown_signals: Rc::new(Cell::new(None)),
545            stress_signals: Rc::new(Cell::new(None)),
546            charts_signals: Rc::new(Cell::new(None)),
547            water_signals,
548        };
549        state.wire_dynamic_hub_actions();
550        state
551    }
552
553    /// Records the host platform index without eagerly materializing `/window` signals at boot.
554    ///
555    /// # Arguments
556    ///
557    /// - `&Self` - Reactive showcase state reference.
558    /// - `usize` - Host platform index (`0..7`).
559    pub fn set_default_host_platform_idx(&self, idx: usize) {
560        self.get_default_host_plat_idx().set(idx);
561        if let Some(rw) = self.get_render_window_signals().get() {
562            let _: bool = rw.get_os_target_platform_idx().set_if_changed(idx);
563        }
564    }
565
566    /// Enables or disables off-main-thread background worker loading for heavy showcase routes.
567    ///
568    /// # Arguments
569    ///
570    /// - `&Self` - Reactive showcase state reference.
571    /// - `bool` - `true` to enable background worker threads on native targets.
572    pub fn set_bg_workers_enabled(&self, enabled: bool) {
573        self.get_bg_workers_enabled().set(enabled);
574    }
575
576    /// Resolves honest baseline adaptive render diagnostics for `platform` without faking unverified GPU direct present or hardware compositor timing.
577    ///
578    /// # Arguments
579    ///
580    /// - `PlatformKind` - Active host platform classification.
581    ///
582    /// # Returns
583    ///
584    /// - `(&'static str, &'static str, bool, &'static str, &'static str)` - `(active_backend, recommended_backend, cpu_mirror_active, timing_source, upload_strategy)`.
585    #[must_use]
586    fn default_adaptive_render_profile(
587        platform: PlatformKind,
588    ) -> (&'static str, &'static str, bool, &'static str, &'static str) {
589        let cfg: RenderConfig = RenderConfig::default();
590        let direct_gpu: bool = cfg.get_direct_gpu_present();
591        match platform {
592            PlatformKind::MacOs | PlatformKind::Ios | PlatformKind::IpadOs => {
593                if direct_gpu {
594                    (
595                        ADAPTIVE_BACKEND_METAL_DIRECT,
596                        ADAPTIVE_BACKEND_METAL_DIRECT,
597                        false,
598                        ADAPTIVE_TIMING_COMPOSITOR,
599                        ADAPTIVE_UPLOAD_DIRECT_GPU,
600                    )
601                } else {
602                    (
603                        ADAPTIVE_BACKEND_SOFTWARE_CPU,
604                        ADAPTIVE_BACKEND_METAL_DIRECT,
605                        true,
606                        ADAPTIVE_TIMING_PROXY,
607                        ADAPTIVE_UPLOAD_MULTI_RECT,
608                    )
609                }
610            }
611            PlatformKind::Android | PlatformKind::HarmonyOs => {
612                if direct_gpu {
613                    (
614                        ADAPTIVE_BACKEND_GLES3_DIRECT,
615                        ADAPTIVE_BACKEND_GLES3_DIRECT,
616                        false,
617                        ADAPTIVE_TIMING_COMPOSITOR,
618                        ADAPTIVE_UPLOAD_DIRECT_GPU,
619                    )
620                } else {
621                    (
622                        ADAPTIVE_BACKEND_SOFTWARE_CPU,
623                        ADAPTIVE_BACKEND_GLES3_DIRECT,
624                        true,
625                        ADAPTIVE_TIMING_PROXY,
626                        ADAPTIVE_UPLOAD_MULTI_RECT,
627                    )
628                }
629            }
630            PlatformKind::Windows => {
631                if direct_gpu {
632                    (
633                        ADAPTIVE_BACKEND_D3D11_DIRECT,
634                        ADAPTIVE_BACKEND_D3D11_DIRECT,
635                        false,
636                        ADAPTIVE_TIMING_COMPOSITOR,
637                        ADAPTIVE_UPLOAD_DIRECT_GPU,
638                    )
639                } else {
640                    (
641                        ADAPTIVE_BACKEND_SOFTWARE_CPU,
642                        ADAPTIVE_BACKEND_D3D11_DIRECT,
643                        true,
644                        ADAPTIVE_TIMING_PROXY,
645                        ADAPTIVE_UPLOAD_MULTI_RECT,
646                    )
647                }
648            }
649            PlatformKind::Linux => {
650                if direct_gpu {
651                    (
652                        ADAPTIVE_BACKEND_VULKAN_DIRECT,
653                        ADAPTIVE_BACKEND_VULKAN_DIRECT,
654                        false,
655                        ADAPTIVE_TIMING_COMPOSITOR,
656                        ADAPTIVE_UPLOAD_DIRECT_GPU,
657                    )
658                } else {
659                    (
660                        ADAPTIVE_BACKEND_SOFTWARE_CPU,
661                        ADAPTIVE_BACKEND_VULKAN_DIRECT,
662                        true,
663                        ADAPTIVE_TIMING_PROXY,
664                        ADAPTIVE_UPLOAD_MULTI_RECT,
665                    )
666                }
667            }
668            PlatformKind::Web => (
669                ADAPTIVE_BACKEND_WEBGL2_UPLOAD,
670                ADAPTIVE_BACKEND_WEBGL2_UPLOAD,
671                true,
672                ADAPTIVE_TIMING_PROXY,
673                ADAPTIVE_UPLOAD_MULTI_RECT,
674            ),
675            PlatformKind::Terminal | PlatformKind::TerminalCli => (
676                ADAPTIVE_BACKEND_TERMINAL,
677                ADAPTIVE_BACKEND_TERMINAL,
678                false,
679                ADAPTIVE_TIMING_UNOBSERVABLE,
680                ADAPTIVE_UPLOAD_NONE,
681            ),
682            PlatformKind::Wearable
683            | PlatformKind::MiniApp
684            | PlatformKind::QuickApp
685            | PlatformKind::Headless => (
686                ADAPTIVE_BACKEND_SOFTWARE_CPU,
687                ADAPTIVE_BACKEND_SOFTWARE_CPU,
688                true,
689                ADAPTIVE_TIMING_PROXY,
690                ADAPTIVE_UPLOAD_MULTI_RECT,
691            ),
692        }
693    }
694
695    /// Synchronizes live adaptive render router telemetry into reactive `/settings` diagnostics signals.
696    ///
697    /// # Arguments
698    ///
699    /// - `&Self` - Reactive showcase state reference.
700    /// - `&str` - Active backend display label.
701    /// - `&str` - Recommended backend display label.
702    /// - `bool` - Whether a CPU software mirror is active.
703    /// - `&str` - Honest presentation timing source label.
704    /// - `&str` - Active upload/submission strategy label.
705    /// - `(u64, u64, u64)` - `(attempts, successes, aborts)` handoff counters.
706    pub fn sync_adaptive_render_diagnostics(
707        &self,
708        active_backend: &str,
709        recommended_backend: &str,
710        cpu_mirror_active: bool,
711        timing_source: &str,
712        upload_strategy: &str,
713        handoff_counts: (u64, u64, u64),
714    ) {
715        let _: bool = self
716            .get_adaptive_active_backend()
717            .set_if_changed(active_backend.to_string());
718        let _: bool = self
719            .get_adaptive_recommended_backend()
720            .set_if_changed(recommended_backend.to_string());
721        let _: bool = self
722            .get_adaptive_cpu_mirror_active()
723            .set_if_changed(cpu_mirror_active);
724        let _: bool = self
725            .get_adaptive_present_timing_source()
726            .set_if_changed(timing_source.to_string());
727        let _: bool = self
728            .get_adaptive_upload_strategy()
729            .set_if_changed(upload_strategy.to_string());
730        let _: bool = self
731            .get_adaptive_handoff_attempts()
732            .set_if_changed(handoff_counts.0);
733        let _: bool = self
734            .get_adaptive_handoff_successes()
735            .set_if_changed(handoff_counts.1);
736        let _: bool = self
737            .get_adaptive_handoff_aborts()
738            .set_if_changed(handoff_counts.2);
739    }
740
741    /// Formats a human-readable backend label from a `(GraphicsBackend, RenderBackendCandidate)` pair.
742    ///
743    /// # Arguments
744    ///
745    /// - `GraphicsBackend` - Active low-level graphics API backend.
746    /// - `RenderBackendCandidate` - Active or recommended adaptive render candidate.
747    ///
748    /// # Returns
749    ///
750    /// - `&'static str` - Canonical truthful backend label.
751    #[must_use]
752    fn adaptive_candidate_label(
753        backend: GraphicsBackend,
754        candidate: RenderBackendCandidate,
755    ) -> &'static str {
756        match candidate {
757            RenderBackendCandidate::GpuDirect => match backend {
758                GraphicsBackend::Metal => ADAPTIVE_BACKEND_METAL_DIRECT,
759                GraphicsBackend::Vulkan => ADAPTIVE_BACKEND_VULKAN_DIRECT,
760                GraphicsBackend::Direct3D11 | GraphicsBackend::Direct3D12 => {
761                    ADAPTIVE_BACKEND_D3D11_DIRECT
762                }
763                GraphicsBackend::OpenGlEs => ADAPTIVE_BACKEND_GLES3_DIRECT,
764                GraphicsBackend::WebGpu | GraphicsBackend::WebGl2 => ADAPTIVE_BACKEND_WEBGL2_DIRECT,
765                GraphicsBackend::Canvas2d => ADAPTIVE_BACKEND_CANVAS2D,
766                GraphicsBackend::SoftwareCpu | GraphicsBackend::Headless => {
767                    ADAPTIVE_BACKEND_SOFTWARE_CPU
768                }
769            },
770            RenderBackendCandidate::GpuUpload => match backend {
771                GraphicsBackend::Metal => ADAPTIVE_BACKEND_METAL_UPLOAD,
772                GraphicsBackend::WebGpu | GraphicsBackend::WebGl2 => ADAPTIVE_BACKEND_WEBGL2_UPLOAD,
773                GraphicsBackend::Vulkan => ADAPTIVE_BACKEND_VULKAN_DIRECT,
774                GraphicsBackend::Direct3D11 | GraphicsBackend::Direct3D12 => {
775                    ADAPTIVE_BACKEND_D3D11_DIRECT
776                }
777                GraphicsBackend::OpenGlEs => ADAPTIVE_BACKEND_GLES3_DIRECT,
778                GraphicsBackend::Canvas2d => ADAPTIVE_BACKEND_CANVAS2D,
779                GraphicsBackend::SoftwareCpu | GraphicsBackend::Headless => {
780                    ADAPTIVE_BACKEND_SOFTWARE_CPU
781                }
782            },
783            RenderBackendCandidate::Hybrid => ADAPTIVE_BACKEND_HYBRID_SPARSE,
784            RenderBackendCandidate::Software => {
785                if backend == GraphicsBackend::Canvas2d {
786                    ADAPTIVE_BACKEND_CANVAS2D
787                } else {
788                    ADAPTIVE_BACKEND_SOFTWARE_CPU
789                }
790            }
791            RenderBackendCandidate::Terminal => ADAPTIVE_BACKEND_TERMINAL,
792        }
793    }
794
795    /// Synchronizes `/settings` adaptive rollout toggle into `app`'s live `AdaptiveRenderRouter` and mirrors real `AdaptiveFrameMetrics` back into reactive signals.
796    ///
797    /// # Arguments
798    ///
799    /// - `&Self` - Reactive showcase state reference.
800    /// - `&mut App` - Active application owning the live `Renderer` and `AdaptiveRenderRouter`.
801    pub fn sync_adaptive_from_app(&self, app: &mut App) {
802        let desired_mode: AdaptiveSwitchMode = if self.get_adaptive_auto_switch().get_untracked() {
803            AdaptiveSwitchMode::AutoSwitch
804        } else {
805            AdaptiveSwitchMode::RecommendOnly
806        };
807        if app.adaptive_switch_mode() != desired_mode {
808            app.set_adaptive_switch_mode(desired_mode);
809        }
810        let metrics: AdaptiveFrameMetrics = app.adaptive_frame_metrics();
811        let snap: AdaptiveRouterSnapshot = metrics.get_adaptive_router();
812        let backend: GraphicsBackend = app.get_renderer().get_active_backend();
813        let active_label: &str =
814            Self::adaptive_candidate_label(backend, snap.get_active_candidate());
815        let rec_label: &str =
816            Self::adaptive_candidate_label(backend, snap.get_recommended_candidate());
817        let timing_label: &str = match metrics.get_present_timing_source() {
818            PresentTimingSource::CompositorMeasured => ADAPTIVE_TIMING_COMPOSITOR,
819            PresentTimingSource::SubmissionProxy => ADAPTIVE_TIMING_PROXY,
820            PresentTimingSource::Unobservable => ADAPTIVE_TIMING_UNOBSERVABLE,
821        };
822        let upload_label: &str = match metrics.get_upload_strategy() {
823            UploadStrategy::DirectGpu => ADAPTIVE_UPLOAD_DIRECT_GPU,
824            UploadStrategy::MultiRect => ADAPTIVE_UPLOAD_MULTI_RECT,
825            UploadStrategy::MergedBbox => ADAPTIVE_UPLOAD_MERGED_BBOX,
826            UploadStrategy::FullFrame => ADAPTIVE_UPLOAD_FULL_FRAME,
827            UploadStrategy::None => ADAPTIVE_UPLOAD_NONE,
828        };
829        let successes: u64 = snap.get_seamless_handoff_successes();
830        let aborts: u64 = snap.get_handoff_aborts();
831        let attempts: u64 = successes.saturating_add(aborts);
832        self.sync_adaptive_render_diagnostics(
833            active_label,
834            rec_label,
835            metrics.get_cpu_mirror_active(),
836            timing_label,
837            upload_label,
838            (attempts, successes, aborts),
839        );
840    }
841
842    /// Synchronizes `/settings` adaptive rollout toggle into `app`'s live `AdaptiveRenderRouter` and combines it with live Web dual-canvas handoff and `SubmissionProxy` telemetry.
843    ///
844    /// # Arguments
845    ///
846    /// - `&Self` - Reactive showcase state reference.
847    /// - `&mut App` - Active WebAssembly application owning the live `Renderer` and `AdaptiveRenderRouter`.
848    /// - `&ShowcaseWebDualCanvasCoordinator` - Live stacked dual-canvas coordinator snapshot.
849    pub fn sync_adaptive_from_web_coordinator(
850        &self,
851        app: &mut App,
852        coord: &ShowcaseWebDualCanvasCoordinator,
853    ) {
854        self.sync_adaptive_from_app(app);
855        let active_path: ShowcaseWebPresentationPath = coord.get_active().get_path();
856        let active_label: &str = match active_path {
857            ShowcaseWebPresentationPath::GpuDirect => ADAPTIVE_BACKEND_WEBGL2_DIRECT,
858            ShowcaseWebPresentationPath::GpuUpload => ADAPTIVE_BACKEND_WEBGL2_UPLOAD,
859            ShowcaseWebPresentationPath::Canvas2d => ADAPTIVE_BACKEND_CANVAS2D,
860        };
861        let upload_label: &str = match active_path {
862            ShowcaseWebPresentationPath::GpuDirect => ADAPTIVE_UPLOAD_DIRECT_GPU,
863            ShowcaseWebPresentationPath::GpuUpload => ADAPTIVE_UPLOAD_MULTI_RECT,
864            ShowcaseWebPresentationPath::Canvas2d => ADAPTIVE_UPLOAD_FULL_FRAME,
865        };
866        let timing_label: &str = match coord.get_timing_source() {
867            ShowcaseWebTimingSource::SubmissionProxy => ADAPTIVE_TIMING_PROXY,
868            ShowcaseWebTimingSource::Unobservable => ADAPTIVE_TIMING_UNOBSERVABLE,
869        };
870        let snap: AdaptiveRouterSnapshot = app.adaptive_router_snapshot();
871        let successes: u64 = snap
872            .get_seamless_handoff_successes()
873            .saturating_add(coord.get_completed_swaps());
874        let aborts: u64 = snap
875            .get_handoff_aborts()
876            .saturating_add(coord.get_aborted_swaps());
877        let attempts: u64 = successes.saturating_add(aborts);
878        self.sync_adaptive_render_diagnostics(
879            active_label,
880            active_label,
881            coord.get_cpu_mirror_active(),
882            timing_label,
883            upload_label,
884            (attempts, successes, aborts),
885        );
886    }
887
888    /// Resets all reactive shell and runtime preferences to canonical showcase defaults.
889    ///
890    /// # Arguments
891    ///
892    /// - `&Self` - Reactive showcase state reference.
893    pub fn reset_preferences_to_defaults(&self) {
894        let _: bool = self.get_auto_hide_chrome().set_if_changed(true);
895        let _: bool = self.get_show_fps_hud().set_if_changed(true);
896        let _: bool = self.get_swipe_routing().set_if_changed(true);
897        let _: bool = self.get_reduced_motion().set_if_changed(false);
898        let _: bool = self.get_adaptive_auto_switch().set_if_changed(false);
899        let _: bool = self
900            .get_theme()
901            .get_scheme()
902            .set_if_changed(active_feature_scheme());
903        let _: bool = self.get_theme().get_mode().set_if_changed(ThemeMode::Light);
904    }
905
906    /// Returns the lazily initialized `/reactive` signal group.
907    ///
908    /// # Arguments
909    ///
910    /// - `&Self` - Reactive showcase state reference.
911    ///
912    /// # Returns
913    ///
914    /// - `ReactiveSignals` - Active `/reactive` signal group.
915    fn reactive_group(&self) -> ReactiveSignals {
916        if let Some(existing) = self.get_reactive_signals().get() {
917            return existing;
918        }
919        let created: ReactiveSignals = self.get_state_scope().enter(ReactiveSignals::create);
920        self.get_reactive_signals().set(Some(created));
921        created
922    }
923
924    /// Returns the lazily initialized `/render` and `/window` signal group.
925    ///
926    /// # Arguments
927    ///
928    /// - `&Self` - Reactive showcase state reference.
929    ///
930    /// # Returns
931    ///
932    /// - `RenderWindowSignals` - Active `/render` and `/window` signal group.
933    fn render_window_group(&self) -> RenderWindowSignals {
934        if let Some(existing) = self.get_render_window_signals().get() {
935            return existing;
936        }
937        let default_plat: usize = self.get_default_host_plat_idx().get();
938        let created: RenderWindowSignals = self
939            .get_state_scope()
940            .enter(|| RenderWindowSignals::create(default_plat));
941        self.get_render_window_signals().set(Some(created));
942        created
943    }
944
945    /// Returns the lazily initialized `/forms` signal group.
946    ///
947    /// # Arguments
948    ///
949    /// - `&Self` - Reactive showcase state reference.
950    ///
951    /// # Returns
952    ///
953    /// - `FormsSignals` - Active `/forms` signal group.
954    fn forms_group(&self) -> FormsSignals {
955        if let Some(existing) = self.get_forms_signals().get() {
956            return existing;
957        }
958        let created: FormsSignals = self.get_state_scope().enter(FormsSignals::create);
959        self.get_forms_signals().set(Some(created));
960        created
961    }
962
963    /// Returns the lazily initialized `/overlays` signal group.
964    ///
965    /// # Arguments
966    ///
967    /// - `&Self` - Reactive showcase state reference.
968    ///
969    /// # Returns
970    ///
971    /// - `OverlaysSignals` - Active `/overlays` signal group.
972    fn overlays_group(&self) -> OverlaysSignals {
973        if let Some(existing) = self.get_overlays_signals().get() {
974            return existing;
975        }
976        let created: OverlaysSignals = self.get_state_scope().enter(OverlaysSignals::create);
977        self.get_overlays_signals().set(Some(created));
978        created
979    }
980
981    /// Returns the lazily initialized `/data` signal group.
982    ///
983    /// # Arguments
984    ///
985    /// - `&Self` - Reactive showcase state reference.
986    ///
987    /// # Returns
988    ///
989    /// - `DataSignals` - Active `/data` signal group.
990    fn data_group(&self) -> DataSignals {
991        if let Some(existing) = self.get_data_signals().get() {
992            return existing;
993        }
994        let created: DataSignals = self.get_state_scope().enter(DataSignals::create);
995        self.get_data_signals().set(Some(created));
996        created
997    }
998
999    /// Returns the lazily initialized `/game3d` signal group.
1000    ///
1001    /// # Arguments
1002    ///
1003    /// - `&Self` - Reactive showcase state reference.
1004    ///
1005    /// # Returns
1006    ///
1007    /// - `Engine3dSignals` - Active `/game3d` signal group.
1008    fn engine3d_group(&self) -> Engine3dSignals {
1009        Engine3dSignals::get_or_init(self.get_engine3d_signals().as_ref(), self.get_state_scope())
1010    }
1011
1012    /// Returns the lazily initialized `/dynamic` signal group.
1013    ///
1014    /// # Arguments
1015    ///
1016    /// - `&Self` - Reactive showcase state reference.
1017    ///
1018    /// # Returns
1019    ///
1020    /// - `DynamicSignals` - Active `/dynamic` signal group.
1021    fn dynamic_group(&self) -> DynamicSignals {
1022        DynamicSignals::get_or_init(self.get_dynamic_signals().as_ref(), self.get_state_scope())
1023    }
1024
1025    /// Returns the lazily initialized `/lab` signal group.
1026    ///
1027    /// # Arguments
1028    ///
1029    /// - `&Self` - Reactive showcase state reference.
1030    ///
1031    /// # Returns
1032    ///
1033    /// - `LabSignals` - Active `/lab` signal group.
1034    fn lab_group(&self) -> LabSignals {
1035        if let Some(existing) = self.get_lab_signals().get() {
1036            return existing;
1037        }
1038        let created: LabSignals = self.get_state_scope().enter(LabSignals::create);
1039        self.get_lab_signals().set(Some(created));
1040        created
1041    }
1042
1043    /// Returns the lazily initialized `/media` signal group.
1044    ///
1045    /// # Arguments
1046    ///
1047    /// - `&Self` - Reactive showcase state reference.
1048    ///
1049    /// # Returns
1050    ///
1051    /// - `MediaSignals` - Active `/media` signal group.
1052    fn media_group(&self) -> MediaSignals {
1053        if let Some(existing) = self.get_media_signals().get() {
1054            return existing;
1055        }
1056        let created: MediaSignals = self.get_state_scope().enter(MediaSignals::create);
1057        self.get_media_signals().set(Some(created));
1058        created
1059    }
1060
1061    /// Returns the lazily initialized `/markdown` signal group.
1062    ///
1063    /// # Arguments
1064    ///
1065    /// - `&Self` - Reactive showcase state reference.
1066    ///
1067    /// # Returns
1068    ///
1069    /// - `MarkdownSignals` - Active `/markdown` signal group.
1070    fn markdown_group(&self) -> MarkdownSignals {
1071        if let Some(existing) = self.get_markdown_signals().get() {
1072            return existing;
1073        }
1074        let created: MarkdownSignals = self.get_state_scope().enter(MarkdownSignals::create);
1075        self.get_markdown_signals().set(Some(created));
1076        created
1077    }
1078
1079    /// Returns the lazily initialized `/stress` signal group.
1080    ///
1081    /// # Arguments
1082    ///
1083    /// - `&Self` - Reactive showcase state reference.
1084    ///
1085    /// # Returns
1086    ///
1087    /// - `StressSignals` - Active `/stress` signal group.
1088    fn stress_group(&self) -> StressSignals {
1089        if let Some(existing) = self.get_stress_signals().get() {
1090            return existing;
1091        }
1092        let created: StressSignals = self.get_state_scope().enter(StressSignals::create);
1093        self.get_stress_signals().set(Some(created));
1094        created
1095    }
1096
1097    /// Returns the lazily initialized `/charts` signal group.
1098    ///
1099    /// # Arguments
1100    ///
1101    /// - `&Self` - Reactive showcase state reference.
1102    ///
1103    /// # Returns
1104    ///
1105    /// - `ChartsSignals` - Active `/charts` signal group.
1106    fn charts_group(&self) -> ChartsSignals {
1107        if let Some(existing) = self.get_charts_signals().get() {
1108            return existing;
1109        }
1110        let created: ChartsSignals = self.get_state_scope().enter(ChartsSignals::create);
1111        self.get_charts_signals().set(Some(created));
1112        created
1113    }
1114
1115    /// Returns the lazily initialized `/water` signal group.
1116    ///
1117    /// # Arguments
1118    ///
1119    /// - `&Self` - Reactive showcase state reference.
1120    ///
1121    /// # Returns
1122    ///
1123    /// - `WaterSignals` - Active `/water` signal group.
1124    fn water_group(&self) -> WaterSignals {
1125        if let Some(existing) = self.get_water_signals().get() {
1126            return existing;
1127        }
1128        let created: WaterSignals = self.get_state_scope().enter(WaterSignals::create);
1129        self.get_water_signals().set(Some(created));
1130        created
1131    }
1132
1133    /// Returns `true` when the `/water` `GyroLiquidGameScene` has been lazily initialized.
1134    ///
1135    /// # Arguments
1136    ///
1137    /// - `&Self` - Reactive showcase state reference.
1138    ///
1139    /// # Returns
1140    ///
1141    /// - `bool` - Whether the liquid simulation handle is materialized.
1142    #[must_use]
1143    pub fn has_water_scene_initialized(&self) -> bool {
1144        self.get_water_scene_cell().borrow().is_some()
1145    }
1146
1147    /// Returns the shared `GyroLiquidGameScene`, materializing it lazily on first `/water` visit.
1148    ///
1149    /// # Arguments
1150    ///
1151    /// - `&Self` - Reactive showcase state reference.
1152    ///
1153    /// # Returns
1154    ///
1155    /// - `GyroLiquidGameScene` - Active shareable liquid physics scene handle.
1156    #[must_use]
1157    pub fn get_or_init_water_scene(&self) -> GyroLiquidGameScene {
1158        if let Some(existing) = self.get_water_scene_cell().borrow().as_ref() {
1159            return existing.clone();
1160        }
1161        let created: GyroLiquidGameScene = GyroLiquidGameScene::default();
1162        *self.get_water_scene_cell().borrow_mut() = Some(created.clone());
1163        let _: bool = self
1164            .water_group()
1165            .get_stats()
1166            .set_if_changed(created.stats());
1167        created
1168    }
1169
1170    /// Returns the `/water` liquid fill percentage signal (`25.0..=80.0`).
1171    ///
1172    /// # Arguments
1173    ///
1174    /// - `&Self` - Reactive showcase state reference.
1175    ///
1176    /// # Returns
1177    ///
1178    /// - `Signal<f32>` - Fill level percentage signal handle.
1179    #[must_use]
1180    pub fn get_water_fill_pct(&self) -> Signal<f32> {
1181        self.water_group().get_fill_pct()
1182    }
1183
1184    /// Returns the `/water` viscosity preset index signal (`0=Water`, `1=Light Oil`, `2=Honey`).
1185    ///
1186    /// # Arguments
1187    ///
1188    /// - `&Self` - Reactive showcase state reference.
1189    ///
1190    /// # Returns
1191    ///
1192    /// - `Signal<usize>` - Viscosity preset index signal handle.
1193    #[must_use]
1194    pub fn get_water_viscosity_idx(&self) -> Signal<usize> {
1195        self.water_group().get_viscosity_idx()
1196    }
1197
1198    /// Returns the `/water` buoyant floating bodies toggle signal.
1199    ///
1200    /// # Arguments
1201    ///
1202    /// - `&Self` - Reactive showcase state reference.
1203    ///
1204    /// # Returns
1205    ///
1206    /// - `Signal<bool>` - Buoyant bodies toggle signal handle.
1207    #[must_use]
1208    pub fn get_water_buoyant_enabled(&self) -> Signal<bool> {
1209        self.water_group().get_buoyant_enabled()
1210    }
1211
1212    /// Returns the `/water` fullscreen portal open signal.
1213    ///
1214    /// # Arguments
1215    ///
1216    /// - `&Self` - Reactive showcase state reference.
1217    ///
1218    /// # Returns
1219    ///
1220    /// - `Signal<bool>` - Fullscreen portal open signal handle.
1221    #[must_use]
1222    pub fn get_water_fullscreen_open(&self) -> Signal<bool> {
1223        self.water_group().get_fullscreen_open()
1224    }
1225
1226    /// Returns the `/water` motion sensor permission status message signal.
1227    ///
1228    /// # Arguments
1229    ///
1230    /// - `&Self` - Reactive showcase state reference.
1231    ///
1232    /// # Returns
1233    ///
1234    /// - `Signal<String>` - Motion sensor status signal handle.
1235    #[must_use]
1236    pub fn get_water_sensor_perm_status(&self) -> Signal<String> {
1237        self.water_group().get_sensor_perm_status()
1238    }
1239
1240    /// Returns the `/water` live physics telemetry snapshot signal.
1241    ///
1242    /// # Arguments
1243    ///
1244    /// - `&Self` - Reactive showcase state reference.
1245    ///
1246    /// # Returns
1247    ///
1248    /// - `Signal<GyroLiquidStats>` - Live liquid physics telemetry signal handle.
1249    #[must_use]
1250    pub fn get_water_stats(&self) -> Signal<GyroLiquidStats> {
1251        self.water_group().get_stats()
1252    }
1253
1254    /// Returns the interactive counter signal for `/reactive`.
1255    ///
1256    /// # Arguments
1257    ///
1258    /// - `&Self` - Reactive showcase state reference.
1259    ///
1260    /// # Returns
1261    ///
1262    /// - `Signal<i32>` - Counter signal handle.
1263    #[must_use]
1264    pub fn get_counter(&self) -> Signal<i32> {
1265        self.reactive_group().get_counter()
1266    }
1267
1268    /// Returns the derived `counter * 2` memo for `/reactive`.
1269    ///
1270    /// # Arguments
1271    ///
1272    /// - `&Self` - Reactive showcase state reference.
1273    ///
1274    /// # Returns
1275    ///
1276    /// - `Memo<i32>` - Doubled counter memo handle.
1277    #[must_use]
1278    pub fn get_doubled(&self) -> Memo<i32> {
1279        self.reactive_group().get_doubled()
1280    }
1281
1282    /// Returns the component-scoped demo render pipeline preview index signal.
1283    ///
1284    /// # Arguments
1285    ///
1286    /// - `&Self` - Reactive showcase state reference.
1287    ///
1288    /// # Returns
1289    ///
1290    /// - `Signal<usize>` - Render mode index signal handle.
1291    #[must_use]
1292    pub fn get_render_mode_index(&self) -> Signal<usize> {
1293        self.render_window_group().get_render_mode_index()
1294    }
1295
1296    /// Returns the component-scoped demo FPS cap index signal on `/window`.
1297    ///
1298    /// # Arguments
1299    ///
1300    /// - `&Self` - Reactive showcase state reference.
1301    ///
1302    /// # Returns
1303    ///
1304    /// - `Signal<usize>` - FPS cap index signal handle.
1305    #[must_use]
1306    pub fn get_demo_fps_cap_index(&self) -> Signal<usize> {
1307        self.render_window_group().get_demo_fps_cap_index()
1308    }
1309
1310    /// Returns the controlled fullscreen toggle signal.
1311    ///
1312    /// # Arguments
1313    ///
1314    /// - `&Self` - Reactive showcase state reference.
1315    ///
1316    /// # Returns
1317    ///
1318    /// - `Signal<bool>` - Fullscreen signal handle.
1319    #[must_use]
1320    pub fn get_fullscreen(&self) -> Signal<bool> {
1321        self.render_window_group().get_fullscreen()
1322    }
1323
1324    /// Returns the Dynamic Island active state signal.
1325    ///
1326    /// # Arguments
1327    ///
1328    /// - `&Self` - Reactive showcase state reference.
1329    ///
1330    /// # Returns
1331    ///
1332    /// - `Signal<bool>` - Island active signal handle.
1333    #[must_use]
1334    pub fn get_island_active(&self) -> Signal<bool> {
1335        self.render_window_group().get_island_active()
1336    }
1337
1338    /// Returns the Dynamic Island progress signal (`0..=100`).
1339    ///
1340    /// # Arguments
1341    ///
1342    /// - `&Self` - Reactive showcase state reference.
1343    ///
1344    /// # Returns
1345    ///
1346    /// - `Signal<u8>` - Island progress signal handle.
1347    #[must_use]
1348    pub fn get_island_progress(&self) -> Signal<u8> {
1349        self.render_window_group().get_island_progress()
1350    }
1351
1352    /// Returns the camera permission status readout signal.
1353    ///
1354    /// # Arguments
1355    ///
1356    /// - `&Self` - Reactive showcase state reference.
1357    ///
1358    /// # Returns
1359    ///
1360    /// - `Signal<String>` - Camera permission status signal handle.
1361    #[must_use]
1362    pub fn get_camera_perm_status(&self) -> Signal<String> {
1363        self.render_window_group().get_camera_perm_status()
1364    }
1365
1366    /// Returns the protocol registration status readout signal.
1367    ///
1368    /// # Arguments
1369    ///
1370    /// - `&Self` - Reactive showcase state reference.
1371    ///
1372    /// # Returns
1373    ///
1374    /// - `Signal<String>` - Protocol status signal handle.
1375    #[must_use]
1376    pub fn get_protocol_status(&self) -> Signal<String> {
1377        self.render_window_group().get_protocol_status()
1378    }
1379
1380    /// Returns the accessibility live announcement counter signal.
1381    ///
1382    /// # Arguments
1383    ///
1384    /// - `&Self` - Reactive showcase state reference.
1385    ///
1386    /// # Returns
1387    ///
1388    /// - `Signal<u32>` - Accessibility counter signal handle.
1389    #[must_use]
1390    pub fn get_a11y_announcements(&self) -> Signal<u32> {
1391        self.render_window_group().get_a11y_announcements()
1392    }
1393
1394    /// Returns the haptic pulse counter signal.
1395    ///
1396    /// # Arguments
1397    ///
1398    /// - `&Self` - Reactive showcase state reference.
1399    ///
1400    /// # Returns
1401    ///
1402    /// - `Signal<u32>` - Haptic counter signal handle.
1403    #[must_use]
1404    pub fn get_haptic_pulses(&self) -> Signal<u32> {
1405        self.render_window_group().get_haptic_pulses()
1406    }
1407
1408    /// Returns the simulated target platform index signal on `/window`.
1409    ///
1410    /// # Arguments
1411    ///
1412    /// - `&Self` - Reactive showcase state reference.
1413    ///
1414    /// # Returns
1415    ///
1416    /// - `Signal<usize>` - Target platform index signal handle.
1417    #[must_use]
1418    pub fn get_os_target_platform_idx(&self) -> Signal<usize> {
1419        self.render_window_group().get_os_target_platform_idx()
1420    }
1421
1422    /// Returns the Dynamic Island presentation mode index signal.
1423    ///
1424    /// # Arguments
1425    ///
1426    /// - `&Self` - Reactive showcase state reference.
1427    ///
1428    /// # Returns
1429    ///
1430    /// - `Signal<usize>` - Island presentation mode index signal handle.
1431    #[must_use]
1432    pub fn get_island_mode_idx(&self) -> Signal<usize> {
1433        self.render_window_group().get_island_mode_idx()
1434    }
1435
1436    /// Returns the live system notifications stack signal.
1437    ///
1438    /// # Arguments
1439    ///
1440    /// - `&Self` - Reactive showcase state reference.
1441    ///
1442    /// # Returns
1443    ///
1444    /// - `Signal<Vec<(String, String)>>` - System notifications signal handle.
1445    #[must_use]
1446    pub fn get_system_notifications(&self) -> Signal<Vec<(String, String)>> {
1447        self.render_window_group().get_system_notifications()
1448    }
1449
1450    /// Returns the per-permission status vector signal on `/window`.
1451    ///
1452    /// # Arguments
1453    ///
1454    /// - `&Self` - Reactive showcase state reference.
1455    ///
1456    /// # Returns
1457    ///
1458    /// - `Signal<Vec<PermissionStatus>>` - Permission statuses signal handle.
1459    #[must_use]
1460    pub fn get_permission_statuses(&self) -> Signal<Vec<PermissionStatus>> {
1461        self.render_window_group().get_permission_statuses()
1462    }
1463
1464    /// Returns the controlled username input signal.
1465    ///
1466    /// # Arguments
1467    ///
1468    /// - `&Self` - Reactive showcase state reference.
1469    ///
1470    /// # Returns
1471    ///
1472    /// - `Signal<String>` - Username signal handle.
1473    #[must_use]
1474    pub fn get_username(&self) -> Signal<String> {
1475        self.forms_group().get_username()
1476    }
1477
1478    /// Returns the controlled multi-line bio textarea signal.
1479    ///
1480    /// # Arguments
1481    ///
1482    /// - `&Self` - Reactive showcase state reference.
1483    ///
1484    /// # Returns
1485    ///
1486    /// - `Signal<String>` - Bio signal handle.
1487    #[must_use]
1488    pub fn get_bio(&self) -> Signal<String> {
1489        self.forms_group().get_bio()
1490    }
1491
1492    /// Returns the controlled numeric stepper signal.
1493    ///
1494    /// # Arguments
1495    ///
1496    /// - `&Self` - Reactive showcase state reference.
1497    ///
1498    /// # Returns
1499    ///
1500    /// - `Signal<i64>` - Stepper value signal handle.
1501    #[must_use]
1502    pub fn get_stepper_value(&self) -> Signal<i64> {
1503        self.forms_group().get_stepper_value()
1504    }
1505
1506    /// Returns the controlled radio group selection index signal.
1507    ///
1508    /// # Arguments
1509    ///
1510    /// - `&Self` - Reactive showcase state reference.
1511    ///
1512    /// # Returns
1513    ///
1514    /// - `Signal<usize>` - Radio index signal handle.
1515    #[must_use]
1516    pub fn get_radio_index(&self) -> Signal<usize> {
1517        self.forms_group().get_radio_index()
1518    }
1519
1520    /// Returns the controlled continuous slider value signal.
1521    ///
1522    /// # Arguments
1523    ///
1524    /// - `&Self` - Reactive showcase state reference.
1525    ///
1526    /// # Returns
1527    ///
1528    /// - `Signal<f32>` - Slider value signal handle.
1529    #[must_use]
1530    pub fn get_slider_value(&self) -> Signal<f32> {
1531        self.forms_group().get_slider_value()
1532    }
1533
1534    /// Returns the controlled select dropdown index signal.
1535    ///
1536    /// # Arguments
1537    ///
1538    /// - `&Self` - Reactive showcase state reference.
1539    ///
1540    /// # Returns
1541    ///
1542    /// - `Signal<usize>` - Select index signal handle.
1543    #[must_use]
1544    pub fn get_select_index(&self) -> Signal<usize> {
1545        self.forms_group().get_select_index()
1546    }
1547
1548    /// Returns the controlled select dropdown open flag signal.
1549    ///
1550    /// # Arguments
1551    ///
1552    /// - `&Self` - Reactive showcase state reference.
1553    ///
1554    /// # Returns
1555    ///
1556    /// - `Signal<bool>` - Select open signal handle.
1557    #[must_use]
1558    pub fn get_select_open(&self) -> Signal<bool> {
1559        self.forms_group().get_select_open()
1560    }
1561
1562    /// Returns the controlled star rating value signal.
1563    ///
1564    /// # Arguments
1565    ///
1566    /// - `&Self` - Reactive showcase state reference.
1567    ///
1568    /// # Returns
1569    ///
1570    /// - `Signal<usize>` - Rating value signal handle.
1571    #[must_use]
1572    pub fn get_rating_value(&self) -> Signal<usize> {
1573        self.forms_group().get_rating_value()
1574    }
1575
1576    /// Returns the controlled toggle pill pressed state signal.
1577    ///
1578    /// # Arguments
1579    ///
1580    /// - `&Self` - Reactive showcase state reference.
1581    ///
1582    /// # Returns
1583    ///
1584    /// - `Signal<bool>` - Pin toggled signal handle.
1585    #[must_use]
1586    pub fn get_pin_toggled(&self) -> Signal<bool> {
1587        self.forms_group().get_pin_toggled()
1588    }
1589
1590    /// Returns the controlled hardware acceleration toggle switch signal.
1591    ///
1592    /// # Arguments
1593    ///
1594    /// - `&Self` - Reactive showcase state reference.
1595    ///
1596    /// # Returns
1597    ///
1598    /// - `Signal<bool>` - Hardware acceleration signal handle.
1599    #[must_use]
1600    pub fn get_hardware_accel(&self) -> Signal<bool> {
1601        self.forms_group().get_hardware_accel()
1602    }
1603
1604    /// Returns the controlled terms checkbox signal.
1605    ///
1606    /// # Arguments
1607    ///
1608    /// - `&Self` - Reactive showcase state reference.
1609    ///
1610    /// # Returns
1611    ///
1612    /// - `Signal<bool>` - Terms checkbox signal handle.
1613    #[must_use]
1614    pub fn get_agree_terms(&self) -> Signal<bool> {
1615        self.forms_group().get_agree_terms()
1616    }
1617
1618    /// Returns the controlled tab bar index signal.
1619    ///
1620    /// # Arguments
1621    ///
1622    /// - `&Self` - Reactive showcase state reference.
1623    ///
1624    /// # Returns
1625    ///
1626    /// - `Signal<usize>` - Active tab signal handle.
1627    #[must_use]
1628    pub fn get_active_tab(&self) -> Signal<usize> {
1629        self.forms_group().get_active_tab()
1630    }
1631
1632    /// Returns the controlled pagination page number signal.
1633    ///
1634    /// # Arguments
1635    ///
1636    /// - `&Self` - Reactive showcase state reference.
1637    ///
1638    /// # Returns
1639    ///
1640    /// - `Signal<usize>` - Page index signal handle.
1641    #[must_use]
1642    pub fn get_page_index(&self) -> Signal<usize> {
1643        self.forms_group().get_page_index()
1644    }
1645
1646    /// Returns the controlled steps indicator index signal.
1647    ///
1648    /// # Arguments
1649    ///
1650    /// - `&Self` - Reactive showcase state reference.
1651    ///
1652    /// # Returns
1653    ///
1654    /// - `Signal<usize>` - Step index signal handle.
1655    #[must_use]
1656    pub fn get_step_index(&self) -> Signal<usize> {
1657        self.forms_group().get_step_index()
1658    }
1659
1660    /// Returns the controlled accordion expanded index signal.
1661    ///
1662    /// # Arguments
1663    ///
1664    /// - `&Self` - Reactive showcase state reference.
1665    ///
1666    /// # Returns
1667    ///
1668    /// - `Signal<Option<usize>>` - Accordion open index signal handle.
1669    #[must_use]
1670    pub fn get_accordion_open(&self) -> Signal<Option<usize>> {
1671        self.forms_group().get_accordion_open()
1672    }
1673
1674    /// Returns the controlled accent color picker signal.
1675    ///
1676    /// # Arguments
1677    ///
1678    /// - `&Self` - Reactive showcase state reference.
1679    ///
1680    /// # Returns
1681    ///
1682    /// - `Signal<Color>` - Picker color signal handle.
1683    #[must_use]
1684    pub fn get_picker_color(&self) -> Signal<Color> {
1685        self.forms_group().get_picker_color()
1686    }
1687
1688    /// Returns the controlled 24-hour time picker signal.
1689    ///
1690    /// # Arguments
1691    ///
1692    /// - `&Self` - Reactive showcase state reference.
1693    ///
1694    /// # Returns
1695    ///
1696    /// - `Signal<(u8, u8)>` - Picker time signal handle.
1697    #[must_use]
1698    pub fn get_picker_time(&self) -> Signal<(u8, u8)> {
1699        self.forms_group().get_picker_time()
1700    }
1701
1702    /// Returns the controlled dynamic tag input list signal.
1703    ///
1704    /// # Arguments
1705    ///
1706    /// - `&Self` - Reactive showcase state reference.
1707    ///
1708    /// # Returns
1709    ///
1710    /// - `Signal<Vec<String>>` - Tag items signal handle.
1711    #[must_use]
1712    pub fn get_tag_items(&self) -> Signal<Vec<String>> {
1713        self.forms_group().get_tag_items()
1714    }
1715
1716    /// Returns the controlled interactive tree selected label signal.
1717    ///
1718    /// # Arguments
1719    ///
1720    /// - `&Self` - Reactive showcase state reference.
1721    ///
1722    /// # Returns
1723    ///
1724    /// - `Signal<Option<String>>` - Tree selection signal handle.
1725    #[must_use]
1726    pub fn get_tree_selected(&self) -> Signal<Option<String>> {
1727        self.forms_group().get_tree_selected()
1728    }
1729
1730    /// Returns the controlled breadcrumb active index signal.
1731    ///
1732    /// # Arguments
1733    ///
1734    /// - `&Self` - Reactive showcase state reference.
1735    ///
1736    /// # Returns
1737    ///
1738    /// - `Signal<usize>` - Breadcrumb index signal handle.
1739    #[must_use]
1740    pub fn get_breadcrumb_active(&self) -> Signal<usize> {
1741        self.forms_group().get_breadcrumb_active()
1742    }
1743
1744    /// Returns the controlled modal open signal on `/overlays`.
1745    ///
1746    /// # Arguments
1747    ///
1748    /// - `&Self` - Reactive showcase state reference.
1749    ///
1750    /// # Returns
1751    ///
1752    /// - `Signal<bool>` - Modal open signal handle.
1753    #[must_use]
1754    pub fn get_modal_open(&self) -> Signal<bool> {
1755        self.overlays_group().get_modal_open()
1756    }
1757
1758    /// Returns the controlled drawer open signal on `/overlays`.
1759    ///
1760    /// # Arguments
1761    ///
1762    /// - `&Self` - Reactive showcase state reference.
1763    ///
1764    /// # Returns
1765    ///
1766    /// - `Signal<bool>` - Drawer open signal handle.
1767    #[must_use]
1768    pub fn get_drawer_open(&self) -> Signal<bool> {
1769        self.overlays_group().get_drawer_open()
1770    }
1771
1772    /// Returns the controlled sheet open signal on `/overlays`.
1773    ///
1774    /// # Arguments
1775    ///
1776    /// - `&Self` - Reactive showcase state reference.
1777    ///
1778    /// # Returns
1779    ///
1780    /// - `Signal<bool>` - Sheet open signal handle.
1781    #[must_use]
1782    pub fn get_sheet_open(&self) -> Signal<bool> {
1783        self.overlays_group().get_sheet_open()
1784    }
1785
1786    /// Returns the controlled popover open signal on `/overlays`.
1787    ///
1788    /// # Arguments
1789    ///
1790    /// - `&Self` - Reactive showcase state reference.
1791    ///
1792    /// # Returns
1793    ///
1794    /// - `Signal<bool>` - Popover open signal handle.
1795    #[must_use]
1796    pub fn get_popover_open(&self) -> Signal<bool> {
1797        self.overlays_group().get_popover_open()
1798    }
1799
1800    /// Returns the controlled dropdown open signal on `/overlays`.
1801    ///
1802    /// # Arguments
1803    ///
1804    /// - `&Self` - Reactive showcase state reference.
1805    ///
1806    /// # Returns
1807    ///
1808    /// - `Signal<bool>` - Dropdown open signal handle.
1809    #[must_use]
1810    pub fn get_dropdown_open(&self) -> Signal<bool> {
1811        self.overlays_group().get_dropdown_open()
1812    }
1813
1814    /// Returns the controlled dropdown selected index signal on `/overlays`.
1815    ///
1816    /// # Arguments
1817    ///
1818    /// - `&Self` - Reactive showcase state reference.
1819    ///
1820    /// # Returns
1821    ///
1822    /// - `Signal<Option<usize>>` - Dropdown selected index signal handle.
1823    #[must_use]
1824    pub fn get_dropdown_selected(&self) -> Signal<Option<usize>> {
1825        self.overlays_group().get_dropdown_selected()
1826    }
1827
1828    /// Returns the controlled toast banner visibility signal on `/overlays`.
1829    ///
1830    /// # Arguments
1831    ///
1832    /// - `&Self` - Reactive showcase state reference.
1833    ///
1834    /// # Returns
1835    ///
1836    /// - `Signal<bool>` - Toast visibility signal handle.
1837    #[must_use]
1838    pub fn get_toast_visible(&self) -> Signal<bool> {
1839        self.overlays_group().get_toast_visible()
1840    }
1841
1842    /// Returns the controlled notification visibility signal on `/overlays`.
1843    ///
1844    /// # Arguments
1845    ///
1846    /// - `&Self` - Reactive showcase state reference.
1847    ///
1848    /// # Returns
1849    ///
1850    /// - `Signal<bool>` - Notification visibility signal handle.
1851    #[must_use]
1852    pub fn get_notif_visible(&self) -> Signal<bool> {
1853        self.overlays_group().get_notif_visible()
1854    }
1855
1856    /// Returns the controlled loading overlay active signal on `/overlays`.
1857    ///
1858    /// # Arguments
1859    ///
1860    /// - `&Self` - Reactive showcase state reference.
1861    ///
1862    /// # Returns
1863    ///
1864    /// - `Signal<bool>` - Loading active signal handle.
1865    #[must_use]
1866    pub fn get_loading_active(&self) -> Signal<bool> {
1867        self.overlays_group().get_loading_active()
1868    }
1869
1870    /// Returns the vertical scroll offset signal driving the 10,000-row virtualized list on `/data`.
1871    ///
1872    /// # Arguments
1873    ///
1874    /// - `&Self` - Reactive showcase state reference.
1875    ///
1876    /// # Returns
1877    ///
1878    /// - `Signal<f32>` - Virtual list scroll offset signal handle.
1879    #[must_use]
1880    pub fn get_list_scroll_y(&self) -> Signal<f32> {
1881        self.data_group().get_list_scroll_y()
1882    }
1883
1884    /// Returns the live 3D quality and ray-tracing configuration signal.
1885    ///
1886    /// # Arguments
1887    ///
1888    /// - `&Self` - Reactive showcase state reference.
1889    ///
1890    /// # Returns
1891    ///
1892    /// - `Signal<RenderQualityConfig>` - 3D quality configuration signal handle.
1893    #[must_use]
1894    pub fn get_engine3d_quality(&self) -> Signal<RenderQualityConfig> {
1895        self.engine3d_group().get_engine3d_quality()
1896    }
1897
1898    /// Returns the live 3D quality preset index signal.
1899    ///
1900    /// # Arguments
1901    ///
1902    /// - `&Self` - Reactive showcase state reference.
1903    ///
1904    /// # Returns
1905    ///
1906    /// - `Signal<usize>` - 3D quality preset index signal handle.
1907    #[must_use]
1908    pub fn get_engine3d_preset_idx(&self) -> Signal<usize> {
1909        self.engine3d_group().get_engine3d_preset_idx()
1910    }
1911
1912    /// Returns the live 3D ray-tracing mode index signal.
1913    ///
1914    /// # Arguments
1915    ///
1916    /// - `&Self` - Reactive showcase state reference.
1917    ///
1918    /// # Returns
1919    ///
1920    /// - `Signal<usize>` - 3D ray-tracing mode index signal handle.
1921    #[must_use]
1922    pub fn get_engine3d_rt_idx(&self) -> Signal<usize> {
1923        self.engine3d_group().get_engine3d_rt_idx()
1924    }
1925
1926    /// Returns the live 3D internal resolution scale percentage signal.
1927    ///
1928    /// # Arguments
1929    ///
1930    /// - `&Self` - Reactive showcase state reference.
1931    ///
1932    /// # Returns
1933    ///
1934    /// - `Signal<f32>` - 3D resolution scale signal handle.
1935    #[must_use]
1936    pub fn get_engine3d_res_scale(&self) -> Signal<f32> {
1937        self.engine3d_group().get_engine3d_res_scale()
1938    }
1939
1940    /// Returns the live 3D sun time-of-day signal.
1941    ///
1942    /// # Arguments
1943    ///
1944    /// - `&Self` - Reactive showcase state reference.
1945    ///
1946    /// # Returns
1947    ///
1948    /// - `Signal<f32>` - 3D time-of-day signal handle.
1949    #[must_use]
1950    pub fn get_engine3d_time_of_day(&self) -> Signal<f32> {
1951        self.engine3d_group().get_engine3d_time_of_day()
1952    }
1953
1954    /// Returns the monotonic 3D model import request signal.
1955    ///
1956    /// # Arguments
1957    ///
1958    /// - `&Self` - Reactive showcase state reference.
1959    ///
1960    /// # Returns
1961    ///
1962    /// - `Signal<u64>` - 3D import queue signal handle.
1963    #[must_use]
1964    pub fn get_engine3d_import_queue(&self) -> Signal<u64> {
1965        self.engine3d_group().get_engine3d_import_queue()
1966    }
1967
1968    /// Returns the live 3D model import status readout signal.
1969    ///
1970    /// # Arguments
1971    ///
1972    /// - `&Self` - Reactive showcase state reference.
1973    ///
1974    /// # Returns
1975    ///
1976    /// - `Signal<String>` - 3D import status signal handle.
1977    #[must_use]
1978    pub fn get_engine3d_import_status(&self) -> Signal<String> {
1979        self.engine3d_group().get_engine3d_import_status()
1980    }
1981
1982    /// Returns the active 3D camera mode signal.
1983    ///
1984    /// # Arguments
1985    ///
1986    /// - `&Self` - Reactive showcase state reference.
1987    ///
1988    /// # Returns
1989    ///
1990    /// - `Signal<u8>` - 3D camera mode signal handle.
1991    #[must_use]
1992    pub fn get_engine3d_camera_mode(&self) -> Signal<u8> {
1993        self.engine3d_group().get_engine3d_camera_mode()
1994    }
1995
1996    /// Returns the preserved sibling counter signal on `/dynamic`.
1997    ///
1998    /// # Arguments
1999    ///
2000    /// - `&Self` - Reactive showcase state reference.
2001    ///
2002    /// # Returns
2003    ///
2004    /// - `Signal<i32>` - Sibling counter signal handle.
2005    #[must_use]
2006    pub fn get_sibling_counter(&self) -> Signal<i32> {
2007        self.dynamic_group().get_sibling_counter()
2008    }
2009
2010    /// Returns the latest dynamic OTA action log readout signal.
2011    ///
2012    /// # Arguments
2013    ///
2014    /// - `&Self` - Reactive showcase state reference.
2015    ///
2016    /// # Returns
2017    ///
2018    /// - `Signal<String>` - Dynamic action log signal handle.
2019    #[must_use]
2020    pub fn get_dynamic_action_log(&self) -> Signal<String> {
2021        self.dynamic_group().get_dynamic_action_log()
2022    }
2023
2024    /// Returns the simulated offline mode toggle signal for dynamic WASM tests.
2025    ///
2026    /// # Arguments
2027    ///
2028    /// - `&Self` - Reactive showcase state reference.
2029    ///
2030    /// # Returns
2031    ///
2032    /// - `Signal<bool>` - WASM offline flag signal handle.
2033    #[must_use]
2034    pub fn get_wasm_offline(&self) -> Signal<bool> {
2035        self.dynamic_group().get_wasm_offline()
2036    }
2037
2038    /// Returns the live dynamic WASM download and fault readout signal.
2039    ///
2040    /// # Arguments
2041    ///
2042    /// - `&Self` - Reactive showcase state reference.
2043    ///
2044    /// # Returns
2045    ///
2046    /// - `Signal<String>` - WASM fault status signal handle.
2047    #[must_use]
2048    pub fn get_wasm_fault_status(&self) -> Signal<String> {
2049        self.dynamic_group().get_wasm_fault_status()
2050    }
2051
2052    /// Returns the `EuvAlertDialog` open state signal on `/lab`.
2053    ///
2054    /// # Arguments
2055    ///
2056    /// - `&Self` - Reactive showcase state reference.
2057    ///
2058    /// # Returns
2059    ///
2060    /// - `Signal<bool>` - Alert dialog open signal handle.
2061    #[must_use]
2062    pub fn get_alert_dialog_open(&self) -> Signal<bool> {
2063        self.lab_group().get_alert_dialog_open()
2064    }
2065
2066    /// Returns the `EuvAlertDialog` confirmed flag signal on `/lab`.
2067    ///
2068    /// # Arguments
2069    ///
2070    /// - `&Self` - Reactive showcase state reference.
2071    ///
2072    /// # Returns
2073    ///
2074    /// - `Signal<bool>` - Alert dialog confirmed signal handle.
2075    #[must_use]
2076    pub fn get_alert_dialog_confirmed(&self) -> Signal<bool> {
2077        self.lab_group().get_alert_dialog_confirmed()
2078    }
2079
2080    /// Returns the `EuvCollapsible` expanded flag signal on `/lab`.
2081    ///
2082    /// # Arguments
2083    ///
2084    /// - `&Self` - Reactive showcase state reference.
2085    ///
2086    /// # Returns
2087    ///
2088    /// - `Signal<bool>` - Collapsible open signal handle.
2089    #[must_use]
2090    pub fn get_collapsible_open(&self) -> Signal<bool> {
2091        self.lab_group().get_collapsible_open()
2092    }
2093
2094    /// Returns the `EuvToggleGroup` active option index signal on `/lab`.
2095    ///
2096    /// # Arguments
2097    ///
2098    /// - `&Self` - Reactive showcase state reference.
2099    ///
2100    /// # Returns
2101    ///
2102    /// - `Signal<usize>` - Toggle group index signal handle.
2103    #[must_use]
2104    pub fn get_toggle_group_index(&self) -> Signal<usize> {
2105        self.lab_group().get_toggle_group_index()
2106    }
2107
2108    /// Returns the `EuvInputOtp` passcode string signal on `/lab`.
2109    ///
2110    /// # Arguments
2111    ///
2112    /// - `&Self` - Reactive showcase state reference.
2113    ///
2114    /// # Returns
2115    ///
2116    /// - `Signal<String>` - OTP code signal handle.
2117    #[must_use]
2118    pub fn get_otp_code(&self) -> Signal<String> {
2119        self.lab_group().get_otp_code()
2120    }
2121
2122    /// Returns the `EuvCommand` query string signal on `/lab`.
2123    ///
2124    /// # Arguments
2125    ///
2126    /// - `&Self` - Reactive showcase state reference.
2127    ///
2128    /// # Returns
2129    ///
2130    /// - `Signal<String>` - Command query signal handle.
2131    #[must_use]
2132    pub fn get_command_query(&self) -> Signal<String> {
2133        self.lab_group().get_command_query()
2134    }
2135
2136    /// Returns the `EuvCommand` selected index signal on `/lab`.
2137    ///
2138    /// # Arguments
2139    ///
2140    /// - `&Self` - Reactive showcase state reference.
2141    ///
2142    /// # Returns
2143    ///
2144    /// - `Signal<Option<usize>>` - Command selected index signal handle.
2145    #[must_use]
2146    pub fn get_command_selected(&self) -> Signal<Option<usize>> {
2147        self.lab_group().get_command_selected()
2148    }
2149
2150    /// Returns the `EuvHoverCard` open flag signal on `/lab`.
2151    ///
2152    /// # Arguments
2153    ///
2154    /// - `&Self` - Reactive showcase state reference.
2155    ///
2156    /// # Returns
2157    ///
2158    /// - `Signal<bool>` - Hover card open signal handle.
2159    #[must_use]
2160    pub fn get_hover_card_open(&self) -> Signal<bool> {
2161        self.lab_group().get_hover_card_open()
2162    }
2163
2164    /// Returns the `EuvCalendar` selected day signal on `/lab`.
2165    ///
2166    /// # Arguments
2167    ///
2168    /// - `&Self` - Reactive showcase state reference.
2169    ///
2170    /// # Returns
2171    ///
2172    /// - `Signal<u32>` - Calendar day signal handle.
2173    #[must_use]
2174    pub fn get_calendar_day(&self) -> Signal<u32> {
2175        self.lab_group().get_calendar_day()
2176    }
2177
2178    /// Returns the `EuvMenubar` active menu index signal on `/lab`.
2179    ///
2180    /// # Arguments
2181    ///
2182    /// - `&Self` - Reactive showcase state reference.
2183    ///
2184    /// # Returns
2185    ///
2186    /// - `Signal<Option<usize>>` - Menubar active index signal handle.
2187    #[must_use]
2188    pub fn get_menubar_active(&self) -> Signal<Option<usize>> {
2189        self.lab_group().get_menubar_active()
2190    }
2191
2192    /// Returns the `EuvCarousel` active slide index signal on `/lab`.
2193    ///
2194    /// # Arguments
2195    ///
2196    /// - `&Self` - Reactive showcase state reference.
2197    ///
2198    /// # Returns
2199    ///
2200    /// - `Signal<usize>` - Carousel index signal handle.
2201    #[must_use]
2202    pub fn get_carousel_index(&self) -> Signal<usize> {
2203        self.lab_group().get_carousel_index()
2204    }
2205
2206    /// Returns the `EuvCombobox` search query signal on `/lab`.
2207    ///
2208    /// # Arguments
2209    ///
2210    /// - `&Self` - Reactive showcase state reference.
2211    ///
2212    /// # Returns
2213    ///
2214    /// - `Signal<String>` - Combobox query signal handle.
2215    #[must_use]
2216    pub fn get_lab_combobox_query(&self) -> Signal<String> {
2217        self.lab_group().get_lab_combobox_query()
2218    }
2219
2220    /// Returns the `EuvCombobox` selected index signal on `/lab`.
2221    ///
2222    /// # Arguments
2223    ///
2224    /// - `&Self` - Reactive showcase state reference.
2225    ///
2226    /// # Returns
2227    ///
2228    /// - `Signal<usize>` - Combobox selected index signal handle.
2229    #[must_use]
2230    pub fn get_lab_combobox_selected(&self) -> Signal<usize> {
2231        self.lab_group().get_lab_combobox_selected()
2232    }
2233
2234    /// Returns the `EuvCombobox` open flag signal on `/lab`.
2235    ///
2236    /// # Arguments
2237    ///
2238    /// - `&Self` - Reactive showcase state reference.
2239    ///
2240    /// # Returns
2241    ///
2242    /// - `Signal<bool>` - Combobox open signal handle.
2243    #[must_use]
2244    pub fn get_lab_combobox_open(&self) -> Signal<bool> {
2245        self.lab_group().get_lab_combobox_open()
2246    }
2247
2248    /// Returns the `EuvDataTable` filter string signal on `/lab`.
2249    ///
2250    /// # Arguments
2251    ///
2252    /// - `&Self` - Reactive showcase state reference.
2253    ///
2254    /// # Returns
2255    ///
2256    /// - `Signal<String>` - Data table filter signal handle.
2257    #[must_use]
2258    pub fn get_lab_table_filter(&self) -> Signal<String> {
2259        self.lab_group().get_lab_table_filter()
2260    }
2261
2262    /// Returns the `EuvDataTable` ascending sort flag signal on `/lab`.
2263    ///
2264    /// # Arguments
2265    ///
2266    /// - `&Self` - Reactive showcase state reference.
2267    ///
2268    /// # Returns
2269    ///
2270    /// - `Signal<bool>` - Data table sort flag signal handle.
2271    #[must_use]
2272    pub fn get_lab_table_sort_asc(&self) -> Signal<bool> {
2273        self.lab_group().get_lab_table_sort_asc()
2274    }
2275
2276    /// Returns the `EuvDataTable` selected row index signal on `/lab`.
2277    ///
2278    /// # Arguments
2279    ///
2280    /// - `&Self` - Reactive showcase state reference.
2281    ///
2282    /// # Returns
2283    ///
2284    /// - `Signal<Option<usize>>` - Data table selected row signal handle.
2285    #[must_use]
2286    pub fn get_lab_table_selected(&self) -> Signal<Option<usize>> {
2287        self.lab_group().get_lab_table_selected()
2288    }
2289
2290    /// Returns the `EuvDatePicker` selected day signal on `/lab`.
2291    ///
2292    /// # Arguments
2293    ///
2294    /// - `&Self` - Reactive showcase state reference.
2295    ///
2296    /// # Returns
2297    ///
2298    /// - `Signal<u32>` - Date picker day signal handle.
2299    #[must_use]
2300    pub fn get_lab_date_day(&self) -> Signal<u32> {
2301        self.lab_group().get_lab_date_day()
2302    }
2303
2304    /// Returns the `EuvDatePicker` open flag signal on `/lab`.
2305    ///
2306    /// # Arguments
2307    ///
2308    /// - `&Self` - Reactive showcase state reference.
2309    ///
2310    /// # Returns
2311    ///
2312    /// - `Signal<bool>` - Date picker open signal handle.
2313    #[must_use]
2314    pub fn get_lab_date_open(&self) -> Signal<bool> {
2315        self.lab_group().get_lab_date_open()
2316    }
2317
2318    /// Returns the `EuvInputGroup` domain input value signal on `/lab`.
2319    ///
2320    /// # Arguments
2321    ///
2322    /// - `&Self` - Reactive showcase state reference.
2323    ///
2324    /// # Returns
2325    ///
2326    /// - `Signal<String>` - Input group value signal handle.
2327    #[must_use]
2328    pub fn get_lab_input_group_val(&self) -> Signal<String> {
2329        self.lab_group().get_lab_input_group_val()
2330    }
2331
2332    /// Returns the `EuvNativeSelect` selected index signal on `/lab`.
2333    ///
2334    /// # Arguments
2335    ///
2336    /// - `&Self` - Reactive showcase state reference.
2337    ///
2338    /// # Returns
2339    ///
2340    /// - `Signal<usize>` - Native select index signal handle.
2341    #[must_use]
2342    pub fn get_lab_native_select_idx(&self) -> Signal<usize> {
2343        self.lab_group().get_lab_native_select_idx()
2344    }
2345
2346    /// Returns the `EuvNavigationMenu` active dropdown index signal on `/lab`.
2347    ///
2348    /// # Arguments
2349    ///
2350    /// - `&Self` - Reactive showcase state reference.
2351    ///
2352    /// # Returns
2353    ///
2354    /// - `Signal<Option<usize>>` - Navigation menu active index signal handle.
2355    #[must_use]
2356    pub fn get_lab_nav_menu_active(&self) -> Signal<Option<usize>> {
2357        self.lab_group().get_lab_nav_menu_active()
2358    }
2359
2360    /// Returns the `EuvResizable` split ratio signal on `/lab`.
2361    ///
2362    /// # Arguments
2363    ///
2364    /// - `&Self` - Reactive showcase state reference.
2365    ///
2366    /// # Returns
2367    ///
2368    /// - `Signal<f32>` - Split ratio signal handle.
2369    #[must_use]
2370    pub fn get_lab_split_ratio(&self) -> Signal<f32> {
2371        self.lab_group().get_lab_split_ratio()
2372    }
2373
2374    /// Returns the nested scroll-chaining block toggle signal on `/lab`.
2375    ///
2376    /// # Arguments
2377    ///
2378    /// - `&Self` - Reactive showcase state reference.
2379    ///
2380    /// # Returns
2381    ///
2382    /// - `Signal<bool>` - Scroll chain toggle signal handle.
2383    #[must_use]
2384    pub fn get_lab_block_scroll_chain(&self) -> Signal<bool> {
2385        self.lab_group().get_lab_block_scroll_chain()
2386    }
2387
2388    /// Returns the click event bubbling stop toggle signal on `/lab`.
2389    ///
2390    /// # Arguments
2391    ///
2392    /// - `&Self` - Reactive showcase state reference.
2393    ///
2394    /// # Returns
2395    ///
2396    /// - `Signal<bool>` - Click bubble toggle signal handle.
2397    #[must_use]
2398    pub fn get_lab_stop_click_bubble(&self) -> Signal<bool> {
2399        self.lab_group().get_lab_stop_click_bubble()
2400    }
2401
2402    /// Returns the outer parent card click counter signal on `/lab`.
2403    ///
2404    /// # Arguments
2405    ///
2406    /// - `&Self` - Reactive showcase state reference.
2407    ///
2408    /// # Returns
2409    ///
2410    /// - `Signal<u32>` - Parent click counter signal handle.
2411    #[must_use]
2412    pub fn get_lab_parent_clicks(&self) -> Signal<u32> {
2413        self.lab_group().get_lab_parent_clicks()
2414    }
2415
2416    /// Returns the inner child button click counter signal on `/lab`.
2417    ///
2418    /// # Arguments
2419    ///
2420    /// - `&Self` - Reactive showcase state reference.
2421    ///
2422    /// # Returns
2423    ///
2424    /// - `Signal<u32>` - Child click counter signal handle.
2425    #[must_use]
2426    pub fn get_lab_child_clicks(&self) -> Signal<u32> {
2427        self.lab_group().get_lab_child_clicks()
2428    }
2429
2430    /// Returns the resize state-preservation counter signal on `/lab`.
2431    ///
2432    /// # Arguments
2433    ///
2434    /// - `&Self` - Reactive showcase state reference.
2435    ///
2436    /// # Returns
2437    ///
2438    /// - `Signal<u32>` - Resize preserve counter signal handle.
2439    #[must_use]
2440    pub fn get_lab_resize_preserve_count(&self) -> Signal<u32> {
2441        self.lab_group().get_lab_resize_preserve_count()
2442    }
2443
2444    /// Returns the RTL direction mode toggle signal on `/lab`.
2445    ///
2446    /// # Arguments
2447    ///
2448    /// - `&Self` - Reactive showcase state reference.
2449    ///
2450    /// # Returns
2451    ///
2452    /// - `Signal<bool>` - RTL mode signal handle.
2453    #[must_use]
2454    pub fn get_lab_rtl_mode(&self) -> Signal<bool> {
2455        self.lab_group().get_lab_rtl_mode()
2456    }
2457
2458    /// Returns the animated GIF playback signal on `/media`.
2459    ///
2460    /// # Arguments
2461    ///
2462    /// - `&Self` - Reactive showcase state reference.
2463    ///
2464    /// # Returns
2465    ///
2466    /// - `Signal<GifAnimation>` - GIF animation signal handle.
2467    #[must_use]
2468    pub fn get_media_gif(&self) -> Signal<GifAnimation> {
2469        self.media_group().get_media_gif()
2470    }
2471
2472    /// Returns the LIVE Photo asset signal on `/media`.
2473    ///
2474    /// # Arguments
2475    ///
2476    /// - `&Self` - Reactive showcase state reference.
2477    ///
2478    /// # Returns
2479    ///
2480    /// - `Signal<LivePhotoAsset>` - LIVE Photo signal handle.
2481    #[must_use]
2482    pub fn get_media_live(&self) -> Signal<LivePhotoAsset> {
2483        self.media_group().get_media_live()
2484    }
2485
2486    /// Returns the cross-platform video track signal on `/media`.
2487    ///
2488    /// # Arguments
2489    ///
2490    /// - `&Self` - Reactive showcase state reference.
2491    ///
2492    /// # Returns
2493    ///
2494    /// - `Signal<VideoTrack>` - Video track signal handle.
2495    #[must_use]
2496    pub fn get_media_video(&self) -> Signal<VideoTrack> {
2497        self.media_group().get_media_video()
2498    }
2499
2500    /// Returns the WAV audio waveform track signal on `/media`.
2501    ///
2502    /// # Arguments
2503    ///
2504    /// - `&Self` - Reactive showcase state reference.
2505    ///
2506    /// # Returns
2507    ///
2508    /// - `Signal<AudioTrack>` - Audio track signal handle.
2509    #[must_use]
2510    pub fn get_media_audio(&self) -> Signal<AudioTrack> {
2511        self.media_group().get_media_audio()
2512    }
2513
2514    /// Returns the multi-page PDF document signal on `/media`.
2515    ///
2516    /// # Arguments
2517    ///
2518    /// - `&Self` - Reactive showcase state reference.
2519    ///
2520    /// # Returns
2521    ///
2522    /// - `Signal<PdfDocument>` - PDF document signal handle.
2523    #[must_use]
2524    pub fn get_media_pdf(&self) -> Signal<PdfDocument> {
2525        self.media_group().get_media_pdf()
2526    }
2527
2528    /// Returns the Media Studio HTML link click log signal.
2529    ///
2530    /// # Arguments
2531    ///
2532    /// - `&Self` - Reactive showcase state reference.
2533    ///
2534    /// # Returns
2535    ///
2536    /// - `Signal<String>` - Media HTML link log signal handle.
2537    #[must_use]
2538    pub fn get_media_html_link_log(&self) -> Signal<String> {
2539        self.media_group().get_media_html_link_log()
2540    }
2541
2542    /// Returns the Media Studio background-decode loading state signal.
2543    ///
2544    /// # Arguments
2545    ///
2546    /// - `&Self` - Reactive showcase state reference.
2547    ///
2548    /// # Returns
2549    ///
2550    /// - `Signal<bool>` - Media loading state signal handle.
2551    #[must_use]
2552    pub fn get_media_loading(&self) -> Signal<bool> {
2553        self.media_group().get_media_loading()
2554    }
2555
2556    /// Returns the Markdown code block copy telemetry signal.
2557    ///
2558    /// # Arguments
2559    ///
2560    /// - `&Self` - Reactive showcase state reference.
2561    ///
2562    /// # Returns
2563    ///
2564    /// - `Signal<String>` - Markdown copy log signal handle.
2565    #[must_use]
2566    pub fn get_markdown_copy_log(&self) -> Signal<String> {
2567        self.markdown_group().get_markdown_copy_log()
2568    }
2569
2570    /// Returns the Markdown hyperlink click telemetry signal.
2571    ///
2572    /// # Arguments
2573    ///
2574    /// - `&Self` - Reactive showcase state reference.
2575    ///
2576    /// # Returns
2577    ///
2578    /// - `Signal<String>` - Markdown link log signal handle.
2579    #[must_use]
2580    pub fn get_markdown_link_log(&self) -> Signal<String> {
2581        self.markdown_group().get_markdown_link_log()
2582    }
2583
2584    /// Returns the Markdown GFM task toggle counter signal.
2585    ///
2586    /// # Arguments
2587    ///
2588    /// - `&Self` - Reactive showcase state reference.
2589    ///
2590    /// # Returns
2591    ///
2592    /// - `Signal<u32>` - Markdown tasks toggled signal handle.
2593    #[must_use]
2594    pub fn get_markdown_tasks_toggled(&self) -> Signal<u32> {
2595        self.markdown_group().get_markdown_tasks_toggled()
2596    }
2597
2598    /// Returns the Markdown code example language tab index signal.
2599    ///
2600    /// # Arguments
2601    ///
2602    /// - `&Self` - Reactive showcase state reference.
2603    ///
2604    /// # Returns
2605    ///
2606    /// - `Signal<usize>` - Markdown language tab signal handle.
2607    #[must_use]
2608    pub fn get_markdown_lang_tab(&self) -> Signal<usize> {
2609        self.markdown_group().get_markdown_lang_tab()
2610    }
2611
2612    /// Returns the Markdown selectable text toggle signal.
2613    ///
2614    /// # Arguments
2615    ///
2616    /// - `&Self` - Reactive showcase state reference.
2617    ///
2618    /// # Returns
2619    ///
2620    /// - `Signal<bool>` - Markdown selectable signal handle.
2621    #[must_use]
2622    pub fn get_markdown_selectable(&self) -> Signal<bool> {
2623        self.markdown_group().get_markdown_selectable()
2624    }
2625
2626    /// Returns the Stress Lab benchmark results list signal.
2627    ///
2628    /// # Arguments
2629    ///
2630    /// - `&Self` - Reactive showcase state reference.
2631    ///
2632    /// # Returns
2633    ///
2634    /// - `Signal<Vec<StressCaseResult>>` - Stress results signal handle.
2635    #[must_use]
2636    pub fn get_stress_results(&self) -> Signal<Vec<StressCaseResult>> {
2637        self.stress_group().get_stress_results()
2638    }
2639
2640    /// Returns the Stress Lab summary readout signal.
2641    ///
2642    /// # Arguments
2643    ///
2644    /// - `&Self` - Reactive showcase state reference.
2645    ///
2646    /// # Returns
2647    ///
2648    /// - `Signal<String>` - Stress summary signal handle.
2649    #[must_use]
2650    pub fn get_stress_summary(&self) -> Signal<String> {
2651        self.stress_group().get_stress_summary()
2652    }
2653
2654    /// Returns the ECharts Studio category filter index signal.
2655    ///
2656    /// # Arguments
2657    ///
2658    /// - `&Self` - Reactive showcase state reference.
2659    ///
2660    /// # Returns
2661    ///
2662    /// - `Signal<usize>` - Charts category index signal handle.
2663    #[must_use]
2664    pub fn get_charts_category_idx(&self) -> Signal<usize> {
2665        self.charts_group().get_charts_category_idx()
2666    }
2667
2668    /// Returns the ECharts Studio live interaction readout signal.
2669    ///
2670    /// # Arguments
2671    ///
2672    /// - `&Self` - Reactive showcase state reference.
2673    ///
2674    /// # Returns
2675    ///
2676    /// - `Signal<String>` - Charts event log signal handle.
2677    #[must_use]
2678    pub fn get_charts_event_log(&self) -> Signal<String> {
2679        self.charts_group().get_charts_event_log()
2680    }
2681
2682    /// Lazily hydrates Media Studio sample assets on first `/media` visit, using a background worker thread on interactive native apps.
2683    ///
2684    /// # Arguments
2685    ///
2686    /// - `&Self` - Reactive showcase state reference.
2687    pub fn ensure_media_loaded(&self) {
2688        if self.get_media_loaded().replace(true) {
2689            return;
2690        }
2691        if self.get_bg_workers_enabled().get() {
2692            let group: MediaSignals = self.media_group();
2693            let _: bool = group.get_media_loading().set_if_changed(true);
2694            let task: BackgroundTask<MediaSampleBundle> =
2695                BackgroundTask::spawn(Self::build_media_sample_bundle);
2696            let _: bool = group.get_media_bg_task().set(Some(task));
2697            return;
2698        }
2699        let bundle: MediaSampleBundle = Self::build_media_sample_bundle();
2700        self.commit_media_sample_bundle(bundle);
2701    }
2702
2703    /// Builds the complete Media Studio sample codec bundle (GIF89a, LIVE Photo, MP4, WAV, PDF).
2704    ///
2705    /// # Returns
2706    ///
2707    /// - `MediaSampleBundle` - Decoded sample media assets ready for signal commit.
2708    fn build_media_sample_bundle() -> MediaSampleBundle {
2709        MediaSampleBundle {
2710            gif: Self::build_decoded_sample_gif(),
2711            live: LivePhotoAsset::sample_live_photo(),
2712            video: Self::build_decoded_sample_mp4(),
2713            audio: AudioTrack::sample_synth_wav(),
2714            pdf: PdfDocument::sample_pdf(),
2715        }
2716    }
2717
2718    /// Commits a decoded `MediaSampleBundle` into the reactive Media Studio signals on the UI thread.
2719    ///
2720    /// # Arguments
2721    ///
2722    /// - `&Self` - Reactive showcase state reference.
2723    /// - `MediaSampleBundle` - Decoded sample media assets.
2724    fn commit_media_sample_bundle(&self, bundle: MediaSampleBundle) {
2725        let group: MediaSignals = self.media_group();
2726        let MediaSampleBundle {
2727            gif,
2728            live,
2729            video,
2730            audio,
2731            pdf,
2732        } = bundle;
2733        let _: bool = group.get_media_gif().set(gif);
2734        let _: bool = group.get_media_live().set(live);
2735        let _: bool = group.get_media_video().set(video);
2736        let _: bool = group.get_media_audio().set(audio);
2737        let _: bool = group.get_media_pdf().set(pdf);
2738        let _: bool = group.get_media_loading().set_if_changed(false);
2739    }
2740
2741    /// Encodes and decodes a real LZW-compressed GIF89a sample stream through `GifEncoder` and `MediaCodecRegistry::decode_gif`.
2742    ///
2743    /// # Returns
2744    ///
2745    /// - `GifAnimation` - Decoded animated GIF ready for Media Studio playback.
2746    fn build_decoded_sample_gif() -> GifAnimation {
2747        let width: u16 = 220;
2748        let height: u16 = 124;
2749        let palette: [[u8; 3]; 8] = [
2750            [17, 24, 39],
2751            [30, 41, 59],
2752            [56, 189, 248],
2753            [168, 85, 247],
2754            [244, 63, 94],
2755            [52, 211, 153],
2756            [226, 232, 240],
2757            [15, 23, 42],
2758        ];
2759        let pixel_count: usize = (width as usize) * (height as usize);
2760        let mut inputs: Vec<GifEncodeFrameInput> = Vec::with_capacity(8);
2761        for frame_idx in 0..8usize {
2762            let accent_idx: u8 = (2 + (frame_idx % 4)) as u8;
2763            let bar_x: usize = (frame_idx * 24) % (width as usize);
2764            let mut indices: Vec<u8> = vec![0u8; pixel_count];
2765            for y in 0..(height as usize) {
2766                let row_off: usize = y * (width as usize);
2767                let is_band: bool = (42..82).contains(&y);
2768                for x in 0..(width as usize) {
2769                    let dist: usize = x.abs_diff(bar_x);
2770                    let color_idx: u8 = if is_band && dist < 18 {
2771                        accent_idx
2772                    } else if (x / 16 + y / 16 + frame_idx) % 2 == 0 {
2773                        1
2774                    } else {
2775                        7
2776                    };
2777                    indices[row_off + x] = color_idx;
2778                }
2779            }
2780            let mut frame: GifEncodeFrameInput = GifEncodeFrameInput::default();
2781            frame
2782                .set_width(width)
2783                .set_height(height)
2784                .set_disposal(GifDisposalMethod::Keep)
2785                .set_delay_cs(12)
2786                .set_indices(indices);
2787            inputs.push(frame);
2788        }
2789        let encoded: Vec<u8> = GifEncoder::encode(width, height, &palette, Some(0), &inputs);
2790        MediaCodecRegistry::decode_gif(&encoded, MEDIA_GIF_TITLE)
2791            .unwrap_or_else(|_: String| GifAnimation::sample_neon_gif())
2792    }
2793
2794    /// Builds and decodes a real ISOBMFF MP4 stream through `Mp4ContainerBuilder` and `VideoTrack::from_mp4_bytes`.
2795    ///
2796    /// # Returns
2797    ///
2798    /// - `VideoTrack` - Decoded HDR MP4 video track ready for Media Studio playback.
2799    fn build_decoded_sample_mp4() -> VideoTrack {
2800        let width: u32 = 280;
2801        let height: u32 = 158;
2802        let accents: [Color; 4] = [
2803            Color::hex(0x22D3EE),
2804            Color::hex(0x6366F1),
2805            Color::hex(0xEC4899),
2806            Color::hex(0x10B981),
2807        ];
2808        let mut samples: Vec<Mp4BuilderSample> = Vec::with_capacity(12);
2809        for idx in 0..12usize {
2810            let img: ImageBuffer = MediaCodecRegistry::synthesize_frame(
2811                width,
2812                height,
2813                Color::hex(0x090D16),
2814                accents[idx % accents.len()],
2815                idx + 1,
2816            );
2817            let payload: Vec<u8> =
2818                SoftwareVideoDecoder::encode_intra_rgba_packet(width, height, img.get_pixels());
2819            let mut sample: Mp4BuilderSample = Mp4BuilderSample::default();
2820            sample
2821                .set_duration_ticks(1_000)
2822                .set_composition_offset_ticks(0)
2823                .set_is_keyframe(idx % 4 == 0)
2824                .set_payload(payload);
2825            samples.push(sample);
2826        }
2827        let mp4_bytes: Vec<u8> = Mp4ContainerBuilder::build_video_mp4(
2828            width,
2829            height,
2830            1_000,
2831            VideoCodec::H264,
2832            VideoColorInfo::hdr10_bt2020_pq(1000, 400),
2833            &samples,
2834        );
2835        match VideoTrack::from_mp4_bytes(mp4_bytes, MEDIA_VIDEO_TITLE) {
2836            Ok(mut track) => {
2837                let captions: Vec<String> = MEDIA_VIDEO_CAPTIONS
2838                    .iter()
2839                    .map(|line: &&str| (*line).to_string())
2840                    .collect();
2841                track.set_captions(captions);
2842                track
2843            }
2844            Err(_) => VideoTrack::sample_hdr_video(),
2845        }
2846    }
2847
2848    /// Lazily populates the in-memory `.wasm` OTA registry on first `/dynamic` visit, offloading payload assembly to a background worker on interactive native apps.
2849    ///
2850    /// # Arguments
2851    ///
2852    /// - `&Self` - Reactive showcase state reference.
2853    pub fn ensure_wasm_registry_loaded(&self) {
2854        if self.get_wasm_registry_loaded().replace(true) {
2855            return;
2856        }
2857        if self.get_bg_workers_enabled().get() {
2858            let group: DynamicSignals = self.dynamic_group();
2859            let _: bool = group
2860                .get_wasm_fault_status()
2861                .set_if_changed(STATUS_WASM_LOADING.to_string());
2862            let task: BackgroundTask<WasmSampleBundle> =
2863                BackgroundTask::spawn(Self::build_wasm_sample_bundle);
2864            let _: bool = group.get_wasm_bg_task().set(Some(task));
2865            return;
2866        }
2867        Self::populate_wasm_registry(self.get_wasm_registry());
2868    }
2869
2870    /// Commits any pending in-flight background WASM registry build synchronously so interactive clicks never race the worker.
2871    ///
2872    /// # Arguments
2873    ///
2874    /// - `&Self` - Reactive showcase state reference.
2875    pub fn ensure_wasm_registry_ready_now(&self) {
2876        self.ensure_wasm_registry_loaded();
2877        if let Some(group) = self.get_dynamic_signals().get()
2878            && let Some(task) = group.get_wasm_bg_task().get_untracked()
2879            && let Some(bundle) = task.take_blocking()
2880        {
2881            Self::commit_wasm_sample_bundle(self.get_wasm_registry(), bundle);
2882            let _: bool = group.get_wasm_bg_task().set(None);
2883            let _: bool = group
2884                .get_wasm_fault_status()
2885                .set_if_changed(DEFAULT_WASM_STATUS.to_string());
2886        }
2887    }
2888
2889    /// Polls any active background worker tasks (`/media`, `/dynamic`) and commits finished payloads atomically onto the UI thread.
2890    ///
2891    /// # Arguments
2892    ///
2893    /// - `&Self` - Reactive showcase state reference.
2894    ///
2895    /// # Returns
2896    ///
2897    /// - `bool` - `true` if any background payload committed on this frame.
2898    pub fn poll_async_loads(&self) -> bool {
2899        let mut committed: bool = false;
2900        if let Some(media) = self.get_media_signals().get()
2901            && let Some(task) = media.get_media_bg_task().get_untracked()
2902            && let Some(bundle) = task.try_take()
2903        {
2904            let _: bool = media.get_media_bg_task().set(None);
2905            self.commit_media_sample_bundle(bundle);
2906            committed = true;
2907        }
2908        if let Some(dyn_group) = self.get_dynamic_signals().get()
2909            && let Some(task) = dyn_group.get_wasm_bg_task().get_untracked()
2910            && let Some(bundle) = task.try_take()
2911        {
2912            let _: bool = dyn_group.get_wasm_bg_task().set(None);
2913            Self::commit_wasm_sample_bundle(self.get_wasm_registry(), bundle);
2914            let _: bool = dyn_group
2915                .get_wasm_fault_status()
2916                .set_if_changed(DEFAULT_WASM_STATUS.to_string());
2917            committed = true;
2918        }
2919        committed
2920    }
2921
2922    /// Lazily initializes the Stress Lab workload descriptors on first `/stress` visit.
2923    ///
2924    /// # Arguments
2925    ///
2926    /// - `&Self` - Reactive showcase state reference.
2927    pub fn ensure_stress_loaded(&self) {
2928        if self.get_stress_loaded().replace(true) {
2929            return;
2930        }
2931        let _: bool = self.get_stress_results().set(default_stress_results());
2932    }
2933
2934    /// Lazily marks ECharts Studio hydrated on first `/charts` visit so Frame 1 incurs zero chart option allocations.
2935    ///
2936    /// # Arguments
2937    ///
2938    /// - `&Self` - Reactive showcase state reference.
2939    pub fn ensure_charts_loaded(&self) {
2940        let _: bool = self.get_charts_loaded().replace(true);
2941    }
2942
2943    /// Assembles all genuine executable partial, global, and fault-case `.wasm` binary entries into a `Send` bundle.
2944    ///
2945    /// # Returns
2946    ///
2947    /// - `WasmSampleBundle` - Pre-built `.wasm` registry entries.
2948    fn build_wasm_sample_bundle() -> WasmSampleBundle {
2949        let p_v1: Vec<u8> = build_partial_widget_wasm(TITLE_WASM_PARTIAL_V1, 1, 0x2563EB);
2950        let p_v2: Vec<u8> = build_partial_widget_wasm(WASM_TITLE_PARTIAL_V2, 2, 0x7C3AED);
2951        let g_v1: Vec<u8> = build_global_app_wasm(WASM_TITLE_GLOBAL_V1, 1);
2952        let g_v2: Vec<u8> = build_global_app_wasm(WASM_TITLE_GLOBAL_V2, 2);
2953        let entries: Vec<WasmRegistryEntry> = vec![
2954            WasmRegistryEntry {
2955                url: URL_WASM_PARTIAL_V1.to_string(),
2956                bytes: p_v1.clone(),
2957                etag: WASM_ETAG_P1.to_string(),
2958                fault: WasmFaultKind::None,
2959            },
2960            WasmRegistryEntry {
2961                url: URL_WASM_PARTIAL_V2.to_string(),
2962                bytes: p_v2,
2963                etag: WASM_ETAG_P2.to_string(),
2964                fault: WasmFaultKind::None,
2965            },
2966            WasmRegistryEntry {
2967                url: URL_WASM_GLOBAL_V1.to_string(),
2968                bytes: g_v1,
2969                etag: WASM_ETAG_G1.to_string(),
2970                fault: WasmFaultKind::None,
2971            },
2972            WasmRegistryEntry {
2973                url: URL_WASM_GLOBAL_V2.to_string(),
2974                bytes: g_v2,
2975                etag: WASM_ETAG_G2.to_string(),
2976                fault: WasmFaultKind::None,
2977            },
2978            WasmRegistryEntry {
2979                url: URL_WASM_TIMEOUT_RETRY.to_string(),
2980                bytes: p_v1.clone(),
2981                etag: WASM_ETAG_RETRY.to_string(),
2982                fault: WasmFaultKind::TimeoutOnceThenSucceed,
2983            },
2984            WasmRegistryEntry {
2985                url: URL_WASM_HTTP_500.to_string(),
2986                bytes: p_v1.clone(),
2987                etag: WASM_ETAG_500.to_string(),
2988                fault: WasmFaultKind::Http500,
2989            },
2990            WasmRegistryEntry {
2991                url: URL_WASM_CORRUPTED.to_string(),
2992                bytes: build_faulty_wasm(WasmFaultKind::CorruptedMagic),
2993                etag: WASM_ETAG_CORRUPT.to_string(),
2994                fault: WasmFaultKind::None,
2995            },
2996            WasmRegistryEntry {
2997                url: URL_WASM_TAMPERED.to_string(),
2998                bytes: p_v1,
2999                etag: WASM_ETAG_TAMPER.to_string(),
3000                fault: WasmFaultKind::TamperedChecksum,
3001            },
3002            WasmRegistryEntry {
3003                url: URL_WASM_BAD_ABI.to_string(),
3004                bytes: build_faulty_wasm(WasmFaultKind::AbiMismatch),
3005                etag: WASM_ETAG_ABI.to_string(),
3006                fault: WasmFaultKind::None,
3007            },
3008            WasmRegistryEntry {
3009                url: URL_WASM_MISSING_EXPORT.to_string(),
3010                bytes: build_faulty_wasm(WasmFaultKind::MissingExport),
3011                etag: WASM_ETAG_NOEXP.to_string(),
3012                fault: WasmFaultKind::None,
3013            },
3014            WasmRegistryEntry {
3015                url: URL_WASM_FUEL_BOMB.to_string(),
3016                bytes: build_faulty_wasm(WasmFaultKind::InfiniteLoopOutOfFuel),
3017                etag: WASM_ETAG_FUEL.to_string(),
3018                fault: WasmFaultKind::None,
3019            },
3020            WasmRegistryEntry {
3021                url: URL_WASM_TRAP.to_string(),
3022                bytes: build_faulty_wasm(WasmFaultKind::ExecutionTrap),
3023                etag: WASM_ETAG_TRAP.to_string(),
3024                fault: WasmFaultKind::None,
3025            },
3026            WasmRegistryEntry {
3027                url: URL_WASM_OVERSIZED.to_string(),
3028                bytes: build_faulty_wasm(WasmFaultKind::OversizedBinary),
3029                etag: WASM_ETAG_BIG.to_string(),
3030                fault: WasmFaultKind::None,
3031            },
3032        ];
3033        WasmSampleBundle { entries }
3034    }
3035
3036    /// Commits a pre-built `WasmSampleBundle` into `registry`.
3037    ///
3038    /// # Arguments
3039    ///
3040    /// - `&RegistryWasmFetcher` - Target CDN registry fetcher.
3041    /// - `WasmSampleBundle` - Pre-built registry entries.
3042    fn commit_wasm_sample_bundle(registry: &RegistryWasmFetcher, bundle: WasmSampleBundle) {
3043        let WasmSampleBundle { entries } = bundle;
3044        for entry in entries.into_iter() {
3045            let WasmRegistryEntry {
3046                url,
3047                bytes,
3048                etag,
3049                fault,
3050            } = entry;
3051            registry.register(url, bytes, etag, fault);
3052        }
3053    }
3054
3055    /// Registers genuine executable partial, global, and fault-case `.wasm` binaries into `registry`.
3056    ///
3057    /// # Arguments
3058    ///
3059    /// - `&RegistryWasmFetcher` - Target CDN registry fetcher.
3060    pub fn populate_wasm_registry(registry: &RegistryWasmFetcher) {
3061        let bundle: WasmSampleBundle = Self::build_wasm_sample_bundle();
3062        Self::commit_wasm_sample_bundle(registry, bundle);
3063    }
3064
3065    /// Formats a concise single-line top navbar title for `route`.
3066    ///
3067    /// # Arguments
3068    ///
3069    /// - `&str` - Active route path.
3070    ///
3071    /// # Returns
3072    ///
3073    /// - `String` - Concise 1-2 word page title for the top navigation bar.
3074    #[must_use]
3075    pub fn breadcrumb_for_route(route: &str) -> String {
3076        SHOWCASE_ROUTES
3077            .iter()
3078            .find(|spec: &&ShowcaseRouteSpec| spec.get_path() == route)
3079            .map(|spec: &ShowcaseRouteSpec| spec.get_title())
3080            .unwrap_or(route)
3081            .to_string()
3082    }
3083
3084    /// Registers dynamic OTA and WASM event handlers on `self.dynamic_hub` without eagerly allocating `/dynamic` signals.
3085    ///
3086    /// # Arguments
3087    ///
3088    /// - `&Self` - Reactive showcase state reference.
3089    fn wire_dynamic_hub_actions(&self) {
3090        let route_sig: Signal<String> = self.get_route();
3091        let dyn_cell: Rc<Cell<Option<DynamicSignals>>> = self.get_dynamic_signals().clone();
3092        let owner_scope: Scope = self.get_state_scope();
3093        let mgr_act: WasmDynamicManager = self.get_wasm_manager().clone();
3094        self.get_dynamic_hub()
3095            .on_action(move |ev: &DynamicActionEvent| {
3096                let dyn_group: DynamicSignals =
3097                    DynamicSignals::get_or_init(dyn_cell.as_ref(), owner_scope);
3098                let action_log: Signal<String> = dyn_group.get_dynamic_action_log();
3099                let wasm_status: Signal<String> = dyn_group.get_wasm_fault_status();
3100                let summary: String = format!(
3101                    "{} from {} ({})",
3102                    ev.get_action(),
3103                    ev.get_source_id(),
3104                    ev.get_payload()
3105                );
3106                let _: bool = action_log.set_if_changed(summary);
3107                if let Some(target_route) = ev.get_action().strip_prefix("navigate:") {
3108                    let _: bool = route_sig.set_if_changed(target_route.to_string());
3109                } else if ev.get_action().as_str() == "return_dynamic" {
3110                    let _: bool = route_sig.set_if_changed(ROUTE_DYNAMIC.to_string());
3111                } else if ev.get_action().as_str() == "wasm_interact" {
3112                    let scope: WasmDynamicScope = WasmDynamicScope::Partial {
3113                        slot_id: SLOT_WASM_WIDGET.to_string(),
3114                    };
3115                    match mgr_act.dispatch_wasm_event(&scope, 1) {
3116                        Ok(next_st) => {
3117                            let _: bool = wasm_status.set(format!(
3118                                "WASM euv_on_event executed inside sandbox -> next_state={next_st} (native UI re-rendered)"
3119                            ));
3120                        }
3121                        Err(err) => {
3122                            let _: bool = wasm_status.set(format!("WASM event error: {err}"));
3123                        }
3124                    }
3125                } else if ev.get_action().as_str() == "global_wasm_action" {
3126                    match mgr_act.dispatch_wasm_event(&WasmDynamicScope::Global, 1) {
3127                        Ok(next_st) => {
3128                            let _: bool = wasm_status.set(format!(
3129                                "Global WASM euv_on_event executed live -> state={next_st} (full shell re-rendered)"
3130                            ));
3131                        }
3132                        Err(err) => {
3133                            let _: bool =
3134                                wasm_status.set(format!("Global WASM event error: {err}"));
3135                        }
3136                    }
3137                } else if ev.get_action().as_str() == "global_wasm_rollback" {
3138                    match mgr_act.rollback_global("user rollback") {
3139                        Ok(ver) => {
3140                            let _: bool = wasm_status.set(format!(
3141                                "Rolled back Global WASM shell to v{ver} (0 = native shell)"
3142                            ));
3143                        }
3144                        Err(_) => {
3145                            mgr_act.restore_native_global();
3146                            let _: bool =
3147                                wasm_status.set(STATUS_RESTORED_NATIVE_SHELL.to_string());
3148                        }
3149                    }
3150                } else if ev.get_action().as_str() == "global_wasm_restore" {
3151                    mgr_act.restore_native_global();
3152                    let _: bool = wasm_status.set(STATUS_RESTORED_NATIVE_SHELL.to_string());
3153                }
3154            });
3155    }
3156
3157    /// Rebinds `hub` onto this state and updates `wasm_manager` and router integration.
3158    ///
3159    /// # Arguments
3160    ///
3161    /// - `&Self` - Mutable showcase state.
3162    /// - `DynamicUpdateHub` - Shared dynamic update hub owned by `App`.
3163    pub fn attach_dynamic_hub(&mut self, hub: DynamicUpdateHub) {
3164        let wasm_mgr: WasmDynamicManager = WasmDynamicManager::new(
3165            hub.clone(),
3166            Rc::new(self.get_wasm_registry().clone()),
3167            WasmSandboxConfig::default(),
3168        );
3169        let Self {
3170            dynamic_hub,
3171            wasm_manager,
3172            router,
3173            ..
3174        } = self;
3175        let _: EuvRouter = router.clone().with_dynamic_hub(hub.clone());
3176        *dynamic_hub = hub;
3177        *wasm_manager = wasm_mgr;
3178        self.wire_dynamic_hub_actions();
3179    }
3180
3181    /// Builds `AiAppHooks` bridging route, theme, and 3D/2D game engine telemetry and controls to AI Schema v1 without eagerly allocating `/game3d` signals.
3182    ///
3183    /// # Arguments
3184    ///
3185    /// - `&Self` - Reactive showcase state reference.
3186    ///
3187    /// # Returns
3188    ///
3189    /// - `AiAppHooks` - Configured AI automation hooks bound to this state.
3190    #[cfg(any(debug_assertions, test))]
3191    #[must_use]
3192    pub fn build_ai_hooks(&self) -> AiAppHooks {
3193        let route_get: Signal<String> = self.get_route();
3194        let route_set: Signal<String> = self.get_route();
3195        let theme_get: UiThemeState = self.get_theme().clone();
3196        let theme_set: UiThemeState = self.get_theme().clone();
3197        let e3d_stats_cell: Rc<Cell<Option<Engine3dSignals>>> = self.get_engine3d_signals().clone();
3198        let e3d_ctrl_cell: Rc<Cell<Option<Engine3dSignals>>> = self.get_engine3d_signals().clone();
3199        let owner_scope: Scope = self.get_state_scope();
3200        AiAppHooks::new()
3201            .on_route(move || route_get.get_untracked())
3202            .on_scheme(move || theme_get.get_scheme().get_untracked().as_str().to_string())
3203            .on_game_stats(move || {
3204                let g: Engine3dSignals =
3205                    Engine3dSignals::get_or_init(e3d_stats_cell.as_ref(), owner_scope);
3206                let raw: String = format!(
3207                    "{{\"preset_idx\":{},\"rt_idx\":{},\"resolution_scale_pct\":{:.1},\"time_of_day\":{:.2},\"camera_mode\":{},\"import_status\":{:?}}}",
3208                    g.get_engine3d_preset_idx().get_untracked(),
3209                    g.get_engine3d_rt_idx().get_untracked(),
3210                    g.get_engine3d_res_scale().get_untracked(),
3211                    g.get_engine3d_time_of_day().get_untracked(),
3212                    g.get_engine3d_camera_mode().get_untracked(),
3213                    g.get_engine3d_import_status().get_untracked()
3214                );
3215                AiSchemaProtocol::parse_json_value(&raw)
3216            })
3217            .on_navigate(move |target: &str| {
3218                let _: bool = route_set.set_if_changed(target.to_string());
3219                Ok(())
3220            })
3221            .on_set_theme(move |scheme_opt: Option<&str>, mode_opt: Option<&str>| {
3222                if let Some(s_name) = scheme_opt {
3223                    let matched: Option<DesignScheme> = DesignScheme::all()
3224                        .into_iter()
3225                        .find(|ds: &DesignScheme| ds.as_str().eq_ignore_ascii_case(s_name));
3226                    match matched {
3227                        Some(ds) => theme_set.select_scheme(ds),
3228                        None => return Err(format!("Unknown design scheme: {s_name}")),
3229                    }
3230                }
3231                if let Some(m_name) = mode_opt {
3232                    let next_mode: ThemeMode = if m_name.eq_ignore_ascii_case("Dark") {
3233                        ThemeMode::Dark
3234                    } else if m_name.eq_ignore_ascii_case("Light") {
3235                        ThemeMode::Light
3236                    } else {
3237                        return Err(format!("Unknown theme mode: {m_name}"));
3238                    };
3239                    let _: bool = theme_set.get_mode().set_if_changed(next_mode);
3240                }
3241                Ok(())
3242            })
3243            .on_game_control(move |cmd: &str, payload: &Value| {
3244                let g: Engine3dSignals =
3245                    Engine3dSignals::get_or_init(e3d_ctrl_cell.as_ref(), owner_scope);
3246                let num_val: f64 = payload
3247                    .as_f64()
3248                    .or_else(|| payload.get("value").and_then(|v: &Value| v.as_f64()))
3249                    .unwrap_or(0.0);
3250                match cmd {
3251                    "camera_mode" => {
3252                        let next_cam: u8 = (num_val.round() as u8).min(3);
3253                        let _: bool = g.get_engine3d_camera_mode().set_if_changed(next_cam);
3254                        Ok(AiSchemaProtocol::parse_json_value(&format!(
3255                            "{{\"camera_mode\":{next_cam}}}"
3256                        )))
3257                    }
3258                    "preset" => {
3259                        let next_p: usize = (num_val.round() as usize).min(4);
3260                        let _: bool = g.get_engine3d_preset_idx().set_if_changed(next_p);
3261                        Ok(AiSchemaProtocol::parse_json_value(&format!(
3262                            "{{\"preset_idx\":{next_p}}}"
3263                        )))
3264                    }
3265                    "ray_tracing" => {
3266                        let next_rt: usize = (num_val.round() as usize).min(3);
3267                        let _: bool = g.get_engine3d_rt_idx().set_if_changed(next_rt);
3268                        Ok(AiSchemaProtocol::parse_json_value(&format!(
3269                            "{{\"rt_idx\":{next_rt}}}"
3270                        )))
3271                    }
3272                    "resolution_scale" => {
3273                        let next_s: f32 = (num_val as f32).clamp(40.0, 125.0);
3274                        let _: bool = g.get_engine3d_res_scale().set_if_changed(next_s);
3275                        Ok(AiSchemaProtocol::parse_json_value(&format!(
3276                            "{{\"resolution_scale_pct\":{next_s:.1}}}"
3277                        )))
3278                    }
3279                    "time_of_day" => {
3280                        let next_t: f32 = (num_val as f32).clamp(6.0, 23.0);
3281                        let _: bool = g.get_engine3d_time_of_day().set_if_changed(next_t);
3282                        Ok(AiSchemaProtocol::parse_json_value(&format!(
3283                            "{{\"time_of_day\":{next_t:.2}}}"
3284                        )))
3285                    }
3286                    "import_model" => {
3287                        let next_q: u64 = g
3288                            .get_engine3d_import_queue()
3289                            .get_untracked()
3290                            .saturating_add(1);
3291                        let _: bool = g.get_engine3d_import_queue().set_if_changed(next_q);
3292                        Ok(AiSchemaProtocol::parse_json_value(&format!(
3293                            "{{\"import_queue\":{next_q}}}"
3294                        )))
3295                    }
3296                    other => Err(format!("Unknown game control command: {other}")),
3297                }
3298            })
3299            .on_set_config({
3300                let st: ShowcaseState = self.clone();
3301                move |key: &str, value: &Value| {
3302                    let as_bool = |v: &Value| -> Result<bool, String> {
3303                        v.as_bool()
3304                            .ok_or_else(|| format!("Config key '{key}' expects a boolean value"))
3305                    };
3306                    let as_usize = |v: &Value| -> Result<usize, String> {
3307                        v.as_u64()
3308                            .map(|n: u64| n as usize)
3309                            .ok_or_else(|| format!("Config key '{key}' expects an unsigned integer"))
3310                    };
3311                    let as_f32 = |v: &Value| -> Result<f32, String> {
3312                        v.as_f64()
3313                            .map(|n: f64| n as f32)
3314                            .ok_or_else(|| format!("Config key '{key}' expects a numeric value"))
3315                    };
3316                    match key {
3317                        "route" => {
3318                            let target: &str = value.as_str().ok_or_else(|| {
3319                                "Config key 'route' expects a string path".to_string()
3320                            })?;
3321                            let _: bool = st.get_route().set_if_changed(target.to_string());
3322                            Ok(Value::String(target.to_string()))
3323                        }
3324                        "theme.scheme" => {
3325                            let s_name: &str = value.as_str().ok_or_else(|| {
3326                                "Config key 'theme.scheme' expects a string".to_string()
3327                            })?;
3328                            let matched: Option<DesignScheme> = DesignScheme::all()
3329                                .into_iter()
3330                                .find(|ds: &DesignScheme| ds.as_str().eq_ignore_ascii_case(s_name));
3331                            match matched {
3332                                Some(ds) => {
3333                                    st.get_theme().select_scheme(ds);
3334                                    Ok(Value::String(ds.as_str().to_string()))
3335                                }
3336                                None => Err(format!("Unknown design scheme: {s_name}")),
3337                            }
3338                        }
3339                        "theme.mode" => {
3340                            let m_name: &str = value.as_str().ok_or_else(|| {
3341                                "Config key 'theme.mode' expects 'Light' or 'Dark'".to_string()
3342                            })?;
3343                            let next_mode: ThemeMode = if m_name.eq_ignore_ascii_case("Dark") {
3344                                ThemeMode::Dark
3345                            } else if m_name.eq_ignore_ascii_case("Light") {
3346                                ThemeMode::Light
3347                            } else {
3348                                return Err(format!("Unknown theme mode: {m_name}"));
3349                            };
3350                            let _: bool = st.get_theme().get_mode().set_if_changed(next_mode);
3351                            Ok(Value::String(
3352                                if next_mode == ThemeMode::Dark {
3353                                    "Dark"
3354                                } else {
3355                                    "Light"
3356                                }
3357                                .to_string(),
3358                            ))
3359                        }
3360                        "shell.auto_hide_chrome" => {
3361                            let b: bool = as_bool(value)?;
3362                            let _: bool = st.get_auto_hide_chrome().set_if_changed(b);
3363                            Ok(Value::Bool(b))
3364                        }
3365                        "shell.show_fps_hud" => {
3366                            let b: bool = as_bool(value)?;
3367                            let _: bool = st.get_show_fps_hud().set_if_changed(b);
3368                            Ok(Value::Bool(b))
3369                        }
3370                        "shell.swipe_routing" => {
3371                            let b: bool = as_bool(value)?;
3372                            let _: bool = st.get_swipe_routing().set_if_changed(b);
3373                            Ok(Value::Bool(b))
3374                        }
3375                        "shell.reduced_motion" => {
3376                            let b: bool = as_bool(value)?;
3377                            let _: bool = st.get_reduced_motion().set_if_changed(b);
3378                            Ok(Value::Bool(b))
3379                        }
3380                        "shell.cmd_palette_open" => {
3381                            let b: bool = as_bool(value)?;
3382                            let _: bool = st.get_cmd_palette_open().set_if_changed(b);
3383                            Ok(Value::Bool(b))
3384                        }
3385                        "render.adaptive_auto_switch" => {
3386                            let b: bool = as_bool(value)?;
3387                            let _: bool = st.get_adaptive_auto_switch().set_if_changed(b);
3388                            Ok(Value::Bool(b))
3389                        }
3390                        "render.mode_index" => {
3391                            let idx: usize = if let Some(s) = value.as_str() {
3392                                if s.eq_ignore_ascii_case("Software") {
3393                                    1
3394                                } else if s.eq_ignore_ascii_case("Hardware") {
3395                                    2
3396                                } else if s.eq_ignore_ascii_case("Hybrid") {
3397                                    3
3398                                } else {
3399                                    0
3400                                }
3401                            } else {
3402                                as_usize(value)?.min(3)
3403                            };
3404                            let _: bool = st.get_render_mode_index().set_if_changed(idx);
3405                            Ok(Value::from(idx as u64))
3406                        }
3407                        "window.fullscreen" => {
3408                            let b: bool = as_bool(value)?;
3409                            let _: bool = st.get_fullscreen().set_if_changed(b);
3410                            Ok(Value::Bool(b))
3411                        }
3412                        "window.demo_fps_cap_index" => {
3413                            let idx: usize = as_usize(value)?.min(6);
3414                            let _: bool = st.get_demo_fps_cap_index().set_if_changed(idx);
3415                            Ok(Value::from(idx as u64))
3416                        }
3417                        "markdown.selectable" => {
3418                            let b: bool = as_bool(value)?;
3419                            let _: bool = st.get_markdown_selectable().set_if_changed(b);
3420                            Ok(Value::Bool(b))
3421                        }
3422                        "markdown.lang_tab" => {
3423                            let idx: usize = as_usize(value)?.min(3);
3424                            let _: bool = st.get_markdown_lang_tab().set_if_changed(idx);
3425                            Ok(Value::from(idx as u64))
3426                        }
3427                        "charts.category_idx" => {
3428                            let idx: usize = as_usize(value)?.min(5);
3429                            let _: bool = st.get_charts_category_idx().set_if_changed(idx);
3430                            Ok(Value::from(idx as u64))
3431                        }
3432                        "lab.rtl" => {
3433                            let b: bool = as_bool(value)?;
3434                            let _: bool = st.get_lab_rtl_mode().set_if_changed(b);
3435                            Ok(Value::Bool(b))
3436                        }
3437                        "lab.block_scroll_chain" => {
3438                            let b: bool = as_bool(value)?;
3439                            let _: bool = st.get_lab_block_scroll_chain().set_if_changed(b);
3440                            Ok(Value::Bool(b))
3441                        }
3442                        "lab.stop_click_bubble" => {
3443                            let b: bool = as_bool(value)?;
3444                            let _: bool = st.get_lab_stop_click_bubble().set_if_changed(b);
3445                            Ok(Value::Bool(b))
3446                        }
3447                        "overlays.modal_open" => {
3448                            let b: bool = as_bool(value)?;
3449                            let _: bool = st.get_modal_open().set_if_changed(b);
3450                            Ok(Value::Bool(b))
3451                        }
3452                        "overlays.drawer_open" => {
3453                            let b: bool = as_bool(value)?;
3454                            let _: bool = st.get_drawer_open().set_if_changed(b);
3455                            Ok(Value::Bool(b))
3456                        }
3457                        "overlays.sheet_open" => {
3458                            let b: bool = as_bool(value)?;
3459                            let _: bool = st.get_sheet_open().set_if_changed(b);
3460                            Ok(Value::Bool(b))
3461                        }
3462                        "overlays.popover_open" => {
3463                            let b: bool = as_bool(value)?;
3464                            let _: bool = st.get_popover_open().set_if_changed(b);
3465                            Ok(Value::Bool(b))
3466                        }
3467                        "overlays.toast_visible" => {
3468                            let b: bool = as_bool(value)?;
3469                            let _: bool = st.get_toast_visible().set_if_changed(b);
3470                            Ok(Value::Bool(b))
3471                        }
3472                        "overlays.loading_active" => {
3473                            let b: bool = as_bool(value)?;
3474                            let _: bool = st.get_loading_active().set_if_changed(b);
3475                            Ok(Value::Bool(b))
3476                        }
3477                        "water.fill_pct" => {
3478                            let pct: f32 = as_f32(value)?.clamp(25.0, 80.0);
3479                            let _: bool = st.get_water_fill_pct().set_if_changed(pct);
3480                            Ok(Value::from(pct))
3481                        }
3482                        "water.viscosity_idx" => {
3483                            let idx: usize = as_usize(value)?.min(2);
3484                            let _: bool = st.get_water_viscosity_idx().set_if_changed(idx);
3485                            Ok(Value::from(idx as u64))
3486                        }
3487                        "water.buoyant_enabled" => {
3488                            let b: bool = as_bool(value)?;
3489                            let _: bool = st.get_water_buoyant_enabled().set_if_changed(b);
3490                            Ok(Value::Bool(b))
3491                        }
3492                        "engine3d.preset_idx" => {
3493                            let idx: usize = as_usize(value)?.min(4);
3494                            let _: bool = st.get_engine3d_preset_idx().set_if_changed(idx);
3495                            Ok(Value::from(idx as u64))
3496                        }
3497                        "engine3d.rt_idx" => {
3498                            let idx: usize = as_usize(value)?.min(3);
3499                            let _: bool = st.get_engine3d_rt_idx().set_if_changed(idx);
3500                            Ok(Value::from(idx as u64))
3501                        }
3502                        "engine3d.res_scale" => {
3503                            let scale: f32 = as_f32(value)?.clamp(40.0, 125.0);
3504                            let _: bool = st.get_engine3d_res_scale().set_if_changed(scale);
3505                            Ok(Value::from(scale))
3506                        }
3507                        "engine3d.time_of_day" => {
3508                            let tod: f32 = as_f32(value)?.clamp(6.0, 23.0);
3509                            let _: bool = st.get_engine3d_time_of_day().set_if_changed(tod);
3510                            Ok(Value::from(tod))
3511                        }
3512                        "engine3d.camera_mode" => {
3513                            let mode: u8 = (as_usize(value)? as u8).min(3);
3514                            let _: bool = st.get_engine3d_camera_mode().set_if_changed(mode);
3515                            Ok(Value::from(mode))
3516                        }
3517                        "reset_defaults" => {
3518                            let b: bool = as_bool(value)?;
3519                            if b {
3520                                st.reset_preferences_to_defaults();
3521                            }
3522                            Ok(Value::Bool(b))
3523                        }
3524                        other => Err(format!("Unknown showcase config key: {other}")),
3525                    }
3526                }
3527            })
3528            .on_get_config({
3529                let st: ShowcaseState = self.clone();
3530                move |_keys: &[String]| {
3531                    let mode_str: &str = if st.get_theme().get_mode().get_untracked()
3532                        == ThemeMode::Dark
3533                    {
3534                        "Dark"
3535                    } else {
3536                        "Light"
3537                    };
3538                    let mut parts: Vec<String> = vec![
3539                        format!("\"route\":{:?}", st.get_route().get_untracked()),
3540                        format!(
3541                            "\"theme.scheme\":{:?}",
3542                            st.get_theme().get_scheme().get_untracked().as_str()
3543                        ),
3544                        format!("\"theme.mode\":{:?}", mode_str),
3545                        format!(
3546                            "\"shell.auto_hide_chrome\":{}",
3547                            st.get_auto_hide_chrome().get_untracked()
3548                        ),
3549                        format!(
3550                            "\"shell.show_fps_hud\":{}",
3551                            st.get_show_fps_hud().get_untracked()
3552                        ),
3553                        format!(
3554                            "\"shell.swipe_routing\":{}",
3555                            st.get_swipe_routing().get_untracked()
3556                        ),
3557                        format!(
3558                            "\"shell.reduced_motion\":{}",
3559                            st.get_reduced_motion().get_untracked()
3560                        ),
3561                        format!(
3562                            "\"shell.cmd_palette_open\":{}",
3563                            st.get_cmd_palette_open().get_untracked()
3564                        ),
3565                        format!(
3566                            "\"render.adaptive_auto_switch\":{}",
3567                            st.get_adaptive_auto_switch().get_untracked()
3568                        ),
3569                    ];
3570                    if let Some(rw) = st.get_render_window_signals().get() {
3571                        parts.push(format!(
3572                            "\"render.mode_index\":{}",
3573                            rw.get_render_mode_index().get_untracked()
3574                        ));
3575                        parts.push(format!(
3576                            "\"window.fullscreen\":{}",
3577                            rw.get_fullscreen().get_untracked()
3578                        ));
3579                        parts.push(format!(
3580                            "\"window.demo_fps_cap_index\":{}",
3581                            rw.get_demo_fps_cap_index().get_untracked()
3582                        ));
3583                    }
3584                    if let Some(md) = st.get_markdown_signals().get() {
3585                        parts.push(format!(
3586                            "\"markdown.selectable\":{}",
3587                            md.get_markdown_selectable().get_untracked()
3588                        ));
3589                        parts.push(format!(
3590                            "\"markdown.lang_tab\":{}",
3591                            md.get_markdown_lang_tab().get_untracked()
3592                        ));
3593                    }
3594                    if let Some(ch) = st.get_charts_signals().get() {
3595                        parts.push(format!(
3596                            "\"charts.category_idx\":{}",
3597                            ch.get_charts_category_idx().get_untracked()
3598                        ));
3599                    }
3600                    if let Some(lab) = st.get_lab_signals().get() {
3601                        parts.push(format!(
3602                            "\"lab.rtl\":{}",
3603                            lab.get_lab_rtl_mode().get_untracked()
3604                        ));
3605                        parts.push(format!(
3606                            "\"lab.block_scroll_chain\":{}",
3607                            lab.get_lab_block_scroll_chain().get_untracked()
3608                        ));
3609                        parts.push(format!(
3610                            "\"lab.stop_click_bubble\":{}",
3611                            lab.get_lab_stop_click_bubble().get_untracked()
3612                        ));
3613                    }
3614                    if let Some(ov) = st.get_overlays_signals().get() {
3615                        parts.push(format!(
3616                            "\"overlays.modal_open\":{}",
3617                            ov.get_modal_open().get_untracked()
3618                        ));
3619                        parts.push(format!(
3620                            "\"overlays.drawer_open\":{}",
3621                            ov.get_drawer_open().get_untracked()
3622                        ));
3623                        parts.push(format!(
3624                            "\"overlays.sheet_open\":{}",
3625                            ov.get_sheet_open().get_untracked()
3626                        ));
3627                    }
3628                    if let Some(w) = st.get_water_signals().get() {
3629                        parts.push(format!(
3630                            "\"water.fill_pct\":{:.1}",
3631                            w.get_fill_pct().get_untracked()
3632                        ));
3633                        parts.push(format!(
3634                            "\"water.viscosity_idx\":{}",
3635                            w.get_viscosity_idx().get_untracked()
3636                        ));
3637                        parts.push(format!(
3638                            "\"water.buoyant_enabled\":{}",
3639                            w.get_buoyant_enabled().get_untracked()
3640                        ));
3641                    }
3642                    if let Some(e3d) = st.get_engine3d_signals().get() {
3643                        parts.push(format!(
3644                            "\"engine3d.preset_idx\":{}",
3645                            e3d.get_engine3d_preset_idx().get_untracked()
3646                        ));
3647                        parts.push(format!(
3648                            "\"engine3d.rt_idx\":{}",
3649                            e3d.get_engine3d_rt_idx().get_untracked()
3650                        ));
3651                        parts.push(format!(
3652                            "\"engine3d.res_scale\":{:.1}",
3653                            e3d.get_engine3d_res_scale().get_untracked()
3654                        ));
3655                        parts.push(format!(
3656                            "\"engine3d.time_of_day\":{:.2}",
3657                            e3d.get_engine3d_time_of_day().get_untracked()
3658                        ));
3659                        parts.push(format!(
3660                            "\"engine3d.camera_mode\":{}",
3661                            e3d.get_engine3d_camera_mode().get_untracked()
3662                        ));
3663                    }
3664                    AiSchemaProtocol::parse_json_value(&format!("{{{}}}", parts.join(",")))
3665                }
3666            })
3667    }
3668
3669    /// Returns the categorized sidebar navigation items grouped in Linear/Vercel/shadcn hierarchy.
3670    ///
3671    /// # Returns
3672    ///
3673    /// - `Vec<EuvNavItem>` - Categorized list of showcase routes.
3674    #[must_use]
3675    pub fn nav_items() -> Vec<EuvNavItem> {
3676        SHOWCASE_ROUTES
3677            .iter()
3678            .map(|spec: &ShowcaseRouteSpec| {
3679                EuvNavItem::new(spec.get_path().to_string(), spec.get_label().to_string())
3680                    .section(spec.get_section())
3681            })
3682            .collect()
3683    }
3684
3685    /// Resolves the currently selected component-scoped demo `RenderMode` from `render_mode_index`.
3686    ///
3687    /// # Arguments
3688    ///
3689    /// - `&Self` - State reference.
3690    ///
3691    /// # Returns
3692    ///
3693    /// - `RenderMode` - Component-scoped demo render pipeline mode.
3694    #[must_use]
3695    pub fn selected_render_mode(&self) -> RenderMode {
3696        match self.get_render_mode_index().get_untracked() {
3697            1 => RenderMode::Software,
3698            2 => RenderMode::Hardware,
3699            3 => RenderMode::Hybrid,
3700            _ => RenderMode::Auto,
3701        }
3702    }
3703
3704    /// Resolves the currently selected component-scoped demo FPS cap from `demo_fps_cap_index`.
3705    ///
3706    /// # Arguments
3707    ///
3708    /// - `&Self` - State reference.
3709    ///
3710    /// # Returns
3711    ///
3712    /// - `Option<u32>` - Demo card FPS target (`None` = Native Uncapped).
3713    #[must_use]
3714    pub fn selected_demo_fps_cap(&self) -> Option<u32> {
3715        match self.get_demo_fps_cap_index().get_untracked() {
3716            1 => Some(30),
3717            2 => Some(60),
3718            3 => Some(120),
3719            4 => Some(144),
3720            5 => Some(240),
3721            6 => Some(360),
3722            _ => None,
3723        }
3724    }
3725
3726    /// Cycles to the next `DesignScheme` in `DesignScheme::all()`.
3727    ///
3728    /// # Arguments
3729    ///
3730    /// - `&Self` - State reference.
3731    pub fn next_scheme(&self) {
3732        let all: [DesignScheme; 17] = DesignScheme::all();
3733        let current: DesignScheme = self.get_theme().get_scheme().get_untracked();
3734        let pos: usize = all
3735            .iter()
3736            .position(|s: &DesignScheme| *s == current)
3737            .unwrap_or(0);
3738        let next: DesignScheme = all[(pos + 1) % all.len()];
3739        let _: bool = self.get_theme().get_scheme().set_if_changed(next);
3740    }
3741
3742    /// Toggles between light and dark theme modes.
3743    ///
3744    /// # Arguments
3745    ///
3746    /// - `&Self` - State reference.
3747    pub fn toggle_theme_mode(&self) {
3748        let cur: ThemeMode = self.get_theme().get_mode().get_untracked();
3749        let next: ThemeMode = match cur {
3750            ThemeMode::Light => ThemeMode::Dark,
3751            ThemeMode::Dark => ThemeMode::Light,
3752        };
3753        let _: bool = self.get_theme().get_mode().set_if_changed(next);
3754    }
3755
3756    /// Snapshots active running/playing state across all 15 showcase pages and freezes 2D/3D engines and media players for background.
3757    ///
3758    /// # Arguments
3759    ///
3760    /// - `&Self` - State reference.
3761    pub fn freeze_for_background(&self) {
3762        if self.get_bg_frozen().get_untracked() {
3763            return;
3764        }
3765        let game2d_running: bool = !self.get_game_host().is_paused();
3766        self.get_bg_snap_game2d_running().set(game2d_running);
3767        self.get_game_host().set_paused(true);
3768        let game3d_running: bool = !self.get_game3d_host().is_paused();
3769        self.get_bg_snap_game3d_running().set(game3d_running);
3770        self.get_game3d_host().set_paused(true);
3771        let water_running: bool = !self.get_water_host().is_paused();
3772        self.get_bg_snap_water_running().set(water_running);
3773        self.get_water_host().set_paused(true);
3774        if self.get_media_loaded().get() {
3775            let gif_playing: bool = self.get_media_gif().get_untracked().get_playing();
3776            self.get_bg_snap_gif_playing().set(gif_playing);
3777            if gif_playing {
3778                let _: bool = self.get_media_gif().update(|gif: &mut GifAnimation| {
3779                    gif.set_playing(false);
3780                });
3781            }
3782            let live_playing: bool = self.get_media_live().get_untracked().get_active_motion();
3783            self.get_bg_snap_live_playing().set(live_playing);
3784            if live_playing {
3785                let _: bool = self.get_media_live().update(|live: &mut LivePhotoAsset| {
3786                    live.set_motion_playing(false);
3787                });
3788            }
3789            let video_playing: bool =
3790                self.get_media_video().get_untracked().get_state() == PlaybackState::Playing;
3791            self.get_bg_snap_video_playing().set(video_playing);
3792            if video_playing {
3793                let _: bool = self.get_media_video().update(|video: &mut VideoTrack| {
3794                    video.set_state(PlaybackState::Paused);
3795                });
3796            }
3797            let audio_playing: bool =
3798                self.get_media_audio().get_untracked().get_state() == PlaybackState::Playing;
3799            self.get_bg_snap_audio_playing().set(audio_playing);
3800            if audio_playing {
3801                let _: bool = self.get_media_audio().update(|audio: &mut AudioTrack| {
3802                    audio.set_state(PlaybackState::Paused);
3803                });
3804            }
3805        }
3806        let _: bool = self.get_bg_frozen().set_if_changed(true);
3807        let _: bool = self
3808            .get_bg_freeze_count()
3809            .update(|count: &mut u32| *count = count.saturating_add(1));
3810    }
3811
3812    /// Restores the exact pre-background running/playing flags across all showcase game hosts and media players on foreground return.
3813    ///
3814    /// # Arguments
3815    ///
3816    /// - `&Self` - State reference.
3817    pub fn restore_from_foreground(&self) {
3818        if !self.get_bg_frozen().get_untracked() {
3819            return;
3820        }
3821        let active_route: String = self.get_route().get_untracked();
3822        if self.get_bg_snap_game2d_running().replace(false) && active_route == ROUTE_GAME {
3823            self.get_game_host().set_paused(false);
3824        }
3825        if self.get_bg_snap_game3d_running().replace(false) && active_route == ROUTE_GAME_3D {
3826            self.get_game3d_host().set_paused(false);
3827        }
3828        if self.get_bg_snap_water_running().replace(false) && active_route == ROUTE_WATER {
3829            self.get_water_host().set_paused(false);
3830        }
3831        if self.get_bg_snap_gif_playing().replace(false) {
3832            let _: bool = self.get_media_gif().update(|gif: &mut GifAnimation| {
3833                gif.set_playing(true);
3834            });
3835        }
3836        if self.get_bg_snap_live_playing().replace(false) {
3837            let _: bool = self.get_media_live().update(|live: &mut LivePhotoAsset| {
3838                live.set_motion_playing(true);
3839            });
3840        }
3841        if self.get_bg_snap_video_playing().replace(false) {
3842            let _: bool = self.get_media_video().update(|video: &mut VideoTrack| {
3843                video.set_state(PlaybackState::Playing);
3844            });
3845        }
3846        if self.get_bg_snap_audio_playing().replace(false) {
3847            let _: bool = self.get_media_audio().update(|audio: &mut AudioTrack| {
3848                audio.set_state(PlaybackState::Playing);
3849            });
3850        }
3851        let _: bool = self.get_bg_frozen().set_if_changed(false);
3852        let _: bool = self
3853            .get_bg_restore_count()
3854            .update(|count: &mut u32| *count = count.saturating_add(1));
3855    }
3856}
3857
3858/// Default `ShowcaseState` delegating to `ShowcaseState::new`.
3859impl Default for ShowcaseState {
3860    /// Creates a default `ShowcaseState`.
3861    ///
3862    /// # Returns
3863    ///
3864    /// - `Self` - Initialized state.
3865    fn default() -> Self {
3866        Self::new()
3867    }
3868}
3869
3870/// Arena setup and gameplay helper methods for `DemoPhysicsScene`.
3871impl DemoPhysicsScene {
3872    /// Creates an empty zero-allocation 2D arena placeholder that hydrates lazily on first active tick or render.
3873    ///
3874    /// # Returns
3875    ///
3876    /// - `Self` - Uninitialized lazy arena placeholder.
3877    #[must_use]
3878    pub fn create_lazy_arena() -> Self {
3879        Self {
3880            world: GameWorld::default(),
3881            physics: PhysicsWorld2D::default(),
3882            camera: Camera2D::default(),
3883            particles: ParticleSystem::default(),
3884            tilemap: TileMap::empty(0, 0, 48.0),
3885            actions: ActionMap::default(),
3886            audio: AudioBus::default(),
3887            player_id: EntityId::default(),
3888            fire_cooldown: 0.0,
3889            dash_cooldown: 0.0,
3890            score: 0,
3891            wave: 1,
3892            show_colliders: false,
3893            smoothed_fps: 0.0,
3894            ticks: 0,
3895            viewport_size: Size::new(820.0, 340.0),
3896            initialized: false,
3897            snapshots: DoubleBufferedSnapshot::new(World2DSnapshot::default()),
3898            to_despawn_scratch: Vec::new(),
3899            last_sampled_tick: u64::MAX,
3900            last_sampled_alpha_milli: i32::MIN,
3901            cached_interp: None,
3902        }
3903    }
3904
3905    /// Hydrates the full 2D arena tilemap, entities, and particle pool once on first active simulation or render.
3906    ///
3907    /// # Arguments
3908    ///
3909    /// - `&Self` - Mutable arena scene.
3910    fn ensure_initialized(&mut self) {
3911        if self.get_initialized() {
3912            return;
3913        }
3914        *self = Self::create_arena();
3915    }
3916
3917    /// Builds a playable 1280x720 tiled neon arena with player ship, obstacles, and initial enemy wave.
3918    ///
3919    /// # Returns
3920    ///
3921    /// - `Self` - Initialized playable arena scene.
3922    #[must_use]
3923    pub fn create_arena() -> Self {
3924        let mut tilemap: TileMap = TileMap::empty(24, 14, 48.0);
3925        let floor_a: u16 = tilemap.add_palette_entry(TilePaletteEntry::new(
3926            Color::hex(0x0B1120),
3927            Color::rgba(30, 41, 59, 90),
3928            false,
3929        ));
3930        let floor_b: u16 = tilemap.add_palette_entry(TilePaletteEntry::new(
3931            Color::hex(0x0F172A),
3932            Color::rgba(30, 41, 59, 90),
3933            false,
3934        ));
3935        let wall_tile: u16 = tilemap.add_palette_entry(TilePaletteEntry::new(
3936            Color::hex(0x1E293B),
3937            Color::hex(0x38BDF8),
3938            true,
3939        ));
3940        for row in 0..tilemap.get_rows() {
3941            for col in 0..tilemap.get_columns() {
3942                let is_border: bool = row == 0
3943                    || col == 0
3944                    || row + 1 == tilemap.get_rows()
3945                    || col + 1 == tilemap.get_columns();
3946                let tid: u16 = if is_border {
3947                    wall_tile
3948                } else if (row + col) % 2 == 0 {
3949                    floor_a
3950                } else {
3951                    floor_b
3952                };
3953                tilemap.set_tile(col, row, tid);
3954            }
3955        }
3956        let world_rect: Rect = tilemap.world_bounds();
3957        let inner_arena: Rect = Rect::new(
3958            56.0,
3959            56.0,
3960            (world_rect.get_width() - 112.0).max(200.0),
3961            (world_rect.get_height() - 112.0).max(200.0),
3962        );
3963        let mut world: GameWorld = GameWorld::with_capacity(256);
3964        let center: Point = Point::new(world_rect.get_width() * 0.5, world_rect.get_height() * 0.5);
3965        let player_id: EntityId = world.spawn(EntityTag::Player, center);
3966        if let Some(player) = world.get_entity_mut(player_id) {
3967            player.set_body(Some(RigidBody2D::dynamic(1.0, 0.4, 3.2)));
3968            player.set_collider(Some(Collider2D::circle(
3969                14.0,
3970                COLLISION_LAYER_PLAYER,
3971                COLLISION_MASK_PLAYER_DEFAULT,
3972                false,
3973            )));
3974            player.set_sprite(Some(Sprite2D::new(
3975                EntityVisualShape::Triangle,
3976                Size::new(30.0, 26.0),
3977                Color::hex(0x38BDF8),
3978                Color::hex(0xE0F2FE),
3979                10,
3980                0.0,
3981                true,
3982            )));
3983        }
3984        let pillars: [(f32, f32); 4] = [
3985            (280.0, 200.0),
3986            (860.0, 200.0),
3987            (280.0, 470.0),
3988            (860.0, 470.0),
3989        ];
3990        for (px, py) in pillars.into_iter() {
3991            let pid: EntityId = world.spawn(EntityTag::Obstacle, Point::new(px, py));
3992            if let Some(obs) = world.get_entity_mut(pid) {
3993                obs.set_body(Some(RigidBody2D::static_body(0.85)));
3994                obs.set_collider(Some(Collider2D::aabb(
3995                    52.0,
3996                    52.0,
3997                    COLLISION_LAYER_WORLD,
3998                    COLLISION_LAYER_ALL,
3999                    false,
4000                )));
4001                obs.set_sprite(Some(Sprite2D::new(
4002                    EntityVisualShape::Rect,
4003                    Size::new(52.0, 52.0),
4004                    Color::hex(0x1E293B),
4005                    Color::hex(0x6366F1),
4006                    2,
4007                    8.0,
4008                    true,
4009                )));
4010            }
4011        }
4012        let mut phys_cfg: PhysicsConfig = PhysicsConfig::default();
4013        phys_cfg.set_arena_bounds(Some(inner_arena));
4014        let mut camera: Camera2D = Camera2D::at(center, 1.0);
4015        camera.set_world_bounds(Some(world_rect));
4016        let mut scene: Self = Self {
4017            world,
4018            physics: PhysicsWorld2D::with_config(phys_cfg),
4019            camera,
4020            particles: ParticleSystem::with_capacity(1024),
4021            tilemap,
4022            actions: ActionMap::default(),
4023            audio: AudioBus::default(),
4024            player_id,
4025            fire_cooldown: 0.0,
4026            dash_cooldown: 0.0,
4027            score: 0,
4028            wave: 1,
4029            show_colliders: false,
4030            smoothed_fps: 0.0,
4031            ticks: 0,
4032            viewport_size: Size::new(820.0, 340.0),
4033            initialized: true,
4034            snapshots: DoubleBufferedSnapshot::new(World2DSnapshot::default()),
4035            to_despawn_scratch: Vec::with_capacity(32),
4036            last_sampled_tick: u64::MAX,
4037            last_sampled_alpha_milli: i32::MIN,
4038            cached_interp: None,
4039        };
4040        scene.spawn_enemy_wave(8);
4041        let initial_snap: World2DSnapshot =
4042            World2DSnapshot::capture(scene.get_world(), scene.get_camera(), true, Vec::new());
4043        scene.set_snapshots(DoubleBufferedSnapshot::new(initial_snap));
4044        scene
4045    }
4046
4047    /// Spawns `count` patrolling enemy drones around the arena perimeter.
4048    ///
4049    /// # Arguments
4050    ///
4051    /// - `&Self` - Mutable arena scene.
4052    /// - `usize` - Number of enemy drones to spawn.
4053    pub fn spawn_enemy_wave(&mut self, count: usize) {
4054        let bounds: Rect = self.get_tilemap().world_bounds();
4055        let cx: f32 = bounds.get_width() * 0.5;
4056        let cy: f32 = bounds.get_height() * 0.5;
4057        for idx in 0..count {
4058            let angle: f32 = ((idx as f32) / (count.max(1) as f32)) * 6.283_185_5
4059                + (self.get_wave() as f32) * 0.45;
4060            let radius: f32 = 220.0 + ((idx % 3) as f32) * 48.0;
4061            let sx: f32 = (cx + angle.cos() * radius).clamp(110.0, bounds.get_width() - 110.0);
4062            let sy: f32 = (cy + angle.sin() * radius).clamp(110.0, bounds.get_height() - 110.0);
4063            let speed: f32 = 95.0 + ((idx % 4) as f32) * 28.0;
4064            let eid: EntityId = self
4065                .get_mut_world()
4066                .spawn(EntityTag::Enemy, Point::new(sx, sy));
4067            if let Some(enemy) = self.get_mut_world().get_entity_mut(eid) {
4068                enemy.set_velocity(Velocity2D::new(
4069                    -angle.sin() * speed,
4070                    angle.cos() * speed,
4071                    1.5,
4072                ));
4073                enemy.set_body(Some(RigidBody2D::dynamic(1.2, 0.95, 0.05)));
4074                enemy.set_collider(Some(Collider2D::circle(
4075                    13.0,
4076                    COLLISION_LAYER_ENEMY,
4077                    COLLISION_LAYER_ALL,
4078                    false,
4079                )));
4080                enemy.set_sprite(Some(Sprite2D::new(
4081                    if idx % 2 == 0 {
4082                        EntityVisualShape::Diamond
4083                    } else {
4084                        EntityVisualShape::Circle
4085                    },
4086                    Size::new(26.0, 26.0),
4087                    if idx % 2 == 0 {
4088                        Color::hex(0xF43F5E)
4089                    } else {
4090                        Color::hex(0xF59E0B)
4091                    },
4092                    Color::hex(0xFEF08A),
4093                    6,
4094                    0.0,
4095                    true,
4096                )));
4097            }
4098        }
4099    }
4100
4101    /// Fires a fast plasma projectile from the player ship along `aim_angle`.
4102    ///
4103    /// # Arguments
4104    ///
4105    /// - `&Self` - Mutable arena scene.
4106    /// - `Point` - Launch origin in world coordinates.
4107    /// - `f32` - Launch angle in radians.
4108    fn fire_projectile(&mut self, origin: Point, aim_angle: f32) {
4109        let dir_x: f32 = aim_angle.cos();
4110        let dir_y: f32 = aim_angle.sin();
4111        let launch: Point =
4112            Point::new(origin.get_x() + dir_x * 20.0, origin.get_y() + dir_y * 20.0);
4113        let pid: EntityId = self.get_mut_world().spawn(EntityTag::Projectile, launch);
4114        if let Some(proj) = self.get_mut_world().get_entity_mut(pid) {
4115            proj.get_mut_transform().set_rotation_rad(aim_angle);
4116            proj.set_velocity(Velocity2D::new(dir_x * 520.0, dir_y * 520.0, 0.0));
4117            proj.set_body(Some(RigidBody2D::dynamic(0.2, 0.9, 0.0)));
4118            proj.set_collider(Some(Collider2D::circle(
4119                5.0,
4120                COLLISION_LAYER_PROJECTILE,
4121                COLLISION_LAYER_ENEMY | COLLISION_LAYER_WORLD,
4122                true,
4123            )));
4124            proj.set_sprite(Some(Sprite2D::new(
4125                EntityVisualShape::Circle,
4126                Size::new(10.0, 10.0),
4127                Color::hex(0x34D399),
4128                Color::hex(0xFFFFFF),
4129                8,
4130                0.0,
4131                true,
4132            )));
4133            proj.set_ttl_secs(Some(1.4));
4134        }
4135        let mut muzzle: ParticleEmitterConfig = ParticleEmitterConfig::default();
4136        muzzle
4137            .set_base_angle(aim_angle)
4138            .set_spread_rad(0.45)
4139            .set_min_speed(80.0)
4140            .set_max_speed(180.0)
4141            .set_min_life(0.12)
4142            .set_max_life(0.26)
4143            .set_start_size(3.5)
4144            .set_start_color(Color::hex(0x34D399))
4145            .set_end_color(Color::rgba(56, 189, 248, 0));
4146        self.get_mut_particles().emit_burst(launch, 6, muzzle);
4147        self.get_mut_audio().play(SoundCue::Laser, 0.65, 0.0, 1.05);
4148    }
4149}
4150
4151/// Deterministic fixed-timestep 2D game engine simulation and camera-driven HUD rendering for `DemoPhysicsScene`.
4152impl GameScene for DemoPhysicsScene {
4153    /// Steps player controls, ECS physics, collision combat, particles, and camera follow at 60Hz fixed cadence.
4154    ///
4155    /// # Arguments
4156    ///
4157    /// - `&Self` - Mutable arena scene.
4158    /// - `f32` - Fixed simulation delta time in seconds.
4159    /// - `&InputState` - Real-time polled keyboard and pointer state.
4160    fn fixed_update(&mut self, dt: f32, input: &InputState) {
4161        self.ensure_initialized();
4162        let move_vec: Point = self.get_actions().movement_vector(input);
4163        let fire_pressed: bool = self.get_actions().is_active(GameAction::Fire, input);
4164        let dash_pressed: bool = self.get_actions().is_just_pressed(GameAction::Dash, input);
4165        let wave_pressed: bool = self
4166            .get_actions()
4167            .is_just_pressed(GameAction::ActionAlt, input);
4168        if wave_pressed {
4169            let next_wave: u32 = self.get_wave().saturating_add(1);
4170            self.set_wave(next_wave);
4171            self.spawn_enemy_wave(6);
4172        }
4173        let fire_cd: f32 = (self.get_fire_cooldown() - dt).max(0.0);
4174        let dash_cd: f32 = (self.get_dash_cooldown() - dt).max(0.0);
4175        self.set_fire_cooldown(fire_cd);
4176        self.set_dash_cooldown(dash_cd);
4177        let player_id: EntityId = self.get_player_id();
4178        let mut player_pos: Point = Point::new(576.0, 336.0);
4179        let mut aim_angle: f32 = 0.0;
4180        let mut dashed: bool = false;
4181        if let Some(player) = self.get_mut_world().get_entity_mut(player_id) {
4182            player_pos = player.get_transform().get_position();
4183            let accel: f32 = 1650.0;
4184            let mut vel: Velocity2D = player.get_velocity();
4185            vel.set_vx(vel.get_vx() + move_vec.get_x() * accel * dt);
4186            vel.set_vy(vel.get_vy() + move_vec.get_y() * accel * dt);
4187            let mut rot: f32 = player.get_transform().get_rotation_rad();
4188            if move_vec.get_x().abs() > 0.05 || move_vec.get_y().abs() > 0.05 {
4189                rot = move_vec.get_y().atan2(move_vec.get_x());
4190            } else {
4191                rot += dt * 0.8;
4192            }
4193            if dash_pressed && dash_cd <= 0.0 {
4194                vel.set_vx(vel.get_vx() + rot.cos() * 440.0);
4195                vel.set_vy(vel.get_vy() + rot.sin() * 440.0);
4196                dashed = true;
4197            }
4198            player.set_velocity(vel);
4199            player.get_mut_transform().set_rotation_rad(rot);
4200            aim_angle = rot;
4201        }
4202        if dashed {
4203            self.set_dash_cooldown(0.45);
4204            self.get_mut_camera().add_trauma(0.25);
4205            let mut burst: ParticleEmitterConfig = ParticleEmitterConfig::default();
4206            burst
4207                .set_base_angle(aim_angle + PI)
4208                .set_spread_rad(0.9)
4209                .set_start_color(Color::hex(0x38BDF8))
4210                .set_end_color(Color::rgba(56, 189, 248, 0));
4211            self.get_mut_particles().emit_burst(player_pos, 18, burst);
4212            self.get_mut_audio().play(SoundCue::Dash, 0.8, 0.0, 1.0);
4213        }
4214        if (fire_pressed || self.get_ticks().is_multiple_of(22)) && fire_cd <= 0.0 {
4215            self.fire_projectile(player_pos, aim_angle);
4216            self.set_fire_cooldown(0.14);
4217        }
4218        let collisions: Vec<CollisionEvent> = {
4219            let Self { world, physics, .. } = self;
4220            physics.step(world, dt)
4221        };
4222        {
4223            let Self {
4224                world,
4225                to_despawn_scratch,
4226                camera,
4227                audio,
4228                ..
4229            } = self;
4230            to_despawn_scratch.clear();
4231            for ev in collisions.into_iter() {
4232                let tag_a: Option<EntityTag> = world
4233                    .get_entity(ev.get_entity_a())
4234                    .map(EntityRecord::get_tag);
4235                let tag_b: Option<EntityTag> = world
4236                    .get_entity(ev.get_entity_b())
4237                    .map(EntityRecord::get_tag);
4238                match (tag_a, tag_b) {
4239                    (Some(EntityTag::Projectile), Some(EntityTag::Enemy)) => {
4240                        if let Some(e) = world.get_entity(ev.get_entity_b()) {
4241                            to_despawn_scratch.push((
4242                                ev.get_entity_b(),
4243                                e.get_transform().get_position(),
4244                                true,
4245                            ));
4246                        }
4247                        to_despawn_scratch.push((ev.get_entity_a(), Point::default(), false));
4248                    }
4249                    (Some(EntityTag::Enemy), Some(EntityTag::Projectile)) => {
4250                        if let Some(e) = world.get_entity(ev.get_entity_a()) {
4251                            to_despawn_scratch.push((
4252                                ev.get_entity_a(),
4253                                e.get_transform().get_position(),
4254                                true,
4255                            ));
4256                        }
4257                        to_despawn_scratch.push((ev.get_entity_b(), Point::default(), false));
4258                    }
4259                    (Some(EntityTag::Projectile), Some(EntityTag::Obstacle)) => {
4260                        to_despawn_scratch.push((ev.get_entity_a(), Point::default(), false));
4261                    }
4262                    (Some(EntityTag::Obstacle), Some(EntityTag::Projectile)) => {
4263                        to_despawn_scratch.push((ev.get_entity_b(), Point::default(), false));
4264                    }
4265                    (Some(EntityTag::Player), Some(EntityTag::Enemy))
4266                    | (Some(EntityTag::Enemy), Some(EntityTag::Player)) => {
4267                        camera.add_trauma(0.35);
4268                        audio.play(SoundCue::Bounce, 0.7, 0.0, 0.85);
4269                    }
4270                    _ => {}
4271                }
4272            }
4273        }
4274        {
4275            let Self {
4276                world,
4277                to_despawn_scratch,
4278                score,
4279                camera,
4280                particles,
4281                audio,
4282                ..
4283            } = self;
4284            for &(eid, pos, is_enemy) in to_despawn_scratch.iter() {
4285                if world.despawn(eid) && is_enemy {
4286                    *score = score.saturating_add(100);
4287                    camera.add_trauma(0.32);
4288                    let mut exp: ParticleEmitterConfig = ParticleEmitterConfig::default();
4289                    exp.set_min_speed(70.0)
4290                        .set_max_speed(260.0)
4291                        .set_start_size(5.5)
4292                        .set_start_color(Color::hex(0xFB7185))
4293                        .set_end_color(Color::rgba(250, 204, 21, 0));
4294                    particles.emit_burst(pos, 22, exp);
4295                    audio.play(SoundCue::Explosion, 0.9, 0.0, 0.95);
4296                }
4297            }
4298            to_despawn_scratch.clear();
4299        }
4300        if self.get_world().count_by_tag(EntityTag::Enemy) < 3 {
4301            let next_wave: u32 = self.get_wave().saturating_add(1);
4302            self.set_wave(next_wave);
4303            self.spawn_enemy_wave(6);
4304        }
4305        let _: usize = self.get_mut_world().tick_lifetimes(dt);
4306        let _: usize = self.get_mut_particles().update(dt);
4307        let _: Vec<AudioCommand> = self.get_mut_audio().drain();
4308        if let Some(player) = self.get_world().get_entity(player_id) {
4309            let p: Point = player.get_transform().get_position();
4310            let vp: Size = self.get_viewport_size();
4311            self.get_mut_camera().follow(p, 7.5, dt, vp);
4312        }
4313        self.set_ticks(self.get_ticks().saturating_add(1));
4314        self.set_last_sampled_tick(u64::MAX);
4315        let next_snap: World2DSnapshot =
4316            World2DSnapshot::capture(self.get_world(), self.get_camera(), false, Vec::new());
4317        self.get_mut_snapshots().commit(next_snap);
4318    }
4319
4320    /// Updates smoothed frame-rate telemetry once per visual frame.
4321    ///
4322    /// # Arguments
4323    ///
4324    /// - `&Self` - Mutable arena scene.
4325    /// - `f32` - Real frame delta time in seconds.
4326    /// - `&InputState` - Current polled input snapshot.
4327    fn update(&mut self, dt: f32, _input: &InputState) {
4328        if dt > 0.0001 {
4329            let inst_fps: f32 = (1.0 / dt).clamp(1.0, 9999.0);
4330            let prev: f32 = self.get_smoothed_fps();
4331            let next: f32 = if prev <= 0.5 {
4332                inst_fps
4333            } else {
4334                prev * 0.85 + inst_fps * 0.15
4335            };
4336            self.set_smoothed_fps(next);
4337        }
4338    }
4339
4340    /// Renders the camera-projected tilemap, ECS entities, raycast targeting laser, particles, and engine HUD with single-pass snapshot interpolation.
4341    ///
4342    /// # Arguments
4343    ///
4344    /// - `&Self` - Mutable arena scene.
4345    /// - `f32` - Interpolation alpha in `[0.0, 1.0]`.
4346    /// - `&mut GameRenderContext<'_>` - Immediate-mode game draw surface.
4347    fn render(&mut self, alpha: f32, ctx: &mut GameRenderContext<'_>) {
4348        self.ensure_initialized();
4349        let size: Size = ctx.viewport_size();
4350        if size.get_width() > 32.0 && size.get_height() > 32.0 {
4351            let world_rect: Rect = self.get_tilemap().world_bounds();
4352            let fit_zoom: f32 = (size.get_width() / world_rect.get_width().max(1.0))
4353                .max(size.get_height() / world_rect.get_height().max(1.0))
4354                .clamp(1.0, 1.85);
4355            let vp_changed: bool = size != self.get_viewport_size();
4356            let zoom_changed: bool = (self.get_camera().get_zoom() - fit_zoom).abs() > 0.001;
4357            if vp_changed || zoom_changed {
4358                self.set_viewport_size(size);
4359                self.get_mut_camera().set_zoom(fit_zoom);
4360                self.get_mut_snapshots()
4361                    .get_mut_prev_state()
4362                    .get_mut_camera()
4363                    .set_zoom(fit_zoom);
4364                self.get_mut_snapshots()
4365                    .get_mut_curr_state()
4366                    .get_mut_camera()
4367                    .set_zoom(fit_zoom);
4368                self.set_last_sampled_tick(u64::MAX);
4369            }
4370        }
4371        ctx.clear(Color::hex(0x020617));
4372        let alpha_milli: i32 = (alpha.clamp(0.0, 1.0) * 1000.0).round() as i32;
4373        let cur_ticks: u64 = self.get_ticks();
4374        let needs_resample: bool = self.get_last_sampled_tick() != cur_ticks
4375            || self.get_last_sampled_alpha_milli() != alpha_milli
4376            || {
4377                let Self { cached_interp, .. } = self;
4378                cached_interp.is_none()
4379            };
4380        if needs_resample {
4381            let sampled: World2DSnapshot = self.get_snapshots().sample(alpha);
4382            let Self {
4383                cached_interp,
4384                last_sampled_tick,
4385                last_sampled_alpha_milli,
4386                ..
4387            } = self;
4388            *cached_interp = Some(sampled);
4389            *last_sampled_tick = cur_ticks;
4390            *last_sampled_alpha_milli = alpha_milli;
4391        }
4392        let player_id: EntityId = self.get_player_id();
4393        let (cam, interp_player_tr): (Camera2D, Option<EntityTransform>) = {
4394            let Self {
4395                cached_interp,
4396                world,
4397                camera,
4398                ..
4399            } = self;
4400            match cached_interp.as_ref() {
4401                Some(snap) => {
4402                    let tr: Option<EntityTransform> = snap
4403                        .get_entities()
4404                        .iter()
4405                        .find(|pose: &&EntityPose2D| pose.get_alive() && pose.get_id() == player_id)
4406                        .map(EntityPose2D::get_transform)
4407                        .or_else(|| world.get_entity(player_id).map(EntityRecord::get_transform));
4408                    (snap.get_camera(), tr)
4409                }
4410                None => (
4411                    *camera,
4412                    world.get_entity(player_id).map(EntityRecord::get_transform),
4413                ),
4414            }
4415        };
4416        ctx.render_tilemap(self.get_tilemap(), &cam);
4417        if let Some(player_tr) = interp_player_tr {
4418            let origin: Point = player_tr.get_position();
4419            let rot: f32 = player_tr.get_rotation_rad();
4420            let dir: Point = Point::new(rot.cos(), rot.sin());
4421            let end_world: Point = match PhysicsWorld2D::raycast(
4422                self.get_world(),
4423                origin,
4424                dir,
4425                340.0,
4426                COLLISION_LAYER_ENEMY | COLLISION_LAYER_WORLD,
4427            ) {
4428                Some(hit) => hit.get_point(),
4429                None => Point::new(
4430                    origin.get_x() + dir.get_x() * 340.0,
4431                    origin.get_y() + dir.get_y() * 340.0,
4432                ),
4433            };
4434            let s0: Point = cam.world_to_screen(origin, size);
4435            let s1: Point = cam.world_to_screen(end_world, size);
4436            ctx.draw_line(s0, s1, 1.5, Color::rgba(56, 189, 248, 120));
4437            ctx.fill_circle(s1, 3.5, Color::hex(0x38BDF8));
4438        }
4439        let drawn_entities: usize = {
4440            let Self {
4441                world,
4442                cached_interp,
4443                ..
4444            } = self;
4445            match cached_interp.as_ref() {
4446                Some(snap) => ctx.render_snapshot_world(world, snap),
4447                None => 0,
4448            }
4449        };
4450        let drawn_particles: usize = ctx.render_particles(self.get_particles(), &cam);
4451        if self.get_show_colliders() {
4452            ctx.draw_debug_colliders(self.get_world(), &cam);
4453        }
4454        ctx.fill_rounded_rect(
4455            Rect::new(
4456                10.0,
4457                10.0,
4458                (size.get_width() - 20.0).clamp(180.0, 560.0),
4459                28.0,
4460            ),
4461            Color::rgba(15, 23, 42, 210),
4462            6.0,
4463        );
4464        ctx.draw_text(
4465            Point::new(18.0, 16.0),
4466            format!(
4467                "FPS {:.0} | Wave {} | Score {} | Ent {} | Part {} | SFX {}",
4468                self.get_smoothed_fps(),
4469                self.get_wave(),
4470                self.get_score(),
4471                drawn_entities,
4472                drawn_particles,
4473                self.get_audio().get_total_played()
4474            ),
4475            12.0,
4476            Color::hex(0xE2E8F0),
4477        );
4478        let hint_y: f32 = (size.get_height() - 32.0).max(44.0);
4479        let hint_w: f32 = (size.get_width() - 24.0).clamp(180.0, 380.0);
4480        ctx.fill_rounded_rect(
4481            Rect::new(10.0, hint_y, hint_w, 22.0),
4482            Color::rgba(15, 23, 42, 200),
4483            6.0,
4484        );
4485        ctx.draw_text(
4486            Point::new(18.0, hint_y + 4.0),
4487            GAME_HUD_CONTROLS_HINT.to_string(),
4488            11.0,
4489            Color::rgba(226, 232, 240, 235),
4490        );
4491    }
4492}
4493
4494/// Construction, async city loading, and runtime-config helpers for `DemoOpenWorld3DScene`.
4495impl DemoOpenWorld3DScene {
4496    /// Creates an empty zero-allocation 3D city placeholder sharing lazy signal and background-worker cells.
4497    ///
4498    /// # Arguments
4499    ///
4500    /// - `Rc<Cell<Option<Engine3dSignals>>>` - Shared lazy `/game3d` control signal cell.
4501    /// - `Scope` - Root ownership scope retaining lazily materialized `/game3d` signals across route evictions.
4502    /// - `Rc<Cell<bool>>` - Shared toggle enabling background OS-thread city construction.
4503    ///
4504    /// # Returns
4505    ///
4506    /// - `Self` - Uninitialized lazy 3D scene placeholder.
4507    #[must_use]
4508    pub(crate) fn create_lazy_city_deferred(
4509        signals_cell: Rc<Cell<Option<Engine3dSignals>>>,
4510        state_scope: Scope,
4511        bg_workers_enabled: Rc<Cell<bool>>,
4512    ) -> Self {
4513        Self {
4514            world: World3D::default(),
4515            renderer: Renderer3D::default(),
4516            actions: ActionMap::default(),
4517            signals_cell,
4518            state_scope,
4519            bg_workers_enabled,
4520            bg_city_task: None,
4521            last_import_seq: 0,
4522            smoothed_fps: 0.0,
4523            initialized: false,
4524            snapshots: DoubleBufferedSnapshot::new(World3DSnapshot::default()),
4525            frame_pool: RenderBufferPool::with_capacity(3),
4526            gpu_target: GpuCompositeTarget::default(),
4527            frame_fence: 0,
4528            last_camera_mode: 0,
4529            ticks: 0,
4530            cached_world_frame: None,
4531            cached_world_rev: u64::MAX,
4532            cached_alpha_milli: i32::MIN,
4533            cached_dims: (0, 0),
4534            cached_quality: RenderQualityConfig::default(),
4535        }
4536    }
4537
4538    /// Resolves the shared lazy `/game3d` control signals on first active tick or render.
4539    ///
4540    /// # Arguments
4541    ///
4542    /// - `&Self` - 3D scene reference.
4543    ///
4544    /// # Returns
4545    ///
4546    /// - `Engine3dSignals` - Active `/game3d` control signals.
4547    fn active_signals(&self) -> Engine3dSignals {
4548        Engine3dSignals::get_or_init(self.get_signals_cell().as_ref(), self.get_state_scope())
4549    }
4550
4551    /// Commits a constructed `World3D` open-world city into this scene and marks the world render target dirty.
4552    ///
4553    /// # Arguments
4554    ///
4555    /// - `&Self` - Mutable 3D scene.
4556    /// - `World3D` - Built Vice Boulevard open-world city.
4557    fn install_world(&mut self, world: World3D) {
4558        let initial_snap: World3DSnapshot =
4559            World3DSnapshot::capture(&world, 0, true, Vec::new(), Vec::new());
4560        let init_mode: u8 = world.get_camera_mode();
4561        self.set_world(world);
4562        self.set_snapshots(DoubleBufferedSnapshot::new(initial_snap));
4563        self.set_last_camera_mode(init_mode);
4564        self.get_mut_gpu_target().mark_world_dirty();
4565        self.set_cached_world_frame(None);
4566        self.set_cached_world_rev(u64::MAX);
4567        self.set_initialized(true);
4568        let _: bool = self
4569            .active_signals()
4570            .get_engine3d_import_status()
4571            .set_if_changed(DEFAULT_ENGINE3D_STATUS.to_string());
4572    }
4573
4574    /// Lazily initializes the Vice Boulevard 3D open-world city, using a background worker thread on interactive native apps.
4575    ///
4576    /// # Arguments
4577    ///
4578    /// - `&Self` - Mutable 3D scene.
4579    ///
4580    /// # Returns
4581    ///
4582    /// - `bool` - `true` when the 3D city is ready for simulation and rendering.
4583    fn ensure_initialized(&mut self) -> bool {
4584        if self.get_initialized() {
4585            return true;
4586        }
4587        let ready_world: Option<World3D> = {
4588            let Self { bg_city_task, .. } = self;
4589            if let Some(task) = bg_city_task.as_ref() {
4590                if let Some(world) = task.try_take() {
4591                    *bg_city_task = None;
4592                    Some(world)
4593                } else {
4594                    return false;
4595                }
4596            } else {
4597                None
4598            }
4599        };
4600        if let Some(world) = ready_world {
4601            self.install_world(world);
4602            return true;
4603        }
4604        if self.get_bg_workers_enabled().get() {
4605            let task: BackgroundTask<World3D> =
4606                BackgroundTask::spawn(World3D::create_open_world_city);
4607            let _: bool = self
4608                .active_signals()
4609                .get_engine3d_import_status()
4610                .set_if_changed(STATUS_ENGINE3D_LOADING.to_string());
4611            self.set_bg_city_task(Some(task));
4612            return false;
4613        }
4614        let world: World3D = World3D::create_open_world_city();
4615        self.install_world(world);
4616        true
4617    }
4618
4619    /// Creates the live Vice Boulevard 3D open-world scene bound to explicit reactive runtime settings signals.
4620    ///
4621    /// # Arguments
4622    ///
4623    /// - `Signal<RenderQualityConfig>` - Live quality/RT/resolution configuration signal.
4624    /// - `Signal<f32>` - Live time-of-day sun hour signal.
4625    /// - `Signal<u64>` - Monotonic model import request signal.
4626    /// - `Signal<String>` - Live status feedback signal.
4627    /// - `Signal<u8>` - Active 3D camera mode signal (`0=Chase, 1=Hood, 2=Orbit, 3=Aerial`).
4628    ///
4629    /// # Returns
4630    ///
4631    /// - `Self` - Initialized 3D open-world scene.
4632    #[must_use]
4633    pub fn create_city(
4634        quality_signal: Signal<RenderQualityConfig>,
4635        time_signal: Signal<f32>,
4636        import_signal: Signal<u64>,
4637        status_signal: Signal<String>,
4638        camera_mode_signal: Signal<u8>,
4639    ) -> Self {
4640        let group: Engine3dSignals = Engine3dSignals {
4641            engine3d_quality: quality_signal,
4642            engine3d_preset_idx: Signal::new(4),
4643            engine3d_rt_idx: Signal::new(3),
4644            engine3d_res_scale: Signal::new(100.0),
4645            engine3d_time_of_day: time_signal,
4646            engine3d_import_queue: import_signal,
4647            engine3d_import_status: status_signal,
4648            engine3d_camera_mode: camera_mode_signal,
4649        };
4650        let (state_scope, _): (Scope, ()) = Scope::run(|_: Scope| {});
4651        let mut scene: Self = Self::create_lazy_city_deferred(
4652            Rc::new(Cell::new(Some(group))),
4653            state_scope,
4654            Rc::new(Cell::new(false)),
4655        );
4656        let _: bool = scene.ensure_initialized();
4657        scene
4658    }
4659}
4660
4661/// Deterministic 3D open-world simulation and HUD-decoupled PBR + BVH ray-traced rendering for `DemoOpenWorld3DScene`.
4662impl GameScene for DemoOpenWorld3DScene {
4663    /// Steps vehicle physics, camera follow, spinning imported models, time-of-day sun, and queued model imports.
4664    ///
4665    /// # Arguments
4666    ///
4667    /// - `&Self` - Mutable 3D scene.
4668    /// - `f32` - Fixed simulation timestep in seconds.
4669    /// - `&InputState` - Real-time polled keyboard/pointer state.
4670    fn fixed_update(&mut self, dt: f32, input: &InputState) {
4671        if !self.ensure_initialized() {
4672            return;
4673        }
4674        let signals: Engine3dSignals = self.active_signals();
4675        let req_seq: u64 = signals.get_engine3d_import_queue().get_untracked();
4676        if req_seq != self.get_last_import_seq() {
4677            self.set_last_import_seq(req_seq);
4678            let is_obj: bool = req_seq % 2 == 1;
4679            let z_pos: f32 = -4.0 - ((req_seq % 5) as f32) * 8.0;
4680            let x_pos: f32 = if is_obj { -5.5 } else { 5.5 };
4681            let import_res: Result<ImportedModel3D, String> = if is_obj {
4682                self.get_mut_world().import_model(
4683                    ModelFormat::Obj,
4684                    SAMPLE_OBJ_MONUMENT,
4685                    Transform3D::new(Vec3::new(x_pos, 0.0, z_pos), 0.0, Vec3::splat(1.0)),
4686                    PbrMaterial::pbr(Color::hex(0xF59E0B), 0.9, 0.14, 0.72),
4687                    0.85,
4688                )
4689            } else {
4690                self.get_mut_world().import_model(
4691                    ModelFormat::GltfJson,
4692                    SAMPLE_GLTF_TOWER,
4693                    Transform3D::new(Vec3::new(x_pos, 0.0, z_pos), 0.0, Vec3::splat(1.0)),
4694                    PbrMaterial::pbr(Color::hex(0x38BDF8), 0.85, 0.12, 0.80),
4695                    -0.70,
4696                )
4697            };
4698            if let Ok(info) = import_res {
4699                let msg: String = format!(
4700                    "Imported {} ({:?}): {} verts, {} tris (LOD0+LOD1 + BVH rebuilt)",
4701                    info.get_name(),
4702                    info.get_format(),
4703                    info.get_total_vertices(),
4704                    info.get_total_triangles()
4705                );
4706                let _: bool = signals.get_engine3d_import_status().set_if_changed(msg);
4707            }
4708        }
4709        let hour: f32 = signals.get_engine3d_time_of_day().get_untracked();
4710        if (hour - self.get_world().get_sun().get_time_of_day()).abs() > 0.05 {
4711            self.get_mut_world()
4712                .set_sun(DirectionalLight3D::from_time_of_day(hour));
4713        }
4714        let cam_mode: u8 = signals.get_engine3d_camera_mode().get_untracked();
4715        let cam_cut: bool = cam_mode != self.get_last_camera_mode();
4716        if cam_mode != self.get_world().get_camera_mode() {
4717            self.get_mut_world().set_camera_mode(cam_mode);
4718        }
4719        self.set_last_camera_mode(cam_mode);
4720        let Self { world, actions, .. } = self;
4721        world.step_simulation(dt, input, actions);
4722        let next_tick: u64 = self.get_ticks().saturating_add(1);
4723        self.set_ticks(next_tick);
4724        let next_snap: World3DSnapshot =
4725            World3DSnapshot::capture(self.get_world(), next_tick, cam_cut, Vec::new(), Vec::new());
4726        if cam_cut {
4727            self.get_mut_snapshots().commit_discontinuous(next_snap);
4728        } else {
4729            self.get_mut_snapshots().commit(next_snap);
4730        }
4731        self.get_mut_gpu_target().mark_world_dirty();
4732    }
4733
4734    /// Updates smoothed FPS telemetry for the 3D HUD overlay without dirtying the 3D world render target.
4735    ///
4736    /// # Arguments
4737    ///
4738    /// - `&Self` - Mutable 3D scene.
4739    /// - `f32` - Real frame delta time in seconds.
4740    /// - `&InputState` - Current polled input snapshot.
4741    fn update(&mut self, dt: f32, _input: &InputState) {
4742        if dt > 0.0001 {
4743            let inst_fps: f32 = (1.0 / dt).clamp(1.0, 9999.0);
4744            let prev: f32 = self.get_smoothed_fps();
4745            let next: f32 = if prev <= 0.5 {
4746                inst_fps
4747            } else {
4748                prev * 0.85 + inst_fps * 0.15
4749            };
4750            self.set_smoothed_fps(next);
4751            self.get_mut_gpu_target().mark_hud_dirty();
4752        }
4753    }
4754
4755    /// Renders the 3D open-world city with HUD-decoupled caching and overlays live telemetry HUD.
4756    ///
4757    /// # Arguments
4758    ///
4759    /// - `&Self` - Mutable 3D scene.
4760    /// - `f32` - Interpolation alpha.
4761    /// - `&mut GameRenderContext<'_>` - Immediate-mode viewport draw context.
4762    fn render(&mut self, alpha: f32, ctx: &mut GameRenderContext<'_>) {
4763        let size: Size = ctx.viewport_size();
4764        if !self.ensure_initialized() {
4765            ctx.clear(Color::hex(0x090D16));
4766            ctx.fill_rounded_rect(
4767                Rect::new(
4768                    10.0,
4769                    10.0,
4770                    (size.get_width() - 20.0).clamp(200.0, 560.0),
4771                    28.0,
4772                ),
4773                Color::rgba(15, 23, 42, 220),
4774                6.0,
4775            );
4776            ctx.draw_text(
4777                Point::new(18.0, 16.0),
4778                HUD_3D_LOADING_TITLE.to_string(),
4779                11.5,
4780                Color::hex(0x38BDF8),
4781            );
4782            return;
4783        }
4784        let signals: Engine3dSignals = self.active_signals();
4785        let quality: RenderQualityConfig = signals.get_engine3d_quality().get_untracked();
4786        let dpr: f32 = ctx.scale_factor().clamp(1.0, 2.5);
4787        let preset_boost: f32 = match quality.get_preset() {
4788            QualityPreset::Low => 1.05,
4789            QualityPreset::Medium => 1.25,
4790            QualityPreset::High => 1.38,
4791            QualityPreset::Ultra => 1.45,
4792            QualityPreset::Cinematic => 1.52,
4793        };
4794        let dpi_boost: f32 = preset_boost.max(dpr.min(2.0));
4795        let raw_w: f32 = (size.get_width().max(64.0) * dpi_boost).max(160.0);
4796        let raw_h: f32 = (size.get_height().max(64.0) * dpi_boost).max(160.0);
4797        let max_dim: f32 = 960.0;
4798        let max_pixels: f32 = 960.0 * 540.0;
4799        let dim_scale: f32 = (max_dim / raw_w.max(raw_h)).min(1.0);
4800        let area_scale: f32 = (max_pixels / (raw_w * raw_h).max(1.0)).sqrt().min(1.0);
4801        let fit_scale: f32 = dim_scale.min(area_scale);
4802        let vw: u32 = ((raw_w * fit_scale).round() as u32).clamp(160, 960);
4803        let vh: u32 = ((raw_h * fit_scale).round() as u32).clamp(160, 960);
4804        let next_fence: u64 = self.get_frame_fence().saturating_add(1);
4805        self.set_frame_fence(next_fence);
4806        let dst_rect: Rect = Rect::new(0.0, 0.0, size.get_width(), size.get_height());
4807        let alpha_milli: i32 = (alpha.clamp(0.0, 1.0) * 1000.0).round() as i32;
4808        let world_rev: u64 = self.get_gpu_target().get_world_revision();
4809        let can_reuse_world: bool = !self.get_gpu_target().needs_world_render()
4810            && self.get_cached_world_rev() == world_rev
4811            && self.get_cached_dims() == (vw, vh)
4812            && self.get_cached_quality() == quality
4813            && self.get_cached_alpha_milli() == alpha_milli;
4814        let mut blitted_pooled: bool = false;
4815        let gpu_handle: GpuTextureHandle = self.get_gpu_target().get_handle();
4816        if gpu_handle.is_valid() && ctx.composite_gpu_texture(dst_rect, gpu_handle) {
4817            let _: Option<GpuCompositeDescriptor> = self
4818                .get_mut_gpu_target()
4819                .record_composite_present(next_fence);
4820            blitted_pooled = true;
4821        } else if can_reuse_world {
4822            let reused_img: Option<ImageBuffer> = {
4823                let Self {
4824                    cached_world_frame, ..
4825                } = self;
4826                cached_world_frame.clone()
4827            };
4828            if let Some(cached_img) = reused_img {
4829                ctx.draw_image(dst_rect, cached_img);
4830                let hud_rev: u64 = self.get_gpu_target().get_hud_revision();
4831                let next_reuse: u64 = self
4832                    .get_gpu_target()
4833                    .get_hud_only_reuses()
4834                    .saturating_add(1);
4835                let target: &mut GpuCompositeTarget = self.get_mut_gpu_target();
4836                target.set_presented_hud_revision(hud_rev);
4837                target.set_hud_only_reuses(next_reuse);
4838                blitted_pooled = true;
4839            }
4840        }
4841        if !blitted_pooled {
4842            let pooled_lease: Option<PooledFrameLease> = {
4843                let Self {
4844                    world,
4845                    renderer,
4846                    snapshots,
4847                    frame_pool,
4848                    ..
4849                } = self;
4850                renderer.render_world_interpolated_into_pool(
4851                    world,
4852                    snapshots,
4853                    alpha,
4854                    (vw, vh),
4855                    &quality,
4856                    (frame_pool, next_fence),
4857                )
4858            };
4859            if let Some(lease) = pooled_lease {
4860                ctx.blit_pooled_frame(dst_rect, &lease);
4861                let cached_copy: ImageBuffer = lease.to_image_buffer_copy();
4862                lease.submit_in_flight();
4863                let _: usize = self.get_frame_pool().retire_fence(next_fence);
4864                self.set_cached_world_frame(Some(cached_copy));
4865                blitted_pooled = true;
4866            }
4867            if !blitted_pooled {
4868                let frame_img: ImageBuffer = {
4869                    let Self {
4870                        world, renderer, ..
4871                    } = self;
4872                    renderer.render_world(world, vw, vh, &quality)
4873                };
4874                self.set_cached_world_frame(Some(frame_img.clone()));
4875                ctx.draw_image(dst_rect, frame_img);
4876            }
4877            self.set_cached_world_rev(world_rev);
4878            self.set_cached_dims((vw, vh));
4879            self.set_cached_quality(quality);
4880            self.set_cached_alpha_milli(alpha_milli);
4881            let hud_rev: u64 = self.get_gpu_target().get_hud_revision();
4882            let target: &mut GpuCompositeTarget = self.get_mut_gpu_target();
4883            target.set_presented_world_revision(world_rev);
4884            target.set_presented_hud_revision(hud_rev);
4885        }
4886        let stats: RenderStats3D = self.get_renderer().get_last_stats();
4887        let fps: f32 = self.get_smoothed_fps();
4888        let compact_hud: bool = size.get_width() < 520.0;
4889        let hud_text: String = if compact_hud {
4890            format!(
4891                "{fps:.0} FPS | {:?} | {}x{} | {} rays",
4892                quality.get_preset(),
4893                stats.get_render_width(),
4894                stats.get_render_height(),
4895                stats.get_rays_traced()
4896            )
4897        } else {
4898            format!(
4899                "{fps:.0} FPS | 3D {:?} | RT {:?} | {}x{} | Tris {} | Rays {} | BVH {}",
4900                quality.get_preset(),
4901                quality.get_ray_tracing(),
4902                stats.get_render_width(),
4903                stats.get_render_height(),
4904                stats.get_triangles_drawn(),
4905                stats.get_rays_traced(),
4906                stats.get_bvh_nodes()
4907            )
4908        };
4909        ctx.fill_rounded_rect(
4910            Rect::new(
4911                10.0,
4912                10.0,
4913                (size.get_width() - 20.0).clamp(200.0, 620.0),
4914                28.0,
4915            ),
4916            Color::rgba(9, 13, 24, 210),
4917            6.0,
4918        );
4919        ctx.draw_text(Point::new(18.0, 16.0), hud_text, 11.0, Color::hex(0xE2E8F0));
4920    }
4921}