import{T as C,l as S,c as d,o as n,d as l,b as p,u as t,f as R,g as V,t as u,i as M,n as T,F as $,h as w,e as F,k as L}from"./app-fEKA3BkQ.js";import{S as v}from"./SelectField-b39MFXJO.js";import{_ as U}from"./SpinnerBtn-BezRkGQj.js";import{_ as B}from"./UserLayout-D_lxcpvH.js";import"./PageHeader-DmRLoM5E.js";import"./assetStore-BSVLrDIW.js";import"./ValidationErrors-B24rcOPH.js";const E={class:"card card-body mx-auto space-y-3 py-6 sm:max-w-2xl"},j={class:"label mb-1"},A={key:0,class:"my-1 text-[11px] font-light text-danger-600"},N={class:"flex items-center gap-3"},O={class:"flex items-center gap-2"},P=["onClick"],D={class:"flex w-full justify-end"},z={__name:"Form",props:{module:{type:String,required:!0},platformLevel:{type:String,default:"Platform"},platforms:{type:Array,required:[]},shortCodes:{type:Array,default:[]},quickReply:{type:Object,default:{}}},setup(r){var c;const s=r,i=!!((c=s.quickReply)!=null&&c.id),e=C({module:s.module,platform_id:"",message_template:"",status:"active",_method:"POST"});S(()=>{i&&s.quickReply&&(e.platform_id=s.quickReply.platform_id,e.message_template=s.quickReply.message_template,e.status=s.quickReply.status,e._method="PUT")});const k=()=>{e.post(route(`user.${s.module.toLowerCase()}.quick-replies.${i?"update":"store"}`,{id:i?s.quickReply.id:null}))},x=[{name:"Active",id:"active"},{name:"Inactive",id:"inactive"}],h=m=>{e.message_template=`${e.message_template} ${m}`};return(m,a)=>{var f,y,_,g,b;return n(),d("form",{onSubmit:F(k,["prevent"])},[l("div",E,[p(v,{label:r.platformLevel,modelValue:t(e).platform_id,"onUpdate:modelValue":a[0]||(a[0]=o=>t(e).platform_id=o),validationMessage:(f=t(e).errors)==null?void 0:f.platform_id,options:r.platforms},null,8,["label","modelValue","validationMessage","options"]),l("div",null,[l("label",j,u(m.trans("Message Template")),1),R(l("textarea",{"onUpdate:modelValue":a[1]||(a[1]=o=>t(e).message_template=o),id:"body-text-id",class:T([{"border border-danger-600":(y=t(e).errors)==null?void 0:y.text},"textarea"])},null,2),[[M,t(e).message_template]]),(_=t(e).errors)!=null&&_.text?(n(),d("div",A,u((g=t(e).errors)==null?void 0:g.text),1)):V("",!0)]),l("div",N,[a[3]||(a[3]=l("p",null,"Variables:",-1)),l("div",O,[(n(!0),d($,null,w(r.shortCodes,(o,q)=>(n(),d("button",{key:q,type:"button",class:"btn-outline-primary rounded px-1",onClick:I=>h(o)},u(o),9,P))),128))])]),p(v,{label:"Select Status",modelValue:t(e).status,"onUpdate:modelValue":a[2]||(a[2]=o=>t(e).status=o),placeholder:"SELECT",validationMessage:(b=t(e).errors)==null?void 0:b.status,options:x},null,8,["modelValue","validationMessage"]),l("div",D,[p(U,{type:"submit",processing:t(e).processing,"btn-text":m.trans(i?"Update":"Create")},null,8,["processing","btn-text"])])])],32)}}},Y=Object.assign({layout:B},{__name:"Create",props:["platforms","quickReply"],setup(r){return(s,i)=>(n(),L(z,{module:"whatsapp",platforms:r.platforms,shortCodes:["{name}","{phone}"],quickReply:r.quickReply},null,8,["platforms","quickReply"]))}});export{Y as default};
