import{d as f,a as g,b as D,n_ as v,r as S,j as e,I as A,aI as F,R as c,n$ as C,o0 as p,o1 as w}from"./index-3141de2d.js";import{c as E,b as $,u as k}from"./index.esm-8b0c9a99.js";import{o as q}from"./yup-c2fea6fa.js";import"./GenericThumbnailView-c2621934.js";import{F as B}from"./FormInput-abff9e70.js";import"./componentStyles-24f97919.js";import"./ScrollableList-fa62971d.js";import"./TextArea-ceaff311.js";import{D as L,a as P}from"./DialogContent-17781b67.js";import{D as R}from"./DialogTitle-16416764.js";import{D as T}from"./DialogContentText-c64ca110.js";import{D as U}from"./DialogActions-37bf04e2.js";const M=({modal:i,closeModal:o,mastersName:u,edit_Id:a,mastersValue:z})=>{const n=f(),{document:{selectedData:t,pageParams:l},system:{userAccessList:N}}=g(r=>({system:D(r),document:v(r)})),d=E().shape({name:$().required("Please enter document name").trim().matches(/^[a-zA-Z0-9 ]*$/,"document name should not contain special characters")});S.useEffect(()=>{i?s({name:(t==null?void 0:t.name)||""}):s()},[i,t]);const{control:h,handleSubmit:x,reset:s}=k({resolver:q(d),values:{name:t!=null&&t.name?t==null?void 0:t.name:""}}),b=r=>{if(a==null||a==0){const m={obj:{name:r.name},pageParams:l,clearDataFn:()=>{},navigate:y=>{}};n(C(m)),o(),n(p({})),s()}else{const m={obj:{id:a,name:r.name},pageParams:l,clearDataFn:()=>{},navigate:y=>{}};n(w(m)),n(p({})),o(),s()}};return e.jsx(e.Fragment,{children:e.jsxs(L,{open:i,onClose:o,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(R,{sx:{bgcolor:"primary.main",color:"white",p:1,px:2,display:"flex",alignItems:"center",justifyContent:"space-between"},variant:"h4",id:"alert-dialog-title",children:[a==null||a==0?"Add ":"Update ",u,e.jsx(A,{onClick:o,children:e.jsx(F,{color:"white"})})]}),e.jsx(P,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(T,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:x(b),children:[e.jsx(B,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter Document here...",control:h}),e.jsxs(U,{sx:{p:2},children:[e.jsx(c,{onClick:o,variant:"outlined",color:"secondary",children:"Cancel"}),a==null||a==0?e.jsx(c,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Submit"}):e.jsx(c,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Update"})]})]})})})]})})};export{M as A};
