import { Feature , SimpleFeatureSerialized , } from '@jbrowse/core/util/simpleFeature' ; const jb2ToJb1 = { refName : 'seq_id' } ; const jb1ToJb2 = { seq_id : 'refName' } ; /**
 * wrapper to adapt nclist features to act like jbrowse 2 features
 */ export default class NCListFeature implements Feature { private parentHandle ? : Feature ; private uniqueId : string ; constructor ( private ncFeature , parent ? , id ? ) { this . uniqueId = id || ncFeature . id ( ) ; this . parentHandle = parent ; } set ( ) { throw new Error ( 'not implemented' ) ; } jb2TagToJb1Tag ( tag ) { const mapped = jb2ToJb1 [ tag ] || tag ; return mapped . toLowerCase ( ) ; } jb1TagToJb2Tag ( tag ) { const t = tag . toLowerCase ( ) ; const mapped = jb1ToJb2 [ t ] || t ; return mapped ; } get ( attrName ) { const attr = this . ncFeature . get ( this . jb2TagToJb1Tag ( attrName ) ) ; if ( attr && attrName === 'subfeatures' ) { return attr . map ( ( subfeature ) => new NCListFeature ( subfeature , this ) ) ; } return attr ; } /**
     * Get an array listing which data keys are present in this feature.
     */ tags ( ) { return this . ncFeature . tags ( ) . map ( ( t ) => this . jb1TagToJb2Tag ( t ) ) ; } /**
     * Get the unique ID of this feature.
     */ id ( ) { return this . uniqueId ; } /**
     * Get this feature's parent feature, or undefined if none.
     */ parent ( ) { return this . parentHandle ; } /**
     * Get an array of child features, or undefined if none.
     */ children ( ) { return this . get ( 'subfeatures' ) ; } toJSON ( ) { const data = { uniqueId : this . id ( ) } ; this . ncFeature . tags ( ) . forEach ( ( tag ) => { const mappedTag = this . jb1TagToJb2Tag ( tag ) ; const value = this . ncFeature . get ( tag ) ; if ( mappedTag === 'subfeatures' ) { data . subfeatures = ( value || [ ] ) . map ( ( f ) => { return new NCListFeature ( f , this ) . toJSON ( ) ; } ) ; } else { data [ mappedTag ] = value ; } } ) ; return data ; } }