import { AppState , ContentRef , KernelRef } from "@nteract/types" ; param state returns export const contentByRef = ( state ) => state . core . entities . contents . byRef ; param state param { contentRef returns export const content = ( state , { contentRef } ) => contentByRef ( state ) . get ( contentRef ) ; param state param { contentRef returns export const model = ( state , { contentRef } ) => { const content = contentByRef ( state ) . get ( contentRef ) ; if ( ! content ) { return null ; } return content . model ; } ; export const notebookModel = ( state , { contentRef } ) => { const notebook = model ( state , { contentRef } ) ; if ( ! notebook || notebook . type !== "notebook" ) { throw new Error ( "Expected notebook model" ) ; } return notebook ; } ; param state param { contentRef returns export const kernelRefByContentRef = ( state , ownProps ) : KernelRef | null | undefined => { const c = content ( state , ownProps ) ; if ( c && c . model && c . model . type === "notebook" ) { return c . model . kernelRef ; } return null ; } ; export const kernelByContentRef = ( state , ownProps ) => { const kernelRef = kernelRefByContentRef ( state , ownProps ) ; if ( kernelRef ) { return state . core . entities . kernels . byRef . get ( kernelRef ) ; } return null ; } ; param state param ownProps returns export const filepath = ( state , ownProps ) : string | null => { const c = content ( state , ownProps ) ; if ( ! c ) { return null ; } return c . filepath ; } ; param state param ownProps returns export const contentRefByFilepath = ( state , ownProps ) : string | undefined => { const byRef = contentByRef ( state ) ; return byRef . findKey ( content => content . filepath === ownProps . filepath ) ; } ;