/** Tab index for「Finished Good Record (mine)」— used by post-pick redirect. */

export const WORKBENCH_TAB_FINISHED_GOOD_RECORD_MINE = 2;



/** Map legacy tab indices to current 7-tab layout (Etra at 1). */

export function normalizeWorkbenchTabFromUrl(raw: number): number | null {

  const allowed = new Set([0, 1, 2, 3, 4, 5, 6]);

  if (allowed.has(raw)) return raw;

  /** Hidden-Etra 6-tab layout: mine was at 1 */

  const legacyWithoutEtra: Record<number, number> = {

    0: 0,

    1: WORKBENCH_TAB_FINISHED_GOOD_RECORD_MINE,

    2: 3,

    3: 4,

    4: 5,

    5: 6,

  };

  const mapped = legacyWithoutEtra[raw];

  return mapped != null && allowed.has(mapped) ? mapped : null;

}

