import{r as _}from"./redux-1.0.74-D8bIc6ki.js";import{j as f}from"./useLoadAppMetaData-1.0.74-BqAxVdHB.js";import{a as g,u as b}from"./hooks-1.0.74-NYCTWeI9.js";import{b as d,ai as i,l as n}from"./lib-1.0.74-B5IEqfHg.js";import{e as l}from"./utils-1.0.74-7xWhx9mc.js";const I=()=>{const s=g(),[e,o]=_.useState(!0);return{loadApps:()=>{f(function(a){const p=a==null?void 0:a.data;n.debug("response data",p);const c=a==null?void 0:a.context;if(n.debug("response context",c),Array.isArray(p)){const u=[];for(let t=0;t<p.length;t++)u.push({appId:p[t].app_id,appName:p[t].app_name,appTitle:p[t].app_title,appType:p[t].app_type,appSettings:p[t].app_settings,appAddToMenu:p[t].app_add_to_menu});const m=c.reduce((t,A)=>{const{app_id:r,app_id_detail:L}=A;return t[r]=t[r]??[],t[r].push(Number(L)),t},{});s(i({appList:u,appApps:m}))}else console.error(p),l((p==null?void 0:p.message)??d.contactSupport,{variant:"error"}),s(i({appList:[],appApps:{}}));o(!1)},a=>{console.error("error",a),l(a??d.contactSupport,{variant:"error"}),s(i({appList:[],appApps:{}})),o(!1)})},isLoading:e,setIsLoading:o}},N=()=>{const s=b(e=>e.apps.appList);return n.debug("apps",s),s};export{I as a,N as u};
