1import D from"./BvgwO89H.js";import{_ as z}from"./DUQqgW5Q.js";import{_ as U}from"./Bs1uh7K_.js";import{c as A,d as J,a as K}from"./CBnC-wTy.js";import{d as O,E as M,ai as W,u as r,a5 as p,r as l,ar as P,o as Z,a6 as g,a7 as G,b as Q,z as X}from"./BbDbjuyS.js";import{E as S}from"./BgPtUu1v.js";import{T as F}from"./JZdjzcWY.js";import{c as Y,a as ee,s as te,bj as B,d as I,h as E,bk as oe,z as ae}from"./B8e4kH1O.js";import{e as ne}from"./kVuZRh9F.js";const se={class:"h-full bg-white flex items-center justify-center"},re=["innerHTML"],ce=O({__name:"ThankContent",props:{formData:{},variables:{}},setup(y){const c=y,{formData:u,variables:_}=c,h=u?.end_content?.replace(/\[(\w+)\]/g,(v,n)=>_?.[n]||`[${n}]`);return(v,n)=>(p(),M("div",se,[W("b",{class:"text-lg",innerHTML:r(h)},null,8,re)]))}}),ie=Object.assign(ce,{__name:"AdminThankContent"}),le={key:0,class:"text-center"},de=O({__name:"FormEmbedComponent",props:{formId:{}},async setup(y){let c,u;const _=y,h=l([]),v=l([]),n=Y(),j=ee(),{site:q}=te(j),b=B("ref").value,a=Q({combo_ids:[],course_ids:[]}),w=l(A().shape({})),{data:o}=([c,u]=P(()=>E(`/api/v1/forms/get-form-embed/${_.formId}`,"$gWtaOcZ6U4")),c=await c,u(),c);if(o.value){const t={};o.value?.values.forEach(e=>{const d=e.var?.replace(/{|}/g,"")??"",m=["checkbox","multi_select"].includes(e.type);a[d]=m?[]:"",e.required&&(t[d]=m?J().min(1,`${e.label} không ÄÆ°á»£c Äá» trá»ng`):K().required(`${e.label} không ÄÆ°á»£c Äá» trá»ng`))}),w.value=A().shape(t)}Z(async()=>{const t=B("viewed_form",{default:()=>[],maxAge:86400});if(o.value){let e=t.value;if(typeof e=="string")try{e=JSON.parse(e)}catch{e=[]}Array.isArray(e)||(e=[]),e.includes(o.value?._id)||(await $fetch(`/api/v1/forms/update-view/${_.formId}`,{method:"PATCH",headers:I(),immediate:!0}),e.push(o.value?._id),t.value=e)}});const R=X(()=>(o.value?.combo_ids?.length??0)>0||(o.value?.course_ids?.length??0)>0);async function V(t){R.value?await L(t.data):await N(t.data)}const{data:H}=([c,u]=P(()=>E(`/api/v1/sites/${q.value?._id}/payment-method`,"$6PVOgtjLf1")),c=await c,u(),c),k=l(H.value?.payment_method?.includes(S.ActiveBank)?S.ActiveBank:""),$=l(!1),C=l("");async function L(t){if(!k.value){n.add({description:"Chưa có phương thưc thanh toán phù hợp!",color:"warning"});return}if(!t?.combo_ids?.length&&!t?.course_ids?.length){n.add({description:"Vui lòng chá»n Ãt nhất má»t sản phẩm hoặc combo Äá» mua",color:"warning"});return}const e=a.phone?oe(a.phone):void 0;if(a.phone&&ne(e)){n.add({description:"Sá» Äiá»n thoại sai Äá»nh dạng! Vui lòng nháºp lại!",color:"warning"});return}const d=l([]);if(a.combo_ids?.length){const i=a.combo_ids.map(s=>v.value.find(f=>f._id===s)).filter(Boolean).map(s=>({product_id:s?._id,type_sell:F.Combo,price:s?.price_sell,quantity:1}));d.value.push(...i)}if(a.course_ids?.length){const i=a.course_ids.map(s=>h.value.find(f=>f._id===s)).filter(Boolean).map(s=>({product_id:s?._id,type_sell:F.Course,price:s?.price_sell,quantity:1}));d.value.push(...i)}const m={full_name:a.full_name,phone:e,email:a.email,products:d.value,paymentMethod:k.value};await $fetch("/api/v2/orders",{method:"POST",body:m,headers:I(),onResponse:async({response:i})=>{i.ok?(console.log(i),n.add({description:"Tạo ÄÆ¡n hà ng thà nh công!",color:"success"}),$.value=!0,C.value=i._data.order_id):n.add({description:"Tạo ÄÆ¡n thất bại!",color:"error"})}})}const T=l(!1),x=l();async function N(t){await $fetch(`/api/v1/lead/create/${_.formId}`,{body:{fields:t,ref:b||""},method:"POST",async onResponse({response:e}){e._data&&e._data.success&&(o.value?.end_type==="content"?(n.add({description:"ÄÄng ký thà nh công!",color:"success"}),T.value=!0,x.value=t):o.value?.end_type==="url"&&(n.add({description:"ÄÄng ký thà nh công!",color:"success"}),ae(o.value?.end_url,{external:!0})))}})}return(t,e)=>{const d=D,m=z,i=U;return r($)?(p(),g(d,{key:0,"order-id":r(C)},null,8,["order-id"])):r(T)?(p(),g(ie,{key:1,"form-data":r(o),variables:r(x)},null,8,["form-data","variables"])):(p(),g(i,{key:2,schema:r(w),state:r(a),class:"overflow-y-auto",style:{"scrollbar-width":"thin"},onSubmit:V},{default:G(()=>[r(o)?(p(),g(m,{key:1,"form-info":r(o),state:r(a),onLoaded:e[0]||(e[0]=({courses:s,combos:f})=>{h.value=s,v.value=f})},null,8,["form-info","state"])):(p(),M("p",le," Không tá»n tại form nà y! "))]),_:1},8,["schema","state"]))}}}),be=Object.assign(de,{__name:"AdminFormEmbedComponent"});export{be as _};
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.