(()=>{"use strict";var e={192:(e,t,n)=>{
/**
 * @license React
 * react-jsx-runtime.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var a=n(609),l=Symbol.for("react.element"),i=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,s=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function _(e,t,n){var a,i={},_=null,d=null;for(a in void 0!==n&&(_=""+n),void 0!==t.key&&(_=""+t.key),void 0!==t.ref&&(d=t.ref),t)o.call(t,a)&&!r.hasOwnProperty(a)&&(i[a]=t[a]);if(e&&e.defaultProps)for(a in t=e.defaultProps)void 0===i[a]&&(i[a]=t[a]);return{$$typeof:l,type:e,key:_,ref:d,props:i,_owner:s.current}}t.Fragment=i,t.jsx=_,t.jsxs=_},540:(e,t,n)=>{e.exports=n(192)},609:e=>{e.exports=window.React}},t={};var n=function n(a){var l=t[a];if(void 0!==l)return l.exports;var i=t[a]={exports:{}};return e[a](i,i.exports,n),i.exports}(540);const{SelectControl:a,TextControl:l,BaseControl:i,Button:o,Notice:s}=wp.components,{useState:r,useEffect:_}=wp.element,{addAction:d,getFormFieldsBlocks:p}=JetFBActions,{ActionFieldsMap:c,WrapperRequiredControl:m,RepeaterWithState:u,ActionModal:f}=JetFBComponents,v={type:"",label:"",format:"",field:"",link_label:""},h=e=>[...e,{value:"_manual_input",label:"Manual Input"}];d("insert_appointment",(function({settings:e,source:t,label:s,help:d,onChangeSetting:b}){const[x,j]=r([]),[g,w]=r([]),[C,y]=r([]),[F,S]=r(!1),[P,k]=r(!1);function B(e){k(!0),jQuery.ajax({url:window.ajaxurl,type:"POST",dataType:"json",data:{action:"jet_appointments_save_wc_details",post_id:t.apartment,nonce:t.nonce,details:e}}).done((function(t){k(!1),t.success?(JetAppointmentActionData.details=e,S(!1)):alert(t.data.message)})).fail((function(e,t,n){k(!1),alert(n)}))}function O(){return(0,n.jsx)("a",{href:"https://codex.wordpress.org/Formatting_Date_and_Time",target:"_blank",children:"Formatting docs"})}return _((()=>{const e={};t.columns.forEach((t=>{e[t]={label:t}}));const n={};t.wc_fields.forEach((e=>{n[e]={label:e}})),w(Object.entries(e)),y(Object.entries(n)),j(p([],"--"))}),[]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(a,{label:s("appointment_service_field"),labelPosition:"side",value:e.appointment_service_field,onChange:e=>b(e,"appointment_service_field"),options:h(x)}),"_manual_input"===e.appointment_service_field&&(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(l,{label:s("appointment_service_manual"),value:e.appointment_service_id,onChange:e=>b(e,"appointment_service_id")})}),(0,n.jsx)(a,{label:s("appointment_provider_field"),labelPosition:"side",value:e.appointment_provider_field,onChange:e=>b(e,"appointment_provider_field"),options:h(x)}),"_manual_input"===e.appointment_provider_field&&(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(l,{label:s("appointment_provider_manual"),value:e.appointment_provider_id,onChange:e=>b(e,"appointment_provider_id")})}),(0,n.jsx)(a,{label:s("appointment_date_field"),labelPosition:"side",value:e.appointment_date_field,onChange:e=>b(e,"appointment_date_field"),options:x}),(0,n.jsx)(a,{label:s("appointment_email_field"),labelPosition:"side",value:e.appointment_email_field,onChange:e=>b(e,"appointment_email_field"),options:x}),(0,n.jsx)(a,{label:s("appointment_name_field"),labelPosition:"side",value:e.appointment_name_field,onChange:e=>b(e,"appointment_name_field"),options:function(){let e=[{value:"",label:"--"},{value:"_use_current_user",label:'Use current user name / "Guest" for not logged-in users'}];for(var t=0;t<x.length;t++)x[t].value&&e.push(x[t]);return e}()}),Boolean(g.length)&&(0,n.jsx)(c,{label:s("db_columns_map"),fields:g,children:({fieldId:t,fieldData:a,index:i})=>(0,n.jsx)(m,{field:[t,a],children:(0,n.jsx)(l,{value:e[`appointment_custom_field_${t}`],onChange:e=>b(e,`appointment_custom_field_${t}`)},t+i)})}),Boolean(t.wc_integration)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(a,{label:s("appointment_wc_price"),help:d("appointment_wc_price"),labelPosition:"side",value:e.appointment_wc_price,onChange:e=>b(e,"appointment_wc_price"),options:x}),(0,n.jsx)(i,{label:s("wc_order_details"),help:d("wc_order_details"),children:(0,n.jsx)(o,{isSecondary:!0,onClick:()=>S(!0),children:"Set up"})}),(0,n.jsx)(c,{label:s("wc_fields_map"),fields:C,plainHelp:d("wc_fields_map"),children:({fieldId:t,fieldData:l,index:i})=>(0,n.jsx)(m,{field:[t,l],children:(0,n.jsx)(a,{labelPosition:"side",value:e[`wc_fields_map__${t}`],onChange:e=>b(e,`wc_fields_map__${t}`),options:x},t+i)})}),F&&(0,n.jsx)(f,{title:"Set up WooCommerce order details",onRequestClose:()=>S(!1),classNames:["width-60"],style:{opacity:P?"0.5":"1"},updateBtnProps:{isBusy:P},children:({actionClick:e,onRequestClose:i})=>(0,n.jsx)(u,{items:t.details,onSaveItems:B,newItem:v,onUnMount:()=>{e||i()},isSaveAction:e,addNewButtonLabel:P?"Saving...":"Add new item +",children:({currentItem:e,changeCurrentItem:i})=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(a,{label:s("wc_details__type"),labelPosition:"side",value:e.type,onChange:e=>i({type:e}),options:t.details_types}),(0,n.jsx)(l,{label:s("wc_details__label"),value:e.label,onChange:e=>i({label:e})}),"date"===e.type&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(l,{label:s("wc_details__date_format"),value:e.date_format,onChange:e=>i({date_format:e})}),O()]}),["slot","slot_end","start_end_time"].includes(e.type)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(l,{label:s("wc_details__time_format"),value:e.time_format,onChange:e=>i({time_format:e})}),O()]}),"date_time"===e.type&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(l,{label:s("wc_details__date_format"),value:e.date_format,onChange:e=>i({date_format:e})}),(0,n.jsx)(l,{label:s("wc_details__time_format"),value:e.time_format,onChange:e=>i({time_format:e})}),O()]}),"field"===e.type&&(0,n.jsx)(a,{label:s("wc_details__field"),labelPosition:"side",value:e.field,onChange:e=>i({field:e}),options:x}),"add_to_calendar"===e.type&&(0,n.jsx)(l,{label:s("wc_details__link_label"),value:e.link_label,onChange:e=>i({link_label:e})})]})})})]})]})}))})();