{"version":3,"file":"chunk-Status.mjs","names":["_Fragment","Steps","StepsPrimitive","_Fragment"],"sources":["../../src/components/Deferred/Deferred.tsx","../../src/components/Skeleton/Skeleton.tsx","../../src/components/Steps/Steps.tsx","../../src/namespaces/Status.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport React, { type PropsWithChildren, type ReactNode, useEffect, useRef, useState } from 'react';\n\n/**\n * Long enough that a transient empty state (a scope resolving before its data, a store settling between query\n * identities) is never rendered, short enough that a genuinely empty surface still feels immediate.\n */\nconst DEFAULT_DELAY = 500;\n\n/** A fallback worth showing at all is worth reading. */\nconst DEFAULT_MIN_DURATION = 1_000;\n\nexport type DeferredProps = PropsWithChildren<{\n  /**\n   * Whether the fallback is what should be shown, typically \"the query has not produced content\". Named for what it\n   * gates, so a caller's `showEmptyState` passes straight through rather than being inverted at every call site.\n   */\n  pending: boolean;\n  /** How long `pending` must hold before the fallback appears, in ms: the flicker guard. */\n  delay?: number;\n  /** Once shown, how long the fallback stays, in ms, counted from when it rendered. */\n  minDuration?: number;\n  /** Rendered while deferred; a thunk, so an expensive fallback costs nothing when it never shows. */\n  fallback: () => ReactNode;\n}>;\n\n/**\n * Renders `children`, falling back to `fallback` while `pending`, but only once `pending` has held for `delay`, and\n * then for at least `minDuration`. A surface cannot tell \"no results yet\" from \"no results\", only how long the state\n * lasts, and a fallback that flashes reads as the real answer. Renders no element of its own.\n */\nexport const Deferred = ({\n  pending,\n  delay = DEFAULT_DELAY,\n  minDuration = DEFAULT_MIN_DURATION,\n  fallback,\n  children,\n}: DeferredProps) => {\n  const [showFallback, setShowFallback] = useState(pending && delay === 0);\n  // When the fallback rendered: one still held back by `delay` has not been on screen, so it owes no minimum.\n  const shownAt = useRef<number | undefined>(showFallback ? Date.now() : undefined);\n\n  useEffect(() => {\n    if (pending) {\n      if (showFallback) {\n        return;\n      }\n\n      const timer = setTimeout(() => {\n        shownAt.current = Date.now();\n        setShowFallback(true);\n      }, delay);\n      return () => clearTimeout(timer);\n    }\n\n    if (!showFallback) {\n      return;\n    }\n\n    const elapsed = shownAt.current === undefined ? minDuration : Date.now() - shownAt.current;\n    const remaining = minDuration - elapsed;\n    if (remaining <= 0) {\n      shownAt.current = undefined;\n      setShowFallback(false);\n      return;\n    }\n\n    const timer = setTimeout(() => {\n      shownAt.current = undefined;\n      setShowFallback(false);\n    }, remaining);\n    return () => clearTimeout(timer);\n  }, [pending, showFallback, delay, minDuration]);\n\n  return <>{showFallback ? fallback() : children}</>;\n};\n\nDeferred.displayName = 'Deferred';\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport React, { type ComponentPropsWithRef, forwardRef } from 'react';\n\nimport { mx } from '@dxos/ui-theme';\nimport { type ThemedClassName } from '@dxos/ui-types';\n\nimport { recipes } from '../../recipes.ts';\n\nexport type SkeletonVariant = 'default' | 'circle' | 'text';\n\nexport type SkeletonProps = ThemedClassName<Omit<ComponentPropsWithRef<'div'>, 'children'>> & {\n  /** `default` is a block-tall bar, `text` a line of text, `circle` a block-sized disc (an avatar). */\n  variant?: SkeletonVariant;\n};\n\n/** A pulsing placeholder in the shape of the content it stands in for; hidden from assistive tech. */\nexport const Skeleton = forwardRef<HTMLDivElement, SkeletonProps>(\n  ({ classNames, variant = 'default', ...props }, forwardedRef) => (\n    <div\n      aria-hidden\n      {...props}\n      data-scope='skeleton'\n      data-part='root'\n      data-variant={variant}\n      className={mx(recipes.skeleton(), classNames)}\n      ref={forwardedRef}\n    />\n  ),\n);\n\nSkeleton.displayName = 'Skeleton';\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { Steps as StepsPrimitive, useStepsContext } from '@ark-ui/react/steps';\nimport React, { type CSSProperties, forwardRef, useEffect, useState } from 'react';\nimport { useTranslation } from 'react-i18next';\n\nimport { mx } from '@dxos/ui-theme';\nimport { type ThemedClassName } from '@dxos/ui-types';\n\nimport { translationKey } from '#translations';\n\nimport { recipes } from '../../recipes.ts';\nimport { type CSSVariables } from '../Container/Container.tsx';\n\n/** One stage of a plan that has identity: a stage the caller can address and select. */\nexport type Step = {\n  id: string;\n  label?: string;\n};\n\n/** Where a stage sits relative to the run: ahead of it, in flight, behind it, or where it failed. */\nexport type StepState = 'pending' | 'active' | 'complete' | 'error';\n\nexport type StepsProps = ThemedClassName<\n  Omit<StepsPrimitive.RootProps, 'children' | 'count' | 'step' | 'defaultStep' | 'onStepChange' | 'onSelect'>\n> & {\n  /** The plan: a count when the stages are anonymous, or the stages themselves; every stage is drawn. */\n  steps: number | Step[];\n  /**\n   * Zero-based index of the stage in flight; absent means none has started, and a value at or past the last stage\n   * means the run is over.\n   */\n  active?: number;\n  /** How far through the stage in flight, 0..1, drawn on the line leaving it. */\n  fraction?: number;\n  /** The stage in flight cannot be counted, so it spins rather than filling its line. */\n  indeterminate?: boolean;\n  /** The run stopped on the stage in flight; every stage it reached is drawn in the error colour. */\n  error?: boolean;\n  /** Index of a stage the caller has singled out. */\n  selected?: number;\n  /** Makes every stage a toggle button. */\n  onSelect?: (step: { index: number; id: string }) => void;\n  /** Milliseconds a line takes to fill, and so how long an advance is held back for it to arrive. */\n  duration?: number;\n};\n\n/**\n * The machine has no \"not started\" step (it throws on an index outside `0..count`), so the plan is declared one stage\n * longer and every stage shifted up by one: the machine resting on index 0 means nothing has started.\n */\nconst PHANTOM = 1;\n\n/**\n * A fixed plan drawn as icon-sized circles joined by lines that flex, so the gaps stay even however many stages there\n * are. Which stage is in flight says where the run is in its plan; the fill of the line leaving it says how far through\n * that stage, so a counted run needs no separate bar (`Progress` is the planless form).\n */\nexport const Steps = forwardRef<HTMLDivElement, StepsProps>(\n  (\n    {\n      classNames,\n      steps,\n      active,\n      fraction = 0,\n      indeterminate,\n      error,\n      selected,\n      onSelect,\n      duration = 500,\n      style,\n      ...props\n    },\n    forwardedRef,\n  ) => {\n    const count = stepCount(steps);\n    const { shown, handover } = useHandover(active, duration);\n    const rootStyle: CSSProperties & CSSVariables = { ...style, '--dx-steps-duration': `${duration}ms` };\n\n    return (\n      <StepsPrimitive.Root\n        {...props}\n        role='list'\n        count={count + PHANTOM}\n        step={shown === undefined ? 0 : Math.min(Math.max(shown, 0) + PHANTOM, count + PHANTOM)}\n        data-error={error ? '' : undefined}\n        style={rootStyle}\n        className={mx(recipes.steps(), classNames)}\n        ref={forwardedRef}\n      >\n        <StepsItems\n          steps={steps}\n          count={count}\n          fraction={indeterminate ? 0 : fraction}\n          handover={handover}\n          indeterminate={indeterminate}\n          error={error}\n          selected={selected}\n          onSelect={onSelect}\n        />\n      </StepsPrimitive.Root>\n    );\n  },\n);\n\nSteps.displayName = 'Steps';\n\ntype StepsItemsProps = Pick<StepsProps, 'steps' | 'indeterminate' | 'error' | 'selected' | 'onSelect'> & {\n  count: number;\n  fraction: number;\n  handover: boolean;\n};\n\nconst StepsItems = ({\n  steps,\n  count,\n  fraction,\n  handover,\n  indeterminate,\n  error,\n  selected,\n  onSelect,\n}: StepsItemsProps) => {\n  const api = useStepsContext();\n  const { t } = useTranslation(translationKey);\n\n  return (\n    <>\n      {Array.from({ length: count }, (_unused, index) => {\n        const step = stepAt(steps, index);\n        const { current, completed } = api.getItemState({ index: index + PHANTOM });\n        const state = stepState(current, completed, handover, error);\n        const last = index === count - 1;\n        // A circle carries no text and an anonymous plan supplies no label, so its position is the only name it has.\n        const label = step.label?.trim() || t('steps.step.label', { index: index + 1 });\n        const indicator = {\n          'index': index + PHANTOM,\n          'aria-label': label,\n          // Ark hides its indicator from assistive tech; here the circle is the stage's only representation.\n          'aria-hidden': false,\n          'data-state': state,\n          'data-selected': selected === index ? '' : undefined,\n          'data-spinning': state === 'active' && indeterminate ? '' : undefined,\n        } as const;\n\n        return (\n          <StepsPrimitive.Item\n            key={step.id}\n            index={index + PHANTOM}\n            role='listitem'\n            data-last={last ? '' : undefined}\n            className={recipes.stepsItem()}\n          >\n            {onSelect ? (\n              // A real button so it takes focus and answers the keyboard; selection toggles, which `aria-pressed`\n              // describes. Not the machine's trigger, which is a `tab` for a panel this component never renders.\n              <StepsPrimitive.Indicator {...indicator} className={recipes.stepsButton()} asChild>\n                <button\n                  type='button'\n                  aria-pressed={selected === index}\n                  onClick={() => onSelect({ index, id: step.id })}\n                />\n              </StepsPrimitive.Indicator>\n            ) : (\n              // A bare element maps to `generic`, where ARIA discards the label.\n              <StepsPrimitive.Indicator {...indicator} role='img' className={recipes.stepsIndicator()} />\n            )}\n            {!last && (\n              <StepsPrimitive.Separator className={recipes.stepsSeparator()}>\n                <span\n                  className={recipes.stepsFill()}\n                  style={{\n                    width: `${connectorFraction(completed, current, handover, fraction) * 100}%`,\n                    // Only the line leaving the stage in flight eases; a reset or rewind lands at once, since a line\n                    // sliding back to zero reads as progress in reverse.\n                    transition: current ? undefined : 'none',\n                  }}\n                />\n              </StepsPrimitive.Separator>\n            )}\n          </StepsPrimitive.Item>\n        );\n      })}\n    </>\n  );\n};\n\n/** Number of stages in a plan, whichever form it takes. */\nconst stepCount = (steps: number | Step[]): number => (typeof steps === 'number' ? steps : steps.length);\n\n/** The stage at `index`, synthesizing an id for an anonymous plan. */\nconst stepAt = (steps: number | Step[], index: number): Step =>\n  typeof steps === 'number' ? { id: `step-${index}` } : steps[index];\n\n/**\n * Holds an advance back until the line leaving the stage being left has filled, so two things never animate at once.\n * Only an advance waits: a retreat or a start from nothing has no line in flight, and is derived (not stored) so it\n * lands in the render that reports it.\n */\nconst useHandover = (active: number | undefined, duration: number) => {\n  const [held, setHeld] = useState(active);\n  const advancing = active !== undefined && held !== undefined && active > held;\n  const shown = advancing ? held : active;\n\n  useEffect(() => {\n    if (!advancing) {\n      setHeld(active);\n      return;\n    }\n\n    const timer = setTimeout(() => setHeld(active), duration);\n    return () => clearTimeout(timer);\n  }, [active, advancing, duration]);\n\n  return { shown, handover: advancing };\n};\n\n/** How a stage is drawn, given what the machine says about it and where the run is. */\nconst stepState = (current: boolean, completed: boolean, handover: boolean, error: boolean | undefined): StepState => {\n  if (completed) {\n    return 'complete';\n  }\n  if (!current) {\n    return 'pending';\n  }\n  // Mid-handover the stage is finished and the next has not started, so nothing is in flight.\n  if (handover) {\n    return 'complete';\n  }\n  return error ? 'error' : 'active';\n};\n\n/** How much of the line leaving a stage is drawn. */\nconst connectorFraction = (completed: boolean, current: boolean, handover: boolean, fraction: number): number => {\n  if (completed) {\n    return 1;\n  }\n  if (!current) {\n    return 0;\n  }\n  // The run already counts the next stage, but the line being waited on is this one, so it holds full.\n  return handover ? 1 : fraction;\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nexport * from '../components/Deferred/Deferred.tsx';\nexport * from '../components/Empty/Empty.tsx';\nexport {\n  ErrorFallback as Error,\n  ErrorBoundary,\n  type ErrorBoundaryProps,\n  type ErrorFallbackProps as ErrorProps,\n  ErrorStack,\n  type ErrorStackFrame,\n  type ErrorStackProps,\n  type FallbackProps,\n  type ParsedStackFrame,\n  parseCaptureOwnerStack,\n} from '../components/ErrorFallback/ErrorFallback.tsx';\nexport * from '../components/Progress/Progress.tsx';\nexport * from '../components/Skeleton/Skeleton.tsx';\nexport * from '../components/Steps/Steps.tsx';\n"],"mappings":";;;;;;;;;;;;;;;;AAUA,IAAM,gBAAgB;;AAGtB,IAAM,uBAAuB;;;;;;AAqB7B,IAAa,YAAY,EACvB,SACA,QAAQ,eACR,cAAc,sBACd,UACA,eACmB;CACnB,MAAM,CAAC,cAAc,mBAAmB,SAAS,WAAW,UAAU,CAAC;CAEvE,MAAM,UAAU,OAA2B,eAAe,KAAK,IAAI,IAAI,KAAA,CAAS;CAEhF,gBAAgB;EACd,IAAI,SAAS;GACX,IAAI,cACF;GAGF,MAAM,QAAQ,iBAAiB;IAC7B,QAAQ,UAAU,KAAK,IAAI;IAC3B,gBAAgB,IAAI;GACtB,GAAG,KAAK;GACR,aAAa,aAAa,KAAK;EACjC;EAEA,IAAI,CAAC,cACH;EAIF,MAAM,YAAY,eADF,QAAQ,YAAY,KAAA,IAAY,cAAc,KAAK,IAAI,IAAI,QAAQ;EAEnF,IAAI,aAAa,GAAG;GAClB,QA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