import { IUser } from "@esri/arcgis-rest-auth" ; import { cloneObject , HubProduct } from "@esri/hub-common" ; import { WELLKNOWNTEAMS } from "../well-known-teams" ; import { canUserCreateTeamInProduct } from "./can-user-create-team-in-product" ; import { IGroupTemplate } from "../types" ; import { removeInvalidPrivs } from "./remove-invalid-privs" ; import { applyPrivPropValuesToTemplate } from "./apply-priv-prop-values-to-template" ; param { object } user param { string } environment param { string } portalApiVersion param { string } subscriptionInfoType export function getUserCreatableTeams ( user , environment , portalApiVersion , subscriptionInfoType = "" ) { console . warn ( "Hub.js::getUserCreatableTeams Deprecation warning portalApiVersion will be removed at v9.0.0" ) ; const teams = WELLKNOWNTEAMS ; const updatedUser = removeInvalidPrivs ( user , subscriptionInfoType ) ; return cloneObject ( teams ) . reduce ( ( acc , teamTmpl ) => { const copyTemplate = applyPrivPropValuesToTemplate ( updatedUser , teamTmpl ) ; if ( canUserCreateTeamInProduct ( updatedUser , environment , copyTemplate ) ) { acc . push ( copyTemplate ) ; } return acc ; } , [ ] ) ; }