import{useCallback as s}from"react";import{useSetAtom as n,useAtomValue as c}from"jotai";import{getActiveMediaType as p}from"../models/index.js";import{operationStore as l}from"../jotai/operation.js";import{activeMimeNameAtom as f}from"../jotai/app.js";function A(o){const t=n(l(o?.operation.pointer||"no_operation_pointer")),m=c(f),e=o?p(o,m):void 0;return s(a=>{if(e)if(e.examples&&e.schema?.oneOf&&Object.keys(e.examples).includes(a)){const i=e.schema?.oneOf?.findIndex(r=>r.title===a);t(i===-1?{activeExampleName:a,requestValues:{}}:{activeOneOf:{[e.schema?.pointer||""]:i},activeExampleName:e.schema?.oneOf?.[i]?.title,requestValues:{}})}else t({activeExampleName:a,requestValues:{}})},[e,t])}export{A as useActivateExample};
