Liferay.Loader.define("commerce-organization-web@5.0.52/js/data/users",["module","exports","require","../utils/constants","../utils/fetch"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.getUsersByEmails=function getUsersByEmails(t){const a=t.map((e=>"emailAddress eq '".concat(e,"'"))).join(" or "),s=new URL("".concat(themeDisplay.getPathContext()).concat(e),themeDisplay.getPortalURL());return s.searchParams.append("filter",a),(0,n.fetchFromHeadless)(s)},t.getOrganizationRoles=function getOrganizationRoles(){const e=new URL("".concat(themeDisplay.getPathContext()).concat(o),themeDisplay.getPortalURL());return e.searchParams.append("pageSize",100),e.searchParams.append("types",s.ORGANIZATIONS_ROLE_TYPE_ID),(0,n.fetchFromHeadless)(e,{},null,!0).then((e=>e.items))},t.getAccountRoles=function getAccountRoles(e){const t=new URL("".concat(themeDisplay.getPathContext()).concat(o),themeDisplay.getPortalURL());t.searchParams.append("pageSize",100),t.searchParams.append("types",s.ACCOUNTS_ROLE_TYPE_ID);const a="".concat(c,"/").concat(e,"/account-roles");return Promise.allSettled([(0,n.fetchFromHeadless)(t),(0,n.fetchFromHeadless)(a)]).then((([e,t])=>[...e.value.items,...t.value.items]))},t.getUsers=function getUsers(t){const a=new URL("".concat(themeDisplay.getPathContext()).concat(e),themeDisplay.getPortalURL());return a.searchParams.append("search",t),a.searchParams.append("pageSize",20),(0,n.fetchFromHeadless)(a)},t.deleteUser=function deleteUser(t){return(0,n.fetchFromHeadless)("".concat(e,"/").concat(t),{method:"DELETE"},null,!0)},t.removeUserFromOrganization=function removeUserFromOrganization(e,t){return(0,n.fetchFromHeadless)("".concat(r,"/").concat(t,"/user-accounts/by-email-address/").concat(e),{method:"DELETE"})},t.addUserEmailsToAccount=function addUserEmailsToAccount(e,t,a){const s=new URL("".concat(themeDisplay.getPathContext()).concat(c,"/").concat(e,"/user-accounts/by-email-address"),themeDisplay.getPortalURL());t&&s.searchParams.append("accountRoleIds","".concat(t));return(0,n.fetchFromHeadless)(s,{body:JSON.stringify(a),method:"POST"}).then((e=>e.items))},t.addUserEmailsToOrganization=function addUserEmailsToOrganization(e,t,a){const s=new URL("".concat(themeDisplay.getPathContext()).concat(r,"/").concat(e,"/user-accounts/by-email-address"),themeDisplay.getPortalURL());t&&s.searchParams.append("organizationRoleIds","".concat(t));return(0,n.fetchFromHeadless)(s,{body:JSON.stringify(a),method:"POST"}).then((e=>e.items))},t.removeUserFromAccount=function removeUserFromAccount(e,t){return(0,n.fetchFromHeadless)("".concat(c,"/").concat(t,"/user-accounts/by-email-address"),{body:JSON.stringify([e]),method:"DELETE"})},t.ORGANIZATIONS_ROOT_ENDPOINT=t.ACCOUNTS_ROOT_ENDPOINT=t.ROLES_ROOT_ENDPOINT=t.USERS_ROOT_ENDPOINT=void 0;var s=a("../utils/constants"),n=a("../utils/fetch");const e="/o/headless-admin-user/v1.0/user-accounts";t.USERS_ROOT_ENDPOINT=e;const o="/o/headless-admin-user/v1.0/roles";t.ROLES_ROOT_ENDPOINT=o;const c="/o/headless-admin-user/v1.0/accounts";t.ACCOUNTS_ROOT_ENDPOINT=c;const r="/o/headless-admin-user/v1.0/organizations";t.ORGANIZATIONS_ROOT_ENDPOINT=r}}));
//# sourceMappingURL=users.js.map