import{r as i,h as t,H as e,g as s,c as n}from"./p-cb5076d4.js";import{g as r}from"./p-d9adb303.js";import{r as o,c as a}from"./p-f46dff5e.js";import{L as d}from"./p-5eec4552.js";import{g as l}from"./p-54805fa4.js";import{I as c,N as f}from"./p-6cf8ecf7.js";import"./p-d343a062.js";import"./p-d50d0ec8.js";function v(i){if(i&&i.sort)return i.sort}const p=class{constructor(t){i(this,t),this.list=d.init(),this.onSimpleFilterChange=({filter:i})=>{this.quickFilter=i,this.fetchList(!0,!0)}}async invalidate(i){this.fetchList(!0,!0)}async retainPosition(){const i=this.el.querySelector(".list-container");i&&(i.scrollTop=this.scrollPosition)}componentWillLoad(){this.fetchList()}fetchList(i=!1,t=!1){const{list:e,quickFilter:s}=this;if(e.isPending||!t&&e.isEndReached()||e.error&&!i)return;const{query:n,table:d,ui:l}=this.view,c=l.quickSearch?r(l.quickSearch,d.fields):void 0,f=function(i,t,e){let s=i?i.filter:void 0;if(t&&(s=i&&i.filter?{operator:"and",filters:[i.filter,t]}:t),s)return o(a(s),e)}(n,s||c,this.params);this.list=e.beforeFetch(),this.apiData.query(d.name,{fields:n.fields,filter:f,limit:25,skip:t?0:e.data?e.data.length:0,sort:v(n)}).then((i=>{this.list=e.afterFetch(i,!t)}),(i=>{this.list=e.afterFetchError(i)}))}render(){const{list:i,view:s}=this,{ui:n}=s;return t(e,null,n.quickSearch&&t("dvn-filter-simple",{fields:this.view.table.fields,progressing:i.isPending&&!!i.data,config:n.quickSearch,onFilterChange:i=>this.onSimpleFilterChange(i.detail)}),i.data&&t("div",{class:"list-container",onScroll:i=>{const t=i.target;this.scrollPosition=t.scrollTop,t.offsetHeight+t.scrollTop>=t.scrollHeight&&this.fetchList()}},t("dvn-card-list-view",{config:s.ui,fields:s.table.fields,items:i.data}),i.isPending&&!n.quickSearch&&t("div",{class:"d-flex justify-content-center pb-3"},t("dvn-progress",{indefinite:!0,tint:"primary"}))),i.isPending&&!i.data&&t("div",{class:"d-flex justify-content-center"},t("dvn-progress",{indefinite:!0,tint:"primary"})),i.error&&t("devingen-error-card",{error:i.error,message:"Fetching list failed.",onRetry:()=>this.fetchList(!0)}))}get el(){return s(this)}};p.style="dvn-app-view-list-view-card{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;overflow:hidden;padding:1rem}dvn-app-view-list-view-card dvn-filter-simple{margin-bottom:1rem}dvn-app-view-list-view-card .list-container{-ms-flex:1;flex:1;overflow-y:auto;overflow-x:hidden}";const h=class{constructor(t){i(this,t),this.invalidation=n(this,"invalidation",7),this.notification=n(this,"notification",7),this.action=n(this,"action",7)}render(){const{createdMeeting:i,membership:s,user:n,userSettings:r,params:{viewedUserMembershipConfig:o,viewedUserMembership:a},view:d}=this;return t(e,{class:"d-block"},t("takvim-available-time-picker",{apiTakvim:this.apiTakvim,userId:n._id,membershipConfigId:s.config._id,userSettings:r,viewedUserId:a.user._id,viewedUserMembershipConfigId:o._id,calendarConfigId:d.table._id,onCreateMeeting:i=>{var t,e;d.successNavigationAction&&(this.createdMeeting=i.detail),null===(e=null===(t=d.events)||void 0===t?void 0:t.success)||void 0===e||e.forEach((i=>{i instanceof c&&this.invalidation.emit(i),i instanceof f&&this.notification.emit(i)}))}}),t("dvn-dialog",{title:"Meeting is scheduled.",shown:!!i,onDismiss:()=>this.createdMeeting=void 0},t("div",{slot:"actions"},t("dvn-button",{view:"flat",onClick:()=>this.createdMeeting=void 0},"Stay on page"),t("dvn-button",{tint:"primary",view:"flat",onClick:()=>this.action.emit(l({},this.createdMeeting,this.view.successNavigationAction))},"Go to meeting page"))))}};export{p as dvn_app_view_list_view_card,h as dvn_app_view_takvim_available_time_picker_view}