(()=>{"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 o=n(609),i=Symbol.for("react.element"),a=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,r=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function p(e,t,n){var o,a={},p=null,d=null;for(o in void 0!==n&&(p=""+n),void 0!==t.key&&(p=""+t.key),void 0!==t.ref&&(d=t.ref),t)l.call(t,o)&&!s.hasOwnProperty(o)&&(a[o]=t[o]);if(e&&e.defaultProps)for(o in t=e.defaultProps)void 0===a[o]&&(a[o]=t[o]);return{$$typeof:i,type:e,key:p,ref:d,props:a,_owner:r.current}}t.Fragment=a,t.jsx=p,t.jsxs=p},540:(e,t,n)=>{e.exports=n(192)},609:e=>{e.exports=window.React}},t={};const n=window.wp.components,o=window.jfb.components,i=window.jfb.actions,a=window.wp.i18n,l=window.jfb.blocksToActions,r=window.wp.element;var s=function n(o){var i=t[o];if(void 0!==i)return i.exports;var a=t[o]={exports:{}};return e[o](a,a.exports,n),a.exports}(540);const p=function({settings:e,onChangeSettingObj:t,source:n}){const p=(0,l.useFields)({withInner:!1,placeholder:"--"}),d=(0,r.useMemo)((()=>n.wc_fields.map((e=>"string"==typeof e?{value:e,label:e}:e))),[]);return(0,s.jsxs)(o.RowControl,{createId:!1,children:[(0,s.jsx)(o.Label,{children:(0,a.__)("WooCommerce checkout fields map","jet-appointments-booking")}),(0,s.jsx)(o.RowControlEnd,{gap:4,children:d.map((n=>(0,s.jsx)(i.FieldsMapField,{tag:n.value,label:n.label,isRequired:n.required,formFields:p,value:e[`wc_fields_map__${n.value}`],onChange:e=>t({[`wc_fields_map__${n.value}`]:e})},n.value)))})]})};const d=function({settings:e,onChangeSettingObj:t,source:n}){const p=(0,l.useFields)({withInner:!1,placeholder:"--"}),d=(0,r.useMemo)((()=>n.columns.map((e=>"string"==typeof e?{value:e,label:e}:e))),[]);return(0,s.jsxs)(o.RowControl,{createId:!1,children:[(0,s.jsx)(o.Label,{children:(0,a.__)("DB columns map","jet-appointments-booking")}),(0,s.jsx)(o.RowControlEnd,{gap:4,children:d.map((n=>(0,s.jsx)(i.FieldsMapField,{tag:n.value,label:n.label,isRequired:n.required,formFields:p,value:e[`appointment_custom_field_${n.value}`],onChange:e=>t({[`appointment_custom_field_${n.value}`]:e})},n.value)))})]})},_=window.wp.data,{RepeaterItemContext:m}=JetFBComponents,c=[{value:"service",label:(0,a.__)("Service name","jet-appointments-booking")},{value:"provider",label:(0,a.__)("Provider name","jet-appointments-booking")},{value:"date",label:(0,a.__)("Date","jet-appointments-booking")},{value:"slot",label:(0,a.__)("Time slot start","jet-appointments-booking")},{value:"slot_end",label:(0,a.__)("Time slot end","jet-appointments-booking")},{value:"start_end_time",label:(0,a.__)("Full time slot","jet-appointments-booking")},{value:"date_time",label:(0,a.__)("Full date and time","jet-appointments-booking")},{value:"field",label:(0,a.__)("Form field","jet-appointments-booking")},{value:"add_to_calendar",label:(0,a.__)("Add to Google calendar link","jet-appointments-booking")}],u=()=>(0,s.jsx)(o.Help,{children:(0,s.jsx)(n.ExternalLink,{href:"https://codex.wordpress.org/Formatting_Date_and_Time",children:(0,a.__)("Formatting docs","jet-appointments-booking")})});const j=function({formFields:e}){const{currentItem:t,changeCurrentItem:l}=(0,r.useContext)(m);return(0,s.jsxs)(n.Flex,{direction:"column",children:[(0,s.jsx)(i.ValidatedSelectControl,{label:(0,a.__)("Type","jet-appointments-booking"),value:t.type,onChange:e=>l({type:e}),options:c}),(0,s.jsx)(o.WideLine,{}),(0,s.jsx)(i.ValidatedTextControl,{label:(0,a.__)("Label","jet-appointments-booking"),value:t.label,onChange:e=>l({label:e})}),["date","date_time"].includes(t.type)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.WideLine,{}),(0,s.jsx)(o.RowControl,{children:({id:e})=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.Label,{htmlFor:e,children:(0,a.__)("Date format","jet-appointments-booking")}),(0,s.jsxs)(o.RowControlEnd,{children:[(0,s.jsx)(n.TextControl,{id:e,value:t.date_format,onChange:e=>l({date_format:e}),__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),(0,s.jsx)(u,{})]})]})})]}),["slot","slot_end","start_end_time","date_time"].includes(t.type)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.WideLine,{}),(0,s.jsx)(o.RowControl,{children:({id:e})=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.Label,{htmlFor:e,children:(0,a.__)("Time format","jet-appointments-booking")}),(0,s.jsxs)(o.RowControlEnd,{children:[(0,s.jsx)(n.TextControl,{id:e,value:t.time_format,onChange:e=>l({time_format:e}),__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),(0,s.jsx)(u,{})]})]})})]}),"field"===t.type&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.WideLine,{}),(0,s.jsx)(i.ValidatedSelectControl,{label:(0,a.__)("Select form field","jet-appointments-booking"),value:t.field,onChange:e=>l({field:e}),options:e})]}),"add_to_calendar"===t.type&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.WideLine,{}),(0,s.jsx)(i.ValidatedTextControl,{label:(0,a.__)("Link text","jet-appointments-booking"),value:t.link_label,onChange:e=>l({link_label:e})})]})]})},{Repeater:x,RepeaterAddNew:g,RepeaterState:b}=JetFBComponents;const v=function({setIsShow:e}){const[t,i]=(0,r.useState)(!1),[p,d]=(0,r.useState)((()=>JetAppointmentActionData.details)),m=(0,l.useFields)({withInner:!1,placeholder:"--"}),c=(0,_.useSelect)((e=>e("core/editor").getEditedPostAttribute("id")),[]);return(0,s.jsxs)(n.Modal,{size:"large",title:(0,a.__)("Set up WooCommerce order details","jet-booking"),onRequestClose:()=>e(!1),className:o.ModalFooterStyle,children:[(0,s.jsxs)(b,{state:e=>{d(e(p))},children:[(0,s.jsx)(x,{items:p,children:(0,s.jsx)(j,{formFields:m})}),(0,s.jsx)(g,{children:(0,a.__)("Add New Item","jet-booking")})]}),(0,s.jsxs)(o.StickyModalActions,{children:[(0,s.jsx)(n.Button,{isPrimary:!0,onClick:function(){i(!0),jQuery.ajax({url:window.ajaxurl,type:"POST",dataType:"json",data:{action:"jet_appointments_save_wc_details",post_id:c,nonce:JetAppointmentActionData.nonce,details:p}}).done((function(t){t.success?(JetAppointmentActionData.details=p,e(!1)):alert(t.data.message)})).fail((function(e,t,n){alert(n)})).always((()=>{i(!1)}))},disabled:t,isBusy:t,children:(0,a.__)("Update","jet-booking")}),(0,s.jsx)(n.Button,{isSecondary:!0,disabled:t,onClick:()=>e(!1),children:(0,a.__)("Cancel","jet-booking")})]})]})};const f=function(e){const{settings:t,onChangeSettingObj:_}=e,m=(0,l.useFields)({withInner:!1}),[c,u]=(0,r.useState)(!1);return(0,s.jsxs)(n.Flex,{direction:"column",children:[(0,s.jsx)(i.ValidatedSelectControl,{label:(0,a.__)("Service ID field","jet-appointments-booking"),value:t.appointment_service_field,options:[{value:"",label:"--"},...m,{value:"_manual_input",label:(0,a.__)("Manual Input","jet-appointments-booking")}],onChange:e=>_({appointment_service_field:e}),isErrorSupported:({property:e})=>"appointment_service_field"===e,required:!0}),"_manual_input"===t.appointment_service_field&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.WideLine,{}),(0,s.jsx)(i.ValidatedTextControl,{label:(0,a.__)("Manual input Service ID","jet-appointments-booking"),value:t.appointment_service_id,onChange:e=>_({appointment_service_id:e}),isErrorSupported:({property:e})=>"appointment_service_id"===e,required:!0})]}),Boolean(JetAppointmentActionData.has_provider)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.WideLine,{}),(0,s.jsx)(i.ValidatedSelectControl,{label:(0,a.__)("Provider ID field","jet-appointments-booking"),value:t.appointment_provider_field,options:[{value:"",label:"--"},...m,{value:"_manual_input",label:(0,a.__)("Manual Input","jet-appointments-booking")}],onChange:e=>_({appointment_provider_field:e}),isErrorSupported:({property:e})=>"appointment_provider_field"===e,required:!0})]}),Boolean(JetAppointmentActionData.has_provider)&&"_manual_input"===t.appointment_provider_field&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.WideLine,{}),(0,s.jsx)(i.ValidatedTextControl,{label:(0,a.__)("Manual input Provider ID","jet-appointments-booking"),value:t.appointment_provider_id,onChange:e=>_({appointment_provider_id:e}),isErrorSupported:({property:e})=>"appointment_provider_id"===e,required:!0})]}),(0,s.jsx)(o.WideLine,{}),(0,s.jsx)(i.ValidatedSelectControl,{label:(0,a.__)("Appointment date field","jet-appointments-booking"),value:t.appointment_date_field,options:[{value:"",label:"--"},...m],onChange:e=>_({appointment_date_field:e}),isErrorSupported:({property:e})=>"appointment_date_field"===e,required:!0}),(0,s.jsx)(o.WideLine,{}),(0,s.jsx)(i.ValidatedSelectControl,{label:(0,a.__)("User e-mail field","jet-appointments-booking"),value:t.appointment_email_field,options:[{value:"",label:"--"},...m],onChange:e=>_({appointment_email_field:e}),isErrorSupported:({property:e})=>"appointment_email_field"===e,required:!0}),(0,s.jsx)(o.WideLine,{}),(0,s.jsx)(i.ValidatedSelectControl,{label:(0,a.__)("User name field","jet-appointments-booking"),value:t.appointment_name_field,options:[{value:"",label:"--"},{value:"_use_current_user",label:'Use current user name / "Guest" for not logged-in users'},...m],onChange:e=>_({appointment_name_field:e})}),Boolean(JetAppointmentActionData.columns?.length)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.WideLine,{}),(0,s.jsx)(d,{...e})]}),Boolean(JetAppointmentActionData.wc_integration)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.WideLine,{}),(0,s.jsx)(i.ValidatedSelectControl,{label:(0,a.__)("WooCommerce Price field","jet-appointments-booking"),help:(0,a.__)("Select field to get total price from. If not selectedprice will be get from post meta value.","jet-appointments-booking"),value:t.appointment_wc_price,onChange:e=>_({appointment_wc_price:e}),options:[{value:"",label:"--"},...m]}),(0,s.jsx)(o.WideLine,{}),(0,s.jsxs)(o.RowControl,{createId:!1,children:[(0,s.jsx)(o.Label,{children:(0,a.__)("WooCommerce order details","jet-appointments-booking")}),(0,s.jsxs)(o.RowControlEnd,{children:[(0,s.jsx)(n.FlexItem,{children:(0,s.jsx)(n.Button,{variant:"secondary",onClick:()=>u(!0),children:(0,a.__)("Set up","jet-appointments-booking")})}),(0,s.jsx)(o.Help,{children:(0,a.__)("Set up booking-related info you want to add to the WooCommerce orders and e-mails.","jet-appointments-booking")})]})]}),(0,s.jsx)(o.WideLine,{}),(0,s.jsx)(p,{...e})]}),c&&(0,s.jsx)(v,{setIsShow:u})]})},h=window.wp.primitives,w=(0,s.jsx)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,s.jsx)(h.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm9 1V8h-1.5v3.5h-2V13H13Z"})}),C={type:"insert_appointment",label:(0,a.__)("Insert appointment","jet-appointments-booking"),edit:f,docHref:"https://crocoblock.com/knowledge-base/jetappointment/how-to-create-appointment-booking-forms/",category:"content",icon:w,validators:[({settings:e})=>!e?.appointment_service_field&&{property:"appointment_service_field"},({settings:e})=>"_manual_input"===e?.appointment_service_field&&(!e?.appointment_service_id&&{property:"appointment_service_id"}),({settings:e})=>!!Boolean(JetAppointmentActionData.has_provider)&&(!e?.appointment_provider_field&&{property:"appointment_provider_field"}),({settings:e})=>!("_manual_input"!==e?.appointment_provider_field||!Boolean(JetAppointmentActionData.has_provider))&&(!e?.appointment_provider_id&&{property:"appointment_provider_id"}),({settings:e})=>!e?.appointment_date_field&&{property:"appointment_date_field"},({settings:e})=>!e?.appointment_email_field&&{property:"appointment_email_field"}]};(0,i.registerAction)(C)})();