File: /home/dmstechonline/whatsapp.dmstech.online/public/build/assets/Index-8a427ccb.js
import{T as O,r as C,O as P,o as n,c as u,a as e,w as Ve,v as Me,u as s,b as x,d as Ze,j as d,g as b,h as M,t as i,F as K,e as Ae,f as E,n as f,l as Se,m as Te,G as $e,k as j,K as Be}from"./app-884e4ce3.js";import Fe from"./Layout-cb864a58.js";import{t as ye}from"./index-d349a931.js";import{d as Ie}from"./debounce-42603f74.js";import{_ as De}from"./AlertModal-7204a9e7.js";import{u as Ne}from"./useAlertModal-e78cf661.js";/* empty css */import{a as Ue,_ as N,T as je}from"./TableHeaderRowItem-d8a183bc.js";import{a as Oe,_ as U,T as ze}from"./TableBodyRowItem-145e00f8.js";import{_ as Le}from"./Dropdown-5f5db5e5.js";import{_ as H}from"./FormInput-ab713954.js";import{_ as Ce}from"./Modal-a947e544.js";import{_ as xe}from"./FormSelect-1f27a419.js";import{_ as Ee}from"./FormTextArea-3daa517d.js";import{_ as ke}from"./FormToggleSwitch-5613ae6f.js";import{P as Pe}from"./Pagination-6803fb76.js";import"./App-faae56c7.js";import"./Sidebar-ec4f7223.js";import"./Menu-58091ecb.js";import"./ProfileModal-268f6e59.js";import"./FormPhoneInput-8c055c19.js";/* empty css */import"./transition-15fedc5d.js";import"./hidden-733404a0.js";import"./use-outside-click-1c7dcbeb.js";import"./micro-task-89dcd6af.js";import"./tabs-3ad99d3f.js";import"./use-resolve-button-type-261165f4.js";import"./LangToggle-54d6b98e.js";import"./OrganizationModal-83fb7cbd.js";import"./use-text-value-48384026.js";import"./index-ff0eb693.js";import"./MobileSidebar-4319591b.js";import"./pusher-e63f75b9.js";import"./useRtl-295d8c04.js";import"./_baseGetTag-0b0c5108.js";import"./_plugin-vue_export-helper-c27b6911.js";import"./use-tree-walker-6ecb48c5.js";const Ke={class:"bg-slate-100 md:bg-slate-50 flex items-center border border-primary md:border-none md:shadow-sm h-10 w-full md:w-80 rounded-[0.5rem] mb-6 text-sm"},He=["placeholder"],Re={key:1,class:"pr-2"},Xe={class:"bg-slate-100 md:bg-slate-50 rounded-[0.5rem]"},qe={class:"w-full"},We=["onClick"],Ge={__name:"DocumentTable",props:{rows:{type:Object,required:!0},filters:{type:Object}},emits:["delete"],setup(V,{emit:Z}){const A=V,{isOpenAlert:c,openAlert:S,confirmAlert:k}=Ne(),$=O({test:null}),_=p=>{$.delete("/automation/upload/document/"+p)},h=p=>p===A.rows.data.length-1,o=C({search:A.filters.search}),v=C(!1),B=()=>{o.value.search=null,F()},T=Ie(()=>{v.value=!0,F()},1e3),F=()=>{P.visit("/automation/ai",{method:"get",data:o.value})},D=p=>p?p.charAt(0).toUpperCase()+p.slice(1):"";return(p,m)=>(n(),u(K,null,[e("div",Ke,[m[6]||(m[6]=e("span",{class:"pl-3"},[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":"2",d:"m15 15l6 6m-11-4a7 7 0 1 1 0-14a7 7 0 0 1 0 14Z"})])],-1)),Ve(e("input",{onInput:m[0]||(m[0]=(...l)=>s(T)&&s(T)(...l)),"onUpdate:modelValue":m[1]||(m[1]=l=>o.value.search=l),type:"text",class:"outline-none px-4 w-full bg-slate-100 md:bg-slate-50",placeholder:p.$t("Search by title")},null,40,He),[[Me,o.value.search]]),v.value===!1&&o.value.search?(n(),u("button",{key:0,onClick:B,type:"button",class:"pr-2"},m[4]||(m[4]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},[e("path",{fill:"currentColor",d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10s10-4.5 10-10S17.5 2 12 2zm3.7 12.3c.4.4.4 1 0 1.4c-.4.4-1 .4-1.4 0L12 13.4l-2.3 2.3c-.4.4-1 .4-1.4 0c-.4-.4-.4-1 0-1.4l2.3-2.3l-2.3-2.3c-.4-.4-.4-1 0-1.4c.4-.4 1-.4 1.4 0l2.3 2.3l2.3-2.3c.4-.4 1-.4 1.4 0c.4.4.4 1 0 1.4L13.4 12l2.3 2.3z"})],-1)]))):x("",!0),v.value?(n(),u("span",Re,m[5]||(m[5]=[Ze('<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><circle cx="12" cy="3.5" r="1.5" fill="currentColor" opacity="0"><animateTransform attributeName="transform" calcMode="discrete" dur="2.4s" repeatCount="indefinite" type="rotate" values="0 12 12;90 12 12;180 12 12;270 12 12"></animateTransform><animate attributeName="opacity" dur="0.6s" keyTimes="0;0.5;1" repeatCount="indefinite" values="1;1;0"></animate></circle><circle cx="12" cy="3.5" r="1.5" fill="currentColor" opacity="0"><animateTransform attributeName="transform" begin="0.2s" calcMode="discrete" dur="2.4s" repeatCount="indefinite" type="rotate" values="30 12 12;120 12 12;210 12 12;300 12 12"></animateTransform><animate attributeName="opacity" begin="0.2s" dur="0.6s" keyTimes="0;0.5;1" repeatCount="indefinite" values="1;1;0"></animate></circle><circle cx="12" cy="3.5" r="1.5" fill="currentColor" opacity="0"><animateTransform attributeName="transform" begin="0.4s" calcMode="discrete" dur="2.4s" repeatCount="indefinite" type="rotate" values="60 12 12;150 12 12;240 12 12;330 12 12"></animateTransform><animate attributeName="opacity" begin="0.4s" dur="0.6s" keyTimes="0;0.5;1" repeatCount="indefinite" values="1;1;0"></animate></circle></svg>',1)]))):x("",!0)]),e("div",Xe,[e("table",qe,[d(je,null,{default:b(()=>[d(Ue,null,{default:b(()=>[d(N,{position:"first"},{default:b(()=>[M(i(p.$t("Title")),1)]),_:1}),d(N,null,{default:b(()=>[M(i(p.$t("Source")),1)]),_:1}),d(N,null,{default:b(()=>[M(i(p.$t("Status")),1)]),_:1}),d(N,null,{default:b(()=>[M(i(p.$t("Last updated")),1)]),_:1}),d(N,{position:"last"})]),_:1})]),_:1}),d(ze,null,{default:b(()=>[(n(!0),u(K,null,Ae(V.rows.data,(l,a)=>(n(),E(Oe,{key:a,class:f(h(a)?"":"border-b")},{default:b(()=>[d(U,{position:"first",class:"capitalize"},{default:b(()=>[M(i(l.title),1)]),_:2},1024),d(U,{class:"hidden sm:table-cell"},{default:b(()=>[M(i(l.source),1)]),_:2},1024),d(U,{class:"hidden sm:table-cell"},{default:b(()=>[M(i(p.$t(D(l.status))),1)]),_:2},1024),d(U,{class:"hidden sm:table-cell"},{default:b(()=>[M(i(l.updated_at),1)]),_:2},1024),d(U,{position:"last"},{default:b(()=>[d(Le,{align:"right",class:"mt-2"},{default:b(()=>[e("button",{onClick:w=>s(S)(l.uuid),class:"inline-flex w-full justify-center rounded-md text-sm font-medium text-black hover:bg-opacity-30 focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75"},m[7]||(m[7]=[e("span",{class:"hover:bg-[#F6F7F9] hover:rounded-full w-[fit-content] p-2"},[e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},[e("path",{fill:"currentColor",d:"M16 9v10H8V9zm-1.5-6h-5l-1 1H5v2h14V4h-3.5zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2z"})])],-1)]),8,We)]),_:2},1024)]),_:2},1024)]),_:2},1032,["class"]))),128))]),_:1})])]),d(De,{modelValue:s(c),"onUpdate:modelValue":m[2]||(m[2]=l=>Se(c)?c.value=l:null),onConfirm:m[3]||(m[3]=()=>s(k)(_)),label:p.$t("Delete row"),description:p.$t("Are you sure you want to delete this row? This action can not be undone")},null,8,["modelValue","label","description"])],64))}},Je={class:"block text-sm leading-6 text-gray-900 mt-4 mb-1"},Qe={class:"max-w-md w-full gap-y-8"},Ye={class:"space-y-6"},et={for:"file-upload",class:"text-center cursor-pointer"},tt={class:"flex text-sm text-gray-600"},st={class:"relative bg-white rounded-md"},ot={class:"pl-1"},lt={class:"text-xs text-gray-500"},at={class:"text-xs text-gray-500"},it={class:"rounded-md p-1 bg-slate-50 text-center text-sm flex items-center gap-x-1"},rt={key:0,class:"form-error text-[#b91c1c] text-xs"},nt={class:"mt-5"},dt={class:"flex justify-center mt-2 w-full"},ut={key:0,class:"w-full inline-flex justify-center rounded-md border border-transparent bg-primary px-4 py-2 text-sm text-white hover:bg-green-800 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2"},ct={__name:"DocumentUploadModal",props:["type","modelValue"],emits:["update:modelValue"],setup(V,{emit:Z}){const A=V,c=Z;Te(()=>Be().props.flash.status);const S=ye("Upload Document"),k=C(A.modelValue),$=C(null),_=C($.value),h=C(null),o=O({title:null,file:null});$e(()=>A.modelValue,l=>{k.value=l});const v=l=>{l.preventDefault();const a=l.target.files[0];T(a)},B=l=>{l.preventDefault();const a=l.dataTransfer.files[0];T(a)};function T(l){if(!["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/plain"].includes(l.type)){alert(ye("please select a PDF, Word, or TXT file"));return}$.value=l.name,_.value=F($.value,28),o.file=l}const F=(l,a)=>{if(l.length<=a)return l;const w=Math.floor(a/2),z=l.slice(0,w),L=l.slice(-w);return`${z}...${L}`};function D(){o.file=null}function p(){const l=new FormData;l.append("title",o.title),l.append("file",o.file),o.post("/automation/upload/document",{preserveScroll:!0,onProgress:a=>{h.value="pending"},onSuccess:()=>{o.reset(),h.value="complete",m()},onError:a=>{h.value=null}})}function m(){k.value=!1,c("update:modelValue",!1),setTimeout(()=>{h.value=null,o.reset(),o.clearErrors()},500)}return(l,a)=>(n(),E(Ce,{label:s(S),isOpen:k.value,closeBtn:!0,onClose:a[5]||(a[5]=w=>m())},{default:b(()=>[d(H,{modelValue:s(o).title,"onUpdate:modelValue":a[0]||(a[0]=w=>s(o).title=w),error:s(o).errors.title,name:"Title",type:"text",class:f("mt-4")},null,8,["modelValue","error"]),e("div",Je,i(l.$t("Document (PDF, word or TXT file)")),1),e("div",Qe,[e("div",Ye,[s(o).file==null?(n(),u("div",{key:0,onDragover:a[2]||(a[2]=j(()=>{},["prevent"])),onDrop:B,class:f(["flex justify-center px-6 pt-5 pb-6 shadow-sm outline-none ring-1 ring-inset rounded-md",s(o).errors.file?"ring-[#b91c1c]":"ring-gray-300"])},[e("input",{type:"file",class:"sr-only",accept:".pdf,.txt,.doc,.docx",ref:"fileInput",id:"file-upload",onChange:a[1]||(a[1]=w=>v(w))},null,544),e("label",et,[e("div",null,[a[7]||(a[7]=e("svg",{class:"mx-auto h-12 w-12 text-gray-400",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},[e("g",{fill:"none"},[e("path",{fill:"currentColor",d:"m15.393 4.054l-.502.557l.502-.557Zm3.959 3.563l-.502.557l.502-.557Zm2.302 2.537l-.685.305l.685-.305ZM3.172 20.828l.53-.53l-.53.53Zm17.656 0l-.53-.53l.53.53ZM14 21.25h-4v1.5h4v-1.5ZM2.75 14v-4h-1.5v4h2.5Zm18.5-.437V14h2.5v-.437h-1.5ZM14.891 4.61l3.959 3.563l1.003-1.115l-3.958-3.563l-1.004 1.115Zm7.859 8.952c0-1.689.015-2.758-.41-3.714l-1.371.61c.266.598.281 1.283.281 3.104h2.5Zm-3.9-5.389c1.353 1.218 1.853 1.688 2.119 2.285l1.37-.61c-.426-.957-1.23-1.66-2.486-2.79L18.85 8.174ZM10.03 2.75c1.582 0 2.179.012 2.71.216l.538-1.4c-.852-.328-1.78-.316-3.248-.316v1.5Zm5.865.746c-1.086-.977-1.765-1.604-2.617-1.93l-.537 1.4c.532.204.98.592 2.15 1.645l1.004-1.115ZM10 21.25c-1.907 0-3.261-.002-4.29-.14c-1.005-.135-1.585-.389-2.008-.812l-1.06 1.06c.748.75 1.697 1.081 2.869 1.239c1.15.155 2.625.153 4.489.153v-1.5ZM1.25 14c0 1.864-.002 3.338.153 4.489c.158 1.172.49 2.121 1.238 2.87l1.06-1.06c-.422-.424-.676-1.004-.811-2.01c-.138-1.027-.14-2.382-.14-4.289h-1.5ZM14 22.75c1.864 0 3.338.002 4.489-.153c1.172-.158 2.121-.49 2.87-1.238l-1.06-1.06c-.424.422-1.004.676-2.01.811c-1.027.138-2.382.14-4.289.14v1.5ZM21.25 14c0 1.907-.002 3.262-.14 4.29c-.135 1.005-.389 1.585-.812 2.008l1.06 1.06c.75-.748 1.081-1.697 1.239-2.869c.155-1.15.153-2.625.153-4.489h-1.5Zm-18.5-4c0-1.907.002-3.261.14-4.29c.135-1.005.389-1.585.812-2.008l-1.06-1.06c-.75.748-1.081 1.697-1.239 2.869C1.248 6.661 1.25 8.136 1.25 10h2.5Zm7.28-8.75c-1.875 0-3.356-.002-4.511.153c-1.177.158-2.129.49-2.878 1.238l1.06 1.06c.424-.422 1.005-.676 2.017-.811c1.033-.138 2.395-.14 4.312-.14v-1.5Z"}),e("path",{stroke:"currentColor","stroke-width":"1.5",d:"M13 2.5V5c0 2.357 0 3.536.732 4.268C14.464 10 15.643 10 18 10h4"})])],-1)),e("div",tt,[e("div",st,[e("span",null,i(l.$t("Click to upload a file")),1)]),e("p",ot,i(l.$t("Or drag and drop")),1)]),e("p",lt,i(l.$t("PDF, Word or TXT files only")),1),e("p",at,[M(i(l.$t("Maximum size"))+" ",1),a[6]||(a[6]=e("b",null,"20MB",-1))])])])],34)):(n(),u("div",{key:1,class:f(["flex justify-center px-6 pt-5 pb-6 shadow-sm outline-none ring-1 ring-inset rounded-md",s(o).errors.file?"ring-[#b91c1c]":"ring-gray-300"])},[e("div",null,[a[9]||(a[9]=e("svg",{class:"mx-auto h-12 w-12 text-gray-400",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},[e("g",{fill:"none"},[e("path",{fill:"currentColor",d:"m15.393 4.054l-.502.557l.502-.557Zm3.959 3.563l-.502.557l.502-.557Zm2.302 2.537l-.685.305l.685-.305ZM3.172 20.828l.53-.53l-.53.53Zm17.656 0l-.53-.53l.53.53ZM14 21.25h-4v1.5h4v-1.5ZM2.75 14v-4h-1.5v4h2.5Zm18.5-.437V14h2.5v-.437h-1.5ZM14.891 4.61l3.959 3.563l1.003-1.115l-3.958-3.563l-1.004 1.115Zm7.859 8.952c0-1.689.015-2.758-.41-3.714l-1.371.61c.266.598.281 1.283.281 3.104h2.5Zm-3.9-5.389c1.353 1.218 1.853 1.688 2.119 2.285l1.37-.61c-.426-.957-1.23-1.66-2.486-2.79L18.85 8.174ZM10.03 2.75c1.582 0 2.179.012 2.71.216l.538-1.4c-.852-.328-1.78-.316-3.248-.316v1.5Zm5.865.746c-1.086-.977-1.765-1.604-2.617-1.93l-.537 1.4c.532.204.98.592 2.15 1.645l1.004-1.115ZM10 21.25c-1.907 0-3.261-.002-4.29-.14c-1.005-.135-1.585-.389-2.008-.812l-1.06 1.06c.748.75 1.697 1.081 2.869 1.239c1.15.155 2.625.153 4.489.153v-1.5ZM1.25 14c0 1.864-.002 3.338.153 4.489c.158 1.172.49 2.121 1.238 2.87l1.06-1.06c-.422-.424-.676-1.004-.811-2.01c-.138-1.027-.14-2.382-.14-4.289h-1.5ZM14 22.75c1.864 0 3.338.002 4.489-.153c1.172-.158 2.121-.49 2.87-1.238l-1.06-1.06c-.424.422-1.004.676-2.01.811c-1.027.138-2.382.14-4.289.14v1.5ZM21.25 14c0 1.907-.002 3.262-.14 4.29c-.135 1.005-.389 1.585-.812 2.008l1.06 1.06c.75-.748 1.081-1.697 1.239-2.869c.155-1.15.153-2.625.153-4.489h-1.5Zm-18.5-4c0-1.907.002-3.261.14-4.29c.135-1.005.389-1.585.812-2.008l-1.06-1.06c-.75.748-1.081 1.697-1.239 2.869C1.248 6.661 1.25 8.136 1.25 10h2.5Zm7.28-8.75c-1.875 0-3.356-.002-4.511.153c-1.177.158-2.129.49-2.878 1.238l1.06 1.06c.424-.422 1.005-.676 2.017-.811c1.033-.138 2.395-.14 4.312-.14v-1.5Z"}),e("path",{stroke:"currentColor","stroke-width":"1.5",d:"M13 2.5V5c0 2.357 0 3.536.732 4.268C14.464 10 15.643 10 18 10h4"})])],-1)),e("div",it,[e("span",null,i(_.value),1),e("span",{onClick:a[3]||(a[3]=w=>D()),class:"bg-slate-200 rounded-full cursor-pointer"},a[8]||(a[8]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 20 20"},[e("g",{fill:"black"},[e("path",{d:"M6.854 13.854a.5.5 0 0 1-.708-.708l7-7a.5.5 0 0 1 .708.708z"}),e("path",{d:"M6.146 6.854a.5.5 0 1 1 .708-.708l7 7a.5.5 0 0 1-.708.708z"})])],-1)]))])])],2))]),s(o).errors.file?(n(),u("span",rt,i(s(o).errors.file),1)):x("",!0)]),e("div",nt,[e("div",dt,[s(o).processing?(n(),u("div",ut,a[10]||(a[10]=[e("svg",{class:"mx-auto text-white",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24"},[e("path",{fill:"none",stroke:"white","stroke-dasharray":"15","stroke-dashoffset":"15","stroke-linecap":"round","stroke-width":"2",d:"M12 3C16.9706 3 21 7.02944 21 12"},[e("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"0.3s",values:"15;0"}),e("animateTransform",{attributeName:"transform",dur:"1.5s",repeatCount:"indefinite",type:"rotate",values:"0 12 12;360 12 12"})])],-1)]))):(n(),u("button",{key:1,type:"button",onClick:a[4]||(a[4]=w=>p()),class:"w-full inline-flex justify-center rounded-md border border-transparent bg-primary px-4 py-2 text-sm text-white hover:bg-green-800 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2"},i(l.$t("Upload")),1))])])]),_:1},8,["label","isOpen"]))}},mt={class:"md:h-[90vh]"},pt={class:"flex justify-center items-center"},ft={class:"md:w-[60em]"},vt={class:"bg-white border border-slate-200 rounded-lg pt-2 text-sm mb-4 px-4 mb-20"},bt={class:"w-full py-2 mb-4 mt-2"},gt={class:"flex w-full"},ht={class:"text-md"},wt={class:"text-[16px]"},_t={class:"mb-1 text-slate-500"},yt={class:"ml-auto"},xt={class:"flex items-center gap-x-3"},kt={key:2},$t={class:"flex items-center justify-between px-4 pt-2 pb-4"},Ct={class:"text-[16px]"},Vt={class:"text-slate-500"},Mt={class:"w-[10%]"},Zt={key:0,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},At={key:1,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},St={key:0},Tt={class:"flex space-x-10 border-b w-full px-4 py-6"},Bt={class:"w-[70%]"},Ft={class:"text-slate-600"},It={class:"text-xs text-slate-700 flex items-center"},Dt={class:"w-[30%]"},Nt={class:"flex space-x-10 border-b w-full px-4 py-6"},Ut={class:"w-[40%]"},jt={class:"text-slate-600"},Ot={class:"text-xs text-slate-700 flex items-center"},zt={class:"w-[60%]"},Lt={class:"flex space-x-10 border-b w-full px-4 py-6"},Et={class:"w-[40%]"},Pt={class:"text-slate-600"},Kt={class:"text-xs text-slate-700 flex items-center"},Ht={class:"w-[60%]"},Rt={class:"flex px-4 pt-1"},Xt={class:"ml-auto mt-2"},qt=["disabled"],Wt={key:0,xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24"},Gt={key:1},Jt={key:1,class:"bg-white border border-slate-200 rounded-lg py-2 text-sm mb-20 pb-4 px-4"},Qt={class:"w-full py-2 mb-4 mt-2"},Yt={class:"flex w-full mb-4"},es={class:"text-md w-[70%]"},ts={class:"text-[16px]"},ss={class:"flex items-center mt-1 text-slate-500"},os={class:"ml-auto w-[40%]"},ls={class:"float-right flex items-center gap-x-2"},as={class:"w-5/5"},is={class:"px-4 pb-4"},rs={class:"mt-5 grid grid-cols-1 gap-x-6 gap-y-4"},ns={class:"sm:col-span-6 border rounded-md p-2"},ds={class:f("sm:col-span-6")},us={class:"block text-sm leading-6 text-gray-900 mb-1"},cs={class:"sm:col-span-6 border rounded-md p-2"},ms={class:"flex sm:col-span-6 grid grid-cols-6"},ps={class:f("sm:col-span-3")},fs={class:"block text-sm leading-6 text-gray-900 mb-1"},vs={class:"sm:col-span-6 bg-[#ffe5b4] rounded-md px-3 py-1 mt-2"},bs={class:"block text-xs leading-6 text-gray-900"},gs={class:"mt-4 flex"},hs=["disabled"],ws={key:0,xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24"},_s={key:1},ao={__name:"Index",props:["appSettings","rows","filters","settings","aimodule","fbmodule","models","voices"],setup(V){var l,a,w,z,L,R,X,q,W,G,J,Q,Y,ee,te,se,oe,le,ae,ie,re,ne,de,ue;const Z=V,A=C(Z.settings.metadata),c=C(A.value?JSON.parse(A.value):null),S=C(!1),k=C(!1),$=C(!1),_=r=>{const t=Z.appSettings.find(I=>I.key===r);return t?t.value:""},h=O({active:((a=(l=c.value)==null?void 0:l.ai)==null?void 0:a.active)??!1}),o=O({active:((z=(w=c.value)==null?void 0:w.ai)==null?void 0:z.active)??!1,api_key:((R=(L=c.value)==null?void 0:L.ai)==null?void 0:R.api_key)??null,model:((q=(X=c.value)==null?void 0:X.ai)==null?void 0:q.model)??null,voice:((G=(W=c.value)==null?void 0:W.ai)==null?void 0:G.voice)??null,allow_audio_response:((Q=(J=c.value)==null?void 0:J.ai)==null?void 0:Q.allow_audio_response)??null,max_tokens:((ee=(Y=c.value)==null?void 0:Y.ai)==null?void 0:ee.max_tokens)??null,temperature:((se=(te=c.value)==null?void 0:te.ai)==null?void 0:se.temperature)??null,ai_chat_form_active:((le=(oe=c.value)==null?void 0:oe.ai)==null?void 0:le.ai_chat_form_active)??!1}),v=O({enable_automatic_responses:((ie=(ae=c.value)==null?void 0:ae.ai)==null?void 0:ie.enable_automatic_responses)??!1,start_keywords:((ne=(re=c.value)==null?void 0:re.ai)==null?void 0:ne.start_keywords)??null,stop_keywords:((ue=(de=c.value)==null?void 0:de.ai)==null?void 0:ue.stop_keywords)??null}),B=()=>{$.value=!$.value},T=()=>{h.active=!h.active,D()},F=()=>{v.enable_automatic_responses=!v.enable_automatic_responses},D=async()=>{h.post("/automation/ai/activate",{preserveScroll:!0})},p=()=>{o.post("/automation/ai/setup",{preserveScroll:!0,onSuccess:()=>{P.visit("/automation/ai",{preserveState:!1})}})},m=()=>{v.post("/automation/ai/assistant-setup",{preserveScroll:!0,onSuccess:()=>{P.visit("/automation/ai",{preserveState:!1})}})};return $e(()=>o.model,r=>{r!=="gpt-4o-audio-preview"&&(o.allow_audio_response=!1)}),(r,t)=>(n(),u(K,null,[d(Fe,{aimodule:V.aimodule,fbmodule:V.fbmodule},{default:b(()=>{var I,ce,me,pe,fe,ve,be,ge,he,we;return[e("div",mt,[e("div",pt,[e("div",ft,[e("div",vt,[e("div",bt,[e("div",gt,[e("div",ht,[e("h4",wt,i(r.$t("Enable AI Assistant")),1),e("div",_t,i(r.$t("Activate AI-generated responses in your conversations")),1)]),e("div",yt,[e("div",xt,[((ce=(I=c.value)==null?void 0:I.ai)==null?void 0:ce.api_key)!=null||_("enable_api_key_input")!=1?(n(),u("div",{key:0,class:f(["w-12 h-6 flex items-center bg-gray-300 rounded-full p-1",{"bg-primary":s(h).active}]),onClick:t[0]||(t[0]=g=>T(r.active))},[e("div",{class:f(["bg-white w-4 h-4 rounded-full shadow-md transform duration-300 ease-in-out",{"translate-x-6":s(h).active}])},null,2)],2)):(n(),u("div",{key:1,class:f(["w-12 h-6 flex items-center bg-gray-300 rounded-full p-1",{"bg-primary":s(o).active}]),onClick:t[1]||(t[1]=g=>{s(o).active=!0,k.value=!0})},[e("div",{class:f(["bg-white w-4 h-4 rounded-full shadow-md transform duration-300 ease-in-out",{"translate-x-6":s(o).active}])},null,2)],2)),((pe=(me=c.value)==null?void 0:me.ai)==null?void 0:pe.api_key)!=null||_("enable_api_key_input")!=1?(n(),u("div",kt," | ")):x("",!0),((ve=(fe=c.value)==null?void 0:fe.ai)==null?void 0:ve.api_key)!=null||_("enable_api_key_input")!=1?(n(),u("button",{key:3,onClick:t[2]||(t[2]=g=>k.value=!0),class:"bg-primary text-white h-8 rounded-lg text-[13px] px-3 w-fit"},i(r.$t("Update")),1)):x("",!0)])])])])]),((ge=(be=c.value)==null?void 0:be.ai)==null?void 0:ge.api_key)!=null||_("enable_api_key_input")!=1?(n(),u("form",{key:0,onSubmit:t[8]||(t[8]=j(g=>m(),["prevent"])),class:"bg-white border border-slate-200 rounded-lg py-2 text-sm mb-4 pb-4"},[e("div",$t,[e("div",{onClick:t[3]||(t[3]=g=>B()),class:"w-[90%] cursor-pointer"},[e("h4",Ct,i(r.$t("AI Assistant Setup")),1),e("div",Vt,i(r.$t("Setup keywords for AI assistance")),1)]),e("div",Mt,[e("button",{type:"button",onClick:t[4]||(t[4]=g=>B()),class:"hover:bg-slate-50 rounded-full p-1 float-right"},[$.value?(n(),u("svg",Zt,t[19]||(t[19]=[e("path",{fill:"black","fill-rule":"evenodd",d:"M16.53 14.03a.75.75 0 0 1-1.06 0L12 10.56l-3.47 3.47a.75.75 0 0 1-1.06-1.06l4-4a.75.75 0 0 1 1.06 0l4 4a.75.75 0 0 1 0 1.06","clip-rule":"evenodd"},null,-1)]))):x("",!0),$.value?x("",!0):(n(),u("svg",At,t[20]||(t[20]=[e("path",{fill:"black","fill-rule":"evenodd",d:"M16.53 8.97a.75.75 0 0 1 0 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 1 1 1.06-1.06L12 12.44l3.47-3.47a.75.75 0 0 1 1.06 0","clip-rule":"evenodd"},null,-1)])))])])]),$.value?(n(),u("div",St,[e("div",Tt,[e("div",Bt,[e("span",Ft,i(r.$t("Enable automatic AI assistance for new conversations")),1),e("div",It,[e("span",null,i(r.$t("Turn on this option to let users automatically get help from the AI whenever they start a new conversation or ticket. If enabled, this will override the keywords set for initiating AI chat.")),1)])]),e("div",Dt,[e("div",{class:f(["ml-auto w-12 h-6 flex items-center bg-gray-300 rounded-full p-1",{"bg-primary":s(v).enable_automatic_responses}]),onClick:t[5]||(t[5]=g=>F())},[e("div",{class:f(["bg-white w-4 h-4 rounded-full shadow-md transform duration-300 ease-in-out",{"translate-x-6":s(v).enable_automatic_responses}])},null,2)],2)])]),e("div",Nt,[e("div",Ut,[e("span",jt,i(r.$t("Keyword(s) to start the AI agent")),1),e("div",Ot,[e("span",null,i(r.$t("Set word or phrase")),1)])]),e("div",zt,[d(H,{modelValue:s(v).start_keywords,"onUpdate:modelValue":t[6]||(t[6]=g=>s(v).start_keywords=g),error:s(v).errors.start_keywords,name:"",type:"text",class:f("col-span-4")},null,8,["modelValue","error"])])]),e("div",Lt,[e("div",Et,[e("span",Pt,i(r.$t("Keyword(s) to stop the AI agent")),1),e("div",Kt,[e("span",null,i(r.$t("Set word or phrase")),1)])]),e("div",Ht,[d(Ee,{modelValue:s(v).stop_keywords,"onUpdate:modelValue":t[7]||(t[7]=g=>s(v).stop_keywords=g),error:s(v).errors.stop_keywords,name:"",type:"text",class:f("col-span-4")},null,8,["modelValue","error"])])]),e("div",Rt,[e("div",Xt,[e("button",{type:"submit",class:"float-right bg-primary text-white h-8 rounded-lg text-[13px] px-3 w-fit",disabled:s(v).processing},[s(v).processing?(n(),u("svg",Wt,t[21]||(t[21]=[e("path",{fill:"currentColor",d:"M12 2A10 10 0 1 0 22 12A10 10 0 0 0 12 2Zm0 18a8 8 0 1 1 8-8A8 8 0 0 1 12 20Z",opacity:".5"},null,-1),e("path",{fill:"currentColor",d:"M20 12h2A10 10 0 0 0 12 2V4A8 8 0 0 1 20 12Z"},[e("animateTransform",{attributeName:"transform",dur:"1s",from:"0 12 12",repeatCount:"indefinite",to:"360 12 12",type:"rotate"})],-1)]))):(n(),u("span",Gt,i(r.$t("Save")),1))],8,qt)])])])):x("",!0)],32)):x("",!0),((we=(he=c.value)==null?void 0:he.ai)==null?void 0:we.api_key)!=null||_("enable_api_key_input")!=1?(n(),u("div",Jt,[e("div",Qt,[e("div",Yt,[e("div",es,[e("h4",ts,i(r.$t("Knowledge Base")),1),e("span",ss,i(r.$t("Enhance your AI assistant by uploading information to improve client interactions.")),1)]),e("div",os,[e("div",ls,[e("button",{onClick:t[9]||(t[9]=g=>S.value=!0),class:"rounded-md bg-primary px-3 h-8 text-[13px] text-white shadow-sm hover:bg-black focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"},i(r.$t("Upload Documents")),1)])])]),e("div",as,[d(Ge,{rows:Z.rows,filters:Z.filters},null,8,["rows","filters"]),e("div",is,[d(Pe,{class:"mt-3",pagination:Z.rows.meta},null,8,["pagination"])])])])])):x("",!0)])])]),d(Ce,{label:r.$t("AI Assistant Setup"),isOpen:k.value},{default:b(()=>{var g,_e;return[e("div",rs,[e("form",{onSubmit:t[17]||(t[17]=j(y=>p(),["prevent"])),class:"grid gap-x-6 gap-y-4 sm:grid-cols-6"},[_("enable_api_key_input")==1?(n(),E(H,{key:0,modelValue:s(o).api_key,"onUpdate:modelValue":t[10]||(t[10]=y=>s(o).api_key=y),error:s(o).errors.api_key,name:r.$t("OpenAI API Key"),type:"password",class:f("sm:col-span-6")},null,8,["modelValue","error","name"])):x("",!0),_("enable_model_selection")==1?(n(),E(xe,{key:1,modelValue:s(o).model,"onUpdate:modelValue":t[11]||(t[11]=y=>s(o).model=y),error:s(o).errors.model,name:r.$t("Model"),type:"text",options:V.models,class:f("sm:col-span-6")},null,8,["modelValue","error","name","options"])):x("",!0),e("div",ns,[e("div",ds,[e("label",us,i(r.$t("Integrate AI assistant into chat form")),1),d(ke,{modelValue:s(o).ai_chat_form_active,"onUpdate:modelValue":t[12]||(t[12]=y=>s(o).ai_chat_form_active=y),error:s(o).errors.ai_chat_form_active,class:f("sm:col-span-6")},null,8,["modelValue","error"])])]),e("div",cs,[e("div",ms,[e("div",ps,[e("label",fs,i(r.$t("Activate audio responses")),1),d(ke,{modelValue:s(o).allow_audio_response,"onUpdate:modelValue":t[13]||(t[13]=y=>s(o).allow_audio_response=y),error:s(o).errors.allow_audio_response,class:f("sm:col-span-6")},null,8,["modelValue","error"])]),d(xe,{modelValue:s(o).voice,"onUpdate:modelValue":t[14]||(t[14]=y=>s(o).voice=y),error:s(o).errors.voice,name:r.$t("Audio voice"),type:"text",options:V.voices,class:f("sm:col-span-3")},null,8,["modelValue","error","name","options"])]),e("div",vs,[e("span",bs,i(r.$t("Audio responses require the gpt-4o-audio-preview model.")),1)])]),e("div",gs,[((_e=(g=c.value)==null?void 0:g.ai)==null?void 0:_e.api_key)==null?(n(),u("button",{key:0,type:"button",onClick:t[15]||(t[15]=j(y=>{k.value=!1,s(o).active=!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"},i(r.$t("Cancel")),1)):(n(),u("button",{key:1,type:"button",onClick:t[16]||(t[16]=j(y=>k.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"},i(r.$t("Cancel")),1)),e("button",{class:f(["inline-flex justify-center rounded-md border border-transparent bg-primary px-4 py-2 text-sm text-white focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2",{"opacity-50":s(h).processing}]),disabled:s(o).processing},[s(o).processing?(n(),u("svg",ws,t[22]||(t[22]=[e("path",{fill:"currentColor",d:"M12 2A10 10 0 1 0 22 12A10 10 0 0 0 12 2Zm0 18a8 8 0 1 1 8-8A8 8 0 0 1 12 20Z",opacity:".5"},null,-1),e("path",{fill:"currentColor",d:"M20 12h2A10 10 0 0 0 12 2V4A8 8 0 0 1 20 12Z"},[e("animateTransform",{attributeName:"transform",dur:"1s",from:"0 12 12",repeatCount:"indefinite",to:"360 12 12",type:"rotate"})],-1)]))):(n(),u("span",_s,i(r.$t("Save")),1))],10,hs)])],32)])]}),_:1},8,["label","isOpen"])]}),_:1},8,["aimodule","fbmodule"]),d(ct,{type:"contact",modelValue:S.value,"onUpdate:modelValue":t[18]||(t[18]=I=>S.value=I)},null,8,["modelValue"])],64))}};export{ao as default};