import{a as v,z as Wt,E as ct,F as Ze,G as Ht,q as O,n as kt,o as wt,p as Dt,_ as we,j as r,s as Se,H as ot,v as Nt,w as K,P as zt,J as Mt,K as Vt,L as pe,I as mt,N as pt,r as Bt,i as _t,T as dt,M as Qe,D as Pt,C as Tt,O as Gt,Q as Kt}from"./index-q3Tisdnr.js";import{D as Ut,a as qt,e as Jt,b as Zt,c as Qt}from"./Close-DL7iP88x.js";import{S as Yt}from"./Snackbar-Cz2M_lq2.js";import{a as Xt,C as eo,A as to,G as h}from"./PageHeader-BdVI3_ZB.js";import{A as oo,f as Ce,o as Ot,i as ft,T as I}from"./TextField-CVNMv7Sa.js";import{B as gt}from"./Button-BmCu8mk5.js";const ro=o=>{const s=v.useRef({});return v.useEffect(()=>{s.current=o}),s.current};function jt(o){return typeof o.normalize<"u"?o.normalize("NFD").replace(/[\u0300-\u036f]/g,""):o}function no(o={}){const{ignoreAccents:s=!0,ignoreCase:d=!0,limit:C,matchFrom:k="any",stringify:j,trim:a=!1}=o;return(f,{inputValue:z,getOptionLabel:W})=>{let $=a?z.trim():z;d&&($=$.toLowerCase()),s&&($=jt($));const R=$?f.filter(Z=>{let w=(j||W)(Z);return d&&(w=w.toLowerCase()),s&&(w=jt(w)),k==="start"?w.indexOf($)===0:w.indexOf($)>-1}):f;return typeof C=="number"?R.slice(0,C):R}}function Ye(o,s){for(let d=0;d{var s;return o.current!==null&&((s=o.current.parentElement)==null?void 0:s.contains(document.activeElement))},lo=[];function io(o){const{unstable_isActiveElementInListbox:s=so,unstable_classNamePrefix:d="Mui",autoComplete:C=!1,autoHighlight:k=!1,autoSelect:j=!1,blurOnSelect:a=!1,clearOnBlur:f=!o.freeSolo,clearOnEscape:z=!1,componentName:W="useAutocomplete",defaultValue:$=o.multiple?lo:null,disableClearable:R=!1,disableCloseOnSelect:Z=!1,disabled:w,disabledItemsFocusable:Ie=!1,disableListWrap:S=!1,filterOptions:De=ao,filterSelectedOptions:u=!1,freeSolo:y=!1,getOptionDisabled:x,getOptionKey:Q,getOptionLabel:oe=t=>{var e;return(e=t.label)!=null?e:t},groupBy:B,handleHomeEndKeys:Y=!o.freeSolo,id:Ne,includeInputInList:Pe=!1,inputValue:de,isOptionEqualToValue:_=(t,e)=>t===e,multiple:m=!1,onChange:Te,onClose:ze,onHighlightChange:Me,onInputChange:re,onOpen:Ee,open:xt,openOnFocus:vt=!1,options:Oe,readOnly:le=!1,selectOnFocus:je=!o.freeSolo,value:Fe}=o,H=Wt(Ne);let M=oe;M=t=>{const e=oe(t);return typeof e!="string"?String(e):e};const Le=v.useRef(!1),We=v.useRef(!0),L=v.useRef(null),V=v.useRef(null),[fe,rt]=v.useState(null),[E,Ae]=v.useState(-1),He=k?0:-1,D=v.useRef(He),[i,yt]=ct({controlled:Fe,default:$,name:W}),[g,ne]=ct({controlled:de,default:"",name:W,state:"inputValue"}),[ge,Ve]=v.useState(!1),ie=v.useCallback((t,e)=>{if(!(m?i.length!(u&&(m?i:[i]).some(e=>e!==null&&_(t,e)))),{inputValue:Ge&&nt?"":g,getOptionLabel:M}):[],U=ro({filteredOptions:b,value:i,inputValue:g});v.useEffect(()=>{const t=i!==U.value;ge&&!t||y&&!t||ie(null,i)},[i,ie,ge,U.value,y]);const $e=se&&b.length>0&&!le,he=Ze(t=>{t===-1?L.current.focus():fe.querySelector(`[data-tag-index="${t}"]`).focus()});v.useEffect(()=>{m&&E>i.length-1&&(Ae(-1),he(-1))},[i,m,E,he]);function me(t,e){if(!V.current||t<0||t>=b.length)return-1;let n=t;for(;;){const l=V.current.querySelector(`[data-option-index="${n}"]`),p=Ie?!1:!l||l.disabled||l.getAttribute("aria-disabled")==="true";if(l&&l.hasAttribute("tabindex")&&!p)return n;if(e==="next"?n=(n+1)%b.length:n=(n-1+b.length)%b.length,n===t)return-1}}const X=Ze(({event:t,index:e,reason:n="auto"})=>{if(D.current=e,e===-1?L.current.removeAttribute("aria-activedescendant"):L.current.setAttribute("aria-activedescendant",`${H}-option-${e}`),Me&&Me(t,e===-1?null:b[e],n),!V.current)return;const l=V.current.querySelector(`[role="option"].${d}-focused`);l&&(l.classList.remove(`${d}-focused`),l.classList.remove(`${d}-focusVisible`));let p=V.current;if(V.current.getAttribute("role")!=="listbox"&&(p=V.current.parentElement.querySelector('[role="listbox"]')),!p)return;if(e===-1){p.scrollTop=0;return}const P=V.current.querySelector(`[data-option-index="${e}"]`);if(P&&(P.classList.add(`${d}-focused`),n==="keyboard"&&P.classList.add(`${d}-focusVisible`),p.scrollHeight>p.clientHeight&&n!=="mouse"&&n!=="touch")){const T=P,te=p.clientHeight+p.scrollTop,It=T.offsetTop+T.offsetHeight;It>te?p.scrollTop=It-p.clientHeight:T.offsetTop-T.offsetHeight*(B?1.3:0){if(!F)return;const P=me((()=>{const T=b.length-1;if(e==="reset")return He;if(e==="start")return 0;if(e==="end")return T;const te=D.current+e;return te<0?te===-1&&Pe?-1:S&&D.current!==-1||Math.abs(e)>1?0:T:te>T?te===T+1&&Pe?-1:S||Math.abs(e)>1?T:0:te})(),n);if(X({index:P,reason:l,event:t}),C&&e!=="reset")if(P===-1)L.current.value=g;else{const T=M(b[P]);L.current.value=T,T.toLowerCase().indexOf(g.toLowerCase())===0&&g.length>0&&L.current.setSelectionRange(g.length,T.length)}}),be=()=>{const t=(e,n)=>{const l=e?M(e):"",p=n?M(n):"";return l===p};if(D.current!==-1&&U.filteredOptions&&U.filteredOptions.length!==b.length&&U.inputValue===g&&(m?i.length===U.value.length&&U.value.every((e,n)=>M(i[n])===M(e)):t(U.value,i))){const e=U.filteredOptions[D.current];if(e)return Ye(b,n=>M(n)===M(e))}return-1},Re=v.useCallback(()=>{if(!F)return;const t=be();if(t!==-1){D.current=t;return}const e=m?i[0]:i;if(b.length===0||e==null){q({diff:"reset"});return}if(V.current){if(e!=null){const n=b[D.current];if(m&&n&&Ye(i,p=>_(n,p))!==-1)return;const l=Ye(b,p=>_(p,e));l===-1?q({diff:"reset"}):X({index:l});return}if(D.current>=b.length-1){X({index:b.length-1});return}X({index:D.current})}},[b.length,m?!1:i,u,q,X,F,g,m]),at=Ze(t=>{Ht(V,t),t&&Re()});v.useEffect(()=>{Re()},[Re]);const G=t=>{se||(Be(!0),_e(!0),Ee&&Ee(t))},ae=(t,e)=>{se&&(Be(!1),ze&&ze(t,e))},ee=(t,e,n,l)=>{if(m){if(i.length===e.length&&i.every((p,P)=>p===e[P]))return}else if(i===e)return;Te&&Te(t,e,n,l),yt(e)},xe=v.useRef(!1),ue=(t,e,n="selectOption",l="options")=>{let p=n,P=e;if(m){P=Array.isArray(i)?i.slice():[];const T=Ye(P,te=>_(e,te));T===-1?P.push(e):l!=="freeSolo"&&(P.splice(T,1),p="removeOption")}ie(t,P),ee(t,P,p,{option:e}),!Z&&(!t||!t.ctrlKey&&!t.metaKey)&&ae(t,p),(a===!0||a==="touch"&&xe.current||a==="mouse"&&!xe.current)&&L.current.blur()};function Ke(t,e){if(t===-1)return-1;let n=t;for(;;){if(e==="next"&&n===i.length||e==="previous"&&n===-1)return-1;const l=fe.querySelector(`[data-tag-index="${n}"]`);if(!l||!l.hasAttribute("tabindex")||l.disabled||l.getAttribute("aria-disabled")==="true")n+=e==="next"?1:-1;else return n}}const Ue=(t,e)=>{if(!m)return;g===""&&ae(t,"toggleInput");let n=E;E===-1?g===""&&e==="previous"&&(n=i.length-1):(n+=e==="next"?1:-1,n<0&&(n=0),n===i.length&&(n=-1)),n=Ke(n,e),Ae(n),he(n)},qe=t=>{Le.current=!0,ne(""),re&&re(t,"","clear"),ee(t,m?[]:null,"clear")},st=t=>e=>{if(t.onKeyDown&&t.onKeyDown(e),!e.defaultMuiPrevented&&(E!==-1&&["ArrowLeft","ArrowRight"].indexOf(e.key)===-1&&(Ae(-1),he(-1)),e.which!==229))switch(e.key){case"Home":F&&Y&&(e.preventDefault(),q({diff:"start",direction:"next",reason:"keyboard",event:e}));break;case"End":F&&Y&&(e.preventDefault(),q({diff:"end",direction:"previous",reason:"keyboard",event:e}));break;case"PageUp":e.preventDefault(),q({diff:-Lt,direction:"previous",reason:"keyboard",event:e}),G(e);break;case"PageDown":e.preventDefault(),q({diff:Lt,direction:"next",reason:"keyboard",event:e}),G(e);break;case"ArrowDown":e.preventDefault(),q({diff:1,direction:"next",reason:"keyboard",event:e}),G(e);break;case"ArrowUp":e.preventDefault(),q({diff:-1,direction:"previous",reason:"keyboard",event:e}),G(e);break;case"ArrowLeft":Ue(e,"previous");break;case"ArrowRight":Ue(e,"next");break;case"Enter":if(D.current!==-1&&F){const n=b[D.current],l=x?x(n):!1;if(e.preventDefault(),l)return;ue(e,n,"selectOption"),C&&L.current.setSelectionRange(L.current.value.length,L.current.value.length)}else y&&g!==""&&Ge===!1&&(m&&e.preventDefault(),ue(e,g,"createOption","freeSolo"));break;case"Escape":F?(e.preventDefault(),e.stopPropagation(),ae(e,"escape")):z&&(g!==""||m&&i.length>0)&&(e.preventDefault(),e.stopPropagation(),qe(e));break;case"Backspace":if(m&&!le&&g===""&&i.length>0){const n=E===-1?i.length-1:E,l=i.slice();l.splice(n,1),ee(e,l,"removeOption",{option:i[n]})}break;case"Delete":if(m&&!le&&g===""&&i.length>0&&E!==-1){const n=E,l=i.slice();l.splice(n,1),ee(e,l,"removeOption",{option:i[n]})}break}},Ct=t=>{Ve(!0),vt&&!Le.current&&G(t)},ve=t=>{if(s(V)){L.current.focus();return}Ve(!1),We.current=!0,Le.current=!1,j&&D.current!==-1&&F?ue(t,b[D.current],"blur"):j&&y&&g!==""?ue(t,g,"blur","freeSolo"):f&&ie(t,i),ae(t,"blur")},N=t=>{const e=t.target.value;g!==e&&(ne(e),_e(!1),re&&re(t,e,"input")),e===""?!R&&!m&&ee(t,null,"clear"):G(t)},A=t=>{const e=Number(t.currentTarget.getAttribute("data-option-index"));D.current!==e&&X({event:t,index:e,reason:"mouse"})},J=t=>{X({event:t,index:Number(t.currentTarget.getAttribute("data-option-index")),reason:"touch"}),xe.current=!0},St=t=>{const e=Number(t.currentTarget.getAttribute("data-option-index"));ue(t,b[e],"selectOption"),xe.current=!1},lt=t=>e=>{const n=i.slice();n.splice(t,1),ee(e,n,"removeOption",{option:i[t]})},it=t=>{se?ae(t,"toggleInput"):G(t)},ut=t=>{t.currentTarget.contains(t.target)&&t.target.getAttribute("id")!==H&&t.preventDefault()},Je=t=>{t.currentTarget.contains(t.target)&&(L.current.focus(),je&&We.current&&L.current.selectionEnd-L.current.selectionStart===0&&L.current.select(),We.current=!1)},ke=t=>{!w&&(g===""||!se)&&it(t)};let ce=y&&g.length>0;ce=ce||(m?i.length>0:i!==null);let ye=b;return B&&(ye=b.reduce((t,e,n)=>{const l=B(e);return t.length>0&&t[t.length-1].group===l?t[t.length-1].options.push(e):t.push({key:n,index:n,group:l,options:[e]}),t},[])),w&&ge&&ve(),{getRootProps:(t={})=>O({"aria-owns":$e?`${H}-listbox`:null},t,{onKeyDown:st(t),onMouseDown:ut,onClick:Je}),getInputLabelProps:()=>({id:`${H}-label`,htmlFor:H}),getInputProps:()=>({id:H,value:g,onBlur:ve,onFocus:Ct,onChange:N,onMouseDown:ke,"aria-activedescendant":F?"":null,"aria-autocomplete":C?"both":"list","aria-controls":$e?`${H}-listbox`:void 0,"aria-expanded":$e,autoComplete:"off",ref:L,autoCapitalize:"none",spellCheck:"false",role:"combobox",disabled:w}),getClearProps:()=>({tabIndex:-1,type:"button",onClick:qe}),getPopupIndicatorProps:()=>({tabIndex:-1,type:"button",onClick:it}),getTagProps:({index:t})=>O({key:t,"data-tag-index":t,tabIndex:-1},!le&&{onDelete:lt(t)}),getListboxProps:()=>({role:"listbox",id:`${H}-listbox`,"aria-labelledby":`${H}-label`,ref:at,onMouseDown:t=>{t.preventDefault()}}),getOptionProps:({index:t,option:e})=>{var n;const l=(m?i:[i]).some(P=>P!=null&&_(e,P)),p=x?x(e):!1;return{key:(n=Q==null?void 0:Q(e))!=null?n:M(e),tabIndex:-1,role:"option",id:`${H}-option-${t}`,onMouseMove:A,onClick:St,onTouchStart:J,"data-option-index":t,"aria-disabled":p,"aria-selected":l}},id:H,inputValue:g,value:i,dirty:ce,expanded:F&&fe,popupOpen:F,focused:ge||E!==-1,anchorEl:fe,setAnchorEl:rt,focusedTag:E,groupedOptions:ye}}function uo(o){return kt("MuiListSubheader",o)}wt("MuiListSubheader",["root","colorPrimary","colorInherit","gutters","inset","sticky"]);const co=["className","color","component","disableGutters","disableSticky","inset"],po=o=>{const{classes:s,color:d,disableGutters:C,inset:k,disableSticky:j}=o,a={root:["root",d!=="default"&&`color${ot(d)}`,!C&&"gutters",k&&"inset",!j&&"sticky"]};return Nt(a,uo,s)},fo=K("li",{name:"MuiListSubheader",slot:"Root",overridesResolver:(o,s)=>{const{ownerState:d}=o;return[s.root,d.color!=="default"&&s[`color${ot(d.color)}`],!d.disableGutters&&s.gutters,d.inset&&s.inset,!d.disableSticky&&s.sticky]}})(({theme:o,ownerState:s})=>O({boxSizing:"border-box",lineHeight:"48px",listStyle:"none",color:(o.vars||o).palette.text.secondary,fontFamily:o.typography.fontFamily,fontWeight:o.typography.fontWeightMedium,fontSize:o.typography.pxToRem(14)},s.color==="primary"&&{color:(o.vars||o).palette.primary.main},s.color==="inherit"&&{color:"inherit"},!s.disableGutters&&{paddingLeft:16,paddingRight:16},s.inset&&{paddingLeft:72},!s.disableSticky&&{position:"sticky",top:0,zIndex:1,backgroundColor:(o.vars||o).palette.background.paper})),Et=v.forwardRef(function(s,d){const C=Dt({props:s,name:"MuiListSubheader"}),{className:k,color:j="default",component:a="li",disableGutters:f=!1,disableSticky:z=!1,inset:W=!1}=C,$=we(C,co),R=O({},C,{color:j,component:a,disableGutters:f,disableSticky:z,inset:W}),Z=po(R);return r.jsx(fo,O({as:a,className:Se(Z.root,k),ref:d,ownerState:R},$))});Et.muiSkipListHighlight=!0;function go(o){return kt("MuiAutocomplete",o)}const c=wt("MuiAutocomplete",["root","expanded","fullWidth","focused","focusVisible","tag","tagSizeSmall","tagSizeMedium","hasPopupIcon","hasClearIcon","inputRoot","input","inputFocused","endAdornment","clearIndicator","popupIndicator","popupIndicatorOpen","popper","popperDisablePortal","paper","listbox","loading","noOptions","option","groupLabel","groupUl"]);var At,$t;const ho=["autoComplete","autoHighlight","autoSelect","blurOnSelect","ChipProps","className","clearIcon","clearOnBlur","clearOnEscape","clearText","closeText","componentsProps","defaultValue","disableClearable","disableCloseOnSelect","disabled","disabledItemsFocusable","disableListWrap","disablePortal","filterOptions","filterSelectedOptions","forcePopupIcon","freeSolo","fullWidth","getLimitTagsText","getOptionDisabled","getOptionKey","getOptionLabel","isOptionEqualToValue","groupBy","handleHomeEndKeys","id","includeInputInList","inputValue","limitTags","ListboxComponent","ListboxProps","loading","loadingText","multiple","noOptionsText","onChange","onClose","onHighlightChange","onInputChange","onOpen","open","openOnFocus","openText","options","PaperComponent","PopperComponent","popupIcon","readOnly","renderGroup","renderInput","renderOption","renderTags","selectOnFocus","size","slotProps","value"],mo=["ref"],bo=["key"],xo=["key"],vo=o=>{const{classes:s,disablePortal:d,expanded:C,focused:k,fullWidth:j,hasClearIcon:a,hasPopupIcon:f,inputFocused:z,popupOpen:W,size:$}=o,R={root:["root",C&&"expanded",k&&"focused",j&&"fullWidth",a&&"hasClearIcon",f&&"hasPopupIcon"],inputRoot:["inputRoot"],input:["input",z&&"inputFocused"],tag:["tag",`tagSize${ot($)}`],endAdornment:["endAdornment"],clearIndicator:["clearIndicator"],popupIndicator:["popupIndicator",W&&"popupIndicatorOpen"],popper:["popper",d&&"popperDisablePortal"],paper:["paper"],listbox:["listbox"],loading:["loading"],noOptions:["noOptions"],option:["option"],groupLabel:["groupLabel"],groupUl:["groupUl"]};return Nt(R,go,s)},yo=K("div",{name:"MuiAutocomplete",slot:"Root",overridesResolver:(o,s)=>{const{ownerState:d}=o,{fullWidth:C,hasClearIcon:k,hasPopupIcon:j,inputFocused:a,size:f}=d;return[{[`& .${c.tag}`]:s.tag},{[`& .${c.tag}`]:s[`tagSize${ot(f)}`]},{[`& .${c.inputRoot}`]:s.inputRoot},{[`& .${c.input}`]:s.input},{[`& .${c.input}`]:a&&s.inputFocused},s.root,C&&s.fullWidth,j&&s.hasPopupIcon,k&&s.hasClearIcon]}})({[`&.${c.focused} .${c.clearIndicator}`]:{visibility:"visible"},"@media (pointer: fine)":{[`&:hover .${c.clearIndicator}`]:{visibility:"visible"}},[`& .${c.tag}`]:{margin:3,maxWidth:"calc(100% - 6px)"},[`& .${c.inputRoot}`]:{[`.${c.hasPopupIcon}&, .${c.hasClearIcon}&`]:{paddingRight:30},[`.${c.hasPopupIcon}.${c.hasClearIcon}&`]:{paddingRight:56},[`& .${c.input}`]:{width:0,minWidth:30}},[`& .${ft.root}`]:{paddingBottom:1,"& .MuiInput-input":{padding:"4px 4px 4px 0px"}},[`& .${ft.root}.${pe.sizeSmall}`]:{[`& .${ft.input}`]:{padding:"2px 4px 3px 0"}},[`& .${Ot.root}`]:{padding:9,[`.${c.hasPopupIcon}&, .${c.hasClearIcon}&`]:{paddingRight:39},[`.${c.hasPopupIcon}.${c.hasClearIcon}&`]:{paddingRight:65},[`& .${c.input}`]:{padding:"7.5px 4px 7.5px 5px"},[`& .${c.endAdornment}`]:{right:9}},[`& .${Ot.root}.${pe.sizeSmall}`]:{paddingTop:6,paddingBottom:6,paddingLeft:6,[`& .${c.input}`]:{padding:"2.5px 4px 2.5px 8px"}},[`& .${Ce.root}`]:{paddingTop:19,paddingLeft:8,[`.${c.hasPopupIcon}&, .${c.hasClearIcon}&`]:{paddingRight:39},[`.${c.hasPopupIcon}.${c.hasClearIcon}&`]:{paddingRight:65},[`& .${Ce.input}`]:{padding:"7px 4px"},[`& .${c.endAdornment}`]:{right:9}},[`& .${Ce.root}.${pe.sizeSmall}`]:{paddingBottom:1,[`& .${Ce.input}`]:{padding:"2.5px 4px"}},[`& .${pe.hiddenLabel}`]:{paddingTop:8},[`& .${Ce.root}.${pe.hiddenLabel}`]:{paddingTop:0,paddingBottom:0,[`& .${c.input}`]:{paddingTop:16,paddingBottom:17}},[`& .${Ce.root}.${pe.hiddenLabel}.${pe.sizeSmall}`]:{[`& .${c.input}`]:{paddingTop:8,paddingBottom:9}},[`& .${c.input}`]:{flexGrow:1,textOverflow:"ellipsis",opacity:0},variants:[{props:{fullWidth:!0},style:{width:"100%"}},{props:{size:"small"},style:{[`& .${c.tag}`]:{margin:2,maxWidth:"calc(100% - 4px)"}}},{props:{inputFocused:!0},style:{[`& .${c.input}`]:{opacity:1}}},{props:{multiple:!0},style:{[`& .${c.inputRoot}`]:{flexWrap:"wrap"}}}]}),Co=K("div",{name:"MuiAutocomplete",slot:"EndAdornment",overridesResolver:(o,s)=>s.endAdornment})({position:"absolute",right:0,top:"50%",transform:"translate(0, -50%)"}),So=K(mt,{name:"MuiAutocomplete",slot:"ClearIndicator",overridesResolver:(o,s)=>s.clearIndicator})({marginRight:-2,padding:4,visibility:"hidden"}),Io=K(mt,{name:"MuiAutocomplete",slot:"PopupIndicator",overridesResolver:({ownerState:o},s)=>O({},s.popupIndicator,o.popupOpen&&s.popupIndicatorOpen)})({padding:2,marginRight:-2,variants:[{props:{popupOpen:!0},style:{transform:"rotate(180deg)"}}]}),Po=K(Mt,{name:"MuiAutocomplete",slot:"Popper",overridesResolver:(o,s)=>{const{ownerState:d}=o;return[{[`& .${c.option}`]:s.option},s.popper,d.disablePortal&&s.popperDisablePortal]}})(({theme:o})=>({zIndex:(o.vars||o).zIndex.modal,variants:[{props:{disablePortal:!0},style:{position:"absolute"}}]})),To=K(zt,{name:"MuiAutocomplete",slot:"Paper",overridesResolver:(o,s)=>s.paper})(({theme:o})=>O({},o.typography.body1,{overflow:"auto"})),Oo=K("div",{name:"MuiAutocomplete",slot:"Loading",overridesResolver:(o,s)=>s.loading})(({theme:o})=>({color:(o.vars||o).palette.text.secondary,padding:"14px 16px"})),jo=K("div",{name:"MuiAutocomplete",slot:"NoOptions",overridesResolver:(o,s)=>s.noOptions})(({theme:o})=>({color:(o.vars||o).palette.text.secondary,padding:"14px 16px"})),Lo=K("div",{name:"MuiAutocomplete",slot:"Listbox",overridesResolver:(o,s)=>s.listbox})(({theme:o})=>({listStyle:"none",margin:0,padding:"8px 0",maxHeight:"40vh",overflow:"auto",position:"relative",[`& .${c.option}`]:{minHeight:48,display:"flex",overflow:"hidden",justifyContent:"flex-start",alignItems:"center",cursor:"pointer",paddingTop:6,boxSizing:"border-box",outline:"0",WebkitTapHighlightColor:"transparent",paddingBottom:6,paddingLeft:16,paddingRight:16,[o.breakpoints.up("sm")]:{minHeight:"auto"},[`&.${c.focused}`]:{backgroundColor:(o.vars||o).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}},'&[aria-disabled="true"]':{opacity:(o.vars||o).palette.action.disabledOpacity,pointerEvents:"none"},[`&.${c.focusVisible}`]:{backgroundColor:(o.vars||o).palette.action.focus},'&[aria-selected="true"]':{backgroundColor:o.vars?`rgba(${o.vars.palette.primary.mainChannel} / ${o.vars.palette.action.selectedOpacity})`:pt(o.palette.primary.main,o.palette.action.selectedOpacity),[`&.${c.focused}`]:{backgroundColor:o.vars?`rgba(${o.vars.palette.primary.mainChannel} / calc(${o.vars.palette.action.selectedOpacity} + ${o.vars.palette.action.hoverOpacity}))`:pt(o.palette.primary.main,o.palette.action.selectedOpacity+o.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:(o.vars||o).palette.action.selected}},[`&.${c.focusVisible}`]:{backgroundColor:o.vars?`rgba(${o.vars.palette.primary.mainChannel} / calc(${o.vars.palette.action.selectedOpacity} + ${o.vars.palette.action.focusOpacity}))`:pt(o.palette.primary.main,o.palette.action.selectedOpacity+o.palette.action.focusOpacity)}}}})),Ao=K(Et,{name:"MuiAutocomplete",slot:"GroupLabel",overridesResolver:(o,s)=>s.groupLabel})(({theme:o})=>({backgroundColor:(o.vars||o).palette.background.paper,top:-8})),$o=K("ul",{name:"MuiAutocomplete",slot:"GroupUl",overridesResolver:(o,s)=>s.groupUl})({padding:0,[`& .${c.option}`]:{paddingLeft:24}}),Xe=v.forwardRef(function(s,d){var C,k,j,a;const f=Dt({props:s,name:"MuiAutocomplete"}),{autoComplete:z=!1,autoHighlight:W=!1,autoSelect:$=!1,blurOnSelect:R=!1,ChipProps:Z,className:w,clearIcon:Ie=At||(At=r.jsx(Xt,{fontSize:"small"})),clearOnBlur:S=!f.freeSolo,clearOnEscape:De=!1,clearText:u="Clear",closeText:y="Close",componentsProps:x={},defaultValue:Q=f.multiple?[]:null,disableClearable:oe=!1,disableCloseOnSelect:B=!1,disabled:Y=!1,disabledItemsFocusable:Ne=!1,disableListWrap:Pe=!1,disablePortal:de=!1,filterSelectedOptions:_=!1,forcePopupIcon:m="auto",freeSolo:Te=!1,fullWidth:ze=!1,getLimitTagsText:Me=e=>`+${e}`,getOptionLabel:re,groupBy:Ee,handleHomeEndKeys:xt=!f.freeSolo,includeInputInList:vt=!1,limitTags:Oe=-1,ListboxComponent:le="ul",ListboxProps:je,loading:Fe=!1,loadingText:H="Loading…",multiple:M=!1,noOptionsText:Le="No options",openOnFocus:We=!1,openText:L="Open",PaperComponent:V=zt,PopperComponent:fe=Mt,popupIcon:rt=$t||($t=r.jsx(oo,{})),readOnly:E=!1,renderGroup:Ae,renderInput:He,renderOption:D,renderTags:i,selectOnFocus:yt=!f.freeSolo,size:g="medium",slotProps:ne={}}=f,ge=we(f,ho),{getRootProps:Ve,getInputProps:ie,getInputLabelProps:se,getPopupIndicatorProps:Be,getClearProps:nt,getTagProps:_e,getListboxProps:Ge,getOptionProps:F,value:b,dirty:U,expanded:$e,id:he,popupOpen:me,focused:X,focusedTag:q,anchorEl:be,setAnchorEl:Re,inputValue:at,groupedOptions:G}=io(O({},f,{componentName:"Autocomplete"})),ae=!oe&&!Y&&U&&!E,ee=(!Te||m===!0)&&m!==!1,{onMouseDown:xe}=ie(),{ref:ue}=je??{},Ke=Ge(),{ref:Ue}=Ke,qe=we(Ke,mo),st=Vt(Ue,ue),ve=re||(e=>{var n;return(n=e.label)!=null?n:e}),N=O({},f,{disablePortal:de,expanded:$e,focused:X,fullWidth:ze,getOptionLabel:ve,hasClearIcon:ae,hasPopupIcon:ee,inputFocused:q===-1,popupOpen:me,size:g}),A=vo(N);let J;if(M&&b.length>0){const e=n=>O({className:A.tag,disabled:Y},_e(n));i?J=i(b,e,N):J=b.map((n,l)=>{const p=e({index:l}),{key:P}=p,T=we(p,bo);return r.jsx(eo,O({label:ve(n),size:g},T,Z),P)})}if(Oe>-1&&Array.isArray(J)){const e=J.length-Oe;!X&&e>0&&(J=J.splice(0,Oe),J.push(r.jsx("span",{className:A.tag,children:Me(e)},J.length)))}const lt=Ae||(e=>r.jsxs("li",{children:[r.jsx(Ao,{className:A.groupLabel,ownerState:N,component:"div",children:e.group}),r.jsx($o,{className:A.groupUl,ownerState:N,children:e.children})]},e.key)),ut=D||((e,n)=>{const{key:l}=e,p=we(e,xo);return r.jsx("li",O({},p,{children:ve(n)}),l)}),Je=(e,n)=>{const l=F({option:e,index:n});return ut(O({},l,{className:A.option}),e,{selected:l["aria-selected"],index:n,inputValue:at},N)},ke=(C=ne.clearIndicator)!=null?C:x.clearIndicator,ce=(k=ne.paper)!=null?k:x.paper,ye=(j=ne.popper)!=null?j:x.popper,t=(a=ne.popupIndicator)!=null?a:x.popupIndicator;return r.jsxs(v.Fragment,{children:[r.jsx(yo,O({ref:d,className:Se(A.root,w),ownerState:N},Ve(ge),{children:He({id:he,disabled:Y,fullWidth:!0,size:g==="small"?"small":void 0,InputLabelProps:se(),InputProps:O({ref:Re,className:A.inputRoot,startAdornment:J,onClick:e=>{e.target===e.currentTarget&&xe(e)}},(ae||ee)&&{endAdornment:r.jsxs(Co,{className:A.endAdornment,ownerState:N,children:[ae?r.jsx(So,O({},nt(),{"aria-label":u,title:u,ownerState:N},ke,{className:Se(A.clearIndicator,ke==null?void 0:ke.className),children:Ie})):null,ee?r.jsx(Io,O({},Be(),{disabled:Y,"aria-label":me?y:L,title:me?y:L,ownerState:N},t,{className:Se(A.popupIndicator,t==null?void 0:t.className),children:rt})):null]})}),inputProps:O({className:A.input,disabled:Y,readOnly:E},ie())})})),be?r.jsx(Po,O({as:fe,disablePortal:de,style:{width:be?be.clientWidth:null},ownerState:N,role:"presentation",anchorEl:be,open:me},ye,{className:Se(A.popper,ye==null?void 0:ye.className),children:r.jsxs(To,O({ownerState:N,as:V},ce,{className:Se(A.paper,ce==null?void 0:ce.className),children:[Fe&&G.length===0?r.jsx(Oo,{className:A.loading,ownerState:N,children:H}):null,G.length===0&&!Te&&!Fe?r.jsx(jo,{className:A.noOptions,ownerState:N,role:"presentation",onMouseDown:e=>{e.preventDefault()},children:Le}):null,G.length>0?r.jsx(Lo,O({as:le,className:A.listbox,ownerState:N},qe,je,{ref:st,children:G.map((e,n)=>Ee?lt({key:e.key,group:e.group,children:e.options.map((l,p)=>Je(l,e.index+p))}):Je(e,n))})):null]}))})):null]})});var bt={},Ro=_t;Object.defineProperty(bt,"__esModule",{value:!0});var Ft=bt.default=void 0,ko=Ro(Bt()),wo=r;Ft=bt.default=(0,ko.default)((0,wo.jsx)("path",{d:"M12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4m8.94 3c-.46-4.17-3.77-7.48-7.94-7.94V1h-2v2.06C6.83 3.52 3.52 6.83 3.06 11H1v2h2.06c.46 4.17 3.77 7.48 7.94 7.94V23h2v-2.06c4.17-.46 7.48-3.77 7.94-7.94H23v-2zM12 19c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7"}),"MyLocation");const Do=["retail","wholesale","manufacturer","distributor","services","ecommerce","other"],No=["newClient","contacted","onboarded","lost"],zo=["Daily","Weekly","Bi-weekly","Monthly","On-demand"],Mo=["basicOnly","full","none"],Eo=["Blue Dart","Delhivery","DTDC","India Post / Speed Post","The Professional Couriers","XpressBees","Ecom Express","Shadowfax","Safexpress","VRL Logistics","TCI (Transport Corporation of India)","Om Logistics","Best Roadways","MSS (Mettur Super Services)","ABT Travels & Logistics","Navata Road Transport","KRS (Kerala Roadways)","Parveen Travels / Parveen Express","SRM Transports","KPN Travels & KPN Speed Parcel","SRS Travels","Hindusthan Travels","City Travels","Essaar Travels","No. 1 Air Travels","A1 Travels","Krish Travels","Hebron Transports","Horma Travels","Vivegam Travels","PSS Transport","SRT (Renugambal Travels)","Thamarai Bus Transports","Rathimeena Travels","Ganesh Travels","John Kennedy Bus Service","Arun Travel","Saaji Meera Roadways","ARC Parcel Service","Chakra Travels & Parcel Service","MVA Parcel And Bus Service","Shrinath Travels & Cargo","Hans Travels","Zingbus","Kalpana Travels / City Land Travels","Trackon Couriers","North India Transways","RSRTC Cargo","UPSRTC Cargo"],ht=["Chennai","Coimbatore","Madurai","Tiruchirappalli","Salem","Tuticorin","Tirupur","Erode","Vellore","Tirunelveli","Thanjavur","Dindigul","Hosur","Nagercoil","Karur","Namakkal","Kanchipuram","Cuddalore","Thoothukudi","Bengaluru","Mysuru","Mangaluru","Hubli","Belagavi","Kalaburagi","Davangere","Ballari","Kochi","Thiruvananthapuram","Kozhikode","Kannur","Thrissur","Kollam","Hyderabad","Warangal","Visakhapatnam","Vijayawada","Tirupati","Guntur","Rajahmundry","Nellore","Mumbai","Pune","Nagpur","Nashik","Aurangabad","Kolhapur","Solapur","New Delhi","Gurugram","Noida","Faridabad","Chandigarh","Amritsar","Ludhiana","Jalandhar","Ahmedabad","Surat","Vadodara","Rajkot","Bhavnagar","Jamnagar","Jaipur","Jodhpur","Udaipur","Kota","Bikaner","Lucknow","Kanpur","Varanasi","Agra","Prayagraj","Gorakhpur","Bhopal","Indore","Gwalior","Jabalpur","Raipur","Kolkata","Siliguri","Durgapur","Patna","Gaya","Ranchi","Jamshedpur","Bhubaneswar","Cuttack","Guwahati","Dibrugarh","Agartala","Imphal","Shillong","Aizawl","Dimapur","Dehradun","Haridwar","Shimla","Srinagar","Jammu","Leh","Panaji","Puducherry","Port Blair"],Rt={name:"",email:"",password:"",phone:"",city:"",businessState:"",businessType:"retail",status:"newClient",frequency:"Daily",parcelVolume:0,activeContracts:0,provider:"",efficiency:"",logisticsSegment:"",transitFrom:"",transitTo:"",neighbourhood:"",surveyAddress:"",surveyLat:"",surveyLng:"",dataConsent:"full",notes:"",pincode:""},et=o=>typeof o=="string"?o.charAt(0).toUpperCase()+o.slice(1).replace(/([A-Z])/g," $1").trim():o,tt=(o,s)=>s&&!o.includes(s)?[s,...o]:o;function Go({open:o,mode:s,initial:d,onClose:C,onSaved:k}){const j=s==="edit",[a,f]=v.useState(Rt),[z,W]=v.useState(!1),[$,R]=v.useState(null),[Z,w]=v.useState(!1),Ie=()=>{if(!navigator.geolocation){alert("Geolocation is not supported by your browser");return}w(!0),navigator.geolocation.getCurrentPosition(async u=>{const y=u.coords.latitude,x=u.coords.longitude;f(Q=>({...Q,surveyLat:y,surveyLng:x}));try{const oe=await(await fetch(`https://nominatim.openstreetmap.org/reverse?format=json&lat=${y}&lon=${x}`)).json();if(oe&&oe.address){const B=oe.address,Y=B.city||B.town||B.village||B.county||"",Ne=B.state||"",Pe=B.postcode||"",de=oe.display_name||"";f(_=>({..._,city:Y||_.city,businessState:Ne||_.businessState,pincode:Pe||_.pincode,surveyAddress:de||_.surveyAddress}))}}catch(Q){console.error("Reverse geocoding failed",Q)}finally{w(!1)}},u=>{alert("Unable to retrieve your location"),w(!1)})};v.useEffect(()=>{o&&(f({...Rt,...d||{}}),R(null))},[o,d]);const S=u=>y=>f(x=>({...x,[u]:y.target.value})),De=async()=>{if(!a.name.trim()){R("Client name is required.");return}W(!0),R(null);const u=a.surveyLat===""?void 0:Number(a.surveyLat),y=a.surveyLng===""?void 0:Number(a.surveyLng),x={first_name:a.name.trim(),phone:a.phone,city:a.city,businessState:a.businessState,businessType:a.businessType,status:a.status,frequency:a.frequency,parcelVolume:Number(a.parcelVolume)||0,activeContracts:Number(a.activeContracts)||0,provider:a.provider,efficiency:a.efficiency,logisticsSegment:a.logisticsSegment,transitFrom:a.transitFrom,transitTo:a.transitTo,neighbourhood:a.neighbourhood,pincode:a.pincode,surveyAddress:a.surveyAddress,dataConsent:a.dataConsent,notes:a.notes,lastUpdated:new Date().toISOString().slice(0,10),registration_source:"web",...a.email.trim()?{email:a.email.trim()}:{},...u!=null?{survey_lat:u}:{},...y!=null?{survey_long:y}:{}};try{j?await Gt(d.id,x):await Kt({...x,...a.password?{password:a.password}:{}}),k()}catch(Q){R(Q.message||"Failed to save client")}finally{W(!1)}};return r.jsxs(r.Fragment,{children:[r.jsx(Yt,{open:!!$,autoHideDuration:6e3,onClose:()=>R(null),anchorOrigin:{vertical:"top",horizontal:"right"},sx:{zIndex:9999},children:r.jsx(to,{onClose:()=>R(null),severity:"error",variant:"filled",sx:{width:"100%",boxShadow:3},children:$})}),r.jsxs(Ut,{open:o,onClose:z?void 0:C,maxWidth:"md",fullWidth:!0,children:[r.jsxs(qt,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[j?"Edit Client":"Add Client",r.jsx(mt,{onClick:C,size:"small",disabled:z,children:r.jsx(Jt,{})})]}),r.jsxs(Zt,{dividers:!0,children:[r.jsx(dt,{variant:"overline",color:"text.secondary",children:"Business"}),r.jsxs(h,{container:!0,spacing:2,sx:{mt:0,mb:1},children:[r.jsx(h,{item:!0,xs:12,sm:6,children:r.jsx(I,{fullWidth:!0,size:"small",label:"Client Name *",value:a.name,onChange:S("name")})}),r.jsx(h,{item:!0,xs:12,sm:6,children:r.jsx(I,{fullWidth:!0,size:"small",label:"Phone",value:a.phone,onChange:S("phone")})}),r.jsx(h,{item:!0,xs:12,sm:6,children:r.jsx(I,{fullWidth:!0,size:"small",label:"Email",value:a.email,onChange:S("email")})}),!j&&r.jsx(h,{item:!0,xs:12,sm:6,children:r.jsx(I,{fullWidth:!0,size:"small",label:"Password",type:"password",value:a.password,onChange:S("password")})}),r.jsx(h,{item:!0,xs:12,sm:6,children:r.jsx(I,{select:!0,fullWidth:!0,size:"small",label:"Business Type",value:a.businessType,onChange:S("businessType"),children:tt(Do,a.businessType).map(u=>r.jsx(Qe,{value:u,children:et(u)},u))})}),r.jsx(h,{item:!0,xs:12,sm:6,children:r.jsx(I,{select:!0,fullWidth:!0,size:"small",label:"Status",value:a.status,onChange:S("status"),children:tt(No,a.status).map(u=>r.jsx(Qe,{value:u,children:et(u)},u))})}),r.jsx(h,{item:!0,xs:12,sm:6,children:r.jsx(I,{select:!0,fullWidth:!0,size:"small",label:"Order Frequency",value:a.frequency,onChange:S("frequency"),children:tt(zo,a.frequency).map(u=>r.jsx(Qe,{value:u,children:et(u)},u))})}),r.jsx(h,{item:!0,xs:12,sm:3,children:r.jsx(I,{fullWidth:!0,size:"small",type:"number",label:"Parcel Volume",value:a.parcelVolume,onChange:S("parcelVolume")})}),r.jsx(h,{item:!0,xs:12,sm:3,children:r.jsx(I,{fullWidth:!0,size:"small",type:"number",label:"Active Contracts",value:a.activeContracts,onChange:S("activeContracts")})}),r.jsx(h,{item:!0,xs:12,sm:6,children:r.jsx(Xe,{autoHighlight:!0,options:Eo,value:a.provider||null,onChange:(u,y)=>f(x=>({...x,provider:y||""})),renderInput:u=>r.jsx(I,{...u,fullWidth:!0,size:"small",label:"Current Provider"})})}),r.jsx(h,{item:!0,xs:12,sm:6,children:r.jsx(I,{fullWidth:!0,size:"small",label:"Efficiency",value:a.efficiency,onChange:S("efficiency")})}),r.jsx(h,{item:!0,xs:12,children:r.jsx(I,{fullWidth:!0,size:"small",label:"Logistics Segment",value:a.logisticsSegment,onChange:S("logisticsSegment"),placeholder:"First Mile, Last Mile"})})]}),r.jsx(Pt,{sx:{my:1.5}}),r.jsx(dt,{variant:"overline",color:"text.secondary",children:"Location & Transit"}),r.jsxs(h,{container:!0,spacing:2,sx:{mt:0,mb:1},children:[r.jsx(h,{item:!0,xs:12,sm:6,children:r.jsx(Xe,{autoHighlight:!0,options:ht,value:a.city||null,onChange:(u,y)=>f(x=>({...x,city:y||""})),renderInput:u=>r.jsx(I,{...u,fullWidth:!0,size:"small",label:"City"})})}),r.jsx(h,{item:!0,xs:12,sm:6,children:r.jsx(I,{fullWidth:!0,size:"small",label:"State",value:a.businessState,onChange:S("businessState")})}),r.jsx(h,{item:!0,xs:12,sm:6,children:r.jsx(I,{fullWidth:!0,size:"small",label:"Pincode",value:a.pincode,onChange:S("pincode")})}),r.jsx(h,{item:!0,xs:12,sm:6,children:r.jsx(I,{fullWidth:!0,size:"small",label:"Neighbourhood / Zone",value:a.neighbourhood,onChange:S("neighbourhood")})}),r.jsx(h,{item:!0,xs:12,sm:6,children:r.jsx(Xe,{autoHighlight:!0,options:ht,value:a.transitFrom||null,onChange:(u,y)=>f(x=>({...x,transitFrom:y||""})),renderInput:u=>r.jsx(I,{...u,fullWidth:!0,size:"small",label:"Transit From"})})}),r.jsx(h,{item:!0,xs:12,sm:6,children:r.jsx(Xe,{autoHighlight:!0,options:ht,value:a.transitTo||null,onChange:(u,y)=>f(x=>({...x,transitTo:y||""})),renderInput:u=>r.jsx(I,{...u,fullWidth:!0,size:"small",label:"Transit To"})})}),r.jsx(h,{item:!0,xs:12,sm:3,children:r.jsx(I,{fullWidth:!0,size:"small",type:"number",label:"Latitude",value:a.surveyLat,onChange:S("surveyLat")})}),r.jsx(h,{item:!0,xs:12,sm:3,children:r.jsx(I,{fullWidth:!0,size:"small",type:"number",label:"Longitude",value:a.surveyLng,onChange:S("surveyLng")})}),r.jsx(h,{item:!0,xs:12,sm:6,display:"flex",alignItems:"center",children:r.jsx(gt,{variant:"outlined",size:"small",onClick:Ie,disabled:Z,startIcon:Z?r.jsx(Tt,{size:16}):r.jsx(Ft,{}),fullWidth:!0,children:"Get GPS Location"})}),r.jsx(h,{item:!0,xs:12,children:r.jsx(I,{fullWidth:!0,size:"small",label:"Survey Address",value:a.surveyAddress,onChange:S("surveyAddress"),multiline:!0,minRows:2})})]}),r.jsx(Pt,{sx:{my:1.5}}),r.jsx(dt,{variant:"overline",color:"text.secondary",children:"Other"}),r.jsxs(h,{container:!0,spacing:2,sx:{mt:0},children:[r.jsx(h,{item:!0,xs:12,sm:6,children:r.jsx(I,{select:!0,fullWidth:!0,size:"small",label:"Data Consent",value:a.dataConsent,onChange:S("dataConsent"),children:tt(Mo,a.dataConsent).map(u=>r.jsx(Qe,{value:u,children:et(u)},u))})}),r.jsx(h,{item:!0,xs:12,children:r.jsx(I,{fullWidth:!0,size:"small",label:"Notes",value:a.notes,onChange:S("notes"),multiline:!0,minRows:2})})]})]}),r.jsxs(Qt,{sx:{px:3,py:2},children:[r.jsx(gt,{onClick:C,disabled:z,children:"Cancel"}),r.jsx(gt,{variant:"contained",onClick:De,disabled:z,startIcon:z?r.jsx(Tt,{size:16,color:"inherit"}):null,children:j?"Save Changes":"Create Client"})]})]})]})}export{Xe as A,Go as C};