PageSourceSearch

https://aegeanconferences.org/_nuxt/Dk5J7SiS.js

js aegeanconferences.org collected 2026-10-02 16:51:25 UTC 46,087 bytes, 3 lines download raw bytes

1import{_ as Ze}from"./dZMSHbq9.js";import{_ as et}from"./DPwGQeF8.js";import{_ as de}from"./D6dPIvLd.js";import{_ as Pe}from"./n1OAE_8c.js";import{_ as Fe}from"./C_w0lb7A.js";import{_ as Re}from"./Cdp_YfT8.js";import{_ as tt}from"./UKev0CPs.js";import{_ as lt}from"./DehZ5H7u.js";import{V as ve,v as ke}from"./C6Qf79MC.js";import{O as D,aI as ot,w as at,L as st,aO as ye,M as ce,V as J,aw as k,ap as I,al as fe,ao as z,aB as G,a2 as l,aq as c,ar as W,as as A,ag as C,ab as Ae,bj as be,ae as _e,aN as Se,ah as f,aL as ge,aC as pe,aP as $e,aQ as qe,bE as nt,P as it,aM as Te}from"#entry";import{u as rt}from"./n68KOXD4.js";import{P as K}from"./CCEm09Zy.js";import{C as xe}from"./CSwdhd6W.js";import{H as dt}from"./DkbZpHrl.js";import{H as ct}from"./B5H9Ps_8.js";import{s as ut}from"./lyztJrWD.js";import{_ as Ge}from"./D0AxRfMS.js";import{_ as He}from"./KYsXsWdt.js";import{V as Ie}from"./DGgWSxJQ.js";import{e as Be,h as Ue}from"./WnfvNmsL.js";import{s as Ee}from"./BZOH98OQ.js";import{a as re,V as q}from"./Ly1tOBCM.js";import{V as te}from"./DtPsbrB9.js";import{V as me}from"./PoHWt3Kk.js";import{V as Ce}from"./BCASv6ZW.js";import{_ as Qe}from"./DlAUqK2U.js";import{V as mt,a as Me}from"./CuwmHbI9.js";import{V as pt}from"./DHDUxPMK.js";import{V as _t}from"./B80HRRYi.js";import{V as Et,a as ft}from"./wLgNTfvD.js";import{V as ht}from"./C1hBpopr.js";import"./1AHlSwOj.js";import"./B0cMYZu1.js";import"./9-WWG6j4.js";import"./BsOYBvuL.js";import"./CYRMsH1k.js";import"./_Fz3sGdJ.js";import"./CnQ1hEwt.js";import"./DjG9fw8d.js";import"./C1a2pyZ1.js";import"./0VvUL2KS.js";import"./D_qxKlPu.js";import"./B06O5MmY.js";import"./BO9bjXXt.js";import"./DNf9vdG5.js";/* empty css        */import"./Bfllde9d.js";import"./D5TDcxfS.js";import"./CUU2iuv_.js";import"./BVljsg4b.js";import"./CKEKRAiK.js";import"./BdkPH9M0.js";import"./wtV5ePi_.js";import"./BpPbWvZm.js";import"./DEXjTAnV.js";import"./jqHxS0XK.js";import"./C1AvWPQ3.js";import"./DmKXoMrN.js";import"./C4fXAsfO.js";import"./BWvxqwnw.js";import"./CWYIK854.js";import"./BxwAcSWk.js";import"./B5b4euO_.js";import"./BcMcAxv0.js";import"./DvuZG3xc.js";import"./BdjqiDtm.js";import"./LZEDwdPY.js";import"./xgxpX_wP.js";import"./BqtdaJ6n.js";import"./2XMI3e6a.js";import"./CJOorrg0.js";function yt(h){const p=h!=="create",O=D(!1),P=D(!1),t=D(null),g=ot({conference_id:null,name:null,description:null,fees_increase_after:null,user_id:null,user:null}),v=D([]),$=D([]),e=D([]);return{form:t,formData:g,fees:v,hotelPrices:$,mealPrices:e,isSubmitting:O,isLoadingProduct:P,isEdit:p,loadProduct:async()=>{if(p){P.value=!0;try{const s=await K.fetchSingleProductById(h);return g.name=s.name,g.description=s.description,g.conference_id=s.conferenceId,g.fees_increase_after=s.feesIncreaseAfter?s.feesIncreaseAfter.split("T")[0]:null,g.user_id=s.user?.id||null,g.user={id:s.user?.id||null,email:s.user?.email||null,name:s.user?.first_name+" "+s.user?.last_name||null},v.value=s.prices.filter(n=>n.type==="fee"),$.value=s.prices.filter(n=>n.type==="hotel"),e.value=s.prices.filter(n=>n.type==="meal"),s.conferenceId}finally{P.value=!1}}},saveProduct:async()=>{if(!t.value)return!1;O.value=!0;try{const s={name:g.name,description:g.description,fees_increase_after:g.fees_increase_after,user_id:g.user_id,c
1onference_id:g.conference_id,registration_fees:v.value.map(n=>({person_type_id:n.personTypeId,list_price:n.listPrice,final_price:n.finalPrice,notes:n.notes})),hotel_prices:$.value.map(n=>({hotel_id:n.hotelId,hotel_room_type_id:n.hotelRoomTypeId,price:n.finalPrice,notes:n.notes})),meal_prices:e.value.map(n=>({meal_id:n.mealId,price:n.finalPrice,notes:n.notes,...n.mealId!==2&&{hotel_id:n.hotelId},...n.mealId===1&&{lunch_price:n.lunchPrice}}))};return await K.createProduct(s),await at({path:"/admin/products",query:{conferenceId:g.conference_id}}),!0}catch(s){throw s}finally{O.value=!1}},updateProduct:async()=>{if(!t.value)return!1;O.value=!0;try{return await K.updateProduct(h,g),!0}catch(s){throw s}finally{O.value=!1}}}}class At{static async getAllPersonTypes(){try{const p=await st.get("/person-types");return Array.isArray(p.data)?p.data:p.data&&Array.isArray(p.data.data)?p.data.data:[]}catch(p){return console.error("Failed to fetch person types",p),[]}}}function It(){const{showErrorToast:h}=ye(),p=D(!1),O=D(!1),P=D([]),t=D([]),g=D([]),v=D([]);return{conferences:P,hotels:t,personTypes:g,roomTypes:v,isLoadingDropdowns:p,isLoadingHotels:O,loadStaticDropdowns:async()=>{p.value=!0;try{const[i,r,b]=await Promise.all([xe.getConferencesDropdown(),dt.getAllHotelRoomTypes(),At.getAllPersonTypes()]);P.value=i.map(s=>({title:s.title,value:Number(s.id)})),v.value=r.hotelRoomTypes.map(s=>({title:s.name,value:Number(s.id)})),g.value=b.map(s=>({title:s.name,value:Number(s.id)}))}catch(i){console.error(i),h("Failed to load form options")}finally{p.value=!1}},fetchHotelsForConference:async i=>{O.value=!0,t.value=[];try{if(i){const r=await xe.getConferenceById(i);r&&Array.isArray(r.hotels)&&(t.value=r.hotels.map(b=>({title:b.name,value:Number(b.id)})))}else{const r=await ct.getAllHotels({});t.value=r.hotels.map(b=>({title:b.name,value:Number(b.id)}))}}catch(r){console.error("Failed to refresh hotels",r)}finally{O.value=!1}}}}const Lt={key:0},Ye=ce({__name:"ProductFeesTable",props:{items:{},personTypes:{},isEditMode:{type:Boolean},isInMaster:{type:Boolean}},emits:["edit","delete"],setup(h,{emit:p}){const O=p,P=h,t={COL_PERSON:"Person Type",COL_LIST:"List Price",COL_FINAL:"Final Price",COL_NOTES:"Notes",COL_ACTIONS:"Actions",HELP_INFO:"Here you can see all the created prices for each person type. You can edit or delete any of them by clicking on the respective action button."},g=[{title:t.COL_PERSON,key:"personName"},{title:t.COL_LIST,key:"listPriceDisp"},{title:t.COL_FINAL,key:"finalPriceDisp"},{title:t.COL_NOTES,key:"notes"},{key:"actions",title:t.COL_ACTIONS,type:"action",styleClass:"justify-end",align:"end"}],v=J(()=>P.items.map((e,i)=>{const r=P.personTypes.find(n=>n.value===e.personTypeId)?.title||"-",s=r.toLowerCase()==="accompanying person"?[]:P.isEditMode?["Edit"]:["Edit","Delete"];return{...e,index:i,personName:r,listPriceDisp:`${e.listPrice}€`,finalPriceDisp:`${e.finalPrice}€`,actions:s}})),$=({actionName:e,item:i})=>{e==="Edit"?O("edit",i.index):e==="Delete"&&O("delete",i.index)};return(e,i)=>{const r=de,b=He;return I(),k(fe,null,[h.isInMaster?G("",!0):(I(),z(r,{key:0},{default:c(()=>[W(A(t.HELP_INFO),1)]),_:1})),l(b,{headers:g,items:v.value,onClickAction:$},{"item.notes":c(({item:s})=>[!s.notes||s.notes.length<=20?(I(),k("span",Lt,A(s.notes||"-"),1)):(I(),z(Ie,{key:1,location:"bottom"},{activator:c(({props:n})=>[C("span",Ae(n,{class:"cursor-help"}),A(s.notes.substring(0,20))+"... ",17)]),default:c(()=>[W(" "+A(s.notes),1)]),_:2},1024))]),_:1},8,["items"])],64)}}}),Tt={class:"text-subtitle-1 font-weight-bold mb-2 text-primary"},Pt={class:"bg-grey-lighten-4 pa-4 rounded-lg"},Rt={class:"mt-4"},vt={key:0,class:"text-subtitle-1 font-weight-bold ml-2 my-2"},bt={key:1,class:"mt-4"},gt=ce({__name:"ProductFeesManager",props:{modelValue:{},personTypes:{},isEdit:{type:Boolean}},emits:["update:modelValue"],setup(h,{expose:p,emit:O}){const P=O,t=h,{showSuccessToast:g,showErrorToast:v}=ye(),$=be(),e={TITLE:"Register Fee",HELP_INFO:"Define registration fees for each person type. Note: Only 4 unique prices (one per person type) are allowed in total.",LABEL_PERSON:"Person Type",LABEL_LIST_PRICE:"List Price",LABEL_FINAL_PRICE:"Final Price",LABEL_NOTES:"Notes",BTN_ADD_ROW:"Add another person type",BTN_ADD_TO_LIST:"Add Registration Fees",HEADER_SUMMARY:"Summary of Registration Fees",PH_SELECT_TYPE:"Select Type",PH_NOTES:"Optional notes",ERR_PRICE_VALIDATION:"Final Price cannot be lower than List Price",ERR_REQUIRED:"This field is required",ERR_DUPLICATE_PERSON:"This person type already has a price defined.",SAVE_CHANGES:"Save changes"},i=D(null),r=D(null),b=D(!1),s=D(null),n=D([{id:null,person_type_id:null,list_price:null,final_price:null,notes:""}]),le=J(()=>t.isEdit?e.SAVE_CHANGES:e.BTN_ADD_TO_LIST),X=J(()=>t.personTypes.filter(m=>!m.title.toLowerCase().includes("accompanying")));_e(()=>t.modelValue,async()=>{await pe(),s.value&&s.value.resetValidation()},{deep:!0});const B=(m,_)=>{if(!m)return e.ERR_REQUIRED;const y=t.modelValue.some(U=>U.personTypeId===m),L=n.value.some((U,x)=>U.person_type_id===m&&x!==_);return y||L?e.ERR_DUPLICATE_PERSON:!0},Q=m=>m==null||m===""?e.ERR_REQUIRED:Number(m)>=0||"Price must be 0 or more",ae=(m,_)=>m===null||_===null||m===""||_===""?!0:Number(_)>=Number(m)||e.ERR_PRICE_VALIDATION,ue=()=>{n.value.push({id:null,person_type_id:null,list_price:null,final_price:null,notes:""})},se=()=>{s.value?.resetValidation()},ee=async()=>{const{valid:m}=await s.value.validate();if(!m)return;const _=n.value.filter(y=>y.person_type_id&&y.final_price!==null);_.length!==0&&(t.isEdit?await oe(_):ne(_))},ne=m=>{const _=[...t.modelValue];m.forEach(y=>{const L={id:null,personTypeId:y.person_type_id,listPrice:y.list_price,finalPrice
1:y.final_price,notes:y.notes,type:"fee"},U=_.findIndex(x=>x.personTypeId===y.person_type_id);U!==-1?_[U]=L:_.push(L)}),Z(_)},oe=async m=>{b.value=!0;try{const _=await Promise.all(m.map(async L=>{const U={person_type_id:L.person_type_id,list_price:L.list_price,final_price:L.final_price,notes:L.notes},x=L.id?await K.updateAtomicPrice(L.id,U,"fee"):await K.createBulkPrices($.params.id,[U],"fee");return{...U,id:Be(x)}})),y=[...t.modelValue];_.forEach(L=>{const U={id:L.id,personTypeId:L.person_type_id,listPrice:L.list_price,finalPrice:L.final_price,notes:L.notes,type:"fee"},x=y.findIndex(Y=>Y.id===L.id);x!==-1?y[x]=U:y.push(U)}),Z(y,"Fees updated successfully.")}catch(_){v(Ue(_))}finally{b.value=!1}},Z=(m,_)=>{P("update:modelValue",m),_&&g(_),n.value=[{id:null,person_type_id:null,list_price:null,final_price:null,notes:""}],se(),Ee(r.value)},S=async m=>{const _=t.modelValue[m];if(t.isEdit&&_.id)try{await K.deleteAtomicPrice(_.id,"fee"),g("Fee deleted successfully.")}catch(L){v(L.message);return}const y=[...t.modelValue];y.splice(m,1),P("update:modelValue",y)},R=async m=>{const _=n.value[m];if(t.isEdit&&_.id)try{await K.deleteAtomicPrice(_.id,"fee"),g("Fee deleted successfully.")}catch(y){v(y.message);return}n.value.splice(m,1)},V=m=>{const _=t.modelValue[m];if(!_)return;n.value=[{id:_.id||null,person_type_id:_.personTypeId,list_price:_.listPrice,final_price:_.finalPrice,notes:_.notes}];const y=[...t.modelValue];y.splice(m,1),P("update:modelValue",y),Ee(i.value)};return p({editFee:V,rootEl:i,resetManagerValidation:se}),(m,_)=>{const y=de,L=Re,U=Pe,x=Ge;return I(),k("div",{ref_key:"rootEl",ref:i,class:"mb-6"},[C("h3",Tt,A(e.TITLE),1),l(y,null,{default:c(()=>[W(A(e.HELP_INFO),1)]),_:1}),C("div",Pt,[l(Ce,{ref_key:"managerForm",ref:s,onSubmit:_[0]||(_[0]=ge(()=>{},["prevent"]))},{default:c(()=>[(I(!0),k(fe,null,Se(n.value,(Y,ie)=>(I(),k("div",{key:ie,class:"mb-4"},[l(re,{dense:"",align:"center"},{default:c(()=>[l(q,{cols:"12",md:"3"},{default:c(()=>[l(L,{modelValue:Y.person_type_id,"onUpdate:modelValue":j=>Y.person_type_id=j,items:X.value,"item-title":"title","item-value":"value",label:e.LABEL_PERSON,labelAbove:"",placeholder:e.LABEL_PERSON,rules:[j=>B(j,ie)],required:"","required-message":e.ERR_REQUIRED},null,8,["modelValue","onUpdate:modelValue","items","label","placeholder","rules","required-message"])]),_:2},1024),l(q,{cols:"6",md:"2",class:"price-column"},{default:c(()=>[l(U,{modelValue:Y.list_price,"onUpdate:modelValue":j=>Y.list_price=j,modelModifiers:{number:!0},type:"number",label:e.LABEL_LIST_PRICE,labelAbove:"","append-inner-icon":"mdi-currency-eur",required:!1,rules:[Q]},null,8,["modelValue","onUpdate:modelValue","label","rules"])]),_:2},1024),l(q,{cols:"6",md:"2",class:"price-column"},{default:c(()=>[l(U,{modelValue:Y.final_price,"onUpdate:modelValue":j=>Y.final_price=j,modelModifiers:{number:!0},type:"number",label:e.LABEL_FINAL_PRICE,labelAbove:"","append-inner-icon":"mdi-currency-eur",required:!1,rules:[Q,()=>ae(Y.list_price,Y.final_price)]},null,8,["modelValue","onUpdate:modelValue","label","rules"])]),_:2},1024),l(q,{cols:"12",md:"4"},{default:c(()=>[l(x,{modelValue:Y.notes,"onUpdate:modelValue":j=>Y.notes=j,label:e.LABEL_NOTES,labelAbove:"",placeholder:e.PH_NOTES,rows:"1","max-characters":f(ve).URL},null,8,["modelValue","onUpdate:modelValue","label","placeholder","max-characters"])]),_:2},1024),l(q,{cols:"12",md:"1",class:"d-flex align-center pt-4"},{default:c(()=>[n.value.length>1?(I(),z(te,{key:0,icon:"mdi-delete",size:"small",variant:"text",color:"error",onClick:j=>R(ie)},null,8,["onClick"])):G("",!0)]),_:2},1024)]),_:2},1024),ie<n.value.length-1?(I(),z(me,{key:0,class:"my-3 border-dashed"})):G("",!0)]))),128))]),_:1},512),l(te,{"prepend-icon":"mdi-plus",variant:"text",size:"small",color:"primary",class:"text-none font-weight-bold",onClick:ue},{default:c(()=>[W(A(e.BTN_ADD_ROW),1)]),_:1}),C("div",Rt,[l(te,{color:"primary",class:"text-capitalize",loading:b.value,onClick:ee},{default:c(()=>[W(A(le.value),1)]),_:1},8,["loading"])])]),C("div",{ref_key:"summaryTable",ref:r,class:"mt-6"},[h.modelValue.length>
10?(I(),k("h3",vt,A(e.HEADER_SUMMARY),1)):G("",!0),h.modelValue.length>0?(I(),k("div",bt,[l(Ye,{items:h.modelValue,"person-types":h.personTypes,"is-edit-mode":h.isEdit,"is-in-master":!1,onEdit:V,onDelete:S},null,8,["items","person-types","is-edit-mode"])])):G("",!0)],512)],512)}}}),Ct=Qe(gt,[["__scopeId","data-v-2c043de5"]]),Ot={key:0},ze=ce({__name:"ProductHotelsTable",props:{items:{},hotelsDropdown:{},roomTypes:{},isInMaster:{type:Boolean}},emits:["edit","delete"],setup(h,{emit:p}){const O=p,P=h,t={COL_HOTEL:"Hotel",COL_ROOM:"Room Type",COL_PRICE:"Price / Night",COL_NOTES:"Notes",COL_ACTIONS:"Actions",HELP_INFO:"Here you can see all the created prices for each hotel. You can edit or delete any of them by clicking on the respective action button."},g=[{title:t.COL_HOTEL,key:"hotelName"},{title:t.COL_ROOM,key:"roomName"},{title:t.COL_PRICE,key:"priceDisp"},{title:t.COL_NOTES,key:"notes"},{key:"actions",title:t.COL_ACTIONS,type:"action",actions:["Edit","Delete"],align:"end"}],v=J(()=>P.items.map((e,i)=>({...e,index:i,hotelName:e.hotelName||P.hotelsDropdown.find(r=>r.value===e.hotelId)?.title||"-",roomName:e.roomTypeName||P.roomTypes.find(r=>r.value===e.hotelRoomTypeId)?.title||"-",priceDisp:`${e.finalPrice}€`}))),$=({actionName:e,item:i})=>{e==="Edit"?O("edit",i.index):e==="Delete"&&O("delete",i.index)};return(e,i)=>{const r=de,b=He;return I(),k(fe,null,[h.isInMaster?G("",!0):(I(),z(r,{key:0},{default:c(()=>[W(A(t.HELP_INFO),1)]),_:1})),l(b,{headers:g,items:v.value,onClickAction:$},{"item.notes":c(({item:s})=>[!s.notes||s.notes.length<=20?(I(),k("span",Ot,A(s.notes||"-"),1)):(I(),z(Ie,{key:1,location:"bottom"},{activator:c(({props:n})=>[C("span",Ae(n,{class:"cursor-help"}),A(s.notes.substring(0,20))+"... ",17)]),default:c(()=>[W(" "+A(s.notes),1)]),_:2},1024))]),_:1},8,["items"])],64)}}}),Vt={class:"text-subtitle-1 font-weight-bold mb-2 text-primary"},Nt={class:"bg-grey-lighten-4 pa-4 rounded-lg"},Dt={class:"mt-4"},Mt={key:0,class:"text-subtitle-1 font-weight-bold ml-2 my-2"},St={key:1,class:"mt-4"},Ht=ce({__name:"ProductHotelsManager",props:{modelValue:{},hotels:{},roomTypes:{},isLoadingHotels:{type:Boolean},isEdit:{type:Boolean}},emits:["update:modelValue"],setup(h,{expose:p,emit:O}){const P=O,t=h,g=be(),{showSuccessToast:v,showErrorToast:$}=ye(),e={TITLE:"Hotel Prices",LABEL_HOTEL:"Hotel",LABEL_ROOM:"Room Type",LABEL_PRICE:"Price per night",LABEL_NOTES:"Notes",BTN_ADD_ROW:"Add another room type",BTN_ADD_TO_LIST:"Add Hotel Prices",HEADER_SUMMARY:"Summary of Hotel Prices",HELP_INFO:"Here you can create and add prices for each hotel. Note: Only 3 unique prices per hotel (one per room type) are allowed in total.",ERR_REQUIRED:"This field is required",SAVE_CHANGES:"Save Changes"},i=D(null),r=D(null),b=D(!1),s=D(null),n=D([{id:null,hotel_id:null,hotel_room_type_id:null,final_price:null,notes:""}]),le=J(()=>t.isEdit?e.SAVE_CHANGES:e.BTN_ADD_TO_LIST);_e(()=>t.modelValue,async()=>{await pe(),s.value&&s.value.resetValidation()},{deep:!0});const X=()=>{s.value?.resetValidation()},B=(S,R,V)=>{if(!S)return e.ERR_REQUIRED;if(!R)return!0;const m=t.modelValue.some(y=>y.hotelId===R&&y.hotelRoomTypeId===S),_=n.value.some((y,L)=>L!==V&&y.hotel_id===R&&y.hotel_room_type_id===S);return m||_?"This room type is already priced for the selected hotel.":!0},Q=()=>{n.value.push({id:null,hotel_id:null,hotel_room_type_id:null,final_price:null,notes:""})},ae=async()=>{const{valid:S}=await s.value.validate();if(!S)return;const R=n.value.filter(V=>V.hotel_id&&V.hotel_room_type_id&&V.final_price!==null);R.length!==0&&(t.isEdit?await se(R):ue(R))},ue=S=>{const R=[...t.modelValue];S.forEach(V=>{const m={id:null,type:"hotel",hotelId:V.hotel_id,hotelRoomTypeId:V.hotel_room_type_id,finalPrice:V.final_price,notes:V.notes},_=R.findIndex(y=>y.hotelId===V.hotel_id&&y.hotelRoomTypeId===V.hotel_room_type_id);_!==-1?R[_]=m:R.push(m)}),ee(R)},se=async S=>{b.value=!0;try{const R=await Promise.all(S.map(async m=>{const _={hotel_id:m.hotel_id,hotel_room_type_id:m.hotel_room_type_id,price:m.final_price,notes:m.notes},y=m.id?await K.updateAtomicPrice(m.id,_,"hotel"):await K.createBulkPrices(g.params.id,[_],"hotel");return{..._,id:Be(y)}})),V=[...t.modelValue];R.forEach(m=>{const _={id:m.id,type:"hotel",hotelId:m.hotel_id,hotelRoomTypeId:m.hotel_room_type_id,finalPrice
1:m.price,notes:m.notes},y=V.findIndex(L=>L.id===m.id);y!==-1?V[y]=_:V.push(_)}),ee(V,"Hotel price updated successfully.")}catch(R){$(Ue(R))}finally{b.value=!1}},ee=(S,R)=>{P("update:modelValue",S),R&&v(R),n.value=[{id:null,hotel_id:null,hotel_room_type_id:null,final_price:null,notes:""}],X(),Ee(r.value)},ne=async S=>{const R=t.modelValue[S];if(t.isEdit&&R.id)try{await K.deleteAtomicPrice(R.id,"hotel"),v("Hotel price deleted successfully.")}catch(m){$(m.message);return}const V=[...t.modelValue];V.splice(S,1),P("update:modelValue",V)},oe=async S=>{const R=n.value[S];if(t.isEdit&&R.id)try{await K.deleteAtomicPrice(R.id,"hotel"),v("Hotel price deleted successfully.")}catch(V){$(V.message);return}n.value.splice(S,1)},Z=S=>{const R=t.modelValue[S];if(!R)return;n.value=[{id:R.id||null,hotel_id:R.hotelId,hotel_room_type_id:R.hotelRoomTypeId,final_price:R.finalPrice,notes:R.notes}];const V=[...t.modelValue];V.splice(S,1),P("update:modelValue",V),Ee(i.value)};return p({editHotel:Z,rootEl:i,resetManagerValidation:X}),(S,R)=>{const V=de,m=Re,_=Pe,y=Ge;return I(),k("div",{ref_key:"rootEl",ref:i,class:"mb-6"},[C("h3",Vt,A(e.TITLE),1),l(V,null,{default:c(()=>[W(A(e.HELP_INFO),1)]),_:1}),C("div",Nt,[l(Ce,{ref_key:"managerForm",ref:s,onSubmit:R[0]||(R[0]=ge(()=>{},["prevent"]))},{default:c(()=>[(I(!0),k(fe,null,Se(n.value,(L,U)=>(I(),k("div",{key:U,class:"mb-4"},[l(re,{dense:""},{default:c(()=>[l(q,{cols:"12",md:"6"},{default:c(()=>[l(m,{modelValue:L.hotel_id,"onUpdate:modelValue":x=>L.hotel_id=x,items:h.hotels,"item-title":"title","item-value":"value",label:e.LABEL_HOTEL,labelAbove:"",loading:h.isLoadingHotels,placeholder:e.LABEL_HOTEL,required:"","required-message":e.ERR_REQUIRED},null,8,["modelValue","onUpdate:modelValue","items","label","loading","placeholder","required-message"])]),_:2},1024),l(q,{cols:"12",md:"6"},{default:c(()=>[l(m,{modelValue:L.hotel_room_type_id,"onUpdate:modelValue":x=>L.hotel_room_type_id=x,items:h.roomTypes,"item-title":"title","item-value":"value",label:e.LABEL_ROOM,labelAbove:"",placeholder:e.LABEL_ROOM,required:"","required-message":e.ERR_REQUIRED,rules:[x=>B(x,L.hotel_id,U)]},null,8,["modelValue","onUpdate:modelValue","items","label","placeholder","required-message","rules"])]),_:2},1024)]),_:2},1024),l(re,{dense:"",class:"mt-2 align-center"},{default:c(()=>[l(q,{cols:"12",md:"5"},{default:c(()=>[l(_,{modelValue:L.final_price,"onUpdate:modelValue":x=>L.final_price=x,modelModifiers:{number:!0},type:"number",label:e.LABEL_PRICE,labelAbove:"","append-inner-icon":"mdi-currency-eur",required:"","required-message":e.ERR_REQUIRED},null,8,["modelValue","onUpdate:modelValue","label","required-message"])]),_:2},1024),l(q,{cols:"12",md:"6"},{default:c(()=>[l(y,{modelValue:L.notes,"onUpdate:modelValue":x=>L.notes=x,label:e.LABEL_NOTES,labelAbove:"",rows:"1","max-characters":f(ve).URL},null,8,["modelValue","onUpdate:modelValue","label","max-characters"])]),_:2},1024),l(q,{cols:"12",md:"1",class:"d-flex align-center pt-4"},{default:c(()=>[n.value.length>1?(I(),z(te,{key:0,icon:"mdi-delete",size:"small",variant:"text",color:"error",onClick:x=>oe(U)},null,8,["onClick"])):G("",!0)]),_:2},1024)]),_:2},1024),U<n.value.length-1?(I(),z(me,{key:0,class:"my-3 border-dashed"})):G("",!0)]))),128))]),_:1},512),l(te,{"prepend-icon":"mdi-plus",variant:"text",size:"small",color:"primary",class:"text-none font-weight-bold",onClick:Q},{default:c(()=>[W(A(e.BTN_ADD_ROW),1)]),_:1}),C("div",Dt,[l(te,{color:"primary",class:"text-capitalize",loading:b.value,onClick:ae},{default:c(()=>[W(A(le.value),1)]),_:1},8,["loading"])])]),C("div",{class:"mt-6",ref_key:"summaryTable",ref:r},[h.modelValue.length>0?(I(),k("h3",Mt,A(e.HEADER_SUMMARY),1)):G("",!0),h.modelValue.length>0?(I(),k("div",St,[l(ze,{items:h.modelValue,"hotels-dropdown":h.hotels,"room-types":h.roomTypes,"is-in-master":!1,onEdit:Z,onDelete:ne},null,8,["items","hotels-dropdown","room-types"])])):G("",!0)],512)],512)}}}),Bt={key:0},Ut={class:"pa-3"},Ke=ce({__name:"ProductMealsTable",props:{items:{},hotels:{},isInMaster:{type:Boolean}},emits:["edit","delete"],setup(h,{emit:p}){const O=p,P=h,t={COL_TYPE:"Meal Type",COL_HOTEL:"Hotel",COL_PRICE:"Price",COL_LUNCH_PRICE:"Lunch Price",COL_DESC:"Description",COL_ACTIONS:"Actions",HELP_INFO:"Here you can see all the created prices for each meal type. You can edit or delete any of them by clicking on the respective action button."},g={1:"Hotel Meal",2:"Meal Package",3:"Combination"},v=[{title:t.COL_TYPE,key:"mealTypeDisp"},{title:t.COL_HOTEL,key:"hotelName"},{title:t.COL_PRICE,key:"priceDisp"},{title:t.COL_LUNCH_PRICE,key:"lunchPriceDisp"},{title:t.COL_DESC,key:"notes"},{key:"actions",title:t.COL_ACTIONS,type:"action",actions:["Edit","Delete"],align:"end"}],$=J(()=>P.items.map((r,b)=>
1({...r,index:b,mealTypeDisp:g[r.mealId]||"-",hotelName:r.hotelName||(r.hotelId?P.hotels.find(s=>s.value===r.hotelId)?.title:"-")||"-",priceDisp:`${r.finalPrice}€`,lunchPriceDisp:r.lunchPrice!=null?`${r.lunchPrice}€`:"-"}))),e=({actionName:r,item:b})=>{r==="Edit"?O("edit",b.index):r==="Delete"&&O("delete",b.index)},i=r=>r.replace(/<[^>]*>/g,"").trim();return(r,b)=>{const s=de,n=He,le=$e("safe-html");return I(),k(fe,null,[h.isInMaster?G("",!0):(I(),z(s,{key:0},{default:c(()=>[W(A(t.HELP_INFO),1)]),_:1})),l(n,{headers:v,items:$.value,onClickAction:e},{"item.notes":c(({item:X})=>[!X.notes||i(X.notes).length<=20?(I(),k("span",Bt,A(i(X.notes)||"-"),1)):(I(),z(Ie,{key:1,location:"bottom"},{activator:c(({props:B})=>[C("span",Ae(B,{class:"cursor-help"}),A(i(X.notes).substring(0,20))+"... ",17)]),default:c(()=>[qe(C("p",Ut,null,512),[[le,X.notes]])]),_:2},1024))]),_:1},8,["items"])],64)}}}),wt={class:"text-subtitle-1 font-weight-bold mb-2 text-primary"},kt={class:"bg-grey-lighten-4 pa-4 rounded-lg"},xt={class:"text-body-2 text-medium-emphasis",role:"note","aria-live":"polite"},Ft={class:"mb-1",style:{"white-space":"pre-line"}},$t={class:"text-amber-darken-4 mb-0"},qt={class:"text-primary"},Gt={class:"text-primary d-flex justify-end"},Qt={class:"mt-4"},Yt={key:0,class:"text-subtitle-1 font-weight-bold ml-2 my-2"},zt={key:1,class:"mt-4"},Kt=ce({__name:"ProductMealsManager",props:{modelValue:{},hotels:{},isEdit:{type:Boolean}},emits:["update:modelValue"],setup(h,{expose:p,emit:O}){const P=O,t=h,g=be(),{showSuccessToast:v,showErrorToast:$}=ye(),e={HOTEL_MEAL:1,MEAL_PACKAGE:2,COMBINATION:3},i={TITLE:"Create meal",LABEL_HOTEL:"Hotel",LABEL_PRICE:"Price",LABEL_PRICE_PER_DAY:"Price / Per Day",LABEL_LUNCH_PRICE:"Lunch Price",LABEL_LUNCH_PRICE_PER_DAY:"Lunch Price / Per Day",LABEL_LUNCH_PRICE_NOTE:"Lunch cost to exclude from hotel meals for combination package",LABEL_DESC:"Description",PH_HOTEL:"Select Hotel",BTN_ADD_ROW:"Add another meal",BTN_ADD_TO_LIST:"Add Meal Prices",HEADER_SUMMARY:"Summary of Meal Prices",HELP_INFO:'Here you can create and add prices for each meal type.<ul style="list-style-type: disc; padding-left: 20px; margin-top: 8px;"><li>Hotel Meal: Fill in the hotel meal price per day and the lunch price per day.</li><li>Meal Package: Fill in the total meal price (not per day).</li><li>Combination: If chosen, the final price is calculated automatically based on the Hotel Meal and Meal Package prices and can be seen in the summary table below.</li></ul>',ERR_REQUIRED:"This field is required",ERR_LUNCH_PRICE_LESS_THAN_PRICE:"Lunch price must be less or equal than price",ERR_NEGATIVE_VALUE:"Price must be 0 or greater",SAVE_CHANGES:"Save Changes",ERR_MEAL_DUPLICATE:"This hotel already has a price for this meal type.",ERR_MEAL_FULL:"All available meal types for this hotel (Hotel meal & Combination) are already priced.",ERR_PACKAGE_EXISTS:"A price for the Meal Package has already been added.",ERR_COMBINATION_REQUIRES_HOTEL_MEAL:"Hotel meal price must be added before Combination.",ERR_COMBINATION_REQUIRES_MEAL_PACKAGE:"Meal Package price must be added before Combination.",DESC_WARNING:"When using styling, bullets or images, the available characters are reduced drastically.",AVAILABLE_CHARACTERS:"Available characters",COMBINATION_CLICK:"Click the 'Add Meal Prices' button to generate the Combination price.",COMBINATION_EXPLANATION:`    The Combination price is calculated as: (Hotel Meal Price - Lunch Price) + Meal Package.
2    For payment, it is calculated as: (Hotel Meal Price - Lunch Price) * Days Of Stay + Meal Package.
3  `},r=D(null),b=D(null),s=D(!1),n=D(null),le=J(()=>t.isEdit?i.SAVE_CHANGES:i.BTN_ADD_TO_LIST),X=()=>{n.value?.resetValidation()},B=()=>`meal_${Math.floor(Math.random()*1e8)}`,Q=D([{_uid:B(),id:null,mealId:e.HOTEL_MEAL,hotelId:null,finalPrice:null,lunchPrice:null,notes:""}]),ae=(o,a,E)=>{if(o===e.MEAL_PACKAGE)return t.modelValue.some(H=>H.mealId===e.MEAL_PACKAGE)||Q.value.some((H,w)=>w!==E&&H.mealId===e.MEAL_PACKAGE)?i.ERR_PACKAGE_EXISTS:!0;if(!a)return!0;if(o===e.COMBINATION){const u=R(a);if(!u.valid)return u.error||i.ERR_REQUIRED}const F=[...t.modelValue.filter(u=>u.hotelId===a),...Q.value.filter((u,H)=>H!==E&&u.hotelId===a)];if(F.some(u=>u.mealId===o))return i.ERR_MEAL_DUPLICATE;const T=F.some(u=>u.mealId===e.HOTEL_MEAL),d=F.some(u=>u.mealId===e.COMBINATION);return T&&d?i.ERR_MEAL_FULL:!0},ue=()=>{Q.value.push({id:null,mealId:e.HOTEL_MEAL,hotelId:y(),finalPrice
3:null,lunchPrice:null,notes:"",_uid:B()})},se=o=>{if(o==null||o==="")return i.ERR_REQUIRED;const a=Number(o);return isNaN(a)?i.ERR_REQUIRED:a<0?i.ERR_NEGATIVE_VALUE:!0},ee=async o=>{o.mealId===e.HOTEL_MEAL&&o.lunchPrice!==null&&o.lunchPrice!==void 0&&(await pe(),n.value?.validate())},ne=(o,a)=>{if(o==null||o==="")return i.ERR_REQUIRED;const E=Number(o);return isNaN(E)?i.ERR_REQUIRED:E<0?i.ERR_NEGATIVE_VALUE:a!=null&&E>a?i.ERR_LUNCH_PRICE_LESS_THAN_PRICE:!0},oe=o=>{if(!o)return null;const a=t.modelValue.find(E=>E.mealId===e.HOTEL_MEAL&&E.hotelId===o);return a?{price:a.finalPrice,lunchPrice:a.lunchPrice}:null},Z=()=>{const o=t.modelValue.find(a=>a.mealId===e.MEAL_PACKAGE);return o?{price:o.finalPrice}:null},S=o=>{const a=oe(o),E=Z();return!a||a.price===null||a.lunchPrice===null||!E||E.price===null?null:a.price-a.lunchPrice+E.price},R=o=>{const a=oe(o),E=Z();return!a||a.price===null||a.lunchPrice===null?{valid:!1,error:i.ERR_COMBINATION_REQUIRES_HOTEL_MEAL}:!E||E.price===null?{valid:!1,error:i.ERR_COMBINATION_REQUIRES_MEAL_PACKAGE}:{valid:!0}},V=o=>{o.finalPrice=null,o.lunchPrice=null,o.mealId===e.COMBINATION&&o.hotelId&&(o.finalPrice=S(o.hotelId))},m=o=>{o.mealId===e.COMBINATION&&o.hotelId&&(o.finalPrice=S(o.hotelId))},_=o=>o?o.replace(/<[^>]*>/g,"").replace(/&nbsp;/g,"").trim()===""?"":o:"",y=()=>t.hotels.length===1?t.hotels[0].value:null,L=o=>o===e.HOTEL_MEAL?i.LABEL_PRICE_PER_DAY:i.LABEL_PRICE,U=()=>i.LABEL_LUNCH_PRICE_PER_DAY;_e(()=>t.hotels,o=>{o.length===1&&Q.value.forEach(a=>{a.hotelId||(a.hotelId=o[0].value)})},{immediate:!0});const x=()=>{let o=!1;const a=t.modelValue.map(E=>{if(E.mealId===e.COMBINATION){const F=S(E.hotelId);if(F!==null&&F!==E.finalPrice)return o=!0,{...E,finalPrice:F}}return E});o&&P("update:modelValue",a)};_e(()=>t.modelValue,()=>{Q.value.forEach(o=>{o.mealId===e.COMBINATION&&o.hotelId&&(o.finalPrice=S(o.hotelId))}),x()},{deep:!0}),_e(()=>t.modelValue,async()=>{await pe(),n.value&&n.value.resetValidation()},{deep:!0});const Y=async()=>{const{valid:o}=await n.value.validate();if(!o)return;const a=Q.value.filter(E=>E.finalPrice!==null);a.length!==0&&(t.isEdit?await Oe(a):ie(a))},ie=o=>{const a=[...t.modelValue];o.forEach(E=>{const F={id:null,type:"meal",mealId:E.mealId,hotelId:E.mealId===e.MEAL_PACKAGE?null:E.hotelId,finalPrice:E.finalPrice,lunchPrice:E.mealId===e.HOTEL_MEAL?E.lunchPrice:null,notes:_(E.notes)},N=a.findIndex(T=>T.mealId===F.mealId&&T.hotelId===F.hotelId);N!==-1?a[N]=F:a.push(F)}),Le(a)},j=async o=>{const a=d=>{const u=d.find(H=>H.mealId===e.MEAL_PACKAGE);return u?{price:u.finalPrice}:null},E=(d,u)=>{if(!u)return null;const H=d.find(w=>w.mealId===e.HOTEL_MEAL&&w.hotelId===u);return H?{price:H.finalPrice,lunchPrice:H.lunchPrice}:null},F=o.filter(d=>d.mealId===e.COMBINATION&&d.id),N=a(o),T=F.map(async d=>{const u=E(o,d.hotelId);if(!u||u.price==null||u.lunchPrice==null||!N||N.price==null)return;const H=u.price-u.lunchPrice+N.price;H!==d.finalPrice&&(await K.updateAtomicPrice(d.id,{price:H},"meal"),d.finalPrice=H)});await Promise.all(T)},Oe=async o=>{s.value=!0;try{const a=await Promise.all(o.map(async N=>{const T=_(N.notes),d={meal_id:N.mealId,price:N.finalPrice,hotel_id:N.mealId===e.MEAL_PACKAGE?null:N.hotelId,notes:T};N.mealId===e.HOTEL_MEAL&&(d.lunch_price=N.lunchPrice);const u=N.id?await K.updateAtomicPrice(N.id,d,"meal"):await K.createBulkPrices(g.params.id,[d],"meal");return{...d,id:Be(u)}})),E=[...t.modelValue];a.forEach(N=>{const T={id:N.id,type:"meal",mealId:N.meal_id,hotelId:N.hotel_id,finalPrice:N.price,lunchPrice:N.lunch_price??null,notes:N.notes},d=E.findIndex(u=>u.id===N.id);d!==-1?E[d]=T:E.push(T)}),o.some(N=>N.mealId===e.HOTEL_MEAL||N.mealId===e.MEAL_PACKAGE)&&await j(E),Le(E,"Meal prices updated successfully.")}catch(a){$(Ue(a))}finally{s.value=!1}},Le=(o,a)=>{Q.value=[{_uid:B(),id:null,mealId:e.HOTEL_MEAL,hotelId:y(),finalPrice:null,lunchPrice:null,notes:""}],P("update:modelValue",o),a&&v(a),pe(()=>{n.value?.resetValidation()}),Ee(b.value)},Ve=o=>o?o.length:0,Ne=async o=>{const a=t.modelValue[o];if(t.isEdit&&a.id)try{await K.deleteAtomicPrice(a.id,"meal"),v("Meal price deleted")}catch(F){$(F.message);return}const E=[...t.modelValue];E.splice(o,1),P("update:modelValue",E)},De=async o=>{const a=Q.value[o];if(t.isEdit&&a.id)try{await K.deleteAtomicPrice(a.id,"meal"),v("Meal price deleted")}catch(E){$(E.message);return}Q.value.splice(o,1)},he=o=>{const a=t.modelValue[o];if(!a)return;Q.value=[{id:a.id||null,mealId:a.mealId,hotelId:a.hotelId,finalPrice
3:a.finalPrice,lunchPrice:a.mealId===e.HOTEL_MEAL?a.lunchPrice??null:null,notes:a.notes,_uid:B()}];const E=[...t.modelValue];E.splice(o,1),P("update:modelValue",E),Ee(r.value)};return p({editMeal:he,rootEl:r,resetManagerValidation:X}),(o,a)=>{const E=de,F=Re,N=Pe,T=Fe,d=$e("safe-html");return I(),k("div",{ref_key:"rootEl",ref:r,class:"mb-6"},[C("h3",wt,A(i.TITLE),1),l(E,null,{default:c(()=>[qe(C("span",null,null,512),[[d,i.HELP_INFO]])]),_:1}),C("div",kt,[l(Ce,{ref_key:"managerForm",ref:n,onSubmit:a[0]||(a[0]=ge(()=>{},["prevent"]))},{default:c(()=>[(I(!0),k(fe,null,Se(Q.value,(u,H)=>(I(),k("div",{key:H,class:"mb-4"},[l(mt,{modelValue:u.mealId,"onUpdate:modelValue":[w=>u.mealId=w,w=>V(u)],inline:"","hide-details":"auto",density:"compact",class:"mb-2",rules:[w=>ae(w,u.hotelId,H)]},{default:c(()=>[l(Me,{label:"Hotel meal",value:e.HOTEL_MEAL,class:"mr-5"},null,8,["value"]),l(Me,{label:"Meal Package",value:e.MEAL_PACKAGE,class:"mr-5"},null,8,["value"]),l(Me,{label:"Combination",value:e.COMBINATION},null,8,["value"])]),_:1},8,["modelValue","onUpdate:modelValue","rules"]),l(re,{dense:""},{default:c(()=>[u.mealId!==e.MEAL_PACKAGE?(I(),z(q,{key:0,cols:"12",md:"4"},{default:c(()=>[l(F,{modelValue:u.hotelId,"onUpdate:modelValue":[w=>u.hotelId=w,w=>m(u)],items:h.hotels,"item-title":"title","item-value":"value",label:i.LABEL_HOTEL,labelAbove:"",placeholder:i.PH_HOTEL,required:"","required-message":i.ERR_REQUIRED,rules:[w=>ae(u.mealId,w,H)]},null,8,["modelValue","onUpdate:modelValue","items","label","placeholder","required-message","rules"])]),_:2},1024)):G("",!0),u.mealId===e.COMBINATION?(I(),z(q,{key:1,cols:"12",md:"8",class:"d-flex align-center"},{default:c(()=>[C("div",xt,[C("p",Ft,A(i.COMBINATION_EXPLANATION),1),C("p",$t,A(i.COMBINATION_CLICK),1)])]),_:1})):(I(),z(q,{key:2,cols:"12",md:"4"},{default:c(()=>[l(N,{modelValue:u.finalPrice,"onUpdate:modelValue":[w=>u.finalPrice=w,w=>ee(u)],modelModifiers:{number:!0},type:"number",label:L(u.mealId),labelAbove:"","append-inner-icon":"mdi-currency-eur",required:"","required-message":i.ERR_REQUIRED,rules:[()=>se(u.finalPrice)],min:"0"},null,8,["modelValue","onUpdate:modelValue","label","required-message","rules"])]),_:2},1024)),u.mealId===e.HOTEL_MEAL?(I(),z(q,{key:3,cols:"12",md:"3",class:"d-flex align-center"},{default:c(()=>[l(N,{modelValue:u.lunchPrice,"onUpdate:modelValue":w=>u.lunchPrice=w,modelModifiers:{number:!0},type:"number",label:U(),labelAbove:"","append-inner-icon":"mdi-currency-eur",required:"","required-message":i.ERR_REQUIRED,rules:[()=>ne(u.lunchPrice,u.finalPrice)],min:"0"},null,8,["modelValue","onUpdate:modelValue","label","required-message","rules"]),l(Ie,{location:"top"},{activator:c(({props:w})=>[l(pt,Ae({ref_for:!0},w,{size:"18",class:"ml-2"}),{default:c(()=>[...a[1]||(a[1]=[W("mdi-information-outline",-1)])]),_:1},16)]),default:c(()=>[C("span",null,A(i.LABEL_LUNCH_PRICE_NOTE),1)]),_:1})]),_:2},1024)):G("",!0)]),_:2},1024),l(re,{dense:"",class:"mt-2 align-center"},{default:c(()=>[l(q,{cols:"12",md:"11"},{default:c(()=>[C("p",qt,A(i.DESC_WARNING),1),l(T,{modelValue:u.notes,"onUpdate:modelValue":w=>u.notes=w,"initial-html":u.notes,placeholder:i.LABEL_DESC,height:300,"show-char-count":!1,"toolbar-id":"toolbar-"+u._uid,class:"mb-4"},null,8,["modelValue","onUpdate:modelValue","initial-html","placeholder","toolbar-id"]),C("p",Gt,A(i.AVAILABLE_CHARACTERS)+": "+A(Ve(u.notes))+" / "+A(f(ve).URL),1)]),_:2},1024),l(q,{cols:"12",md:"1",class:"d-flex align-center pt-4"},{default:c(()=>[Q.value.length>1?(I(),z(te,{key:0,icon:"mdi-delete",size:"small",variant:"text",color:"error",onClick:w=>De(H)},null,8,["onClick"])):G("",!0)]),_:2},1024)]),_:2},1024),H<Q.value.length-1?(I(),z(me,{key:0,class:"my-3 border-dashed"})):G("",!0)]))),128))]),_:1},512),l(te,{"prepend-icon":"mdi-plus",variant:"text",size:"small",color:"primary",class:"text-none font-weight-bold",onClick:ue},{default:c(()=>[W(A(i.BTN_ADD_ROW),1)]),_:1}),C("div",Qt,[l(te,{color:"primary",class:"text-capitalize",loading:s.value,onClick:Y},{default:c(()=>[W(A(le.value),1)]),_:1},8,["loading"])])]),C("div",{ref_key:"summaryTable",ref:b,class:"mt-6"},[h.modelValue.length>
30?(I(),k("h3",Yt,A(i.HEADER_SUMMARY),1)):G("",!0),h.modelValue.length>0?(I(),k("div",zt,[l(Ke,{items:h.modelValue,hotels:h.hotels,"is-in-master":!1,onEdit:he,onDelete:Ne},null,8,["items","hotels"])])):G("",!0)],512)],512)}}}),Wt={class:"mt-8"},Xt={class:"text-h5 font-weight-bold mb-4"},jt={key:0,class:"mb-6"},Jt={class:"text-subtitle-2 text-primary mb-2"},Zt={key:1,class:"mb-6"},el={class:"text-subtitle-2 text-primary mb-2"},tl={key:2,class:"mb-6"},ll={class:"text-subtitle-2 text-primary mb-2"},ol=ce({__name:"ProductMasterTable",props:{fees:{},hotels:{},meals:{},personTypes:{},hotelsDropdown:{},roomTypes:{},isEditMode:{type:Boolean}},emits:["delete-fee","delete-hotel","delete-meal","edit-fee","edit-hotel","edit-meal"],setup(h,{emit:p}){const O={TITLE:"Master Price List",FEES_TITLE:"Registration Fees",HOTELS_TITLE:"Hotel Prices",MEALS_TITLE:"Meal Prices",HELP_INFO:"Here you can see all the created prices(registration fees, hotel prices and meal prices). You can edit or delete any of them by clicking on the respective action button."};return(P,t)=>{const g=de;return I(),k("div",Wt,[C("h2",Xt,A(O.TITLE),1),l(g,null,{default:c(()=>[W(A(O.HELP_INFO),1)]),_:1}),h.fees.length?(I(),k("div",jt,[C("h3",Jt,A(O.FEES_TITLE),1),l(Ye,{items:h.fees,"person-types":h.personTypes,"is-in-master":!0,"is-edit-mode":h.isEditMode,onEdit:t[0]||(t[0]=v=>P.$emit("edit-fee",v)),onDelete:t[1]||(t[1]=v=>P.$emit("delete-fee",v))},null,8,["items","person-types","is-edit-mode"])])):G("",!0),h.hotels.length?(I(),k("div",Zt,[C("h3",el,A(O.HOTELS_TITLE),1),l(ze,{items:h.hotels,"hotels-dropdown":h.hotelsDropdown,"room-types":h.roomTypes,"is-in-master":!0,onEdit:t[2]||(t[2]=v=>P.$emit("edit-hotel",v)),onDelete:t[3]||(t[3]=v=>P.$emit("delete-hotel",v))},null,8,["items","hotels-dropdown","room-types"])])):G("",!0),h.meals.length?(I(),k("div",tl,[C("h3",ll,A(O.MEALS_TITLE),1),l(Ke,{items:h.meals,hotels:h.hotelsDropdown,"is-in-master":!0,onEdit:t[4]||(t[4]=v=>P.$emit("edit-meal",v)),onDelete:t[5]||(t[5]=v=>P.$emit("delete-meal",v))},null,8,["items","hotels"])])):G("",!0)])}}}),al={key:0,class:"d-flex flex-column align-center justify-center pa-12"},sl={class:"text-body-2 text-grey-darken-1 mb-6"},nl={class:"text-grey-darken-1 text-body-2 font-weight-bold"},il={class:"text-primary text-body-2"},rl={class:"text-primary d-flex justify-end text-caption"},dl={class:"mt-8"},cl={class:"mb-4"},ul=ce({__name:"[id]",setup(h){const p={PAGE_TITLE_CREATE:"Create Product",PAGE_TITLE_EDIT:"Edit Product",CREATE_SUBHEADER:"Create a new product for users to purchase",EDIT_SUBHEADER:"Edit an existing product",LABEL_NAME:"Product Name",LABEL_DESCRIPTION:"Description",LABEL_CONFERENCE:"Conference",LABEL_FEES_INCREASE:"Fees Increase After",LABEL_RESTRICTED:"Visible Only to this user (Optional)",BTN_CREATE:"Create Product",BTN_UPDATE:"Update Product",SUCCESS_CREATE:"Product created successfully.",SUCCESS_UPDATE:"Product updated successfully.",ERROR_CREATE:"Unable to create product. Make sure that all person types have a register fee price",ERROR_UPDATE:"Unable to update product. Make sure that all person types have a register fee price",ERR_REQUIRED:"This field is required",CONFIRM_UPDATE_TITLE:"Confirm Product Update",CONFIRM_UPDATE_MESSAGE:"Updating this product will affect users who currently have this product in their cart.",CONFIRM_UPDATE_QUESTION:"Are you sure you want to proceed with these changes?",BUTTON_TOOLTIP:"You need to add fees for all person types before you can submit",DESC_WARNING:"When using styling, bullets or images, the available characters are reduced drastically.",AVAILABLE_CHARACTERS:"Available characters",DESCRIPTION_PLACEHOLDER:"Enter a description for this product",EDIT_MODE_INFO:"This product is currently in edit mode. Changes are saved individually per section. The main update button applies only to the core product details, including the name and description"},O=be(),P=rt(),t=O.params.id,{showSuccessToast:g,showErrorToast:v}=ye(),{loading:$,userDropdownItems:e}=nt(P),{form:i,formData:r,fees:b,hotelPrices:s,mealPrices:n,isSubmitting:le,isLoadingProduct:X,isEdit:B,loadProduct:Q,saveProduct:ae,updateProduct:ue}=yt(t),{conferences:se,hotels:ee,personTypes:ne,roomTypes:oe,isLoadingHotels:Z,loadStaticDropdowns:S,fetchHotelsForConference:R}=It(),V=ke.lengthRange("Name",2,100);ke.maxLength("Description",1e3);const m=D(null),_=D(null),y=D(null),L=D(!0),U=J(()=>L.value||X.value),x=J(()=>B?p.EDIT_SUBHEADER:p.CREATE_SUBHEADER),Y=D(!1),ie=J(()=>B?p.BTN_UPDATE:p.BTN_CREATE),j=J(()=>[b.value,s.value,n.value].some(T=>T.length>0)),Oe=J(()=>X.value||b.value.length<3);it(async()=>{L.value=!0;try{const T=[S()];if(O.query.conferenceId&&(r.conference_id=Number(O.query.conferenceId)),B){await Q();const d=r.user?.name;r.user_id&&d&&!d.includes("undefined")&&!d.includes("null")&&P.searchUsers(d)}else T.push(P.fetchUsers());r.conference_id&&T.push(R(r.conference_id)),await Promise.all(T)}finally{L.value=!1}}),_e(()=>r.conference_id,T=>{T&&!L.value&&(R(T),B||(s.value=[],n.value=[]))});const Le=T=>T?T.length:0,Ve=async()=>(await i.value.validate()).valid?j.value?!0:(v("Please add at least one price (Fee, Hotel, or Meal)."),!1):(v("Unable to save the product. Please check the form for potential errors"),await pe(),ut(),!1),Ne=async()=>
3{if(await Ve()){if(B){Y.value=!0;return}await he()}},De=async()=>{Y.value=!1,await he()},he=async()=>{r.user_id||(r.user_id=null),m.value?.resetManagerValidation(),_.value?.resetManagerValidation(),y.value?.resetManagerValidation();try{(B?await ue():await ae())&&g(B?p.SUCCESS_UPDATE:p.SUCCESS_CREATE)}catch(T){const d=typeof T=="string"?T:B?p.ERROR_UPDATE:p.ERROR_CREATE;v(d)}},o=T=>P.searchUsers(T),a={fee:{ref:m,editMethod:"editFee"},hotel:{ref:_,editMethod:"editHotel"},meal:{ref:y,editMethod:"editMeal"}},E=(T,d)=>{const u=a[T],H=u.ref.value;H&&u.editMethod in H&&(H[u.editMethod](d),pe(()=>{H.$el?.scrollIntoView({behavior:"smooth",block:"center"})}))},F=async(T,d)=>{const u=T[d];if(B&&u?.id)try{await K.deleteAtomicPrice(u.id,u.type),g("Price removed successfully.")}catch(H){v(H.message||"Failed to delete price");return}T.splice(d,1)},N=T=>T===t?r.name||(B?p.PAGE_TITLE_EDIT:p.PAGE_TITLE_CREATE):null;return(T,d)=>{const u=Ze,H=et,w=de,We=Pe,Xe=Fe,we=Re,je=tt,Je=lt;return I(),z(_t,{fluid:"",class:"content-width pa-6"},{default:c(()=>[l(re,{class:"mb-4"},{default:c(()=>[l(q,{cols:"12"},{default:c(()=>[l(u,{resolver:N}),l(H,{title:f(B)?p.PAGE_TITLE_EDIT:p.PAGE_TITLE_CREATE},null,8,["title"])]),_:1})]),_:1}),l(Et,{flat:"",class:"rounded-lg border bg-white","min-height":f(U)?"400px":"auto"},{default:c(()=>[f(U)?(I(),k("div",al,[l(ht,{indeterminate:"",color:"primary",size:"64",width:"6"}),d[15]||(d[15]=C("div",{class:"mt-4 text-grey"},"Loading data...",-1))])):(I(),z(ft,{key:1,class:"pa-6"},{default:c(()=>[C("div",sl,A(f(x)),1),f(B)?(I(),z(w,{key:0},{default:c(()=>[W(A(p.EDIT_MODE_INFO),1)]),_:1})):G("",!0),l(Ce,{ref_key:"form",ref:i,onSubmit:ge(Ne,["prevent"])},{default:c(()=>[l(re,null,{default:c(()=>[l(q,{cols:"12"},{default:c(()=>[l(We,{modelValue:f(r).name,"onUpdate:modelValue":d[0]||(d[0]=M=>f(r).name=M),label:p.LABEL_NAME,labelAbove:"",required:"",rules:f(V),"required-message":p.ERR_REQUIRED},null,8,["modelValue","label","rules","required-message"])]),_:1}),l(q,{cols:"12"},{default:c(()=>[C("p",nl,A(p.LABEL_DESCRIPTION),1),C("p",il,A(p.DESC_WARNING),1),l(Xe,{modelValue:f(r).description,"onUpdate:modelValue":d[1]||(d[1]=M=>f(r).description=M),"initial-html":f(r).description,placeholder:p.DESCRIPTION_PLACEHOLDER,height:300,"show-char-count":!1,"toolbar-id":"product-description-toolbar",class:"mb-4"},null,8,["modelValue","initial-html","placeholder"]),C("p",rl,A(p.AVAILABLE_CHARACTERS)+": "+A(Le(f(r).description))+" / "+A(("VALIDATION_LIMITS"in T?T.VALIDATION_LIMITS:f(ve)).URL),1)]),_:1}),l(q,{cols:"12"},{default:c(()=>[l(we,{modelValue:f(r).conference_id,"onUpdate:modelValue":d[2]||(d[2]=M=>f(r).conference_id=M),items:f(se),"item-title":"title","item-value":"value",label:p.LABEL_CONFERENCE,labelAbove:"",required:"","required-message":p.ERR_REQUIRED,placeholder:p.LABEL_CONFERENCE,loading:f(Z),disabled:f(B)},null,8,["modelValue","items","label","required-message","placeholder","loading","disabled"])]),_:1})]),_:1}),l(re,{class:"mt-2"},{default:c(()=>[l(q,{cols:"12",md:"6"},{default:c(()=>[l(je,{modelValue:f(r).fees_increase_after,"onUpdate:modelValue":d[3]||(d[3]=M=>f(r).fees_increase_after=M),label:p.LABEL_FEES_INCREASE,labelAbove:"",required:"","required-message":p.ERR_REQUIRED},null,8,["modelValue","label","required-message"])]),_:1}),l(q,{cols:"12",md:"6"},{default:c(()=>[l(we,{modelValue:f(r).user_id,"onUpdate:modelValue":d[4]||(d[4]=M=>f(r).user_id=M),label:p.LABEL_RESTRICTED,labelAbove:"",placeholder:p.LABEL_RESTRICTED,items:f(e),"item-title":"text","item-value":"value",clearable:"",loading:f($),"onUpdate:search":o},null,8,["modelValue","label","placeholder","items","loading"])]),_:1})]),_:1}),l(me,{class:"my-6"}),l(Ct,{ref_key:"feesRef",ref:m,modelValue:f(b),"onUpdate:modelValue":d[5]||(d[5]=M=>Te(b)?b.value=M:null),"person-types":f(ne),"is-edit":f(B)},null,8,["modelValue","person-types","is-edit"]),l(me,{class:"my-6"}),l(Ht,{ref_key:"hotelsRef",ref:_,modelValue:f(s),"onUpdate:modelValue":d[6]||(d[6]=M=>Te(s)?s.value=M:null),hotels:f(ee),"room-types":f(oe),"is-loading-hotels":f(Z),"is-edit":f(B)},null,8,["modelValue","hotels","room-types","is-loading-hotels","is-edit"]),l(me,{class:"my-6"}),l(Kt,{ref_key:"mealsRef",ref:y,modelValue:f(n),"onUpdate:modelValue":d[7]||(d[7]=M=>Te(n)?n.value=M:null),hotels:f(ee),"is-edit":f(B)},null,8,["modelValue","hotels","is-edit"]),l(me,{class:"my-6"}),l(ol,{fees:f(b),hotels:f(s),meals:f(n),"person-types":f(ne),"hotels-dropdown":f(ee),"room-types":f(oe),"is-edit-mode":f(B),onDeleteFee:d[8]||(d[8]=M=>F(f(b),M)),onDeleteHotel:d[9]||(d[9]=M=>F(f(s),M)),onDeleteMeal:d[10]||(d[10]=M=>
3F(f(n),M)),onEditFee:d[11]||(d[11]=M=>E("fee",M)),onEditHotel:d[12]||(d[12]=M=>E("hotel",M)),onEditMeal:d[13]||(d[13]=M=>E("meal",M))},null,8,["fees","hotels","meals","person-types","hotels-dropdown","room-types","is-edit-mode"]),C("div",dl,[l(Ie,{text:p.BUTTON_TOOLTIP,location:"top",disabled:f(b).length>=4},{activator:c(({props:M})=>[C("span",Ae(M,{class:"d-inline-block"}),[l(te,{color:"primary",size:"large",type:"submit",class:"text-capitalize","prepend-icon":"mdi-cube-outline",loading:f(le),disabled:f(Oe)},{default:c(()=>[W(A(f(ie)),1)]),_:1},8,["loading","disabled"])],16)]),_:1},8,["text","disabled"])])]),_:1},512)]),_:1}))]),_:1},8,["min-height"]),l(Je,{modelValue:f(Y),"onUpdate:modelValue":d[14]||(d[14]=M=>Te(Y)?Y.value=M:null),type:"confirm",title:p.CONFIRM_UPDATE_TITLE,"confirm-text":"Update Product",onConfirm:De},{body:c(()=>[C("p",cl,A(p.CONFIRM_UPDATE_MESSAGE),1),C("p",null,A(p.CONFIRM_UPDATE_QUESTION),1)]),_:1},8,["modelValue","title"])]),_:1})}}}),Vo=Qe(ul,[["__scopeId","data-v-63ecd3c3"]]);export{Vo as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.