import { createMessage } from "@nteract/messaging" ; /**
 * Jupyter messaging protocol's _jupyter_types_experimental completion result.
 */ interface CompletionResult { end : number ; start : number ; type : string ; text : string ; displayText ? : string ; } /**
 * Juptyer completion match item.
 */ export type CompletionMatch = string | CompletionResult ; /**
 * Jupyter messaging protocol's complete_reply response.
 */ export interface CompletionResults { status : string ; cursor_start : number ; cursor_end : number ; matches : CompletionMatch [ ] ; metadata ? : { _jupyter_types_experimental ? : any ; } ; } param code param cursorPos export const completionRequest = ( code , cursorPos ) => createMessage ( "complete_request" , { content : { code , cursor_pos : cursorPos } } ) ; param js_idx param text export const js_idx_to_char_idx = ( js_idx , text ) : number => { let char_idx = js_idx ; for ( let i = 0 ; i + 1 < text . length && i < js_idx ; i ++ ) { const char_code = text . charCodeAt ( i ) ; if ( char_code >= 0xd800 && char_code <= 0xdbff ) { const next_char_code = text . charCodeAt ( i + 1 ) ; if ( next_char_code >= 0xdc00 && next_char_code <= 0xdfff ) { char_idx -- ; i ++ ; } } } return char_idx ; } ;