import * as Base from "./Base" ; import Projects from "./Projects" ; import ProjectManifest from "./ProjectManifest" ; import Badges from "./Badges" ; import Entries from "./Entries" ; import Assets from "./Assets" ; import Resources from "./Resources" ; import Rooms from "./Rooms" ; import Room from "./Room" ; import RoomUsers from "./RoomUsers" ; export { Base , Projects , ProjectManifest , Badges , Entries , Assets , Resources , Rooms , Room , RoomUsers } ; export function hasDuplicateName ( id , name , siblings ) { for ( const sibling of siblings ) { if ( sibling . id !== id && sibling . name === name ) return true ; } return false ; } export function ensureUniqueName ( id , name , siblings ) { name = name . trim ( ) ; let candidateName = name ; let nameNumber = 1 ; const matches = name . match ( /\d+$/ ) ; if ( matches != null ) { name = name . substring ( 0 , name . length - matches [ 0 ] . length ) ; nameNumber = parseInt ( matches [ 0 ] , 10 ) ; } while ( hasDuplicateName ( id , candidateName , siblings ) ) candidateName = `${ name }${ ++ nameNumber }` ; return candidateName ; }