@ws-ui/store 0.2.31 → 0.2.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -143,7 +143,7 @@ End try`}];function iv(e,r){switch(e){case v.FileFolderType.WEBFORMS:{const t={m
143
143
  `)}}),e.addCase(zn.pending,(r,t)=>{const{tab:a}=t.meta.arg;switch(a.type){case v.FileFolderType.CLASS:case v.FileFolderType.METHOD:v.lspSubject.next({action:v.LspActions.WILL_SAVE,payload:{filePath:a.path}});break}}),e.addCase(zn.fulfilled,(r,t)=>{if(!t.payload)return;const a=r.tabs.find(({path:s})=>{var i;return s===((i=t.payload)==null?void 0:i.path)});if(a){switch(a.content=t.payload.content,a.date=t.payload.date,a.initialContent=t.payload.initialContent,a.flags.touched=!1,a.flags.confirmed=!0,a.flags.old=!1,a.type){case v.FileFolderType.CLASS:case v.FileFolderType.METHOD:v.lspSubject.next({action:v.LspActions.DID_SAVE,payload:{filePath:a.path,content:a.content}});break}t.payload.errors.length>0&&v.toastSubject.next({kind:"error",message:t.payload.errors})}}),e.addCase(zn.rejected,()=>{v.toastSubject.next({kind:"danger",message:"Cannot save file"})}),e.addCase(hv.fulfilled,(r,t)=>{const a=[...t.payload.files];r.tabs=r.tabs.map(s=>{if([v.FileFolderType.CLASS,v.FileFolderType.METHOD].includes(s.type)){const i=a.find(u=>u.name===s.name&&u.type===s.type);if(i){const u=new Date(s.date),l=new Date(i.date);if(u.getTime()!==l.getTime())return{...s,flags:{...s.flags,old:!0}}}}return s})}),e.addCase(as.pending,(r,t)=>{r.tabs=r.tabs.map(a=>a.path===t.meta.arg.path?{...a,flags:{...a.flags,loading:!0}}:a)}),e.addCase(as.fulfilled,(r,t)=>{const a=t.payload;if(a){const s=t.meta.arg;r.tabs=r.tabs.map(i=>{if(i.name===s.name&&i.type===s.type){const u=i.extra||{};return i.type===v.FileFolderType.METHOD?(u.attributes=v.parseAttributes(a.content),a.content=v.addAttributesToContent(a.content,{})):i.type===v.FileFolderType.SETTINGS&&(a.content={}),{...i,initialContent:a.content,content:a.content,date:a.date,flags:{enabled:i.flags.enabled,confirmed:i.flags.confirmed},extra:u}}return i})}}),e.addCase(as.rejected,(r,t)=>{const a=t.meta.arg.path;r.tabs=r.tabs.map(s=>s.path===a?{...s,flags:{...s.flags,loading:!1}}:s)}),e.addCase(ol.fulfilled,(r,t)=>{if(!t.payload)return;const{line:a,offset:s}=t.meta.arg,i=r.tabs.find(({path:u})=>{var l;return u===((l=t.payload)==null?void 0:l.path)});i&&(i.extra={...i.extra,initialLineInfo:{line:a,offset:s,lastModification:Date.now()}})}),e.addCase(pv.fulfilled,(r,t)=>{if(!t.payload)return;const{selection:a}=t.meta.arg,s=r.tabs.find(({path:i})=>{var u;return i===((u=t.payload)==null?void 0:u.path)});s&&(s.extra={...s.extra,initialSelectionInfo:{selection:a,lastModification:Date.now()}})}),e.addCase(Vn.fulfilled,(r,t)=>{t.payload.new!==t.payload.old&&(r.tabs=[...r.tabs].map(a=>a.path===t.payload.old.path?{...a,path:t.payload.new.path,name:t.payload.new.name}:a),r.activeTab===t.payload.old.path&&(r.activeTab=t.payload.new.path))}),e.addCase(Eu.pending,(r,t)=>{const a=t.meta.arg,s=`${a.path}${a.ext?`.${a.ext}`:""}`;switch(a.ext){case"4dm":case"4qs":v.lspSubject.next({action:v.LspActions.WILL_DELETE,payload:{filePath:s}});break}}),e.addCase(Eu.fulfilled,(r,t)=>{const{deleted:a,node:s}=t.payload;if(!a)return;const i=`${s.path}${s.ext?`.${s.ext}`:""}`;switch(s.ext){case"4dm":case"4qs":v.lspSubject.next({action:v.LspActions.DID_DELETE,payload:{filePath:i}});break}if(r.tabs=r.tabs.filter(u=>u.path!==i),r.recent=r.recent.filter(({path:u})=>i!==u),r.tabs.length){r.activeTab=r.tabs[r.tabs.length-1].path;return}r.activeTab=""}),e.addCase(Tu.pending,(r,t)=>{const a=t.meta.arg,s=`${a.path}${a.ext?`.${a.ext}`:""}`;switch(a.ext){case"4dm":case"4qs":v.lspSubject.next({action:v.LspActions.WILL_DELETE,payload:{filePath:s}});break}}),e.addCase(Tu.fulfilled,(r,t)=>{const{node:a}=t.payload,s=`${a.path}${a.ext?`.${a.ext}`:""}`;switch(a.ext){case"4dm":case"4qs":v.lspSubject.next({action:v.LspActions.DID_DELETE,payload:{filePath:s}});break}}),e.addCase($a.fulfilled,(r,t)=>{const{draggedNode:a,newLocation:s}=t.meta.arg;if(r.tabs.find(i=>i.path===`${a.path}${a.ext?`.${a.ext}`:""}`))return r.tabs=r.tabs.map(i=>i.path===`${a.path}${a.ext?`.${a.ext}`:""}`?{...i,path:`${s.path}/${a.name}.${a.ext}`}:i),r.recent=r.recent.map(i=>i.path===`${a.path}${a.ext?`.${a.ext}`:""}`?{...i,path:`${s.path}/${a.name}.${a.ext}`}:i),r.activeTab=`${s.path}/${a.name}.${a.ext}`,r}),e.addCase(Cs.fulfilled,(r,t)=>{const a=r.tabs.find(s=>s.path===t.payload.path);a&&(a.flags.touched=!1,a.flags.confirmed=!0,a.date=t.payload.date,a.content=t.payload.content,a.initialContent=t.payload.content)}),e.addCase(vv.fulfilled,(r,t)=>{var i;if(!((i=t.payload)!=null&&i.path))return;const a=r.tabs.find(v.by("path",t.payload.path));if(!a)return;a.content=a.content+`
144
144
  exposed Function ${t.meta.arg.name}()
145
145
  `,a.flags={...a.flags,touched:!0,confirmed:!0};const s=a.content.split(`
146
- `);a.path.startsWith("Classes/")&&(a.type=v.FileFolderType.CLASS),a.extra={...a.extra,editor:v.EDITOR.Code,initialLineInfo:{line:s.length-1,lastModification:Date.now()}}}),e.addCase(sl.fulfilled,(r,t)=>{var i,u;if(!((i=t.payload)!=null&&i.path)||(u=t.payload)!=null&&u.namespace)return;const a=t.payload.path,s=r.tabs.find(v.by("path",a));!s||!s.content||!s.content.metadata||(Object.assign(s.content.metadata,{datasources:t.payload.datasources}),s.flags.touched=!0,s.flags.confirmed=!0)}),e.addCase(il.fulfilled,(r,t)=>{const{payload:a,meta:{arg:s}}=t;s.namespace||r.tabs.forEach(i=>{i.path===s.path&&Object.assign(i.content,{metadata:{...i.content.metadata,datasources:a}})})}),e.addCase(_v.fulfilled,(r,t)=>{const{staleThreadIds:a}=t.payload;if(a.length===0)return;const s=a.map(i=>`Debugger/${i}`);if(r.tabs=r.tabs.filter(i=>!s.includes(i.path)),r.recent=r.recent.filter(({path:i})=>!s.includes(i)),r.tabs.length){r.activeTab=r.tabs[r.tabs.length-1].path;return}r.activeTab=""}),e.addCase(nl.pending,r=>zc(r,!1)),e.addCase($v,(r,t)=>{const{id:a}=t.payload;r.tabs=r.tabs.map(s=>{var i;return{...s,content:{...s.content,metadata:{...s.content.metadata,states:(((i=s.content.metadata)==null?void 0:i.states)||[]).map(u=>{if(u.conditions){const l=Xs(u.conditions,a);return l?{...u,conditions:l}:xe.omit(u,"conditions")}return u})}}}})}),e.addMatcher(pr(yu),(r,t)=>{["project"].includes(t.payload.path)&&zc(r,!0)}),e.addMatcher(pr(zs),r=>{zc(r,!1)}),e.addMatcher(pr(Wv,Pt),(r,t)=>{const{payload:a}=t;let s;typeof a=="string"?s=r.tabs.find(({path:i})=>a===i):s=a,s&&(r.recent=[s,...r.recent.filter(({path:i})=>![s.path,"settings"].includes(i))])}),e.addMatcher(pr(tv,ev),r=>{r.tabs=r.tabs.map(t=>t.path===v.ROLES_TAB_PATH?{...t,flags:{...t.flags,confirmed:!0,touched:!0}}:t)}),e.addMatcher(pr(rl),r=>{r.tabs=r.tabs.map(t=>t.path===v.ROLES_TAB_PATH?{...t,flags:{...t.flags,touched:!1}}:t)}),e.addMatcher(pr(ll.fulfilled,fl.fulfilled,La.fulfilled,Kn.fulfilled),(r,t)=>{var s,i,u;const a=r.tabs.find(v.by("path",((s=t.payload)==null?void 0:s.path)||t.meta.arg.path));!a||(i=t.payload)!=null&&i.namespace||(a.flags.touched=!0,a.flags.confirmed=!0,Object.assign(a.content,{metadata:{...a.content.metadata,datasources:(u=t.payload)==null?void 0:u.list}}))}),e.addMatcher(pr(La.fulfilled,Kn.fulfilled),(r,t)=>{var l;const a=r.tabs.find(v.by("path",((l=t.payload)==null?void 0:l.path)||t.meta.arg.path));if(!a)return;const{panel:s}=a.view,i=v.getDatasourceId({id:t.meta.arg.id,namespace:t.meta.arg.namespace});if(s.type==="datasource"&&s.current===i)switch(t.type){case La.fulfilled.type:Object.assign(a.view.panel,{type:"component",current:$O});break;case Kn.fulfilled.type:const f=v.getDatasourceId({id:t.meta.arg.new_name,namespace:t.meta.arg.namespace});Object.assign(a.view.panel,{type:"datasource",current:f});break}})}}),{copyToClipBoard:eI,setTabs:tI,closeTab:Qs,setContent:dl,setTabFlags:Lv,setTabsFlags:rI,setTabExtra:nI,closeAllTabs:Nv,addDataSource:aI,closeRightTabs:kv,closeOthers:jv,closeLeftTabs:Bv,closeSavedTabs:oI,setDataSources:sI,removeDataSource:iI,confirmTab:cI,selectTab:Wv,selectTabByReference:Pt,openTabUnselected:Hv,addWebFormStyles:uI,changeTabEditor:lI,openSettingsTab:fI,setWebformState:Uv,setPanelState:dI,addWebformState:pI,editWebformState:hI,updateStateConditionDs:gI,removeWebformState:vI,resetComponentState:mI,addDefaultWebformState:yI,removeDefaultWebformState:bI,setDefaultWebformStates:_I,setHistoryContent:Gv,unlockHistory:pl,undo:SI,redo:EI}=Ga.actions,qv=Ga.reducer,TI=mv.reducer,Cn=Z("catalog/fetchCatalog",async(e,{rejectWithValue:r})=>{var t,a;try{const s=await v.getCatalog(),i=new Map,u=new Map,l=new Map;return(t=s.singletons)==null||t.forEach(({methods:f=[],...p})=>{const h={...p,methods:f};l.set(p.name,h)}),(a=s==null?void 0:s.dataClasses)==null||a.forEach(({methods:f=[],...p})=>{if(p.uuid||Object.assign(p,{uuid:v.generateUUID()}),p.attributes){const m=["storage","relatedEntity"];p.attributes=p.attributes.map(_=>(m.includes(_.kind)&&!_.uuid&&Object.assign(_,{uuid:v.generateUUID()}),_))}const h={...p,methods:f};u.set(p.className,h),i.set(p.collectionName,h)}),{__BASEID:s.__BASEID,__UNIQID:s.__UNIQID,dataClassByCollectionName:Object.fromEntries(i.entries()),methods:s.methods||[],dataClasses:Object.fromEntries(u.entries()),singletons:Object.fromEntries(l.entries())}}catch{return r("Error while loading the catalog")}}),wI=Yt({name:"catalog",initialState:{state:"loading"},reducers:{},extraReducers(e){e.addCase(Cn.pending,()=>({state:"loading"})).addCase(Cn.fulfilled,(r,{payload:t})=>({state:"loaded",model:t})).addCase(Cn.rejected,(r,t)=>({state:"error",error:t.payload||"Error while loading the catalog"}))}}),CI=wI.reducer,xI=Vg.reducer,ss=Z("shared_datasources/fetchSharedSources",async(e,{rejectWithValue:r})=>{try{return await v.getSharedDatasources()}catch{return r("Error while loading the shared datasources")}}),Yv=Z("shared_datasources/addSharedSource",async(e,{rejectWithValue:r,getState:t})=>{try{const a=JSON.parse(JSON.stringify(t().sharedDatasources));if(e.namespace)a.sources[e.namespace]?a.sources[e.namespace].push(e):a.sources[e.namespace]=[e];else return r("Namespace is required");return await v.setSharedSources(a.sources),a.sources}catch{return r("Error while saving the shared datasources")}}),Vv=Z("shared_datasources/editSharedSource",async(e,{rejectWithValue:r,getState:t})=>{try{const a=t().sharedDatasources;if(!e.namespace)return r("Namespace is required");if(a.sources[e.namespace])a.sources[e.namespace]=a.sources[e.namespace].map(s=>s.id===e.id?{...e,id:s.id}:s);else return r("Namespace not found");return await v.setSharedSources(a.sources),a.sources}catch{return r("Error while saving the shared datasources")}}),zv=Z("shared_datasources/deleteSharedSource",async(e,{rejectWithValue:r,getState:t})=>{try{const a={...t().sharedDatasources};if(a.sources[e.namespace]){const s=a.sources[e.namespace].filter(i=>i.id!==e.id);if(s.length===0){const{[e.namespace]:i,...u}=a.sources;a.sources=u}else a.sources={...a.sources,[e.namespace]:s}}return await v.setSharedSources(a.sources),a.sources}catch{return r("Error while saving the shared datasources")}}),hl=Z("shared_datasources/updateSharedDatasources",async(e,{rejectWithValue:r,getState:t})=>{try{const a={...t().sharedDatasources};for(const s of e){if(!s.namespace)return r("Namespace is required");if(a.sources[s.namespace])a.sources[s.namespace]=a.sources[s.namespace].map(i=>i.id===s.id?s:i);else return r("Namespace not found")}return await v.setSharedSources(a.sources),a.sources}catch{return r("Error while saving the shared datasources")}}),OI=Z("shared_datasources/setDatasourceEvents",async({tabPath:e,name:r,namespace:t,events:a},{getState:s,dispatch:i})=>{var S,T,w;const{root:{tabs:u},sharedDatasources:l}=s(),f=((w=(T=(S=u.find(({path:P})=>P===e))==null?void 0:S.content)==null?void 0:T.metadata)==null?void 0:w.datasources)||[],p={local:!1,shared:!1},h=(P,D)=>P.id===r&&(!t&&!P.namespace||P.namespace===t)?(D==null||D(),{...P,events:a}):P,m=f.map(P=>h(P,()=>{p.local=!0})),_=xe.flatten(xe.values(l.sources)).map(P=>h(P,()=>{p.shared=!0}));p.local&&i(dl({path:e,content:m,contentPath:"metadata.datasources"})),p.shared&&i(hl(_))}),Kv=Yt({name:"shared-datasources",initialState:{},reducers:{addEmptyNamespace(e,r){e.sources[r.payload.name]=[]}},extraReducers(e){e.addCase(ss.pending,r=>({state:"loading",sources:{}})).addCase(ss.fulfilled,(r,t)=>({state:"loaded",sources:t.payload})).addCase(ss.rejected,(r,t)=>({state:"error",sources:{},error:t.payload||"Error while loading the shared datasources"})).addCase(hl.fulfilled,(r,t)=>({state:"loaded",sources:t.payload})).addCase(il.fulfilled,(r,t)=>{const{payload:a,meta:{arg:s}}=t;s.namespace&&Object.assign(r.sources,{[s.namespace]:a})}).addCase(Yv.fulfilled,(r,t)=>({...r,sources:t.payload})).addCase(zv.fulfilled,(r,t)=>({...r,sources:t.payload})).addCase(Vv.fulfilled,(r,t)=>({...r,sources:t.payload})).addCase(sl.fulfilled,(r,t)=>{if(!t.payload)return r;const{datasources:a,namespace:s}=t.payload;s&&r.sources[s]&&Object.assign(r.sources[s],{[s]:a})}).addMatcher(pr(ll.fulfilled,La.fulfilled,fl.fulfilled,Kn.fulfilled),(r,t)=>{if(!t.payload)return;const{namespace:a,list:s}=t.payload;a&&Object.assign(r.sources,{[a]:s})})}}),{addEmptyNamespace:AI}=Kv.actions,RI=Kv.reducer,DI=ov.reducer,is=Z("shared_css/fetchSharedCSS",async(e,{rejectWithValue:r})=>{try{const{classes:t}=await v.getSharedCSS();return t}catch{return r("Error while loading the shared CSS")}}),PI=v.queue();async function FI(e){const r={verb:v.DesignerRequestVerb.SET_FILE_CONTENT,asText:!1,name:"shared_css.json",path:"",root:"shared",content:{classes:e.map(({scope:t,...a})=>({...a}))}};await PI(()=>v.http(v.API_PREFIX,{method:"POST",body:JSON.stringify(r),headers:new Headers({"Content-Type":"application/json"})}))}const Jv=Yt({name:"shared-css",initialState:()=>{const{sharedCSS:e}=Zn();return e||{state:"loading",styles:[]}},reducers:{updateSharedCss:(e,r)=>(e.styles=r.payload.classes,FI(r.payload.classes),e),initSharedCss:(e,r)=>(e.styles=r.payload.classes,e)},extraReducers(e){e.addCase(is.pending,r=>({...r,state:"loading"})).addCase(is.fulfilled,(r,{payload:t})=>({state:"loaded",styles:t})).addCase(is.rejected,(r,t)=>({...r,state:"error",error:t.payload||"Error while loading the shared css"}))}}),{updateSharedCss:II,initSharedCss:MI}=Jv.actions,$I=Jv.reducer,LI={},NI=Yt({name:"tabs",initialState:LI,reducers:{}}),kI=e=>B(aa,r=>{var t,a;return(a=(t=r.find(s=>s.path===e))==null?void 0:t.view)==null?void 0:a.panel});NI.reducer;const Xv=lh({root:qv,explorer:DI,debugger:TI,settings:gP,catalog:CI,roles:fP,sharedDatasources:RI,savedConditions:QF,webforms:BF,modals:xI,sharedCSS:$I,model:MF});let Aa;const Zv=()=>(Aa||(Aa=aw({reducer:Xv}),Aa.subscribe(m1(()=>{const{root:{activeTab:e,tabs:r,recent:t},roles:a,debugger:s,webforms:i,sharedCSS:u,settings:{session:l}}=Aa.getState();Dh({...l}),Rh({tabs:r,activeTab:e,recent:t,roles:a,debugger:s,webforms:i,sharedCSS:u})},1e3))),Aa);var wu={exports:{}},Gn={};/** @license React v17.0.2
146
+ `);a.path.startsWith("Classes/")&&(a.type=v.FileFolderType.CLASS),a.extra={...a.extra,editor:v.EDITOR.Code,initialLineInfo:{line:s.length-1,lastModification:Date.now()}}}),e.addCase(sl.fulfilled,(r,t)=>{var i,u;if(!((i=t.payload)!=null&&i.path)||(u=t.payload)!=null&&u.namespace)return;const a=t.payload.path,s=r.tabs.find(v.by("path",a));!s||!s.content||!s.content.metadata||(Object.assign(s.content.metadata,{datasources:t.payload.datasources}),s.flags.touched=!0,s.flags.confirmed=!0)}),e.addCase(il.fulfilled,(r,t)=>{const{payload:a,meta:{arg:s}}=t;s.namespace||r.tabs.forEach(i=>{i.path===s.path&&Object.assign(i.content,{metadata:{...i.content.metadata,datasources:a}})})}),e.addCase(_v.fulfilled,(r,t)=>{const{staleThreadIds:a}=t.payload;if(a.length===0)return;const s=a.map(i=>`Debugger/${i}`);if(r.tabs=r.tabs.filter(i=>!s.includes(i.path)),r.recent=r.recent.filter(({path:i})=>!s.includes(i)),r.tabs.length){r.activeTab=r.tabs[r.tabs.length-1].path;return}r.activeTab=""}),e.addCase(nl.pending,r=>zc(r,!1)),e.addCase($v,(r,t)=>{const{id:a}=t.payload;r.tabs=r.tabs.map(s=>{var i;return{...s,content:{...s.content,metadata:{...s.content.metadata,states:(((i=s.content.metadata)==null?void 0:i.states)||[]).map(u=>{if(u.conditions){const l=Xs(u.conditions,a);return l?{...u,conditions:l}:xe.omit(u,"conditions")}return u})}}}})}),e.addMatcher(pr(yu),(r,t)=>{["project"].includes(t.payload.path)&&zc(r,!0)}),e.addMatcher(pr(zs),r=>{zc(r,!1)}),e.addMatcher(pr(Wv,Pt),(r,t)=>{const{payload:a}=t;let s;typeof a=="string"?s=r.tabs.find(({path:i})=>a===i):s=a,s&&(r.recent=[s,...r.recent.filter(({path:i})=>![s.path,"settings"].includes(i))])}),e.addMatcher(pr(tv,ev),r=>{r.tabs=r.tabs.map(t=>t.path===v.ROLES_TAB_PATH?{...t,flags:{...t.flags,confirmed:!0,touched:!0}}:t)}),e.addMatcher(pr(rl),r=>{r.tabs=r.tabs.map(t=>t.path===v.ROLES_TAB_PATH?{...t,flags:{...t.flags,touched:!1}}:t)}),e.addMatcher(pr(ll.fulfilled,fl.fulfilled,La.fulfilled,Kn.fulfilled),(r,t)=>{var s,i,u;const a=r.tabs.find(v.by("path",((s=t.payload)==null?void 0:s.path)||t.meta.arg.path));!a||(i=t.payload)!=null&&i.namespace||(a.flags.touched=!0,a.flags.confirmed=!0,Object.assign(a.content,{metadata:{...a.content.metadata,datasources:(u=t.payload)==null?void 0:u.list}}))}),e.addMatcher(pr(La.fulfilled,Kn.fulfilled),(r,t)=>{var l;const a=r.tabs.find(v.by("path",((l=t.payload)==null?void 0:l.path)||t.meta.arg.path));if(!a)return;const{panel:s}=a.view,i=v.getDatasourceId({id:t.meta.arg.id,namespace:t.meta.arg.namespace});if(s.type==="datasource"&&s.current===i)switch(t.type){case La.fulfilled.type:Object.assign(a.view.panel,{type:"component",current:$O});break;case Kn.fulfilled.type:const f=v.getDatasourceId({id:t.meta.arg.new_name,namespace:t.meta.arg.namespace});Object.assign(a.view.panel,{type:"datasource",current:f});break}})}}),{copyToClipBoard:eI,setTabs:tI,closeTab:Qs,setContent:dl,setTabFlags:Lv,setTabsFlags:rI,setTabExtra:nI,closeAllTabs:Nv,addDataSource:aI,closeRightTabs:kv,closeOthers:jv,closeLeftTabs:Bv,closeSavedTabs:oI,setDataSources:sI,removeDataSource:iI,confirmTab:cI,selectTab:Wv,selectTabByReference:Pt,openTabUnselected:Hv,addWebFormStyles:uI,changeTabEditor:lI,openSettingsTab:fI,setWebformState:Uv,setPanelState:dI,addWebformState:pI,editWebformState:hI,updateStateConditionDs:gI,removeWebformState:vI,resetComponentState:mI,addDefaultWebformState:yI,removeDefaultWebformState:bI,setDefaultWebformStates:_I,setHistoryContent:Gv,unlockHistory:pl,undo:SI,redo:EI}=Ga.actions,qv=Ga.reducer,TI=mv.reducer,Cn=Z("catalog/fetchCatalog",async(e,{rejectWithValue:r})=>{var t,a;try{const s=await v.getCatalog(),i=new Map,u=new Map,l=new Map;return(t=s.singletons)==null||t.forEach(({methods:f=[],...p})=>{const h={...p,methods:f};l.set(p.name,h)}),(a=s==null?void 0:s.dataClasses)==null||a.forEach(({methods:f=[],...p})=>{if(p.uuid||Object.assign(p,{uuid:v.generateUUID()}),p.attributes){const m=["storage","relatedEntity"];p.attributes=p.attributes.map(_=>(m.includes(_.kind)&&!_.uuid&&Object.assign(_,{uuid:v.generateUUID()}),_))}const h={...p,methods:f};u.set(p.className,h),i.set(p.collectionName,h)}),{__BASEID:s.__BASEID,__UNIQID:s.__UNIQID,dataClassByCollectionName:Object.fromEntries(i.entries()),methods:s.methods||[],dataClasses:Object.fromEntries(u.entries()),singletons:Object.fromEntries(l.entries())}}catch{return r("Error while loading the catalog")}}),wI=Yt({name:"catalog",initialState:{state:"loading"},reducers:{},extraReducers(e){e.addCase(Cn.pending,()=>({state:"loading"})).addCase(Cn.fulfilled,(r,{payload:t})=>({state:"loaded",model:t})).addCase(Cn.rejected,(r,t)=>({state:"error",error:t.payload||"Error while loading the catalog"}))}}),CI=wI.reducer,xI=Vg.reducer,ss=Z("shared_datasources/fetchSharedSources",async(e,{rejectWithValue:r})=>{try{return await v.getSharedDatasources()}catch{return r("Error while loading the shared datasources")}}),Yv=Z("shared_datasources/addSharedSource",async(e,{rejectWithValue:r,getState:t})=>{try{const a=JSON.parse(JSON.stringify(t().sharedDatasources));if(e.namespace)a.sources[e.namespace]?a.sources[e.namespace].push(e):a.sources[e.namespace]=[e];else return r("Namespace is required");return await v.setSharedSources(a.sources),a.sources}catch{return r("Error while saving the shared datasources")}}),Vv=Z("shared_datasources/editSharedSource",async(e,{rejectWithValue:r,getState:t})=>{try{const a=t().sharedDatasources;if(!e.namespace)return r("Namespace is required");if(a.sources[e.namespace])a.sources[e.namespace]=a.sources[e.namespace].map(s=>s.id===e.id?{...e,id:s.id}:s);else return r("Namespace not found");return await v.setSharedSources(a.sources),a.sources}catch{return r("Error while saving the shared datasources")}}),zv=Z("shared_datasources/deleteSharedSource",async(e,{rejectWithValue:r,getState:t})=>{try{const a={...t().sharedDatasources};if(a.sources[e.namespace]){const s=a.sources[e.namespace].filter(i=>i.id!==e.id);if(s.length===0){const{[e.namespace]:i,...u}=a.sources;a.sources=u}else a.sources={...a.sources,[e.namespace]:s}}return await v.setSharedSources(a.sources),a.sources}catch{return r("Error while saving the shared datasources")}}),hl=Z("shared_datasources/updateSharedDatasources",async(e,{rejectWithValue:r,getState:t})=>{try{const a={...t().sharedDatasources};for(const s of e){if(!s.namespace)return r("Namespace is required");if(a.sources[s.namespace])a.sources[s.namespace]=a.sources[s.namespace].map(i=>i.id===s.id?s:i);else return r("Namespace not found")}return await v.setSharedSources(a.sources),a.sources}catch{return r("Error while saving the shared datasources")}}),OI=Z("shared_datasources/setDatasourceEvents",async({tabPath:e,name:r,namespace:t,events:a},{getState:s,dispatch:i})=>{var S,T,w;const{root:{tabs:u},sharedDatasources:l}=s(),f=((w=(T=(S=u.find(({path:P})=>P===e))==null?void 0:S.content)==null?void 0:T.metadata)==null?void 0:w.datasources)||[],p={local:!1,shared:!1},h=(P,D)=>P.id===r&&(!t&&!P.namespace||P.namespace===t)?(D==null||D(),{...P,events:a}):P,m=f.map(P=>h(P,()=>{p.local=!0})),_=xe.flatten(xe.values(l.sources)).map(P=>h(P,()=>{p.shared=!0}));p.local&&i(dl({path:e,content:m,contentPath:"metadata.datasources"})),p.shared&&i(hl(_))}),Kv=Yt({name:"shared-datasources",initialState:{},reducers:{addEmptyNamespace(e,r){e.sources[r.payload.name]=[]}},extraReducers(e){e.addCase(ss.pending,r=>({state:"loading",sources:{}})).addCase(ss.fulfilled,(r,t)=>({state:"loaded",sources:t.payload})).addCase(ss.rejected,(r,t)=>({state:"error",sources:{},error:t.payload||"Error while loading the shared datasources"})).addCase(hl.fulfilled,(r,t)=>({state:"loaded",sources:t.payload})).addCase(il.fulfilled,(r,t)=>{const{payload:a,meta:{arg:s}}=t;s.namespace&&Object.assign(r.sources,{[s.namespace]:a})}).addCase(Yv.fulfilled,(r,t)=>({...r,sources:t.payload})).addCase(zv.fulfilled,(r,t)=>({...r,sources:t.payload})).addCase(Vv.fulfilled,(r,t)=>({...r,sources:t.payload})).addCase(sl.fulfilled,(r,t)=>{if(!t.payload)return r;const{datasources:a,namespace:s}=t.payload;s&&r.sources[s]&&Object.assign(r.sources[s],{[s]:a})}).addMatcher(pr(ll.fulfilled,La.fulfilled,fl.fulfilled,Kn.fulfilled),(r,t)=>{if(!t.payload)return;const{namespace:a,list:s}=t.payload;a&&Object.assign(r.sources,{[a]:s})})}}),{addEmptyNamespace:AI}=Kv.actions,RI=Kv.reducer,DI=ov.reducer,is=Z("shared_css/fetchSharedCSS",async(e,{rejectWithValue:r})=>{try{const{classes:t}=await v.getSharedCSS();return t}catch{return r("Error while loading the shared CSS")}}),PI=v.queue();async function FI(e){const r={verb:v.DesignerRequestVerb.SET_FILE_CONTENT,asText:!1,name:"shared_css.json",path:"",root:"shared",content:{classes:e.map(({scope:t,...a})=>({...a}))}};await PI(()=>v.http(v.API_PREFIX,{method:"POST",body:JSON.stringify(r),headers:new Headers({"Content-Type":"application/json"})}))}const Jv=Yt({name:"shared-css",initialState:()=>{const{sharedCSS:e}=Zn();return e||{state:"loading",styles:[]}},reducers:{updateSharedCss:(e,r)=>(e.styles=r.payload.classes,FI(r.payload.classes),e),initSharedCss:(e,r)=>(e.styles=r.payload.classes,e)},extraReducers(e){e.addCase(is.pending,r=>({...r,state:"loading"})).addCase(is.fulfilled,(r,{payload:t})=>({state:"loaded",styles:t})).addCase(is.rejected,(r,t)=>({...r,state:"error",error:t.payload||"Error while loading the shared css"}))}}),{updateSharedCss:II,initSharedCss:MI}=Jv.actions,$I=Jv.reducer,LI={},NI=Yt({name:"tabs",initialState:LI,reducers:{}}),kI=e=>B(aa,r=>{var t,a;return(a=(t=r.find(s=>s.path===e))==null?void 0:t.view)==null?void 0:a.panel});NI.reducer;const Xv=lh({root:qv,explorer:DI,debugger:TI,settings:gP,catalog:CI,roles:fP,sharedDatasources:RI,savedConditions:QF,webforms:BF,modals:xI,sharedCSS:$I,model:MF});let Aa;const Zv=()=>{if(!Aa){Aa=aw({reducer:Xv});const e=()=>{const{root:{activeTab:r,tabs:t,recent:a},roles:s,debugger:i,webforms:u,sharedCSS:l,settings:{session:f}}=Aa.getState();Dh({...f}),Rh({tabs:t,activeTab:r,recent:a,roles:s,debugger:i,webforms:u,sharedCSS:l})};Aa.subscribe(m1(e,1e3)),window.addEventListener("beforeunload",e)}return Aa};var wu={exports:{}},Gn={};/** @license React v17.0.2
147
147
  * react-jsx-runtime.production.min.js
148
148
  *
149
149
  * Copyright (c) Facebook, Inc. and its affiliates.