import{__assign as r}from"tslib";import{jsx as t}from"react/jsx-runtime";import{createContext as i,useReducer as e,useCallback as n,useContext as o}from"react";var a={history:{},globalCitations:[]};function s(t,i){var e;switch(i.type){case"SAVE_CITATIONS":return r(r({},t),{globalCitations:i.rawCitations,history:r(r({},t.history),(e={},e[i.requestId]=i.reasoningMap,e))});case"RESET":return a;default:return t}}var u=i(void 0),h=function(i){var o=i.children,h=e(s,a),c=h[0],f=h[1],v=n(function(r){var t=Object.keys(c.history);if(0===t.length)return"";for(var i=t.length-1;i>=0;i--){var e=c.history[t[i]][r];if(e)return e}return""},[c.history]);return t(u.Provider,r({value:{state:c,dispatch:f,getLatestReasoning:v}},{children:o}))},c=function(){var r=o(u);if(!r)throw new Error("useCitations must be used within a CitationProvider");return r};export{h as CitationProvider,c as useCitations};
//# sourceMappingURL=CitationsContext.js.map
