/*! phoscon-app 2024-01-19 */

export function initMachine(pages,scanStates,actions,Machine,interpret,context,detailEvents={}){const machine=Machine({id:"wizard",type:"parallel",context:context,states:{general:{...{id:"generalSub",initial:context.overviewInitial,states:{table:{on:{TABLE:"table",DETAILS:"details",EMPTY:"empty"},onEntry:["showTableView"],onExit:["hideTableView"]},empty:{on:{TABLE:"table",DETAILS:"details",EMPTY:"empty"},onEntry:["showEmptyView"],onExit:["hideEmptyView"]},details:{on:{TABLE:"table",DETAILS:"details",EMPTY:"empty",...detailEvents},onEntry:["showDetailsView"],onExit:["hideDetailsView"]}}}},pages:pages,scan:scanStates}},{actions:{showTableView:(context,event)=>{context.generalViews.overview.show()},hideTableView:(context,event)=>{context.generalViews.overview.hide()},showEmptyView:(context,event)=>{context.generalViews.emptyview.show()},hideEmptyView:(context,event)=>{context.generalViews.emptyview.hide()},showDetailsView:(context,event)=>{const View=context.generalViews.detailsView;if(View){let view=new View(event.model);view.service=context.service,context.generalViews.details=view}},hideDetailsView:(context,event)=>{context.generalViews.details.hide()},...actions}});let service=interpret(machine).onTransition(state=>{console.log("send: ",state.event," machine: ",state.value)});return machine.context.service=service,service.start(),machine};