/**
 * Minimal progress-bar helper for the load lifecycle.
 *
 * The #progress container holds a single inner .bar element whose width is
 * driven as a percentage. show/hide just toggle the `hidden` class so CSS
 * controls visibility (see src/style.css). Kept dependency-free so both the
 * dropzone wiring and ThreeDViewer.loadServerAsset can use it.
 */

/**
 * Reveal the progress container by removing the `hidden` class.
 * `el` is the #progress element.
 */
export function showProgress(el: HTMLElement): void {
  el.classList.remove("hidden");
}

/**
 * Hide the progress container by adding the `hidden` class.
 */
export function hideProgress(el: HTMLElement): void {
  el.classList.add("hidden");
}

/**
 * Set the inner `.bar` width to `percent` (clamped to 0..100).
 * `el` is the #progress element; its first `.bar` descendant is resized.
 */
export function setProgress(el: HTMLElement, percent: number): void {
  const clamped = Math.max(0, Math.min(100, percent));
  const bar = el.querySelector<HTMLElement>(".bar");
  if (bar) bar.style.width = `${clamped}%`;
}

/** Write a user-facing status/error message into the #status element. */
export function setStatus(el: HTMLElement, msg: string): void {
  el.textContent = msg;
}
