import { _getAdministration , _interceptReads , action , computed , defineProperty , intercept , getAtom , IObjectWillChange , observable , observe , set , IObjectDidChange , makeObservable } from "mobx" ; import { addHiddenFinalProp , addHiddenWritableProp , ArrayType , ComplexType , createActionInvoker , createObjectNode , EMPTY_ARRAY , EMPTY_OBJECT , escapeJsonPath , fail , flattenTypeErrors , freeze , getContextForPath , getPrimitiveFactoryFromValue , getStateTreeNode , IAnyType , IChildNodesMap , IValidationContext , IJsonPatch , isPlainObject , isPrimitive , isStateTreeNode , isType , IType , IValidationResult , mobxShallow , optional , MapType , typecheckInternal , typeCheckFailure , TypeFlags , Hook , AnyObjectNode , AnyNode , _CustomOrOther , _NotCustomized , Instance , devMode , assertIsString , assertArg } from "../../internal" ; import { ComputedValue } from "mobx/dist/internal" ; const PRE_PROCESS_SNAPSHOT = "preProcessSnapshot" ; const POST_PROCESS_SNAPSHOT = "postProcessSnapshot" ; hidden export interface ModelProperties { [ key ] : IAnyType ; } hidden export type ModelPrimitive = string | number | boolean | Date ; hidden export interface ModelPropertiesDeclaration { [ key ] : ModelPrimitive | IAnyType ; } hidden export type ModelPropertiesDeclarationToProperties < T extends ModelPropertiesDeclaration > = T extends { [ k ] : IAnyType ; } ? T : { [ K in keyof T ] : T [ K ] extends IAnyType ? T [ K ] : T [ K ] extends string ? IType < string | undefined , string , string > : T [ K ] extends number ? IType < number | undefined , number , number > : T [ K ] extends boolean ? IType < boolean | undefined , boolean , boolean > : T [ K ] extends Date ? IType < number | Date | undefined , number , Date > : never ; } ; hidden type IsOptionalValue < C , TV , FV > = undefined extends C ? TV : FV ; hidden type DefinablePropsNames < T > = { [ K in keyof T ] : IsOptionalValue < T [ K ] , never , K > ; } [ keyof T ] ; hidden export declare const $nonEmptyObject ; hidden export interface NonEmptyObject { [ $nonEmptyObject ] ? : any ; } hidden export type ExtractCFromProps < P extends ModelProperties > = { [ k in keyof P ] : P [ k ] [ "CreationType" ] ; } ; hidden export type ModelCreationType < PC > = { [ P in DefinablePropsNames < PC > ] : PC [ P ] ; } & Partial < PC > & NonEmptyObject ; hidden export type ModelCreationType2 < P extends ModelProperties , CustomC > = _CustomOrOther < CustomC , ModelCreationType < ExtractCFromProps < P > > > ; hidden export type ModelSnapshotType < P extends ModelProperties > = { [ K in keyof P ] : P [ K ] [ "SnapshotType" ] ; } & NonEmptyObject ; hidden export type ModelSnapshotType2 < P extends ModelProperties , CustomS > = _CustomOrOther < CustomS , ModelSnapshotType < P > > ; hidden export type ModelInstanceTypeProps < P extends ModelProperties > = { [ K in keyof P ] : P [ K ] [ "Type" ] ; } & NonEmptyObject ; hidden export type ModelInstanceType < P extends ModelProperties , O > = ModelInstanceTypeProps < P > & O ; hidden export interface ModelActions { [ key ] : Function ; } export interface IModelType < PROPS extends ModelProperties , OTHERS , CustomC = _NotCustomized , CustomS = _NotCustomized > extends IType < ModelCreationType2 < PROPS , CustomC > , ModelSnapshotType2 < PROPS , CustomS > , ModelInstanceType < PROPS , OTHERS > > { readonly properties : PROPS ; named ( newName ) : IModelType < PROPS , OTHERS , CustomC , CustomS > ; props < PROPS2 extends ModelPropertiesDeclaration > ( props ) : IModelType < PROPS & ModelPropertiesDeclarationToProperties < PROPS2 > , OTHERS , CustomC , CustomS > ; views < V extends Object > ( fn ) : IModelType < PROPS , OTHERS & V , CustomC , CustomS > ; actions < A extends ModelActions > ( fn ) : IModelType < PROPS , OTHERS & A , CustomC , CustomS > ; volatile < TP extends object > ( fn ) : IModelType < PROPS , OTHERS & TP , CustomC , CustomS > ; extend < A extends ModelActions = { } , V extends Object = { } , VS extends Object = { } > ( fn ) : IModelType < PROPS , OTHERS & A & V & VS , CustomC , CustomS > ; deprecated preProcessSnapshot < NewC = ModelCreationType2 < PROPS , CustomC > > ( fn ) : IModelType < PROPS , OTHERS , NewC , CustomS > ; deprecated postProcessSnapshot < NewS = ModelSnapshotType2 < PROPS , CustomS > > ( fn ) : IModelType < PROPS , OTHERS , CustomC , NewS > ; } /**
 * Any model type.
 */ export interface IAnyModelType extends IModelType < any , any , any , any > { } hidden export type ExtractProps < T extends IAnyModelType > = T extends IModelType < infer P , any , any , any > ? P : never ; hidden export type ExtractOthers < T extends IAnyModelType > = T extends IModelType < any , infer O , any , any > ? O : never ; function objectTypeToString ( this ) { return getStateTreeNode ( this ) . toString ( ) ; } internal hidden export interface ModelTypeConfig { name ? : string ; properties ? : ModelPropertiesDeclaration ; initializers ? : ReadonlyArray < ( instance : any ) => any > ; preProcessor ? : ( snapshot : any ) => any ; postProcessor ? : ( snapshot : any ) => any ; } const defaultObjectOptions = { name : "AnonymousModel" , properties : { } , initializers : EMPTY_ARRAY } ; function toPropertiesObject ( declaredProps ) { return Object . keys ( declaredProps ) . reduce ( ( props , key ) => { if ( key in Hook ) throw fail ( `Hook '${ key }' was defined as property. Hooks should be defined as part of the actions` ) ; const descriptor = Object . getOwnPropertyDescriptor ( props , key ) ! ; if ( "get" in descriptor ) { throw fail ( "Getters are not supported as properties. Please use views instead" ) ; } const value = descriptor . value ; if ( value === null || value === undefined ) { throw fail ( "The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?" ) ; } else if ( isPrimitive ( value ) ) { return Object . assign ( { } , props , { [ key ] : optional ( getPrimitiveFactoryFromValue ( value ) , value ) } ) ; } else if ( value instanceof MapType ) { return Object . assign ( { } , props , { [ key ] : optional ( value , { } ) } ) ; } else if ( value instanceof ArrayType ) { return Object . assign ( { } , props , { [ key ] : optional ( value , [ ] ) } ) ; } else if ( isType ( value ) ) { return props ; } else if ( devMode ( ) && typeof value === "function" ) { throw fail ( `Invalid type definition for property '${ key }', it looks like you passed a function. Did you forget to invoke it, or did you intend to declare a view / action?` ) ; } else if ( devMode ( ) && typeof value === "object" ) { throw fail ( `Invalid type definition for property '${ key }', it looks like you passed an object. Try passing another model type or a types.frozen.` ) ; } else { throw fail ( `Invalid type definition for property '${ key }', cannot infer a type from a value like '${ value }' (${ typeof value })` ) ; } } , declaredProps as any ) ; } internal hidden export class ModelType < PROPS extends ModelProperties , OTHERS , CustomC , CustomS , MT extends IModelType < PROPS , OTHERS , CustomC , CustomS > > extends ComplexType < ModelCreationType2 < PROPS , CustomC > , ModelSnapshotType2 < PROPS , CustomS > , ModelInstanceType < PROPS , OTHERS > > implements IModelType < PROPS , OTHERS , CustomC , CustomS > { readonly flags = TypeFlags . Object ; public readonly initializers ! : ( ( instance : any ) => any ) [ ] ; public readonly properties ! : PROPS ; private preProcessor ! : ( snapshot : any ) => any | undefined ; private postProcessor ! : ( snapshot : any ) => any | undefined ; private readonly propertyNames : string [ ] ; constructor ( opts ) { super ( opts . name || defaultObjectOptions . name ) ; Object . assign ( this , defaultObjectOptions , opts ) ; this . properties = toPropertiesObject ( this . properties ) as PROPS ; freeze ( this . properties ) ; this . propertyNames = Object . keys ( this . properties ) ; this . identifierAttribute = this . _getIdentifierAttribute ( ) ; } private _getIdentifierAttribute ( ) { let identifierAttribute = undefined ; this . forAllProps ( ( propName , propType ) => { if ( propType . flags & TypeFlags . Identifier ) { if ( identifierAttribute ) throw fail ( `Cannot define property '${ propName }' as object identifier, property '${ identifierAttribute }' is already defined as identifier property` ) ; identifierAttribute = propName ; } } ) ; return identifierAttribute ; } cloneAndEnhance ( opts ) { return new ModelType ( { name : opts . name || this . name , properties : Object . assign ( { } , this . properties , opts . properties ) , initializers : this . initializers . concat ( opts . initializers || [ ] ) , preProcessor : opts . preProcessor || this . preProcessor , postProcessor : opts . postProcessor || this . postProcessor } ) ; } actions < A extends ModelActions > ( fn ) { const actionInitializer = ( self ) => { this . instantiateActions ( self , fn ( self ) ) ; return self ; } ; return this . cloneAndEnhance ( { initializers : [ actionInitializer ] } ) ; } private instantiateActions ( self , actions ) { if ( ! isPlainObject ( actions ) ) throw fail ( `actions initializer should return a plain object containing actions` ) ; Object . keys ( actions ) . forEach ( ( name ) => { if ( name === PRE_PROCESS_SNAPSHOT ) throw fail ( `Cannot define action '${ PRE_PROCESS_SNAPSHOT }', it should be defined using 'type.preProcessSnapshot(fn)' instead` ) ; if ( name === POST_PROCESS_SNAPSHOT ) throw fail ( `Cannot define action '${ POST_PROCESS_SNAPSHOT }', it should be defined using 'type.postProcessSnapshot(fn)' instead` ) ; let action2 = actions [ name ] ; let baseAction = ( self as any ) [ name ] ; if ( name in Hook && baseAction ) { let specializedAction = action2 ; action2 = function ( ) { baseAction . apply ( null , arguments ) ; specializedAction . apply ( null , arguments ) ; } ; } const middlewares = ( action2 as any ) . $mst_middleware ; let boundAction = action2 . bind ( actions ) ; boundAction . $mst_middleware = middlewares ; const actionInvoker = createActionInvoker ( self as any , name , boundAction ) ; actions [ name ] = actionInvoker ; ( ! devMode ( ) ? addHiddenFinalProp : addHiddenWritableProp ) ( self , name , actionInvoker ) ; } ) ; } named : MT [ "named" ] = ( name ) => { return this . cloneAndEnhance ( { name } ) ; } ; props : MT [ "props" ] = ( properties ) => { return this . cloneAndEnhance ( { properties } ) ; } ; volatile < TP extends object > ( fn ) { if ( typeof fn !== "function" ) { throw fail ( `You passed an ${ typeof fn } to volatile state as an argument, when function is expected` ) ; } const stateInitializer = ( self ) => { this . instantiateVolatileState ( self , fn ( self ) ) ; return self ; } ; return this . cloneAndEnhance ( { initializers : [ stateInitializer ] } ) ; } private instantiateVolatileState ( self , state ) { if ( ! isPlainObject ( state ) ) throw fail ( `volatile state initializer should return a plain object containing state` ) ; set ( self , state ) ; } extend < A extends ModelActions = { } , V extends Object = { } , VS extends Object = { } > ( fn ) { const initializer = ( self ) => { const { actions , views , state , ... rest } = fn ( self ) ; for ( let key in rest ) throw fail ( `The \`extend\` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '${ key }'` ) ; if ( state ) this . instantiateVolatileState ( self , state ) ; if ( views ) this . instantiateViews ( self , views ) ; if ( actions ) this . instantiateActions ( self , actions ) ; return self ; } ; return this . cloneAndEnhance ( { initializers : [ initializer ] } ) ; } views < V extends Object > ( fn ) { const viewInitializer = ( self ) => { this . instantiateViews ( self , fn ( self ) ) ; return self ; } ; return this . cloneAndEnhance ( { initializers : [ viewInitializer ] } ) ; } private instantiateViews ( self , views ) { if ( ! isPlainObject ( views ) ) throw fail ( `views initializer should return a plain object containing views` ) ; Object . keys ( views ) . forEach ( ( key ) => { const descriptor = Object . getOwnPropertyDescriptor ( views , key ) ! ; if ( "get" in descriptor ) { defineProperty ( self , key , descriptor ) ; makeObservable ( self , { [ key ] : computed } as any ) ; } else if ( typeof descriptor . value === "function" ) { ; ( ! devMode ( ) ? addHiddenFinalProp : addHiddenWritableProp ) ( self , key , descriptor . value ) ; } else { throw fail ( `A view member should either be a function or getter based property` ) ; } } ) ; } preProcessSnapshot : MT [ "preProcessSnapshot" ] = ( preProcessor ) => { const currentPreprocessor = this . preProcessor ; if ( ! currentPreprocessor ) return this . cloneAndEnhance ( { preProcessor } ) ; else return this . cloneAndEnhance ( { preProcessor : ( snapshot ) => currentPreprocessor ( preProcessor ( snapshot ) ) } ) ; } ; postProcessSnapshot : MT [ "postProcessSnapshot" ] = ( postProcessor ) => { const currentPostprocessor = this . postProcessor ; if ( ! currentPostprocessor ) return this . cloneAndEnhance ( { postProcessor } ) ; else return this . cloneAndEnhance ( { postProcessor : ( snapshot ) => postProcessor ( currentPostprocessor ( snapshot ) ) } ) ; } ; instantiate ( parent , subpath , environment , initialValue ) { const value = isStateTreeNode ( initialValue ) ? initialValue : this . applySnapshotPreProcessor ( initialValue ) ; return createObjectNode ( this , parent , subpath , environment , value ) ; } initializeChildNodes ( objNode , initialSnapshot = { } ) { const type = objNode . type as this ; const result = { } ; type . forAllProps ( ( name , childType ) => { result [ name ] = childType . instantiate ( objNode , name , undefined , ( initialSnapshot as any ) [ name ] ) ; } ) ; return result ; } createNewInstance ( childNodes ) { return observable . object ( childNodes , EMPTY_OBJECT , mobxShallow ) as any ; } finalizeNewInstance ( node , instance ) { addHiddenFinalProp ( instance , "toString" , objectTypeToString ) ; this . forAllProps ( ( name ) => { _interceptReads ( instance , name , node . unbox ) ; } ) ; this . initializers . reduce ( ( self , fn ) => fn ( self ) , instance ) ; intercept ( instance , this . willChange ) ; observe ( instance , this . didChange ) ; } private willChange ( chg ) { const change = chg as IObjectWillChange & { newValue ? : any ; } ; const node = getStateTreeNode ( change . object ) ; const subpath = change . name as string ; node . assertWritable ( { subpath } ) ; const childType = ( node . type as this ) . properties [ subpath ] ; if ( childType ) { typecheckInternal ( childType , change . newValue ) ; change . newValue = childType . reconcile ( node . getChildNode ( subpath ) , change . newValue , node , subpath ) ; } return change ; } private didChange ( chg ) { const change = chg as IObjectWillChange & { newValue ? : any ; oldValue ? : any ; } ; const childNode = getStateTreeNode ( change . object ) ; const childType = ( childNode . type as this ) . properties [ change . name as string ] ; if ( ! childType ) { return ; } const oldChildValue = change . oldValue ? change . oldValue . snapshot : undefined ; childNode . emitPatch ( { op : "replace" , path : escapeJsonPath ( change . name as string ) , value : change . newValue . snapshot , oldValue : oldChildValue } , childNode ) ; } getChildren ( node ) { const res = [ ] ; this . forAllProps ( ( name ) => { res . push ( this . getChildNode ( node , name ) ) ; } ) ; return res ; } getChildNode ( node , key ) { if ( ! ( key in this . properties ) ) throw fail ( "Not a value property: " + key ) ; const adm = _getAdministration ( node . storedValue , key ) ; const childNode = adm . raw ( ) ; if ( ! childNode ) throw fail ( "Node not available for property " + key ) ; return childNode ; } getSnapshot ( node , applyPostProcess = true ) { const res = { } as any ; this . forAllProps ( ( name , type ) => { ; ( getAtom ( node . storedValue , name ) as any ) . reportObserved ( ) ; res [ name ] = this . getChildNode ( node , name ) . snapshot ; } ) ; if ( applyPostProcess ) { return this . applySnapshotPostProcessor ( res ) ; } return res ; } processInitialSnapshot ( childNodes ) { const processed = { } as any ; Object . keys ( childNodes ) . forEach ( ( key ) => { processed [ key ] = childNodes [ key ] . getSnapshot ( ) ; } ) ; return this . applySnapshotPostProcessor ( processed ) ; } applyPatchLocally ( node , subpath , patch ) { if ( ! ( patch . op === "replace" || patch . op === "add" ) ) { throw fail ( `object does not support operation ${ patch . op }` ) ; } ; ( node . storedValue as any ) [ subpath ] = patch . value ; } applySnapshot ( node , snapshot ) { const preProcessedSnapshot = this . applySnapshotPreProcessor ( snapshot ) ; typecheckInternal ( this , preProcessedSnapshot ) ; this . forAllProps ( ( name ) => { ; ( node . storedValue as any ) [ name ] = preProcessedSnapshot [ name ] ; } ) ; } applySnapshotPreProcessor ( snapshot ) { const processor = this . preProcessor ; return processor ? processor . call ( null , snapshot ) : snapshot ; } applySnapshotPostProcessor ( snapshot ) { const postProcessor = this . postProcessor ; if ( postProcessor ) return postProcessor . call ( null , snapshot ) ; return snapshot ; } getChildType ( propertyName ) { assertIsString ( propertyName , 1 ) ; return this . properties [ propertyName ] ; } isValidSnapshot ( value , context ) { let snapshot = this . applySnapshotPreProcessor ( value ) ; if ( ! isPlainObject ( snapshot ) ) { return typeCheckFailure ( context , snapshot , "Value is not a plain object" ) ; } return flattenTypeErrors ( this . propertyNames . map ( ( key ) => this . properties [ key ] . validate ( snapshot [ key ] , getContextForPath ( context , key , this . properties [ key ] ) ) ) ) ; } private forAllProps ( fn ) { this . propertyNames . forEach ( ( key ) => fn ( key , this . properties [ key ] ) ) ; } describe ( ) { return ( "{ " + this . propertyNames . map ( ( key ) => key + ": " + this . properties [ key ] . describe ( ) ) . join ( "; " ) + " }" ) ; } getDefaultSnapshot ( ) { return EMPTY_OBJECT as this [ "C" ] ; } removeChild ( node , subpath ) { ; ( node . storedValue as any ) [ subpath ] = undefined ; } } ModelType . prototype . applySnapshot = action ( ModelType . prototype . applySnapshot ) ; export function model < P extends ModelPropertiesDeclaration = { } > ( name , properties ? ) ; export function model < P extends ModelPropertiesDeclaration = { } > ( properties ? ) ; /**
 * `types.model` - Creates a new model type by providing a name, properties, volatile state and actions.
 *
 * See the [model type](/concepts/trees#creating-models) description or the [getting started](intro/getting-started.md#getting-started-1) tutorial.
 */ export function model ( ... args ) { const name = typeof args [ 0 ] === "string" ? args . shift ( ) : "AnonymousModel" ; const properties = args . shift ( ) || { } ; return new ModelType ( { name , properties } ) ; } hidden export type _CustomJoin < A , B > = A extends _NotCustomized ? B : A & B ; export function compose < PA extends ModelProperties , OA , FCA , FSA , PB extends ModelProperties , OB , FCB , FSB > ( name , A , B ) ; export function compose < PA extends ModelProperties , OA , FCA , FSA , PB extends ModelProperties , OB , FCB , FSB > ( A , B ) ; export function compose < PA extends ModelProperties , OA , FCA , FSA , PB extends ModelProperties , OB , FCB , FSB , PC extends ModelProperties , OC , FCC , FSC > ( name , A , B , C ) ; export function compose < PA extends ModelProperties , OA , FCA , FSA , PB extends ModelProperties , OB , FCB , FSB , PC extends ModelProperties , OC , FCC , FSC > ( A , B , C ) ; export function compose < PA extends ModelProperties , OA , FCA , FSA , PB extends ModelProperties , OB , FCB , FSB , PC extends ModelProperties , OC , FCC , FSC , PD extends ModelProperties , OD , FCD , FSD > ( name , A , B , C , D ) ; export function compose < PA extends ModelProperties , OA , FCA , FSA , PB extends ModelProperties , OB , FCB , FSB , PC extends ModelProperties , OC , FCC , FSC , PD extends ModelProperties , OD , FCD , FSD > ( A , B , C , D ) ; export function compose < PA extends ModelProperties , OA , FCA , FSA , PB extends ModelProperties , OB , FCB , FSB , PC extends ModelProperties , OC , FCC , FSC , PD extends ModelProperties , OD , FCD , FSD , PE extends ModelProperties , OE , FCE , FSE > ( name , A , B , C , D , E ) ; export function compose < PA extends ModelProperties , OA , FCA , FSA , PB extends ModelProperties , OB , FCB , FSB , PC extends ModelProperties , OC , FCC , FSC , PD extends ModelProperties , OD , FCD , FSD , PE extends ModelProperties , OE , FCE , FSE > ( A , B , C , D , E ) ; export function compose < PA extends ModelProperties , OA , FCA , FSA , PB extends ModelProperties , OB , FCB , FSB , PC extends ModelProperties , OC , FCC , FSC , PD extends ModelProperties , OD , FCD , FSD , PE extends ModelProperties , OE , FCE , FSE , PF extends ModelProperties , OF , FCF , FSF > ( name , A , B , C , D , E , F ) ; export function compose < PA extends ModelProperties , OA , FCA , FSA , PB extends ModelProperties , OB , FCB , FSB , PC extends ModelProperties , OC , FCC , FSC , PD extends ModelProperties , OD , FCD , FSD , PE extends ModelProperties , OE , FCE , FSE , PF extends ModelProperties , OF , FCF , FSF > ( A , B , C , D , E , F ) ; export function compose < PA extends ModelProperties , OA , FCA , FSA , PB extends ModelProperties , OB , FCB , FSB , PC extends ModelProperties , OC , FCC , FSC , PD extends ModelProperties , OD , FCD , FSD , PE extends ModelProperties , OE , FCE , FSE , PF extends ModelProperties , OF , FCF , FSF , PG extends ModelProperties , OG , FCG , FSG > ( name , A , B , C , D , E , F , G ) ; export function compose < PA extends ModelProperties , OA , FCA , FSA , PB extends ModelProperties , OB , FCB , FSB , PC extends ModelProperties , OC , FCC , FSC , PD extends ModelProperties , OD , FCD , FSD , PE extends ModelProperties , OE , FCE , FSE , PF extends ModelProperties , OF , FCF , FSF , PG extends ModelProperties , OG , FCG , FSG > ( A , B , C , D , E , F , G ) ; export function compose < PA extends ModelProperties , OA , FCA , FSA , PB extends ModelProperties , OB , FCB , FSB , PC extends ModelProperties , OC , FCC , FSC , PD extends ModelProperties , OD , FCD , FSD , PE extends ModelProperties , OE , FCE , FSE , PF extends ModelProperties , OF , FCF , FSF , PG extends ModelProperties , OG , FCG , FSG , PH extends ModelProperties , OH , FCH , FSH > ( name , A , B , C , D , E , F , G , H ) ; export function compose < PA extends ModelProperties , OA , FCA , FSA , PB extends ModelProperties , OB , FCB , FSB , PC extends ModelProperties , OC , FCC , FSC , PD extends ModelProperties , OD , FCD , FSD , PE extends ModelProperties , OE , FCE , FSE , PF extends ModelProperties , OF , FCF , FSF , PG extends ModelProperties , OG , FCG , FSG , PH extends ModelProperties , OH , FCH , FSH > ( A , B , C , D , E , F , G , H ) ; export function compose < PA extends ModelProperties , OA , FCA , FSA , PB extends ModelProperties , OB , FCB , FSB , PC extends ModelProperties , OC , FCC , FSC , PD extends ModelProperties , OD , FCD , FSD , PE extends ModelProperties , OE , FCE , FSE , PF extends ModelProperties , OF , FCF , FSF , PG extends ModelProperties , OG , FCG , FSG , PH extends ModelProperties , OH , FCH , FSH , PI extends ModelProperties , OI , FCI , FSI > ( name , A , B , C , D , E , F , G , H , I ) ; export function compose < PA extends ModelProperties , OA , FCA , FSA , PB extends ModelProperties , OB , FCB , FSB , PC extends ModelProperties , OC , FCC , FSC , PD extends ModelProperties , OD , FCD , FSD , PE extends ModelProperties , OE , FCE , FSE , PF extends ModelProperties , OF , FCF , FSF , PG extends ModelProperties , OG , FCG , FSG , PH extends ModelProperties , OH , FCH , FSH , PI extends ModelProperties , OI , FCI , FSI > ( A , B , C , D , E , F , G , H , I ) ; /**
 * `types.compose` - Composes a new model from one or more existing model types.
 * This method can be invoked in two forms:
 * Given 2 or more model types, the types are composed into a new Type.
 * Given first parameter as a string and 2 or more model types,
 * the types are composed into a new Type with the given name
 */ export function compose ( ... args ) { const hasTypename = typeof args [ 0 ] === "string" ; const typeName = hasTypename ? args [ 0 ] : "AnonymousModel" ; if ( hasTypename ) { args . shift ( ) ; } if ( devMode ( ) ) { args . forEach ( ( type , i ) => { assertArg ( type , isModelType , "mobx-state-tree model type" , hasTypename ? i + 2 : i + 1 ) ; } ) ; } return args . reduce ( ( prev , cur ) => prev . cloneAndEnhance ( { name : prev . name + "_" + cur . name , properties : cur . properties , initializers : cur . initializers , preProcessor : ( snapshot ) => cur . applySnapshotPreProcessor ( prev . applySnapshotPreProcessor ( snapshot ) ) , postProcessor : ( snapshot ) => cur . applySnapshotPostProcessor ( prev . applySnapshotPostProcessor ( snapshot ) ) } ) ) . named ( typeName ) ; } param type returns export function isModelType < IT extends IAnyModelType = IAnyModelType > ( type ) { return isType ( type ) && ( type . flags & TypeFlags . Object ) > 0 ; }