/home/blackyak/www/wordpress/wp-content/plugins/wp-travel-engine/dist/chunks/708.js
(globalThis.webpackChunkwp_travel_engine=globalThis.webpackChunkwp_travel_engine||[]).push([[708],{420:()=>{window.wteL10n=window.wteL10n||{},window.wteL10n.api=window.wteapi=window.WTEApi=class{constructor(){}static async get(t,e={},i={}){let a={packages:this.getPackages,categories:this.getPackageCategories,trip:this.getTrip};return wteL10n.locale&&(e.lang=wteL10n.locale),this[t]||(this[t]="trip"==t?await a[t](e,i):lodash.keyBy(await a[t](e,i),"id")),this[t]}static async getTrip(t,e){const i=await fetch(`${wteL10n.wpapi.root+wteL10n.wpapi.versionString}trip/${t.id}?context=${t.context||"view"}`,e);return await i.json()}static async getPackageCategories(t){const e=await fetch(`${wteL10n.wpapi.root+wteL10n.wpapi.versionString}package-categories?per_page=100`);return await e.json()}static async getPackages(t,e){var i;const a=Object.entries(t).map((([t,e])=>`${t}=${e}`)).join("&"),n=await fetch(`${wteL10n.wpapi.root+wteL10n.wpapi.versionString}packages/${null!==(i=t.id)&&void 0!==i?i:`?${a}`}`,e);return await n.json()}static async addNewPackage(t){const e=await fetch(`${wteL10n.wpapi.root+wteL10n.wpapi.versionString}packages`,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":wteL10n.wpapi.nonce},body:JSON.stringify({title:"Untitled Package",status:"publish",post_type:"trip-packages",...t})});return await e.json()}static async removePackage(t){const e=await fetch(`${wteL10n.wpapi.root+wteL10n.wpapi.versionString}packages/${t.id}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":wteL10n.wpapi.nonce}});return await e.json()}}},1778:(t,e,i)=>{"use strict";function a(){}i.d(e,{A:()=>n}),a.hasClass=function(t,e){return t.classList?t.classList.contains(e):!!t.getAttribute("class").match(new RegExp("(\\s|^)"+e+"(\\s|$)"))},a.addClass=function(t,e){var i=e.split(" ");t.classList?t.classList.add(i[0]):a.hasClass(t,i[0])||t.setAttribute("class",t.getAttribute("class")+" "+i[0]),i.length>1&&a.addClass(t,i.slice(1).join(" "))},a.removeClass=function(t,e){var i=e.split(" ");if(t.classList)t.classList.remove(i[0]);else if(a.hasClass(t,i[0])){var n=new RegExp("(\\s|^)"+i[0]+"(\\s|$)");t.setAttribute("class",t.getAttribute("class").replace(n," "))}i.length>1&&a.removeClass(t,i.slice(1).join(" "))},a.toggleClass=function(t,e,i){i?a.addClass(t,e):a.removeClass(t,e)},a.setAttributes=function(t,e){for(var i in e)t?.setAttribute&&t.setAttribute(i,e[i])},a.getChildrenByClassName=function(t,e){t.children;for(var i=[],n=0;n<t.children.length;n++)a.hasClass(t.children[n],e)&&i.push(t.children[n]);return i},a.getIndexInArray=function(t,e){return Array.prototype.indexOf.call(t,e)},a.on=function(t,e,i){document.addEventListener(t,(function(t){for(var a=t.target;a&&a!=this;a=a.parentNode)if(a.matches(e)){i.call(a,t);break}}),!1)};const n=a},4708:(t,e,i)=>{"use strict";i.d(e,{wtePriceFormat:()=>v});var a={};i.r(a),i.d(a,{calculateGrandTotal:()=>l,numberFormat:()=>d,phpToMomentDF:()=>p,priceFormat:()=>m,wteGetFormatedPrice:()=>r,wteGetFormatedPriceWithCurrencyCode:()=>s,wteGetFormatedPriceWithCurrencyCodeSymbol:()=>o,wteGetFormatedPriceWithCurrencySymbol:()=>c});var n=i(1778);function r(t,e,i){return t=t||0,e=e||!0,i=i||0,"undefined"!=typeof WTE_CC_convData&&WTE_CC_convData.rate&&(t*=parseFloat(WTE_CC_convData.rate)),0==e?t:(t=(t=(t=parseFloat(t)).toFixed(i)).replace(".00",""),t=addCommas(t))}function s(t,e,i,a){return wteL10n.priceFormat(t).format(!0,!!i)}function o(t,e,i,a,n){return wteL10n.priceFormat(t).format(!1,!!a)}function c(t,e,i,a){return wteL10n.priceFormat(t).format(!1,!!i)}function l(){return parseFloat(window.wte.trip.travellersCost)+parseFloat(window.wte.trip.extraServicesCost)}function d(t,e=2,i=".",a=",",n=!0,r=!1){try{e=Math.abs(e),e=isNaN(e)?2:e;const s=t<0?"-":"";if(n){const e=Math.abs(Number(t)||0),{integerPart:n,decimalPart:r}=u(e.toString());let o="";if(r){const t=r.replace(/0+$/,"");t&&(o=i+t)}return s+w(n,a)+o}{let n=Math.abs(Number(t)||0);if(r)n=parseFloat(n.toFixed(e));else{const t=Math.pow(10,e);n=Math.floor(n*t)/t}const{integerPart:o,decimalPart:c}=u(n.toString()),l=w(o,a);let d=function(t,e,i){return e>0&&t?i+t.padEnd(e,"0").substr(0,e):e>0?i+"0".repeat(e):""}(c,e,i);return d&&(d=d.replace(/0+$/,""),d===i&&(d="")),s+l+d}}catch(t){console.log(t)}}function u(t){const e=t.split(".");return{integerPart:e[0],decimalPart:e[1]||""}}function w(t,e){const i=t,a=i.length>3?i.length%3:0;return(a?i.substr(0,a)+e:"")+i.substr(a).replace(/(\d{3})(?=\d)/g,"$1"+e)}function m(t,e,i,a="%CURRENCY_SYMBOL%%FORMATED_AMOUNT%",n=2,r=".",s=",",o=!1,c=!1){t<0&&(a.includes("%AMOUNT%")||a.includes("%FORMATED_AMOUNT%"))&&(t=Math.abs(t),a="-"+a);let l=!0;isNaN(n)||(l=!1),["BIF","CLP","DJF","GNF","JPY","KMF","KRW","MGA","PYG","RWF","VND","VUV","XAF","XOF","XPF"].includes(e)&&(n=0,l=!1,c=!0);let u={"%CURRENCY_CODE%":o?e:`<span class="wpte-currency-code currency">${e}</span>`,"%CURRENCY_SYMBOL%":o?i:`<span class="wpte-currency-code currency">${i}</span>`,"%AMOUNT%":o?t:`<strong class="wpte-price amount">${t}</strong>`,"%FORMATED_AMOUNT%":o?d(t,n,r,s,l,c):`<strong class="wpte-price amount">${d(t,n,r,s,l,c)}</strong>`};return a.split(/(%\w+%)/g).reduce(((t="",e)=>{const i=u[e];return i||0===i?t+i:t+e}))}function p(t){let e={d:"DD",D:"ddd",j:"D",l:"dddd",w:"d",F:"MMMM",M:"MMM",m:"MM",n:"M",S:"o",jS:"Do",Y:"YYYY",y:"YY"};return t.match(/(\\?\\?[\w\W])/g)?.map((t=>e[t]||t)).join("")}i(420),window.wteL10n.util=window.wteutil=n.A,window.wteL10n.ui=window.wteui=window.wteL10n.ui||{},window.wteL10n.ui.Accordion=window.wteui.Accordion=class{constructor(t){this.element=t,n.A.addClass(this.element,"wte-accordion-initialized"),this.items=n.A.getChildrenByClassName(this.element,"wte-accordion-item"),this.version=this.element.getAttribute("data-version")?"-"+this.element.getAttribute("data-version"):"",this.showClass="wte-accordion-open",this.animateHeight="on"==this.element.getAttribute("data-animation"),this.multiItems=!("off"==this.element.getAttribute("data-multi-items")),this.deepLinkOn="on"==this.element.getAttribute("data-deep-link"),this.initAccordion()}initAccordion(){for(var t=0;t<this.items.length;t++){var e=this.items[t].getElementsByClassName("wte-accordion-button")[0];if(e){var i=this.items[t].getElementsByClassName("wte-accordion-collapse")[0],a=n.A.hasClass(this.items[t],this.showClass)?"true":"false";n.A.setAttributes(e,{"aria-expanded":a,"aria-controls":"accordion-content-"+t,id:"accordion-header-"+t}),n.A.addClass(e,"wte-accordion-trigger"),n.A.setAttributes(i,{"aria-labelledby":"accordion-header-"+t,id:"accordion-content-"+t})}}this.initAccordionEvents(),this.initDeepLink()}initAccordionEvents(){var t=this;this.element.addEventListener("click",(function(e){var i=e.target.closest(".wte-accordion-trigger");i&&n.A.getIndexInArray(t.items,i.closest(".wte-accordion-item"))>=0&&t.triggerAccordion(i)}))}triggerAccordion(t){var e="true"===t.getAttribute("aria-expanded");this.animateAccordion(t,e,!1),!e&&this.deepLinkOn&&history.replaceState(null,"","#"+t.getAttribute("aria-controls"))}animateAccordion(t,e,i){var a=t.closest(".wte-accordion-item"),r=a.getElementsByClassName("wte-accordion-collapse")[0],s=e?"false":"true";n.A.toggleClass(a,this.showClass,!e),t.setAttribute("aria-expanded",s),r&&this.resetContentVisibility(a,r,e),(!this.multiItems&&!e||i)&&this.closeSiblings(a)}resetContentVisibility(t,e,i){n.A.toggleClass(t,this.showClass,!i),e.removeAttribute("style"),i&&!this.multiItems&&this.moveContent()}closeSiblings(t){for(var e=n.A.getIndexInArray(this.items,t),i=0;i<this.items.length;i++)if(n.A.hasClass(this.items[i],this.showClass)&&i!=e)return this.animateAccordion(this.items[i].getElementsByClassName("wte-accordion-trigger")[0],!0,!1),!1}moveContent(){var t=this.element.getElementsByClassName(this.showClass);if(0!=t.length){var e=t[0].getBoundingClientRect();if(e.top<0||e.top>window.innerHeight){var i=window.scrollY||document.documentElement.scrollTop;window.scrollTo(0,e.top+i)}}}initDeepLink(){if(this.deepLinkOn){var t=window.location.hash.substr(1);if(t&&""!=t){var e=this.element.querySelector('.wte-accordion-trigger[aria-controls="'+t+'"]');e&&"true"!==e.getAttribute("aria-expanded")&&(this.animateAccordion(e,!1,!0),setTimeout((function(){e.scrollIntoView(!0)})))}}}},window.wteL10n.helpers=window.wtehelpers=a,window.addCommas||(window.addCommas=t=>{for(var e=(t+="").split("."),i=e[0],a=e.length>1?"."+e[1]:"",n=/(\d+)(\d{3})/;n.test(i);)i=i.replace(n,"$1"+WPTE_Price_Separator+"$2");return i+a}),window.wteGetFormatedPrice=r,window.wteGetFormatedPriceWithCurrencyCode=s,window.wteGetFormatedPriceWithCurrencyCodeSymbol=o,window.wteGetFormatedPriceWithCurrencySymbol=c,window.calculateGrandTotal=l;const h=function(t){const{currency:e,baseCurrency:i,currencySymbol:a,format:{number:n,price:r}}=wteL10n;let s={"%CURRENCY_CODE%":`${e}`,"%CURRENCY_SYMBOL%":`${a}`,"%AMOUNT%":""+(t*=+{[i]:1}[e]),"%FORMATED_AMOUNT%":`${d(t,+n.decimal,n.decimalSeparator,n.thousansSeparator,!0,format.enableRound)}`};return r.split(/(%\w+%)/g).reduce(((t="",e)=>s[e]?t+s[e]:t+e))};n.A.on("click",".wte-popper button",(function(t){let e=this.closest(".wte-popper");e&&n.A.toggleClass(e,"active",!n.A.hasClass(e,"active"))}));const g=function(t){if(!n.A.hasClass(t,"wte-price-field")){let e=t.parentElement,i=document.createElement("input");i.type="hidden",i.name=t.name,i.value=t.value,t.name="",t.value=h(t.value),e.appendChild(i),t.addEventListener("focus",(function(){t.value=i.value})),t.addEventListener("blur",(function(){i.value=t.value,t.value=h(t.value)})),t.classList.add("wte-price-field")}};function f(t){var e=wteL10n.version,i=document.querySelectorAll("[class*=_wte_update_notice_], [data-wte-update]");if(i)for(var a in i){var n=i[a];if(n.classList)if(n.classList.contains(`_wte_update_notice_${e}`))n.classList.remove(`_wte_update_notice_${e}`);else{var r=new RegExp(`^(wte_(new|updated|note)_${e})$`);if(n.dataset.wteUpdate.match(r)){var s=n.dataset.wteUpdate;n.classList.add(s),n.removeAttribute("data-wte-update")}}}}window.wteL10n.ui.priceField=g,document.addEventListener("wteEditPackageRender",(function(){document.querySelectorAll('[data-wte-field-type="price"]')?.forEach((function(t){g(t)}))})),n.A.on("change","[data-toggle-target]",(function(t){let e=document.querySelector(this.dataset.toggleTarget);e&&(this.checked?e.style.removeProperty("display"):e.style.display="none")})),n.A.on("click",".wpte-edit-booking-detail",(function(t){t.preventDefault(),this.closest(".wpte-block").querySelectorAll("select, input").forEach((function(t){t.dataset.attribName&&(t.name=t.dataset.attribName),t.dataset.attribValue&&(t.value=t.dataset.attribValue),t.dataset.attribType&&(t.type=t.dataset.attribType),t.disabled&&(t.disabled=!1),t.type&&(t.readOnly=!1)})),this.closest(".wpte-block").querySelectorAll(".show_on_edit").forEach((function(){this.style.removeProperty("display")}))})),n.A.on("click",".wpte-edit-additional-note",(function(t){t.preventDefault(),this.closest(".wpte-block").querySelectorAll("select, input").forEach((function(t){t.dataset.attribName&&(t.name=t.dataset.attribName),t.dataset.attribValue&&(t.value=t.dataset.attribValue),t.dataset.attribType&&(t.type=t.dataset.attribType),t.disabled&&(t.disabled=!1),t.type&&(t.readOnly=!1)})),this.closest(".wpte-block").querySelectorAll(".show_on_edit").forEach((function(){this.style.removeProperty("display")}))})),n.A.on("click",".wte-email-template-updater",(function(t){t.preventDefault();var e=document.getElementById(this.dataset.target);e&&e.submit()})),document.addEventListener("wteSettingsTabContentLoaded",f),document.addEventListener("DOMContentLoaded",(t=>{f();var e=document.querySelectorAll(".wte-code");e&&e.forEach((function(t){t.dataset.height&&(t.style.height=t.dataset.height+"px"),hljs&&hljs.highlightBlock(t)})),n.A.on("click",".wte-onclick-toggler",(function(t){if(t.preventDefault(),this.dataset.target){var e=document.querySelector(this.dataset.target);e&&(Array.from(e.classList).includes("visible")?(e.classList.remove("visible"),e.style.display="none"):(e.style.removeProperty("display"),e.classList.add("visible")))}}))})),window.wteL10n=window.wteL10n||{};const y=function(t){this._value=t,this._getPriceFormat=function(){return wteL10n.format.price},this.get=function(){return this._value},this.format=function(t=!1,e=!0){const{currency:i,baseCurrency:a,currencySymbol:n,baseCurrencySymbol:r,format:{number:s,price:o,enableRound:c}}=wteL10n;let l={[a]:1};if("undefined"!=typeof wteCc&&wteCc?.code&&e)for(let t in wteCc.code)l={...l,[wteCc.code[t]]:wteCc.rate[t]};let d=+this._value*(e?+l[i]:1),u=+s.decimal;return wtehelpers.priceFormat(d,e?i:a,e?n:r,o,u,s.decimalSeparator,s.thousandSeparator,t,c)}},v=function(t){return new y(t)};window.wteL10n.priceFormat=window.wteL10n.priceFormat||v;const C=function(t){this._time=t,this.get=function(){return this._time},this.set=function(t){this._time=t},this._getTimeFormat=function(){return wteL10n.helpers.phpToMomentDF(wteL10n.format.datetime.date)},this.format=function(t=null,e=!1){if(wteL10n.format.datetime.timezone,!this._time)return this._time;if(t)return moment(this._time).format(t);let i=moment(this._time).format(this._getTimeFormat());return i+=e?" at "+moment(this._time).format("h:mm A"):"",i},this.getDatewithOffset=function(t){if(this._time){let e=moment(this._time).utc().format("YYYY-MM-DDTHH:mm:ss")+t;return new Date(e)}}};window.wteL10n.dateFormat=window.wteL10n.dateFormat||function(t){return new C(t)}}}]);