var te=Object.defineProperty,oe=Object.defineProperties;var ne=Object.getOwnPropertyDescriptors;var M=Object.getOwnPropertySymbols;var se=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var G=(n,r,t)=>r in n?te(n,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[r]=t,$=(n,r)=>{for(var t in r||(r={}))se.call(r,t)&&G(n,t,r[t]);if(M)for(var t of M(r))re.call(r,t)&&G(n,t,r[t]);return n},B=(n,r)=>oe(n,ne(r));import{ab as ae,aH as ie,e2 as Z,r as v,a as V,g as Q,c_ as W,j as e,h,d4 as le,d1 as J,d2 as K,ca as ce,bt as de,be as me,H as pe,i as ue,ap as fe,c as R,_ as q,dq as he,b6 as be,cc as ge,I as ve,cd as xe,b9 as ye,V as Se}from"./main-634.js";import"./bf-535-182.js";import{_ as U}from"./bf-432-274.js";import{D as we,B as Ce}from"./bf-400-72.js";import{n as je,C as Ee}from"./bf-25-81.js";import{C as X}from"./bf-577-275.js";import{F as Ie}from"./bf-570-251.js";import{S as Oe}from"./bf-534-247.js";import{G as Y}from"./bf-299-245.js";import"./bf-438-114.js";const Ne=ae(ie),$e=n=>n.lbl||n.adminLbl||n.txt,ee=()=>Object.entries(Ne).map(([n,r])=>({lbl:$e(r)||n,val:`${n}`})),Fe=()=>je.map(({name:n,label:r})=>({lbl:r,val:`bfVars["${n}"]`})),_e=n=>`/* On Field ${Z(n)}*/
document.querySelector(\`#form-\${bfContentId}\`).querySelector(\`#fieldKey-\${bfSlNo}\`).addEventListener('${n}', event => {
  /* Write your code here*/
});`,f=n=>({lbl:`On ${Z(n)}`,val:_e(n)}),Le=[{type:"group-opts",name:"Global Variables/Property",childs:[{lbl:"Form ID",val:"bf_globals[bfContentId].formId"},...Fe(),{lbl:"Dummy Data",val:"window.bf_dummy_data = { /* Overwrite Dummy Data */};"}]},{type:"group-opts",name:"Field Keys",childs:[...ee()]},{type:"group-opts",name:"Form Events",childs:[{lbl:"On Form Submit Success",val:"/* On Form Submit Success */\ndocument.querySelector(`#form-${bfContentId}`).addEventListener('bf-form-submit-success', ({detail:{formId, entryId, formData}}) => {\n	/* Write your code here... */\n});"},{lbl:"On Form Submit Error",val:"/* On Form Submit Error */\ndocument.querySelector(`#form-${bfContentId}`).addEventListener('bf-form-submit-error', ({detail:{formId, errors}}) => {\n	/* Write your code here... */\n});"},{lbl:"On Form Reset",val:"/* On Form Reset */\ndocument.querySelector(`#form-${bfContentId}`).addEventListener('bf-form-reset', ({detail:{formId}}) => {\n	/* Write your code here... */\n});"},{lbl:"On Form Validation Error",val:"/* On Form Validation Error */\ndocument.querySelector(`#form-${bfContentId}`).addEventListener('bf-form-validation-error', ({detail:{formId, fieldId, error}}) => {\n	/* Write your code here... */\n});"}]},{type:"group-title",name:"Field Events"},{type:"group-accordion",name:"Text Field",childs:[f("change"),f("input"),f("blur"),f("focus")]},{type:"group-accordion",name:"Textarea Field",childs:[f("change"),f("input"),f("blur"),f("focus")]},{type:"group-accordion",name:"Email Field",childs:[f("change"),f("input"),f("blur"),f("focus")]},{type:"group-accordion",name:"Checkbox",childs:[f("change")]},{type:"group-accordion",name:"Select",childs:[f("change")]},{type:"group-accordion",name:"Button",childs:[f("click")]},{type:"group-accordion",name:"Address Field",childs:[{lbl:"On Map Options",val:`/* On Address Map Options — mutate the Google Maps options before the map renders */
document.querySelector(\`#form-\${bfContentId}\`).addEventListener('bf-address-map-options', ({detail:{options, config, mode}}) => {
	/* mode is 'preview' | 'interactive'. Example: */
	/* options.streetViewControl = false; */
	/* options.mapTypeId = 'satellite'; */
});`},{lbl:"On Zip Patterns",val:`/* On Address Zip Patterns — add/override/remove the auto zip-validation regex per country */
document.querySelector(\`#form-\${bfContentId}\`).addEventListener('bf-address-zip-patterns', ({detail:{patterns, country, config, fldData}}) => {
	/* country is the selected 2-letter ISO code. Example: */
	/* patterns.US = /^\\d{5}$/ ;*/
	/* patterns.XX = /^.+$/ ;*/
	/* delete patterns.JP ;*/
});`},{lbl:"On State Options",val:`/* On Address State Options — filter/modify the state list before the dropdown builds */
document.querySelector(\`#form-\${bfContentId}\`).addEventListener('bf-address-states', ({detail:{states, country, config}}) => {
	/* country is the 2-letter ISO code. states is [{value,label}]. Example: */
	/* states.splice(0, states.length, ...states.filter(s => s.value !== 'AK')); */
	/* states.push({ value: 'XX', label: 'Custom' }); */
});`}]},{type:"group-accordion",name:"Payment Fields",childs:[{lbl:"On PayPal Order Options",val:`/* On PayPal Order — mutate the order payload before paypal.order.create */
document.querySelector(\`#form-\${bfContentId}\`).addEventListener('bf-paypal-order-options', ({detail:{order, config, contentId}}) => {
	/* Example: disable shipping + set default billing country */
	/* order.payment_source = { paypal: { experience_context: { shipping_preference: 'NO_SHIPPING' }, address: { country_code: 'US' } } }; */
});`},{lbl:"On PayPal Subscription Options",val:`/* On PayPal Subscription — mutate the subscription payload before paypal.subscription.create */
document.querySelector(\`#form-\${bfContentId}\`).addEventListener('bf-paypal-subscription-options', ({detail:{subData, config, contentId}}) => {
	/* Example: */
	/* subData.application_context = { shipping_preference: 'NO_SHIPPING' }; */
});`},{lbl:"On Razorpay Options",val:`/* On Razorpay Options — mutate the full Razorpay options before the checkout opens */
document.querySelector(\`#form-\${bfContentId}\`).addEventListener('bf-razorpay-options', ({detail:{options, config, contentId}}) => {
	/* Example: */
	/* options.theme = { color: '#3399cc' }; */
	/* options.notes = { ...options.notes, source: 'bitform' }; */
});`},{lbl:"On Mollie Payment Config",val:`/* On Mollie Payment Config — mutate the payment config before it is sent */
document.querySelector(\`#form-\${bfContentId}\`).addEventListener('bf-mollie-payment-config', ({detail:{confData, config, contentId}}) => {
	/* Example: */
	/* confData.metadata = { ...confData.metadata, source: 'bitform' }; */
});`},{lbl:"On Stripe Payment Config",val:`/* On Stripe Payment Config — mutate the payment config before it is sent */
document.querySelector(\`#form-\${bfContentId}\`).addEventListener('bf-stripe-payment-config', ({detail:{confData, config, contentId}}) => {
	/* Example: */
	/* confData.metadata = { ...confData.metadata, source: 'bitform' }; */
});`}]},{type:"group-opts",name:"Filter Functions",childs:[{lbl:"Filter Logic status",val:`function bf_modify_workflow_logic_status(logicStatus, logics, fieldValues, rowIndex, condIndx, props) {
	/* write your code here */ 
	return logicStatus
}`},{lbl:"Filter Razorpay Notes",val:`function bf_modify_razorpay_notes(notes) {
	 /* write your code here */ 
	return notes
}`}]}],ke=[{type:"group-opts",name:"Field Keys",childs:[...ee()]}];function Pe({className:n,route:r,title:t,children:p,childrenAccodin:O=!1,fldData:s,open:j=!1,actionComponent:E,offset:y=0,tag:u,highlightSelector:i,onClick:d,styleOverride:S}){const[w,b]=v.useState(j),[C,I]=v.useState(j?"auto":0),F=v.useRef(null),{css:m}=V(),{"*":A}=Q(),[k,D]=A.split("/"),H=`${u?`${u}-`:""}${W(t)}-acc`,z=`${u?`${u}-`:""}${W(t)}-acc-focus`;v.useEffect(()=>{b(j)},[j]);let P;k==="theme-customize"&&D===r&&(P=!0);const _=l=>{if(l.type==="keypress"&&(l.code==="Space"||l.code==="Enter")){b(c=>!c);return}if(l.type==="keyup"&&l.code==="Escape"){b(!1);return}l.type==="click"&&b(c=>!c)},N=l=>l.stopPropagation(),o=l=>{const c=window.getComputedStyle(l),L=parseFloat(c.marginTop)+parseFloat(c.marginBottom);return Math.ceil(l.offsetHeight+L)},a=()=>I(o(F.current));return e.jsxs("div",{role:"button",tabIndex:0,onKeyUp:_,onKeyDown:_,className:`${n} ${w&&m(x.active)} ${m(x.accordionLbl)}`,onClick:d,"data-testid":H,children:[e.jsx("div",{className:`btgl ${m({w:"100%"},P&&x.navBtnActive)}`,tabIndex:"-1",role:"button",onClick:_,onKeyDown:_,children:e.jsxs("div",{className:`${m(h.flxc,x.titlebar)} ${m(P&&{bd:"hsl(233deg 36% 95%)"})}`,style:{paddingLeft:y*2},children:[e.jsx("div",{children:e.jsx(le,{className:`toggle-icn ${m(x.icn)} `,size:"9",style:{transform:`rotate(${w?180:90}deg)`}})}),e.jsxs("div",{className:m(x.flxbwn),children:[e.jsxs("div",{className:m(h.flxc,h.mr2),children:[e.jsx("span",{className:`title ${m(x.dflx,!O&&h.fw500)}`,children:t}),u&&e.jsx("span",{title:`Field key: ${u}`,className:m(x.titleTag),children:u}),S&&e.jsx("span",{className:m(x.overrideIndicator),title:"Theme styles override"}),s&&e.jsx(Ee,{width:150,icnSize:15,className:`${m(h.mr2)} hovertip`,children:e.jsx("div",{className:m(x.tipBody),children:((s==null?void 0:s.lbl)||(s==null?void 0:s.txt)||(s==null?void 0:s.adminLbl))&&(s.lbl||s.txt||s.adminLbl)})}),e.jsx("div",{className:m(x.navActionBtn),"data-action-btn-lbl":!0,children:i&&e.jsx("div",{onMouseEnter:()=>J(i),onFocus:()=>J(i),onMouseLeave:()=>K(),onBlur:()=>K(),role:"button",tabIndex:"0",className:m(x.highlightBtn),title:"Highlight Element in Builder","data-testid":z,children:e.jsx(Ie,{size:15,stroke:"2.5"})})})]}),e.jsx("div",{onClick:N,onKeyDown:N,role:"button",tabIndex:"-1",children:E&&E})]})]})}),e.jsx("div",{style:{height:C,transition:"height 300ms",overflow:C==="auto"?"auto":"hidden"},children:e.jsx(ce,{nodeRef:F,in:w,timeout:300,onEntering:a,onEntered:()=>I("auto"),onExit:()=>I(F.current.offsetHeight),onExiting:()=>I(0),unmountOnExit:!0,style:{overflow:w?"auto":"hidden"},children:e.jsx("div",{ref:F,className:`body ${m(x.body)}`,onClick:N,onKeyDown:N,style:{paddingLeft:y*4},children:p})})})]})}const x={flxbwn:{flx:"between"},titlebar:{ws:"nowrap",fw:500,ow:"hidden",":hover":{bd:"#eeeff7"},"& .hovertip":{oy:0}},dflx:{flx:"align-center",fw:400,fs:13,lh:2,curp:1,"& .hover-tip":{oy:0}},":hover":{bd:"var(--b-50-95)"},icn:{cr:"#c6c6c6",mr:4,ml:4,mt:-1,tn:"transform 250ms"},body:{fs:12},titleTag:{p:"1px 5px",bd:"#EDF2F7",brs:5,cr:"gray",fs:11,fw:400,b:"1px solid #d8dde2",ml:"7px",curp:1},tipBody:{lh:"1.1",fs:"12.5px",fw:100,ff:'"Roboto", sans-serif'},accordionLbl:{":focus-within":{"& div[data-action-btn-lbl]":{dy:"flex"}},":focus-visible":{focusShadow:1,"& div[data-action-btn-lbl]":{dy:"flex"}},":hover":{bd:"#f8f8f8","& div[data-action-btn-lbl]":{dy:"flex"}}},highlightBtn:{flx:"center",brs:5,h:20,w:20,curp:1,":focus-visible":{focusShadow:1},":hover":{bd:"#d3d3d3"}},navActionBtn:{b:"none",pn:"absolute",rt:10,jc:"center",ai:"center",dy:"none",pl:15},overrideIndicator:{w:"5px",h:"5px",brs:"50%",bc:"#ffd64f",ml:"3px",px:2},active:{bd:"hsl(0deg 13% 97%)"},navBtnActive:{bd:"#eeeff7"}},Be=n=>{let r=0;return n.reduce((t,p)=>(p.type?(t.push(p),r=0):(r||(t.push({type:"no-group",childs:[]}),r=1),t[t.length-1].childs.push(p)),t),[])};function Te({options:n,action:r}){var u;const{css:t}=V(),p=Be(n),[O,s]=v.useState(p);v.useEffect(()=>{s(p)},[n]);const j=i=>{const d=i.target.value.toLowerCase().trim();if(!d)return s(p);const w=pe(p).reduce((b,C)=>(C.type!=="group-title"&&(b.push(C),C.childs&&(b[b.length-1].childs=C.childs.filter(I=>I.lbl.toLowerCase().includes(d)),b[b.length-1].childs.length===0&&b.pop())),b),[]);s(w)},E=()=>{y.current.value="",s(p)},y=v.useRef(null);return e.jsxs("div",{className:t(g.main),children:[e.jsxs("div",{className:t(g.fields_search),children:[e.jsx("input",{ref:y,title:"Search Field","aria-label":"Search Field",autoComplete:"off","data-testid":"tlbr-srch-inp",placeholder:"Search...",id:"search-icon",type:"search",name:"searchIcn",onChange:j,className:t(g.search_field)}),((u=y==null?void 0:y.current)==null?void 0:u.value)&&e.jsx("span",{title:"clear",className:t(g.clear_icn),role:"button",tabIndex:"-1",onClick:E,onKeyDown:E,children:" "}),e.jsx("span",{title:"search",className:t(g.search_icn),children:e.jsx(de,{size:"20"})})]}),e.jsx(me,{style:{height:"92%"},autoHide:!0,children:e.jsx("div",{className:t(g.groupList),children:O.map(i=>e.jsxs(v.Fragment,{children:[i.type==="group-accordion"&&e.jsx(Pe,{title:i.name,children:e.jsx("ul",{className:t(g.ul),children:"childs"in i&&i.childs.map(d=>e.jsx("li",{className:t(g.li),children:e.jsx("button",{type:"button",className:`${t(g.button)} btnHover`,title:d.lbl,onClick:()=>r(d.val),children:d.lbl})},`childs-${d.val}`))})},`group-accordion-${i.name}`),i.type==="group-opts"&&e.jsxs("ul",{className:t(g.ul),children:[i.type.match(/group-opts|group-title/)&&e.jsx("h4",{className:t(g.title),children:i.name}),"childs"in i&&i.childs.map(d=>e.jsx("li",{className:t(g.li),children:e.jsx("button",{type:"button",className:`${t(g.button)} btnHover`,title:d.lbl,onClick:()=>r(d.val),children:d.lbl})},`group-child-${d.val}`))]}),i.type==="group-title"&&e.jsx("h4",{className:t(g.title),children:i.name})]},`group-acc-${i.name}`))})})]})}const g={main:{h:300,w:200,py:3,ow:"hidden"},title:{m:0,pt:7,pb:5,pn:"sticky",tp:0,bd:"#fff",zx:9},fields_search:{pn:"relative",tn:"width .2s"},search_field:{mx:2,w:"98%",oe:"none",b:"none !important",brs:"9px !important",pl:"27px !important",pr:"5px !important",bd:"var(--white-0-97) !important",":focus":{oe:"none",bs:"0px 0px 0px 1.5px var(--b-50) !important",pr:"0px !important","& ~ .shortcut":{dy:"none"},"& ~ span svg":{cr:"var(--b-50)"}},"::placeholder":{fs:12},"::-webkit-search-cancel-button":{appearance:"none"}},search_icn:{pn:"absolute",tp:"50%",mx:6,lt:0,tm:"translateY(-50%)",cr:"var(--white-0-50)",curp:1,"& svg":{dy:"block"}},clear_icn:{pn:"absolute",tp:"50%",mx:6,rt:0,tm:"translateY(-50%)",cr:"var(--white-0-50)",curp:1,w:14,h:14,bd:"var(--white-0-83)",brs:20,backgroundPosition:"54% 50% !important",bi:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='Black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'%3E%3C/line%3E%3Cline x1='6' y1='6' x2='18' y2='18'%3E%3C/line%3E%3C/svg%3E")`},groupList:{mt:10},ul:{mt:0,mb:10},li:{mb:0,mt:5,ml:5},button:{fw:"normal",brs:5,dy:"block",w:"100%",ta:"left",b:0,bd:"none",p:3,curp:1,"&:hover":{bd:"var(--white-0-95)",cr:"var(--black-0)"},fs:11}};function Ue({width:n="100%",height:r="330px"}){const{css:t}=V(),{formType:p,formID:O}=Q(),[s,j]=v.useState("JavaScript"),[E,y]=v.useState(localStorage.getItem("bf-editor-theme")||"tomorrow"),[u,i]=v.useState(localStorage.getItem("bf-enable-editor")||"on"),d=v.useRef({}),[S,w]=ue(be),b=fe(ge),[C,I]=v.useState(Ae),F=["JavaScript","CSS"],m=[{label:"Light Theme",value:"tomorrow"},{label:"Dark Theme",value:"twilight"}],A=o=>{o&&!(o in d.current)&&(d.current[s]=o)},k=o=>{w(a=>B($({},a),{[s]:o}))},D=o=>{const a=d.current[s],{editor:l}=a;l.session.insert(l.getCursorPosition(),o);const c=l.getValue();w(L=>B($({},L),{[s]:c})),a.editor.renderer.scrollBarV.scrollTop!==a.editor.renderer.scrollBarV.maxScrollTop&&a.editor.gotoLine(a.editor.session.getLength()+1)},H=o=>{localStorage.setItem("bf-editor-theme",o),y(o)},z=o=>{const{checked:a}=o.target;a?(i("on"),localStorage.setItem("bf-enable-editor","on")):(i("off"),localStorage.setItem("bf-enable-editor","off"))},P=o=>{if(!ve){b($({show:!0},xe.customCode));return}if(p==="new"){ye("#update-btn").click();return}const l=R({form_id:O,customCodes:S},"bitforms_add_custom_code").then(c=>c);Se.promise(l,{loading:q("Updating..."),success:c=>{var L;return((L=c==null?void 0:c.data)==null?void 0:L.message)||(c==null?void 0:c.data)},error:q("Error occurred, Please try again.")}),o.preventDefault()},_=()=>{if(s==="JavaScript")return Le;if(s==="CSS")return ke},N={mode:s.toLowerCase(),theme:E,name:s,value:S[s]||"",onChange:o=>{k(o)},height:r,width:n,placeholder:'Write your code here...(Note: Do not use single line"//" comment)',setOptions:C,ref:A};return v.useEffect(()=>{p==="edit"&&!(S.JavaScript||S.CSS)?R({form_id:O},"bitforms_get_custom_code").then(a=>{var l,c;return w({JavaScript:(l=a==null?void 0:a.data)==null?void 0:l.JavaScript,CSS:(c=a==null?void 0:a.data)==null?void 0:c.CSS,isFetched:!0}),a}):p==="new"&&R({form_id:O,customCodes:S},"bitforms_add_custom_code").then(a=>a)},[]),e.jsxs("div",{children:[e.jsxs("div",{className:t({flx:"between"}),children:[e.jsx("div",{className:t(h.w10,{flx:"center",my:2,ml:27}),children:e.jsx(Oe,{width:300,options:F.map(o=>({label:o})),onChange:o=>j(o),defaultActive:"JavaScript",actionValue:s,wideTab:!0})}),e.jsx("div",{className:t(h.flxc),children:e.jsxs(we,{place:"bottom-end",children:[e.jsx("button",{"data-testid":"titl-mor-opt-btn","data-close":!0,type:"button",className:t(T.btn),unselectable:"on",draggable:"false",style:{cursor:"pointer"},title:q("Snippets"),children:e.jsx(Ce,{size:"16"})}),e.jsx(Te,{options:_(),action:D})]})})]}),e.jsx(Y,{open:s==="JavaScript",children:e.jsx("div",{className:"pos-rel",children:u==="on"?e.jsx(U,B($({},N),{onLoad:o=>{var a;(a=o==null?void 0:o.session)!=null&&a.$worker&&o.session.$worker.send("changeOptions",[{asi:!0}])}})):e.jsx("textarea",{className:t(T.editor,{h:r}),onChange:o=>k(o.target.value),value:S[s]||"",rows:"18"})})}),e.jsx(Y,{open:s==="CSS",children:e.jsx("div",{className:"pos-rel",children:u==="on"?e.jsx(U,$({},N)):e.jsx("textarea",{className:t(T.editor,{h:r}),onChange:o=>k(o.target.value),value:S[s]||"",rows:"18"})})}),e.jsxs("div",{className:t(h.flxb,h.mt1,h.mb1,{jc:"between"}),children:[e.jsxs("div",{className:t(h.flxc,h.w10,T.editorBtn),children:[e.jsx(X,{className:t(h.mr2),title:"Editor Mode",checked:u==="on",onChange:z}),u==="on"&&e.jsxs(e.Fragment,{children:[e.jsx(he,{onChange:H,value:E,options:m,size:"sm",className:t({w:150})}),e.jsx(X,{className:t(h.ml4),title:"Word Wrap",checked:C.wrap,onChange:()=>I(o=>B($({},o),{wrap:!o.wrap}))})]})]}),e.jsx("button",{onClick:P,type:"button",className:t(h.btn,T.saveBtn),children:"Save"})]})]})}const T={editor:{w:"99%"},btn:{b:0,brs:5,curp:1,flx:"center-between"},theme:{dy:"flex",jc:"flex-end"},editorBtn:{fs:12,pr:5},saveBtn:{bc:"var(--b-50)",brs:4,fs:13,fw:800,px:15,py:8,cr:"var(--white-100)",":hover":{bd:"var(--b-36)"}}},Ae={autoScrollEditorIntoView:!0,enableBasicAutocompletion:!0,enableLiveAutocompletion:!0,enableSnippets:!0,showLineNumbers:!0,tabSize:2,animatedScroll:!0,showFoldWidgets:!0,displayIndentGuides:!0,enableEmmet:!0,enableMultiselect:!0,highlightSelectedWord:!0,fontSize:15,useSoftTabs:!0,showPrintMargin:!0,showGutter:!0,highlightActiveLine:!0};export{Ue as default};
