import{_ as M,i as y,H as R,g as m,E as f,J as K,e as H,P as L,z as B,r as E,o as r,c as n,F as v,a as c,b as l,w as i,y as C,d as u,t as w,k as g}from"./index-20f16f2f.js";import{g as F}from"./timeline-435273bb.js";const N={name:"PageMasterTimetableEventintegrity",setup(){const b=y(g.errorHandler).handleErrorAsync,x=y(g.resourceHourStore),D=y(g.eventStore),a=y(g.generalTimetableScope),_=R(!1),p=R([]),T=b(async()=>{_.value=!0;const e=(await D.query({startTime:m.combine(a.dateRange.value[0],f()),endTime:m.combine(a.dateRange.value[1],f())})).filter(o=>o.resources.some(k=>k.id===a.classroom.value)&&!o.eventChangeTo),t=[...new Map(e.flatMap(o=>o.resources).map(o=>[o.id,o])).values()].filter(o=>!o.disabled),s=await Promise.all(t.map(o=>x.query({resource:o.id,startTime:m.combine(a.dateRange.value[0],f()),endTime:m.combine(a.dateRange.value[1],f())})));p.value=t.map((o,k)=>({resource:o,timeline:F(e.filter(S=>S.resources.some(V=>V.id===o.id)),s[k],m.min,m.max)})),_.value=!1});K([a.classroom,a.dateRange],()=>{T()},{immediate:!0});const d=H(()=>p.value.filter(({resource:e})=>e.multiplicity>=0).flatMap(({resource:e,timeline:t})=>t.filter(s=>s.events.length>e.multiplicity).map(s=>({resource:e,startTime:s.startTime,endTime:s.endTime,events:s.events})))),h=H(()=>p.value.flatMap(({resource:e,timeline:t})=>t.filter(s=>s.events.length>0&&!s.available).flatMap(s=>s.events.map(o=>({resource:e,event:o,startTime:s.startTime,endTime:s.endTime})))));return{loading:_,collisionErrors:d,outOfHourErrors:h,getResourceDisplayText:L,cmp:B}}},O=c("h1",null,"整合性チェック",-1),P={key:0},q=c("h1",null,"衝突",-1),G=c("p",null," 「リソース」が「開始時刻」と「終了時刻」の間で複数のイベントで使われています。 それらのイベントは「イベント」で示されています。 ",-1),j={key:1},z=c("h1",null,"時間外",-1),A=c("p",null," 「リソース」が使用可能時間外の「開始時刻」と「終了時刻」の間で使われています。 使われているイベントは「イベント」で示されています。 ",-1),J={key:1};function I(b,x,D,a,_,p){const T=E("EventLink"),d=E("DateTime"),h=E("DataGrid");return r(),n("div",null,[O,a.loading?(r(),n("p",P,"読み込み中")):(r(),n(v,{key:1},[c("section",null,[q,a.collisionErrors.length!==0?(r(),n(v,{key:0},[G,l(h,{modelValue:a.collisionErrors,itemKey:e=>`${e.resource.id}-${e.startTime.isoFormat()}`,headers:[{text:"イベント",value:"events"},{text:"リソース",value:"resource",sort:(e,t)=>e.id-t.id},{text:"開始時刻",value:"startTime",sort:(e,t)=>a.cmp(e,t)},{text:"終了時刻",value:"endTime",sort:(e,t)=>a.cmp(e,t)}]},{"td-イベント":i(({data:e})=>[(r(!0),n(v,null,C(e,t=>(r(),n(v,{key:t.id},[u(" ["),l(T,{event:t},null,8,["event"]),u("] ")],64))),128))]),"td-リソース":i(({data:e})=>[u(w(a.getResourceDisplayText(e)),1)]),"td-開始時刻":i(({data:e})=>[l(d,{value:e},null,8,["value"])]),"td-終了時刻":i(({data:e})=>[l(d,{value:e},null,8,["value"])]),_:1},8,["modelValue","itemKey","headers"])],64)):(r(),n("span",j,"衝突しているイベントはありません"))]),c("section",null,[z,a.outOfHourErrors.length!==0?(r(),n(v,{key:0},[A,l(h,{modelValue:a.outOfHourErrors,itemKey:e=>`${e.resource.id}-${e.event.id}`,headers:[{text:"イベント",value:"event",sort:(e,t)=>e.id-t.id},{text:"リソース",value:"resource",sort:(e,t)=>e.id-t.id},{text:"開始時刻",value:"startTime",sort:(e,t)=>a.cmp(e,t)},{text:"終了時刻",value:"endTime",sort:(e,t)=>a.cmp(e,t)}]},{"td-イベント":i(({data:e})=>[u(" ["),l(T,{event:e},null,8,["event"]),u("] ")]),"td-リソース":i(({data:e})=>[u(w(a.getResourceDisplayText(e)),1)]),"td-開始時刻":i(({data:e})=>[l(d,{value:e},null,8,["value"])]),"td-終了時刻":i(({data:e})=>[l(d,{value:e},null,8,["value"])]),_:1},8,["modelValue","itemKey","headers"])],64)):(r(),n("span",J,"時間外のイベントはありません"))])],64))])}const W=M(N,[["render",I]]);export{W as default};
