1(()=>{"use strict";const t=window.wp.url;window.MPHB=window.MPHB||{},window.MPHB.restApiHelper=new class{_activeRequests=new Map;_cachedData=new Map;async _request(e,s="GET",a={},r=!1){const i=JSON.stringify({endpointWithFirstSlash:e,params:a,method:s});if(this._activeRequests.has(i))return this._activeRequests.get(i);let o=window.MPHB._data?.restApiUrl??window.MPHBAdmin?.Plugin.myThis.data.restApiUrl??"";o+=e;const n={method:s,headers:{"X-WP-Nonce":window.MPHB._data?.restApiWpNonce??window.MPHBAdmin?.Plugin.myThis.data.restApiWpNonce??"","Content-Type":"application/json"}};"GET"===s?a&&Object.keys(a).length>0&&(o=(0,t.addQueryArgs)(o,a)):n.body=JSON.stringify(a);const u=(async()=>{try{const t=await fetch(o,n),e=await t.json();if(!t.ok){const s=new Error(e?.message||`REST API error: ${t.status} ${t.statusText}`);throw s.status=t.status,s.code=e?.code,s.data=e?.data,s}if(!r)return e;const s=t.headers.get("X-WP-Total"),a=t.headers.get("X-WP-TotalPages");return{data:e,total:Number(s),totalPages:Number(a)}}finally{this._activeRequests.delete(i)}})();return this._activeRequests.set(i,u),u}async _postMultipartFormData(t,e){let s=window.MPHB._data?.restApiUrl??window.MPHBAdmin?.Plugin.myThis.data.restApiUrl??"";s+=t;const a={method:"POST",body:e,headers:{"X-WP-Nonce":window.MPHB._data?.restApiWpNonce??window.MPHBAdmin?.Plugin.myThis.data.restApiWpNonce??""}},r=await fetch(s,a),i=await r.json();if(!r.ok){const t=i?.message||`REST API error: ${r.status} ${r.statusText}`,e=new Error(t);throw e.code=i?.code,e.data=i?.data,e.status=r.status,e}return i}_getCachedData(t){return this._cachedData.get(t)}_setCachedData(t,e){this._cachedData.set(t,e)}getFormattedDate(t){return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}getCachedAvailabilityData(t=[],e=!1,s=!1,a=!1){const r=JSON.stringify(["getAvailabilityData",t,e,s,a]);return this._getCachedData(r)??{}}async getAvailabilityData(t,e=()=>{},s=()=>{}){const a=window.MPHB._data?.isAdmin??window.MPHBAdmin?.Plugin.myThis.data.isAdmin??!1,r={start_date:new Date,end_date:new Date,room_type_ids:[],is_add_prices:!1,is_truncate_prices:!1,is_add_prices_currency:!1,is_request_for_admin_area:a,...t},i=JSON.stringify(["getAvailabilityData",r.room_type_ids,r.is_add_prices,r.is_truncate_prices,r.is_add_prices_currency]),o=this._getCachedData(i);let n=new Date(r.start_date.getTime()),u=new Date(r.end_date.getTime());if(o){let t=this.getFormattedDate(n),e=this.getFormattedDate(u);const s=r.room_type_ids[0]??0;if(void 0!==o[s][t]&&void 0!==o[s][e])return o;for(;n.getTime()<u.getTime()&&void 0!==o[s][t];)n.setDate(n.getDate()+1),t=this.getFormattedDate(n)}const{start_date:d,end_date:c,..._}=r;e();const h=await this._request("/availability","GET",{start_date:this.getFormattedDate(n),end_date:this.getFormattedDate(u),..._}),l={...o};for(const[t,e]of Object.entries(h)){l[t]||(l[t]={});for(const[s,a]of Object.entries(e))l[t][s]={...l[t][s]||{},...a}}return this._setCachedData(i,l),s(),l}async getAll(t,e){const s=await t(e),a=[...s.data];for(let r=2;r<=s.totalPages;r++){const s=await t({...e,page:r});a.push(...s.data)}return a}getAccommodationTypes(t){return this._request("/accommodation_types","GET",t,!0)}getAccommodations(t){return this._request("/accommodations","GET",t,!0)}getSeasons(t){return this._request("/seasons","GET",t,!0)}getRates(t){return this._request("/rates","GET",t,!0)}getBookings(t){return this._request("/bookings","GET",t,!0)}getRateCustomPrices(t,e,s){return this._request(`/rates/${t}/custom_prices`,"GET",{start_date:e,end_date:s})}updateRateCustomPrices(t,e,s,a){return this._request(`/rates/${t}/custom_prices`,"POST",{start_date:e,end_date:s,price:a})}deleteRateCustomPrice(t,e,s){return this._request(`/rates/${t}/custom_prices`,"DELETE",{start_date:e,end_date:s})}getBookingRules(){return this._request("/booking_rules")}getServices(t){return this._request("/accommodation_types/services","GET",t,!0)}getSettings(){return this._request("/settings")}getCustomBookingRules(t,e,s){return this._request("/booking_rules/custom","GET",{room_type_id:t,start_date:e,end_date:s})}updateCustomBookingRules(t,e,s,a,r){return this._request("/booking_rules/custom","POST",{room_type_id:t,start_date:e,end_date:s,[a]:r})}updateBookingRules(t){return this._request("/booking_rules","PATCH",t)}createSeason(t){return this._request("/seasons","POST",t)}updateSeason(t,e){return this._request(`/seasons/${t}`,"POST",e)}deleteSeason(t){return this._request(`/seasons/${t}`,"DELETE")}createRate(t){return this._request("/rates","POST",t)}updateRate(t,e){return this._request(`/rates/${t}`,"POST",e)}deleteRate(t){return this._request(`/rates/${t}`,"DELETE")}createBlock(t){return this._request("/booking_rules/blocks","POST",t)}deleteBlock(t){return this._request("/booking_rules/blocks/"+t,"DELETE")}deleteBlocks(t){return this._request("/booking_rules/blocks","DELETE",{block_ids:t},!0)}getBlock(t){return this._request("/booking_rules/blocks/"+t)}getBlocks(t){return this._request("/booking_rules/blocks","GET",t,!0)}updateBlock(t,e){return this._request("/booking_rules/blocks/"+t,"POST",e)}async getCountries(t="en_US"){const e=JSON.stringify(["getCountries",t]),s=this._getCachedData(e);if(s)return s;const a=await this._request("/countries","GET",{locale:t});return this._setCachedData(e,a),a}async getGoogleHotelsData(){return await this._request("/google-hotels-data")}async updateGoogleHotelsData(t){return await this._request("/google-hotels-data","POST",t)}async submitCheckout(t){return await this._postMultipartFormData("/checkout",t)}async submitAdminCheckout(t){return await this._postMultipartFormData("/checkout/admin",t)}async submitPayment(t){return await this._request("/checkout/payments","POST",t)}}})();
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.