import{v as o,w as l,x as B,y as P,s as c,L as i}from"../assets/layouts-e9o3BY4c.js";import{u as C,n as D}from"./vendor/react-core.DXghOv-E.min.js";var m;(function(a){a.PUBLIC="public",a.PRIVATE="private",a.INTERNAL="internal"})(m||(m={}));var N;(function(a){a.ALL="all",a.RESTRICTED="restricted",a.NONE="none"})(N||(N={}));var E;(function(a){a.TEXT_INPUT="textInput",a.TEXT_BOX="textBox",a.SINGLE_CHECKBOX="singleCheckbox",a.SINGLE_SELECT_DROPDOWN="singleSelectDropdown",a.MULTI_SELECT_DROPDOWN="multiSelectDropdown",a.DATE_PICKER="datePicker",a.NUMERIC_INPUT="numericInput",a.NUMERIC_DROPDOWN="numericDropdown"})(E||(E={}));var h;(function(a){a.REQUIRED="required",a.OPTIONAL="optional",a.HIDDEN="hidden"})(h||(h={}));var I;(function(a){a.TEXT="text",a.BOOLEAN="boolean",a.DATE="date",a.NUMBER="number",a.STRING_MUL="string[]",a.NUMBER_MUL="number[]"})(I||(I={}));var A;(function(a){a.TEXT="text",a.TEXT_MULTILINE="text-multiline",a.DROPDOWN="dropdown",a.CHECKBOX="checkbox",a.DATE="date",a.NUMBER="number",a.TOKENS="tokens"})(A||(A={}));const d="/profile-fields",n=o("@@userProfiles/fetchProfileFields",async(a,{rejectWithValue:r})=>{try{const{data:e}=await l.get(d,{params:{...a}});return e}catch(e){return r(e)}}),R=o("@@userProfiles/fetchProfileField",async(a,{rejectWithValue:r})=>{try{const{data:e}=await l.get(`${d}/${a}`);return e}catch(e){return r(e)}}),O=o("@@userProfiles/postProfileField",async(a,{rejectWithValue:r})=>{try{const{data:e}=await l.post(d,a);return e}catch(e){return r(e)}}),U=o("@@userProfiles/patchProfileField",async({apiName:a,...r},{rejectWithValue:e})=>{try{const{data:s}=await l.patch(`${d}/${a}`,r);return s}catch(s){return e(s)}}),u=o("@@userProfiles/fetchUserProfileFields",async({userID:a,...r},{rejectWithValue:e})=>{try{const{data:s}=await l.get(`users/${a}${d}`,r);return s}catch(s){return e(s)}}),p=o("@@userProfiles/deleteProfileField",async(a,{rejectWithValue:r})=>{try{return(await l.delete(`${d}/${a}`)).data}catch(e){return r(e)}});o("@@userProfiles/patchUserProfileFields",async({userID:a,...r},{rejectWithValue:e})=>{try{const{data:s}=await l.patch(`users/${a}${d}`,r);return s}catch(s){return e(s)}});const L=o("@@userProfiles/putProfileFieldsSorts",async(a,{rejectWithValue:r})=>{try{(await l.put(`${d}/sorts`,a)).data}catch(e){return r(e)}}),g={profileFieldApiNamesByParamHash:{},profileFieldsByApiName:{},profileFieldsByUserID:{},deleteStatusByApiName:{}},y=B({name:"userProfiles",initialState:g,reducers:{},extraReducers:a=>{a.addCase(n.pending,(r,e)=>{const s=c(e.meta.arg);r.profileFieldApiNamesByParamHash[s]={status:i.LOADING}}).addCase(n.fulfilled,(r,e)=>{const s=c(e.meta.arg);r.profileFieldApiNamesByParamHash[s]={status:i.SUCCESS,data:e.payload.map(t=>t.apiName)},e.payload.forEach(t=>{r.profileFieldsByApiName[t.apiName]=t})}).addCase(n.rejected,(r,e)=>{const s=c(e.meta.arg);r.profileFieldApiNamesByParamHash[s]={status:i.ERROR,error:e.error}}).addCase(R.fulfilled,(r,e)=>{const s=e.meta.arg;r.profileFieldsByApiName[s]=e.payload}).addCase(O.fulfilled,(r,e)=>{const{apiName:s}=e.payload;r.profileFieldsByApiName[s]=e.payload}).addCase(U.fulfilled,(r,e)=>{const s=e.payload.apiName;r.profileFieldsByApiName[s]={...r.profileFieldsByApiName[s],...e.payload}}).addCase(u.pending,(r,e)=>{const s=e.meta.arg.userID;r.profileFieldsByUserID[s]={status:i.LOADING}}).addCase(u.fulfilled,(r,e)=>{const s=e.meta.arg.userID;r.profileFieldsByUserID[s]={status:i.SUCCESS,data:e.payload}}).addCase(u.rejected,(r,e)=>{const s=e.meta.arg.userID;r.profileFieldsByUserID[s]={status:i.ERROR,error:e.error}}).addCase(p.pending,(r,e)=>{const s=e.meta.arg;r.deleteStatusByApiName[s]={status:i.LOADING}}).addCase(p.fulfilled,(r,e)=>{const s=e.meta.arg;r.deleteStatusByApiName[s]={status:i.SUCCESS,data:e.payload},delete r.profileFieldsByApiName[s],Object.keys(r.profileFieldApiNamesByParamHash).forEach(t=>{var f;r.profileFieldApiNamesByParamHash[t].data=(f=r.profileFieldApiNamesByParamHash[t].data)==null?void 0:f.filter(S=>S!==s)})}).addCase(p.rejected,(r,e)=>{const s=e.meta.arg;r.deleteStatusByApiName[s]={status:i.ERROR,error:e.error}}).addCase(L.fulfilled,(r,e)=>{Object.entries(e.meta.arg).forEach(([s,t])=>{r.profileFieldsByApiName[s]={...r.profileFieldsByApiName[s],sort:t}})})}});P({reducer:{[y.name]:y.reducer}});const T=()=>C(),H=D;export{A as P,H as a,m as b,n as f,T as u};
