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