import{jsx as E,Fragment as h,jsxs as u}from"react/jsx-runtime";import{memo as O}from"react";import{useAtom as g}from"jotai";import{ExampleSwitch as v,useExampleKey as K}from"../Samples/index.js";import{useActivateExample as j,useTelemetry as C}from"../../hooks/index.js";import{operationStore as P}from"../../jotai/operation.js";function b({mediaType:e,mediaContent:m,renderSample:a}){const l=C(),p=e.operation.pointer,[n,x]=g(P(p)),s=e.examples||e.formExamples||{},t=Object.keys(s),i=j(m),{exampleKey:c}=K(e.operation,s),r=t[n.activeOneOf[e?.examplesPointer||e.operation.pointer]]||c;return!t.length||t.length===1?a():u(h,{children:[E(v,{examples:s,exampleKey:r,onChange:o=>{const f=e.examplesPointer&&e.examplesPointer.startsWith(e.operation.pointer)?e.examplesPointer:e.operation.pointer;l.sendExamplesSwitcherClickedMessage({exampleNumber:t.indexOf(o),totalExamples:t.length}),x({...n,activeExampleName:o,activeOneOf:{...n.activeOneOf,[f]:t.indexOf(o)},requestValues:{body:null}}),i(o)}}),a(r)]})}const M=O(b);export{M as Example};
