/** Display-option and reset event wiring for the deck.gl scene controller. @example ```ts wireDisplay({ session, commit }); wireReset({ session, probes, commit }); ``` */ import { computeSceneBounds, } from '../deck-config.ts'; import type { PackageProbe, } from '../probe.ts'; import { el, elInput, elSelect, syncDomFromState, } from './controller-dom.ts'; import type { Commit, Session, } from './controller-event-types.ts'; import { unpinTooltip, } from './controller-tooltip.ts'; import { defaultState, } from './state.ts'; //region Types /** Display-toggle boolean keys controlled by checkboxes. */ type CheckboxDisplayKey = 'showWireframe' | 'showThresholdPlanes' | 'showAxisLabels' | 'showUnknownCluster'; //endregion Types //region Helpers /** Binds one checkbox to its display-toggles key. @param id - Element id of checkbox. @param key - Display-toggles boolean controlled by checkbox. @param session - Mutable session. @param commit - Callback that re-renders and syncs hash. @example ```ts bindCheckbox({ id: 'display-wireframe', key: 'showWireframe', session, commit }); ``` */ function bindCheckbox( { id, key, session, commit, }: { id: string; key: CheckboxDisplayKey; session: Session; commit: Commit; }, ): void { /** Checkbox `` resolved by id; `change` event drives bound display toggle. */ const input = elInput(id,); input.addEventListener( 'change', function onChange() { session.state = { ...session.state, displayToggles: { ...session.state .displayToggles, [key]: input.checked, }, }; commit(); }, ); } //endregion Helpers //region Wire functions /** Wires four display checkboxes plus `name-labels` select. Each change triggers a full layer rebuild via `commit`. @param session - Mutable session. @param commit - Callback that re-renders and syncs hash. @example ```ts wireDisplay({ session, commit }); ``` */ export function wireDisplay( { session, commit, }: { session: Session; commit: Commit; }, ): void { bindCheckbox({ id: 'display-wireframe', key: 'showWireframe', session, commit, },); bindCheckbox({ id: 'display-planes', key: 'showThresholdPlanes', session, commit, },); bindCheckbox({ id: 'display-axis-labels', key: 'showAxisLabels', session, commit, },); bindCheckbox({ id: 'display-unknown', key: 'showUnknownCluster', session, commit, },); /** Name-labels `