1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./VwPEvOHT.js","./Ci2lQbqp.js","./C0DNC_0X.js","./Ct08gblQ.js","./entry.DaYiuiJB.css","./BctKqZ1I.js","./FieldBadge.CPFSrFhX.css","./RichInputMention.CounYCnx.css","./BuPs7KAS.js","./CSyVPGqW.js","./D8cq3K3m.js","./CSTjkOKE.js","./Aw32P5U_.js","./useBilling.Bh3p95GD.css","./DA99VFiF.js","./BUi8dlW1.js","./AiChat.BUGkD1EZ.css","./useFieldEditor.BGlsi9_a.css","./CFliEpwd.js","./C5BCYW_K.js","./BiEpS6xn.js","./BH0n1SmV.js","./mJI5hUTp.js","./suuSAV1K.js","./pJZVvTcv.js","./TheFormShellBar.BwhD6BWT.css","./Djgyu3pV.js","./mYNF08FW.js","./CXh-Xv7B.js","./Ddj4y8jk.js","./BKyhqnl2.js","./Bu9DYH_8.js","./B4lld5Fh.js","./Spinner.uy7LSPv1.css","./DJo252Ne.js","./Dn0zyF38.js","./B-gvHSNg.js","./BL6s728J.js","./Bzjlv5NU.js","./wtC4gHQ9.js","./BRcTrRBC.js","./-zVkaUYZ.js","./DOowkj04.js","./Cbx33RRN.js","./DN8gGrtC.js","./CalendlyEditor.BLUq_Z3e.css","./CyHaKl5n.js","./D6NzroiV.js","./Dlov03CL.js","./DateEditor.B40B11CJ.css","./DJG2lGnU.js","./CtH_S9do.js","./B-oM_8OV.js","./BRxfSabk.js","./BULMZNOl.js","./GroupEditor.BkUlNeCW.css","./5CQGKCPt.js","./Btz6-SsC.js","./De3TL8tw.js","./MatrixEditor.B0myE_7k.css","./qS61aAG8.js","./Bkp5rMHu.js","./MultipleChoiceEditor.D3OpCSK5.css","./DYnCZoqe.js","./w8oJC0EC.js","./B4FIAvMR.js","./C8UaYe_v.js","./B9c9YLul.js","./4nijnh9_.js","./PhoneEditor.C2fjG3hB.css","./BX9aPfTa.js","./PictureChoiceEditor.vAjphlCe.css","./BNTWQf58.js","./OaD888-H.js","./DvkRPldY.js","./n1r6ZEjD.js","./BfeShtBg.js","./DG5pMBwV.js","./C5FFfWes.js","./BTkz2adG.js","./YesNoEditor.bO3YGLvP.css","./BEopBAHn.js","./CN02JISt.js","./CpYsfv9v.js","./CalendlySettings.rcDHR2VC.css","./Cl1ETbmC.js","./dBne8-Yr.js","./dbUDvmOn.js","./BDONWIMz.js","./Cgz7hdOl.js","./BUf_zBzK.js","./DSxYFM1P.js","./CNn3H7tR.js","./C8s0gcIs.js","./BR9h5ZlP.js","./CMQti2-S.js","./DrO6LNyw.js","./CVucr25c.js","./DWS0tUZb.js","./Cm0sxWpb.js","./D4e9COxU.js","./CKjz5p6A.js","./orxJxFwD.js","./BTObhxMJ.js","./BNib9XAA.js","./DLiyceJr.js","./DxZAxS7-.js","./Jhck_d1a.js"])))=>i.map(i=>d[i]); 2import{a as Gn,_ as Jn}from"./C5BCYW_K.js";import{_ as at}from"./BctKqZ1I.js";import{N as _n}from"./BiEpS6xn.js";import{Y as Ft,d as Yn,S as Be,c as pt,aB as Ae,M as ye,r as Ie,e as r,s as J,w as P,v as C,y as s,q as e,z as q,f as c,C as V,ae as tt,B as se,t as k,A as re,J as F,dZ as Qn,L as Re,h as qt,b0 as rt,aF as Ye,V as He,d_ as Xn,ad as ue,ao as xe,a$ as st,d$ as Qt,D as Z,b1 as Qe,ak as Ke,e0 as Zn,e1 as Ct,e2 as wn,e3 as Wt,e4 as Xt,e5 as eo,Z as De,dP as xn,aO as to,o as nt,bk as he,dR as Rt,x as Ce,dU as Ve,e6 as kn,e7 as no,k as $n,j as gt,bB as kt,e8 as je,bi as zt,e9 as oo,T as Zt,ea as io,eb as Ot,ec as Fe,cJ as vt,ed as Xe,aC as so,bm as Nt,an as Fn,bl as En,ee as lo,a2 as Sn,ef as Ne,br as ao,eg as ro,eh as uo,bn as co,as as lt,ei as en,ej as _t,ek as Tn,el as Pt,em as tn,en as nn,eo as on,ep as et,eq as Cn,er as sn,es as It,et as mo,eu as fo,ev as In,ew as po,ex as go,ey as vo,ez as $t,eA as ct,eB as ln,eC as ho,eD as yo,eE as bo,eF as _o,N as Ln,eG as wo,eH as xo,u as ko,cK as $o,dV as Fo,aM as Ze,W as ot,az as Eo,a as So}from"./Ct08gblQ.js";import{i as To}from"./Djgyu3pV.js";import{d as Bt,c as Co,r as Io}from"./BuPs7KAS.js";import{u as Et,r as An,_ as Lo}from"./Aw32P5U_.js";import{a as Vn,u as Ao}from"./CXh-Xv7B.js";import{u as Gt}from"./BKyhqnl2.js";import{_ as Dn}from"./Ddj4y8jk.js";import{_ as Rn}from"./DA99VFiF.js";import{_ as Jt}from"./B4lld5Fh.js";import{a as On,F as Nn}from"./BUi8dlW1.js";import{_ as ht}from"./DJo252Ne.js";import{a as Vo}from"./Dn0zyF38.js";import{_ as Pn}from"./B-gvHSNg.js";import{u as Bn}from"./Bzjlv5NU.js";import{_ as Do,l as Ro}from"./C0DNC_0X.js";import{a as wt}from"./wtC4gHQ9.js";import{u as Oo}from"./BRcTrRBC.js";import{_ as No}from"./pJZVvTcv.js";import{c as Po,_ as Bo}from"./CSTjkOKE.js";import{u as Mo}from"./-zVkaUYZ.js";import{u as jo}from"./DOowkj04.js";import{u as Uo}from"./Cbx33RRN.js";import{u as Ko}from"./DN8gGrtC.js";const Ho=()=>{const{apiClient:t}=Ft();return{async find(n){return(await t(`/workspaces/${n}/medias`,{method:"GET"})).data},async findOne(n,o=!0){return(await t(`/medias/${n}`,{method:"GET",params:{draft:o}})).data}
2,async create(n,o){return(await t(`/workspaces/${n}/medias`,{method:"POST",body:o,headers:{"Content-Type":"multipart/form-data"}})).data},async duplicate(n,o){return(await t(`/workspaces/${n}/medias`,{method:"POST",body:{cloneMediaId:o}})).data},async update(n,o){return(await t(`/medias/${n}`,{method:"PUT",body:o})).data},async delete(n){return await t(`/medias/${n}`,{method:"DELETE"})}}},dt=()=>{const{apiClient:t}=Ft();return{async find(n){return(await t(`/workspaces/${n}/themes`,{method:"GET"})).data},async findOne(n){return(await t(`/themes/${n}`,{method:"GET"})).data},async create(n,o){return(await t(`/workspaces/${n}/themes`,{method:"POST",body:o})).data},async duplicate(n,o){return(await t(`/workspaces/${n}/themes`,{method:"POST",body:{cloneThemeId:o}})).data},async update(n,o){return(await t(`/themes/${n}`,{method:"PUT",body:o})).data},async delete(n){return await t(`/themes/${n}`,{method:"DELETE"})}}},qo="https://api.unsplash.com",Wo=()=>{const{public:t}=Yn(),{createExternalClient:n}=Ft(),o=n(qo);return{async searchPhotos(i="nature",d=1,a=12){try{const u=t.unsplashAccessKey;if(!u)throw new Error("Unsplash access key not configured");return await o("/search/photos",{method:"GET",params:{query:i,page:d,per_page:a,client_id:u}})}catch(u){throw console.error("Unsplash API Error:",u),u}},async getFeaturedPhotos(i=1,d=12){try{const a=t.unsplashAccessKey;if(!a)throw new Error("Unsplash access key not configured");return await o("/photos",{method:"GET",params:{page:i,per_page:d,client_id:a}})}catch(a){throw console.error("Unsplash API Error:",a),a}},async downloadPhoto(i){try{const d=t.unsplashAccessKey;if(!d)throw new Error("Unsplash access key not configured");return await o(i,{method:"GET",params:{client_id:d}})}catch(d){throw console.error("Unsplash Download Error:",d),d}}}},zo={name:"prefillNameField",email:"prefillEmailField",phone:"prefillPhoneField"};function Go(t,n){const o=t?.eventTypeId;if(!o)return"noEventType";if(n==null)return null;const i=n.find(a=>a.id===o);return i?To(i)?(i.fields??[]).some(a=>a.required&&!t[zo[a.key]])?"unmappedField":null:"inactiveEventType":"missingEventType"}const Jo=["innerHTML"],Yo=["aria-label"],Qo={class:"w-8"},Xo={__name:"FieldListItem",props:{id:{type:[String,Number],required:!0},title:{type:String,default:""},type:{type:String,default:""},position:{type:[Number,String],default:0}},emits:["duplicate","delete"],setup(t){const n=t,o=pt(),i=F(()=>n.type!=="welcome-screen"),d=F(()=>String(o.query.field??"")===String(n.id)),a=Ae(),u=F(()=>n.type==="scheduling"?Qn(a.form?.workspaceId):null),m=F(()=>n.type==="scheduling"?Go(a.getFieldById?.(n.id)?.settings,u.value?.value??null):null);return(f,p)=>{const y=at,E=ye("VDropdown"),w=_n,S=Ie("tooltip"),x=Ie("close-popper");return r(),J(w,{to:{path:e(o).path,query:{field:t.id}},class:re(["group field",{"field-active":e(d)}]),"data-tour":e(d)?"editor-selected-question":void 0,"data-field-id":t.id,"data-field-type":t.type,"data-testid":"field-sidebar-item"},{default:P(()=>[C(y,{type:t.type,"show-position":!0,position:t.position},null,8,["type","position"]),s("span",{class:"field-title flex-grow truncate",innerHTML:t.title},null,8,Jo),e(m)?q((r(),c("i",{key:0,"data-test":"field-problem","aria-label":f.$t(`components.formEdit.fieldListItem.schedulingProblem.${e(m)}`),class:"oi oi-alert-circle oi-14 flex-none text-danger"},null,8,Yo)),[[S,f.$t(`components.formEdit.fieldListItem.schedulingProblem.${e(m)}`)]]):V("",!0),s("div",Qo,[C(E,{distance:6},{popper:P(()=>[e(i)?q((r(),c("button",{key:0,"aria-role":"listitem",class:"dropdown-item",onClick:p[1]||(p[1]=N=>f.$emit("duplicate",t.id))},[p[4]||(p[4]=s("i",{class:"oi oi-copy-paste oi-16 text-neutral"},null,-1)),se(k(f.$t("components.formEdit.fieldListItem.duplicate")),1)])),[[x]]):V("",!0),q((r(),c("button",{"aria-role":"listitem",class:"dropdown-item",onClick:p[2]||(p[2]=N=>f.$emit("delete",t.id))},[p[5]||(p[5]=s("i",{class:"oi oi-bin oi-16 text-neutral"},null,-1)),se(k(f.$t("components.formEdit.fieldListItem.delete")),1)])),[[x]])]),default:P(()=>[q((r(),c("button",{class:"btn btn-sm btn-action opacity-0 group-hover:opacity-100",onClick:p[
20]||(p[0]=tt(()=>{},["prevent","stop"]))},[...p[3]||(p[3]=[s("i",{class:"oi oi-ellipsis-v oi-16"},null,-1)])])),[[S,f.$t("components.formEdit.fieldListItem.dupDel")]])]),_:1})])]),_:1},8,["to","class","data-tour","data-field-id","data-field-type"])}}},Zo=Be(Xo,[["__scopeId","data-v-b7447574"]]),ei={class:"flex flex-col gap-5"},ti={"data-tour":"editor-welcome",class:"flex flex-col gap-2"},ni={class:"subheading-sm"},oi={key:0,class:"flex flex-col gap-2"},ii={"data-tour":"editor-questions",class:"flex flex-col gap-2"},si={class:"subheading-sm"},li={class:"flex flex-col gap-2"},ai={key:0,class:"ml-4 flex flex-col gap-2 group-children-area"},ri={class:"btn-placeholder text-xs"},di={class:"grid grid-cols-2 gap-4"},ui={class:"dropdown-title"},ci={class:"flex flex-col gap-1"},mi=["value","onClick"],fi={class:"flex items-center gap-2"},pi={class:"btn-placeholder"},gi={class:"grid grid-cols-2 gap-4"},vi={class:"dropdown-title"},hi={class:"flex flex-col gap-1"},yi=["value","onClick"],bi={class:"flex items-center gap-2"},_i=["title"],wi={"data-tour":"editor-endings",class:"flex flex-col gap-2"},xi={class:"subheading-sm"},ki={key:0,class:"flex flex-col gap-2"},$i={__name:"TheFieldList",setup(t){const{t:n}=Re(),o=Ae(),i=qt(),d=pt(),{requireFeatureSettled:a}=Vn(),u=Ao(),{canUse:m,billingLoading:f}=Et(),p=rt(),y=Ye(),{isSandbox:E}=Gt(),w=F(()=>o.getWelcomeScreens),S=F(()=>o.getTopLevelQuestions),x=F(()=>o.getEndingScreens),N=Z([]),I=Z({}),R=Z(!1);let T=!1;function ce(){R.value=!0}function be(){R.value=!1,T&&(T=!1,Ke(ae))}function ae(){if(R.value){T=!0;return}N.value=[...S.value];const G={};for(const U of o.fields)U.parentId&&(G[U.parentId]||(G[U.parentId]=[]),G[U.parentId].push(U));for(const U in G)G[U].sort((oe,ke)=>(oe.position??0)-(ke.position??0));I.value=G}He(()=>o.fields.map(G=>`${G.id}:${G.parentId??""}:${G.position??0}:${G.title??""}:${G.type??""}`).join("|"),ae,{immediate:!0});async function W(G,U){if(G.added){const oe=G.added.element,ke=G.added.newIndex,_e=o.fields.find(z=>z.id===oe.id)?.parentId??null,le=U??null,O=_e!==le,A=()=>{y.execute({resourceKey:`field:move:${oe.id}:${Date.now()}`,actionKey:"actions.moveFieldToScope",execute:()=>o.moveFieldToScope(oe.id,U,ke)})};if(O){const z=Le=>({"jump-remap":"components.formEdit.theFieldList.cascadeMoveJumpRemap","own-jump-strip":"components.formEdit.theFieldList.cascadeMoveRemoveOwnJump","mention-strip":"components.formEdit.theFieldList.cascadeMoveSameScreenMention","reverse-ref-cascade":"components.formEdit.theFieldList.cascadeMoveReverseSameScreenMention","move-out-mention-strip":"components.formEdit.theFieldList.cascadeMoveOutMention"})[Le.type],$e=Le=>new Promise(Te=>{p.warn({title:n("components.common.blockedActionDialog.titleReferences"),message:Le.consequences.map(Ue=>n(z(Ue))).join(` 3 4`)},()=>Te(!0),()=>Te(!1))}),Se=await o.moveFieldToScopeWithCascade(oe.id,le,ke,{confirm:$e});if(Se.status==="blocked"){const Le=Se.blocks[0];Le.type==="group-into-group"?p.alert(n("components.formEdit.theFieldList.blockedMoveGroupIntoGroup"),n("components.common.blockedDeletionDialog.title")):Le.type==="disallowed-child"?p.alert(n("components.formEdit.theFieldList.blockedMoveDisallowedChild"),n("components.common.blockedActionDialog.titleMove")):p.alert(n("components.formEdit.theFieldList.blockedMoveFieldHasLayout"),n("components.common.blockedActionDialog.titleMove")),Ke(ae);return}if(Se.status!=="ready"){Ke(ae);return}y.execute({resourceKey:`field:move:${oe.id}:${Date.now()}`,actionKey:"actions.moveFieldToScope",execute:()=>Se.execute()});return}A();return}if(G.moved){const oe=U?I.value[U]||[]:N.value,ke=G.moved.element,Ee=o.fields.map(A=>({...A})),_e=U?D(Ee,U,oe):j(Ee,oe),le=ke?Zn(Ee,_e,ke.id):[],O=(A=null)=>{y.execute({resourceKey:`fields:reorder:${U??"top"}:${Date.now()}`,actionKey:"actions.reorderInScope",execute:async()=>{if(await Ke(),A&&await A(),U){const z=o.fields.map($e=>({field:$e,position:$e.position}));o.reorderChildrenOf(U,oe),await o.persistChildrenPosition(U,oe,z)}else{const z=o.fields.map($e=>({field:$e,position:$e.position}));o.reorderFields(oe),await o.persistFieldsPosition(oe,z)}}})};if(le.length>
40){p.warn({title:n("components.common.blockedActionDialog.titleReferences"),message:n("components.formEdit.theFieldList.reorderOrphansMessage",{count:le.length}),references:le},()=>{O(async()=>{for(const A of le)await o.cascadeRemoveReferences(A.targetId??ke.id,{kind:"field",excludeFieldIds:[],onlyReferrerIds:[A.fieldId],channel:A.refType===eo.LOGIC_ACTION?Xt.JUMP:Xt.ANSWER_CONSUMING})})},()=>{Ke(ae)});return}O()}}function j(G,U){const oe=G.filter(_e=>_e.type==="welcome-screen"||_e.type==="ending-screen"),ke=G.filter(_e=>_e.type!=="welcome-screen"&&_e.type!=="ending-screen"&&_e.parentId),Ee=U.filter(_e=>_e.type!=="welcome-screen"&&_e.type!=="ending-screen"&&!_e.parentId).map((_e,le)=>({..._e,position:le+1}));return[...oe,...Ee,...ke]}function D(G,U,oe){const ke=G.filter(_e=>_e.parentId!==U),Ee=oe.filter(_e=>_e&&_e.parentId===U).map((_e,le)=>({..._e,position:le+1}));return[...ke,...Ee]}function L(G){const U=["welcome-screen","ending-screen"];return(U.includes(G)?Ct(G):Ct(G).filter(ke=>!U.includes(ke.type))).filter(ke=>Wt(ke.type,{sandbox:E.value}))}function M(G){return Ct(G).filter(U=>!wn.includes(U.type))}function Q(){const G=d.query.field;o.setCurrentField(G)}function X(){const G=u(),U=o.form?.id;return()=>G()&&o.form?.id===U}function ie(G,U){U()&&i.push({path:d.path,query:{field:G}})}async function pe(G){const U=X(),oe=Qe[G]?.requiredFeature;oe&&!await a(oe,{stillCurrent:U})||y.execute({resourceKey:`field:add:${G}:${Date.now()}`,actionKey:"actions.addField",execute:async()=>{const ke=await o.addField(G);ie(ke.id,U)}})}function B(G,U){const oe=X();y.execute({resourceKey:`field:add:${G}:child:${Date.now()}`,actionKey:"actions.addField",execute:async()=>{const ke=await o.addField(G,{parentId:U});ie(ke.id,oe)}})}function K(){const G=X();y.execute({resourceKey:`field:add:welcome:${Date.now()}`,actionKey:"actions.addField",execute:async()=>{const U=await o.addWelcomeScreenField();ie(U.id,G)}})}function ne(){const G=X();y.execute({resourceKey:`field:add:ending:${Date.now()}`,actionKey:"actions.addField",execute:async()=>{const U=await o.addEndingScreenField();ie(U.id,G)}})}async function we(G){const U=X(),oe=Qe[o.getFieldById(G)?.type]?.requiredFeature;oe&&!await a(oe,{stillCurrent:U})||y.execute({resourceKey:`field:duplicate:${G}`,actionKey:"actions.duplicateField",execute:async()=>{const ke=await o.duplicateField(G);ie(ke.id,U)}})}async function ve(G){if(o.getFieldById(G).type==="ending-screen"&&!await a(An.customEndingScreen))return;const oe=({scope:le,integrationCount:O})=>{const A={field:"components.formEdit.theFieldList.cascadeDeletionField","group-all":"components.formEdit.theFieldList.cascadeDeletionGroup","group-keep":"components.formEdit.theFieldList.cascadeDeletionGroupKeep"}[le]??"components.formEdit.theFieldList.cascadeDeletionField";let z=n(A);return O>0&&(z+=` 5 6`+n("components.common.blockedActionDialog.integrationsAffected",{count:O})),z},ke=le=>new Promise(O=>{switch(le.type){case"group-choice":p.chooseGroupDeletion({title:n("components.common.groupDeletionDialog.title"),message:n("components.formEdit.theFieldList.deleteGroupQuestion")},()=>O("all"),()=>O("keep"));return;case"references":p.warn({title:n("components.common.blockedActionDialog.titleReferences"),message:oe(le),references:le.refs},()=>O(!0),()=>O(!1));return;case"own-logic-loss":p.confirmDeletion(n("components.formEdit.theFieldList.confirmDeletionLogic"),()=>O(!0));return;case"answers-loss":p.confirmDeletion(le.isScreen?n("components.formEdit.theFieldList.confirmResponsesLossEnding"):n("components.formEdit.theFieldList.confirmResponsesLossWelcome"),()=>O(!0));return;default:O(!0)}}),Ee=await o.deleteFieldWithCascade(G,{confirm:ke});if(Ee.status!=="ready")return;const _e=X();y.execute({resourceKey:`field:delete:${G}`,actionKey:"actions.deleteField",execute:async()=>{const le=await Ee.execute();le&&ie(le.id,_e)}})}return He(()=>d.query,Q),Xn(()=>{Q()}),(G,U)=>{const oe=Zo,ke=ye("o-icon"),Ee=ye("VDropdown"),_e=Ie("close-popper");return r(),c("div",ei,[s("div",ti,[s("div",ni,k(e(n)("components.formEdit.theFieldList.welcomeScreen")),1),e(w).length>0?(r(),c("div",oi,[(r(!0),c(ue,null,xe(e(w),le=>(r(),J(oe,st({key:le.id},{ref_for:!0},le,{onDelete:ve}),null,16))),128))])):V("",!0),e(w).length===0?(r(),c("button",{key:1,class:"btn-placeholder",onClick:K},[U[1]||(U[1]=s("i",{class:"oi oi-plus oi-sm ml-1"},null,-1)),se(k(e(n)("components.formEdit.theFieldList.addWelcomeScreen")),1)])):V("",!0)]),s("div",ii,[s("div",si,k(e(n)("components.formEdit.theFieldList.questions")),1),e(N)?(r(),J(e(Bt),{key:0,list:e(N),group:"fields",class:"flex flex-col gap-2","item-key":"id","component-data":{tag:"ul",name:"flip-list",type:"transition"},filter:".btn-action","prevent-on-filter":!1,onStart:ce,onEnd:be,onChange:U[0]||(U[0]=le=>W(le,null))},{item:P(({element:le})=>[s("li",li,[C(oe,{id:le.id,type:le.type,position:le.position,title:le.title,onDelete:ve,onDuplicate:we},null,8,["id","type","position","title"]),le.type==="group"?(r(),c("div",ai,[C(e(Bt),{list:e(I)[le.id]||[],group:"fields",class:"flex flex-col gap-2 group-children-droparea","item-key":"id","component-data":{tag:"ul",name:"flip-list",type:"transition"},filter:".btn-action, .group-add-question","prevent-on-filter":!1,"empty-insert-threshold":40,onStart:ce,onEnd:be,onChange:O=>W(O,le.id)},{item:P(({element:O})=>[C(oe,{id:O.id,type:O.type,position:O.position,title:O.title,onDelete:ve,onDuplicate:we},null,8,["id","type","position","title"])]),footer:P(()=>[C(Ee,{distance:6,placement:"right",class:"group-add-question"},{popper:P(()=>[s("div",di,[(r(!0),c(ue,null,xe(e(Qt)(),O=>(r(),c("div",{key:O},[s("h2",ui,k(e(n)(O)),1),s("div",ci,[(r(!0),c(ue,null,xe(M(O),(A,z)=>q((r(),c("button",{key:`child-field-${z}`,value:z,"aria-role":"listitem",class:"dropdown-item",onClick:$e=>B(A.type,le.id)},[s("div",{class:re([A.color,"h-6 w-6 px-2 flex items-center justify-center rounded-md"])},[C(ke,{icon:A.icon,size:"sm",class:re(A.color)},null,8,["icon","class"])],2),s("div",fi,k(e(n)(A.name)),1)],8,mi)),[[_e]])),128))])]))),128))])]),default:P(()=>[s("button",ri,[U[2]||(U[2]=s("i",{class:"oi oi-plus oi-sm ml-1"},null,-1)),se(" "+k(e(n)("components.formEdit.theFieldList.AddQuestion")),1)])]),_:2},1024)]),_:2},1032,["list","onChange"])])):V("",!0)])]),_:1},8,["list"])):V("",!0),C(Ee,{distance:6,placement:"right"},{popper:P(()=>[s("div",gi,[(r(!0),c(ue,null,xe(e(Qt)(),le=>(r(),c("div",{key:le},[s("h2",vi,k(e(n)(le)),1),s("div",hi,[(r(!0),c(ue,null,xe(L(le),(O,A)=>q((r(),c("button",{key:`field-${A}`,value:A,"aria-role":"listitem",class:"dropdown-item",onClick:z=>pe(O.type)},[s("div",{class:re([O.color,"h-6 w-6 px-2 flex items-center justify-center rounded-md"])},[C(ke,{icon:O.icon,size:"sm",class:re(O.color)},null,8,["icon","class"])],2),s("div",bi,[se(k(e(n)(O.name))+" ",1),O.requiredFeature&&!e(f)&&!e(m)(O.requiredFeature)?(r(),c("span",{key:0,class:"feature-locked text-gray-400",title:e(n)("upgradeRequired.features.scheduling.name")}
6,[...U[4]||(U[4]=[s("i",{class:"oi oi-lock-2 oi-sm"},null,-1)])],8,_i)):V("",!0)])],8,yi)),[[_e]])),128))])]))),128))])]),default:P(()=>[s("button",pi,[U[3]||(U[3]=s("i",{class:"oi oi-plus oi-sm ml-1"},null,-1)),se(" "+k(e(n)("components.formEdit.theFieldList.AddQuestion")),1)])]),_:1})]),s("div",wi,[s("div",xi,k(e(n)("components.formEdit.theFieldList.endingScreens")),1),e(x).length>0?(r(),c("div",ki,[(r(!0),c(ue,null,xe(e(x),le=>(r(),J(oe,st({key:le.id},{ref_for:!0},le,{onDelete:ve,onDuplicate:we}),null,16))),128))])):V("",!0),s("button",{class:"btn-placeholder",onClick:ne},[U[5]||(U[5]=s("i",{class:"oi oi-plus oi-sm ml-1"},null,-1)),se(k(e(n)("components.formEdit.theFieldList.addEndingScreens")),1)])])])}}},Fi=Be($i,[["__scopeId","data-v-ab5c5550"]]);var Ei={grad:.9,turn:360,rad:360/(2*Math.PI)},it=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},Pe=function(t,n,o){return n===void 0&&(n=0),o===void 0&&(o=Math.pow(10,n)),Math.round(o*t)/o+0},Ge=function(t,n,o){return n===void 0&&(n=0),o===void 0&&(o=1),t>o?o:t>n?t:n},Mn=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},an=function(t){return{r:Ge(t.r,0,255),g:Ge(t.g,0,255),b:Ge(t.b,0,255),a:Ge(t.a)}},Lt=function(t){return{r:Pe(t.r),g:Pe(t.g),b:Pe(t.b),a:Pe(t.a,3)}},Si=/^#([0-9a-f]{3,8})$/i,xt=function(t){var n=t.toString(16);return n.length<2?"0"+n:n},jn=function(t){var n=t.r,o=t.g,i=t.b,d=t.a,a=Math.max(n,o,i),u=a-Math.min(n,o,i),m=u?a===n?(o-i)/u:a===o?2+(i-n)/u:4+(n-o)/u:0;return{h:60*(m<0?m+6:m),s:a?u/a*100:0,v:a/255*100,a:d}},Un=function(t){var n=t.h,o=t.s,i=t.v,d=t.a;n=n/360*6,o/=100,i/=100;var a=Math.floor(n),u=i*(1-o),m=i*(1-(n-a)*o),f=i*(1-(1-n+a)*o),p=a%6;return{r:255*[i,m,u,u,f,i][p],g:255*[f,i,i,m,u,u][p],b:255*[u,u,f,i,i,m][p],a:d}},rn=function(t){return{h:Mn(t.h),s:Ge(t.s,0,100),l:Ge(t.l,0,100),a:Ge(t.a)}},dn=function(t){return{h:Pe(t.h),s:Pe(t.s),l:Pe(t.l),a:Pe(t.a,3)}},un=function(t){return Un((o=(n=t).s,{h:n.h,s:(o*=((i=n.l)<50?i:100-i)/100)>0?2*o/(i+o)*100:0,v:i+o,a:n.a}));var n,o,i},mt=function(t){return{h:(n=jn(t)).h,s:(d=(200-(o=n.s))*(i=n.v)/100)>0&&d<200?o*i/100/(d<=100?d:200-d)*100:0,l:d/2,a:n.a};var n,o,i,d},Ti=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ci=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ii=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Li=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Mt={string:[[function(t){var n=Si.exec(t);return n?(t=n[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?Pe(parseInt(t[3]+t[3],16)/255,2):1}:t.length===6||t.length===8?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:t.length===8?Pe(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var n=Ii.exec(t)||Li.exec(t);return n?n[2]!==n[4]||n[4]!==n[6]?null:an({r:Number(n[1])/(n[2]?100/255:1),g:Number(n[3])/(n[4]?100/255:1),b:Number(n[5])/(n[6]?100/255:1),a:n[7]===void 0?1:Number(n[7])/(n[8]?100:1)}):null},"rgb"],[function(t){var n=Ti.exec(t)||Ci.exec(t);if(!n)return null;var o,i,d=rn({h:(o=n[1],i=n[2],i===void 0&&(i="deg"),Number(o)*(Ei[i]||1)),s:Number(n[3]),l:Number(n[4]),a:n[5]===void 0?1:Number(n[5])/(n[6]?100:1)});return un(d)},"hsl"]],object:[[function(t){var n=t.r,o=t.g,i=t.b,d=t.a,a=d===void 0?1:d;return it(n)&&it(o)&&it(i)?an({r:Number(n),g:Number(o),b:Number(i),a:Number(a)}):null},"rgb"],[function(t){var n=t.h,o=t.s,i=t.l,d=t.a,a=d===void 0?1:d;if(!it(n)||!it(o)||!it(i))return null;var u=rn({h:Number(n),s:Number(o),l:Number(i),a:Number(a)});return un(u)},"hsl"],[function(t){var n=t.h,o=t.s,i=t.v,d=t.a,a=d===void 0?1:d;if(!it(n)||!it(o)||!it(i))return null;var u=(function(m){return{h:Mn(m.h),s:Ge(m.s,0,100),v:Ge(m.v,0,100),a:Ge(m.a)}})({h:Number(n),s:Number(o),v:Number(i),a:Number(a)});return Un(u)},"hsv"]]},cn=function(t,n){for(var o=0;o<n.length;o++){var i=n[o][0](t);if(i)return[i,n[o][1]]}return[null,void 0]},Ai=function(t){return typeof t=="string"?cn(t.trim(),Mt.string):typeof t=="object"&&t!==null?cn(t,Mt.object):[null,void 0]},At=function(t,n){var o=mt(t);return{h:o.h,s:Ge(o.s+100*n,0,100),l:o.l,a:o.a}},Vt=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},mn=function(t,n){var o=mt(t);
vendor: 4,822 bytes, line 6
6return{h:o.h,s:o.s,l:Ge(o.l+100*n,0,100),a:o.a}},jt=(function(){function t(n){this.parsed=Ai(n)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return this.parsed!==null},t.prototype.brightness=function(){return Pe(Vt(this.rgba),2)},t.prototype.isDark=function(){return Vt(this.rgba)<.5},t.prototype.isLight=function(){return Vt(this.rgba)>=.5},t.prototype.toHex=function(){return n=Lt(this.rgba),o=n.r,i=n.g,d=n.b,u=(a=n.a)<1?xt(Pe(255*a)):"","#"+xt(o)+xt(i)+xt(d)+u;var n,o,i,d,a,u},t.prototype.toRgb=function(){return Lt(this.rgba)},t.prototype.toRgbString=function(){return n=Lt(this.rgba),o=n.r,i=n.g,d=n.b,(a=n.a)<1?"rgba("+o+", "+i+", "+d+", "+a+")":"rgb("+o+", "+i+", "+d+")";var n,o,i,d,a},t.prototype.toHsl=function(){return dn(mt(this.rgba))},t.prototype.toHslString=function(){return n=dn(mt(this.rgba)),o=n.h,i=n.s,d=n.l,(a=n.a)<1?"hsla("+o+", "+i+"%, "+d+"%, "+a+")":"hsl("+o+", "+i+"%, "+d+"%)";var n,o,i,d,a},t.prototype.toHsv=function(){return n=jn(this.rgba),{h:Pe(n.h),s:Pe(n.s),v:Pe(n.v),a:Pe(n.a,3)};var n},t.prototype.invert=function(){return ze({r:255-(n=this.rgba).r,g:255-n.g,b:255-n.b,a:n.a});var n},t.prototype.saturate=function(n){return n===void 0&&(n=.1),ze(At(this.rgba,n))},t.prototype.desaturate=function(n){return n===void 0&&(n=.1),ze(At(this.rgba,-n))},t.prototype.grayscale=function(){return ze(At(this.rgba,-1))},t.prototype.lighten=function(n){return n===void 0&&(n=.1),ze(mn(this.rgba,n))},t.prototype.darken=function(n){return n===void 0&&(n=.1),ze(mn(this.rgba,-n))},t.prototype.rotate=function(n){return n===void 0&&(n=15),this.hue(this.hue()+n)},t.prototype.alpha=function(n){return typeof n=="number"?ze({r:(o=this.rgba).r,g:o.g,b:o.b,a:n}):Pe(this.rgba.a,3);var o},t.prototype.hue=function(n){var o=mt(this.rgba);return typeof n=="number"?ze({h:n,s:o.s,l:o.l,a:o.a}):Pe(o.h)},t.prototype.isEqual=function(n){return this.toHex()===ze(n).toHex()},t})(),ze=function(t){return t instanceof jt?t:new jt(t)},fn=[],Vi=function(t){t.forEach(function(n){fn.indexOf(n)<0&&(n(jt,Mt),fn.push(n))})};function Di(t,n){var o={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",s
6andybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var d in o)i[o[d]]=d;var a={};t.prototype.toName=function(u){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var m,f,p=i[this.toHex()];if(p)return p;if(u?.closest){var y=this.toRgb(),E=1/0,w="black";if(!a.length)for(var S in o)a[S]=new t(o[S]).toRgb();for(var x in o){var N=(m=y,f=a[x],Math.pow(m.r-f.r,2)+Math.pow(m.g-f.g,2)+Math.pow(m.b-f.b,2));N<E&&(E=N,w=x)}return w}},n.string.push([function(u){var m=u.toLowerCase(),f=m==="transparent"?"#0000":o[m];return f?new t(f).toRgb():null},"name"])}Vi([Di]);const yt={methods:{setColorValue(t){const n=ze(t).toRgb(),{r:o,g:i,b:d,a}=n,{h:u,s:m,v:f}=this.rgb2hsv(n);return{r:o,g:i,b:d,a:a===void 0?1:a,h:u,s:m,v:f}},createAlphaSquare(t){const n=document.createElement("canvas"),o=n.getContext("2d"),i=t*2;return n.width=i,n.height=i,o.fillStyle="#ffffff",o.fillRect(0,0,i,i),o.fillStyle="#ccd5db",o.fillRect(0,0,t,t),o.fillRect(t,t,t,t),n},createLinearGradient(t,n,o,i,d,a){const u=t==="l",m=n.createLinearGradient(0,0,u?o:0,u?0:i);m.addColorStop(.01,d),m.addColorStop(.99,a),n.fillStyle=m,n.fillRect(0,0,o,i)},rgb2hex({r:t,g:n,b:o},i){const d=u=>("0"+Number(u).toString(16)).slice(-2),a=`#${d(t)}${d(n)}${d(o)}`;return i?a.toUpperCase():a},hex2rgb(t){t=t.slice(1);const n=o=>parseInt(o,16)||0;return{r:n(t.slice(0,2)),g:n(t.slice(2,4)),b:n(t.slice(4,6))}},rgb2rgba(t){return typeof t=="string"?(t=(/rgba?\((.*?)\)/.exec(t)||["","0,0,0,1"])[1].split(","),{r:Number(t[0])||0,g:Number(t[1])||0,b:Number(t[2])||0,a:Number(t[3]?t[3]:1)}):t},rgb2hsv({r:t,g:n,b:o}){t=t/255,n=n/255,o=o/255;const i=Math.max(t,n,o),d=Math.min(t,n,o),a=i-d;let u=0;i===d?u=0:i===t?n>=o?u=60*(n-o)/a:u=60*(n-o)/a+360:i===n?u=60*(o-t)/a+120:i===o&&(u=60*(t-n)/a+240),u=Math.floor(u);let m=parseFloat((i===0?0:1-d/i).toFixed(2)),f=parseFloat(i.toFixed(2));return{h:u,s:m,v:f}}}},Ri={mixins:[yt],props:{color:{type:String,default:"#000000"},hsv:{type:Object,default:null},size:{type:Number,default:152}},data(){return{slideSaturationStyle:{}}},mounted(){this.renderColor(),this.renderSlide()},methods:{renderColor(){const t=this.$refs.canvasSaturation,n=this.size,o=t.getContext("2d");t.width=n,t.height=n,o.fillStyle=this.color,o.fillRect(0,0,n,n),this.createLinearGradient("l",o,n,n,"#FFFFFF","rgba(255,255,255,0)"),this.createLinearGradient("p",o,n,n,"rgba(0,0,0,0)","#000000")},renderSlide(){this.slideSaturationStyle={left:this.hsv.s*this.size-5+"px",top:(1-this.hsv.v)*this.size-5+"px"}},selectSaturation(t){const{top:n,left:o}=this.$el.getBoundingClientRect(),i=t.target.getContext("2d"),d=u=>{let m=u.clientX-o,f=u.clientY-n;m<0&&(m=0),f<0&&(f=0),m>this.size&&(m=this.size),f>this.size&&(f=this.size),this.slideSaturationStyle={left:m-5+"px",top:f-5+"px"};const p=i.getImageData(Math.min(m,this.size-1),Math.min(f,this.size-1),1,1),[y,E,w]=p.data;this.$emit("selectSaturation",{r:y,g:E,b:w})};d(t);const a=()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",a)};document.addEventListener("mousemove",d),document.addEventListener("mouseup",a)}}},Oi={ref:"canvasSaturation"};function Ni(t,n,o,i,d,a){return r(),c("div",{class:"saturation",onMousedown:n[0]||(n[0]=tt((...u)=>a.selectSaturation&&a.selectSaturation(...u),["prevent","stop"]))},[s("canvas",Oi,null,512),s("div",{style:De(d.slideSaturationStyle),class:"slide"},null,4)],32)}const Pi=Be(Ri,[["render",Ni]]),Bi={props:{hsv:{type:Object,default:null},width:{type:Number,default:15},height:{type:Number,default:152}},data(){return{slideHueStyle:{}}},mounted(){this.renderColor(),this.renderSlide()},methods:{renderColor(){const t=this.$refs.canvasHue,n=this.width,o=this.height,i=t.getContext("2d");t.width=n,t.height=o;const d=i.createLinearGradient(0,0,0,o);d.addColorStop(0,"#FF0000"),d.addColorStop(.17*1,"#FF00FF"),d.addColorStop(.17*2,"#0000FF"),d.addColorStop(.17*3,"#00FFFF"),d.addColorStop(.17*4,"#00FF00"),d.addColorStop(.17*5,"#FFFF00"),d.addColorStop(1,"#FF0000"),i.fillStyle=d,i.fillRect(0,0,n,o)}
6,renderSlide(){this.slideHueStyle={top:(1-this.hsv.h/360)*this.height-2+"px"}},selectHue(t){const{top:n}=this.$el.getBoundingClientRect(),o=t.target.getContext("2d"),i=a=>{let u=a.clientY-n;u<0&&(u=0),u>this.height&&(u=this.height),this.slideHueStyle={top:u-2+"px"};const m=o.getImageData(0,Math.min(u,this.height-1),1,1),[f,p,y]=m.data;this.$emit("selectHue",{r:f,g:p,b:y})};i(t);const d=()=>{document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",d)};document.addEventListener("mousemove",i),document.addEventListener("mouseup",d)}}},Mi={ref:"canvasHue"};function ji(t,n,o,i,d,a){return r(),c("div",{class:"hue",onMousedown:n[0]||(n[0]=tt((...u)=>a.selectHue&&a.selectHue(...u),["prevent","stop"]))},[s("canvas",Mi,null,512),s("div",{style:De(d.slideHueStyle),class:"slide"},null,4)],32)}const Ui=Be(Bi,[["render",ji]]),Ki={mixins:[yt],props:{color:{type:String,default:"#000000"},rgba:{type:Object,default:null},width:{type:Number,default:15},height:{type:Number,default:152}},data(){return{slideAlphaStyle:{},alphaSize:5}},watch:{color(){this.renderColor()},"rgba.a"(){this.renderSlide()}},mounted(){this.renderColor(),this.renderSlide()},methods:{renderColor(){const t=this.$refs.canvasAlpha,n=this.width,o=this.height,i=this.alphaSize,d=this.createAlphaSquare(i),a=t.getContext("2d");t.width=n,t.height=o,a.fillStyle=a.createPattern(d,"repeat"),a.fillRect(0,0,n,o),this.createLinearGradient("p",a,n,o,"rgba(255,255,255,0)",this.color)},renderSlide(){this.slideAlphaStyle={top:this.rgba.a*this.height-2+"px"}},selectAlpha(t){const{top:n}=this.$el.getBoundingClientRect(),o=d=>{let a=d.clientY-n;a<0&&(a=0),a>this.height&&(a=this.height);let u=parseFloat((a/this.height).toFixed(2));this.$emit("selectAlpha",u)};o(t);const i=()=>{document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",i)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",i)}}},Hi={ref:"canvasAlpha"};function qi(t,n,o,i,d,a){return r(),c("div",{class:"color-alpha",onMousedown:n[0]||(n[0]=tt((...u)=>a.selectAlpha&&a.selectAlpha(...u),["prevent","stop"]))},[s("canvas",Hi,null,512),s("div",{style:De(d.slideAlphaStyle),class:"slide"},null,4)],32)}const Wi=Be(Ki,[["render",qi]]),zi={mixins:[yt],props:{color:{type:String,default:"#000000"},width:{type:Number,default:100},height:{type:Number,default:30}},data(){return{alphaSize:5}},watch:{color(){this.renderColor()}},mounted(){this.renderColor()},methods:{renderColor(){const t=this.$el,n=this.width,o=this.height,i=this.alphaSize,d=this.createAlphaSquare(i),a=t.getContext("2d");t.width=n,t.height=o,a.fillStyle=a.createPattern(d,"repeat"),a.fillRect(0,0,n,o),a.fillStyle=this.color,a.fillRect(0,0,n,o)}}};function Gi(t,n,o,i,d,a){return r(),c("canvas")}const Ji=Be(zi,[["render",Gi]]),Yi="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAlBJREFUOBGNkk2IUlEUx+99vufXQvCjEA11YWgk7TTLZhwVLTfSRmY1QbOoTdMqad0iiGB20cpVUAt3SVHCJDJG40IXBVGLIIOB8hM/QPy+/a/xYqK38MJ99757zu9/zj3nUrLmiEajdkEQni6Xy6hKpfqB/eNCofCMrsOHQiEPgPfwtdhsNkYpJe12m0LolkpJIJFI7DkcDm+9Xv/o9/vPw+dwsVhYnE4nc7lc1G63016vx8bj8TlRSWA6nd6cz+cXAoHAGYD3sDdarVam1+vpaDRaITgjjLHTigKArkK9ifXhbDYjBoOBSZL0F261Wqzb7VKtVvtBUQCwi4N88kjD4ZAg+ioyT53DGo3mJwLs/VcD3PkyrnAwmUwks9n8YDAYuPBvxGQASL/fp8imiwJeKZVK3/4R4DAicliLIt4pFosvsH9Vq9Wu4b5GCHC4j+hb5XL5C09JWOWFTzAY3MJyAAHJ7XbfRo9fclsmk2maTKY8IhJRFAna+QTwJ27jYyUQDofj6O1bPBLJ6/Xu5vP5N3/MhMC2gxrcReTvEGio1er7eFRR2S7EYrE40nsNWPB4PLu5XO6dbIxEIjuo+COkfAyfTZ1OF4dIHyJnZR8RkZ/zH5/PdyObzR7KhmQyud3pdFYw2rVRqVSOYePTIvvwVYDyKThUT8KpVGq70WjsI/Iv+HC4zp2VhoiiEP625ZFOp683m819iLZxtlGtVuuyTWmlePcM9x9A6DNWikd0EYJtdGPz6OjoqxJ08ox3oQzYgKtcwgwi7Q5athbMhX4DL0sglf8ys78AAAAASUVORK5CYII=",Qi={props:{suckerCanvas:{type:null,default:null},suckerArea:{type:Array,default:()=>[]}},data(){return{isOpenSucker:!1,suckerPreview:null,isSucking:!1}},watch:{suckerCanvas(t){this.isSucking=!1,this.suckColor(t),t.style.cursor=`url(${Yi}) 0 32, default`}},methods:{openSucker(){this.isOpenSucker?this.keydownHandler({keyCode:27}):(this.isOpenSucker=!0,this.isSucking=!0,this.$emit("openSucker",!0),document.addEventListener("keydown",this.keydownHandler))},keydownHandler(t){t.keyCode===27&&(this.isOpenSucker=!1,this.isSucking=!1,this.$emit("openSucker",!1),document.removeEventListener("keydown",this.keydownHandler),document.removeEventListener("mousemove",this.mousemoveHandler),document.removeEventListener("mouseup",this.mousemoveHandler),this.suckerPreview&&(document.body.removeChild(this.suckerPreview),this.suckerPreview=null))},mousemoveHandler(t){const{clientX:n,clientY:o}=t,{top:i,left:d,width:a,height:u}=this.suckerCanvas.getBoundingClientRect(),m=n-d,f=o-i,y=this.suckerCanvas.getContext("2d").getImageData(Math.min(m,a-1),Math.min(f,u-1),1,1);let[E,w,S,x]=y.data;x=parseFloat((x/255).toFixed(2));const N=this.suckerPreview.style;Object.assign(N,{position:"absolute",left:n+20+"px",top:o-36+"px",width:"24px",height:"24px",borderRadius:"50%",border:"2px s
6olid #fff",boxShadow:"0 0 8px 0 rgba(0, 0, 0, 0.16)",background:`rgba(${E}, ${w}, ${S}, ${x})`,zIndex:95}),n>=this.suckerArea[0]&&o>=this.suckerArea[1]&&n<=this.suckerArea[2]&&o<=this.suckerArea[3]?N.display="":N.display="none"},suckColor(t){t&&t.tagName!=="CANVAS"||(this.suckerPreview=document.createElement("div"),document.body.appendChild(this.suckerPreview),document.addEventListener("mousemove",this.mousemoveHandler),document.addEventListener("mouseup",this.mousemoveHandler),t.addEventListener("click",n=>{const{clientX:o,clientY:i}=n,{top:d,left:a,width:u,height:m}=t.getBoundingClientRect(),f=o-a,p=i-d,E=t.getContext("2d").getImageData(Math.min(f,u-1),Math.min(p,m-1),1,1);let[w,S,x,N]=E.data;N=parseFloat((N/255).toFixed(2)),this.$emit("selectSucker",{r:w,g:S,b:x,a:N})}))}}},Xi={key:1,class:"sucker",viewBox:"-16 -16 68 68",xmlns:"http://www.w3.org/2000/svg",stroke:"#9099a4"};function Zi(t,n,o,i,d,a){return r(),c("div",null,[d.isSucking?V("",!0):(r(),c("svg",{key:0,class:re([{active:d.isOpenSucker},"sucker"]),xmlns:"http://www.w3.org/2000/svg",viewBox:"-12 -12 48 48",onClick:n[0]||(n[0]=(...u)=>a.openSucker&&a.openSucker(...u))},[...n[1]||(n[1]=[s("path",{d:"M13.1,8.2l5.6,5.6c0.4,0.4,0.5,1.1,0.1,1.5s-1.1,0.5-1.5,0.1c0,0-0.1,0-0.1-0.1l-1.4-1.4l-7.7,7.7C7.9,21.9,7.6,22,7.3,22H3.1C2.5,22,2,21.5,2,20.9l0,0v-4.2c0-0.3,0.1-0.6,0.3-0.8l5.8-5.8C8.5,9.7,9.2,9.6,9.7,10s0.5,1.1,0.1,1.5c0,0,0,0.1-0.1,0.1l-5.5,5.5v2.7h2.7l7.4-7.4L8.7,6.8c-0.5-0.4-0.5-1-0.1-1.5s1.1-0.5,1.5-0.1c0,0,0.1,0,0.1,0.1l1.4,1.4l3.5-3.5c1.6-1.6,4.1-1.6,5.8-0.1c1.6,1.6,1.6,4.1,0.1,5.8L20.9,9l-3.6,3.6c-0.4,0.4-1.1,0.5-1.5,0.1"},null,-1)])],2)),d.isSucking?(r(),c("svg",Xi,[...n[2]||(n[2]=[xn('<g fill="none" fill-rule="evenodd"><g transform="translate(1 1)" stroke-width="4"><circle stroke-opacity=".5" cx="18" cy="18" r="18"></circle><path d="M36 18c0-9.94-8.06-18-18-18"><animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur="1s" repeatCount="indefinite"></animateTransform></path></g></g>',1)])])):V("",!0)])}const es=Be(Qi,[["render",Zi]]),ts={props:{name:{type:String,default:""},color:{type:String,default:""}},computed:{modelColor:{get(){return this.color},set(t){this.$emit("inputColor",t)}}}},ns={class:"color-type"},os={class:"name"};function is(t,n,o,i,d,a){return r(),c("div",ns,[s("span",os,k(o.name),1),q(s("input",{"onUpdate:modelValue":n[0]||(n[0]=u=>a.modelColor=u),class:"value"},null,512),[[to,a.modelColor]])])}const ss=Be(ts,[["render",is]]),ls={mixins:[yt],props:{color:{type:String,default:"#000000"},colorsDefault:{type:Array,default:()=>[]},colorsHistoryKey:{type:String,default:""}},data(){return{imgAlphaBase64:"",colorsHistory:JSON.parse(localStorage.getItem(this.colorsHistoryKey))||[]}},created(){this.imgAlphaBase64=this.createAlphaSquare(4).toDataURL()},destroyed(){this.setColorsHistory(this.color)},methods:{selectColor(t){this.$emit("selectColor",t)},setColorsHistory(t){if(!t)return;const n=this.colorsHistory,o=n.indexOf(t);o>=0&&n.splice(o,1),n.length>=8&&(n.length=7),n.unshift(t),this.colorsHistory=n,localStorage.setItem(this.colorsHistoryKey,JSON.stringify(n))}}},as={class:"colors"},rs=["onClick"],ds={key:0,class:"colors history"},us=["onClick"];function cs(t,n,o,i,d,a){return r(),c("div",null,[s("ul",as,[(r(!0),c(ue,null,xe(o.colorsDefault,u=>(r(),c("li",{key:u,class:"item",onClick:m=>a.selectColor(u)},[s("div",{style:De({background:`url(${d.imgAlphaBase64})`}),class:"alpha"},null,4),s("div",{style:De({background:u}),class:"color"},null,4)],8,rs))),128))]),d.colorsHistory.length?(r(),c("ul",ds,[(r(!0),c(ue,null,xe(d.colorsHistory,u=>(r(),c("li",{key:u,class:"item",onClick:m=>a.selectColor(u)},[s("div",{style:De({background:`url(${d.imgAlphaBase64})`}),class:"alpha"},null,4),s("div",{style:De({background:u}),class:"color"},null,4)],8,us))),128))])):V("",!0)])}const ms=Be(ls,[["render",cs]]),fs={components:{Saturation:Pi,Hue:Ui,Alpha:Wi,Preview:Ji,Sucker:es,Box:ss,Colors:ms},mixins:[yt],props:{color:{type:String,default:"#000000"},theme:{type:String,default:"dark"},suckerHide:{type:Boolean,default:!0},suckerCanvas:{type:null,default:null},suckerArea:{type:Array,default:()=>[]},colorsDefault:{type:Array,default:()=>["#000000","#FFFFFF","#FF1900","#F47365","#FFB243","#FFE623","#6EFF2A","#1BC7B1","#00BEFF","#2E81FF","#5D61FF","#FF89CF","#FC3CAD","#BF3DCE","#8E00A7","rgba(0,0,0,0)"]}
6,colorsHistoryKey:{type:String,default:"vue-colorpicker-history"}},data(){return{hueWidth:15,hueHeight:152,previewHeight:30,modelRgba:"",modelHex:"",r:0,g:0,b:0,a:1,h:0,s:0,v:0}},computed:{isLightTheme(){return this.theme==="light"},totalWidth(){return this.hueHeight+(this.hueWidth+8)*2},previewWidth(){return this.totalWidth-(this.suckerHide?0:this.previewHeight)},rgba(){return{r:this.r,g:this.g,b:this.b,a:this.a}},hsv(){return{h:this.h,s:this.s,v:this.v}},rgbString(){return`rgb(${this.r}, ${this.g}, ${this.b})`},rgbaStringShort(){return`${this.r}, ${this.g}, ${this.b}, ${this.a}`},rgbaString(){return`rgba(${this.rgbaStringShort})`},hexString(){return this.rgb2hex(this.rgba,!0)}},created(){Object.assign(this,this.setColorValue(this.color)),this.setText(),this.$watch("rgba",()=>{this.$emit("changeColor",{rgba:this.rgba,hsv:this.hsv,hex:this.hexString})})},methods:{selectSaturation(t){const{r:n,g:o,b:i,h:d,s:a,v:u}=this.setColorValue(t);Object.assign(this,{r:n,g:o,b:i,h:d,s:a,v:u}),this.setText()},selectHue(t){const{r:n,g:o,b:i,h:d,s:a,v:u}=this.setColorValue(t);Object.assign(this,{r:n,g:o,b:i,h:d,s:a,v:u}),this.setText(),this.$nextTick(()=>{this.$refs.saturation.renderColor(),this.$refs.saturation.renderSlide()})},selectAlpha(t){this.a=t,this.setText()},inputHex(t){if(this.modelHex=t,!ze(t).isValid())return;const{r:n,g:o,b:i,a:d,h:a,s:u,v:m}=this.setColorValue(t);Object.assign(this,{r:n,g:o,b:i,a:d,h:a,s:u,v:m}),this.modelRgba=this.rgbaStringShort,this.$nextTick(()=>{this.$refs.saturation.renderColor(),this.$refs.saturation.renderSlide(),this.$refs.hue.renderSlide()})},inputRgba(t){this.modelRgba=t;const n=`rgba(${t})`;if(!ze(n).isValid())return;const{r:o,g:i,b:d,a,h:u,s:m,v:f}=this.setColorValue(n);Object.assign(this,{r:o,g:i,b:d,a,h:u,s:m,v:f}),this.modelHex=this.hexString,this.$nextTick(()=>{this.$refs.saturation.renderColor(),this.$refs.saturation.renderSlide(),this.$refs.hue.renderSlide()})},setText(){this.modelHex=this.hexString,this.modelRgba=this.rgbaStringShort},openSucker(t){this.$emit("openSucker",t)},selectSucker(t){const{r:n,g:o,b:i,a:d,h:a,s:u,v:m}=this.setColorValue(t);Object.assign(this,{r:n,g:o,b:i,a:d,h:a,s:u,v:m}),this.setText(),this.$nextTick(()=>{this.$refs.saturation.renderColor(),this.$refs.saturation.renderSlide(),this.$refs.hue.renderSlide()})},selectColor(t){const{r:n,g:o,b:i,a:d,h:a,s:u,v:m}=this.setColorValue(t);Object.assign(this,{r:n,g:o,b:i,a:d,h:a,s:u,v:m}),this.setText(),this.$nextTick(()=>{this.$refs.saturation.renderColor(),this.$refs.saturation.renderSlide(),this.$refs.hue.renderSlide()})}}},ps={class:"color-set"};function gs(t,n,o,i,d,a){const u=ye("Saturation"),m=ye("Hue"),f=ye("Alpha"),p=ye("Preview"),y=ye("Sucker"),E=ye("Box"),w=ye("Colors");return r(),c("div",{class:re(["hu-color-picker",{light:a.isLightTheme}]),style:De({width:a.totalWidth+"px"})},[s("div",ps,[C(u,{ref:"saturation",color:a.rgbString,hsv:a.hsv,size:d.hueHeight,onSelectSaturation:a.selectSaturation},null,8,["color","hsv","size","onSelectSaturation"]),C(m,{ref:"hue",hsv:a.hsv,width:d.hueWidth,height:d.hueHeight,onSelectHue:a.selectHue},null,8,["hsv","width","height","onSelectHue"]),C(f,{ref:"alpha",color:a.rgbString,rgba:a.rgba,width:d.hueWidth,height:d.hueHeight,onSelectAlpha:a.selectAlpha},null,8,["color","rgba","width","height","onSelectAlpha"])]),s("div",{style:De({height:d.previewHeight+"px"}),class:"color-show"},[C(p,{color:a.rgbaString,width:a.previewWidth,height:d.previewHeight},null,8,["color","width","height"]),o.suckerHide?V("",!0):(r(),J(y,{key:0,"sucker-canvas":o.suckerCanvas,"sucker-area":o.suckerArea,onOpenSucker:a.openSucker,onSelectSucker:a.selectSucker},null,8,["sucker-canvas","sucker-area","onOpenSucker","onSelectSucker"]))],4),C(E,{name:"HEX",color:d.modelHex,onInputColor:a.inputHex},null,8,["color","onInputColor"]),C(E,{name:"RGBA",color:d.modelRgba,onInputColor:a.inputRgba},null,8,["color","onInputColor"]),C(w,{color:a.rgbaString,"colors-default":o.colorsDefault,"colors-history-key":o.colorsHistoryKey,onSelectColor:a.selectColor},null,8,["color","colors-default","colors-history-key","onSelectColor"])],6)}const vs=Be(fs,[["render",gs]]),hs={class:"color-picker-wrapper"},ys={__name:"ColorDropdown",props:{modelValue:{type:String,required:!0}},emits:["update:modelValue","change"],setup(t,{emit:n}){const o=t,i=n,d=F({get(){return o.modelValue},set(u){i("update:modelValue",u)}}),a=u=>{i("change",u),i("update:modelValue",u.hex)};return(u,m)=>{const f=ye("o-button"),p=ye("o-dropdown");return r(),J(p,{modelValue:d.value,"onUpdate:modelValue":m[1]||(m[1]=y=>d.value=y),"aria-role":"list",position:"bottom-right","menu-class":"overflow-hidden"},{trigger:P(()=>[C(f,{variant:"dropdown-select btn-sm",class:"!pl-1.5 pr-2"},{default:P(()=>[s("div",{class:"w-5 h-5 border boder-neutral-lightest shadow-sm rounded-full",style:De({"background-color":t.modelValue})},null,4),m[2]||(m[2]=s("i",{class:"oi oi-angle-down"},null,-1))]),_:1})]),default:P(()=>[s("div",hs,[C(e(vs),{theme:"light",color:t.modelValue,"sucker-hide":!0,onChangeColor:m[0]||(m[0]=y=>a(y))},null,8,["color"])])]),_:1},8,["modelValue"])}}},bs={key:0,class:"w-full h-9 rounded-md animate-pulse bg-neutral-lighter"},_s={class:"flex flex-row items-center gap-2"},ws={key:0,class:"text-neutral"},xs={__name:"FontsDropdown",props:{modelValue:{type:String,default:"Arial"}},emits:["update:modelValue"],setup(t,{emit:n}){const o=t,i=n,d=Z([]),a=F({get(){return o.modelValue},set(f){i("update:modelValue",f)}}),u=f=>{i("update:modelValue",f)},m={mounted(f,{value:p}){p.source!=="Google Fonts"||typeof IntersectionObserver>"u"||(f._previewFontObserver=new IntersectionObserver(y=>{y.some(E=>E.isIntersecting)&&(Ve.loadGoogleFont(p.name),f._previewFontObserver.disconnect())}),f._previewFontObserver.observe(f))},unmounted(f){f._previewFontObserver?.disconnect()}};return nt(async()=>{try{d.value=(await he(async()=>{const{default:f}=await import("./D4v3kQNg.js");return{default:f}},[],import.meta.url)).default}catch(f){console.error("[FontsDropdown] failed to load fonts util:",f)}}),(f,p)=>{const y=ye("o-button"),E=ye("o-dropdown-item"),w=ye("o-dropdown");return r(),c("div",null,[e(d).length===0?(r(),c("div",bs)):V("",!0),e(d).length>0?(r(),J(w,{key:1,modelValue:e(a),"onUpdate:modelValue":p[0]||(p[0]=S=>Ce(a)?a.value=S:null),"aria-role":"list",scrollable:"","max-height":200,"root-class":"w-full relative","menu-class":"w-full",selectable:"",onChange:u},{trigger:P(()=>[C(y,{variant:"dropdown-select"},{default:P(()=>[s("div",_s,k(t.modelValue),1),p[1]||(p[1]=s("i",{class:"oi oi-angle-down"},null,-1))]),_:1})]),default:P(()=>[(r(!0),c(ue,null,xe(e(d),(S,x)=>(r(),J(E,{key:`view-${x}`,value:S.name,"aria-role":"listitem"},{default:P(()=>[q((r(),c("div",{style:De({fontFamily:e(Rt)(S.name)})},[se(k(S.name)+" ",1),S.source!==""?(r(),c("span",ws,"("+k(S.source)+")",1)):V("",!0)],4)),[[m,S]])]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])):V("",!0)])}}},Kn=kn("themes",{state:()=>({themes:[]}),getters:{getThemes:t=>t.themes,getCurrentTheme:t=>{const o=Ae().getCurrentThemeId;return t.themes.find(i=>i.id===o)},getCurrentThemeId(){return Ae().getCurrentThemeId}},actions:{async retrieveThemes(t){if(!no(this.themes))return;const o=await dt().find(t);this.setThemes(o)},async updateTheme({id:t,name:n,fontName:o,answerTextColor:i,buttonBackgroun
6dColor:d,buttonTextColor:a,fieldTextColor:u,pageBackgroundColor:m,fontSizeScale:f,buttonBorderRadius:p}){const E=await dt().update(t,{name:n,fontName:o,answerTextColor:i,buttonBackgroundColor:d,buttonTextColor:a,fieldTextColor:u,pageBackgroundColor:m,fontSizeScale:f,buttonBorderRadius:p});return this.updateThemeInStore(E),E},async addTheme(t){const o=await dt().create(t,{name:"My theme",fontName:"Arial",fieldTextColor:"#000000",answerTextColor:"#7f7f7f",buttonBackgroundColor:"#000000",buttonTextColor:"#ffffff",pageBackgroundColor:"#ffffff",fontSizeScale:"md",buttonBorderRadius:"regular"});return this.addThemeToStore(o),o},async duplicateTheme({workspaceId:t,cloneThemeId:n}){const i=await dt().duplicate(t,n);return this.addThemeToStore(i),i},async deleteTheme(t){await dt().delete(t),this.deleteThemeFromStore(t)},setThemes(t){this.themes=t},addThemeToStore(t){this.themes.push(t)},updateThemeInStore(t){const n=this.themes.findIndex(o=>o.id===t.id);n!==-1&&this.themes.splice(n,1,t)},deleteThemeFromStore(t){const n=this.themes.findIndex(o=>o.id===t);n!==-1&&this.themes.splice(n,1)},resetState(){this.themes=[]}}}),ks={key:0,class:"flex flex-col gap-4"},$s={class:"flex items-center"},Fs={class:"flex flex-col gap-2"},Es={class:"subheading-sm"},Ss={class:"flex flex-col gap-0.5"},Ts={class:"field-label"},Cs={class:"btn-group p-1 gap-1"},Is={class:"flex flex-col gap-2"},Ls={class:"subheading-sm"},As={class:"flex flex-col gap-2"},Vs={class:"subheading-sm"},Ds={class:"btn-group p-1 gap-1"},Rs={key:0,class:"sticky bottom-0 flex flex-col gap-4 bg-neutral-50 pb-2"},Os={class:"w-full flex gap-4"},Ns={__name:"TheThemeEditor",props:{theme:{type:Object,required:!0}},emits:["close"],setup(t,{emit:n}){const o=t,i=n,{t:d}=Re(),a=Ae(),u=Kn(),m=rt(),f=$n(),p=Z(!1),y=Z(null),E=Z(null),w=F(()=>a.getThemeFontName),S=F(()=>a.getThemeFieldTextColor),x=F(()=>a.getThemeAnswerTextColor),N=F(()=>a.getThemeButtonBackgroundColor),I=F(()=>a.getThemeButtonTextColor),R=F(()=>a.getThemePageBackgroundColor),T=F(()=>a.getThemeFontSizeScale),ce=F(()=>a.getThemeButtonBorderRadius),be=F(()=>a.getFormTheme);He(()=>o.theme,B=>{B&&(E.value={...B},y.value=E.value.name,a.previewThemeProperty({key:"fontSizeScale",value:B.fontSizeScale}),a.previewThemeProperty({key:"buttonBorderRadius",value:B.buttonBorderRadius}),Ve.init(E.value))},{immediate:!0});function ae(B){p.value=!0;let K=B.trim();K===""&&(K="Untitled theme"),y.value=K}function W({key:B,value:K}){p.value=!0,a.previewThemeProperty({key:B,value:K})}function j(B){W({key:"fontName",value:B})}function D(B,K){W({key:K,value:B.hex})}function L(B){W({key:"fontSizeScale",value:B})}function M(B){W({key:"buttonBorderRadius",value:B})}function Q(){if(p.value){const B={title:d("components.formEdit.theThemeEditor.title"),message:d("components.formEdit.theThemeEditor.message"),noButtonText:d("components.formEdit.theThemeEditor.noButtonText"),yesButtonText:d("components.formEdit.theThemeEditor.yesButtonText")};m.confirm(B,()=>{X(),i("close")})}else i("close")}function X(){y.value=E.value.name,a.revertThemePreviewChanges(E.value),p.value=!1}const ie=Ye();async function pe(){const B={...be.value,name:y.value};ie.execute({resourceKey:`theme:${B.id}`,actionKey:"actions.updateTheme",execute:async()=>{await u.updateTheme(B),p.value=!1,i("close")},rollback:()=>{X()}})}return(B,K)=>{const ne=Gn,we=ys,ve=ye("o-field"),G=xs,U=Ie("tooltip");return e(y)!==null?(r(),c("div",ks,[s("div",$s,[q((r(),c("button",{class:"btn btn-sm btn-action",onClick:Q},[...K[11]||(K[11]=[s("i",{class:"oi oi-angle-left oi-16"},null,-1)])])),[[U,e(d)("components.formEdit.theThemeEditor.goBack")]]),C(ne,{value:e(y),"empty-value-placeholder":e(d)("components.formEdit.theThemeEditor.untitledTheme"),"edit-placeholder":e(d)("components.formEdit.theThemeEditor.themeName"),variant:"sm","read-mode-class":"w-full","edit-mode-class":"w-full",onInput:ae},null,8,["value","empty-value-placeholder","edit-placeholder"])]),K[18]||(K[18]=s("div",{class:"h-1 border-t-2 border-neutral-lightest"},null,-1)),s("div",Fs,[s("div",Es,k(e(d)("components.formEdit.theThemeEditor.page")),1)]),C(ve,{label:e(d)(e(Ve).properties.pageBackgroun
6dColor.name),class:"flex justify-between items-center"},{default:P(()=>[C(we,{"model-value":e(R),onChange:K[0]||(K[0]=oe=>D(oe,e(Ve).properties.pageBackgroundColor.key))},null,8,["model-value"])]),_:1},8,["label"]),s("div",Ss,[s("div",Ts,k(e(d)("components.formEdit.theThemeEditor.font")),1),C(G,{"model-value":e(w),"onUpdate:modelValue":j},null,8,["model-value"])]),C(ve,{label:e(d)("components.formEdit.theThemeEditor.fontSize"),class:"flex justify-between items-center"},{default:P(()=>[s("div",Cs,[q((r(),c("button",{class:re(["btn btn-sm px-2 aspect-square",{"btn-active":e(T)==="sm"}]),onClick:K[1]||(K[1]=oe=>L("sm"))},[se(k(e(d)("components.formEdit.theThemeEditor.sm")),1)],2)),[[U,e(d)("components.formEdit.theThemeEditor.small")]]),q((r(),c("button",{class:re(["btn btn-sm px-2 aspect-square",{"btn-active":e(T)==="md"}]),onClick:K[2]||(K[2]=oe=>L("md"))},[se(k(e(d)("components.formEdit.theThemeEditor.md")),1)],2)),[[U,e(d)("components.formEdit.theThemeEditor.medium")]]),q((r(),c("button",{class:re(["btn btn-sm px-2 aspect-square",{"btn-active":e(T)==="lg"}]),onClick:K[3]||(K[3]=oe=>L("lg"))},[se(k(e(d)("components.formEdit.theThemeEditor.lg")),1)],2)),[[U,e(d)("components.formEdit.theThemeEditor.large")]])])]),_:1},8,["label"]),K[19]||(K[19]=s("div",{class:"h-1 border-t-2 border-neutral-lightest"},null,-1)),s("div",Is,[s("div",Ls,k(e(d)("components.formEdit.theThemeEditor.question")),1)]),C(ve,{label:e(d)(e(Ve).properties.fieldTextColor.name),class:"flex justify-between items-center"},{default:P(()=>[C(we,{"model-value":e(S),onChange:K[4]||(K[4]=oe=>D(oe,e(Ve).properties.fieldTextColor.key))},null,8,["model-value"])]),_:1},8,["label"]),C(ve,{label:e(d)(e(Ve).properties.answerTextColor.name),class:"flex justify-between items-center"},{default:P(()=>[C(we,{"model-value":e(x),onChange:K[5]||(K[5]=oe=>D(oe,e(Ve).properties.answerTextColor.key))},null,8,["model-value"])]),_:1},8,["label"]),K[20]||(K[20]=s("div",{class:"h-1 border-t-2 border-neutral-lightest"},null,-1)),s("div",As,[s("div",Vs,k(e(d)("components.formEdit.theThemeEditor.button")),1)]),C(ve,{label:e(d)(e(Ve).properties.buttonBackgroundColor.name),class:"flex justify-between items-center"},{default:P(()=>[C(we,{"model-value":e(N),onChange:K[6]||(K[6]=oe=>D(oe,e(Ve).properties.buttonBackgroundColor.key))},null,8,["model-value"])]),_:1},8,["label"]),C(ve,{label:e(d)(e(Ve).properties.buttonTextColor.name),class:"flex justify-between items-center"},{default:P(()=>[C(we,{"model-value":e(I),onChange:K[7]||(K[7]=oe=>D(oe,e(Ve).properties.buttonTextColor.key))},null,8,["model-value"])]),_:1},8,["label"]),C(ve,{label:e(d)("components.formEdit.theThemeEditor.buttonBorderRadius"),class:"flex justify-between items-center"},{default:P(()=>[s("div",Ds,[s("button",{class:re(["btn btn-sm px-2 items-start pt-1 flex text-sm",{"btn-active":e(ce)==="flat"}]),onClick:K[8]||(K[8]=oe=>M("flat"))},[...K[12]||(K[12]=[s("i",{class:"oi oi-corner-flat oi-20"},null,-1)])],2),s("button",{class:re(["btn btn-sm px-2 items-start pt-1 flex text-sm",{"btn-active":e(ce)==="regular"}]),onClick:K[9]||(K[9]=oe=>M("regular"))},[...K[13]||(K[13]=[s("i",{class:"oi oi-corner-regular oi-20"},null,-1)])],2),s("button",{class:re(["btn btn-sm px-2 items-start pt-1 flex text-sm",{"btn-active":e(ce)==="full"}]),onClick:K[10]||(K[10]=oe=>M("full"))},[...K[14]||(K[14]=[s("i",{class:"oi oi-corner-full oi-20"},null,-1)])],2)])]),_:1},8,["label"]),e(p)?(r(),c("div",Rs,[K[17]||(K[17]=s("div",{class:"h-1 border-t-2 border-neutral-lightest"},null,-1)),s("div",Os,[q((r(),c("button",{class:"btn btn-sm btn-secondary w-full",onClick:X},[K[15]||(K[15]=s("i",{class:"oi oi-check-2 oi-16 mr-2"},null,-1)),se(" "+k(e(d)("components.formEdit.theThemeEditor.revert")),1)])),[[U,e(d)("components.formEdit.theThemeEditor.discardChangesTooltip")]]),q((r(),c("button",{class:"btn btn-sm btn-primary w-full",onClick:pe},[K[16]||(K[16]=s("i",{class:"oi oi-check-2 oi-16 mr-2"},null,-1)),se(k(e(f).isLoading?e(d)("common.state.saving"):e(d)("common.action.save")),1)])),[[U,e(d)("components.formEdit.theThemeEditor.saveChangesTooltip")]])])])):V("",!0)])):V("",!0)}}},Ps={class:"text-sm p-2 flex items-center gap-2 justify-between rounded-b-lg h-10"},Bs={class:"bg-white absolute right-2 flex-row gap-1 hidden group-hover:flex"},Ms=["disabled"],js=["disabled"],Us=["disabled"],Ks={__name:"ThemeListItem",props:{theme:{type:Object,required:!0},selected:{type:Boolean,required:!0}},emits:["select","edit","duplicate","delete"],setup(t,{emit:n}){const o=t,i=n,d=()=>{i("select",o.theme.id)},a=()=>{o.theme.workspaceId!==null&&i("edit",o.theme.id)},u=()=>{i("duplicate",o.theme.id)},m=()=>{o.theme.workspaceId!==null&&i("delete",o.theme.id)};return(f,p)=>{const y=Ie("tooltip");return r(),c("a",{class:re(["group relative flex flex-col shadow-sm rounded-lg cursor-pointer bg-white border border-neutral-lighter hover:border-neutral-light hover:shadow-lg",{"cursor-default border-white ring-2 ring-primary hover:border-white":t.selected}])},[q((r(),c("div",{class:"p-4 rounded-t-lg",style:De({"background-color":t.theme.pageBackgroun
6dColor}),onClick:d},[s("div",{class:"text-base",style:De({color:t.theme.fieldTextColor,"font-family":e(Rt)(t.theme.fontName)})},k(f.$t("components.formEdit.themeListItem.question")),5),s("div",{class:"text-sm",style:De({color:t.theme.answerTextColor,"font-family":e(Rt)(t.theme.fontName)})},k(f.$t("components.formEdit.themeListItem.answer")),5),s("div",{class:"w-16 h-4 rounded-sm mt-2 mb-2",style:De({"background-color":t.theme.buttonBackgroundColor})},null,4)],4)),[[y,t.selected?"":f.$t("components.formEdit.themeListItem.clickToSelect")]]),s("div",Ps,[s("div",{class:"pl-2 w-full",onClick:d},k(t.theme.name),1),s("div",Bs,[q((r(),c("div",null,[s("button",{disabled:t.selected,class:"btn btn-sm btn-action w-full disabled:opacity-50 disabled:cursor-not-allowed",onClick:d},[...p[0]||(p[0]=[s("i",{class:"oi oi-check-circle-1 oi-16"},null,-1)])],8,Ms)])),[[y,t.selected?f.$t("components.formEdit.themeListItem.thisTheme"):f.$t("components.formEdit.themeListItem.selectThisTheme")]]),q((r(),c("button",{class:"btn btn-sm btn-action",onClick:u},[...p[1]||(p[1]=[s("i",{class:"oi oi-copy-paste oi-16"},null,-1)])])),[[y,f.$t("components.formEdit.themeListItem.duplicate")]]),q((r(),c("button",{class:re([{"opacity-50 cursor-not-allowed":t.theme.workspaceId===null},"btn btn-sm btn-action disabled:opacity-50 disabled:cursor-not-allowed"]),disabled:t.theme.workspaceId===null,onClick:a},[...p[2]||(p[2]=[s("i",{class:"oi oi-pencil oi-16"},null,-1)])],10,js)),[[y,t.theme.workspaceId===null?f.$t("components.formEdit.themeListItem.cannotEditDefaultTheme"):f.$t("components.formEdit.themeListItem.editFont")]]),q((r(),c("div",null,[s("button",{class:re([{"opacity-50 cursor-not-allowed":t.theme.workspaceId===null},"btn btn-sm btn-action w-full disabled:opacity-50 disabled:cursor-not-allowed"]),disabled:t.selected||t.theme.workspaceId===null,onClick:m},[...p[3]||(p[3]=[s("i",{class:"oi oi-bin oi-16"},null,-1)])],10,Us)])),[[y,t.theme.workspaceId===null?f.$t("components.formEdit.themeListItem.cannotDeleteDefaultTheme"):t.selected?f.$t("components.formEdit.themeListItem.thisThemeIsBeing"):f.$t("components.formEdit.themeListItem.deleteThisTheme")]])])])],2)}}},Hs={class:"flex flex-col gap-4 pb-4"},qs={class:"flex flex-col gap-4 sticky top-0 z-10 bg-white"},Ws={class:"flex items-center gap-2 justify-between"},zs={class:"subheading-sm mb-0"},Gs={class:"px-2"},Js={class:"btn-group flex justify-center"},Ys={key:0,class:"flex flex-col gap-4"},Qs={__name:"TheThemeList",setup(t){const{t:n}=Re(),o=Ae(),i=Kn(),d=gt(),a=rt(),u=$n(),m=Ye(),f=Z("list"),p=Z("myThemes"),y=F(()=>i.themes),E=F(()=>o.form.workspaceId),w=F(()=>o.getCurrentThemeId),S=F(()=>o.getFormTheme),x=F(()=>f.value==="edit"&&!!S.value),N=F(()=>y.value.filter(j=>j.workspaceId!==null)),I=F(()=>y.value.filter(j=>j.workspaceId===null));nt(async()=>{try{await i.retrieveThemes(E.value);for(let j=0;j<y.value.length;j++)Ve.loadGoogleFont(y.value[j].fontName)}catch(j){d.error(j)}}),He(w,()=>{const j=o.getFormTheme;j&&Ve.init(j)});function R(j){p.value=j}function T(j){const D=o.getFormTheme,L=y.value.find(M=>M.id===j);Ve.init(L),o.updateFormTheme(L),m.execute({resourceKey:`form:${o.form.id}:theme`,actionKey:"actions.updateTheme",execute:()=>o.persistFormThemeAsync(L),rollback:()=>{D&&(Ve.init(D),o.updateFormTheme(D)),f.value="list"}})}function ce(j){T(j),f.value="edit"}function be(j){const D=w.value;m.execute({resourceKey:`theme:duplicate:${j}`,actionKey:"actions.duplicateTheme",execute:async()=>{const L=await i.duplicateTheme({workspaceId:E.value,cloneThemeId:j});await o.updateFormThemeAsync(L),f.value="edit"},rollback:()=>{const L=y.value.find(M=>M.id===D);L&&Ve.init(L)}})}function ae(){const j=w.value;m.execute({resourceKey:`theme:add:${Date.now()}`,actionKey:"actions.addTheme",execute:async()=>{const D=await i.addTheme(E.value);await o.updateFormThemeAsync(D),f.value="edit"},rollback:()=>{const D=y.value.find(L=>L.id===j);D&&Ve.init(D)}})}function W(j){const D=y.value.find(L=>L.id===j);a.confirmDeletion(n("components.formEdit.theThemeList.confirmDeletion",{name:D.name}),()=>{m.execute({resourceKey:`theme:delete:${j}`,actionKey:"actions.deleteTheme",execute:()=>i.deleteTheme(j)})})}return(j,D)=>{const L=Ns,M=Ks,Q=Ie("tooltip");return r(),c("div",Hs,[C(kt,{name:"fade",duration:"300"},{default:P(()=>[e(x)?(r(),J(L,{key:0,theme:e(S),onClose:D[0]||(D[0]=X=>f.value="list")},null,8,["theme"])):V("",!0)]),_:1}),e(x)?V("",!0):(r(),c(ue,{key:0},[s("div",qs,[s("div",Ws,[s("h3",zs,k(e(n)("components.formEdit.theThemeList.themes")),1),q((r(),c("button",{class:"btn btn-xs btn-primary",onClick:ae},[...D[3]||(D[3]=[s("i",{class:"oi oi-plus"},null,-1)])])),[[Q,e(n)("components.formEdit.theThemeList.newTheme")]])]),s("div",Gs,[s("div",Js,[s("button",{class:re(["btn btn-sm flex-1 flex items-center justify-center",{"btn-active":e(p)==="myThemes"}]),onClick:D[1]||(D[1]=X=>R("myThemes"))},[s("span",null,k(e(n)("components.formEdit.theThemeList.myThemes")),1)],2),s("button",{class:re(["btn btn-sm flex-1 flex items-center justify-center",{"btn-active":e(p)==="gallery"}]),onClick:D[2]||(D[2]=X=>R("gallery"))},[s("span",null,k(e(n)("components.formEdit.theThemeList.gallery")),1)],2)])])]),e(u).isLoading?(r(),c(ue,{key:0},xe(12,X=>s("div",{key:X,class:"flex flex-col shadow-sm rounded-lg overflow-hidden cursor-pointer bg-white border border-neutral-lighter"},[...D[4]||(D[4]=[xn('<div class="p-4"><div class="animate-pulse flex flex-col w-full gap-2">
6<div class="flex h-6 bg-neutral-lightest rounded w-24"></div><div class="flex h-5 bg-neutral-lightest rounded w-16"></div><div class="flex h-5 bg-neutral-lightest rounded w-20"></div></div></div><div class="animate-pulse p-4"><div class="h-5 bg-neutral-lightest rounded w-3/4"></div></div>',2)])])),64)):(r(),J(kt,{key:1,name:"slide-left"},{default:P(()=>[e(x)?V("",!0):(r(),c("div",Ys,[e(p)==="myThemes"?(r(!0),c(ue,{key:0},xe(e(N),(X,ie)=>(r(),J(M,{key:ie,theme:X,selected:X.id===e(w),onSelect:pe=>T(X.id),onDuplicate:pe=>be(X.id),onEdit:pe=>ce(X.id),onDelete:pe=>W(X.id)},null,8,["theme","selected","onSelect","onDuplicate","onEdit","onDelete"]))),128)):V("",!0),e(p)==="gallery"?(r(!0),c(ue,{key:1},xe(e(I),(X,ie)=>(r(),J(M,{key:ie,theme:X,selected:X.id===e(w),onSelect:pe=>T(X.id),onDuplicate:pe=>be(X.id),onEdit:pe=>ce(X.id),onDelete:pe=>W(X.id)},null,8,["theme","selected","onSelect","onDuplicate","onEdit","onDelete"]))),128)):V("",!0)]))]),_:1}))],64))])}}},Xs={class:"flex items-center gap-2 w-full"},Zs={class:"w-ful flex items-center gap-2"},el={__name:"FormSettingSwitch",props:{setting:{type:String,required:!0},name:{type:String,required:!0},disabled:{type:Boolean,default:!1},help:{type:String,default:""},defaultValue:{type:Boolean,default:!1}},emits:["update","input"],setup(t,{emit:n}){const o=t,i=n,d=Ae(),{t:a}=Re(),u=Ye(),m=Z(!1),f=F(()=>d.form),p=F(()=>{const S=o.help?"<br><br>":"";return o.disabled?`${o.help}${S}<b>${a("components.formEdit.fieldSettingSwitch.upgradeYourPlan")}</b>`:o.help});function y(S,x){return f.value?.settings?f.value.settings[S]??x:x}const E=F(()=>y(o.setting,o.defaultValue));He(E,S=>{m.value=S}),nt(()=>{m.value=y(o.setting,o.defaultValue)});function w(S){Ke(()=>{m.value=S}),u.execute({resourceKey:`form:${f.value.id}:setting:${o.setting}`,actionKey:"actions.updateSetting",execute:async()=>{await d.updateFormSetting({setting:o.setting,value:S}),i("update",S),i("input",S)},rollback:()=>{Ke(()=>{m.value=!S})}})}return(S,x)=>{const N=Dn,I=ye("o-switch"),R=Ie("tooltip");return r(),c("div",Xs,[t.disabled?(r(),J(N,{key:0})):V("",!0),e(f)?q((r(),J(I,{key:1,modelValue:e(m),"onUpdate:modelValue":x[0]||(x[0]=T=>Ce(m)?m.value=T:null),"root-class":"flex flex-1 justify-between items-center",position:"left",disabled:t.disabled,onInput:w},{default:P(()=>[s("div",Zs,k(t.name),1)]),_:1},8,["modelValue","disabled"])),[[R,{content:e(p),html:!0,popperClass:"tooltip-help"}]]):V("",!0)])}}},tl={key:0},nl={class:"text-sm text-neutral-dark text-center px-4"},ol={key:0,class:"text-xs text-neutral mt-1"},il=["accept"],sl={class:"text-sm text-neutral-dark mt-4 text-center"},ll={__name:"ImageUploader",props:{message:{type:String,default:"Click or drag image to upload"},hint:{type:String,default:""},loadingMessage:{type:String,default:"Uploading..."},loading:{type:Boolean,default:!1},acceptTypes:{type:String,default:"image/jpeg,image/png,image/jpg,image/gif,image/svg+xml,image/webp"},iconClass:{type:String,default:"oi oi-upload-bottom text-3xl"},heightClass:{type:String,default:"h-48"}},emits:["select","error"],setup(t,{expose:n,emit:o}){const i=t,d=o,a=Z(!1),u=Z(null),m=()=>{u.value?.click()},f=E=>{const w=E.target.files?.[0];w&&(y(w)?d("select",w):d("error","Invalid file type"),E.target.value="")},p=E=>{a.value=!1;const w=E.dataTransfer?.files;if(w&&w.length>0){const S=w[0];y(S)?d("select",S):d("error","Invalid file type")}},y=E=>i.acceptTypes.split(",").map(S=>S.trim()).some(S=>{if(S.endsWith("/*")){const x=S.replace("/*","");return E.type.startsWith(x)}return E.type===S});return n({triggerFileInput:m}),(E,w)=>{const S=Jt;return r(),c("div",null,[t.loading?(r(),c("div",{key:1,class:re(["rounded-lg border-2 border-dashed border-gray-500 flex flex-col justify-center items-center",t.heightClass])}
6,[C(S,{class:"self-center"}),s("p",sl,k(t.loadingMessage),1)],2)):(r(),c("div",tl,[s("div",{class:re(["rounded-lg border-2 border-dashed border-gray-400 hover:border-primary flex flex-col items-center justify-center cursor-pointer transition-colors bg-neutral-lightest hover:bg-neutral-lighter",[t.heightClass,{"border-primary bg-primary-lightest":e(a)}]]),onDragover:w[0]||(w[0]=tt(x=>a.value=!0,["prevent"])),onDragleave:w[1]||(w[1]=tt(x=>a.value=!1,["prevent"])),onDrop:tt(p,["prevent"]),onClick:m},[s("i",{class:re([t.iconClass,"text-neutral-dark mb-2"])},null,2),s("p",nl,k(t.message),1),t.hint?(r(),c("p",ol,k(t.hint),1)):V("",!0)],34),s("input",{ref_key:"fileInputRef",ref:u,type:"file",accept:t.acceptTypes,class:"hidden",onChange:f},null,40,il)]))])}}},ut=new Map,al=()=>({registerForm:(a,u)=>{a&&u&&ut.set(a,u)},unregisterForm:a=>{ut.delete(a)},submitForm:a=>{const u=ut.get(a);u?.value?.node&&u.value.node.submit()},resetForm:a=>{const u=ut.get(a);u?.value?.node&&u.value.node.reset()},getFormNode:a=>ut.get(a)?.value?.node}),rl={class:"modal-card modal-card--lg max-w-2xl"},dl={class:"modal-card-body !overflow-hidden flex flex-col min-h-0"},ul={key:0},cl={key:0,class:"gap-x-4 pt-2 columns-3"},ml={class:"mb-4 group grid bg-neutral-lighter opacity-90 rounded-md"},fl=["onClick"],pl=["onClick"],gl=["src"],vl={key:1},hl={class:"animate-pulse grid grid-cols-3 gap-3"},yl={class:"mb-4"},bl={key:0},_l={key:0,ref:"unsplashContainer",class:"grid grid-cols-3 gap-4 pt-2"},wl={class:"mb-4 group grid bg-neutral-lighter opacity-90 rounded-md"},xl=["onClick"],kl=["src","alt"],$l={key:0,class:"col-span-3 text-center py-4"},Fl={class:"mt-2 text-neutral-dark text-sm"},El={key:1},Sl={class:"animate-pulse grid grid-cols-3 gap-3"},Tl={key:2,class:"text-center text-neutral-dark py-8"},Cl={key:3,class:"text-center py-8"},Il={class:"mt-4 text-neutral-dark text-sm"},Ll={class:"modal-card-foot"},Hn={__name:"ModalAddMedia",props:{fieldId:{type:String,required:!1,default:""},onAdd:{type:Function,required:!0},fieldType:{type:String,required:!1,default:""}},emits:["close"],setup(t,{emit:n}){const o=t,i=n,d=gt(),a=rt(),u=Ae(),m=Ho(),f=Wo(),{registerForm:p,submitForm:y}=al(),{t:E}=Re(),w=Z(0),S=Z({image:"",video:""}),x=Z(""),N=Z(!1),I=Z(!1),R=Z(!1),T=Z(!1),ce=Z(u.form.workspaceId),be=Z([]),ae=Z([]),W=Z(""),j=Z(null),D=Z(1),L=Z(!0),M=Z(!1),Q=Z(""),X=Z(null),ie=Z(null);function pe(O){O!==w.value&&(w.value=O,O===4&&ae.value.length===0&&!W.value&&ke(),Ke(()=>{const A=document.querySelector(".modal-card-body");A&&(A.removeEventListener("scroll",_e),O===4&&A.addEventListener("scroll",_e))}))}nt(async()=>{try{R.value=!0;const O=await m.find(ce.value);be.value=O,N.value=be.value.length===0}catch{d.error(E("components.formEdit.modalAddMedia.errorFind"))}finally{R.value=!1}p("add-media-1",X),p("add-media-2",ie)});const B=()=>{y(`add-media-${w.value}`)},K=async()=>{try{const O=w.value===2?je.video:je.image;(w.value===1||w.value===2)&&(x.value=S.value[O]),o.onAdd(O,x.value),i("close")}catch(O){d.error(O.message||E("components.formEdit.modalAddMedia.errorSubmit"))}},ne=()=>{d.error(E("components.formEdit.modalAddMedia.errorMedia"))},we=async O=>{try{await a.confirmDeletion(E("components.formEdit.modalAddMedia.areYouSure"),async()=>{const A=be.value.findIndex(z=>z.id===O);await m.delete(O),A!==-1&&be.value.splice(A,1),N.value=be.value.length===0})}catch{d.error(E("components.formEdit.modalAddMedia.errorDelete"))}},ve=O=>{x.value=O},G=async O=>{try{I.value=!0;const A=new FormData;A.append("media",new Blob([O]));const z=await m.create(ce.value,A);console.log("processFile",z),x.value=z.url;const $e=je.image;o.onAdd($e,x.value),i("close")}catch(A){d.error(A.message==="Request failed with status code 422"?E("components.formEdit.modalAddMedia.errorMedia"):E("components.formEdit.modalAddMedia.errorUpload"))}finally{I.value=!1}},U=()=>{j.value&&clearTimeout(j.value),j.value=setTimeout(async()=>{if(!W.value||W.value.trim().length<2){ae.value=[],Ee();return}Ee(),Q.value=W.value.trim();try{T.value=!0;const O=await f.searchPhotos(Q.value,1,10);ae.value=O.results||[],L.value=O.total_pages>1}catch{d.error(E("components.formEdit.modalAddMedia.errorUnsplash")),ae.value=[]}finally{T.value=!1}},500)},oe=async O=>{try{try{O.links&&O.links.download_location&&await f.downloadPhoto(O.links.download_location)}catch(z){console.warn("Unsplash tracking failed:",z)}x.value=O.urls.regular||O.urls.full;const A=je.image;o.onAdd(A,x.value);try{const z=new FormData,Se=await(await fetch(x.value)).blob();z.append("media",Se),await m.create(ce.value,z)}catch(z){console.warn("Failed to save Unsplash image to database:",z)}i("close")}catch(A){console.error("Unsplash selection error:",A),d.error(E("components.formEdit.modalAddMedia.errorUnsplash"))}},ke=async()=>{try{T.value=!0,Ee();const O=await f.getFeaturedPhotos(1,10);ae.value=O||[],L.value=O&&O.length===10}catch{d.error(E("components.formEdit.modalAddMedia.errorUnsplash")),ae.value=[]}finally{T.value=!1}},Ee=()=>{D.value=1,L.value=!0,M.value=!1},_e=O=>{const{scrollTop:A,scrollHeight:z,clientHeight:$e}=O.target;A+$e>=z-100&&L.value&&!M.value&&!T.value&&le()},le=async()=>
6{if(!(!L.value||M.value))try{M.value=!0,D.value+=1;let O;if(Q.value){O=await f.searchPhotos(Q.value,D.value,10);const A=O.results||[];ae.value.push(...A),L.value=D.value<O.total_pages}else{const A=await f.getFeaturedPhotos(D.value,10);ae.value.push(...A),L.value=A&&A.length===10}}catch{d.error(E("components.formEdit.modalAddMedia.errorLoadingMore")),D.value-=1}finally{M.value=!1}};return(O,A)=>{const z=Rn,$e=ll,Se=ye("o-tab-item"),Le=On,Te=ht,Ue=Jt,Me=ye("o-tabs"),l=ye("o-button"),b=Ie("tooltip");return r(),c("div",rl,[C(e(Nn),{"config-file":"true"},{default:P(()=>[C(z,{title:O.$t("components.formEdit.modalAddMedia.addImage"),onClose:A[0]||(A[0]=_=>O.$emit("close"))},null,8,["title"]),s("div",dl,[C(Me,{"model-value":e(w),class:"flex-1 flex flex-col min-h-0","onUpdate:modelValue":pe},{default:P(()=>[C(Se,{value:0,label:O.$t("components.formEdit.modalAddMedia.imageUpload"),icon:"oi-upload-bottom"},{default:P(()=>[C($e,{message:O.$t("components.formEdit.modalAddMedia.selectImageToUpload"),hint:O.$t("components.formEdit.modalAddMedia.allowedExtensions"),"loading-message":`${O.$t("components.formEdit.modalAddMedia.optimizingTheFile")} ${O.$t("components.formEdit.modalAddMedia.pleaseWait")}`,loading:e(I),onSelect:G,onError:ne},null,8,["message","hint","loading-message","loading"])]),_:1},8,["label"]),C(Se,{value:1,label:O.$t("components.formEdit.modalAddMedia.imageUrl"),icon:"oi-picture-sun"},{default:P(()=>[C(Le,{ref_key:"imageUrlFormRef",ref:X,modelValue:e(S),"onUpdate:modelValue":A[1]||(A[1]=_=>Ce(S)?S.value=_:null),type:"form",name:"add-media-1",actions:!1,onSubmit:K},{default:P(()=>[e(w)===1?(r(),J(Le,{key:0,ref:"image",type:"text",name:"image","validation-label":"Image URL",label:"",placeholder:O.$t("components.formEdit.modalAddMedia.egImage"),validation:"url|imageUrl",help:O.$t("components.formEdit.modalAddMedia.enterUrlImage"),"validation-messages":{url:O.$t("components.formEdit.modalAddMedia.enterValidImageUrl"),imageUrl:O.$t("components.formEdit.modalAddMedia.enterValidImageUrl")},"validation-visibility":"submit"},null,8,["placeholder","help","validation-messages"])):V("",!0)]),_:1},8,["modelValue"])]),_:1},8,["label"]),t.fieldType!=="picture-choice"?(r(),J(Se,{key:0,value:2,label:O.$t("components.formEdit.modalAddMedia.video"),icon:"oi-social-video-youtube-clip"},{default:P(()=>[C(Le,{ref_key:"videoFormRef",ref:ie,modelValue:e(S),"onUpdate:modelValue":A[2]||(A[2]=_=>Ce(S)?S.value=_:null),type:"form",name:"add-media-2",actions:!1,onSubmit:K},{default:P(()=>[e(w)===2?(r(),J(Le,{key:0,ref:"video",type:"text",name:"video","validation-label":"Video URL",label:"",placeholder:O.$t("components.formEdit.modalAddMedia.egYoutube"),validation:"url|embedableMedia",help:O.$t("components.formEdit.modalAddMedia.enterUrlVideo"),"validation-messages":{url:O.$t("components.formEdit.modalAddMedia.enterValidYoutube"),embedableMedia:O.$t("components.formEdit.modalAddMedia.enterValidYoutube")},"validation-visibility":"submit"},null,8,["placeholder","help","validation-messages"])):V("",!0)]),_:1},8,["modelValue"])]),_:1},8,["label"])):V("",!0),C(Se,{value:3,label:O.$t("components.formEdit.modalAddMedia.gallery"),icon:"oi-layout-module-1"},{default:P(()=>[e(w)===3?(r(),J(Le,{key:0,modelValue:e(S),"onUpdate:modelValue":A[3]||(A[3]=_=>Ce(S)?S.value=_:null),type:"form",actions:!1,onSubmit:K},{default:P(()=>[e(N)===!1?(r(),c("div",ul,[e(R)==!1?(r(),c("div",cl,[(r(!0),c(ue,null,xe(e(be),(_,h)=>(r(),c("div",{key:h},[s("div",ml,[q((r(),c("button",{type:"button",class:"btn btn-sm btn-secondary opacity-0 group-hover:opacity-100 absolute z-30 mt-1 mr-1 justify-self-end",onClick:v=>we(_.id)},[...A[7]||(A[7]=[s("i",{class:"oi oi-bin"},null,-1)])],8,fl)),[[b,O.$t("components.formEdit.theFieldLayout.remove")]]),s("button",{onClick:v=>ve(_.url)},[s("img",{src:_.thumbnail.replace("cdn.yayforms.link","yayforms.nyc3.cdn.digitaloceanspaces.com"),alt:"",class:"w-full hover:opacity-80 object-contain rounded-md z-0"},null,8,gl)],8,pl)])]))),128))])):(r(),c("footer",vl,[s("div",hl,[(r(),c(ue,null,xe(6,_=>s("div",{key:_,class:"h-40 bg-neutral-lightest rounded-md"})),64))])]))])):(r(),J(Te,{key:1,variant:"empty",message:O.$t("components.formEdit.modalAddMedia.emptyGallery"),icon:"oi-picture-sun",class:"mt-10"},null,8,["message"]))]),_:1},8,["modelValue"])):V("",!0)]),_:1},8,["label"]),C(Se,{value:4,label:O.$t("components.formEdit.modalAddMedia.unsplash"),icon:"oi-image"},{default:P(()=>[e(w)===4?(r(),J(Le,{key:0,modelValue:e(S),"onUpdate:modelValue":A[5]||(A[5]=_=>Ce(S)?S.value=_:null),type:"form",actions:!1,onSubmit:K},{default:P(()=>[s("div",yl,[C(Le,{modelValue:e(W),"onUpdate:modelValue":A[4]||(A[4]=_=>Ce(W)?W.value=_:null),type:"text",name:"unsplashSearch",placeholder:O.$t("components.formEdit.modalAddMedia.searchUnsplash"),onInput:U},null,8,["modelValue","placeholder"])]),e(ae).length>0?(r(),c("div",bl,[e(T)?(r(),c("footer",El,[s("div",Sl,[(r(),c(ue,null,xe(6,_=>
6s("div",{key:_,class:"h-40 bg-neutral-lightest rounded-md"})),64))])])):(r(),c("div",_l,[(r(!0),c(ue,null,xe(e(ae),_=>(r(),c("div",{key:_.id},[s("div",wl,[s("button",{onClick:h=>oe(_)},[s("img",{src:_.urls.small,alt:_.alt_description||_.description,class:"w-full hover:opacity-80 object-cover rounded-md z-0 h-40"},null,8,kl)],8,xl)])]))),128)),e(M)?(r(),c("div",$l,[C(Ue,{class:"mx-auto"}),s("p",Fl,k(O.$t("components.formEdit.modalAddMedia.loadingMore")),1)])):V("",!0)],512))])):!e(T)&&e(W)?(r(),J(Te,{key:1,variant:"empty",message:O.$t("components.formEdit.modalAddMedia.noUnsplashResults"),icon:"oi-picture-sun",class:"mt-10"},null,8,["message"])):e(T)?(r(),c("div",Cl,[C(Ue,{class:"mx-auto"}),s("p",Il,k(O.$t("components.formEdit.modalAddMedia.loadingUnsplash")),1)])):(r(),c("div",Tl,[A[8]||(A[8]=s("i",{class:"oi oi-picture-sun text-4xl mb-4 block"},null,-1)),s("p",null,k(O.$t("components.formEdit.modalAddMedia.searchUnsplash")),1)]))]),_:1},8,["modelValue"])):V("",!0)]),_:1},8,["label"])]),_:1},8,["model-value"])]),s("footer",Ll,[e(w)===1||e(w)===2?(r(),J(l,{key:0,type:"button",variant:"secondary",onClick:A[6]||(A[6]=_=>O.$emit("close"))},{default:P(()=>[se(k(O.$t("common.action.cancel")),1)]),_:1})):V("",!0),e(w)===1||e(w)===2?(r(),J(l,{key:1,tag:"input","native-type":"submit",variant:"primary",value:O.$t("components.formEdit.modalAddMedia.add"),onClick:B},null,8,["value"])):V("",!0)])]),_:1})])}}},Al=1,Vl=1440,Dl=60;function pn(t){const n=Number.parseInt(t,10);return Number.isNaN(n)?Dl:Math.min(Vl,Math.max(Al,n))}const Rl={key:0,class:"flex flex-col gap-5"},Ol={class:"subheading-sm"},Nl={class:"flex flex-col gap-0.5"},Pl={class:"field-label flex items-center gap-1"},Bl={class:"oi oi-question-circle oi-12"},Ml={key:0,class:"flex flex-col gap-2"},jl=["innerHTML"],Ul={class:"subheading-sm"},Kl={class:"subheading-sm"},Hl={class:"subheading-sm"},ql={class:"flex justify-between items-center"},Wl={key:2},zl=["src"],Gl={__name:"TheFormSettings",setup(t){const{t:n}=Re(),o=Ae(),{canUse:i}=Et(),d=zt(),a=Ye(),u=oo,m=F(()=>o.form),f=F(()=>i(An.hideCredits)),p=F({get:()=>m.value?.language||"en",set:D=>{a.execute({resourceKey:`form:${m.value.id}:language`,actionKey:"actions.updateLanguage",execute:()=>o.updateFormLanguageAsync(D)})}}),y=F(()=>u.find(D=>D.code===p.value)?.name||"English");function E(D,L){const M=`form:${m.value.id}:setting:${D}`;a.debounced({resourceKey:M,actionKey:"actions.updateSetting",initialValue:m.value.settings?.[D],value:L,apply:Q=>o.updateFormSettingInStore({setting:D,value:Q}),execute:Q=>o.updateFormSetting({setting:D,value:Q}),debounce:1e3})}const w=F({get:()=>m.value?.settings?.prompt||"",set:D=>E("prompt",D)}),S=F({get:()=>pn(m.value?.settings?.sendIncompleteResponsesAfter),set:D=>E("sendIncompleteResponsesAfter",pn(D))});function x(D,L){const M=`form:${m.value.id}:metatag:${D}`;a.debounced({resourceKey:M,actionKey:"actions.updateMetaTag",initialValue:m.value.metaTags?.[D],value:L,apply:Q=>o.updateFormMetaTagInStore({metaTag:D,value:Q}),execute:Q=>o.updateFormMetaTag({metaTag:D,value:Q}),debounce:1e3})}const N=F({get:()=>m.value?.metaTags?.title||"",set:D=>x("title",D)}),I=F({get:()=>m.value?.metaTags?.description||"",set:D=>x("description",D)}),R=F(()=>m.value?.metaTags?.image||""),T=F(()=>m.value?.settings?.aiFeedback||!1),ce=F(()=>m.value?.settings?.sendIncompleteResponses||!1);function be(D){o.updateFormSetting({setting:"aiFeedback",value:D}),D&&E("prompt",w.value)}function ae(D){o.updateFormSetting({setting:"sendIncompleteResponses",value:D}),D&&E("sendIncompleteResponsesAfter",S.value)}function W(D){D&&o.updateFormSetting({setting:"scheduleCloseDate",value:!1})}async function j(){await d.modal.open({component:Hn,custom:!0,trapFocus:!0,props:{onAdd:(D,L)=>{x("image",L)}}})}return(D,L)=>{const M=ye("o-button"),Q=ye("o-dropdown-item"),X=ye("o-dropdown"),ie=el,pe=ye("o-input"),B=ye("o-field"),K=Ie("tooltip");return e(m)?(r(),c("div",Rl,[s("h2",Ol,k(e(n)("components.formEdit.theFormSettings.formSettings")),1),s("div",Nl,[s("div",Pl,[se(k(e(n)("components.formEdit.theFormSettings.language"))+" ",1),q(s("i",Bl,null,512),[[K,e(n)("components.formEdit.theFormSettings.theLanguageToShow")]])]),s("div",null,[e(m)?(r(),J(X,{key:0,modelValue:e(p),"onUpdate:modelValue":L[0]||(L[0]=ne=>Ce(p)?p.value=ne:null),"aria-role":"list",scrollable:"","max-height":200,"root-class":"w-full relative","menu-class":"w-full",selectable:""},{trigger:P(()=>[C(M,{variant:"dropdown-select",class:"btn dropdown-type"},{default:P(()=>[se(k(e(n)(e(y)))+" ",1),L[7]||(L[7]=s("i",{class:"oi oi-angle-down"},null,-1))]),_:1})]),default:P(()=>[(r(!0),c(ue,null,xe(e(u),(ne,we)=>(r(),J(Q,{key:we,value:ne.code,"aria-role":"listitem"},{default:P(()=>[se(k(e(n)(ne.name)),1)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])):V("",!0)])]),C(ie,{setting:"hideProgressBar",name:e(n)("components.formEdit.theFormSettings.hideProgressBar"),help:e(n)("components.formEdit.theFormSettings.hideProgressBarHelp")},null,8,["name","help"]),C(ie,{setting:"autosaveProgress","default-value":!0,name:e(n)("components.formEdit.theFormSettings.autosaveProgress"),help:e(n)("components.formEdit.theFormSettings.autosaveProgressHelp")},null,8,["name","help"]),C(ie,{setting:"hideCredits",name:e(n)("components.formEdit.theFormSettings.hidePowered"),disabled:!e(f),help:e(n)("components.formEdit.theFormSettings.removeTheCredits")},null,8,["name","disabled","help"]),C(ie,{value:e(T),setting:"aiFeedback",name:e(n)("components.formEdit.theFormSettings.aiFeedback"),help:e(n)("components.formEdit.theFormSettings.aiFeedbackHelp"),onInput:be},null,8,["value","name","help"]),e(T)?(r(),c("div",Ml,[C(B,{label:e(n)("components.formEdit.theFormSettings.prompt.label")},{default:P(()=>[C(pe,{modelValue:e(w),"onUpdate:modelValue":L[1]||(L[1]=ne=>Ce(w)?w.value=ne:null),type:"textarea","input-class":"h-28 py-2",placeholder:e(n)("components.formEdit.theFormSettings.prompt.placeholder"),help:e(n)("components.formEdit.theFormSettings.prompt.help")},null,8,["modelValue","placeholder","help"])]),_:1},8,["label"]),s("div",{class:"text-xs text-neutral",innerHTML:e(n)("components.formEdit.theFormSettings.prompt.help")},null,8,jl)])):V("",!0),L[9]||(L[9]=s("div",{class:"h-1 border-t-2 border-neutral-lightest"},null,-1)),s("h2",Ul,k(e(n)("components.formEdit.theFormSettings.accessAndSchedule")),1),C(ie,{setting:"closeForm",name:e(n)("components.formEdit.theFormSettings.closeForm"),help:e(n)("components.formEdit.theFormSettings.closeForm"),onUpdate:W},null,8,["name","help"]),L[10]||(L[10]=s("div",{class:"h-1 border-t-2 border-neutral-lightest"},null,-1)),s("h2",Kl,k(e(n)("components.formEdit.theFormSettings.integrationsSettings")),1),C(ie,{value:e(ce),setting:"sendIncompleteResponses",name:e(n)("components.formEdit.theFormSettings.sendIncomplete"),help:e(n)("components.formEdit.theFormSettings.enableSending"),onInput:ae},null,8,["value","name","help"]),e(ce)?(r(),J(B,{key:1,label:e(n)("components.formEdit.theFormSettings.waitingTime")},{default:P(()=>[C(pe,{modelValue:e(S),"onUpdate:modelValue":L[2]||(L[2]=ne=>Ce(S)?S.value=ne:null),type:"number",min:"1",max:"1440",placeholder:"1-1440"},null,8,["modelValue"])]),_:1},8,["label"])):V("",!0),L[11]||(L[11]=s("div",{class:"h-1 border-t-2 border-neutral-lightest"},null,-1)),s("h2",Hl,k(e(n)("components.formEdit.theFormSettings.metaTagsSettings")),1),C(B,{label:e(n)("components.formEdit.theFormSettings.title")},{default:P(()=>
6[C(pe,{modelValue:e(N),"onUpdate:modelValue":L[3]||(L[3]=ne=>Ce(N)?N.value=ne:null),type:"text",maxlength:"60",placeholder:e(n)("components.formEdit.theFormSettings.enterTitle")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),C(B,{label:e(n)("components.formEdit.theFormSettings.description")},{default:P(()=>[C(pe,{modelValue:e(I),"onUpdate:modelValue":L[4]||(L[4]=ne=>Ce(I)?I.value=ne:null),type:"textarea",maxlength:"900","input-class":"h-16 py-2",placeholder:e(n)("components.formEdit.theFormSettings.enterDescription")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),s("div",ql,[C(B,{label:e(n)("components.formEdit.theFormSettings.previewImage")},null,8,["label"]),e(R)===""?(r(),c("button",{key:0,class:"btn btn-sm btn-secondary",onClick:L[5]||(L[5]=ne=>j())},k(e(n)("components.formEdit.theFieldLayout.add")),1)):q((r(),c("button",{key:1,class:"btn btn-sm btn-secondary",onClick:L[6]||(L[6]=ne=>x("image",""))},[...L[8]||(L[8]=[s("i",{class:"oi oi-bin"},null,-1)])])),[[K,e(n)("components.formEdit.theFieldLayout.remove")]])]),e(R)!==""?(r(),c("div",Wl,[C(B,{label:"Preview"}),s("img",{src:e(R),class:"w-full h-auto self-center"},null,8,zl)])):V("",!0)])):V("",!0)}}},Jl={props:{headsAnchor:{type:String,default:""},initialTab:{type:String,default:""},tabs:{type:Array,default:()=>[]},cssClassBody:{type:String,default:"tabs-body"},onBeforeSwitchTab:{type:Function,default:()=>!0}},data(){return{activeTab:this.initialTab}},computed:{tabPanelSlotName(){return`tab-panel-${this.activeTab}`}},methods:{tabHeadSlotName(t){return`tab-head-${t}`},switchTab(t){this.onBeforeSwitchTab()&&(this.activeTab=t)}}},Yl={class:"tabs"},Ql={class:"tabs-header"},Xl=["data-tour"],Zl=["onClick"];function ea(t,n,o,i,d,a){return r(),c("div",Yl,[s("header",Ql,[s("ul",{"data-tour":o.headsAnchor||void 0,class:"tab-heads"},[(r(!0),c(ue,null,xe(o.tabs,u=>(r(),c("li",{key:u,class:re(["tab-head",{"tab-head--active":d.activeTab===u}]),onClick:m=>{a.switchTab(u)}},[Zt(t.$slots,a.tabHeadSlotName(u),{},()=>[se(k(u),1)],!0)],10,Zl))),128))],8,Xl)]),s("main",{class:re(o.cssClassBody)},[(r(),J(io,null,[(r(),c("div",{key:d.activeTab,class:"tab-panel"},[Zt(t.$slots,a.tabPanelSlotName,{},void 0,!0)]))],1024))],2)])}const qn=Be(Jl,[["render",ea],["__scopeId","data-v-ee5d51cb"]]),ta={__name:"TheFormLeftMenu",setup(t){const n=pt(),o=Z("content"),i=["content","design","settings"];function d(a){i.includes(a)&&(o.value=a)}return nt(()=>{d(n.query.tab)}),(a,u)=>{const m=Fi,f=Qs,p=Gl,y=qn;return r(),J(y,{"heads-anchor":"editor-left-tabs",tabs:i,"initial-tab":e(o),class:"h-full","css-class-body":"h-full overflow-auto pt-5"},{"tab-head-content":P(()=>[se(k(a.$t("components.formEdit.theFormLeftMenu.content")),1)]),"tab-panel-content":P(()=>[C(m)]),"tab-head-design":P(()=>[se(k(a.$t("components.formEdit.theFormLeftMenu.design")),1)]),"tab-panel-design":P(()=>[C(f)]),"tab-head-settings":P(()=>[se(k(a.$t("components.formEdit.theFormLeftMenu.settings")),1)]),"tab-panel-settings":P(()=>[C(p)]),_:1},8,["initial-tab"])}}},bt=kn("editor-ui",{state:()=>({editingDevice:"desktop"}),getters:{isMobile:t=>t.editingDevice==="mobile",isTablet:t=>t.editingDevice==="tablet",isDesktop:t=>t.editingDevice==="desktop"},actions:{setEditingDevice(t){Ot.includes(t)&&(this.editingDevice=t)},resetEditingDevice(){this.editingDevice="desktop"}}});function Je(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function ft(t,n){if(t===n)return!0;if(t==null||n==null)return t==null&&n==null;if(typeof t!=typeof n)return!1;if(!Je(t)||!Je(n))return t===n;const o=Object.keys(t),i=Object.keys(n);if(o.length!==i.length)return!1;for(const d of o)if(!ft(t[d],n[d]))return!1;return!0}function Wn(t,n){if(!Je(n))return ft(t,n)?void 0:n;if(!Je(t))return n;const o={};let i=!1;for(const d of Object.keys(n)){const a=t[d],u=n[d];if(Je(a)&&Je(u)){const m=Wn(a,u);m!==void 0&&(o[d]=m,i=!0)}else ft(a,u)||(o[d]=u,i=!0)}return i?o:void 0}function na(t,n){if(!Je(t))return;const o=n.split(".");let i=t;for(const d of o){if(!Je(i))return;i=i[d]}return i}function zn(t){if(Je(t))for(const n of Object.keys(t))Je(t[n])&&(zn(t[n]),Object.keys(t[n]).length===0&&delete t[n])}function Dt(t){return t===Fe.split||t===Fe.full?"cover":"contain"}const oa={class:"canvas-navbar"},ia={"data-tour":"editor-devices",class:"device-tabs"},sa=["onClick"],la={key:0,class:"device-tab-override-dot","aria-hidden":"true"},aa={__name:"TheCanvasDeviceNavbar",setup(t){const n=["desktop","tablet","mobile"],{t:o}=Re(),i=bt(),d=Ae(),{editingDevice:a}=vt(i);function u(p){i.setEditingDevice(p)}function m(p){return o(p==="mobile"?"components.formEdit.theFieldLayout.deviceMobile":p==="tablet"?"components.formEdit.theFieldLayout.deviceTablet":"components.formEdit.theFieldLayout.deviceDesktop")}function f(p){if(p==="desktop")return!1;const y=d.getCurrentField?.layout;if(!y?.[p])return!1;const E=Xe(y,p),w=Xe({...y,[p]:void 0},p);return!ft(E,w)}return(p,y)=>{const E=Ie("tooltip");return r(),c("div",oa,[s("ul",ia,[(r(),c(ue,null,xe(n,w=>s("li",{key:w,class:re(["device-tab",{"device-tab--active":e(a)===w}]),onClick:S=>u(w)},[se(k(m(w))+" ",1),f(w)?q((r(),c("span",la,null,512)),[[E,e(o)("components.formEdit.theCanvasDeviceNavbar.hasOverrides",{device:m(w)})]]):V("",!0)],10,sa)),64))])])}}},ra=Be(aa,[["__scopeId","data-v-118df168"]]),da=["src","alt"],ua=["src"],ca={__name:"MediaRenderer",setup(t){const{t:n}=Re(),o=Ae(),i=bt(),{editingDevice:d}=vt(i),a=Ye(),u=so("previewField",null),m=F(()=>u?.value??o.getCurrentField),f=F(()=>Xe(m.value?.layout,d.value)),p=F(()=>f.value?.media?.settings?.description),y=F(()=>{const x=f.value;if(!x)return{};const N=x.media?.settings?.focalPoint,I=N&&Number.isFinite(N.x)&&Number.isFinite(N.y)?{objectPosition:`${N.x}% ${N.y}%`}:{},R=x.media?.settings?.objectFit,T=R?{objectFit:R}:{};return x.type===Fe.split?{height:"inherit",width:"inherit",...I,...T}:x.type===Fe.float?{height:"auto",width:"auto",...I,...T}:{height:x.media?.settings?.height||"auto",width:x.media?.settings?.width||"auto",...I,...T}}),E=F(()=>{const x=f.value;if(!x)return[];const N=x.type===Fe.full?`layout-${x.type}`:`layout-${x.type}-${x.placement}`,I=`media-${x.media?.type}`;return[N,I]});function w(){return Vo(f.value?.media?.url)}function S(){const x=m.value.layout;a.execute({resourceKey:`field:${m.value.id}:layout`,actionKey:"actions.removeLayout",execute:()=>o.updateFieldLayout({fieldId:m.value.id,layout:null}),rollback:()=>o.updateFieldLayout({fieldId:m.value.id,layout:x})})}return(x,N)=>{const I=Ie("tooltip");return r(),c("figure",{class:re([e(E),"group"])},[q((r(),c("button",{class:"btn btn-sm btn-secondary opacity-0 group-hover:opacity-100 absolute right-0.5 top-0.5 z-30",onClick:S},[...N[0]||(N[0]=[s("i",{class:"oi oi-bin oi-16"},null,-1)])])),[[I,e(n)("components.formEdit.mediaRenderer.remove")]]),e(f)?.media?.type===e(je).image&&e(f).type!="split"?(r(),c("img",{key:0,src:e(f).media.url.replace("cdn.yayforms.link","yayforms.nyc3.cdn.digitaloceanspaces.com"),alt:e(p),style:De(e(y))},null,12,da)):V("",!0),e(f)?.media?.type===e(je).video?(r(),c("iframe",{key:1,src:w(),frameborder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",allowfullscreen:"",class:"absolute w-full h-full top-0 left-0 bottom-0 right-0"},null,8,ua)):V("",!0)],2)}}},ma={key:0,class:"field-preview-frame"}
6,fa={key:0,class:"preview-browser-controls flex flex-row gap-2","aria-hidden":"true"},pa={__name:"TheFieldPreview",setup(t){const n=Ae(),o=bt(),{editingDevice:i}=vt(o),d=F(()=>i.value==="mobile"?"preview-device-mobile":i.value==="tablet"?"preview-device-tablet":""),a=F(()=>i.value!=="mobile"&&i.value!=="tablet"),{component:u,loadError:m,load:f,reload:p}=Bn(),y=Z(`font-${Ve.properties.fontSizeScale.value}`),E=Z(`button-border-${Ve.properties.buttonBorderRadius.value}`),w=F(()=>n.form?.theme),S=F(()=>n.getCurrentField),x=F(()=>lo(S.value,n.getFieldById)),N=F(()=>x.value.previewField),I=F(()=>x.value.activeChildId);Nt("activeGroupChildId",I),Nt("previewField",N);const R=F(()=>Xe(N.value?.layout,i.value)),T=F(()=>R.value?"preview-mobile-top":"preview-mobile-center"),ce=F(()=>N.value?{...N.value,layout:R.value}:null),be=F(()=>N.value?.type),ae=F(()=>N.value?.id);function W(B){return B==="cover"?"cover":B==="contain"?"contain":B==="fill"?"100% 100%":null}const j=F(()=>{const B=R.value;if(!B)return"";const K=B.media?.url;if(B.type==="full"&&K){const we=B.media?.settings?.focalPoint,ve=we&&Number.isFinite(we.x)&&Number.isFinite(we.y)?` background-position: ${we.x}% ${we.y}%;`:"",G=W(B.media?.settings?.objectFit),U=G?` background-size: ${G};`:"";return`background-image: url('${K}'); background-repeat: no-repeat;${ve}${U}`}return""}),D=F(()=>{const B=R.value;return B?.type!=="split"?!1:B.placement==="top"||i.value==="mobile"}),L=F(()=>R.value?.type==="float"&&i.value==="mobile"),M=F(()=>{const B=R.value;if(!B)return"";const K=B.media?.url?.replace("cdn.yayforms.link","yayforms.nyc3.cdn.digitaloceanspaces.com");if(B.type==="split"&&K){const we=B.media?.settings?.focalPoint,ve=we&&Number.isFinite(we.x)&&Number.isFinite(we.y)?` background-position: ${we.x}% ${we.y}%;`:"",G=W(B.media?.settings?.objectFit),U=G?` background-size: ${G};`:"";return{url:`background-image: url('${K}'); background-repeat: no-repeat;${ve}${U}`,class:D.value?"w-full h-96 bg-cover bg-center flex-shrink-0":"h-full w-3/6 bg-cover bg-center"}}return""}),Q=F(()=>{const B=R.value;return B?B.type==="split"&&D.value?"flex flex-col justify-start h-full w-full":B.type==="float"&&L.value?"flex flex-col items-center w-full mx-auto container-width":(B.type==="float"||B.type==="split")&&B.placement==="left"?"flex flex-row justify-center flex-1 min-h-0 overflow-hidden items-center":(B.type==="float"||B.type==="split")&&B.placement==="right"?"flex flex-row-reverse justify-center items-center flex-1 min-h-0 overflow-hidden":B.type==="full"?"flex flex-col flex-1 min-h-0 items-center justify-center w-1/2 mx-auto theme-base-font-scale container-width":"flex flex-col flex-1 items-center justify-center w-1/2 mx-auto theme-base-font-scale container-width":"flex flex-col flex-1 items-center justify-center w-1/2 mx-auto container-width"}),X=F(()=>{const B=R.value;return B?B.type==="split"&&D.value||B.type==="float"&&L.value?"w-full self-center p-6":B.type==="float"?"w-3/6 self-center p-5 h-full overflow-y-auto flex flex-col preview-media-center":B.type==="split"?"w-3/6 self-center p-12 h-full overflow-y-auto flex flex-col preview-media-center":B.type==="full"?"w-full h-full overflow-y-auto flex flex-col preview-media-center":"w-full":"w-full pt-4"}),ie=F(()=>{const B=R.value;return B&&B.type==="split"?"flex flex-col gap-8 w-full h-full theme-page":"flex flex-col gap-8 w-full h-full bg-cover bg-center p-4 theme-page"}),pe=async B=>{if(!B){u.value=null;return}await Ke(),await f(()=>Pn(Object.assign({
6"./field-types/calendly/CalendlyEditor.vue":()=>he(()=>import("./VwPEvOHT.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45]),import.meta.url),
6"./field-types/date/DateEditor.vue":()=>he(()=>import("./CyHaKl5n.js"),__vite__mapDeps([46,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,47,48,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,49]),import.meta.url),
6"./field-types/dropdown/DropdownEditor.vue":()=>he(()=>import("./DJG2lGnU.js"),__vite__mapDeps([50,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,48,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44]),import.meta.url),
6"./field-types/email/EmailEditor.vue":()=>he(()=>import("./CtH_S9do.js"),__vite__mapDeps([51,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,47,48,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44]),import.meta.url),
6"./field-types/ending-screen/EndingScreenEditor.vue":()=>he(()=>import("./B-oM_8OV.js"),__vite__mapDeps([52,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,48,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44]),import.meta.url),
6"./field-types/file-upload/FileUploadEditor.vue":()=>he(()=>import("./BRxfSabk.js"),__vite__mapDeps([53,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44]),import.meta.url),
6"./field-types/group/GroupEditor.vue":()=>he(()=>import("./BULMZNOl.js"),__vite__mapDeps([54,3,4,1,2,5,6,7,8,9,10,11,12,13,14,15,16,17,36,37,48,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,39,40,41,42,43,44,55]),import.meta.url),
6"./field-types/long-text/LongTextEditor.vue":()=>he(()=>import("./5CQGKCPt.js"),__vite__mapDeps([56,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,47,48,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44]),import.meta.url),
6"./field-types/matrix/MatrixEditor.vue":()=>he(()=>import("./Btz6-SsC.js"),__vite__mapDeps([57,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,58,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,59]),import.meta.url),
6"./field-types/multiple-choice/MultipleChoiceEditor.vue":()=>he(()=>import("./qS61aAG8.js"),__vite__mapDeps([60,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,61,48,58,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,62]),import.meta.url),
6"./field-types/nps/NpsEditor.vue":()=>he(()=>import("./DYnCZoqe.js"),__vite__mapDeps([63,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44]),import.meta.url),
6"./field-types/number/NumberEditor.vue":()=>he(()=>import("./w8oJC0EC.js"),__vite__mapDeps([64,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,47,48,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44]),import.meta.url),
6"./field-types/opinion-scale/OpinionScaleEditor.vue":()=>he(()=>import("./B4FIAvMR.js"),__vite__mapDeps([65,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44]),import.meta.url),
6"./field-types/phone/PhoneEditor.vue":()=>he(()=>import("./C8UaYe_v.js"),__vite__mapDeps([66,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,47,48,67,68,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,69]),import.meta.url),
6"./field-types/picture-choice/PictureChoiceEditor.vue":()=>he(()=>import("./BX9aPfTa.js"),__vite__mapDeps([70,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,61,48,58,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,71]),import.meta.url),
6"./field-types/rating/RatingEditor.vue":()=>he(()=>import("./BNTWQf58.js"),__vite__mapDeps([72,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,73,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44]),import.meta.url),
6"./field-types/scheduling/SchedulingEditor.vue":()=>he(()=>import("./DvkRPldY.js"),__vite__mapDeps([74,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44]),import.meta.url),
6"./field-types/short-text/ShortTextEditor.vue":()=>he(()=>import("./n1r6ZEjD.js"),__vite__mapDeps([75,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,47,48,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44]),import.meta.url),
6"./field-types/statement/StatementEditor.vue":()=>he(()=>import("./BfeShtBg.js"),__vite__mapDeps([76,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,48,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44]),import.meta.url),
6"./field-types/website/WebsiteEditor.vue":()=>he(()=>import("./DG5pMBwV.js"),__vite__mapDeps([77,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,47,48,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44]),import.meta.url),
6"./field-types/welcome-screen/WelcomeScreenEditor.vue":()=>he(()=>import("./C5FFfWes.js"),__vite__mapDeps([78,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,48,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44]),import.meta.url),
6"./field-types/yes-no/YesNoEditor.vue":()=>he(()=>import("./BTkz2adG.js"),__vite__mapDeps([79,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,48,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,80]),import.meta.url)}),`./field-types/${B}/${En(B)}Editor.vue`,4))};return He(be,async B=>{await pe(B)},{immediate:!0}),He(w,()=>{Ke(()=>{y.value=`font-${Ve.properties.fontSizeScale.value}`,E.value=`button-border-${Ve.properties.buttonBorderRadius.value}`})},{deep:!0,immediate:!0}),(B,K)=>{const ne=ca,we=ht;return e(N)?(r(),c("div",ma,[e(a)?(r(),c("div",fa,[...K[0]||(K[0]=[s("span",{class:"w-2 h-2 rounded-full bg-red"},null,-1),s("span",{class:"w-2 h-2 rounded-full bg-yellow"},null,-1),s("span",{class:"w-2 h-2 rounded-full bg-green"},null,-1)])])):V("",!0),s("div",{class:re([[e(ie),e(d)],"overflow-y-auto"]),style:De(e(j))},[s("div",{class:re([[e(Q),e(y),e(E),e(T)],"theme-base-font-scale"])},[e(R)&&e(R).type=="split"?(r(),c("div",{key:0,class:re(e(M).class),style:De(e(M).url)},[C(ne)],6)):V("",!0),e(R)&&e(R).type=="float"?(r(),J(ne,{key:1,class:re(e(L)?"w-full":"w-3/6")},null,8,["class"])):V("",!0),s("div",{class:re(e(X))},[e(u)&&e(ce)&&!e(m)?(r(),J(Fn(e(u)),st({key:e(ae)},e(ce)),null,16)):e(m)?(r(),J(we,{key:1,variant:"error",message:B.$t("components.formEdit.theFieldPreview.loadError"),"show-reload":"",onReload:e(p)},null,8,["message","onReload"])):(r(),J(we,{key:2,variant:"empty",message:B.$t("components.formEdit.theFieldPreview.chooseOrAdd"),icon:"oi-list-bullets"}
6,null,8,["message"]))],2)],2)],6)])):V("",!0)}}},ga={class:"flex flex-col gap-2"},va=["src","alt"],ha=["aria-label"],ya={__name:"FocalPointPicker",props:{imageUrl:{type:String,default:""},modelValue:{type:Object,default:null}},emits:["update:modelValue"],setup(t,{emit:n}){const{t:o}=Re(),i=t,d=n,a=Z(null),u=Z(!1),m=F(()=>{const N=i.modelValue;return N&&Number.isFinite(N.x)&&Number.isFinite(N.y)?N:{x:50,y:50}}),f=F(()=>({left:`${m.value.x}%`,top:`${m.value.y}%`}));function p(N){return N<0?0:N>100?100:N}function y(N){const I=a.value;if(!I)return;const R=I.getBoundingClientRect();if(R.width===0||R.height===0)return;const T=p((N.clientX-R.left)/R.width*100),ce=p((N.clientY-R.top)/R.height*100);d("update:modelValue",{x:Math.round(T),y:Math.round(ce)})}function E(N){i.imageUrl&&(N.preventDefault(),u.value=!0,y(N),window.addEventListener("pointermove",w),window.addEventListener("pointerup",S))}function w(N){u.value&&y(N)}function S(){u.value=!1,window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",S)}function x(){d("update:modelValue",null)}return Sn(()=>{window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",S)}),(N,I)=>(r(),c("div",ga,[s("div",{ref_key:"boxRef",ref:a,class:re(["focal-point-box",{"cursor-grabbing":u.value}]),onPointerdown:E},[t.imageUrl?(r(),c("img",{key:0,src:t.imageUrl,alt:e(o)("components.formEdit.focalPointPicker.previewAlt"),class:"focal-point-image",draggable:"false"},null,8,va)):V("",!0),s("div",{class:"focal-point-handle",style:De(f.value),"aria-label":e(o)("components.formEdit.focalPointPicker.handleAria")},null,12,ha)],34),t.modelValue?(r(),c("button",{key:0,type:"button",class:"btn btn-sm btn-secondary self-end",onClick:x},k(e(o)("components.formEdit.focalPointPicker.reset")),1)):V("",!0)]))}},ba=Be(ya,[["__scopeId","data-v-b4a60238"]]),_a={class:"flex flex-col gap-2"},wa={class:"subheading-sm flex justify-between items-center"},xa={class:"flex items-center gap-2"},ka=["aria-label"],$a={key:0,class:"flex flex-col gap-2 mt-2"},Fa={key:0,class:"flex gap-2"},Ea={class:"flex items-center gap-2"},Sa=["aria-label"],Ta={class:"unit-input"},Ca={type:"button",class:"unit-toggle"},Ia={class:"flex items-center gap-2"},La=["aria-label"],Aa={class:"unit-input"},Va={type:"button",class:"unit-toggle"},Da={class:"flex items-center gap-2"},Ra=["aria-label"],Oa={key:2,class:"flex flex-col gap-1"},Na={class:"flex items-center gap-2"},Pa={class:"text-sm text-neutral-darker"},Ba=["aria-label"],Ma={__name:"TheFieldLayout",setup(t){function n(h,v="px"){return!h||h==="auto"?v:h.endsWith("%")?"%":"px"}function o(h){return!h||h==="auto"?"":h.replace("%","").replace("px","")}const{t:i}=Re(),d=Ae(),a=bt(),{editingDevice:u}=vt(a),m=zt(),f=Z("none"),p=Z(Ne.top),y=Z(""),E=Z(""),w=Z(""),S=Z(""),x=Z("px"),N=Z(""),I=Z("%"),R=Z(null),T=Z("contain"),ce=[{value:"contain",labelKey:"components.formEdit.theFieldLayout.objectFitContain"},{value:"cover",labelKey:"components.formEdit.theFieldLayout.objectFitCover"},{value:"fill",labelKey:"components.formEdit.theFieldLayout.objectFitFill"}];function be(h){return i(h==="mobile"?"components.formEdit.theFieldLayout.deviceMobile":h==="tablet"?"components.formEdit.theFieldLayout.deviceTablet":"components.formEdit.theFieldLayout.deviceDesktop")}const ae=F(()=>be(u.value)),W=F(()=>i("components.formEdit.theFieldLayout.removePropertyOverride",{device:ae.value})),j=F(()=>d.getCurrentField),D=F(()=>j.value?.layout||null),L=F(()=>{const h=ce.find(v=>v.value===T.value);return h?i(h.labelKey):T.value}),M=F(()=>{if(f.value===Fe.split||f.value===Fe.full)return!0;if(f.value===Fe.banner){const h=S.value;return h!==""&&h!=="auto"&&!Number.isNaN(Number(h))}return!1}),Q=F(()=>y.value===je.image&&M.value),X=F(()=>y.value===je.image&&M.value),ie=F(()=>y.value===je.video?{list:"btn-group self-start",principal:"flex flex-col gap-2",field:"flex justify-between items-center"}:{list:`btn-group p-1 grid ${u.value==="mobile"?"grid-cols-4":"grid-cols-7"} gap-1 mt-2`,principal:"",field:""}),pe=F({get:()=>N.value===""||Number.isNaN(N.value)?"auto":N.value.trim()+I.value,set:h=>{N.value=o(h),I.value=n(h,"%")}
6}),B=F({get:()=>S.value===""||Number.isNaN(S.value)?"auto":S.value.trim()+x.value,set:h=>{S.value=o(h),x.value=n(h)}}),K=Z(!1);let ne=null;const we=Ye();He(D,()=>{Ee()},{immediate:!0}),He(u,()=>{Ee()});function ve(){if(!E.value)return null;const h=()=>{if(y.value===je.image){const v={focalPoint:R.value,objectFit:T.value};return f.value===Fe.banner?(v.height=B.value,v.width=pe.value):(v.height="auto",v.width="auto"),v}};return{type:f.value||Fe.banner,placement:p.value||Ne.top,media:{type:y.value,url:E.value,settings:h()}}}function G(){const h=ve();if(!h)return null;const v=j.value?.layout||{};let H;if(u.value==="desktop"){H={...v,...h};for(const g of Ot)v[g]?H[g]=v[g]:H[g]!==void 0&&(H[g]=void 0)}else{const g={...v,[u.value]:void 0},$=Xe(g,u.value),te=Wn($,h);te?H={...v,[u.value]:te}:H=Object.fromEntries(Object.entries(v).filter(([fe])=>fe!==u.value))}E.value&&(H.media={...H.media??{},type:H.media?.type??y.value,url:H.media?.url??E.value,settings:{...H.media?.settings??{},description:w.value??""}});for(const g of Ot){if(!H[g])continue;const $=Xe(H,g),te=Xe({...H,[g]:void 0},g);ft($,te)&&(H[g]=void 0)}return H}function U(){const h=G(),v=j.value.id,H=`field:${v}:layout`;we.setLastSyncedValue(H,ne),we.execute({resourceKey:H,actionKey:"actions.updateLayout",execute:async()=>{await d.updateFieldLayout({fieldId:v,layout:h}),ne=h},rollback:()=>{ne&&ke(Xe(ne,u.value))}})}function oe(){const h=ne,v=j.value.id,H=`field:${v}:layout`;we.execute({resourceKey:H,actionKey:"actions.removeLayout",execute:async()=>{await d.updateFieldLayout({fieldId:v,layout:null}),ne=null},rollback:()=>{h&&(ne=h,ke(Xe(h,u.value)))}})}function ke(h){y.value=h?.media?.type,E.value=h?.media?.url,w.value=h?.media?.settings?.description,B.value=h?.media?.settings?.height,pe.value=h?.media?.settings?.width;const v=h?.media?.settings?.focalPoint||null,H=R.value;v===H||v&&H&&v.x===H.x&&v.y===H.y||(R.value=v),T.value=h?.media?.settings?.objectFit||Dt(h?.type),Se(h?.type,h?.placement)}function Ee(){K.value=!0;const h=Xe(j.value?.layout,u.value);ke(h),ne=j.value?.layout||null,Ke(()=>{K.value=!1})}function _e(){f.value="none",p.value=Ne.top,y.value="",E.value="",w.value="",S.value="",N.value="",x.value="px",I.value="%",R.value=null,T.value="contain",a.resetEditingDevice(),oe()}function le(h){if(u.value==="desktop")return!1;const v=j.value?.layout?.[u.value];return na(v,h)!==void 0}function O(h){return h.some(v=>le(v))}function A(h){z([h])}function z(h){if(u.value==="desktop")return;const v=j.value?.layout||{},H=JSON.parse(JSON.stringify(v)),g=H[u.value];if(!Je(g))return;for(const fe of h){const ge=fe.split(".");let de=g,me=!0;for(let ee=0;ee<ge.length-1;ee++){if(!Je(de[ge[ee]])){me=!1;break}de=de[ge[ee]]}me&&delete de[ge[ge.length-1]]}zn(g),Object.keys(g).length===0&&delete H[u.value];const $=j.value.id,te=`field:${$}:layout`;we.setLastSyncedValue(te,ne),we.execute({resourceKey:te,actionKey:"actions.updateLayout",execute:async()=>{await d.updateFieldLayout({fieldId:$,layout:H}),ne=H,Ee()},rollback:()=>{ne&&ke(Xe(ne,u.value))}})}function $e(h,v){const H=Dt(f.value);Se(h,v),T.value===H&&(T.value=Dt(h)),U()}function Se(h,v){f.value=h||"none",p.value=v||Ne.top}async function Le(){await m.modal.open({component:Hn,custom:!0,trapFocus:!0,props:{fieldId:j.value.id,onAdd:async(h,v)=>{a.resetEditingDevice(),f.value=Fe.banner,y.value=h,E.value=v,await U(),Ee()}}})}const Te=ao(()=>{U()},1e3);He([w,S,N],()=>{K.value||Te()});function Ue(h){x.value=h,U()}function Me(h){I.value=h,U()}function l(h){R.value=h,K.value||U()}function b(h){T.value=h,K.value||U()}function _(h,v){return h===Fe.full&&f.value===Fe.full?!0:f.value===h&&p.value===v}return(h,v)=>{const H=ye("o-field"),g=ye("o-input"),$=ye("VDropdown"),te=ye("o-button"),fe=ye("o-dropdown-item"),ge=ye("o-dropdown"),de=Ie("tooltip"),me=Ie("close-popper");return r(),c("div",_a,[s("div",wa,[s("div",null,k(e(i)("components.formEdit.theFieldLayout.imageVideo")),1),e(f)==="none"?(r(),c("button",{key:0,class:"btn btn-sm btn-secondary",onClick:Le},k(e(i)("components.formEdit.theFieldLayout.add")),1)):V("",!0),e(f)!=="none"?q((r(),c("button",{key:1,class:"btn btn-sm btn-secondary",onClick:_e},[...v[20]||(v[20]=[s("i",{class:"oi oi-bin"},null,-1)])])),[[de,e(i)("components.formEdit.theFieldLayout.remove")]]):V("",!0)]),C(kt,{name:"fade",duration:"100",mode:"out-in"},{default:P(()=>
6[e(f)!=="none"?(r(),c("div",{key:0,class:re(e(ie).principal)},[C(H,{class:re(e(ie).field)},{label:P(()=>[s("div",xa,[se(k(e(i)("components.formEdit.theFieldLayout.layout"))+" ",1),O(["type","placement"])?q((r(),c("button",{key:0,type:"button",class:"device-override-dot","aria-label":e(W),onClick:v[0]||(v[0]=ee=>z(["type","placement"]))},null,8,ka)),[[de,e(W)]]):V("",!0)])]),default:P(()=>[s("div",{class:re(e(ie).list)},[e(y)===e(je).image?q((r(),c("button",{key:0,class:re(["btn px-2",{"btn-active":_(e(Fe).full)}]),onClick:v[1]||(v[1]=ee=>$e(e(Fe).full))},[...v[21]||(v[21]=[s("i",{class:"oi oi-layout-wallpaper oi-20"},null,-1)])],2)),[[de,"Full background"]]):V("",!0),e(y)===e(je).image&&e(u)!=="mobile"?q((r(),c("button",{key:1,class:re(["btn px-2",{"btn-active":_(e(Fe).float,e(Ne).left)}]),onClick:v[2]||(v[2]=ee=>$e(e(Fe).float,e(Ne).left))},[...v[22]||(v[22]=[s("i",{class:"oi oi-layout-float-left oi-20"},null,-1)])],2)),[[de,"Float left"]]):V("",!0),e(y)===e(je).image&&e(u)!=="mobile"?q((r(),c("button",{key:2,class:re(["btn px-2",{"btn-active":_(e(Fe).float,e(Ne).right)}]),onClick:v[3]||(v[3]=ee=>$e(e(Fe).float,e(Ne).right))},[...v[23]||(v[23]=[s("i",{class:"oi oi-layout-float-right oi-20"},null,-1)])],2)),[[de,"Float right"]]):V("",!0),e(y)===e(je).image&&e(u)!=="mobile"?q((r(),c("button",{key:3,class:re(["btn px-2",{"btn-active":_(e(Fe).split,e(Ne).left)}]),onClick:v[4]||(v[4]=ee=>$e(e(Fe).split,e(Ne).left))},[...v[24]||(v[24]=[s("i",{class:"oi oi-layout-split-left oi-20"},null,-1)])],2)),[[de,"Split left"]]):V("",!0),e(y)===e(je).image&&e(u)==="mobile"?q((r(),c("button",{key:4,class:re(["btn px-2",{"btn-active":_(e(Fe).split,e(Ne).top)}]),onClick:v[5]||(v[5]=ee=>$e(e(Fe).split,e(Ne).top))},[...v[25]||(v[25]=[s("i",{class:"oi oi-layout-split-top oi-20"},null,-1)])],2)),[[de,"Split top"]]):V("",!0),e(y)===e(je).image&&e(u)!=="mobile"?q((r(),c("button",{key:5,class:re(["btn px-2",{"btn-active":_(e(Fe).split,e(Ne).right)}]),onClick:v[6]||(v[6]=ee=>$e(e(Fe).split,e(Ne).right))},[...v[26]||(v[26]=[s("i",{class:"oi oi-layout-split-right oi-20"},null,-1)])],2)),[[de,"Split right"]]):V("",!0),q((r(),c("button",{class:re(["btn px-2",{"btn-active":_(e(Fe).banner,e(Ne).top)}]),onClick:v[7]||(v[7]=ee=>$e(e(Fe).banner,e(Ne).top))},[...v[27]||(v[27]=[s("i",{class:"oi oi-layout-banner-top oi-20"},null,-1)])],2)),[[de,"On the top"]]),q((r(),c("button",{class:re(["btn px-2",{"btn-active":_(e(Fe).banner,e(Ne).middle)}]),onClick:v[8]||(v[8]=ee=>$e(e(Fe).banner,e(Ne).middle))},[...v[28]||(v[28]=[s("i",{class:"oi oi-layout-banner-center oi-20"},null,-1)])],2)),[[de,"On the middle"]])],2)]),_:1},8,["class"]),e(y)===e(je).image?(r(),c("div",$a,[e(f)===e(Fe).banner?(r(),c("div",Fa,[C(H,null,{label:P(()=>[s("div",Ea,[se(k(e(i)("components.formEdit.theFieldLayout.height"))+" ",1),le("media.settings.height")?q((r(),c("button",{key:0,type:"button",class:"device-override-dot","aria-label":e(W),onClick:v[9]||(v[9]=ee=>A("media.settings.height"))},null,8,Sa)),[[de,e(W)]]):V("",!0)])]),default:P(()=>[s("div",Ta,[C(g,{modelValue:e(S),"onUpdate:modelValue":v[10]||(v[10]=ee=>Ce(S)?S.value=ee:null),type:"number",step:"10",placeholder:"auto"},null,8,["modelValue"]),C($,{distance:6},{popper:P(()=>[q((r(),c("div",{"aria-role":"listitem",class:"dropdown-item",onClick:v[11]||(v[11]=ee=>Ue("px"))},[...v[29]||(v[29]=[se(" px ",-1)])])),[[me]]),q((r(),c("div",{"aria-role":"listitem",class:"dropdown-item",onClick:v[12]||(v[12]=ee=>Ue("%"))},[...v[30]||(v[30]=[se(" % ",-1)])])),[[me]])]),default:P(()=>[s("button",Ca,k(e(x)),1)]),_:1})])]),_:1}),C(H,null,{label:P(()=>[s("div",Ia,[se(k(e(i)("components.formEdit.theFieldLayout.width"))+" ",1),le("media.settings.width")?q((r(),c("button",{key:0,type:"button",class:"device-override-dot","aria-label":e(W),onClick:v[13]||(v[13]=ee=>A("media.settings.width"))},null,8,La)),[[de,e(W)]]):V("",!0)])]),default:P(()=>[s("div",Aa,[C(g,{modelValue:e(N),"onUpdate:modelValue":v[14]||(v[14]=ee=>Ce(N)?N.value=ee:null),type:"number",step:"10",placeholder:e(i)("components.formEdit.theFieldLayout.auto")},null,8,["modelValue","placeholder"]),C($,{distance:6},{popper:P(()=>[q((r(),c("div",{"aria-role":"listitem",class:"dropdown-item",onClick:v[15]||(v[15]=ee=>Me("px"))},[...v[31]||(v[31]=[se(" px ",-1)])])),[[me]]),q((r(),c("div",{"aria-role":"listitem",class:"dropdown-item",onClick:v[16]||(v[16]=ee=>Me("%"))},[...v[32]||(v[32]=[se(" % ",-1)])])),[[me]])]),default:P(()=>[s("button",Va,k(e(I)),1)]),_:1})])]),_:1})])):V("",!0),e(X)?(r(),J(H,{key:1},{label:P(()=>[s("div",Da,[se(k(e(i)("components.formEdit.theFieldLayout.objectFit"))+" ",1),le("media.settings.objectFit")?q((r(),c("button",{key:0,t
6ype:"button",class:"device-override-dot","aria-label":e(W),onClick:v[17]||(v[17]=ee=>A("media.settings.objectFit"))},null,8,Ra)),[[de,e(W)]]):V("",!0)])]),default:P(()=>[C(ge,{"model-value":e(T),"aria-role":"list",scrollable:"","root-class":"w-full relative","menu-class":"w-full",selectable:"","onUpdate:modelValue":b},{trigger:P(()=>[C(te,{variant:"dropdown-select",class:"btn dropdown-type"},{default:P(()=>[s("span",null,k(e(L)),1),v[33]||(v[33]=s("i",{class:"oi oi-angle-down"},null,-1))]),_:1})]),default:P(()=>[(r(),c(ue,null,xe(ce,ee=>C(fe,{key:ee.value,value:ee.value,"aria-role":"listitem"},{default:P(()=>[se(k(e(i)(ee.labelKey)),1)]),_:2},1032,["value"])),64))]),_:1},8,["model-value"])]),_:1})):V("",!0),e(Q)&&e(T)!=="fill"?(r(),c("div",Oa,[s("div",Na,[s("label",Pa,k(e(i)("components.formEdit.theFieldLayout.focalPoint")),1),le("media.settings.focalPoint")?q((r(),c("button",{key:0,type:"button",class:"device-override-dot","aria-label":e(W),onClick:v[18]||(v[18]=ee=>A("media.settings.focalPoint"))},null,8,Ba)),[[de,e(W)]]):V("",!0)]),C(ba,{"image-url":e(E),"model-value":e(R),"onUpdate:modelValue":l},null,8,["image-url","model-value"])])):V("",!0),e(f)!=e(Fe).full?(r(),J(H,{key:3,label:e(i)("components.formEdit.theFieldLayout.altText")},{default:P(()=>[C(g,{modelValue:e(w),"onUpdate:modelValue":v[19]||(v[19]=ee=>Ce(w)?w.value=ee:null),type:"text",placeholder:e(i)("components.formEdit.theFieldLayout.imageDescription")},null,8,["modelValue","placeholder"])]),_:1},8,["label"])):V("",!0)])):V("",!0)],2)):V("",!0)]),_:1})])}}},ja=Be(Ma,[["__scopeId","data-v-be2da094"]]),Ua={key:0,class:"flex flex-col gap-5"},Ka={class:"flex flex-col gap-0.5"},Ha={class:"field-label"},qa={class:"flex flex-row items-center gap-2"},Wa={class:"flex items-center gap-2"},za=["title"],Ga={class:"w-full"},Ja={class:"field-addons"},Ya=["value"],Qa={class:"flex flex-col gap-2"},Xa={class:"subheading-sm"},Za={__name:"TheFieldSettings",setup(t){const{t:n}=Re(),{canUse:o,billingLoading:i}=Et(),{requireFeatureSettled:d}=Vn(),a=Ae(),u=gt(),m=rt(),f=Ye(),{isSandbox:p}=Gt(),{component:y,loadError:E,load:w,reload:S}=Bn(),x=F(()=>a.getCurrentField);let N=0;const I=F({get:()=>x.value?.type,set:j=>{const D=++N,L=Qe[j]?.requiredFeature;if(!L)return R(j);const M=x.value?.id;d(L,{stillCurrent:()=>D===N&&x.value?.id===M}).then(X=>X&&R(j))}});function R(j){if(x.value.answers>0){m.alert(n("components.formEdit.theFieldSettings.alert"));return}if(x.value.type==="group"&&j!=="group"&&a.fields.filter(X=>X.parentId===x.value.id).length>0){m.alert(n("components.formEdit.theFieldSettings.blockedTypeChangeGroup"),n("components.common.blockedActionDialog.titleTypeChange"));return}if(uo(a.fields,x.value.id).length>0){m.alert(n("components.formEdit.theFieldSettings.blockedTypeChange"),n("components.common.blockedActionDialog.titleTypeChange"));return}const L=x.value.id,M={...x.value};f.execute({resourceKey:`field:${L}:type`,actionKey:"actions.updateFieldType",execute:async()=>{await a.updateFieldType({fieldId:L,type:j})},rollback:()=>{a.updateFieldInStore(M)}})}const T=F(()=>Qe[I.value]),ce=F(()=>I.value!=="welcome-screen"&&I.value!=="ending-screen");async function be(j){if(!j){y.value=null;return}await w(()=>Pn(Object.assign({
6"./field-types/calendly/CalendlySettings.vue":()=>he(()=>import("./BEopBAHn.js"),__vite__mapDeps([81,82,3,4,83,5,6,19,20,12,13,21,22,23,24,25,26,27,8,28,29,30,31,14,32,33,15,34,35,36,37,38,2,7,39,40,11,16,41,42,43,44,84]),import.meta.url),
6"./field-types/date/DateSettings.vue":()=>he(()=>import("./Cl1ETbmC.js"),__vite__mapDeps([85,82,3,4,19,20,12,13,21,22,23,24,25,5,6,26,27,8,28,29,30,31,14,32,33,15,34,35,36,37,38,2,7,39,40,11,16,41,42,43,44]),import.meta.url),
6"./field-types/dropdown/DropdownSettings.vue":()=>he(()=>import("./dBne8-Yr.js"),__vite__mapDeps([86,82,3,4,19,20,12,13,21,22,23,24,25,5,6,26,27,8,28,29,30,31,14,32,33,15,34,35,36,37,38,2,7,39,40,11,16,41,42,43,44]),import.meta.url),
6"./field-types/email/EmailSettings.vue":()=>he(()=>import("./dbUDvmOn.js"),__vite__mapDeps([87,82,3,4,88,19,20,12,13,21,22,23,24,25,5,6,26,27,8,28,29,30,31,14,32,33,15,34,35,36,37,38,2,7,39,40,11,16,41,42,43,44]),import.meta.url),
6"./field-types/ending-screen/EndingScreenSettings.vue":()=>he(()=>import("./Cgz7hdOl.js"),__vite__mapDeps([89,2,3,4,5,6,7,12,13,48,8,19,20,21,22,23,24,25,26,27,28,29,30,31,14,32,33,15,34,35,36,37,38,39,40,11,16,41,42,43,44]),import.meta.url),
6"./field-types/file-upload/FileUploadSettings.vue":()=>he(()=>import("./BUf_zBzK.js"),__vite__mapDeps([90,82,3,4,19,20,12,13,21,22,23,24,25,5,6,26,27,8,28,29,30,31,14,32,33,15,34,35,36,37,38,2,7,39,40,11,16,41,42,43,44]),import.meta.url),
6"./field-types/group/GroupSettings.vue":()=>he(()=>import("./DSxYFM1P.js"),__vite__mapDeps([91,48,3,4,19,20,12,13,21,22,23,24,25,5,6,26,27,8,28,29,30,31,14,32,33,15,34,35,36,37,38,2,7,39,40,11,16,41,42,43,44]),import.meta.url),
6"./field-types/long-text/LongTextSettings.vue":()=>he(()=>import("./CNn3H7tR.js"),__vite__mapDeps([92,82,3,4,12,13,19,20,21,22,23,24,25,5,6,26,27,8,28,29,30,31,14,32,33,15,34,35,36,37,38,2,7,39,40,11,16,41,42,43,44]),import.meta.url),
6"./field-types/matrix/MatrixSettings.vue":()=>he(()=>import("./C8s0gcIs.js"),__vite__mapDeps([93,82,3,4,19,20,12,13,21,22,23,24,25,5,6,26,27,8,28,29,30,31,14,32,33,15,34,35,36,37,38,2,7,39,40,11,16,41,42,43,44]),import.meta.url),
6"./field-types/multiple-choice/MultipleChoiceSettings.vue":()=>he(()=>import("./BR9h5ZlP.js"),__vite__mapDeps([94,82,3,4,19,20,12,13,21,22,23,24,25,5,6,26,27,8,28,29,30,31,14,32,33,15,34,35,36,37,38,2,7,39,40,11,16,41,42,43,44]),import.meta.url),
6"./field-types/nps/NpsSettings.vue":()=>he(()=>import("./CMQti2-S.js"),__vite__mapDeps([95,82,3,4,19,20,12,13,21,22,23,24,25,5,6,26,27,8,28,29,30,31,14,32,33,15,34,35,36,37,38,2,7,39,40,11,16,41,42,43,44]),import.meta.url),
6"./field-types/number/NumberSettings.vue":()=>he(()=>import("./DrO6LNyw.js"),__vite__mapDeps([96,82,3,4,19,20,12,13,21,22,23,24,25,5,6,26,27,8,28,29,30,31,14,32,33,15,34,35,36,37,38,2,7,39,40,11,16,41,42,43,44]),import.meta.url),
6"./field-types/opinion-scale/OpinionScaleSettings.vue":()=>he(()=>import("./CVucr25c.js"),__vite__mapDeps([97,82,3,4,19,20,12,13,21,22,23,24,25,5,6,26,27,8,28,29,30,31,14,32,33,15,34,35,36,37,38,2,7,39,40,11,16,41,42,43,44]),import.meta.url),
6"./field-types/phone/PhoneSettings.vue":()=>he(()=>import("./DWS0tUZb.js"),__vite__mapDeps([98,82,3,4,88,67,68,19,20,12,13,21,22,23,24,25,5,6,26,27,8,28,29,30,31,14,32,33,15,34,35,36,37,38,2,7,39,40,11,16,41,42,43,44]),import.meta.url),
6"./field-types/picture-choice/PictureChoiceSettings.vue":()=>he(()=>import("./Cm0sxWpb.js"),__vite__mapDeps([99,82,3,4,19,20,12,13,21,22,23,24,25,5,6,26,27,8,28,29,30,31,14,32,33,15,34,35,36,37,38,2,7,39,40,11,16,41,42,43,44]),import.meta.url),
6"./field-types/rating/RatingSettings.vue":()=>he(()=>import("./D4e9COxU.js"),__vite__mapDeps([100,82,3,4,73,19,20,12,13,21,22,23,24,25,5,6,26,27,8,28,29,30,31,14,32,33,15,34,35,36,37,38,2,7,39,40,11,16,41,42,43,44]),import.meta.url),
6"./field-types/scheduling/SchedulingSettings.vue":()=>he(()=>import("./CKjz5p6A.js"),__vite__mapDeps([101,82,3,4,83,5,6,102,12,13,28,29,26,23,27,19,20,21,22,24,25,8,30,31,14,32,33,15,34,35,36,37,38,2,7,39,40,11,16,41,42,43,44]),import.meta.url),
6"./field-types/short-text/ShortTextSettings.vue":()=>he(()=>import("./BTObhxMJ.js"),__vite__mapDeps([103,82,3,4,12,13,19,20,21,22,23,24,25,5,6,26,27,8,28,29,30,31,14,32,33,15,34,35,36,37,38,2,7,39,40,11,16,41,42,43,44]),import.meta.url),
6"./field-types/statement/StatementSettings.vue":()=>he(()=>import("./BNib9XAA.js"),__vite__mapDeps([104,48,3,4,19,20,12,13,21,22,23,24,25,5,6,26,27,8,28,29,30,31,14,32,33,15,34,35,36,37,38,2,7,39,40,11,16,41,42,43,44]),import.meta.url),
6"./field-types/website/WebsiteSettings.vue":()=>he(()=>import("./DLiyceJr.js"),__vite__mapDeps([105,82,3,4,19,20,12,13,21,22,23,24,25,5,6,26,27,8,28,29,30,31,14,32,33,15,34,35,36,37,38,2,7,39,40,11,16,41,42,43,44]),import.meta.url),
6"./field-types/welcome-screen/WelcomeScreenSettings.vue":()=>he(()=>import("./DxZAxS7-.js"),__vite__mapDeps([106,48,3,4,19,20,12,13,21,22,23,24,25,5,6,26,27,8,28,29,30,31,14,32,33,15,34,35,36,37,38,2,7,39,40,11,16,41,42,43,44]),import.meta.url),
6"./field-types/yes-no/YesNoSettings.vue":()=>he(()=>import("./Jhck_d1a.js"),__vite__mapDeps([107,82,3,4,19,20,12,13,21,22,23,24,25,5,6,26,27,8,28,29,30,31,14,32,33,15,34,35,36,37,38,2,7,39,40,11,16,41,42,43,44]),import.meta.url)
6}),`./field-types/${j}/${En(j)}Settings.vue`,4))}function ae(){return ro({isChild:!!x.value?.parentId}).filter(j=>Wt(j,{sandbox:p.value,current:x.value?.type}))}async function W(j){try{await navigator.clipboard.writeText(j),u.success(n("common.feedback.copySuccess"))}catch{u.error(n("common.feedback.copyError"))}}return He(I,async()=>{await be(I.value)}),nt(async()=>{await be(I.value)}),(j,D)=>{const L=at,M=ye("o-button"),Q=ye("o-icon"),X=ye("o-dropdown-item"),ie=ye("o-dropdown"),pe=ht,B=ja,K=Ie("tooltip");return r(),c("div",null,[e(x)?(r(),c("div",Ua,[q((r(),c("div",Ka,[s("div",Ha,k(e(n)("components.formEdit.theFieldSettings.type")),1),s("div",null,[e(x)?(r(),J(ie,{key:0,modelValue:e(I),"onUpdate:modelValue":D[0]||(D[0]=ne=>Ce(I)?I.value=ne:null),"aria-role":"list",scrollable:"","max-height":200,"root-class":"w-full relative","menu-class":"w-full",disabled:!e(ce),selectable:""},{trigger:P(()=>[C(M,{variant:"dropdown-select",class:"btn dropdown-type"},{default:P(()=>[s("div",qa,[C(L,{type:e(I)},null,8,["type"]),se(" "+k(e(n)(e(T).name)),1)]),D[2]||(D[2]=s("i",{class:"oi oi-angle-down"},null,-1))]),_:1})]),default:P(()=>[(r(!0),c(ue,null,xe(ae(),ne=>(r(),J(X,{key:ne,value:ne,"aria-role":"listitem"},{default:P(()=>[s("div",{class:re([e(Qe)[ne].color,"h-6 w-6 px-2 flex items-center justify-center rounded-md"])},[C(Q,{icon:e(Qe)[ne].icon,size:"sm",class:re(e(Qe)[ne].color)},null,8,["icon","class"])],2),s("div",Wa,[se(k(e(n)(e(Qe)[ne].name))+" ",1),e(Qe)[ne].requiredFeature&&!e(i)&&!e(o)(e(Qe)[ne].requiredFeature)?(r(),c("span",{key:0,class:"feature-locked text-gray-400",title:e(n)("upgradeRequired.features.scheduling.name")},[...D[3]||(D[3]=[s("i",{class:"oi oi-lock-2 oi-sm"},null,-1)])],8,za)):V("",!0)])]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue","disabled"])):V("",!0)])])),[[K,e(ce)?"":e(n)("components.formEdit.theFieldSettings.welcome")]]),s("div",Ga,[D[5]||(D[5]=s("label",{for:"fieldId",class:"field-label"},"ID",-1)),s("div",Ja,[s("input",{id:"fieldId",class:"input input-sm items-center justify-center bg-neutral-lightest border-neutral-lightest shadow-none hover:border-primary",value:e(x).id,readonly:""},null,8,Ya),q((r(),c("button",{class:"btn btn-sm btn-action",onClick:D[1]||(D[1]=ne=>W(e(x).id))},[...D[4]||(D[4]=[s("i",{class:"oi oi-copy-paste"},null,-1)])])),[[K,e(n)("forms.share.tooltipCopy")]])])]),D[7]||(D[7]=s("div",{class:"h-1 border-t-2 border-neutral-lightest"},null,-1)),s("div",Qa,[s("div",Xa,k(e(n)("components.formEdit.theFieldSettings.settings")),1),e(y)&&!e(E)?(r(),J(Fn(e(y)),{key:e(x).id,class:"flex flex-col gap-4"})):V("",!0),e(E)?(r(),J(pe,{key:1,variant:"error",message:e(n)("components.formEdit.theFieldSettings.loadError"),"show-reload":"",onReload:e(S)},null,8,["message","onReload"])):V("",!0)]),e(x).parentId?V("",!0):(r(),c(ue,{key:0},[D[6]||(D[6]=s("div",{class:"h-1 border-t-2 border-neutral-lightest"},null,-1)),(r(),J(B,{key:e(x).id}))],64))])):(r(),J(pe,{key:1,variant:"empty",message:e(n)("components.formEdit.theFieldSettings.select"),icon:"oi-settings-slider",class:"py-10"},null,8,["message"]))])}}},er=Be(Za,[["__scopeId","data-v-afbe8d83"]]);function Yt(){const t=Ae(),n=Ye(),o=F(()=>t.getCurrentField),i=F({get:()=>o.value?.required||!1,set:f=>{const p=o.value?.id;if(!p)return;const y=`field:${p}:required`,E=o.value.required;t.updateFieldRequiredInStore({fieldId:p,required:f}),n.execute({id:y,resourceKey:y,actionKey:"actions.updateFieldRequired",execute:async()=>{await t.updateFieldRequired({fieldId:p,required:f})},rollback:()=>{t.updateFieldRequiredInStore({fieldId:p,required:E})}})}});function d(f,p){const y=o.value?.id;if(!y)return;const E=`field:${y}:setting:${f}`,w=o.value?.settings?.[f];t.updateFieldSettingInStore({fieldId:y,setting:f,value:p}),n.execute({id:E,resourceKey:E,actionKey:"actions.updateFieldSetting",execute:async()=>{await t.updateFieldSetting({fieldId:y,setting:f,value:p})},rollback:()=>{t.updateFieldSettingInStore({fieldId:y,setting:f,value:w})}})}function a(f,p){return u(o.value,f,p)}function u(f,p,y){return f?.settings?f.settings[p]??y:y}function m(f,p="",y={}){const{debounce:E=1e3,transform:w=null,actionKey:S="actions.updateFieldSetting",fieldId:x=null}=y,N=()=>x?t.getFieldById(x):o.value;return F({get:()=>u(N(),f,p),set:I=>{const R=N()?.id;if(!R)return;const T=`field:${R}:setting:${f}`;n.debounced({resourceKey:T,actionKey:S,initialValue:u(N(),f,p),value:I,apply:ce=>{t.updateFieldSettingInStore({fieldId:R,setting:f,value:ce})},execute:async ce=>{const be=w?w(ce):ce;await t.updateFieldSetting({fieldId:R,setting:f,value:be})},debounce:E})}})}
6return{field:o,required:i,updateSetting:d,getSetting:a,useSettingModel:m}}const tr={class:"flex items-center gap-2 w-full mb-1"},nr={class:"w-ful flex items-center gap-2"},or={__name:"FieldSettingSwitch",props:{setting:{type:String,required:!0},name:{type:String,required:!0},disabled:{type:Boolean,default:!1},help:{type:String,default:""}},emits:["update"],setup(t,{emit:n}){const{t:o}=Re(),i=t,d=n,{updateSetting:a,getSetting:u}=Yt();gt();const m=Z(!1),f=F(()=>{const E=i.help?"<br><br>":"";return i.disabled?`${i.help}${E} ${o("components.formEdit.fieldSettingSwitch.upgradeYourPlan")}`:i.help}),p=F(()=>u(i.setting,!1));He(p,E=>{m.value=E}),nt(()=>{m.value=u(i.setting,!1)});async function y(E){const w=!E;try{await a(i.setting,E,w),Ke(()=>{m.value=E}),d("update",E)}catch{Ke(()=>{m.value=w})}}return(E,w)=>{const S=Dn,x=ye("o-switch"),N=Ie("tooltip");return r(),c("div",tr,[t.disabled?(r(),J(S,{key:0})):V("",!0),q((r(),J(x,{modelValue:e(m),"onUpdate:modelValue":w[0]||(w[0]=I=>Ce(m)?m.value=I:null),"root-class":"flex flex-1 justify-between items-center",position:"left",disabled:t.disabled,onInput:y},{default:P(()=>[s("div",nr,k(t.name),1)]),_:1},8,["modelValue","disabled"])),[[N,{content:e(f),html:!0}]])])}}},Ut=20,Kt=500;function Ht(t){if(t===""||t===null||t===void 0)return null;const n=Number.parseInt(t,10);return Number.isNaN(n)?null:Math.min(Math.max(n,Ut),Kt)}function ir(t){const n=Ht(t);return n!==null&&Number(t)===n}const sr={class:"flex flex-col gap-2"},lr={key:0,class:"flex flex-col gap-1"},ar={class:"field-label"},rr=["innerHTML"],dr={key:0,class:"flex items-start gap-1.5 rounded-md bg-yellow-lightest px-2 py-1.5 text-xs text-yellow-darkest"},ur={key:1,class:"flex flex-col gap-1"},cr={class:"field-label"},mr={class:"text-xs text-neutral"},fr={__name:"AiTextGenerationSettings",props:{part:{type:String,required:!0,validator:t=>t==="title"||t==="description"}},setup(t){const n=t,{t:o}=Re(),{getSetting:i,useSettingModel:d,field:a}=Yt(),u=Ae(),m={title:80,description:220},f=F(()=>n.part==="description"?"enableAiDescription":"enableAiTitle"),p=F(()=>n.part==="description"?"aiDescriptionPrompt":"aiTitlePrompt"),y=F(()=>n.part==="description"?"aiDescriptionMaxTokens":"aiTitleMaxTokens"),E=F(()=>i(f.value,!1)),w=d(p.value,""),S=d(y.value,null,{fieldId:a.value?.id}),x=F(()=>m[n.part]),N=F(()=>E.value&&String(w.value||"").trim()!==""&&!Co(w.value)),I=Z(null),R=F({get:()=>I.value??S.value??"",set:W=>{if(!ir(W)){I.value=W;return}S.value=Ht(W),I.value=null}});function T(){I.value!==null&&(S.value=Ht(I.value),I.value=null)}Sn(T);const ce=F(()=>a.value?.id),be=F(()=>{const W=[Io(o)];return(u.form?.variables||[]).forEach(M=>{M?.name&&W.push({type:"variable",value:M.name,id:M.name})}),(u.form?.hiddenFields||[]).forEach(M=>{const Q=M?.name||M;Q&&W.push({type:"hidden",value:Q,id:Q})}),["utm_source","utm_medium","utm_campaign","utm_term","utm_content"].forEach(M=>{W.push({type:"tracking",value:M,id:M})}),ce.value&&u.getFieldsBefore(ce.value).filter(M=>M?.type!=="statement"&&M?.id!==ce.value).forEach(M=>{const Q=lt(String(M?.title||""));W.push({type:"field",id:M.id,value:Q,fieldType:M.type,position:M.position})}),W});function ae({query:W}){const j=be.value;if(!W)return j;const D=String(W).toLowerCase();return j.filter(L=>String(L.value||"").toLowerCase().startsWith(D)||String(L.id||"").toLowerCase().startsWith(D))}return(W,j)=>{const D=or,L=Do,M=ye("o-icon"),Q=ye("o-input");return r(),c("div",sr,[C(D,{setting:e(f),name:W.$t(`components.formEdit.aiTextGeneration.${t.part}.switch`),help:W.$t(`components.formEdit.aiTextGeneration.${t.part}.switchHelp`)},null,8,["setting","name","help"]),e(E)?(r(),c("div",lr,[s("label",ar,k(W.$t("components.formEdit.aiTextGeneration.promptLabel")),1),C(L,{"model-value":e(w),"suggestion-query":ae,"enable-mention":!0,multiline:!0,"input-class":"min-h-[6rem] py-2",placeholder:W.$t(`components.formEdit.aiTextGeneration.${t.part}.promptPlaceholder`),"onUpdate:modelValue":j[0]||(j[0]=X=>w.value=X)},null,8,["model-value","placeholder"]),s("p",{class:"text-xs text-neutral",innerHTML:W.$t(`components.formEdit.aiTextGeneration.${t.part}.promptHelp`)},null,8,rr),e(N)?(r(),c("div",dr,[C(M,{icon:"oi-alert-circle",class:"mt-0.5 shrink-0"}),s("span",null,k(W.$t("components.formEdit.aiTextGeneration.noMentionWarning")),1)])):V("",!0)])):V("",!0),e(E)?(r(),c("div",ur,[
6s("label",cr,k(W.$t("components.formEdit.aiTextGeneration.maxTokensLabel")),1),C(Q,{modelValue:e(R),"onUpdate:modelValue":j[1]||(j[1]=X=>Ce(R)?R.value=X:null),type:"number",min:e(Ut),max:e(Kt),placeholder:String(e(x)),onBlur:T,onKeydown:co(T,["enter"])},null,8,["modelValue","min","max","placeholder"]),s("p",mr,k(W.$t("components.formEdit.aiTextGeneration.maxTokensHelp",{min:e(Ut),max:e(Kt),default:e(x)})),1)])):V("",!0)])}}},pr={key:0,class:"flex flex-col gap-5"},gr={class:"flex items-center gap-2 text-sm text-neutral"},vr=["innerHTML"],hr={__name:"TheFieldAiSettings",setup(t){const{field:n}=Yt();return(o,i)=>{const d=fr,a=ht;return e(n)?(r(),c("div",pr,[s("div",gr,[i[0]||(i[0]=s("i",{class:"oi oi-light-bulb-shine text-fuchsia text-base"},null,-1)),s("span",{innerHTML:o.$t("components.formEdit.aiTextGeneration.intro")},null,8,vr)]),(r(),J(d,{key:`${e(n).id}-ai-title`,part:"title"})),(r(),J(d,{key:`${e(n).id}-ai-description`,part:"description"}))])):(r(),J(a,{key:1,title:o.$t("components.formEdit.theFieldSettings.select")},null,8,["title"]))}}},yr={class:"group hover:border-lime-dark focus-within:border-lime-darker text-sm font-medium lowercase border border-lime bg-lime-lighter text-lime-darkest rounded pl-1 pr-2 h-6 flex gap-1 items-center"},br={class:"min-w-0 flex-1"},_r={class:"input-editor min-w-[30px] w-full truncate"}
6,wr={__name:"FormVariable",props:{name:{type:String,required:!0},type:{type:String,required:!0}},setup(t){const n=t,o=F(()=>{const i={number:"oi-hashtag",string:"oi-text-style",boolean:"oi-checkbox-line"};return i[n.type]||i.number});return(i,d)=>{const a=Ie("tooltip");return r(),c("div",yr,[q(s("i",{class:re(["oi oi-16 text-lime-darker",[e(o),{"text-xs":t.type==="string"}]])},null,2),[[a,t.type]]),s("div",br,[q((r(),c("div",_r,[se(k(t.name),1)])),[[a,t.name]])])])}}},St=Be(wr,[["__scopeId","data-v-499e2334"]]),xr={class:"condition relative group"},kr={class:"btn btn-dropdown-select !flex !justify-between !gap-2 min-w-0"},$r={class:"flex items-center gap-2 w-full min-w-0"},Fr={class:"text-2xs uppercase font-bold"},Er={key:0,class:"flex flex-nowrap w-full max-w-full truncate"},Sr=["innerHTML"],Tr={key:2,class:"flex items-center gap-2 cursor-pointer"},Cr={class:"text-neutral-darkest text-sm truncate"},Ir={key:3,class:"flex items-center gap-2 cursor-pointer"},Lr={class:"text-neutral-darkest text-sm truncate"},Ar={class:"max-h-96 max-w-lg"},Vr={class:"dropdown-title"},Dr=["onClick"],Rr={class:"dropdown-title"},Or=["onClick"],Nr=["innerHTML"],Pr={class:"dropdown-group-header","aria-role":"presentation"},Br=["innerHTML"],Mr=["onClick"],jr=["innerHTML"],Ur={class:"dropdown-title"},Kr=["onClick"],Hr={class:"truncate"},qr={class:"dropdown-title"},Wr=["onClick"],zr={class:"truncate"},Gr={key:0,class:"flex items-center gap-2 w-full"},Jr={class:"btn btn-dropdown-select !flex !justify-between !gap-2 min-w-0"},Yr={class:"text-neutral-darkest text-sm truncate max-w-full"},Qr={class:"max-h-96 max-w-lg overflow-auto"},Xr=["onClick"],Zr={class:"option-name"},ed={key:1,class:"flex items-center gap-2 w-full"},td={class:"btn btn-dropdown-select !flex !justify-between !gap-2"},nd={class:"text-neutral-darkest text-2xs uppercase font-bold whitespace-nowrap"},od=["onClick"],id={class:"truncate"},sd={class:"text-neutral"},ld={key:0,class:"flex-grow overflow-hidden relative"},ad={class:"relative w-full"},rd={class:"text-neutral-darkest text-2xs uppercase font-bold whitespace-nowrap"},dd={class:"truncate flex-grow"},ud={key:2,class:"flex items-center gap-2"},cd={class:"text-sm"},md={key:3,class:"flex items-center gap-2"},fd={class:"text-sm"},pd={class:"dropdown-title"},gd={class:"dropdown-title"},vd=["onClick"],hd={class:"dropdown-title"},yd=["onClick"],bd={class:"truncate"},_d={class:"dropdown-title"},wd=["onClick"],xd={class:"truncate"},kd={class:"btn btn-dropdown-select !flex !justify-between !gap-2 min-w-0"},$d={class:"option-name"},Fd={class:"max-h-96 max-w-lg"},Ed=["onClick"],Sd={class:"option-name"},Td={__name:"LogicConditionEditor",props:{index:{type:Number,required:!0},canDelete:{type:Boolean,default:!0},condition:{type:Object,required:!0}},emits:["delete","add","update"],setup(t,{emit:n}){const o={FIELD:"field",VARIABLE:"variable",TRACKING:"tracking",HIDDENFIELD:"hiddenField",UNKNOWN:"unknown"},i=t,d=n,a=Ae(),u=Z(""),m=Z(""),f=Z(""),p=Z(""),y=Z(""),E=Z(""),w=Z(""),S=Z(!1),x=Z(!1),N=F(()=>a.form.variables),{t:I}=Re(),R=F(()=>({content:wt(i.condition.value,T.value,I),html:!0})),T=F(()=>a.getFieldById(m.value)),ce=F(()=>a.getConditionFieldsBefore(a.getCurrentFieldId)),be=F(()=>Ro(ce.value,g=>a.getFieldById(g))),ae=F(()=>a.getVariableByName(u.value)),W=()=>{if(m.value)return et.field;if(u.value)return et.variable;if(f.value)return et.hiddenField;if(p.value)return et.tracking},j=()=>{if(m.value)return T.value;if(u.value)return ae.value;if(f.value)return f.value;if(p.value)return p.value},D=F(()=>{const g=W(),$=j();return!g||!$?[]:Cn(g,$).getOperators()}),L=F(()=>!["isEmpty","isNotEmpty","isTheGreatest","isTheLeast"].includes(E.value)),M=F(()=>mo(T.value?.type)),Q=F(()=>M.value.conditionExtras.includes("rowLabel")),X=F(()=>T.value&&M.value.getRowOptions?M.value.getRowOptions(T.value):[]),ie=F(()=>T.value&&M.value.getValueOptions?M.value.getValueOptions(T.value):[]),pe=F(()=>W()!==et.field?!1:M.value.valueOptionOperators.includes(E.value)&&ie.value.length>0),B=F(()=>sn(w.value)?.identifier??""),K=F(()=>a.getFieldById(B.value)),ne=F(()=>{const g=sn(w.value);return g&&o[g.type.toUpperCase()]||o.UNKNOWN}),we=F(()=>!(W()===et.field&&["eq","notEq"].includes(E.value)&&T.value&&fo(T.value.type)||["isEmpty","isNotEmpty","isTheGreatest","isTheLeast"].includes(E.value)));nt(()=>{m.value=i.condition.fieldId,u.value=i.condition.variableName,f.value=i.condition.hiddenField,p.value=i.condition.tracking,y.value=i.condition.rowLabel??"",E.value=i.condition.operator,w.value=i.condition.value;const g=l(),$=Me();(g||$)&&!ve()&&Te()});const ve=()=>{const g=pe.value&&!en(ie.value,i.condition.value)&&_t(ie.value,i.condition.value)===void 0,$=Q.value&&X.value.length>0&&!X.value.includes(i.condition.rowLabel)&&_t(X.value,i.condition.rowLabel)===void 0;return g||$},G=g=>{w.value=It("variable",g),S.value=!1,Te()},U=g=>{w.value=It("hiddenField",g),S.value=!1,Te()},oe=g=>{w.value=It("tracking",g),S.value=!1,Te()},ke=()=>{w.value="",Te(),Ke(()=>{S.value=!0})},Ee=()=>{d("delete",i.index)},_e=()=>{d("add",Ue())},le=g=>{_(),m.value=g,b(),l(),Me(),Te()},O=g=>{y.value=g,Te()},A=g=>{_(),u.value=g,b(),l(),Te()},z=g=>{_(),f.value=g,b(),l(),Te()},$e=g=>{_(),p.value=g,b(),l(),Te()},Se=g=>{w.value=g,Te()},Le=g=>{E.value=g,l(),Te()},Te=()=>{d("update",Ue())},Ue=()=>({index:i.index,condition:Tn({field:T.value,variable:ae.value,hiddenField:f.value,tracking:p.value,operator:E.value,value:w.value,rowLabel:y.value})}),Me=()=>{if(!Q.value)return y.value="",!1;const g=X.value;if(!g.length)return y.value="",!1;if(g.includes(y.value))return!1;const $=_t(g,y.value);return y.value=$??g[0],$!==void 0},l=()=>{if(!pe.value||en(ie.value,w.value))return!1;const g=_t(ie.value,w.value);return w.value=g??Pt(ie.value[0]),g!==void 0},b=()=>{D.value.includes(E.value)||(E.value=D.value[0].name)},_=()=>{m.value=void 0,u.value=void 0,f.value=void 0,p.value=void 0},h=()=>{we.value&&!w.value&&(S.value=!0)},v=g=>{g===""&&we.value?S.value=!0:S.value=!1},H=g=>{x.value||(S.value=!1,Se(g.target.value))};return(g,$)=>{const te=at,fe=St,ge=ye("VDropdown"),de=ye("o-input"),me=Ie("tooltip"),ee=Ie("close-popper");return r(),c("div",xr,[C(ge,{distance:6},{popper:P(()=>
6[s("div",Ar,[s("div",Vr,k(g.$t("components.formEdit.logicConditionEditor.variables")),1),(r(!0),c(ue,null,xe(e(N),Y=>q((r(),c("div",{key:`variable-${Y.name}`,"aria-role":"listitem",class:"dropdown-item",onClick:Oe=>A(Y.name)},[C(fe,{name:Y.name,type:Y.type},null,8,["name","type"])],8,Dr)),[[ee]])),128)),s("div",Rr,k(g.$t("components.formEdit.logicConditionEditor.fields")),1),(r(!0),c(ue,null,xe(e(be),(Y,Oe)=>(r(),c(ue,{key:`row-${Oe}`},[Y.kind==="field"?q((r(),c("div",{key:0,"aria-role":"listitem",class:"dropdown-item",onClick:qe=>le(Y.field.id)},[C(te,{type:Y.field.type,"show-position":!0,position:Y.field.position},null,8,["type","position"]),q(s("div",{class:"truncate",innerHTML:Y.field.title},null,8,Nr),[[me,{content:Y.field.title,html:!0}]])],8,Or)),[[ee]]):(r(),c(ue,{key:1},[s("div",Pr,[C(te,{type:Y.group.type,"show-position":!0,position:Y.group.position},null,8,["type","position"]),q(s("div",{class:"truncate",innerHTML:Y.group.title},null,8,Br),[[me,{content:Y.group.title,html:!0}]])]),(r(!0),c(ue,null,xe(Y.children,qe=>q((r(),c("div",{key:`child-${qe.id}`,"aria-role":"listitem",class:"dropdown-item dropdown-item-child",onClick:We=>le(qe.id)},[C(te,{type:qe.type,"show-position":!0,position:qe.position},null,8,["type","position"]),q(s("div",{class:"truncate",innerHTML:qe.title},null,8,jr),[[me,{content:qe.title,html:!0}]])],8,Mr)),[[ee]])),128))],64))],64))),128)),s("div",Ur,k(g.$t("components.formEdit.logicConditionEditor.hiddenFields")||"Hidden Fields"),1),(r(!0),c(ue,null,xe(e(a).getHiddenFields,Y=>q((r(),c("div",{key:`subject-hidden-${Y}`,"aria-role":"listitem",class:"dropdown-item",onClick:Oe=>z(Y)},[$[12]||($[12]=s("div",{class:"rounded tag-gray w-6 h-6 flex justify-center items-center"},[s("i",{class:"oi oi-view-off oi-14 text-white"})],-1)),s("div",Hr,k(Y),1)],8,Kr)),[[ee]])),128)),s("div",qr,k(g.$t("components.formEdit.logicConditionEditor.utms")||"UTMs"),1),(r(!0),c(ue,null,xe(e(a).getTracking,Y=>q((r(),c("div",{key:`subject-tracking-${Y}`,"aria-role":"listitem",class:"dropdown-item",onClick:Oe=>$e(Y)},[$[13]||($[13]=s("div",{class:"rounded tag-gray w-6 h-6 flex justify-center items-center"},[s("i",{class:"oi oi-cursor-double-click-3 oi-14 text-white"})],-1)),s("div",zr,k(Y),1)],8,Wr)),[[ee]])),128))])]),default:P(()=>[s("div",kr,[s("div",$r,[s("div",Fr,k(g.$t("components.formEdit.logicConditionEditor.if")),1),e(T)?(r(),c("div",Er,[q(C(te,{type:e(T).type,"show-position":!0,position:e(T).position,class:"cursor-pointer mr-1",hovered:!0},null,8,["type","position"]),[[me,g.$t("components.formEdit.logicConditionEditor.clickToChoose")]]),s("span",{class:"field-title text-neutral-darkest text-sm truncate max-w-full",innerHTML:e(T).title},null,8,Sr)])):V("",!0),e(u)?(r(),J(fe,{key:1,name:e(ae).name,type:e(ae).type,class:"cursor-pointer"},null,8,["name","type"])):V("",!0),e(f)?(r(),c("div",Tr,[$[9]||($[9]=s("div",{class:"h-6 w-6 flex-none flex items-center justify-center rounded tag-gray"},[s("i",{class:"oi oi-view-off oi-14 text-white"})],-1)),s("span",Cr,k(e(f)),1)])):V("",!0),e(p)?(r(),c("div",Ir,[$[10]||($[10]=s("div",{class:"h-6 w-6 flex-none flex items-center justify-center rounded tag-gray"},[s("i",{class:"oi oi-cursor-double-click-3 oi-14 text-white"})],-1)),s("span",Lr,k(e(p)),1)])):V("",!0)]),$[11]||($[11]=s("i",{class:"oi oi-angle-down"},null,-1))])]),_:1}),e(Q)?(r(),c("div",Gr,[C(ge,{distance:6},{popper:P(()=>[s("div",Qr,[(r(!0),c(ue,null,xe(e(X),(Y,Oe)=>q((r(),c("div",{key:`${e(m)}-row-${Oe}`,"aria-role":"listitem",class:"dropdown-item",onClick:qe=>O(Y)},[s("div",Zr,k(Y),1)],8,Xr)),[[ee]])),128))])]),default:P(()=>[s("div",Jr,[s("div",Yr,k(e(y)||g.$t("components.formEdit.logicConditionEditor.selectRow")),1),$[14]||($[14]=s("i",{class:"oi oi-angle-down"},null,-1))])]),_:1})])):V("",!0),e(E)?(r(),c("div",ed,[C(ge,{distance:6},{popper:P(()=>[(r(!0),c(ue,null,xe(e(D),(Y,Oe)=>q((r(),c("div",{key:`operator-${Oe}`,"aria-role":"listitem",class:"dropdown-item",onClick:qe=>Le(Y.name)},[s("div",id,k(g.$t(Y.label)),1),s("div",sd,k(Y.symbol),1)],8,od)),[[ee]])),128))]),default:P(()=>[s("div",td,[q((r(),c("div",nd,[se(k(e(tn)(e(E))?e(tn)(e(E)):g.$t(e(nn)(e(E)))),1)])),[[me,g.$t(e(nn)(e(E)))]]),$[15]||($[15]=s("i",{"data-v-03e8e103":"",class:"oi oi-angle-down"},null,-1))])]),_:1}),e(E)&&e(L)?(r(),c("div",ld,[s("div",ad,[e(pe)?V("",!0):(r(),J(ge,{key:0,ref:"myDropdown",shown:e(S),triggers:[],"auto-hide":!1,distance:6},{popper:P(()=>[s("div",{class:"max-h-96 max-w-lg overflow-auto",onMousedown:$[7]||($[7]=Y=>x.value=!0),onMouseup:$[8]||($[8]=Y=>x.value=!1)},[e(ae)&&e(ae).type==="boolean"?(r(),c(ue,{key:0},[s("div",pd,k(g.$t("components.formEdit.logicConditionEditor.staticValues")||"Static Values"),1),s("div",{class:"dropdown-item",onClick:$[5]||($[5]=Y=>{Se(!0),S.value=!1})},k(g.$t("components.formEdit.logicConditionEditor.true")),1),s("div",{class:"dropdown-item",onClick:$[6]||($[6]=Y=>{Se(!1),S.value=!1})},k(g.$t("components.formEdit.logicConditionEditor.false")),1)],64)):V("",!0),s("div",gd,k(g.$t("components.formEdit.logicConditionEditor.variables")),1),(r(!0),c(ue,null,xe(e(N),Y=>(r(),c("div",{key:`dyn-variable-${Y.name}`,class:"dropdown-item",onClick:Oe=>
6G(Y.name)},[C(fe,{name:Y.name,type:Y.type},null,8,["name","type"])],8,vd))),128)),s("div",hd,k(g.$t("components.formEdit.logicConditionEditor.hiddenFields")||"Hidden Fields"),1),(r(!0),c(ue,null,xe(e(a).getHiddenFields,Y=>(r(),c("div",{key:`dyn-hidden-field-${Y}`,class:"dropdown-item",onClick:Oe=>U(Y)},[$[20]||($[20]=s("div",{class:"rounded tag-gray w-6 h-6 flex justify-center items-center"},[s("i",{class:"oi oi-view-off oi-14 text-white"})],-1)),s("div",bd,k(Y),1)],8,yd))),128)),s("div",_d,k(g.$t("components.formEdit.logicConditionEditor.utms")||"UTMs"),1),(r(!0),c(ue,null,xe(e(a).getTracking,Y=>(r(),c("div",{key:`dyn-tracking-${Y}`,"data-test":"value-tracking",class:"dropdown-item",onClick:Oe=>oe(Y)},[$[21]||($[21]=s("div",{class:"rounded tag-gray w-6 h-6 flex justify-center items-center"},[s("i",{class:"oi oi-cursor-double-click-3 oi-14 text-white"})],-1)),s("div",xd,k(Y),1)],8,wd))),128))],32)]),default:P(()=>[e(on)(e(w))?V("",!0):(r(),c(ue,{key:0},[e(ae)&&e(ae).type==="boolean"?(r(),c("div",{key:0,class:"btn btn-dropdown-select !flex !justify-between !gap-2",onClick:h},[s("div",rd,k(e(w)?g.$t("components.formEdit.logicConditionEditor.true"):g.$t("components.formEdit.logicConditionEditor.false")),1),$[16]||($[16]=s("i",{class:"oi oi-angle-down"},null,-1))])):e(ae)&&e(ae).type==="number"?(r(),J(de,{key:1,ref:"valueInput",modelValue:e(w),"onUpdate:modelValue":$[0]||($[0]=Y=>Ce(w)?w.value=Y:null),type:"number",placeholder:"Value",class:"w-full",onFocus:h,onBlur:H,onInput:$[1]||($[1]=Y=>v(Y))},null,8,["modelValue"])):(r(),J(de,{key:2,ref:"valueInput",modelValue:e(w),"onUpdate:modelValue":$[2]||($[2]=Y=>Ce(w)?w.value=Y:null),type:"text",placeholder:"Value",class:"w-full",onFocus:h,onBlur:H,onInput:$[3]||($[3]=Y=>v(Y))},null,8,["modelValue"]))],64)),e(on)(e(w))?(r(),c("div",{key:1,class:"btn btn-dropdown-select !flex !justify-between !gap-1 px-1 min-w-0 truncate",onClick:$[4]||($[4]=Y=>S.value=!0)},[s("div",dd,[e(ne)===o.FIELD&&e(T)&&e(K)?q((r(),J(te,{key:0,type:e(K).type,"show-position":!0,position:e(T).position,class:"cursor-pointer mr-1",hovered:!0},null,8,["type","position"])),[[me,g.$t("components.formEdit.logicConditionEditor.clickToChoose")]]):V("",!0),e(ne)===o.VARIABLE&&e(a).getVariableByName(e(B))?(r(),J(fe,{key:1,name:e(a).getVariableByName(e(B)).name,type:e(a).getVariableByName(e(B)).type,class:"cursor-pointer"},null,8,["name","type"])):V("",!0),e(ne)===o.HIDDENFIELD?(r(),c("div",ud,[$[17]||($[17]=s("div",{class:"h-6 w-6 flex-none flex items-center justify-center rounded tag-gray"},[s("i",{class:"oi oi-view-off oi-14 text-white"})],-1)),q((r(),c("span",cd,[se(k(e(B)),1)])),[[me,e(B)]])])):V("",!0),e(ne)===o.TRACKING?(r(),c("div",md,[$[18]||($[18]=s("div",{class:"h-6 w-6 flex-none flex items-center justify-center rounded tag-gray"},[s("i",{class:"oi oi-cursor-double-click-3 oi-14 text-white"})],-1)),q((r(),c("span",fd,[se(k(e(B)),1)])),[[me,e(B)]])])):V("",!0)]),q((r(),c("button",{class:"btn btn-xs btn-action flex-shrink-0",onClick:tt(ke,["stop"])},[...$[19]||($[19]=[s("i",{class:"oi oi-close-line"},null,-1)])])),[[me,g.$t("components.formEdit.logicConditionEditor.clear")]])])):V("",!0)]),_:1},8,["shown"])),e(pe)?q((r(),J(ge,{key:1,distance:6},{popper:P(()=>[s("div",Fd,[(r(!0),c(ue,null,xe(e(ie),(Y,Oe)=>q((r(),c("div",{key:`${e(m)}-option-${Oe}`,"aria-role":"listitem",class:"dropdown-item",onClick:qe=>Se(Y)},[s("div",Sd,k(e(wt)(Y,e(T),g.$t)),1)],8,Ed)),[[me,{content:e(wt)(Y,e(T),g.$t),html:!0}],[ee]])),128))])]),default:P(()=>[s("div",kd,[s("div",$d,k(e(wt)(e(lt)(t.condition.value),e(T),g.$t)),1),$[22]||($[22]=s("i",{class:"oi oi-angle-down"},null,-1))])]),_:1})),[[me,e(R)]]):V("",!0)])])):V("",!0)])):V("",!0),q((r(),c("div",{class:"btn btn-xs hover:bg-neutral-lighter absolute -bottom-7 left-0 opacity-0 group-hover:opacity-100",onClick:_e},[se(k(g.$t("components.formEdit.logicConditionEditor.condition")),1)])),[[me,g.$t("components.formEdit.logicConditionEditor.addNewCondition")]]),t.canDelete?q((r(),c("div",{key:2,class:"btn btn-xs hover:bg-neutral-lighter absolute -bottom-7 right-0 opacity-0 group-hover:opacity-100",onClick:Ee},[$[23]||($[23]=s("i",{class:"oi oi-bin oi-12 mr-1"},null,-1)),se(" "+k(g.$t("components.formEdit.logicConditionEditor.delete")),1)])),[[me,g.$t("components.formEdit.logicConditionEditor.deleteThisCondition")]]):V("",!0)])}}},Cd={class:"flex flex-col items-center w-full"},Id={key:0,class:"flex h-3"},Ld={key:1,class:"rounded bg-neutral-lighter py-0.5 px-0.5 flex font-bold text-2xs uppercase items-center"},Ad={key:0,class:"px-1.5 border border-transparent"},Vd={key:2,class:"flex h-3"},Dd={__name:"LogicLogicalOperator",props:{operator:{type:String,default:"or"},hasBefore:{type:Boolean,default:!0},hasAfter:{type:Boolean,default:!0},readonly:{type:Boolean,default:!1}},emits:["change"],setup(t,{emit:n}){const o=t,i=n,d=a=>{o.readonly||i("change",a)};return(a,u)=>(r(),c("div",Cd,[t.hasBefore?(r(),c("div",Id,[...u[2]||(u[2]=[s("div",{class:"h-full flex-grow"},null,-1),s("div",{class:"h-full w-0.5 bg-neutral-lighter"},null,-1),s("div",{class:"h-full flex-grow"},null,-1)])])):V("",!0),t.hasBefore&&t.hasAfter?(r(),c("div",Ld,[t.readonly?(r(),c("div",Ad,k(a.$t(`components.formEdit.logicLogicalOperator.${t.operator}`)),1)):(r(),c(ue,{key:1},[s("div",{class:re({"btn-logical-operator":t.operator==="or","px-1.5 border border-transparent cursor-pointer":t.operator!=="or"}),onClick:u[0]||(u[0]=m=>d("or"))},k(a.$t("components.formEdit.logicLogicalOperator.or")),3),s("div",{class:re({"btn-logical-operator":t.operator==="and","px-1.5 border border-transparent cursor-pointer":t.operator!=="and"}),onClick:u[1]||(u[1]=m=>d("and"))},k(a.$t("components.formEdit.logicLogicalOperator.and")),3)],64))])):V("",!0),t.hasAfter?(r(),c("div",Vd,[...u[3]||(u[3]=[s("div",{class:"h-full flex-grow"},null,-1),s("div",{class:"h-full w-0.5 bg-neutral-lighter"},null,-1),s("div",{class:"h-full flex-grow"},null,-1)])])):V("",!0)]))}},Rd={class:"action relative group"},Od={class:"text-2xs uppercase font-bold"},Nd={class:"btn btn btn-dropdown-select"},Pd=["onClick"],Bd={class:"flex items-center gap-2"},Md={class:"btn btn-dropdown-select !flex !justify-between !gap-2 px-1"},jd=["innerHTML"],Ud={class:"max-h-96 max-w-lg"},Kd=["onClick"],Hd=["innerHTML"],qd={class:"btn btn-dropdown-select !flex !justify-between !gap-2"},Wd={class:"text-neutral-darkest text-2xs uppercase font-bold whitespace-nowrap"},zd={class:"max-h-96 max-w-lg overflow-auto"},Gd={key:2,class:"relative w-full"},Jd={class:"truncate"},Yd={key:0,class:"flex items-center gap-2"},Qd={class:"text-sm"},Xd={class:"dropdown-title"},Zd=["onClick"],eu={class:"truncate"},tu={class:"text-2xs uppercase font-bold"},nu=["onClick"],ou={__name:"LogicActionEditor",props:{index:{type:Number,required:!0},canDelete:{type:Boolean,default:!0},action:{type:Object,required:!0},ruleModel:{type:Array,required:!0}},emits:["update","delete","add"],setup(t,{emit:n}){const o={FIELD:"field",VARIABLE:"variable",TRACKING:"tracking",HIDDEN_FIELD:"hiddenField",UNKNOWN:"unknown"},i=t,d=n,a=Ae(),{t:u}=Re(),m=Z(""),f=Z(""),p=Z(""),y=Z(!1),E=Z(!1),w=F({get:()=>p.value,set:A=>U(A)}),S=F(()=>
6{if(!M(p.value))return null;const A=p.value.match(/\{\{(.+?):.+?\}\}/);return A?A[1]:null}),x=F(()=>{if(!M(p.value))return null;const A=p.value.match(/\{\{.+?:(.+?)\}\}/);return A?A[1]:null}),N=F(()=>a.getHiddenFields),I=F(()=>S.value===o.HIDDEN_FIELD&&x.value?x.value:null),R=F(()=>!0),T=F(()=>a.getFieldById(i.action.value)||$t()),ce=F(()=>({content:`${T.value?.title}<br>(${u("components.formEdit.LogicActionEditor.clickToChoose")})`,html:!0})),be=F(()=>{const A=a.getFieldsAfter(a.getCurrentFieldId).filter(z=>!z.parentId);return A.find(z=>z.type==="ending-screen")||A.push($t()),A}),ae=F(()=>!!a.getFieldById(a.getCurrentFieldId)?.parentId),W=F(()=>go(vo,{isChild:ae.value,ruleHasOtherJumpTo:ne()&&i.action.function!=="jumpTo"})),j=F(()=>(a.form.variables||[]).findIndex(A=>A.name==="score")<0?a.form.variables.concat([{name:"score",type:"number",value:0}]):a.form.variables),D=F(()=>ct(i.action.function)?j.value.filter(A=>A.type==="number"):j.value),L=F(()=>i.action.function==="jumpTo");nt(()=>{m.value=i.action.variable,f.value=i.action.function,p.value=i.action.value});const M=A=>typeof A=="string"&&A.match(/\{\{.+?:.+?\}\}/),Q=A=>{p.value=`{{hiddenField:${A}}}`,y.value=!1,_e()},X=()=>{p.value="",_e(),Ke(()=>{y.value=!0})},ie=()=>{R.value&&!p.value&&(y.value=!0)},pe=A=>{A===""&&R.value?y.value=!0:y.value=!1},B=A=>{E.value||(y.value=!1,U(A.target.value))},K=A=>a.form.variables.find($e=>$e.name===A)?.type||"number",ne=()=>i.ruleModel.some(A=>A.function==="jumpTo"),we=A=>{p.value=A,_e()},ve=A=>{f.value=A,ke(),Ee(),_e()},G=A=>{m.value=A;const z=K(A);i.action.function==="assign"&&(z==="number"?p.value=0:z==="string"?p.value="":z==="boolean"&&(p.value=!1)),_e()},U=A=>{let z=A;if(oe()){const $e=Number(A);z=Number.isFinite($e)?$e:0}p.value=z,_e()},oe=()=>f.value==="assign"?K(m.value)==="number":ct(f.value),ke=()=>{ln(f.value)&&!m.value&&(m.value=j.value[0]?j.value[0].name:"score"),ct(f.value)&&K(m.value)!=="number"&&(m.value="score")},Ee=()=>{const A=K(m.value);if(f.value==="jumpTo"){if(!p.value){const z=ho(a.getLastNavigableField);p.value=z.value}}else f.value==="assign"?A==="number"?p.value=isNaN(p.value)?0:p.value:A==="string"?p.value="":A==="boolean"&&(p.value=!1):p.value=isNaN(p.value)?0:p.value},_e=()=>{const A={function:f.value,value:p.value};ln(f.value)&&(A.variable=m.value),d("update",{index:i.index,action:A})},le=()=>{d("delete",i.index)},O=()=>{d("add",i.index)};return(A,z)=>{const $e=ye("VDropdown"),Se=at,Le=ye("o-input"),Te=St,Ue=Ie("close-popper"),Me=Ie("tooltip");return r(),c("div",Rd,[s("div",Od,[C($e,{distance:6},{popper:P(()=>[(r(!0),c(ue,null,xe(e(W),(l,b)=>q((r(),c("div",{key:`action-${b}`,"aria-role":"listitem",class:"dropdown-item",onClick:_=>ve(l.key)},[s("div",Bd,[s("i",{class:re(["oi oi-16 text-neutral",l.icon])},null,2),se(" "+k(e(u)(l.label)),1)])],8,Pd)),[[Ue]])),128))]),default:P(()=>[s("button",Nd,[s("span",null,k(e(u)(e(In)(t.action.function))),1),z[9]||(z[9]=s("i",{"data-v-03e8e103":"",class:"oi oi-angle-down"},null,-1))])]),_:1})]),e(L)?(r(),J($e,{key:0,distance:6,class:"w-full truncate"},{popper:P(()=>[s("div",Ud,[(r(!0),c(ue,null,xe(e(be),(l,b)=>q((r(),c("div",{key:`field-${b}`,"aria-role":"listitem",class:re(["dropdown-item",{"dropdown-item-active":l.id===e(T).id}]),onClick:_=>we(l.id)},[C(Se,{type:l.type,"show-position":!0,position:l.position},null,8,["type","position"]),q(s("div",{class:"truncate",innerHTML:l.title},null,8,Hd),[[Me,{content:l.title,html:!0}]])],10,Kd)),[[Ue]])),128))])]),default:P(()=>[s("div",Md,[e(T)?q((r(),J(Se,{key:0,type:e(T).type,"show-position":!0,position:e(T).position,class:"cursor-pointer",hovered:!0},null,8,["type","position"])),[[Me,e(ce)]]):V("",!0),s("span",{class:"text-neutral-darkest text-sm truncate",innerHTML:e(T).title},null,8,jd)])]),_:1})):V("",!0),t.action.variable?(r(),c("div",{key:1,class:re(["flex flex-row gap-2 items-center truncate w-full",{"flex-row-reverse":t.action.function==="divide"||t.action.function==="assign"}])},[t.action.function==="assign"?(r(),c(ue,{key:0},[K(t.action.variable)==="boolean"?(r(),J($e,{key:0,triggers:["click"],"auto-hide":!0,distance:6},{popper:P(()=>[s("div",zd,[s("div",{class:"dropdown-item",onClick:z[0]||(z[0]=l=>U(!0))},k(e(u)("components.formEdit.logicConditionEditor.true")),1),s("div",{class:"dropdown-item",onClick:z[1]||(z[1]=l=>U(!1))},k(e(u)("components.formEdit.logicConditionEditor.false")),1)])]),default:P(()=>[s("div",qd,[s("div",Wd,k(e(p)?e(u)("components.formEdit.logicConditionEditor.true"):e(u)("components.formEdit.logicConditionEditor.false")),1),z[10]||(z[10]=s("i",{class:"oi oi-angle-down"},null,-1))])]),_:1}
6)):K(t.action.variable)==="number"?(r(),J(Le,{key:1,modelValue:e(w),"onUpdate:modelValue":z[2]||(z[2]=l=>Ce(w)?w.value=l:null),type:"number",class:"flex-grow min-w-[108px] max-w-[108px]",placeholder:"Value..."},null,8,["modelValue"])):(r(),c("div",Gd,[C($e,{ref:"myDropdown",shown:e(y),triggers:[],"auto-hide":!1,distance:6},{popper:P(()=>[s("div",{class:"max-h-96 max-w-lg overflow-auto",onMousedown:z[6]||(z[6]=l=>E.value=!0),onMouseup:z[7]||(z[7]=l=>E.value=!1)},[s("div",Xd,k(e(u)("components.formEdit.logicConditionEditor.hiddenFields")||"Hidden Fields"),1),(r(!0),c(ue,null,xe(e(N),l=>(r(),c("div",{key:`dyn-hidden-field-${l}`,class:"dropdown-item flex items-center gap-2",onClick:b=>Q(l)},[z[13]||(z[13]=s("div",{class:"rounded tag-gray w-6 h-6 flex justify-center items-center"},[s("i",{class:"oi oi-view-off oi-14 text-white"})],-1)),s("div",eu,k(l),1)],8,Zd))),128))],32)]),default:P(()=>[M(e(p))?V("",!0):(r(),J(Le,{key:0,modelValue:e(w),"onUpdate:modelValue":z[3]||(z[3]=l=>Ce(w)?w.value=l:null),type:"text",class:"w-[108px] flex-none",placeholder:"Value...",onFocus:ie,onBlur:B,onInput:z[4]||(z[4]=l=>pe(l))},null,8,["modelValue"])),M(e(p))?(r(),c("div",{key:1,class:"btn btn-dropdown-select !flex !justify-between !gap-1 px-1 w-[108px] flex-none truncate",onClick:z[5]||(z[5]=l=>y.value=!0)},[s("div",Jd,[e(S)===o.HIDDEN_FIELD&&e(I)?(r(),c("div",Yd,[z[11]||(z[11]=s("div",{class:"h-6 w-6 flex-none flex items-center justify-center rounded tag-gray"},[s("i",{class:"oi oi-view-off oi-14 text-white"}
6)],-1)),q((r(),c("span",Qd,[se(k(e(I)),1)])),[[Me,e(I)]])])):V("",!0)]),q((r(),c("button",{class:"btn btn-xs btn-action flex-shrink-0",onClick:tt(X,["stop"])},[...z[12]||(z[12]=[s("i",{class:"oi oi-close-line"},null,-1)])])),[[Me,e(u)("components.formEdit.logicConditionEditor.clear")]])])):V("",!0)]),_:1},8,["shown"])]))],64)):(r(),J(Le,{key:1,modelValue:e(w),"onUpdate:modelValue":z[8]||(z[8]=l=>Ce(w)?w.value=l:null),type:"number",class:"flex-grow min-w-[108px] max-w-[108px]",placeholder:"Value..."},null,8,["modelValue"])),s("div",tu,k(e(u)(e(po)(t.action.function))),1),C($e,{distance:6,class:"truncate w-full"},{popper:P(()=>[(r(!0),c(ue,null,xe(e(D),(l,b)=>q((r(),c("div",{key:`variable-${b}`,"aria-role":"listitem",class:"dropdown-item",onClick:_=>G(l.name)},[C(Te,st({ref_for:!0},l),null,16)],8,nu)),[[Ue]])),128))]),default:P(()=>[C(Te,{name:t.action.variable,type:K(t.action.variable),class:"truncate cursor-pointer hover:bg-lime-light w-full"},null,8,["name","type"])]),_:1})],2)):V("",!0),q((r(),c("div",{class:"btn btn-xs hover:bg-neutral-lighter absolute -bottom-7 left-0 opacity-0 group-hover:opacity-100",onClick:O},[se(k(e(u)("components.formEdit.logicRuleEditor.addAction")),1)])),[[Me,e(u)("components.formEdit.logicRuleEditor.addAction")]]),t.canDelete?q((r(),c("div",{key:2,class:"btn btn-xs hover:bg-neutral-lighter absolute -bottom-7 right-0 opacity-0 group-hover:opacity-100",onClick:le},[z[14]||(z[14]=s("i",{class:"oi oi-bin oi-12 mr-1"},null,-1)),se(" "+k(e(u)("components.formEdit.logicRuleEditor.deleteAction")),1)])),[[Me,e(u)("components.formEdit.logicRuleEditor.deleteThisAction")]]):V("",!0)])}}},iu=Be(ou,[["__scopeId","data-v-8b84f353"]]),su={class:"flex flex-col items-center w-full"},lu={class:"flex gap-1 items-center uppercase text-2xs text-neutral-dark font-bold"},au={class:"flex gap-2 w-full mt-6"},ru={__name:"LogicRuleEditor",props:{rule:{type:Object,required:!0}},emits:["save","delete"],setup(t,{emit:n}){const o=t,i=n,d=Ae(),a=Z({actions:[]});He(()=>o.rule,()=>{a.value=JSON.parse(JSON.stringify(o.rule))},{immediate:!0});const u=()=>{i("save",a.value)},m=()=>{i("delete",a.value)},f=(I,R)=>{if(I===et.field)return d.getFieldById(R.fieldId);if(I===et.variable)return d.getVariableByName(R.variableName);if(I===et.hiddenField)return R.hiddenField;if(I===et.tracking)return R.tracking},p=I=>{const R=bo(I.condition);if(!R)return;const T=f(R,I.condition);if(!T)return;const ce=Cn(R,T).emptyCondition(I.condition.operator);a.value.conditions.splice(I.index+1,0,ce)},y=I=>{a.value.conditions.splice(I,1)},E=I=>{a.value.logicalOperator=I},w=I=>{a.value.conditions.splice(I.index,1,I.condition)},S=I=>{const R={function:"add",value:0,variable:"score"};a.value.actions.splice(I+1,0,R)},x=I=>{a.value.actions.splice(I,1)},N=I=>{a.value.actions.splice(I.index,1,I.action)};return(I,R)=>{const T=Td,ce=Dd,be=iu,ae=Ie("tooltip");return r(),c("div",su,[(r(!0),c(ue,null,xe(e(a).conditions,(W,j)=>(r(),c("div",{key:`or-${j}`,class:"flex flex-col items-center w-full"},[(r(),J(T,{key:e(yo)("condition",j),condition:W,index:j,"can-delete":e(a).conditions.length>1,onDelete:y,onAdd:p,onUpdate:w},null,8,["condition","index","can-delete"])),C(ce,{operator:e(a).logicalOperator,"has-before":!0,"has-after":j<e(a).conditions.length-1,readonly:!1,onChange:E},null,8,["operator","has-after"])]))),128)),s("div",lu,k(I.$t("components.formEdit.logicRuleEditor.then")),1),R[1]||(R[1]=s("div",{class:"flex h-2"},[s("div",{class:"h-full flex-grow"}),s("div",{class:"h-full w-0.5 bg-neutral-lighter"}),s("div",{class:"h-full flex-grow"})],-1)),(r(!0),c(ue,null,xe(e(a).actions,(W,j)=>(r(),c("div",{key:`action-${j}`,class:"w-full"},[C(be,{class:"mb-1",action:W,"rule-model":e(a).actions,index:j,"can-delete":e(a).actions.length>1,onDelete:x,onAdd:S,onUpdate:N},null,8,["action","rule-model","index","can-delete"]),C(ce,{operator:"and","has-after":j<e(a).actions.length-1,readonly:!0},null,8,["has-after"])]))),128)),s("div",au,[q((r(),c("button",{class:"btn btn-secondary btn-sm w-full",onClick:m},[R[0]||(R[0]=s("i",{class:"oi oi-bin oi-16 mr-2"},null,-1)),se(k(I.$t("components.formEdit.logicRuleEditor.delete")),1)])),[[ae,I.$t("components.formEdit.logicRuleEditor.deleteThisRule")]]),s("button",{class:"btn btn-primary btn-sm w-full",onClick:u}," OK ")])])}}},du={class:"text-2xs text-neutral-dark uppercase font-bold"},uu={class:"text-2xs text-neutral-dark uppercase font-bold whitespace-nowrap"},cu={class:"text-2xs text-neutral-dark uppercase font-bold"},mu={__name:"LogicRuleItem",props:{index:{type:Number,required:!0},rule:{type:Object,required:!0},edit:{type:Boolean,default:!1},isNew:{type:Boolean,default:!1}},emits:["save","delete"],setup(t,{emit:n}){const o=t,i=n,d=Ae(),a=Z(o.edit),u=F(()=>o.rule.conditions[0]||null),m=F(()=>d.getFieldById(u.value?.fieldId)||null),f=F(()=>d.getVariableByName(u.value?.variableName)||null),p=F(()=>o.rule.actions[0]||null),y=F(()=>d.getFieldById(o.rule.actions[0].value)||$t()),E=S=>{const x=JSON.stringify(o.rule)!==JSON.stringify(S)||o.isNew;a.value=!1,i("save",{index:o.index,rule:S,isDirty:x})},w=()=>{a.value=!1,i("delete",o.index)};return(S,x)=>{const N=at,I=St,R=ru,T=Ie("tooltip");
6return r(),c("div",{class:re(["bg-neutral-lightest rounded flex flex-col items-center",{"p-2":e(a)}])},[e(a)?V("",!0):q((r(),c("div",{key:0,class:"logic-rule-item cursor-pointer",onClick:x[0]||(x[0]=ce=>a.value=!e(a))},[s("div",du,k(S.$t("components.formEdit.logicRuleItem.if")),1),s("div",null,[e(m)?q((r(),J(N,{key:0,type:e(m).type,"show-position":!0,position:e(m).position},null,8,["type","position"])),[[T,{content:e(m).title,html:!0}]]):V("",!0),e(f)?(r(),J(I,{key:1,name:e(f).name,type:e(f).type,class:"cursor-pointer"},null,8,["name","type"])):V("",!0)]),x[1]||(x[1]=s("div",{class:"text-2xs uppercase font-bold flex-grow text-center"}," ... ",-1)),e(p)?(r(),c(ue,{key:0},[e(p).function==="jumpTo"?(r(),c(ue,{key:0},[s("div",uu,k(S.$t(e(In)(e(p).function))),1),e(y)?q((r(),J(N,{key:"test",type:e(y).type,"show-position":!0,position:e(y).position},null,8,["type","position"])),[[T,{content:e(y).title,html:!0}]]):V("",!0)],64)):V("",!0),e(ct)(e(p).function)?(r(),c(ue,{key:1},[C(I,{name:e(p).variable,type:"number",class:"truncate"},null,8,["name"]),s("i",{class:re(["oi oi-16",e(_o)(e(p).function)])},null,2),s("div",cu,k(e(p).value),1)],64)):V("",!0)],64)):V("",!0)])),[[T,S.$t("components.formEdit.logicRuleItem.clickToEdit")]]),C(kt,{name:"slide",duration:"100"},{default:P(()=>
6[e(a)?(r(),J(R,{key:0,field:e(d).getCurrentField,rule:t.rule,onSave:E,onDelete:w},null,8,["field","rule"])):V("",!0)]),_:1})],2)}}},fu={class:"modal-card modal-card--md bg-white"},pu={class:"modal-card-body gap-2"},gu={class:"subheading-sm"},vu={class:"flex-grow"},hu={class:"subheading-sm mt-4"},yu={class:"flex w-full items-center gap-1"},bu={class:"btn btn-dropdown-select !flex !flex-between !items-center gap-2"},_u={class:"flex items-center gap-1 min-w-[5rem]"},wu=["onClick"],xu={class:"flex items-center gap-2"},ku={class:"min-w-[12rem]"},$u=["disabled","onClick"],Fu=["disabled"],Eu={class:"modal-card-foot"},Su={class:"flex justify-end"},Tu={class:"flex gap-4"},Cu={__name:"ModalEditVariables",emits:["close"],setup(t,{emit:n}){const{t:o}=Re(),i=rt(),d=Ae(),a=gt(),u=Ye(),m=F(()=>d.defaultVariables),f=F(()=>d.customVariables),p=Z({}),y=Z([{value:"number",icon:"oi-hashtag"},{value:"string",icon:"oi-text-style"},{value:"boolean",icon:"oi-checkbox-line"}]),E=n,w=L=>{const M={number:"oi-hashtag",string:"oi-text-style",boolean:"oi-checkbox-line"};return M[L]||M.number},S=L=>{const M=d.form.variables.filter(pe=>pe.name!==L).map(pe=>pe.name),Q=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],X=d.form.hiddenFields||[];return[...M,...X,...Q].join(",")},x=L=>{const Q={number:{type:"number",validation:"required|number",placeholder:"0",step:"any"},string:{type:"text",validation:"",placeholder:"Text value"},boolean:{type:"select",options:{true:"True",false:"False"},validation:""}}[L.type];return Q.value=Q.type!=="number"?String(L.value??""):L.value??0,Q.name=L.name,Q},N=()=>{d.addVariable()},I=async L=>{const M=d.form.id,Q=ie=>new Promise(pe=>{let B=o("components.formEdit.modalEditVariables.cascadeDeletion");ie.integrationCount>0&&(B+=` 7 8`+o("components.common.blockedActionDialog.integrationsAffected",{count:ie.integrationCount})),i.warn({title:o("components.common.blockedActionDialog.titleReferences"),message:B,references:ie.refs},()=>pe(!0),()=>pe(!1))}),X=await d.deleteVariableWithCascade(L,{confirm:Q});X.status==="ready"&&u.execute({resourceKey:`form:${M}:variable:${L}`,actionKey:"actions.deleteVariable",undoable:!1,execute:()=>X.execute()})},R=L=>L?.target?L.target.value:L?.detail?.value!==void 0?L.detail.value:typeof L=="object"&&L?.value!==void 0&&typeof L.value!="function"?L.value:L,T=Z(!1),ce=async(L,M)=>{const Q=f.value[M].name,X=(R(L)||"").toString().trim();if(!(!X||X===Q||T.value)){T.value=!0;try{await d.updateVariableName({oldName:Q,newName:X})}catch(ie){a.error(ie)}finally{T.value=!1}}},be=(L,M)=>{if(T.value)return;const Q=R(L);Q!=null&&d.updateVariableValue({varName:M,value:Q})},ae=async(L,M)=>{const Q=d.form.variables.find(ie=>ie.name===M);if(T.value||Q.type===L)return;const X=W(M);if(X.length>0){const ie=X.map(B=>`${B.position}. ${B.title}`).join(` 9`),pe=o("components.formEdit.modalEditVariables.variableTypeChangeMessage",{fieldsList:ie});i.confirm({title:o("components.formEdit.modalEditVariables.variableTypeChangeTitle"),message:pe,variant:"warning",noButtonText:o("common.action.cancel"),yesButtonText:o("components.formEdit.modalEditVariables.changeAnyway")},async()=>{await d.updateVariableType({varName:M,type:L})})}else await d.updateVariableType({varName:M,type:L})},W=L=>{const M=[];for(const Q of d.fields){if(!Q.logic||Q.logic.length===0)continue;Q.logic.some(ie=>{const pe=ie.conditions&&ie.conditions.some(K=>K.variableName===L),B=ie.actions&&ie.actions.some(K=>K.variable===L);return pe||B})&&M.push({id:Q.id,title:Q.title?j(Q.title):`Field ${Q.position}`,position:Q.position})}return M},j=L=>new DOMParser().parseFromString(L,"text/html").body.textContent||"",D=L=>{E("close")};return(L,M)=>{const Q=Rn,X=Ln,ie=St,pe=On,B=ye("VDropdown"),K=ye("o-button"),ne=Ie("close-popper"),we=Ie("tooltip");return r(),J(e(Nn),{"config-file":"true"},{default:P(()=>[C(pe,{modelValue:e(p),"onUpdate:modelValue":M[2]||(M[2]=ve=>Ce(p)?p.value=ve:null),type:"form",actions:!1},{default:P(()=>[s("div",fu,[C(Q,{title:e(o)("components.formEdit.modalEditVariables.variables"),onClose:M[0]||(M[0]=ve=>D(!1))},null,8,["title"]),s("div",pu,[C(X,{class:"mb-0"},{default:P(()=>[se(k(e(o)("components.formEdit.modalEditVariables.variablesAllow")),1)]),_:1}),s("h2",gu,k(e(o)("components.formEdit.modalEditVariables.defaultVariables")),1),(r(!0),c(ue,null,xe(e(m),(ve,G)=>(r(),c("div",{key:`default-variable-${G}`,class:"group card-solid flex flex-row gap-2 items-center p-1"},[C(ie,{name:ve.name,type:ve.type,class:re(["!h-8",{"opacity-60":ve.name==="score"}])},null,8,["name","type","class"]),M[3]||(M[3]=s("div",{class:"text-sm text-neutral"}," = ",-1)),s("div",vu,[C(pe,st({ref_for:!0},x(ve),{disabled:e(T),onBlur:U=>be(U,ve.name)}),null,16,["disabled","onBlur"])])]))),128)),s("h2",hu,k(e(o)("components.formEdit.modalEditVariables.customVariables")),1),(r(!0),c(ue,null,xe(e(f),(ve,G)=>(r(),c("div",{key:`custom-variable-${G}`,class:"group card-solid flex flex-row gap-2 items-center p-1"},[s("div",yu,[C(pe,{type:"text","validation-visibility":"blur",value:ve.name,"validation-label":"Variable name",placeholder:e(o)("components.formEdit.modalEditVariables.variableName"),validation:`bail|required|matches:/^[A-Za-z0-9_]*$/|unique:${S(ve.name)}`,"validation-messages":{matches:e(o)("components.formEdit.modalEditVariables.matches"),unique:e(o)("components.formEdit.modalEditVariables.unique")},"outer-class":"flex-grow",disabled:e(T),onBlur:U=>ce(U,G)},null,8,["value","placeholder","validation","validation-messages","disabled","onBlur"]),C(B,{distance:6,disabled:e(T)},{popper:P(()=>[(r(!0),c(ue,null,xe(e(y),U=>q((r(),c("div",{key:U.value,"aria-role":"listitem",class:"dropdown-item",onClick:oe=>ae(U.value,ve.name)},[s("div",xu,[s("i",{class:re(["oi oi-16 text-neutral",[U.icon,{"text-xs":U.value==="string"}]])},null,2),se(" "+k(e(o)(`components.formEdit.modalEditVariables.types.${U.value}
9`)),1)])],8,wu)),[[ne]])),128))]),default:P(()=>[s("div",bu,[s("div",_u,[s("i",{class:re(["oi oi-16",[w(ve.type),{"text-xs":ve.type==="string"}]])},null,2),se(" "+k(e(o)(`components.formEdit.modalEditVariables.types.${ve.type}`)),1)]),M[4]||(M[4]=s("i",{class:"oi oi-angle-down"},null,-1))])]),_:2},1032,["disabled"])]),M[6]||(M[6]=s("div",{class:"text-sm text-neutral"}," = ",-1)),s("div",ku,[(r(),J(pe,st({key:`${ve.name}-${ve.type}`},{ref_for:!0},x(ve),{disabled:e(T),onBlur:U=>be(U,ve.name)}),null,16,["disabled","onBlur"]))]),ve.name!=="score"?q((r(),c("button",{key:0,class:"btn btn-sm btn-secondary px-2",disabled:e(T),onClick:tt(U=>I(ve.name),["prevent"])},[...M[5]||(M[5]=[s("i",{class:"oi oi-bin oi-16"},null,-1)])],8,$u)),[[we,e(o)("components.formEdit.modalEditVariables.removeVariable")]]):V("",!0)]))),128)),s("button",{type:"button",class:"btn-placeholder",disabled:e(T),onClick:N},[M[7]||(M[7]=s("i",{class:"oi oi-read-email-at oi-16 ml-1"},null,-1)),se(k(e(o)("components.formEdit.modalEditVariables.addVariable")),1)],8,Fu)]),s("footer",Eu,[s("div",Su,[s("div",Tu,[C(K,{type:"button",variant:"primary",onClick:M[1]||(M[1]=ve=>D(!1))},{default:P(()=>[se(k(e(o)("components.formEdit.modalEditVariables.close")),1)]),_:1})])])])])]),_:1},8,["modelValue"])]),_:1})}}},Iu={class:"flex flex-col gap-5"},Lu={class:"flex-1"},Au={class:"subheading-sm mb-2 flex gap-2"},Vu={class:"text-sm text-neutral-dark group-hover:text-neutral-dark"},Du={key:1,class:"flex flex-col gap-2"},Ru={class:"subheading-sm flex items-center gap-2 w-full"},Ou={class:"text-sm text-neutral mb-4"},Nu={class:"flex flex-col gap-2"},Pu={class:"h-12 text-neutral-darkest p-2 w-full flex flex-row items-center gap-2 text-sm flex-nowrap"},Bu={class:"text-2xs uppercase font-bold"},Mu={class:"text-2xs text-neutral-dark uppercase font-bold"},ju={__name:"TheLogicRuleList",setup(t){const{t:n}=Re(),o=Ae(),i=zt(),d=Ye(),a=Z([]),u=F(()=>o.getCurrentField),m=F(()=>o.getLastNavigableField),f=F(()=>wo(u.value)),p=F({get:()=>a.value,set:R=>{a.value=R,x()}}),y=F(()=>$t());He(u,R=>{const T=R?.logic;a.value=Array.isArray(T)?JSON.parse(JSON.stringify(T)):[]},{immediate:!0});function E(){for(let R=0;R<a.value.length;R++)a.value[R].edit=!1;a.value.push({edit:!0,isNew:!0,...xo(u.value,o.getLastNavigableField)})}function w(R){R.rule.edit=!1,R.isDirty&&(a.value.splice(R.index,1,R.rule),x())}function S(R){a.value.splice(R,1),x()}function x(){const R=N(),T=u.value.logic?JSON.parse(JSON.stringify(u.value.logic)):[];d.execute({resourceKey:`field:${u.value.id}:logic`,actionKey:"actions.updateLogic",execute:()=>o.updateFieldLogic({fieldId:u.value.id,logic:R}),rollback:()=>{a.value=T}})}function N(){return a.value.map(R=>({logicalOperator:R.logicalOperator,conditions:R.conditions,actions:R.actions}))}async function I(){await i.modal.open({component:Cu,custom:!0,trapFocus:!0})}return(R,T)=>{const ce=Ln,be=at,ae=mu,W=Ie("tooltip");return r(),c("div",Iu,[s("div",{class:"group card-solid card-solid--clickable p-4 gap-4 items-center",onClick:I},[T[3]||(T[3]=s("div",{class:"bg-neutral-light rounded h-8 w-8 flex items-center justify-center self-start"},[s("i",{class:"oi oi-16 oi-read-email-at text-neutral-darkest"})],-1)),s("div",Lu,[s("h3",Au,k(e(n)("components.formEdit.theLogicRuleList.variables")),1),s("p",Vu,k(e(n)("components.formEdit.theLogicRuleList.createVariables")),1)]),T[4]||(T[4]=s("i",{class:"oi oi-20 oi-angle-right text-neutral group-hover:text-neutral-dark"},null,-1))]),e(u)?(r(),c(ue,{key:0},[e(f)?(r(),c("div",Du,[s("div",Ru,k(e(n)("components.formEdit.theLogicRuleList.rules")),1),s("div",Ou,[se(k(e(n)("components.formEdit.theLogicRuleList.theFollowingRules"))+" ",1),e(u)?q((r(),J(be,{key:0,type:e(u).type,"show-position":!0,position:e(u).position,class:"!inline-flex"},null,8,["type","position"])),[[W,{content:e(u).title,html:!0}]]):V("",!0),T[5]||(T[5]=se(". ",-1))]),e(a).length>0?(r(),J(e(Bt),{key:0,modelValue:e(p),"onUpdate:modelValue":T[0]||(T[0]=j=>Ce(p)?p.value=j:null),group:"rules",class:"flex flex-col gap-2","item-key":"id","component-data":{tag:"ul",name:"flip-list",type:"transition"},onStart:T[1]||(T[1]=j=>R.drag=!0),onEnd:T[2]||(T[2]=j=>R.drag=!1)},{item:P(({element:j,index:D})=>[s("li",Nu,[(r(),J(ae,{key:`${e(u).id}-logicRuleItem-${D}`,rule:j,edit:j.edit,"is-new":j.isNew,index:D,class:"flex-grow rule-item",onDelete:S,onSave:w},null,8,["rule","edit","is-new","index"])),e(a).length>0?(r(),c("div",{key:`else-${D}`,class:"uppercase text-2xs font-bold ml-2"},k(e(n)("components.formEdit.theLogicRuleList.else")),1)):V("",!0)])]),_:1},8,["modelValue"])):V("",!0),e(f)?(r(),c("button",{key:1,class:"btn-placeholder h-12",onClick:E},[T[6]||(T[6]=s("i",{class:"oi oi-ui-webpage-bullets oi-16 ml-1"},null,-1)),se(k(e(n)("components.formEdit.theLogicRuleList.addRule")),1)])):V("",!0),T[8]||(T[8]=s("div",{class:"h-1 border-t-2 border-neutral-lightest"},null,-1)),s("div",Pu,[s("div",Bu,[e(a).length>0?(r(),c(ue,{key:0},[se(k(e(n)("components.formEdit.theLogicRuleList.otherwise")),1)],64)):V("",!0),e(a).length===0?(r(),c(ue,{key:1},[se(k(e(n)("components.formEdit.theLogicRuleList.byDefault")),1)],64)):V("",!0)]),T[7]||(T[7]=s("div",{class:"text-sm flex-grow text-center"},null,-1)),s("div",Mu,k(e(n)("components.formEdit.theLogicRuleList.goTo")),1
9),s("div",null,[e(m)?q((r(),J(be,{key:0,type:e(m).type,"show-position":!0,position:e(m).position},null,8,["type","position"])),[[W,{content:e(m).title,html:!0}]]):q((r(),J(be,{key:1,type:e(y).type,"show-position":!0,position:e(y).position},null,8,["type","position"])),[[W,{content:e(y).title,html:!0}]])])])])):(r(),J(ce,{key:0,variant:"info",class:"mb-4"},{default:P(()=>[se(k(e(n)("components.formEdit.theLogicRuleList.pleaseSelect")),1)]),_:1}))],64)):(r(),J(ht,{key:1,variant:"empty",message:e(n)("components.formEdit.theLogicRuleList.selectAQuestion"),icon:"oi-move-to-bottom",class:"py-10"},null,8,["message"]))])}}},Uu={class:"inline-flex items-center gap-1.5"},Ku={__name:"TheFormRightMenu",setup(t){const n=Z("field"),o=Z(["field","ai","logic"]);return(i,d)=>{const a=er,u=Lo,m=hr,f=ju,p=qn;return r(),J(p,{tabs:e(o),"initial-tab":e(n),class:"h-full","css-class-body":"h-full overflow-auto pt-4"},{"tab-head-field":P(()=>[se(k(i.$t("components.formEdit.theFormRightMenu.question")),1)]),"tab-panel-field":P(()=>[C(a)]),"tab-head-ai":P(()=>[s("span",Uu,[se(k(i.$t("components.formEdit.theFormRightMenu.ai"))+" ",1),C(u,{value:"Beta",variant:"yellow"})])]),"tab-panel-ai":P(()=>[C(m)]),"tab-head-logic":P(()=>[se(k(i.$t("components.formEdit.theFormRightMenu.logic")),1)]),"tab-panel-logic":P(()=>[C(f)]),_:1},8,["tabs","initial-tab"])}}},Hu={class:"flex-1 flex flex-col bg-white rounded-2xl box-border overflow-y-auto"},qu={class:"m-auto w-full flex flex-col items-center text-center px-6 py-10 box-border"},Wu={class:"text-xl font-bold text-gray-900 mt-6"},zu={class:"text-sm text-gray-500 leading-relaxed mt-3 max-w-sm"},Gu={class:"text-xs text-gray-500 leading-normal mt-6 max-w-xs"},Ju={__name:"TheEditorSmallScreen",props:{formId:{type:String,required:!0}},setup(t){const n=t,{t:o}=Re(),i=Oo();function d(){i(`${window.location.origin}/forms/${n.formId}`,{success:o("forms.index.smallScreen.copied"),error:o("forms.index.smallScreen.copyError")})}return(a,u)=>{const m=_n;return r(),c("div",Hu,[s("div",qu,[u[0]||(u[0]=s("div",{class:"w-20 h-20 rounded-full bg-gray-100 text-gray-900 flex items-center justify-center flex-none"},[s("i",{class:"oi oi-desktop-computer text-3xl"})],-1)),s("h2",Wu,k(e(o)("forms.index.smallScreen.title")),1),s("p",zu,k(e(o)("forms.index.smallScreen.body")),1),s("button",{type:"button",class:"w-full max-w-sm h-11 mt-7 rounded-full bg-gray-900 text-white text-sm font-semibold flex items-center justify-center gap-2 cursor-pointer",onClick:d},[C(No,{name:"copy",size:15}),se(k(e(o)("forms.index.smallScreen.copyEditorLink")),1)]),C(m,{to:`/forms/${t.formId}/results`,class:"w-full max-w-sm h-11 mt-2.5 rounded-full border border-gray-200 bg-white text-sm font-semibold text-gray-900 flex items-center justify-center"},{default:P(()=>[se(k(e(o)("forms.index.smallScreen.viewResults")),1)]),_:1},8,["to"]),s("p",Gu,k(e(o)("forms.index.smallScreen.footnote")),1)])])}}},Yu=()=>{const{apiClient:t}=Ft();return{async init(n){return(await t(`/forms/${n}/ai-chat/init?agent=form-edit`)).data},async edit(n,o,i,d){return(await t(`/forms/${n}/ai-chat`,{method:"POST",body:{instruction:d?.executePlan||d?.blocked_operations?void 0:o,conversation_id:i||void 0,agent:"form-edit",mode:d?.mode,execute_plan:d?.executePlan||void 0,blocked_operations:d?.blocked_operations,async:d?.async||void 0}})).data},async feedback(n,o,i,d,a){return(await t(`/forms/${n}/ai-chat/feedback`,{method:"POST",body:{message_id:o,type:i,category:d,comment:a}})).data}}},Qu=["opinion-scale","nps","rating"],gn=["yes-no","nps"];function vn(t,n){if(typeof t=="string")try{t=JSON.parse(t)}catch{return t}return Array.isArray(t)&&t.length&&Qu.includes(n)?t.map(o=>Number(o)):t}function hn(t){return t==null?!1:Array.isArray(t)?t.length>0:typeof t=="object"?Object.keys(t).length>0:!1}function Xu(t){return/^[a-f0-9]{24}$/.test(t)}function Zu(t,n){if(!Array.isArray(t))return[];const o=new Set((Array.isArray(n)?n:[]).map(i=>lt(Pt(i))));return t.filter(i=>!o.has(lt(Pt(i))))}function yn(t,n){if(!Array.isArray(t))return[];const o=new Set((Array.isArray(n)?n:[]).map(lt));return t.filter(i=>!o.has(lt(i)))}function ec(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&("rows"in t||"columns"in t)}function bn(t){return t.replace(/<[^>]*>/g,"").trim().toLowerCase()}function tc(){const t=pt(),n=qt(),o=ko(),i=Ae(),d=Ye(),{canUseSettled:a}=Et(),{t:u}=Re(),m=()=>i.form;function f(l,b){return!l||Xu(l)||i.getFieldById(l)?l:b[l]||b[l.toLowerCase()]||b[bn(l)]||l}function p(l,b){return l&&l.map(_=>({..._,conditions:_.conditions.map(h=>({...h,fieldId:f(h.fieldId,b)})),actions:_.actions.map(h=>({...h,value:h.function==="jumpTo"?f(h.value,b):h.value}))}))}function y(l,b){return E(l).every(h=>!h||i.getFieldById(h)||b[h]||b[h?.toLowerCase?.()]||b[bn(h)]||h==="default-ending-screen")}
9function E(l){const b=[];if(l.field_id&&b.push(l.field_id),l.parent_id&&l.parent_id!==""&&l.parent_id!=="null"&&b.push(l.parent_id),l.logic)for(const _ of l.logic){for(const h of _.conditions||[])h.fieldId&&b.push(h.fieldId);for(const h of _.actions||[])h.function==="jumpTo"&&h.value&&b.push(h.value)}return b}function w(l,b){return l.field_id&&(l.field_id=f(l.field_id,b)),l.parent_id&&l.parent_id!==""&&l.parent_id!=="null"&&(l.parent_id=f(l.parent_id,b)),l.logic&&(l.logic=p(l.logic,b)),l}function S(l){l&&(t.query.field===l?(i.setCurrentField(null),Ke(()=>{i.setCurrentField(l)})):n.push({path:t.path,query:{...t.query,field:l}}))}function x(l){return i.isCurrentForm(l)}function N(l,b){d.execute({...b,execute:async()=>{if(!x(l))throw Fo();return b.execute()}})}function I(l,b){return new Promise(_=>{N(l,{resourceKey:b.resourceKey,actionKey:b.actionKey,execute:async()=>{await b.run(),_(null)},rollback:b.rollback,onError:h=>_(b.describeError(h))})})}const{isSandbox:R}=Gt();async function T(l,b){const _=l.parent_id&&l.parent_id!==""&&l.parent_id!=="null"?l.parent_id:null;if(_&&wn.includes(l.field_type))return{warning:`The field was NOT created: a ${l.field_type} field owns its whole screen and cannot be placed inside a group. Add it at the top level instead.`};if(!Wt(l.field_type,{sandbox:R.value}))return{warning:`The field was NOT created: ${l.field_type} fields are not available to this account yet. Use another field type instead.`};const h=Qe[l.field_type]?.requiredFeature;if(h){if(!await a(h))return{warning:`The field was NOT created: ${l.field_type} is not included in this workspace's plan. Tell the user to upgrade the plan.`};if(!x(b))return{warning:"The field was NOT created: the form was closed while the plan was being checked. Ask the user to try again."}}let v=null;return new Promise(H=>{N(b,{resourceKey:`field:add:${l.field_type}:${Date.now()}`,actionKey:"actions.addField",execute:async()=>{const g=await i.addField(l.field_type,{parentId:_});if(!g){H({});return}v=g.id;const $={entityId:g.id,refTitle:l.title};if(!x(b))return H($);if(l.title){const te=i.getFieldById(g.id)?.title;if(await Ze().update(g.id,{title:l.title}),!x(b))return H($);i.getFieldById(g.id)?.title===te&&i.updateFieldTitleInStore({fieldId:g.id,title:l.title})}if(l.description){const te=i.getFieldById(g.id)?.description;if(await Ze().update(g.id,{description:l.description}),!x(b))return H($);i.getFieldById(g.id)?.description===te&&i.updateFieldDescriptionInStore({fieldId:g.id,description:l.description})}if(l.required!==void 0){const te=l.required===!0||l.required==="true",fe=i.getFieldById(g.id)?.required;if(await Ze().update(g.id,{required:te}),!x(b))return H($);i.getFieldById(g.id)?.required===fe&&i.updateFieldRequiredInStore({fieldId:g.id,required:te})}if(l.options&&!gn.includes(l.field_type)){const te=vn(l.options,l.field_type);if(hn(te)){const fe=i.getFieldById(g.id)?.options;if(await Ze().update(g.id,{options:te}),!x(b))return H($);i.getFieldById(g.id)?.options===fe&&i.updateFieldOptionsInStore({fieldId:g.id,options:te})}}if(l.settings&&l.settings!==""){const te=typeof l.settings=="string"?JSON.parse(l.settings):l.settings,fe=i.getFieldById(g.id)?.settings,ge={...fe,...te};if(await Ze().update(g.id,{settings:ge}),!x(b))return H($);if(i.getFieldById(g.id)?.settings===fe)for(const[de,me]of Object.entries(te))i.updateFieldSettingInStore({fieldId:g.id,setting:de,value:me})}H($)},onError:g=>H(v?{entityId:v,refTitle:l.title,warning:`The field was created but some of its details could not be saved: ${g.message}. Update the existing field instead of adding a new one.`}:{warning:`The field could not be added: ${g.message}. Adjust the request and try again.`})})})}async function ce(l,b,_){let h=!1;if(ec(b)){for(const v of yn(b?.rows,_?.rows))h=await i.cascadeRemoveMatrixRowReferences(l,v)||h;for(const v of yn(b?.columns,_?.columns))h=await i.cascadeRemoveMatrixColumnReferences(l,v)||h}else for(const v of Zu(b,_))h=await i.cascadeRemoveOptionReferences(l,v)||h;return h?"Logic conditions that filtered by a removed option were automatically removed.":void 0}async function be(l,b){if(!l.field_id)return{};if(!i.getFieldById(l.field_id))return{warning:"The field could not be updated: it was not found."};const _=[];let h,v;if(l.title){const g=await I(b,{resourceKey:`field:${l.field_id}:title`,actionKey:"actions.updateFieldTitle",run:async()=>{const $=i.getFieldById(l.field_id)?.title;await Ze().update(l.field_id,{title:l.title}),x(b)&&i.getFieldById(l.field_id)?.title===$&&(i.updateFieldTitleInStore({fieldId:l.field_id,title:l.title}),i.updateFormIsDirty(!0),await i.replaceTitleVariableNameOnFields({fieldId:l.field_id,value:l.title}))},describeError:$=>`The title could not be saved: ${$.message}.`});g&&_.push(g)}if(l.description){const g=await I(b,{resourceKey:`field:${l.field_id}:description`,actionKey:"actions.updateFieldDescription",run:async()=>{const $=i.getFieldById(l.field_id)?.description;await Ze().update(l.field_id,{description:l.description}),x(b)&&i.getFieldById(l.field_id)?.description===$&&(i.updateFieldDescriptionInStore({fieldId:l.field_id,description:l.description}),i.updateFormIsDirty(!0))},describeError:$=>`The description could not be saved: ${$.message}.`});g&&_.push(g)}if(l.required!==void 0&&l.required!==""){const g=l.required===!0||l.required==="true",$=await I(b,{resourceKey:`field:${l.field_id}:required`,actionKey:"actions.updateFieldRequired",run:async()=>{const te=i.getFieldById(l.field_id)?.required;await Ze().update(l.field_id,{required:g}),x(b)&&i.getFieldById(l.field_id)?.required===te&&(i.updateFieldRequiredInStore({fieldId:l.field_id,required:g}),i.updateFormIsDirty(!0))},describeError:te=>`The required flag could not be saved: ${te.message}.`});$&&_.push($)}if(l.settings&&l.settings!==""){const g=typeof l.settings=="string"?JSON.parse(l.settings):l.settings;for(const[$,te]of Object.entries(g)){const fe=await I(b,{resourceKey:`field:${l.field_id}:setting:${$}`,actionKey:"actions.updateFieldSetting",run:async()=>{const ge=i.getFieldById(l.field_id)?.settings?.[$],de={...i.getFieldById(l.field_id)?.settings,[$]:te};await Ze().update(l.field_id,{settings:de}),x(b)&&i.getFieldById(l.field_id)?.settings?.[$]===ge&&(i.updateFieldSettingInStore({fieldId:l.field_id,setting:$,value:te}),i.updateFormIsDirty(!0))},describeError:ge=>`The "${$}" setting could not be saved: ${ge.message}.`});fe&&_.push(fe)}}if(l.options){const g=i.getFieldById(l.field_id);if(!gn.includes(g?.type)){const $=vn(l.options,g?.type);if(hn($)){const te=i.getFieldById(l.field_id)?.options;let fe,ge=!1,de=!1;const me=await I(b,{resourceKey:`field:${l.field_id}:options`,actionKey:"actions.updateFieldOptions",run:async()=>{ge||(fe=i.getFieldById(l.field_id)?.options,ge=!0),de=!1,i.getFieldById(l.field_id)?.options===te&&(await Ze().update(l.field_id,{options:$}),x(b)&&i.getFieldById(l.field_id)?.options===te&&(i.updateFieldOptionsInStore({fieldId:l.field_id,options:$}),i.updateFormIsDirty(!0),de=!0))},describeError:ee=>`The options could not be saved: ${ee.message}.`});if(me)_.push(me);else if(de){let ee;const Y=await I(b,{resourceKey:`field:${l.field_id}:options-logic-cleanup`,actionKey:"actions.updateFieldOptions",run:async()=>{ee=await ce(l.field_id,fe,$)},describeError:Oe=>`Logic referencing a removed option may need manual cleanup: ${Oe.message}.`});Y?_.push(Y):ee&&(v=ee)}}}}if(l.parent_id!==void 0&&l.parent_id!==""){const g=l.parent_id==="null"?null:l.parent_id,$=i.getFieldById(l.field_id);if($&&($.parentId??null)!==g){const te=(i.fields||[]).filter(ge=>g?ge.parentId===g:!ge.parentId&&!["welcome-screen","ending-screen"].includes(ge.type)),fe=await i.moveFieldToScopeWithCascade(l.field_id,g,te.length,{confirm:ae});if(fe.status==="blocked"){const ge=fe.blocks?.[0],de=ge?.type==="media-layout"?"the field carries its own media layout and a group owns its screen media":ge?.type==="disallowed-child"?`a ${ge.fieldType} field owns its whole screen and cannot be placed inside a group`:"a group cannot be nested inside another group";_.push(`The field was NOT moved: ${de}. Resolve the conflict first (or ask the user to do it in the builder).`)}else if(fe.status==="ready"){const ge=await I(b,{resourceKey:`field:${l.field_id}:parent`,actionKey:"actions.moveFieldToScope",run:()=>fe.execute(),describeError:me=>`The field could not be moved: ${me.message}.`});ge&&_.push(ge);const de=W(fe);de&&(h=de)}}}
9const H=[..._,h,v].filter(Boolean);return H.length?{entityId:l.field_id,warning:H.join(" "),..._.length===0?{disclosure:!0}:{}}:{entityId:l.field_id}}async function ae(l){return l.type==="group-choice"?"all":!0}function W(l){const b=[...l.disclosures||[]];return l.integrationsSkipped&&!b.some(_=>_.type==="integrations-skipped")&&b.push({type:"integrations-skipped"}),j(b)}function j(l){if(!l?.length)return;const b=[];for(const _ of l)switch(_.type){case"group-choice":_.choice==="all"&&b.push("The group's child fields were deleted together with the group.");break;case"references":b.push("References to the deleted element in other fields (logic conditions, mentions, scheduling and Calendly prefill) were automatically removed.");break;case"own-logic-loss":b.push("Its own logic rules were deleted with it.");break;case"answers-loss":b.push("Previously collected answers for it were discarded.");break;case"integrations-skipped":b.push("Integration mappings referencing it were NOT touched â the user should review them on the Integrations page.");break;case"jump-remap":b.push("Jump rules pointing at the field were remapped to the destination group.");break;case"own-jump-strip":b.push("The field's own jump rules were removed (group children cannot own jumps).");break;case"mention-strip":case"move-out-mention-strip":b.push("Mentions that can no longer resolve after the move were removed.");break;case"reverse-ref-cascade":b.push("Same-screen references to the field from the destination group were removed.");break}return b.length?b.join(" "):void 0}async function D(l,b){if(!l.field_id)return{};if(!i.getFieldById(l.field_id))return{warning:"The field could not be deleted: it was not found."};const _=await i.deleteFieldWithCascade(l.field_id,{confirm:ae,purgeIntegrations:!1});if(_.status==="not-found")return{warning:"The field could not be deleted: it was not found."};if(_.status!=="ready")return{};const h=W(_);return new Promise(v=>{N(b,{resourceKey:`field:delete:${l.field_id}`,actionKey:"actions.deleteField",execute:async()=>{await _.execute(),v({entityId:null,...h?{warning:h,disclosure:!0}:{}})},onError:H=>v({warning:`The field could not be deleted: ${H.message}. It was left in place â try again or ask the user to remove it in the builder.`})})})}async function L(l){return l.title?(await i.updateFormTitleAsync(l.title),{}):{}}function M(l){return{logicalOperator:l.logicalOperator||"or",conditions:(l.conditions||[]).map(Q),actions:(l.actions||[]).map(X)}}function Q(l){return Tn({field:l.fieldId?i.getFieldById(l.fieldId)??{id:l.fieldId}:void 0,variable:l.variableName?{name:l.variableName}:void 0,hiddenField:l.hiddenField||void 0,tracking:l.tracking||void 0,operator:l.operator,value:l.value,rowLabel:l.rowLabel})}function X(l){const b={function:l.function,value:ie(l)?pe(l.value):l.value};return l.variable&&(b.variable=l.variable),b}function ie(l){return l.function==="assign"?(i.getVariableByName(l.variable)?.type??"number")==="number":ct(l.function)}function pe(l){if(typeof l!="string"||l.trim()==="")return l;const b=Number(l);return Number.isFinite(b)?b:l}async function B(l,b){if(!l.field_id||!l.logic)return{};if(!i.getFieldById(l.field_id))return{warning:"The logic could not be updated: the field was not found."};const _=i.getFieldsAfter(l.field_id),h=new Set(_.map(me=>me.id)),v=l.logic.reduce((me,ee)=>me+(ee.actions?.length||0),0),H=l.logic.filter(me=>me.conditions?.length>0&&me.actions?.length>0).map(me=>({...me,actions:me.actions.filter(ee=>ee.function!=="jumpTo"?!0:ee.value==="default-ending-screen"||h.has(ee.value))})).filter(me=>me.actions.length>0),g=H.reduce((me,ee)=>me+ee.actions.length,0);if(g<v&&g===0)return{entityId:l.field_id,warning:"The logic rule was not applied because jumpTo can only target fields that come AFTER the current field. Backward jumps are not allowed."};const $=g<v?"Some jumpTo actions were removed because their targets are not valid (only fields AFTER the current field, never group children).":void 0,te=H.length>0?H:null,fe=i.getFieldById(l.field_id)?.logic,ge=await I(b,{resourceKey:`field:${l.field_id}:logic`,actionKey:"actions.updateLogic",run:()=>i.updateFieldLogic({fieldId:l.field_id,logic:te}),rollback:()=>{i.updateFieldLogicInStore({fieldId:l.field_id,logic:fe})},describeError:me=>`The logic could not be saved: ${me.message}.`}),de=ge||$;
9return{entityId:l.field_id,...de?{warning:de,...ge?{}:{disclosure:!0}}:{}}}async function K(l,b){if(!l.field_id)return{};if(!i.getFieldById(l.field_id))return{warning:"The logic could not be deleted: the field was not found."};const _=i.getFieldById(l.field_id)?.logic,h=await I(b,{resourceKey:`field:${l.field_id}:logic`,actionKey:"actions.deleteLogic",run:()=>i.updateFieldLogic({fieldId:l.field_id,logic:null}),rollback:()=>{i.updateFieldLogicInStore({fieldId:l.field_id,logic:_})},describeError:v=>`The logic could not be deleted: ${v.message}.`});return{entityId:l.field_id,...h?{warning:h}:{}}}async function ne(l,b){if(!l.field_id||!l.rule)return{};if(!i.getFieldById(l.field_id))return{warning:"The logic could not be appended: the field was not found."};const _=Array.isArray(i.getFieldById(l.field_id)?.logic)?i.getFieldById(l.field_id).logic:[];return B({...l,logic:[..._,M(l.rule)]},b)}async function we(l,b){if(!Array.isArray(l.rules)||l.rules.length===0)return{};const _=new Map;for(const g of l.rules)!g?.field_id||!g?.rule||(_.has(g.field_id)||_.set(g.field_id,[]),_.get(g.field_id).push(g.rule));const h=[];let v,H=!1;for(const[g,$]of _)if(i.getFieldById(g))try{const te=Array.isArray(i.getFieldById(g)?.logic)?i.getFieldById(g).logic:[],fe=await B({field_id:g,logic:[...te,...$.map(M)]},b);fe.warning&&h.push(fe.warning),fe.warning&&!fe.disclosure&&(H=!0),fe.entityId&&(v=fe.entityId)}catch(te){H=!0,h.push(`The logic for field ${g} could not be appended: ${te?.message??te}.`)}return{...v?{entityId:v}:{},...h.length?{warning:h.join(" "),...H?{}:{disclosure:!0}}:{}}}async function ve(l,b){if(!l.variable_name)return{};const _=l.variable_name.trim().toLowerCase();if(i.getVariableByName(_))return{};const h=l.variable_type||"number";let v=l.variable_value||(h==="number"?0:h==="boolean"?!1:"");h==="number"&&(v=Number(v)||0),h==="boolean"&&(v=v==="true"||v===!0);const H={name:_,type:h,value:v},g=await I(b,{resourceKey:`variable:add:${_}`,actionKey:"actions.addVariable",run:async()=>{if((m().variables||[]).some(te=>te.name===_))return;const $=[...m().variables||[],H];await ot().update(b,{variables:$}),x(b)&&(i.addVariableToForm(H),i.updateFormIsDirty(!0))},describeError:$=>`The variable "${_}" could not be saved: ${$.message}.`});return g?{warning:g}:{}}async function G(l,b){if(!l.variable_name)return{};const _=l.variable_name;if(!m().variables.some(g=>g.name===_))return{warning:`The variable "${_}" was not found, so it could not be updated.`};const h=[];let v=_,H;if(l.new_variable_name&&l.new_variable_name!==_){const g=_,$=l.new_variable_name.trim().toLowerCase(),te=m().variables.findIndex(ge=>ge.name===g);if(m().variables.some((ge,de)=>ge.name===$&&de!==te))h.push(`The variable could not be renamed to "${$}": a variable with that name already exists.`);else if(te!==-1){const ge=await I(b,{resourceKey:`variable:rename:${g}`,actionKey:"actions.updateVariableName",run:async()=>{const de=m().variables.findIndex(We=>We.name===g);if(de===-1)throw new Error(`the variable "${g}" no longer exists`);if(m().variables.some((We,Tt)=>We.name===$&&Tt!==de))throw new Error(`a variable named "${$}" already exists`);const me=await i.replaceVariableNameOnFields({oldName:g,newName:$}),ee=m().variables.findIndex(We=>We.name===g);if(ee===-1){await i.restorePrefillRetargets(me);return}const Y=m().variables.map((We,Tt)=>Tt===ee?{...We,name:$}:We);try{await ot().update(b,{variables:Y})}catch(We){throw await i.restorePrefillRetargets(me),We}if(!x(b))return;const qe=(await Promise.allSettled([i.replaceVariableNameOnRules({oldName:g,newName:$}),i.replaceVariableNameInFieldContent({oldName:g,newName:$})])).find(We=>We.status==="rejected");if(qe)throw await i.undoVariableRename({formId:b,index:ee,oldName:g,newName:$,landed:me}),qe.reason;x(b)&&(i.updateVariableInForm({index:ee,key:"name",value:$}),i.updateFormIsDirty(!0))},describeError:de=>`The variable could not be renamed: ${de.message}.`});ge?h.push(ge):v=$}}if(l.variable_type){const g=await I(b,{resourceKey:`variable:type:${v}`,actionKey:"actions.updateVariableType",run:async()=>{const $=m().variables.findIndex(Y=>Y.name===v);if($===-1)throw new Error(`the variable "${v}" no longer exists`);const te=m().variables[$].type,fe=m().variables[$].value,ge=te!==l.variable_type;let de=0;l.variable_type==="string"&&(de=""),l.variable_type==="boolean"&&(de="false");const me=m().variables.map((Y,Oe)=>Oe!==$?Y:ge?{...Y,type:l.variable_type,value:de}:{...Y,type:l.variable_type});if(await ot().update(b,{variables:me}),!x(b))return;const ee=m().variables.findIndex(Y=>Y.name===v);ee===-1||m().variables[ee].type!==te||m().variables[ee].value!==fe||(ge&&i.updateV
9ariableInForm({index:ee,key:"value",value:de}),i.updateVariableInForm({index:ee,key:"type",value:l.variable_type}),i.updateFormIsDirty(!0))},describeError:$=>`The variable type could not be saved: ${$.message}.`});g?h.push(g):H=l.variable_type}if(l.variable_value!==void 0&&l.variable_value!==""){const g=await I(b,{resourceKey:`variable:value:${v}`,actionKey:"actions.updateVariableValue",run:async()=>{const $=m().variables.findIndex(ee=>ee.name===v);if($===-1)throw new Error(`the variable "${v}" no longer exists`);const te=H||m().variables[$].type;let fe=l.variable_value;te==="number"?fe=Number(fe):te==="boolean"&&(fe=fe==="true"?!0:fe==="false"?!1:!!fe);const ge=m().variables[$].value,de=m().variables.map((ee,Y)=>Y===$?{...ee,...H?{type:H}:{},value:fe}:ee);if(await ot().update(b,{variables:de}),!x(b))return;const me=m().variables.findIndex(ee=>ee.name===v);me===-1||m().variables[me].value!==ge||(i.updateVariableInForm({index:me,key:"value",value:fe}),i.updateFormIsDirty(!0))},describeError:$=>`The variable value could not be saved: ${$.message}.`});g&&h.push(g)}return h.length?{warning:h.join(" ")}:{}}async function U(l,b){if(!l.variable_name)return{};const _=await i.deleteVariableWithCascade(l.variable_name,{confirm:ae,purgeIntegrations:!1});if(_.status==="blocked")return{warning:`The variable "${l.variable_name}" is system-managed and cannot be deleted.`};if(_.status==="not-found")return{warning:`The variable "${l.variable_name}" was not found, so it could not be deleted.`};if(_.status!=="ready")return{};const h=W(_),v=await I(b,{resourceKey:`variable:delete:${l.variable_name}`,actionKey:"actions.deleteVariable",run:()=>_.execute(),describeError:g=>`The variable could not be deleted: ${g.message}. It was left in place.`}),H=[h,v].filter(Boolean).join(" ");return H?{warning:H,...v?{}:{disclosure:!0}}:{}}async function oe(l,b){if(!l.settings)return{};const _=typeof l.settings=="string"?JSON.parse(l.settings):l.settings,h=[];for(const[v,H]of Object.entries(_)){const g=await I(b,{resourceKey:`form:${b}:setting:${v}`,actionKey:"actions.updateFormSetting",run:async()=>{const $=m().settings?.[v],te={...m().settings,[v]:H};await ot().update(b,{settings:te}),x(b)&&m().settings?.[v]===$&&i.updateFormSettingInStore({setting:v,value:H})},describeError:$=>`The "${v}" form setting could not be saved: ${$.message}.`});g&&h.push(g)}return h.length?{warning:h.join(" ")}:{}}async function ke(l,b){if(!l.settings)return{};const _=typeof l.settings=="string"?JSON.parse(l.settings):l.settings,h=[];for(const[v,H]of Object.entries(_)){const g=await I(b,{resourceKey:`form:${b}:metatag:${v}`,actionKey:"actions.updateMetaTag",run:async()=>{const $=m().metaTags?.[v],te={...m().metaTags,[v]:H};await ot().update(b,{metaTags:te}),x(b)&&m().metaTags?.[v]===$&&i.updateFormMetaTagInStore({metaTag:v,value:H})},describeError:$=>`The "${v}" meta tag could not be saved: ${$.message}.`});g&&h.push(g)}return h.length?{warning:h.join(" ")}:{}}async function Ee(l){const b=l.variable_value;return b?(await i.updateFormLanguageAsync(b),{}):{}}async function _e(l){const b=l.variable_value||null;return await i.updateFormClosedAtAsync(b),{}}async function le(){const l=`form:${i.form.id}:publish`;try{await i.publishForm(new Date),await d.awaitIdle([l])}catch(b){if(b instanceof $o)return{warning:b.resourceKeys?.includes(l)?"The form was NOT published: the backend rejected it (for example, a field has AI title/description enabled with an empty prompt). Fix the offending field, then publish again.":"The form was NOT published: a pending change could not be saved (terminal save error). Do not retry publishing â the user must fix or discard the failing change first."};throw b}return{}}async function O(){return await i.discardForm(),{}}async function A(l,b){if(!l.variable_name)return{};const _=l.variable_name.toLowerCase().trim();if((m().hiddenFields||[]).includes(_))return{};const h=await I(b,{resourceKey:`form:${b}:hiddenField:${_}`,actionKey:"actions.addHiddenField",run:async()=>{if((m().hiddenFields||[]).includes(_)||(await ot().update(b,{hiddenFields:[...i.hiddenFieldsToSave(),_]}),!x(b)))return;const H=m().hiddenFields||[];H.includes(_)||i.updateHiddenFieldsInForm([...H,_]),i.updateFormIsDirty(!0)},describeError:v=>`The hidden field could not be added: ${v.message}.`});return h?{warning:h}:{}}async function z(l,b){if(!l.variable_name||!l.new_variable_name)return{};if(!(m().hiddenFields||[]).includes(l.variable_name))return{warning:`The hidden field "${l.variable_name}" was not found, so it could not be renamed.`};const _=l.new_variable_name.trim(),h=await I(b,{resourceKey:`form:${b}:hiddenField:${l.variable_name}`,actionKey:"actions.updateHiddenField",run:async()=>{const v=i.hiddenFieldsToSave(l.variable_name),H=v.indexOf(l.variable_name);if(H===-1||(v[H]=_,await ot().update(b,{hiddenFields:v}),!x(b)))return;const g=[...m().hiddenFields||[]],$=g.indexOf(l.variable_name);$!==-1&&(g[$]=_,i.updateHiddenFieldsInForm(g));try{await i.retargetReferences(l.variable_name,_,"hiddenField")}catch(te){const fe=ge=>ge.map(de=>de===_?l.variable_name:de);throw await i.retargetReferences(_,l.variable_name,"hiddenField").cat
9ch(()=>{}),await ot().update(b,{hiddenFields:fe(i.hiddenFieldsToSave(_))}).catch(()=>{}),x(b)&&i.updateHiddenFieldsInForm(fe(m().hiddenFields||[])),te}i.updateFormIsDirty(!0)},describeError:v=>`The hidden field could not be renamed: ${v.message}.`});return h?{warning:h}:{}}async function $e(l,b){if(!l.variable_name)return{};const _=await i.deleteHiddenFieldWithCascade(l.variable_name,{confirm:ae,purgeIntegrations:!1});if(_.status==="not-found")return{warning:`The hidden field "${l.variable_name}" was not found, so it could not be deleted.`};if(_.status!=="ready")return{};const h=W(_),v=await I(b,{resourceKey:`form:${b}:hiddenField:${l.variable_name}`,actionKey:"actions.deleteHiddenField",run:()=>_.execute(),describeError:g=>`The hidden field could not be deleted: ${g.message}. It was left in place.`}),H=[h,v].filter(Boolean).join(" ");return H?{warning:H,...v?{}:{disclosure:!0}}:{}}async function Se(l,b){const _=l.is_active==="true",h=await I(b,{resourceKey:`form:${b}:tracking`,actionKey:"actions.toggleUtmParameters",run:async()=>{await i.toggleUtmParameters(_)},describeError:v=>`UTM tracking could not be ${_?"enabled":"disabled"}: ${v.message}.`});return h?{warning:h}:{}}async function Le(l,b){const _=m()?.id;switch(l.action){case"add_field":return T(l,_);case"update_field":return be(l,_);case"delete_field":return D(l,_);case"update_form_title":return L(l);case"delete_field_logic":return K(l,_);case"append_field_logic_rule":return ne(l,_);case"append_logic_rules":return we(l,_);case"add_variable":return ve(l,_);case"update_variable":return G(l,_);case"delete_variable":return U(l,_);case"update_form_setting":return oe(l,_);case"update_form_meta_tag":return ke(l,_);case"update_form_language":return Ee(l);case"update_form_close_date":return _e(l);case"publish_form":return le();case"discard_form":return O();case"add_hidden_field":return A(l,_);case"update_hidden_field":return z(l,_);case"delete_hidden_field":return $e(l,_);case"toggle_utm_tracking":return Se(l,_);default:return{}}}const Te=Po("form-edit");async function Ue(){for(;i.aiLoadingFieldIds.length>0;)await new Promise(l=>setTimeout(l,500))}const Me={contextKey:"form-edit",entityId:F(()=>t.params.id),language:F(()=>m()?.language||o.user?.language||"en"),placeholder:u("components.formEdit.aiChat.placeholder"),repository:Yu(),executeOperation:Le,resolveReferences:{canResolve:y,collectRefs:E,resolveOp:w},onOperationsComplete:l=>{l&&S(l)},canLoadSuggestions:Ue,addRouteParam:Te,fieldCount:F(()=>(i.fields||[]).filter(l=>!["welcome-screen","ending-screen"].includes(l.type)).length),fallbackSuggestions:()=>[u("components.formEdit.aiChat.suggestionFallback1"),u("components.formEdit.aiChat.suggestionFallback2"),u("components.formEdit.aiChat.suggestionFallback3"),u("components.formEdit.aiChat.suggestionFallback4")]};return jo(Me),Me}const nc={class:"flex flex-col flex-1 min-w-0 min-h-0"},oc={class:"flex-1 min-w-0 min-h-0 flex gap-1 pb-3.5 pr-3.5 box-border max-md:px-3 max-md:pb-3"},ic={class:"flex flex-col w-full flex-1 min-w-0 min-h-0 overflow-hidden"},sc={class:"hidden lg:flex flex-1 min-h-0 overflow-hidden min-w-0 gap-1"},lc={"data-tour":"editor-left",class:"w-80 flex-none bg-white rounded-l-2xl shadow-sm px-4 py-5 overflow-hidden"},ac={"data-tour":"editor-canvas",class:"flex-1 w-full flex flex-col bg-white px-5 py-4 shadow-sm full-height min-h-0 min-w-0"},rc={key:0,class:"flex-none mb-3.5"},dc={class:"flex-1 min-h-0 flex justify-center overflow-hidden"},uc={"data-tour":"editor-right",class:"w-80 flex-none bg-white rounded-r-2xl shadow-sm p-5 overflow-hidden"},cc={class:"hidden lg:contents"},mc={__name:"index",setup(t){Eo({htmlAttrs:{class:"overflow-hidden"},bodyAttrs:{class:"bg-neutral-lightest overflow-hidden"}});const n=pt(),o=qt(),i=Ae(),d=So(),a=bt(),{editingDevice:u}=vt(a),{gotoHome:m}=Uo(),f=Mo(),p=F(()=>u.value==="mobile"?"canvas-device-mobile":u.value==="tablet"?"canvas-device-tablet":"");Nt("ai-chat-context",tc());const y=Z(!0),E=Z(null);return Ko("editor",()=>!y.value),nt(async()=>{const w=n.params.id;try{if(!await i.retrieveFormForPage(w))return;const S=i.fields[0];Ve.init(i.form.theme),i.form?.workspaceId&&d.ensureActiveBilling().catch(N=>{console.warn("Failed to load form workspace billing:",N)}),i.fields.find(N=>N.id===n.query.field)?o.push({path:n.path,query:{...n.query,field:n.query.field}}):o.push({path:n.path,query:{...n.query,field:S?.id}})}catch(S){if(f())return;E.value=S,m({error:S})}finally{y.value=!1}}),(w,S)=>{const x=Jn,N=ta,I=ra,R=Jt,T=ye("o-loading"),ce=pa,be=Ku,ae=Ju,W=Bo;return r(),c("div",nc,[C(x,{"show-editor-actions":!0}),s("div",oc,[s("div",ic,[s("div",sc,[s("div",lc,[e(y)?V("",!0):(r(),J(N,{key:0}))]),s("div",ac,[e(y)?V("",!0):(r(),c("div",rc,[C(I)])),s("div",dc,[s("div",{class:re(["flex-1 rounded-3xl border-8 border-neutral-darkest bg-white relative overflow-hidden",e(p)])},[C(T,{"full-page":!1,active:e(y),"can-cancel":!1},{default:P(()=>[C(R)]),_:1},8,["active"]),e(y)?V("",!0):(r(),J(ce,{key:0}))],2)])]),s("div",uc,[e(y)?V("",!0):(r(),J(be,{key:0}))])]),C(ae,{class:"lg:hidden","form-id":e(n).params.id},null,8,["form-id"]),s("div",cc,[e(y)?V("",!0):(r(),J(W,{key:0}))])])])])}}}
9,fc=Be(mc,[["__scopeId","data-v-5aff03d2"]]),Mc=Object.freeze(Object.defineProperty({__proto__:null,default:fc},Symbol.toStringTag,{value:"Module"}));export{St as _,or as a,bt as b,Hn as c,ca as d,Mc as i,Yt as u};
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.