import ServerEventV2 from "./ServerEvent" ; import { NetMiddleware } from "../middleware" ; type MiddlewareOverload = [ middleware : Array < NetMiddleware < any > > , callback : ( player : Player , ... args : Array < unknown > ) => void ] ; type CreateServerListenerOverloads = [ callback : ( player : Player , ... args : Array < unknown > ) => void ] | MiddlewareOverload ; function isMiddlewareArgument < T > ( args ) { return args . size ( ) > 1 && typeIs ( args [ 0 ] , "table" ) ; } /**
 * Creates a server listening event
 */ export default function createServerListener < T extends Array < unknown > > ( id , callback ) ; export default function createServerListener < M0 extends Array < unknown > > ( id , middleware , callback ) ; export default function createServerListener < M0 extends Array < unknown > , M1 extends Array < unknown > > ( id , middleware , callback ) ; export default function createServerListener < M0 extends Array < unknown > , M1 extends Array < unknown > , M2 extends Array < unknown > > ( id , middleware , callback ) ; export default function createServerListener ( id , ... args ) { let event ; if ( isMiddlewareArgument ( args ) ) { const [ middleware , connect ] = args ; event = new ServerEventV2 ( id , middleware as [ NetMiddleware < any > ] ) ; return event . Connect ( connect ) ; } else { const [ connect ] = args ; event = new ServerEventV2 ( id ) ; return event . Connect ( connect ) ; } }