import{useCallback}from"react";import{useSetAtom}from"jotai";import{getActiveMediaType}from"../models";import{operationStore}from"../jotai/operation";export function useActivateExample(e){const i=useSetAtom(operationStore((null==e?void 0:e.operation.pointer)||"no_operation_pointer")),o=e?getActiveMediaType(e):void 0;return useCallback((e=>{var t,a,n;if(o)if(o.examples&&(null===(t=o.schema)||void 0===t?void 0:t.oneOf)&&Object.keys(o.examples).includes(e)){const t=null===(n=null===(a=o.schema)||void 0===a?void 0:a.oneOf)||void 0===n?void 0:n.findIndex((i=>i.title===e));i(-1===t?i=>Object.assign(Object.assign({},i),{activeExampleName:e}):e=>{var i,a,n,s;return Object.assign(Object.assign({},e),{activeOneOf:Object.assign(Object.assign({},e.activeOneOf),{[(null===(i=o.schema)||void 0===i?void 0:i.pointer)||""]:t}),activeExampleName:(null===(s=null===(n=null===(a=o.schema)||void 0===a?void 0:a.oneOf)||void 0===n?void 0:n[t])||void 0===s?void 0:s.title)||e.activeExampleName})})}else i((i=>Object.assign(Object.assign({},i),{activeExampleName:e})))}),[o,i])}
//# sourceMappingURL=useActivateExample.js.map