Your IP : 216.73.217.77


Current Path : /home/users/unlimited/www/whatsapp-crm/public/build/assets/
Upload File :
Current File : /home/users/unlimited/www/whatsapp-crm/public/build/assets/Edit-8d41cc54.js

import{r as g,T as R,c as a,f as p,g as b,F as y,o as d,a as e,t as r,u as i,l as U,k as x,h as k,n as c,b as v,e as A,x as N}from"./app-f1493ab2.js";import{_ as O}from"./App-45dbd9fa.js";import{t as m}from"./index-764662c4.js";import{_ as F}from"./FormInput-b3450213.js";import{_ as $}from"./FormSelect-3a6ffebd.js";import{_ as P}from"./FormSelectCombo-66d92913.js";import{_ as E}from"./FormTextArea-95511fff.js";import{_ as I}from"./Modal-a0814fa2.js";import"./Sidebar-f2ddcf5a.js";import"./Menu-73c1148a.js";import"./ProfileModal-09ae28bb.js";import"./tabs-80627b62.js";import"./hidden-f79cef22.js";import"./micro-task-89dcd6af.js";import"./transition-f32a8133.js";import"./use-outside-click-92c6377f.js";import"./LangToggle-d2b58a25.js";import"./index-114bea05.js";import"./MobileSidebar-e6661e49.js";/* empty css              */import"./pusher-a82d1614.js";import"./use-text-value-ecd8c541.js";import"./use-tree-walker-d52d0c0b.js";const J={class:"bg-white md:bg-inherit pt-10 px-4 md:pt-8 md:p-8 rounded-[5px] text-[#000] h-full md:overflow-y-auto"},D={class:"flex justify-between"},G={class:"text-xl mb-1"},H={class:"mb-6 flex items-center text-sm leading-6 text-gray-600"},W={class:"ml-1 mt-1"},q={class:"flex border-b py-5"},z={class:"w-[40%] mb-1"},K={class:"text-sm text-gray-500 tracking-[0px]"},Q={class:"w-[60%] flex space-x-6"},X={class:"w-[80%]"},Y={class:"flex border-b py-5"},ee={class:"w-[40%] mb-1"},te={class:"text-sm text-gray-500 tracking-[0px]"},se={class:"flex text-xs mt-2"},oe={class:"w-[60%] flex space-x-6"},ie={class:"w-[80%]"},re={class:"flex border-b py-5"},le={class:"w-[40%] mb-1"},ne={class:"text-sm text-gray-500 tracking-[0px]"},ae={class:"flex text-xs mt-2"},de={class:"w-[60%] flex space-x-6"},pe={class:"w-[80%]"},ce={class:"flex border-b py-5"},ue={class:"w-[40%] mb-1"},me={class:"text-sm text-gray-500 tracking-[0px]"},he={class:"w-[60%] flex space-x-6"},fe={class:"w-[80%]"},ge={key:0,class:"flex py-5"},xe={class:"w-[40%] mb-1"},ve={class:"text-sm text-gray-500 tracking-[0px]"},be={class:"w-[60%] flex space-x-6"},_e={class:"w-[80%]"},we={class:c("sm:col-span-6 mb-2")},ye={class:"mt-2"},ke={key:0,class:"form-error text-[#b91c1c] text-xs"},$e={type:"submit",class:"float-right flex items-center space-x-4 rounded-md bg-black px-3 py-2 text-sm text-white shadow-sm hover:bg-slate-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"},Ve={key:1,class:"flex py-5"},Ce={class:"w-[40%] mb-1"},Le={class:"text-sm text-gray-500 tracking-[0px]"},Se={class:"w-[60%] flex space-x-6"},Me={class:"w-[80%]"},Te={type:"submit",class:"float-right flex items-center space-x-4 rounded-md bg-black px-3 py-2 text-sm text-white shadow-sm hover:bg-slate-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"},Ze={key:2,class:"flex py-5"},je={class:"w-[40%] mb-1"},Be={key:0,class:"text-sm text-gray-500 tracking-[0px]"},Re={key:1,class:"text-sm text-gray-500 tracking-[0px]"},Ue={class:"w-[60%] flex space-x-6"},Ae={class:"w-[80%]"},Ne=["accept"],Oe={class:"text-center"},Fe={key:0,class:"flex justify-center items-center"},Pe={class:"flex justify-center items-center space-x-3 py-1 border bg-slate-100 rounded-lg mb-2 w-fit px-2"},Ee={class:"flex items-center space-x-2"},Ie={class:"text-sm"},Je={class:"flex justify-center text-sm text-gray-600"},De={key:0,for:"file-upload",class:"relative cursor-pointer bg-white rounded-md font-medium hover:text-indigo-500 focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-indigo-500"},Ge={class:"text-xs text-center text-gray-500"},He={key:1,for:"file-upload",class:"relative cursor-pointer bg-white rounded-md font-medium hover:text-indigo-500 focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-indigo-500"},We={class:"text-xs text-center text-gray-500"},qe={key:0,class:"form-error text-[#b91c1c] text-xs"},ze={type:"submit",class:"mt-10 float-right flex items-center space-x-4 rounded-md bg-black px-3 py-2 text-sm text-white shadow-sm hover:bg-slate-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"},Ke={class:"mt-2 grid grid-cols-1 gap-x-6"},Qe={class:"pt-3 grid grid-cols-2 gap-x-2 text-sm gap-y-1"},Xe=["onClick"],Ye={class:"mt-4 border-t pt-4"},kt={__name:"Edit",props:["autoreply","placeholders"],setup(V){const u=V,h=g(!1),_=g(null),C=s=>{const t=_.value;if(t){const n=t.selectionStart,l=t.selectionEnd;t.value=`${t.value.substring(0,n)}${s}${t.value.substring(l)}`}h.value=!1},L=s=>{o.response=s.target.value},f=JSON.parse(u.autoreply.metadata).type,S=()=>{const s=JSON.parse(u.autoreply.metadata).data;return f==="text"?s.text:f==="image"||f==="audio"?s==null?void 0:s.file:s.template},o=R({_method:"put",name:u.autoreply.name,trigger:u.autoreply.trigger,match_criteria:u.autoreply.match_criteria,response_type:f,response:S()}),M=g([{value:"exact match",label:m("When text is an exact match to trigger text")},{value:"contains",label:m("When text contains trigger text")}]),T=g([{value:"text",label:m("Respond with text")},{value:"image",label:m("Respond with image")},{value:"audio",label:m("Respond with audio")}]),Z=async(s,t)=>{try{const n=await N.get("/templates?query="+s);t(n.data[0])}catch(n){console.error("Error fetching rows:",n)}},j=s=>{const t=s.target.files[0],n=new FileReader;n.onload=l=>{o.response=t},n.readAsDataURL(t)},w=()=>{o.response=null},B=()=>{o.post("/automation/basic/"+u.autoreply.uuid)};return(s,t)=>(d(),a(y,null,[p(O,null,{default:b(()=>{var n;return[e("div",J,[e("div",D,[e("div",null,[e("h2",G,r(s.$t("Update automation")),1),e("p",H,[t[10]||(t[10]=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24"},[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 11v5m0 5a9 9 0 1 1 0-18a9 9 0 0 1 0 18Zm.05-13v.1h-.1V8h.1Z"})],-1)),e("span",W,r(s.$t("Update your setup")),1)])]),e("div",null,[p(i(U),{href:"/automation/basic",class:"flex items-center space-x-4 rounded-md bg-indigo-600 px-3 py-2 text-sm text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"},{default:b(()=>[t[11]||(t[11]=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"},[e("path",{fill:"currentColor","fill-rule":"evenodd",d:"M5.841 5.28a.75.75 0 0 0-1.06-1.06L1.53 7.47L1 8l.53.53l3.25 3.25a.75.75 0 0 0 1.061-1.06l-1.97-1.97H24.25a.75.75 0 0 0 0-1.5H3.871l1.97-1.97Z","clip-rule":"evenodd"})],-1)),x(" "+r(s.$t("Back")),1)]),_:1})])]),e("form",{onSubmit:t[8]||(t[8]=k(l=>B(),["prevent"])),class:"bg-white border py-5 px-5 rounded-[0.5rem]"},[e("div",q,[e("div",z,[e("h2",K,r(s.$t("Name")),1)]),e("div",Q,[e("div",X,[p(F,{modelValue:i(o).name,"onUpdate:modelValue":t[0]||(t[0]=l=>i(o).name=l),type:"text",error:i(o).errors.name,class:c("w-full"),labelClass:"mb-0"},null,8,["modelValue","error"])])])]),e("div",Y,[e("div",ee,[e("h2",te,r(s.$t("Trigger")),1),e("span",se,[t[12]||(t[12]=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"15",height:"15",viewBox:"0 0 24 24"},[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 11v5m0 5a9 9 0 1 1 0-18a9 9 0 0 1 0 18Zm.05-13v.1h-.1V8h.1Z"})],-1)),x(" "+r(s.$t("Add the string of text responsible for triggering the response")),1)])]),e("div",oe,[e("div",ie,[p(E,{modelValue:i(o).trigger,"onUpdate:modelValue":t[1]||(t[1]=l=>i(o).trigger=l),type:"text",error:i(o).errors.trigger,textAreaRows:3,class:c("sm:col-span-6 mb-10")},null,8,["modelValue","error"])])])]),e("div",re,[e("div",le,[e("h2",ne,r(s.$t("Match criteria")),1),e("span",ae,[t[13]||(t[13]=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"15",height:"15",viewBox:"0 0 24 24"},[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 11v5m0 5a9 9 0 1 1 0-18a9 9 0 0 1 0 18Zm.05-13v.1h-.1V8h.1Z"})],-1)),x(" "+r(s.$t("Select the criteria for matching the trigger text above")),1)])]),e("div",de,[e("div",pe,[p($,{modelValue:i(o).match_criteria,"onUpdate:modelValue":t[2]||(t[2]=l=>i(o).match_criteria=l),options:M.value,error:i(o).errors.match_criteria,class:c("sm:col-span-6"),placeholder:s.$t("Select criteria")},null,8,["modelValue","options","error","placeholder"])])])]),e("div",ce,[e("div",ue,[e("h2",me,r(s.$t("Response type")),1)]),e("div",he,[e("div",fe,[p($,{modelValue:i(o).response_type,"onUpdate:modelValue":[t[3]||(t[3]=l=>i(o).response_type=l),w],options:T.value,error:i(o).errors.response_type,class:c("sm:col-span-6"),placeholder:"Select Type"},null,8,["modelValue","options","error"])])])]),i(o).response_type==="text"?(d(),a("div",ge,[e("div",xe,[e("h2",ve,r(s.$t("Text response")),1)]),e("div",be,[e("div",_e,[e("div",null,[e("div",we,[e("div",ye,[e("textarea",{class:c(["block w-full rounded-md border-0 py-1.5 px-4 text-gray-900 shadow-sm outline-none ring-1 ring-inset placeholder:text-gray-400 sm:text-sm sm:leading-6",i(o).errors.response?"ring-[#b91c1c]":"ring-gray-300"]),onInput:L,rows:"3",ref_key:"textareaRef",ref:_},r(i(o).response),35)]),i(o).errors.response?(d(),a("div",ke,r(i(o).errors.response),1)):v("",!0)]),e("button",{type:"button",onClick:t[4]||(t[4]=l=>h.value=!0),class:"bg-slate-100 px-2 py-1 rounded-md text-sm flex items-center gap-x-1 shadow-sm"},t[14]||(t[14]=[x(" Add Variable "),e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24"},[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M8.25 15L12 18.75L15.75 15m-7.5-6L12 5.25L15.75 9"})],-1)]))]),e("button",$e,r(s.$t("Save")),1)])])])):i(o).response_type==="template"?(d(),a("div",Ve,[e("div",Ce,[e("h2",Le,r(s.$t("Template response")),1)]),e("div",Se,[e("div",Me,[p(P,{modelValue:i(o).response,"onUpdate:modelValue":t[5]||(t[5]=l=>i(o).response=l),loadOptions:Z,error:i(o).errors.response,class:c("sm:col-span-6 mb-10"),placeholder:"Select Template"},null,8,["modelValue","error"]),e("button",Te,r(s.$t("Save")),1)])])])):i(o).response_type==="image"||i(o).response_type==="audio"?(d(),a("div",Ze,[e("div",je,[i(o).response_type==="image"?(d(),a("h2",Be,r(s.$t("Image response")),1)):(d(),a("h2",Re,r(s.$t("Audio response")),1))]),e("div",Ue,[e("div",Ae,[e("div",{class:c([i(o).errors.response?"border-[#b91c1c]":"border-gray-300","flex justify-center px-6 pt-5 pb-6 border-2 border-dashed rounded-md"])},[e("input",{type:"file",class:"sr-only",accept:i(o).response_type==="image"?".jpg, .png":".mp3",ref:"fileInput",id:"file-upload",onChange:t[6]||(t[6]=l=>j(l))},null,40,Ne),e("div",Oe,[e("div",null,[i(o).response?(d(),a("div",Fe,[e("div",Pe,[t[16]||(t[16]=e("div",null,[e("svg",{class:"mx-auto h-6 w-6 text-gray-400 cursor-pointer",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},[e("path",{fill:"currentColor",d:"M14 9a1.5 1.5 0 1 1 3 0a1.5 1.5 0 0 1-3 0Z"}),e("path",{fill:"currentColor","fill-rule":"evenodd",d:"M7.268 4.658a54.647 54.647 0 0 1 9.465 0l1.51.132a3.138 3.138 0 0 1 2.831 2.66a30.604 30.604 0 0 1 0 9.1a3.138 3.138 0 0 1-2.831 2.66l-1.51.131c-3.15.274-6.316.274-9.465 0l-1.51-.131a3.138 3.138 0 0 1-2.832-2.66a30.601 30.601 0 0 1 0-9.1a3.138 3.138 0 0 1 2.831-2.66l1.51-.132Zm9.335 1.495a53.147 53.147 0 0 0-9.206 0l-1.51.131A1.638 1.638 0 0 0 4.41 7.672a29.101 29.101 0 0 0-.311 5.17L7.97 8.97a.75.75 0 0 1 1.09.032l3.672 4.13l2.53-.844a.75.75 0 0 1 .796.21l3.519 3.91a29.101 29.101 0 0 0 .014-8.736a1.638 1.638 0 0 0-1.478-1.388l-1.51-.131Zm2.017 11.435l-3.349-3.721l-2.534.844a.75.75 0 0 1-.798-.213l-3.471-3.905l-4.244 4.243c.049.498.11.996.185 1.491a1.638 1.638 0 0 0 1.478 1.389l1.51.131c3.063.266 6.143.266 9.206 0l1.51-.131c.178-.016.35-.06.507-.128Z","clip-rule":"evenodd"})])],-1)),e("div",Ee,[e("span",Ie,r(((n=i(o).response)==null?void 0:n.name)??i(o).response),1),e("button",{type:"button",onClick:t[7]||(t[7]=l=>w())},t[15]||(t[15]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},[e("path",{fill:"currentColor","fill-rule":"evenodd",d:"M17.707 7.707a1 1 0 0 0-1.414-1.414L12 10.586L7.707 6.293a1 1 0 0 0-1.414 1.414L10.586 12l-4.293 4.293a1 1 0 1 0 1.414 1.414L12 13.414l4.293 4.293a1 1 0 1 0 1.414-1.414L13.414 12l4.293-4.293Z","clip-rule":"evenodd"})],-1)]))])])])):v("",!0),e("div",Je,[i(o).response_type==="image"?(d(),a("label",De,[e("p",null,r(s.$t("Click to upload image")),1),e("p",Ge,r(s.$t("PNG or JPG files only")),1)])):(d(),a("label",He,[e("p",null,r(s.$t("Click to upload audio")),1),e("p",We,r(s.$t("MP3 files only")),1)]))])])])],2),i(o).errors.response?(d(),a("div",qe,r(i(o).errors.response),1)):v("",!0),e("button",ze,r(s.$t("Save")),1)])])])):v("",!0)],32)])]}),_:1}),p(I,{label:s.$t("Select variable"),isOpen:h.value},{default:b(()=>[t[17]||(t[17]=e("div",{class:"flex bg-slate-50 p-2 rounded-md mt-3"},[e("span",{class:"font-light text-sm"},"Select a placeholder to add to your response. The placeholder will replace itself with the actual data.")],-1)),e("div",Ke,[e("div",Qe,[(d(!0),a(y,null,A(u.placeholders,n=>(d(),a("button",{onClick:l=>C(n.value),class:"col-span-1 bg-gray-100 p-2 rounded-md text-left hover:bg-gray-50"},r(s.$t(n.label)),9,Xe))),256))]),e("div",Ye,[e("button",{type:"button",onClick:t[9]||(t[9]=k(n=>h.value=!1,["self"])),class:"inline-flex justify-center rounded-md border border-transparent bg-slate-50 px-4 py-2 text-sm text-slate-500 hover:bg-slate-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 mr-4"},r(s.$t("Cancel")),1)])])]),_:1},8,["label","isOpen"])],64))}};export{kt as default};