import{jsx as i}from"react/jsx-runtime";import{useState as d,useEffect as p}from"react";import{MimeLabel as h,Container as x,Select as v}from"../common/index.js";import{SelectOrLabel as S}from"../SelectOrLabel/index.js";import{normalizeText as b}from"../../utils/index.js";const O=({exampleKey:o,examples:n,onChange:l,className:c})=>{const a=Object.keys(n),t=o?a.indexOf(o):0,[m,s]=d(t>-1?t:0);p(()=>s(t>-1?t:0),[o,t]);const r=a.map((e,f)=>({value:b(n[e].summary)||e,idx:f})),u=({idx:e})=>{s(e),l(a[e])};return r.length<2?null:i(x,{"data-testid":"example-switch",className:c,children:i(S,{Select:v,Label:h,variant:"dark",fullWidth:!0,options:r,value:r[m]?.value,onChange:u})})};export{O as ExampleSwitch};
