import{j as n,aM as k,S as I}from"./vendor-mui-CBBEb17G.js";import{a as c}from"./vendor-react-BBazpZul.js";import{I as l,r as E,aP as x,bE as j,b3 as w,J as R}from"./index-IP_FWtso.js";import{c as C,a as D}from"./columnTypeItems-CulcDcPL.js";import{b as i,c as S,a as N,d as F}from"./index-5ex8CyJt.js";const A=({child:a,onChange:b,haveChilds:f=!1})=>{var m,t;const[e,s]=c.useState(null),[h,u]=c.useState(null),v=!!h,T=r=>{u(r.currentTarget)},p=()=>{e&&b(e),u(null)},y=r=>{if(!e||r<0||(e.children.length??0)===r)return;const o={...e};if(e.children.length<r){for(let d=0;d<r-e.children.length;d++)o.children.push({uuId:w(),columnType:i.PatientGroup,width:0});s(o)}else{for(let d=0;d<e.children.length-r;d++)o.children.pop();s(o)}};c.useEffect(()=>{a&&s(a)},[a]);const g=f?[{label:S[i.Text],value:i.Text},...C]:C;return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center justify-center px-1",children:[n.jsx("div",{className:"mx-auto",children:a.columnType===i.Text?n.jsx("div",{className:"mx-auto",children:a.text??""}):n.jsx("div",{className:"mx-auto",children:S[a.columnType]})}),n.jsx("div",{className:"mr-auto cursor-pointer",onClick:r=>T(r),children:n.jsx(l.Settings,{})})]}),n.jsx(k,{open:v,anchorEl:h,onClose:p,anchorOrigin:{vertical:"bottom",horizontal:"left"},children:n.jsxs(I,{spacing:2,p:2,children:[n.jsxs("div",{className:"flex items-center pb-1  border-b",children:[n.jsxs("div",{className:"flex items-center gap-1 text-xs text-slate-600",children:[n.jsx(l.Settings,{}),n.jsx("span",{children:"تنظیمات"})]}),n.jsx("div",{className:"mr-auto cursor-pointer hover:text-red-500 hover:bg-slate-100 hover:rounded-full",onClick:()=>p(),children:n.jsx(l.CloseIcon,{})})]}),n.jsx(E,{items:g,label:"نوع ستون",value:(m=e==null?void 0:e.columnType)==null?void 0:m.toString(),onchange:r=>s(o=>({...o,columnType:+r}))}),(e==null?void 0:e.columnType)===i.Text&&n.jsx(x,{label:"عنوان ستون",value:e==null?void 0:e.text,onChange:r=>s(o=>({...o,text:r}))}),f&&n.jsx(j,{label:"تعداد زیر ستون",value:((t=e==null?void 0:e.children)==null?void 0:t.length)??0,onChange:r=>y(r)}),n.jsx(j,{label:"عرض ستون",value:e==null?void 0:e.width,onChange:r=>s(o=>({...o,width:r}))}),n.jsx(x,{label:"رنگ پس زمینه",value:(e==null?void 0:e.backgroundColor)??"#475569",onChange:r=>s(o=>({...o,backgroundColor:r})),type:"color"}),n.jsx(x,{label:"رنگ متن",value:(e==null?void 0:e.color)??"#ffffff",onChange:r=>s(o=>({...o,color:r})),type:"color"})]})})]})},B=({column:a,onChange:b,onDelete:f})=>{var g,m;const[e,s]=c.useState(null),[h,u]=c.useState(null),v=!!h,T=t=>{u(t.currentTarget)},p=()=>{if((e==null?void 0:e.columnType)===N.Text&&!e.text){R.warning("عنوان ستون را وارد نمایید");return}e&&b(e),u(null)},y=t=>{if(!e||t<0||(e.children.length??0)===t)return;const r={...e};if(e.children.length<t){for(let o=0;o<t-e.children.length;o++)r.children.push({uuId:w(),columnType:i.PatientGroup,width:0,children:[]});s(r)}else{for(let o=0;o<e.children.length-t;o++)r.children.pop();s(r)}};return c.useEffect(()=>{a&&s(a)},[]),n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center justify-center gap-1 px-1",children:[a.columnType===N.Text?n.jsx("div",{className:"mx-auto",children:a.text??""}):n.jsx("div",{className:"mx-auto",children:F[a.columnType]}),n.jsx("div",{className:"mr-auto cursor-pointer",onClick:t=>{s(a),T(t)},children:n.jsx(l.Settings,{})}),n.jsx("div",{className:"cursor-pointer",onClick:()=>f(a.uuId),children:n.jsx(l.CloseIcon,{})})]}),n.jsx(k,{open:v,anchorEl:h,onClose:p,anchorOrigin:{vertical:"bottom",horizontal:"left"},children:n.jsxs(I,{spacing:2,p:2,children:[n.jsxs("div",{className:"flex items-center pb-1  border-b",children:[n.jsxs("div",{className:"flex items-center gap-1 text-xs text-slate-600",children:[n.jsx(l.Settings,{}),n.jsx("span",{children:"تنظیمات"})]}),n.jsx("div",{className:"mr-auto cursor-pointer hover:text-red-500 hover:bg-slate-100 hover:rounded-full",onClick:()=>p(),children:n.jsx(l.CloseIcon,{})})]}),n.jsx(E,{items:D,label:"نوع ستون",value:(g=e==null?void 0:e.columnType)==null?void 0:g.toString(),onchange:t=>s(r=>({...r,columnType:+t}))}),(e==null?void 0:e.columnType)===N.Text&&n.jsx(x,{label:"عنوان ستون",value:e==null?void 0:e.text,onChange:t=>s(r=>({...r,text:t}))}),n.jsx(j,{label:"تعداد زیر ستون",value:((m=e==null?void 0:e.children)==null?void 0:m.length)??0,onChange:t=>y(t)}),n.jsx(j,{label:"عرض ستون",value:e==null?void 0:e.width,onChange:t=>s(r=>({...r,width:t}))}),n.jsx(x,{label:"رنگ پس زمینه",value:(e==null?void 0:e.backgroundColor)??"#3b6df6",onChange:t=>s(r=>({...r,backgroundColor:t})),type:"color"}),n.jsx(x,{label:"رنگ متن",value:(e==null?void 0:e.color)??"#ffffff",onChange:t=>s(r=>({...r,color:t})),type:"color"})]})})]})};export{B as C,A as a};
