@realtek/core-theme 0.0.351 → 0.0.352

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,10 +14,10 @@ Upload the résumé first — we can read the details straight from it`})}),(0,l
14
14
  }
15
15
  }
16
16
  `}),(0,l.jsxs)(s.Form,{form:u,layout:`vertical`,initialValues:aT,disabled:h,className:`template-editor-form`,children:[(0,l.jsxs)(`div`,{className:`template-editor-grid`,children:[(0,l.jsx)(s.Form.Item,{name:`name`,label:`Template name`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`Candidate introduction`})}),(0,l.jsx)(s.Form.Item,{name:`module`,label:`Module`,rules:[{required:!0}],children:(0,l.jsx)(s.Select,{showSearch:!0,optionFilterProp:`label`,options:r,onChange:e=>{u.setFieldValue(`action`,``),C(e)}})}),(0,l.jsx)(s.Form.Item,{name:`action`,label:`Action`,rules:[{required:!0}],tooltip:`Pick a Row Action, or TYPE a system action key. Not every email comes from a row action — the credentials mail sent when an employer's recruiters are provisioned uses "accountCreated", which is raised by a workflow and so never appears in this list.`,children:(0,l.jsx)(s.Select,{showSearch:!0,mode:`tags`,maxCount:1,optionFilterProp:`label`,options:_,placeholder:`Select a row action, or type a system key (e.g. accountCreated)`})}),(0,l.jsx)(s.Form.Item,{name:`clientId`,label:`Client scope (optional)`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,options:i,placeholder:`Available to every client`})})]}),(0,l.jsx)(s.Form.Item,{name:`description`,label:`Description`,children:(0,l.jsx)(s.Input.TextArea,{rows:2})}),(0,l.jsxs)(`div`,{className:`template-editor-grid template-editor-grid--three`,children:[(0,l.jsx)(s.Form.Item,{name:`toMail`,label:`Default To`,children:(0,l.jsx)(s.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`]})}),(0,l.jsx)(s.Form.Item,{name:`ccMail`,label:`Default Cc`,children:(0,l.jsx)(s.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`]})}),(0,l.jsx)(s.Form.Item,{name:`bccMail`,label:`Default Bcc`,children:(0,l.jsx)(s.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`]})})]}),(0,l.jsxs)(`div`,{className:`template-editor-workspace`,style:{display:`grid`,gridTemplateColumns:`minmax(0, 1.2fr) minmax(360px, 0.8fr)`,gap:20,alignItems:`start`,marginTop:4},children:[(0,l.jsxs)(`div`,{className:`template-editor-compose-pane`,style:{minWidth:0,padding:16,border:`1px solid #e5e7eb`,borderRadius:10,background:`#fff`},children:[(0,l.jsx)(iT,{strong:!0,style:{display:`block`,marginBottom:12},children:`Email content`}),(0,l.jsx)(s.Form.Item,{name:`subject`,label:`Subject`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`Email subject — drag placeholders here`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`copy`}})}),(0,l.jsx)(s.Form.Item,{label:`Message`,required:!0,style:{marginBottom:0},children:(0,l.jsx)(`div`,{onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`copy`},style:{minHeight:320},children:(0,l.jsx)(n.Dn,{value:d,onChange:f,placeholder:`Write the reusable email body… Drag placeholders from the right panel.`})})})]}),(0,l.jsxs)(`div`,{className:`template-placeholder-panel`,style:{position:`sticky`,top:0,maxHeight:`calc(100vh - 190px)`,overflowY:`auto`,padding:16,border:`1px solid #dbeafe`,borderRadius:10,background:`#f8fbff`},children:[(0,l.jsx)(iT,{strong:!0,style:{display:`block`},children:`All module placeholders`}),(0,l.jsx)(iT,{type:`secondary`,style:{display:`block`,marginTop:4},children:`Drag a placeholder into Subject or Message. You can also click a placeholder to append it to the message.`}),A.map(e=>(0,l.jsxs)(`div`,{style:{marginTop:14},children:[(0,l.jsx)(iT,{type:`secondary`,strong:!0,children:e.label||e.moduleName}),(0,l.jsx)(`div`,{className:`template-placeholder-list`,style:{marginTop:6},children:e.fields.map(t=>(0,l.jsx)(s.Tooltip,{title:`${t.label||t.key} · ${t.value}`,children:(0,l.jsx)(s.Tag,{color:`blue`,draggable:!0,onDragStart:e=>D(e,t),onClick:()=>E(t),style:{cursor:`grab`,userSelect:`none`,marginBottom:6},children:`{{.${t.key}}}`})},`${e.moduleName}:${t.key}:${t.value}`))})]},e.moduleName)),!A.length&&(0,l.jsx)(s.Empty,{image:s.Empty.PRESENTED_IMAGE_SIMPLE,description:`No module fields available`})]})]}),(0,l.jsx)(s.Form.Item,{name:`isActive`,label:`Available in mail composer`,valuePropName:`checked`,style:{marginTop:16},children:(0,l.jsx)(s.Switch,{})})]})]})}function fT(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(0),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(``),[p,m]=(0,o.useState)(1),[h,g]=(0,o.useState)(20),[_,v]=(0,o.useState)([]),[y,b]=(0,o.useState)([]),[x,S]=(0,o.useState)(null),[C,w]=(0,o.useState)(!1),T=(0,o.useMemo)(()=>_.map(e=>({value:e.key??e.module??e.value,label:e.label??e.name??e.key??e.module??e.value})).filter(e=>e.value),[_]);function E(e=p,n=h,r=d){u(!0),vw({offset:(e-1)*n,limit:n,search:r}).then(({items:e,totalCount:n})=>{t(e),i(n)}).catch(e=>s.message.error(e?.message||`Could not load templates`)).finally(()=>u(!1))}(0,o.useEffect)(()=>{queueMicrotask(()=>{E(1,h,``)})},[]),(0,o.useEffect)(()=>{Promise.all([n.xr(),n.pr({limit:200})]).then(([e,t])=>{v(Gx(e).map(({value:e,label:t})=>({key:e,label:t}))),b(t)}).catch(()=>{})},[]);async function D(e,n){let r=oT(e);try{await xw(r,{...e,isActive:n}),t(e=>e.map(e=>oT(e)===r?{...e,isActive:n}:e))}catch(e){s.message.error(e?.message||`Could not update status`)}}async function O(e){try{await Sw(e),s.message.success(`Template deleted`),E(1),m(1)}catch(e){s.message.error(e?.message||`Could not delete template`)}}let k=[{title:`Template`,key:`template`,width:300,ellipsis:!0,render:(e,t)=>(0,l.jsxs)(`div`,{className:`admin-config-primary-cell templates-primary-cell`,children:[(0,l.jsx)(iT,{strong:!0,ellipsis:{tooltip:t.name},children:t.name}),(0,l.jsx)(iT,{type:`secondary`,ellipsis:{tooltip:t.description||t.subject},children:t.description||t.subject||`No description`})]})},{title:`Module`,dataIndex:`module`,key:`module`,width:140,ellipsis:!0,responsive:[`sm`],render:e=>e?(0,l.jsx)(s.Tag,{color:`blue`,children:e}):`—`},{title:`Action`,dataIndex:`action`,key:`action`,width:180,ellipsis:!0,responsive:[`md`],render:e=>e?(0,l.jsx)(iT,{code:!0,ellipsis:{tooltip:e},children:e}):`—`},{title:`Recipients`,key:`recipients`,width:130,responsive:[`lg`],render:(e,t)=>`${(t.toMail?.length??0)+(t.ccMail?.length??0)+(t.bccMail?.length??0)} defaults`},{title:`Active`,dataIndex:`isActive`,key:`active`,width:80,render:(e,t)=>(0,l.jsx)(s.Switch,{size:`small`,checked:e,onChange:e=>D(t,e)})},{title:``,key:`actions`,width:84,fixed:`right`,render:(e,t)=>(0,l.jsxs)(s.Space,{size:2,children:[(0,l.jsx)(s.Tooltip,{title:`Edit`,children:(0,l.jsx)(s.Button,{type:`text`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{S(oT(t)),w(!0)}})}),(0,l.jsx)(s.Popconfirm,{title:`Delete this template?`,onConfirm:()=>O(oT(t)),children:(0,l.jsx)(s.Button,{type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})]})}],A=y.map(e=>({value:e._id??e.id,label:e.clientName??e.name??e._id})).filter(e=>e.value);return(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.MailOutlined,{}),title:`Email templates`,extra:(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>{S(null),w(!0)},children:`New template`}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(iT,{type:`secondary`,children:`Create reusable, module-aware email content. Modules, actions and placeholders are read from DB configuration.`})]}),(0,l.jsxs)(Z,{title:`${r} template${r===1?``:`s`}`,extra:(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:()=>E(),children:`Reload`}),children:[(0,l.jsx)(`div`,{className:`admin-config-table-tools`,children:(0,l.jsx)(s.Input,{allowClear:!0,prefix:(0,l.jsx)(c.SearchOutlined,{}),placeholder:`Search templates`,value:d,onChange:e=>{let t=e.target.value;f(t),m(1),E(1,h,t)}})}),(0,l.jsx)(`div`,{className:`templates-table-viewport`,children:(0,l.jsx)(s.Table,{rowKey:oT,columns:k,dataSource:e,loading:a,className:`fg-table`,size:`small`,tableLayout:`fixed`,sticky:!0,scroll:{x:914,y:`calc(100vh - 410px)`},pagination:{current:p,pageSize:h,total:r,showSizeChanger:!0,responsive:!0,onChange:(e,t)=>{m(e),g(t),E(e,t)}}})})]}),(0,l.jsx)(dT,{open:C,templateId:x,modules:T,clients:A,onClose:()=>w(!1),onSaved:()=>{w(!1),E()}})]})}function pT({open:e,signatureId:t,onClose:r,onSaved:i}){let[a,c]=(0,o.useState)(``),[u,d]=(0,o.useState)(``),[f,p]=(0,o.useState)({module:`userSignature`,keys:[]}),[m,h]=(0,o.useState)(!1),[g,_]=(0,o.useState)(!1);(0,o.useEffect)(()=>{if(!e)return;let n=!1;return queueMicrotask(()=>{_(!0),Promise.all([t?Dw(t):Promise.resolve(null),Tw()]).then(([e,t])=>{n||(c(e?.signatureName??``),d(e?.signature??``),p(t??{module:`userSignature`,keys:[]}))}).catch(()=>{n||s.message.error(`Could not load signature details`)}).finally(()=>{n||_(!1)})}),()=>{n=!0}},[e,t]);function v(e){let t=`{{.${e.key}}}`;d(e=>`${e}${e?` `:``}${t}`)}async function y(){if(!a.trim())return s.message.error(`Signature name is required`);if(!u.trim())return s.message.error(`Signature content is required`);h(!0);try{let e=uT(u),n=(f.keys??[]).filter(t=>e.has(t.key)).map(e=>({key:e.key,value:e.value})),r={signatureId:t,signatureName:a,signature:u,signatureLogoPath:``,placeHolder:n.length?[{moduleName:f.module||`userSignature`,holders:n}]:[]};t?await kw(r):await Ow(r),s.message.success(t?`Signature updated`:`Signature created`),i()}catch(e){s.message.error(e?.message||`Could not save signature`)}finally{h(!1)}}let b=(f.keys??[]).filter(e=>![`Role_id`,`Role_name`,`Reporting_manager`].includes(e.key)),x=(f.keys??[]).filter(e=>[`Role_id`,`Role_name`,`Reporting_manager`].includes(e.key)),S=e=>(0,l.jsx)(`div`,{className:`template-placeholder-list`,children:e.map(e=>(0,l.jsx)(s.Tooltip,{title:`Mongo field: ${e.value}`,children:(0,l.jsx)(s.Tag,{color:`blue`,style:{cursor:`pointer`},onClick:()=>v(e),children:`{{.${e.key}}}`})},e.key))});return(0,l.jsx)(s.Drawer,{open:e,onClose:r,width:`min(820px, 96vw)`,title:t?`Edit signature`:`New signature`,destroyOnClose:!0,extra:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{onClick:r,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:m,onClick:y,children:t?`Update`:`Create`})]}),children:(0,l.jsxs)(s.Form,{layout:`vertical`,children:[(0,l.jsx)(s.Form.Item,{label:`Signature name`,required:!0,children:(0,l.jsx)(s.Input,{value:a,onChange:e=>c(e.target.value)})}),(0,l.jsx)(s.Form.Item,{label:`Signature content`,required:!0,children:(0,l.jsx)(n.Dn,{value:u,onChange:d,placeholder:`Create the reusable signature…`})}),(0,l.jsxs)(`div`,{className:`template-placeholder-panel`,children:[(0,l.jsx)(iT,{strong:!0,children:`Signature placeholders`}),(0,l.jsx)(iT,{type:`secondary`,children:`Click a placeholder to add it to the signature. Values resolve from MongoDB users and roles when mail is generated.`}),g?(0,l.jsx)(iT,{type:`secondary`,children:`Loading placeholders…`}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{style:{marginTop:10},children:[(0,l.jsx)(iT,{strong:!0,children:`User details`}),S(b)]}),(0,l.jsxs)(`div`,{style:{marginTop:10},children:[(0,l.jsx)(iT,{strong:!0,children:`Role details`}),S(x)]}),!f.keys?.length&&(0,l.jsx)(s.Empty,{image:s.Empty.PRESENTED_IMAGE_SIMPLE,description:`No signature placeholders available`})]})]})]})})}function mT(){let[e,t]=(0,o.useState)([]),[n,r]=(0,o.useState)(0),[i,a]=(0,o.useState)(!1),[u,d]=(0,o.useState)(``),[f,p]=(0,o.useState)(1),[m,h]=(0,o.useState)(20),[g,_]=(0,o.useState)(!1),[v,y]=(0,o.useState)(null);function b(e=f,n=m,i=u){a(!0),Ew({offset:(e-1)*n,limit:n,search:i}).then(({items:e,totalCount:n})=>{t(e),r(n)}).catch(()=>s.message.error(`Could not load signatures`)).finally(()=>a(!1))}(0,o.useEffect)(()=>{queueMicrotask(()=>{b(1,m,``)})},[]);async function x(e,n){try{await jw(e.signatureId,n),t(t=>t.map(t=>t.signatureId===e.signatureId?{...t,isActive:n}:t))}catch{s.message.error(`Could not update status`)}}async function S(e){try{await Aw(e),s.message.success(`Signature deleted`),p(1),b(1)}catch{s.message.error(`Could not delete signature`)}}return(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsx)(Z,{icon:(0,l.jsx)(c.MailOutlined,{}),title:`Signature templates`,extra:(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>{y(null),_(!0)},children:`New signature`}),children:(0,l.jsx)(iT,{type:`secondary`,children:`Existing company and user signatures from the shared DB.`})}),(0,l.jsxs)(Z,{title:`${n} signature${n===1?``:`s`}`,children:[(0,l.jsx)(`div`,{className:`admin-config-table-tools`,children:(0,l.jsx)(s.Input,{allowClear:!0,prefix:(0,l.jsx)(c.SearchOutlined,{}),value:u,placeholder:`Search signatures`,onChange:e=>{d(e.target.value),p(1),b(1,m,e.target.value)}})}),(0,l.jsx)(`div`,{className:`templates-table-viewport`,children:(0,l.jsx)(s.Table,{rowKey:`signatureId`,dataSource:e,columns:[{title:`Signature`,dataIndex:`templateName`,key:`name`,width:300,ellipsis:!0,render:e=>(0,l.jsx)(iT,{strong:!0,ellipsis:{tooltip:e},children:e||`Untitled signature`})},{title:`Created`,dataIndex:`createdDt`,key:`created`,width:150,responsive:[`md`],render:e=>e?new Date(e).toLocaleDateString():`—`},{title:`Active`,dataIndex:`isActive`,key:`active`,width:80,render:(e,t)=>(0,l.jsx)(s.Switch,{size:`small`,checked:e,onChange:e=>x(t,e)})},{title:``,key:`actions`,width:84,fixed:`right`,render:(e,t)=>(0,l.jsxs)(s.Space,{size:2,children:[(0,l.jsx)(s.Button,{type:`text`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{y(t.signatureId),_(!0)}}),(0,l.jsx)(s.Popconfirm,{title:`Delete this signature?`,onConfirm:()=>S(t.signatureId),children:(0,l.jsx)(s.Button,{type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})]})}],loading:i,className:`fg-table`,size:`small`,tableLayout:`fixed`,sticky:!0,scroll:{x:614,y:`calc(100vh - 410px)`},pagination:{current:f,pageSize:m,total:n,responsive:!0,onChange:(e,t)=>{p(e),h(t),b(e,t)}}})})]}),(0,l.jsx)(pT,{open:g,signatureId:v,onClose:()=>_(!1),onSaved:()=>{_(!1),b()}})]})}function hT(){return(0,l.jsx)(s.Tabs,{defaultActiveKey:`email`,className:`admin-config-tabs`,items:[{key:`email`,label:`Email templates`,children:(0,l.jsx)(fT,{})},{key:`signature`,label:`Signatures`,children:(0,l.jsx)(mT,{})}]})}var{Text:gT}=s.Typography,_T={serviceKey:``,label:``,baseUrl:``,authHeader:``,authValue:``,enabled:!0};function vT({open:e,service:t,onClose:r,onSaved:i}){let[a]=s.Form.useForm(),[c,u]=(0,o.useState)(!1);(0,o.useEffect)(()=>{e&&a.setFieldsValue({..._T,...t,authValue:``})},[e,t,a]);async function d(){try{let e=await a.validateFields();u(!0),await n.ei(e),s.message.success(`AI service saved`),i()}catch(e){e?.errorFields||s.message.error(e?.message||`Could not save AI service`)}finally{u(!1)}}return(0,l.jsx)(s.Drawer,{open:e,onClose:r,width:`min(560px, 96vw)`,title:t?`Edit AI service`:`New AI service`,destroyOnClose:!0,extra:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{onClick:r,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:c,onClick:d,children:`Save`})]}),children:(0,l.jsxs)(s.Form,{form:a,layout:`vertical`,initialValues:_T,children:[(0,l.jsx)(s.Form.Item,{name:`serviceKey`,label:`Service Key`,rules:[{required:!0,message:`Service key is required`}],tooltip:`Referenced by an AI Action's Service Key on any form field (e.g. pyOps).`,children:(0,l.jsx)(s.Input,{placeholder:`pyOps`,disabled:!!t,className:`fg-mono-input`})}),(0,l.jsx)(s.Form.Item,{name:`label`,label:`Label`,children:(0,l.jsx)(s.Input,{placeholder:`Resume/JD Parsing Service`})}),(0,l.jsx)(s.Form.Item,{name:`baseUrl`,label:`Base URL`,rules:[{required:!0,message:`Base URL is required`}],children:(0,l.jsx)(s.Input,{placeholder:`https://ai.example.com`,className:`fg-mono-input`})}),(0,l.jsx)(s.Form.Item,{name:`authHeader`,label:`Auth Header (optional)`,children:(0,l.jsx)(s.Input,{placeholder:`x-api-key`,className:`fg-mono-input`})}),(0,l.jsx)(s.Form.Item,{name:`authValue`,label:`Auth Value`,tooltip:`Write-only — leave blank to keep the currently saved value.`,children:(0,l.jsx)(s.Input.Password,{placeholder:t?`Unchanged`:``})}),(0,l.jsx)(s.Form.Item,{name:`enabled`,label:`Enabled`,valuePropName:`checked`,children:(0,l.jsx)(s.Switch,{})})]})})}function yT(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(null);function p(){i(!0),n.hr().then(e=>t(Array.isArray(e)?e:[])).catch(e=>s.message.error(e?.message||`Could not load AI services`)).finally(()=>i(!1))}(0,o.useEffect)(()=>{queueMicrotask(()=>{p()})},[]);async function m(e,r){try{await n.ei({...e,enabled:r}),t(t=>t.map(t=>t.serviceKey===e.serviceKey?{...t,enabled:r}:t))}catch(e){s.message.error(e?.message||`Could not update AI service`)}}async function h(e){try{await n.nr(e),s.message.success(`AI service deleted`),p()}catch(e){s.message.error(e?.message||`Could not delete AI service`)}}return(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.ThunderboltOutlined,{}),title:`AI Services`,extra:(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>{f(null),u(!0)},children:`New service`}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(gT,{type:`secondary`,children:`Register the AI/automation backends that admin-configured "AI Actions" (Generate/Parse-style buttons on any form field) call. A field's AI Action names a Service Key here — no URL is ever hardcoded in the app.`})]}),(0,l.jsx)(Z,{title:`${e.length} service${e.length===1?``:`s`}`,extra:(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:p,children:`Reload`}),children:(0,l.jsx)(s.Table,{rowKey:`serviceKey`,columns:[{title:`Service`,key:`service`,render:(e,t)=>(0,l.jsxs)(`div`,{className:`admin-config-primary-cell`,children:[(0,l.jsx)(gT,{strong:!0,children:t.label||t.serviceKey}),(0,l.jsx)(gT,{type:`secondary`,code:!0,children:t.serviceKey})]})},{title:`Base URL`,dataIndex:`baseUrl`,key:`baseUrl`,ellipsis:!0,render:e=>(0,l.jsx)(gT,{code:!0,ellipsis:{tooltip:e},children:e})},{title:`Auth Header`,dataIndex:`authHeader`,key:`authHeader`,width:140,render:e=>e||`—`},{title:`Enabled`,dataIndex:`enabled`,key:`enabled`,width:90,render:(e,t)=>(0,l.jsx)(s.Switch,{size:`small`,checked:e,onChange:e=>m(t,e)})},{title:``,key:`actions`,width:84,fixed:`right`,render:(e,t)=>(0,l.jsxs)(s.Space,{size:2,children:[(0,l.jsx)(s.Tooltip,{title:`Edit`,children:(0,l.jsx)(s.Button,{type:`text`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{f(t),u(!0)}})}),(0,l.jsx)(s.Popconfirm,{title:`Delete this AI service?`,onConfirm:()=>h(t.serviceKey),children:(0,l.jsx)(s.Button,{type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})]})}],dataSource:e,loading:r,className:`fg-table`,size:`small`})}),(0,l.jsx)(vT,{open:a,service:d,onClose:()=>u(!1),onSaved:()=>{u(!1),p()}})]})}var{Text:bT}=s.Typography,xT={integrationKey:``,label:``,category:`GENERAL`,updateMethod:`MANUAL`,enabled:!0,provider:``,baseUrl:``,authType:`API_KEY`,authHeader:`x-api-key`,authValue:``,clientId:``,clientSecret:``,tokenUrl:``,createPath:``,statusPath:``,testPath:``,webhookSecret:``,targetModule:``,targetField:``,stageMatchField:``,stageMatchValue:``,stageStatusField:``,providerStatusPath:``,providerReferencePath:``,statusMappings:[{providerStatus:``,applicationStatus:``}]},ST=[{label:`API Key`,value:`API_KEY`},{label:`Bearer Token`,value:`BEARER_TOKEN`},{label:`Basic Authentication`,value:`BASIC_AUTH`},{label:`OAuth 2.0 Client Credentials`,value:`OAUTH2_CLIENT_CREDENTIALS`}];function CT(e){let t=Object.fromEntries((e.statusMappings??[]).filter(e=>e?.providerStatus&&e?.applicationStatus).map(e=>[e.providerStatus.trim(),e.applicationStatus.trim()])),n={...e,statusMapping:e.updateMethod===`API`?{targetModule:e.targetModule,targetField:e.targetField,stageMatchField:e.stageMatchField,stageMatchValue:e.stageMatchValue,stageStatusField:e.stageStatusField,providerStatusPath:e.providerStatusPath,providerReferencePath:e.providerReferencePath,values:t}:void 0};return[`statusMappings`,`targetModule`,`targetField`,`stageMatchField`,`stageMatchValue`,`stageStatusField`,`providerStatusPath`,`providerReferencePath`].forEach(e=>delete n[e]),n}function wT({open:e,integration:t,onClose:r,onSaved:i}){let[a]=s.Form.useForm(),[u,d]=(0,o.useState)(!1),[f,p]=(0,o.useState)(!1),m=s.Form.useWatch(`updateMethod`,a),h=s.Form.useWatch(`authType`,a),g=m===`API`,_=h===`OAUTH2_CLIENT_CREDENTIALS`;(0,o.useEffect)(()=>{if(!e)return;let n=t?.statusMapping??{};a.setFieldsValue({...xT,...t,authValue:``,clientSecret:``,webhookSecret:``,targetModule:n.targetModule??``,targetField:n.targetField??``,stageMatchField:n.stageMatchField??``,stageMatchValue:n.stageMatchValue??``,stageStatusField:n.stageStatusField??``,providerStatusPath:n.providerStatusPath??``,providerReferencePath:n.providerReferencePath??``,statusMappings:Object.entries(n.values??{}).map(([e,t])=>({providerStatus:e,applicationStatus:t})).concat(Object.keys(n.values??{}).length?[]:[{providerStatus:``,applicationStatus:``}])})},[a,t,e]);async function v(){try{let e=CT(await a.validateFields());d(!0),await n.ii(e),s.message.success(`Integration saved`),i()}catch(e){e?.errorFields||s.message.error(e?.message||`Could not save integration`)}finally{d(!1)}}async function y(){try{let e=await a.validateFields([`integrationKey`,`baseUrl`,`testPath`,`authType`,`authHeader`,`authValue`,`clientId`,`clientSecret`,`tokenUrl`]);p(!0);let t=await n.di(CT({...a.getFieldsValue(!0),...e}));s.message.success(t?.message||`Connection successful${t?.statusCode?` (${t.statusCode})`:``}`)}catch(e){e?.errorFields||s.message.error(e?.message||`Connection test failed`)}finally{p(!1)}}return(0,l.jsx)(s.Drawer,{open:e,onClose:r,width:`min(680px, 96vw)`,title:t?`Edit ${t.label}`:`Add Integration`,destroyOnClose:!0,extra:(0,l.jsxs)(s.Space,{children:[g&&(0,l.jsx)(s.Button,{loading:f,onClick:y,children:`Test Connection`}),(0,l.jsx)(s.Button,{onClick:r,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:u,onClick:v,children:`Save`})]}),children:(0,l.jsxs)(s.Form,{form:a,layout:`vertical`,initialValues:xT,children:[(0,l.jsxs)(s.Row,{gutter:16,children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`label`,label:`Integration Name`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`Background Check`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`integrationKey`,label:`Integration Key`,rules:[{required:!0},{pattern:/^[a-z][a-z0-9_-]{1,63}$/,message:`Use lowercase letters, numbers, _ or -`}],children:(0,l.jsx)(s.Input,{placeholder:`bgc`,disabled:!!t})})})]}),(0,l.jsxs)(s.Row,{gutter:16,children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`category`,label:`Category`,children:(0,l.jsx)(s.Select,{options:[{value:`ONBOARDING`,label:`Onboarding`},{value:`HRMS`,label:`HRMS`},{value:`PAYROLL`,label:`Payroll`},{value:`ESIGNATURE`,label:`E-Signature`},{value:`VMS`,label:`VMS`},{value:`GENERAL`,label:`General / Custom`}]})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`enabled`,label:`Enabled`,valuePropName:`checked`,children:(0,l.jsx)(s.Switch,{})})})]}),(0,l.jsx)(s.Form.Item,{name:`updateMethod`,label:`Update Method`,rules:[{required:!0}],children:(0,l.jsx)(s.Radio.Group,{optionType:`button`,buttonStyle:`solid`,options:[{label:`Manual Update`,value:`MANUAL`},{label:`API Integration`,value:`API`}]})}),!g&&(0,l.jsx)(s.Alert,{type:`info`,showIcon:!0,message:`This integration will use manual updates.`}),g&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.Alert,{type:t?.credentialsConfigured?`success`:`warning`,showIcon:!0,message:t?.credentialsConfigured?`Credentials configured`:`Credentials required`,description:`Secrets are write-only. Leave a secret blank while editing to keep its current value.`,style:{marginBottom:16}}),(0,l.jsxs)(s.Row,{gutter:16,children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`provider`,label:`Provider`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`Provider name`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`baseUrl`,label:`API Base URL`,rules:[{required:!0,type:`url`}],children:(0,l.jsx)(s.Input,{placeholder:`https://api.provider.com`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`createPath`,label:`Create/Submit Path`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`/v1/requests`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`statusPath`,label:`Status Path`,rules:[{required:!0}],tooltip:`Use {referenceId} as a placeholder.`,children:(0,l.jsx)(s.Input,{placeholder:`/v1/requests/{referenceId}`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`testPath`,label:`Test Connection Path`,rules:[{required:!0}],tooltip:`A safe GET endpoint used only to validate URL and credentials.`,children:(0,l.jsx)(s.Input,{placeholder:`/v1/health`})})})]}),(0,l.jsx)(s.Form.Item,{name:`authType`,label:`Authentication Type`,rules:[{required:!0}],children:(0,l.jsx)(s.Select,{options:ST})}),_?(0,l.jsxs)(s.Row,{gutter:16,children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`clientId`,label:`Client ID`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`clientSecret`,label:`Client Secret`,children:(0,l.jsx)(s.Input.Password,{placeholder:t?.credentialsConfigured?`Unchanged`:`Required`})})}),(0,l.jsx)(s.Col,{xs:24,children:(0,l.jsx)(s.Form.Item,{name:`tokenUrl`,label:`Token URL`,rules:[{required:!0,type:`url`}],children:(0,l.jsx)(s.Input,{})})})]}):(0,l.jsxs)(s.Row,{gutter:16,children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`authHeader`,label:`Authentication Header`,children:(0,l.jsx)(s.Input,{placeholder:`x-api-key`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`authValue`,label:`API Credential`,children:(0,l.jsx)(s.Input.Password,{placeholder:t?.credentialsConfigured?`Unchanged`:`Required`})})})]}),(0,l.jsx)(s.Form.Item,{name:`webhookSecret`,label:`Webhook Signing Secret (optional)`,children:(0,l.jsx)(s.Input.Password,{placeholder:t?.webhookConfigured?`Unchanged`:``})}),(0,l.jsxs)(Z,{title:`Status Mapping`,children:[(0,l.jsx)(bT,{type:`secondary`,children:`Map a status from the provider response into a module field or a matching workflow stage.`}),(0,l.jsxs)(s.Row,{gutter:16,style:{marginTop:16},children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`targetModule`,label:`Target Module`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`onboarding`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`targetField`,label:`Target Field`,rules:[{required:!0}],tooltip:`Use stages for a stage-array update, or a direct field name.`,children:(0,l.jsx)(s.Input,{placeholder:`stages`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`providerStatusPath`,label:`Provider Status JSON Path`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`data.status`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{name:`providerReferencePath`,label:`Provider Reference JSON Path`,children:(0,l.jsx)(s.Input,{placeholder:`data.id`})})}),(0,l.jsx)(s.Col,{xs:24,md:8,children:(0,l.jsx)(s.Form.Item,{name:`stageMatchField`,label:`Stage Match Field`,children:(0,l.jsx)(s.Input,{placeholder:`stageCode`})})}),(0,l.jsx)(s.Col,{xs:24,md:8,children:(0,l.jsx)(s.Form.Item,{name:`stageMatchValue`,label:`Stage Match Value`,children:(0,l.jsx)(s.Input,{placeholder:`BGC`})})}),(0,l.jsx)(s.Col,{xs:24,md:8,children:(0,l.jsx)(s.Form.Item,{name:`stageStatusField`,label:`Stage Status Field`,children:(0,l.jsx)(s.Input,{placeholder:`status`})})})]}),(0,l.jsx)(bT,{strong:!0,children:`Status Values`}),(0,l.jsx)(s.Form.List,{name:`statusMappings`,children:(e,{add:t,remove:n})=>(0,l.jsxs)(s.Space,{direction:`vertical`,style:{width:`100%`,marginTop:8},children:[e.map(e=>(0,l.jsxs)(s.Row,{gutter:12,children:[(0,l.jsx)(s.Col,{flex:`1 1 220px`,children:(0,l.jsx)(s.Form.Item,{...e,name:[e.name,`providerStatus`],rules:[{required:!0,message:`Provider status is required`}],children:(0,l.jsx)(s.Input,{placeholder:`Provider status, e.g. completed`})})}),(0,l.jsx)(s.Col,{flex:`1 1 220px`,children:(0,l.jsx)(s.Form.Item,{...e,name:[e.name,`applicationStatus`],rules:[{required:!0,message:`Application status is required`}],children:(0,l.jsx)(s.Input,{placeholder:`Zinnext status, e.g. CLEARED`})})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{danger:!0,onClick:()=>n(e.name),children:`Remove`})})]},e.key)),(0,l.jsx)(s.Button,{type:`dashed`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>t({providerStatus:``,applicationStatus:``}),children:`Add Status Mapping`})]})})]})]})]})})}function TT(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(null),p=(0,o.useCallback)(()=>{i(!0),n.Ar().then(e=>t(Array.isArray(e)?e:[])).catch(e=>s.message.error(e?.message||`Could not load integrations`)).finally(()=>i(!1))},[]);(0,o.useEffect)(()=>{queueMicrotask(p)},[p]);async function m(e){try{await n.ir(e),s.message.success(`Integration deleted`),p()}catch(e){s.message.error(e?.message||`Could not delete integration`)}}return(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.ApiOutlined,{}),title:`Integrations`,extra:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:p,children:`Reload`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>{f(null),u(!0)},children:`Add Integration`})]}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(bT,{type:`secondary`,children:`Configure reusable manual or API integrations for onboarding, payroll, e-signature, VMS, HRMS, and custom workflows.`})]}),(0,l.jsx)(Z,{title:`${e.length} integration${e.length===1?``:`s`}`,children:(0,l.jsx)(s.Table,{rowKey:`integrationKey`,columns:[{title:`Integration`,key:`name`,render:(e,t)=>(0,l.jsxs)(`div`,{className:`admin-config-primary-cell`,children:[(0,l.jsx)(bT,{strong:!0,children:t.label}),(0,l.jsx)(bT,{type:`secondary`,code:!0,children:t.integrationKey})]})},{title:`Category`,dataIndex:`category`,width:130,render:e=>e||`GENERAL`},{title:`Method`,dataIndex:`updateMethod`,width:110,render:e=>(0,l.jsx)(s.Tag,{color:e===`API`?`blue`:`default`,children:e})},{title:`Provider`,dataIndex:`provider`,render:e=>e||`—`},{title:`Enabled`,dataIndex:`enabled`,width:90,render:e=>(0,l.jsx)(s.Tag,{color:e?`green`:`default`,children:e?`Yes`:`No`})},{title:``,key:`actions`,width:90,render:(e,t)=>(0,l.jsxs)(s.Space,{size:2,children:[(0,l.jsx)(s.Button,{type:`text`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{f(t),u(!0)}}),(0,l.jsx)(s.Popconfirm,{title:`Delete this integration?`,onConfirm:()=>m(t.integrationKey),children:(0,l.jsx)(s.Button,{type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})]})}],dataSource:e,loading:r,size:`small`,className:`fg-table`})}),(0,l.jsx)(wT,{open:a,integration:d,onClose:()=>u(!1),onSaved:()=>{u(!1),p()}})]})}var{Text:$}=s.Typography;function ET({rows:e,onChange:t,keyPlaceholder:n,valuePlaceholder:r}){let i=(n,r)=>t(e.map((e,t)=>t===n?{...e,...r}:e)),a=n=>t(e.filter((e,t)=>t!==n));return(0,l.jsxs)(`div`,{children:[e.map((e,t)=>(0,l.jsxs)(`div`,{style:{display:`flex`,gap:6,marginTop:6},children:[(0,l.jsx)(s.Input,{size:`small`,style:{flex:1},placeholder:n,value:e.key,onChange:e=>i(t,{key:e.target.value}),className:`fg-mono-input`}),(0,l.jsx)(`span`,{style:{color:`#94a3b8`,alignSelf:`center`},children:`→`}),(0,l.jsx)(s.Input,{size:`small`,style:{flex:1},placeholder:r,value:e.value,onChange:e=>i(t,{value:e.target.value}),className:`fg-mono-input`}),(0,l.jsx)(s.Button,{size:`small`,type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{}),onClick:()=>a(t)})]},t)),(0,l.jsx)(s.Button,{size:`small`,type:`dashed`,icon:(0,l.jsx)(c.PlusOutlined,{}),style:{marginTop:6},onClick:()=>t([...e,{key:``,value:``}]),children:`Add`})]})}function DT({rows:e,onChange:t,keyPlaceholder:n=`field`,valuePlaceholder:r=`literal or {{field.path}}`}){let i=(n,r)=>t(e.map((e,t)=>t===n?{...e,...r}:e)),a=n=>t(e.filter((e,t)=>t!==n));return(0,l.jsxs)(`div`,{children:[e.map((e,t)=>(0,l.jsxs)(`div`,{style:{display:`flex`,gap:6,marginTop:6},children:[(0,l.jsx)(s.Input,{size:`small`,style:{flex:1},placeholder:n,value:e.key,onChange:e=>i(t,{key:e.target.value}),className:`fg-mono-input`}),(0,l.jsx)(s.Input,{size:`small`,style:{flex:1.6},placeholder:r,value:e.value,onChange:e=>i(t,{value:e.target.value}),className:`fg-mono-input`}),(0,l.jsx)(s.Button,{size:`small`,type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{}),onClick:()=>a(t)})]},t)),(0,l.jsx)(s.Button,{size:`small`,type:`dashed`,icon:(0,l.jsx)(c.PlusOutlined,{}),style:{marginTop:6},onClick:()=>t([...e,{key:``,value:``}]),children:`Add`}),(0,l.jsxs)($,{type:`secondary`,style:{fontSize:11,display:`block`,marginTop:4},children:[`Values are read as JSON when possible (true, 123, ["a","b"]) — otherwise kept as literal text. Use `,(0,l.jsx)(`code`,{children:`{{field.path}}`}),` to reference a payload field, or `,(0,l.jsx)(`code`,{children:`{{now}}`}),` for the current time.`]})]})}function OT(e){return Object.entries(e??{}).map(([e,t])=>({key:e,value:String(t??``)}))}function kT(e){let t={};for(let n of e??[])n.key?.trim()&&(t[n.key.trim()]=n.value??``);return t}function AT(e){return Object.entries(e??{}).map(([e,t])=>({key:e,value:typeof t==`string`?t:JSON.stringify(t)}))}function jT(e){let t={};for(let n of e??[]){if(!n.key?.trim())continue;let e=n.value;if(typeof e==`string`){let t=e.trim();if(t!==``)try{e=JSON.parse(t)}catch{}}t[n.key.trim()]=e}return t}function MT({open:e,rule:t,onClose:n,onSave:r}){let[i,a]=(0,o.useState)(()=>({sourceModule:``,sourceIdField:``,required:!1,...t??{},fieldMapRows:OT(t?.fieldMap)})),u=(e,t)=>a(n=>({...n,[e]:t}));return(0,l.jsx)(s.Modal,{open:e,onCancel:n,width:640,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,l.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,l.jsx)(c.DatabaseOutlined,{}),` `,t?`Edit Denormalize Rule`:`New Denormalize Rule`]}),footer:(0,l.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,l.jsx)(s.Button,{onClick:n,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),onClick:()=>{if(!i.sourceModule?.trim())return s.message.error(`Source module is required`);if(!i.sourceIdField?.trim())return s.message.error(`Source id field is required`);let{fieldMapRows:e,...t}=i;r({...t,fieldMap:kT(e)})},children:`Apply`})]}),children:(0,l.jsxs)(`div`,{className:`fg-form-section`,children:[(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Source module`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`job`,value:i.sourceModule??``,onChange:e=>u(`sourceModule`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Source id field (on THIS payload)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`jobId`,value:i.sourceIdField??``,onChange:e=>u(`sourceIdField`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:14},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!i.required,onChange:e=>u(`required`,e)}),(0,l.jsx)($,{style:{fontSize:13},children:`Required — block the write if the source record can't be found`})]}),(0,l.jsxs)(`div`,{style:{marginTop:16},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Field map (source field → this payload's field)`}),(0,l.jsx)(ET,{rows:i.fieldMapRows??[],onChange:e=>u(`fieldMapRows`,e),keyPlaceholder:`jobTitle`,valuePlaceholder:`jobTitle`})]})]})})}function NT({open:e,rule:t,onClose:n,onSave:r}){let[i,a]=(0,o.useState)(()=>({sourceField:``,targetField:``,sourceCollection:``,idField:``,idOutputKey:``,stampNow:``,...t??{},fieldMapRows:OT(t?.fieldMap)})),u=(e,t)=>a(n=>({...n,[e]:t}));return(0,l.jsx)(s.Modal,{open:e,onCancel:n,width:640,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,l.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,l.jsx)(c.ApartmentOutlined,{}),` `,t?`Edit Array Enrichment`:`New Array Enrichment`]}),footer:(0,l.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,l.jsx)(s.Button,{onClick:n,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),onClick:()=>{if(!i.sourceField?.trim())return s.message.error(`Source field is required`);if(!i.targetField?.trim())return s.message.error(`Target field is required`);let{fieldMapRows:e,...t}=i;r({...t,fieldMap:kT(e)})},children:`Apply`})]}),children:(0,l.jsxs)(`div`,{className:`fg-form-section`,children:[(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Source field (array of ids on this payload)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`recruitersData`,value:i.sourceField??``,onChange:e=>u(`sourceField`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Target field (enriched array written here)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`recruiters`,value:i.targetField??``,onChange:e=>u(`targetField`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Source collection`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`users (default)`,value:i.sourceCollection??``,onChange:e=>u(`sourceCollection`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Id field on that collection`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`legacyUserId (default)`,value:i.idField??``,onChange:e=>u(`idField`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{style:{marginTop:16},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Field map (source collection field → output key)`}),(0,l.jsx)(ET,{rows:i.fieldMapRows??[],onChange:e=>u(`fieldMapRows`,e),keyPlaceholder:`firstName`,valuePlaceholder:`recruiterName`})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Also write the matched id as`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`recruiterId`,value:i.idOutputKey??``,onChange:e=>u(`idOutputKey`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Also stamp the current time as`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`assignedDateTime`,value:i.stampNow??``,onChange:e=>u(`stampNow`,e.target.value),className:`fg-mono-input`})]})]})]})})}function PT({open:e,rule:t,onClose:n,onSave:r}){let[i,a]=(0,o.useState)(()=>({sourceField:``,targetField:``,uploadedFileNameField:``,uniqueNameField:``,uploadedAtField:``,uploadedByField:``,arrayMode:!1,nameFromField:``,nameOutputField:``,historyField:``,historySnapshotKey:``,historyReason:``,...t??{},staticFieldRows:OT(t?.staticFields),arrayFieldNameRows:OT(t?.arrayFieldNames)})),u=(e,t)=>a(n=>({...n,[e]:t}));return(0,l.jsx)(s.Modal,{open:e,onCancel:n,width:760,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,l.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,l.jsx)(c.DatabaseOutlined,{}),` `,t?`Edit File Field Map`:`New File Field Map`]}),footer:(0,l.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,l.jsx)(s.Button,{onClick:n,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),onClick:()=>{if(!i.sourceField?.trim())return s.message.error(`Source field (the multipart upload key) is required`);if(!i.targetField?.trim())return s.message.error(`Target field is required`);let{staticFieldRows:e,arrayFieldNameRows:t,...n}=i;r({...n,staticFields:kT(e),arrayFieldNames:kT(t)})},children:`Apply`})]}),children:(0,l.jsxs)(`div`,{className:`fg-form-section`,children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:10},children:`Turns one uploaded file field into a nested object (or array of objects) instead of a flat S3 path string — for schemas like a candidate's resume/passport/visa that store location + filename + who/when as sub-fields.`}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Source field (multipart upload key)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`resume`,value:i.sourceField??``,onChange:e=>u(`sourceField`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsxs)($,{type:`secondary`,style:{fontSize:12},children:[`Target field `,i.arrayMode?`(array)`:`(location sub-field)`]}),(0,l.jsx)(s.Input,{size:`small`,placeholder:i.arrayMode?`documents`:`resume.location`,value:i.targetField??``,onChange:e=>u(`targetField`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:14},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!i.arrayMode,onChange:e=>u(`arrayMode`,e)}),(0,l.jsx)($,{style:{fontSize:13},children:`Array mode — every uploaded file becomes one element (e.g. "documents")`})]}),i.arrayMode?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{style:{marginTop:12},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Sub-field names (location / uploadedFileName / uniqueName → this schema's names)`}),(0,l.jsx)(ET,{rows:i.arrayFieldNameRows??[],onChange:e=>u(`arrayFieldNameRows`,e),keyPlaceholder:`location`,valuePlaceholder:`documentCopyLocation`})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Take each element's display name from (payload array field)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`documents`,value:i.nameFromField??``,onChange:e=>u(`nameFromField`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`...reading its field`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`documentName`,value:i.nameOutputField??``,onChange:e=>u(`nameOutputField`,e.target.value),className:`fg-mono-input`})]})]})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Original filename field`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`resume.uploadedFileName`,value:i.uploadedFileNameField??``,onChange:e=>u(`uploadedFileNameField`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Unique name field`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`resume.uniqueName`,value:i.uniqueNameField??``,onChange:e=>u(`uniqueNameField`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Uploaded-at field`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`resume.uploadedAt`,value:i.uploadedAtField??``,onChange:e=>u(`uploadedAtField`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Uploaded-by field`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`resume.uploadedBy`,value:i.uploadedByField??``,onChange:e=>u(`uploadedByField`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{style:{marginTop:12},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Static fields (literal value written alongside the upload)`}),(0,l.jsx)(ET,{rows:i.staticFieldRows??[],onChange:e=>u(`staticFieldRows`,e),keyPlaceholder:`resume.source`,valuePlaceholder:`candidate`})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Append a snapshot to (history array field)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`resumeHistory`,value:i.historyField??``,onChange:e=>u(`historyField`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`...under snapshot key`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`resume`,value:i.historySnapshotKey??``,onChange:e=>u(`historySnapshotKey`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`...with reason`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`Initial resume upload`,value:i.historyReason??``,onChange:e=>u(`historyReason`,e.target.value),className:`fg-mono-input`})]})]})]})]})})}function FT({open:e,rule:t,onClose:n,onSave:r}){let[i,a]=(0,o.useState)(()=>({name:``,seedField:``,direction:`up`,stopRole:0,includeSeed:!0,...t??{}})),u=(e,t)=>a(n=>({...n,[e]:t}));return(0,l.jsx)(s.Modal,{open:e,onCancel:n,width:620,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,l.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,l.jsx)(c.ApartmentOutlined,{}),` `,t?`Edit Hierarchy Expansion`:`New Hierarchy Expansion`]}),footer:(0,l.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,l.jsx)(s.Button,{onClick:n,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),onClick:()=>{if(!i.name?.trim())return s.message.error(`Name is required — this is how RelatedUpdates/Notify reference the result`);if(!/^[a-zA-Z0-9_]+$/.test(i.name))return s.message.error(`Name: letters, numbers, underscores only`);r(i)},children:`Apply`})]}),children:(0,l.jsxs)(`div`,{className:`fg-form-section`,children:[(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Name`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`chain`,value:i.name??``,onChange:e=>u(`name`,e.target.value),className:`fg-mono-input`}),(0,l.jsxs)($,{type:`secondary`,style:{fontSize:11},children:[`Referenced as `,(0,l.jsx)(`code`,{children:`{{hierarchy.`+(i.name||`name`)+`}}`})]})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Seed field (blank = the caller)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`recruitersData`,value:i.seedField??``,onChange:e=>u(`seedField`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Direction`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},value:i.direction||`up`,onChange:e=>u(`direction`,e),options:[{value:`up`,label:`Up — toward admin (reporting chain)`},{value:`down`,label:`Down — toward subordinates (team)`}]})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Stop at role id (up only, 0 = walk to the top)`}),(0,l.jsx)(s.InputNumber,{size:`small`,style:{width:`100%`},min:0,value:i.stopRole??0,onChange:e=>u(`stopRole`,e??0),disabled:i.direction!==`up`})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:14},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:i.includeSeed!==!1,onChange:e=>u(`includeSeed`,e)}),(0,l.jsx)($,{style:{fontSize:13},children:`Include the seed user(s) themselves in the result`})]})]})})}function IT({open:e,rule:t,hierarchyNames:n,onClose:r,onSave:i}){let[a,u]=(0,o.useState)(()=>({collectionName:``,targetModule:``,matchField:``,scopeTenant:!1,forEach:``,insertMode:!!(t?.insertIfMissing&&Object.keys(t.insertIfMissing).length),...t??{},extraFilterRows:AT(t?.extraFilter),pullRows:AT(t?.pull),pushRows:AT(t?.push),setRows:AT(t?.set),setIfNonBlankRows:AT(t?.setIfNonBlank),insertIfMissingRows:AT(t?.insertIfMissing)})),d=(e,t)=>u(n=>({...n,[e]:t})),f=()=>{if(!a.collectionName?.trim()&&!a.targetModule?.trim())return s.message.error(`Set either a collection name or a target module`);let{extraFilterRows:e,pullRows:t,pushRows:n,setRows:r,setIfNonBlankRows:o,insertIfMissingRows:c,insertMode:l,...u}=a;i({...u,extraFilter:jT(e),pull:l?{}:jT(t),push:l?{}:jT(n),set:l?{}:jT(r),setIfNonBlank:l?{}:jT(o),insertIfMissing:l?jT(c):{}})},p=(n??[]).map(e=>({value:`hierarchy.${e}`,label:`{{hierarchy.${e}}}`}));return(0,l.jsx)(s.Modal,{open:e,onCancel:r,width:820,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,l.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,l.jsx)(c.ThunderboltOutlined,{}),` `,t?`Edit Related Update`:`New Related Update`]}),footer:(0,l.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,l.jsx)(s.Button,{onClick:r,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),onClick:f,children:`Apply`})]}),children:(0,l.jsxs)(`div`,{className:`fg-form-section`,children:[(0,l.jsx)(`div`,{className:`fg-form-section-label`,children:`Target`}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Collection name (used verbatim)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`hiringProgress`,value:a.collectionName??``,onChange:e=>d(`collectionName`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`— or — target module`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`job`,value:a.targetModule??``,onChange:e=>d(`targetModule`,e.target.value),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Match field (this payload's field holding the target _id)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`jobId (blank for a tenant-scoped board)`,value:a.matchField??``,onChange:e=>d(`matchField`,e.target.value),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Repeat once per element of (ForEach)`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},allowClear:!0,showSearch:!0,placeholder:`e.g. {{hierarchy.chain}}`,value:a.forEach||void 0,onChange:e=>d(`forEach`,e??``),options:p})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:14},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!a.scopeTenant,onChange:e=>d(`scopeTenant`,e)}),(0,l.jsx)($,{style:{fontSize:13},children:`Scope filter to the caller's tenant/business/businessUnit`})]}),(0,l.jsxs)(`div`,{style:{marginTop:14},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Extra filter (merged into the match filter)`}),(0,l.jsx)(DT,{rows:a.extraFilterRows??[],onChange:e=>d(`extraFilterRows`,e),keyPlaceholder:`recruiterId`,valuePlaceholder:`{"$in":"{{hierarchy.chain}}"}`})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:18},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!a.insertMode,onChange:e=>d(`insertMode`,e)}),(0,l.jsx)($,{style:{fontSize:13},children:`Insert-only-if-missing (seed a new document instead of updating an existing one)`})]}),a.insertMode?(0,l.jsxs)(`div`,{style:{marginTop:10},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Document to insert when the filter matches nothing`}),(0,l.jsx)(DT,{rows:a.insertIfMissingRows??[],onChange:e=>d(`insertIfMissingRows`,e),keyPlaceholder:`hiringProgressJobStatus`,valuePlaceholder:`"unread"`})]}):(0,l.jsx)(s.Tabs,{size:`small`,style:{marginTop:10},items:[{key:`pull`,label:`Pull`,children:(0,l.jsx)(DT,{rows:a.pullRows??[],onChange:e=>d(`pullRows`,e),keyPlaceholder:`submitted`,valuePlaceholder:`{"candidateId":"{{applicantId}}"}`})},{key:`push`,label:`Push`,children:(0,l.jsx)(DT,{rows:a.pushRows??[],onChange:e=>d(`pushRows`,e),keyPlaceholder:`submitted`,valuePlaceholder:`{"status":"{{submissionStatus}}"}`})},{key:`set`,label:`Set`,children:(0,l.jsx)(DT,{rows:a.setRows??[],onChange:e=>d(`setRows`,e),keyPlaceholder:`hiringProgressJobStatus`,valuePlaceholder:`"unread"`})},{key:`setIfNonBlank`,label:`Set if non-blank`,children:(0,l.jsx)(DT,{rows:a.setIfNonBlankRows??[],onChange:e=>d(`setIfNonBlankRows`,e),keyPlaceholder:`resume.location`,valuePlaceholder:`{{resume.location}}`})}]})]})})}function LT({icon:e,title:t,description:n,rules:r,columns:i,onAdd:a,onEdit:o,onDelete:u}){return(0,l.jsxs)(Z,{title:(0,l.jsxs)(`span`,{children:[e,` `,t]}),extra:(0,l.jsx)(s.Button,{size:`small`,type:`dashed`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:a,children:`Add`}),styles:{body:{paddingTop:8}},children:[n&&(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:10},children:n}),(0,l.jsx)(s.Table,{rowKey:(e,t)=>t,dataSource:r,columns:[...i,{title:``,key:`actions`,width:80,align:`right`,render:(e,t,n)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Tooltip,{title:`Edit`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>o(n,t)})}),(0,l.jsx)(s.Tooltip,{title:`Delete`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{}),onClick:()=>u(n)})})]})}],pagination:!1,size:`small`,className:`fg-table`,locale:{emptyText:(0,l.jsx)(s.Empty,{image:s.Empty.PRESENTED_IMAGE_SIMPLE,description:`Not configured`})}})]})}var RT={sequence:null,duplicateCheck:null,fileVersioning:null,denormalizations:[],arrayEnrichments:[],fileFieldMaps:[],sanitizeFields:[],defaults:{},hierarchyExpands:[],relatedUpdates:[],notify:null,cacheInvalidate:[]};function zT(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(!0),[a,u]=(0,o.useState)(``),[d,f]=(0,o.useState)({storage:`mongo`}),[p,m]=(0,o.useState)(`mongo`),[h,g]=(0,o.useState)(RT),[_,v]=(0,o.useState)(!1),[y,b]=(0,o.useState)(!1),[x,S]=(0,o.useState)(``),[C,w]=(0,o.useState)(null),[T,E]=(0,o.useState)(null),[D,O]=(0,o.useState)(null),[k,A]=(0,o.useState)(null),[j,M]=(0,o.useState)(null);(0,o.useEffect)(()=>{n.xr().then(e=>{let n=Gx(e).map(({value:e,label:t})=>({key:e,label:t}));t(n),n.length&&u(n[0].key)}).catch(()=>t([])).finally(()=>i(!1))},[]),(0,o.useEffect)(()=>{if(!a)return;let e=!1;return(async()=>{v(!0),S(``);try{let t=await n.Lr(a);if(e)return;let r=t.gateway??{storage:`mongo`};f(r),m(r.storage||`mongo`),g({...RT,...t.strategies??{}})}catch(t){e||S(t?.message||`Failed to load automations`)}finally{e||v(!1)}})(),()=>{e=!0}},[a]);let N=(0,o.useMemo)(()=>(h.hierarchyExpands??[]).map(e=>e.name).filter(Boolean),[h.hierarchyExpands]);function P(e,t){g(n=>({...n,[e]:t}))}function F(e,t){g(n=>{let r=n.duplicateCheck??{},i=[...r.stages??[]];return i[e]=t,{...n,duplicateCheck:{...r,stages:i}}})}function I(){b(!0);let e={...h,denormalizations:h.denormalizations?.length?h.denormalizations:void 0,arrayEnrichments:h.arrayEnrichments?.length?h.arrayEnrichments:void 0,fileFieldMaps:h.fileFieldMaps?.length?h.fileFieldMaps:void 0,sanitizeFields:h.sanitizeFields?.length?h.sanitizeFields:void 0,hierarchyExpands:h.hierarchyExpands?.length?h.hierarchyExpands:void 0,relatedUpdates:h.relatedUpdates?.length?h.relatedUpdates:void 0,cacheInvalidate:h.cacheInvalidate?.length?h.cacheInvalidate:void 0,defaults:Object.keys(h.defaults??{}).length?h.defaults:void 0};n.ai(a,{gateway:d,strategies:e}).then(()=>{m(d.storage||`mongo`),s.message.success(`Automations saved`)}).catch(e=>s.message.error(e?.message||`Could not save automations`)).finally(()=>b(!1))}function L(){if((d.storage||`mongo`)!==p){s.Modal.confirm({title:`Change how this module persists writes?`,content:`You're switching ${a} from "${p}" to "${d.storage}". `+(d.storage===`mongo`?`This module will stop calling its downstream service and this gateway will own the write + every Strategy below.`:`This module will stop using the Strategies below and go back to calling its downstream service.`)+` Make sure the downstream service / e2e checks are ready before confirming.`,okText:`Confirm cutover`,okButtonProps:{danger:!0},onOk:I});return}I()}let R=[{title:`Source module`,dataIndex:`sourceModule`,key:`sourceModule`,render:e=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Source id field`,dataIndex:`sourceIdField`,key:`sourceIdField`},{title:`Fields`,key:`fields`,render:(e,t)=>(0,l.jsx)(s.Badge,{count:Object.keys(t.fieldMap??{}).length,showZero:!0,color:`var(--color-brand)`})},{title:`Required`,dataIndex:`required`,key:`required`,width:90,render:e=>e?(0,l.jsx)(s.Tag,{color:`volcano`,children:`Required`}):(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`optional`})}],z=[{title:`Source field`,dataIndex:`sourceField`,key:`sourceField`,render:e=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Target field`,dataIndex:`targetField`,key:`targetField`,render:e=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`From collection`,key:`coll`,render:(e,t)=>t.sourceCollection||`users`},{title:`Fields`,key:`fields`,render:(e,t)=>(0,l.jsx)(s.Badge,{count:Object.keys(t.fieldMap??{}).length,showZero:!0,color:`var(--color-brand)`})}],B=[{title:`Source field`,dataIndex:`sourceField`,key:`sourceField`,render:e=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Target field`,dataIndex:`targetField`,key:`targetField`,render:e=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Mode`,dataIndex:`arrayMode`,key:`arrayMode`,width:100,render:e=>e?(0,l.jsx)(s.Tag,{color:`blue`,children:`Array`}):(0,l.jsx)(s.Tag,{children:`Single`})},{title:`History`,dataIndex:`historyField`,key:`historyField`,render:e=>e||(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`—`})}],V=[{title:`Name`,dataIndex:`name`,key:`name`,render:e=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:`{{hierarchy.`+e+`}}`})},{title:`Seed field`,dataIndex:`seedField`,key:`seedField`,render:e=>e||(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`caller`})},{title:`Direction`,dataIndex:`direction`,key:`direction`,render:e=>(0,l.jsx)(s.Tag,{color:e===`down`?`blue`:`purple`,children:e===`down`?`Down — team`:`Up — chain`})},{title:`Stop role`,dataIndex:`stopRole`,key:`stopRole`,width:90,render:e=>e||(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`top`})}],ee=[{title:`Target`,key:`target`,render:(e,t)=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:t.collectionName||t.targetModule})},{title:`Match`,key:`match`,render:(e,t)=>t.matchField||(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`tenant-scoped`})},{title:`For each`,key:`forEach`,render:(e,t)=>t.forEach?(0,l.jsx)(s.Tag,{color:`geekblue`,children:`{{${t.forEach}}}`}):(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`once`})},{title:`Mode`,key:`mode`,render:(e,t)=>Object.keys(t.insertIfMissing??{}).length?(0,l.jsx)(s.Tag,{color:`green`,children:`Insert if missing`}):(0,l.jsx)(s.Tag,{children:`Update`})}],te=e.map(e=>({key:e.key,label:e.label}));return(0,l.jsxs)(`div`,{className:`fg-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.ThunderboltOutlined,{}),title:`Automations`,extra:(0,l.jsx)(s.Button,{type:`primary`,size:`small`,icon:(0,l.jsx)(c.SaveOutlined,{}),loading:y,disabled:!a,onClick:L,children:`Save Automations`}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)($,{type:`secondary`,style:{fontSize:13},children:`Config-driven side-effects the common CRUD gateway runs around a create — reference ids, duplicate checks, cross-module field snapshots, reporting-chain hierarchy expansion, board updates, notifications, cache invalidation. Nothing here is module-specific: the same engine serves every module.`})]}),(0,l.jsx)(Z,{styles:{body:{paddingTop:8}},children:(0,l.jsxs)(s.Spin,{spinning:r,children:[(0,l.jsx)(s.Tabs,{activeKey:a,onChange:u,items:te.map(e=>({...e,children:null})),className:`admin-module-tabs`}),x&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,message:x,style:{marginBottom:12}}),(0,l.jsxs)(s.Spin,{spinning:_,children:[(0,l.jsxs)(Z,{title:`Gateway`,styles:{body:{paddingTop:8}},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:10},children:`Selects how a write to this module persists. "Proxy" forwards to a downstream microservice (which owns every side-effect below itself). "Mongo" makes THIS gateway own the write and run every Strategy configured below.`}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Storage`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},value:d.storage||`mongo`,onChange:e=>f(t=>({...t,storage:e})),options:[{value:`mongo`,label:`Mongo — this gateway owns the write`},{value:`proxy`,label:`Proxy — forward to a downstream service`}]})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`File field key`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`file`,value:d.fileKey??``,onChange:e=>f(t=>({...t,fileKey:e.target.value})),className:`fg-mono-input`})]})]}),d.storage===`proxy`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Base URL env var`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`JOBS_SERVICE_URL`,value:d.baseUrlEnv??``,onChange:e=>f(t=>({...t,baseUrlEnv:e.target.value})),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Base URL (fallback)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`http://...`,value:d.baseUrl??``,onChange:e=>f(t=>({...t,baseUrl:e.target.value})),className:`fg-mono-input`})]})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Create path`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`/v1/jobs`,value:d.createPath??``,onChange:e=>f(t=>({...t,createPath:e.target.value})),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Update path (%s = id)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`/v1/edit/%s`,value:d.updatePath??``,onChange:e=>f(t=>({...t,updatePath:e.target.value})),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Update method`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},value:d.updateMethod||`PUT`,onChange:e=>f(t=>({...t,updateMethod:e})),options:[`PUT`,`POST`,`PATCH`].map(e=>({value:e,label:e}))})]})]})]})]}),(0,l.jsxs)(Z,{title:`Reference ID (Sequence)`,styles:{body:{paddingTop:8}},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:10},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!h.sequence,onChange:e=>P(`sequence`,e?{field:``,prefix:``,counterKey:``}:null)}),(0,l.jsxs)($,{style:{fontSize:13},children:[`Generate a "`,`{prefix}{n}`,`" reference id on create`]})]}),h.sequence&&(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Payload field`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`submissionId`,value:h.sequence.field??``,onChange:e=>P(`sequence`,{...h.sequence,field:e.target.value}),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Prefix`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`sub`,value:h.sequence.prefix??``,onChange:e=>P(`sequence`,{...h.sequence,prefix:e.target.value}),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Counter key`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`submissions`,value:h.sequence.counterKey??``,onChange:e=>P(`sequence`,{...h.sequence,counterKey:e.target.value}),className:`fg-mono-input`})]})]})]}),(0,l.jsxs)(Z,{title:`Check for someone already on file`,styles:{body:{paddingTop:8}},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:10},children:`Before a new record is saved, look for one that already matches. This is what stops the same person being added twice under slightly different details.`}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:10},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!h.duplicateCheck,onChange:e=>P(`duplicateCheck`,e?{stages:[],policy:`prompt`,displayFields:[],message:``}:null)}),(0,l.jsx)($,{style:{fontSize:13},children:`Check before saving a new record`})]}),h.duplicateCheck&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:6},children:[(0,l.jsx)(`b`,{children:`Checks run in order, top first, and stop at the first match.`}),` Put your most certain check first — matching an email or a phone number is near proof; matching a name alone is only a maybe, so it belongs lower down.`]}),(h.duplicateCheck.stages??[]).map((e,t)=>(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginBottom:8,alignItems:`flex-end`},children:[(0,l.jsxs)(`div`,{style:{flex:1.6},children:[(0,l.jsxs)($,{type:`secondary`,style:{fontSize:12},children:[`Check `,t+1,` — compare these`]}),(0,l.jsx)(s.Select,{mode:`tags`,size:`small`,style:{width:`100%`},placeholder:`email, contactNumber`,value:e.fields??[],onChange:n=>F(t,{...e,fields:n})})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Counts as a match when`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},value:e.match??`all`,onChange:n=>F(t,{...e,match:n}),options:[{value:`any`,label:`Any one of them matches`},{value:`all`,label:`All of them match`}]})]}),(0,l.jsxs)(`div`,{style:{flex:.8},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`How sure is it?`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},value:e.weight??`strong`,onChange:n=>F(t,{...e,weight:n}),options:[{value:`strong`,label:`Almost certainly the same`},{value:`weak`,label:`Possibly the same`}]})]}),(0,l.jsxs)(`div`,{style:{flex:2},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`What to tell the user`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`A candidate with this email already exists — {name}, last updated {age}.`,value:e.message??``,onChange:n=>F(t,{...e,message:n.target.value})})]}),(0,l.jsx)(s.Button,{size:`small`,danger:!0,type:`text`,onClick:()=>P(`duplicateCheck`,{...h.duplicateCheck,stages:(h.duplicateCheck.stages??[]).filter((e,n)=>n!==t)}),children:`Remove`})]},t)),(0,l.jsx)(s.Button,{size:`small`,type:`dashed`,style:{marginBottom:12},onClick:()=>P(`duplicateCheck`,{...h.duplicateCheck,stages:[...h.duplicateCheck.stages??[],{fields:[],match:`any`,weight:`strong`}]}),children:`Add another check`}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`When a match is found`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},value:h.duplicateCheck.policy??`prompt`,onChange:e=>P(`duplicateCheck`,{...h.duplicateCheck,policy:e}),options:[{value:`prompt`,label:`Ask, and offer to update the existing one`},{value:`block`,label:`Refuse to save, and name the existing one`}]})]}),(0,l.jsxs)(`div`,{style:{flex:1.2},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Which details identify the record`}),(0,l.jsx)(s.Select,{mode:`tags`,size:`small`,style:{width:`100%`},placeholder:`firstName, lastName, email`,value:h.duplicateCheck.displayFields??[],onChange:e=>P(`duplicateCheck`,{...h.duplicateCheck,displayFields:e})})]})]}),(0,l.jsx)(`div`,{className:`fg-field-meta-row`,style:{marginTop:10},children:(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Where to open the existing record`}),(0,l.jsx)(s.Input,{size:`small`,className:`fg-mono-input`,placeholder:`/candidate/edit/:id`,value:h.duplicateCheck.editRoute??``,onChange:e=>P(`duplicateCheck`,{...h.duplicateCheck,editRoute:e.target.value})})]})}),(0,l.jsxs)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:6},children:[`The page that opens when someone chooses to update the record you already have. Use `,(0,l.jsx)(`b`,{children:`:id`}),` where the record's id goes. This has to be filled in — it cannot be worked out, because addresses follow no single pattern (this app uses `,(0,l.jsx)(`code`,{children:`/candidate/edit/:id`}),` but `,(0,l.jsx)(`code`,{children:`/clients/edit/:id`}),`). Left blank, the dialog still appears and simply does not navigate, rather than sending anyone to a page that does not exist.`]}),(0,l.jsxs)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:8},children:[`In any message you can use `,(0,l.jsx)(`b`,{children:`{name}`}),` for the matched record and`,(0,l.jsxs)(`b`,{children:[` `,`{age}`]}),` for how long ago it was last touched ("about 2 months ago"). `,(0,l.jsx)(`b`,{children:`{updatedOn}`}),` gives the date instead. Only the details listed above are shown — nothing else about the record is revealed.`]})]})]}),(0,l.jsxs)(Z,{title:`Keep previous versions of an uploaded file`,styles:{body:{paddingTop:8}},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:10},children:`Normally a new upload replaces the old one and it is gone. Turn this on and the last few are kept instead — useful when someone sends an updated CV and you may want to look back at the earlier one. Everywhere in the app still shows the newest; the older ones sit behind it.`}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:10},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!h.fileVersioning,onChange:e=>P(`fileVersioning`,e?{fields:[],keep:2,historyKey:``,s3Prefix:``,deleteEvicted:!1}:null)}),(0,l.jsx)($,{style:{fontSize:13},children:`Keep previous uploads`})]}),h.fileVersioning&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{style:{marginBottom:10},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`},children:`Where the older versions are kept`}),(0,l.jsxs)(s.Radio.Group,{size:`small`,value:h.fileVersioning.store===`documents`?`documents`:`record`,onChange:e=>{let t=e.target.value,n={...h.fileVersioning,store:t===`documents`?`documents`:``};t===`documents`&&(n.linkField=n.linkField||`documentIds`,n.clearRecordKeys=n.clearRecordKeys?.length?n.clearRecordKeys:(n.fields??[]).flatMap(e=>[`${e}History`,`${e}Versions`])),P(`fileVersioning`,n)},children:[(0,l.jsx)(s.Radio,{value:`documents`,children:`In Documents (recommended)`}),(0,l.jsx)(s.Radio,{value:`record`,children:`On the record itself`})]}),(0,l.jsxs)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:6},children:[(0,l.jsx)(`b`,{children:`In Documents`}),` keeps the file and all its earlier versions in one place, the same place every other document lives. The record just points at it — so when a candidate is submitted for a job, the submission shows the very same file, and replacing it updates both at once. `,(0,l.jsx)(`b`,{children:`On the record itself`}),` is the older way: each record keeps its own copy of the history, which is why the same résumé could end up recorded several times over and the copies could disagree.`]})]}),h.fileVersioning.store===`documents`&&(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginBottom:10},children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`List of attached documents is kept in`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`documentIds`,value:h.fileVersioning.linkField??``,onChange:e=>P(`fileVersioning`,{...h.fileVersioning,linkField:e.target.value})})]}),(0,l.jsxs)(`div`,{style:{flex:1.6},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Old history fields to clear off the record`}),(0,l.jsx)(s.Select,{mode:`tags`,size:`small`,style:{width:`100%`},placeholder:`resumeHistory`,value:h.fileVersioning.clearRecordKeys??[],onChange:e=>P(`fileVersioning`,{...h.fileVersioning,clearRecordKeys:e})})]})]}),(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1.4},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Which uploads`}),(0,l.jsx)(s.Select,{mode:`tags`,size:`small`,style:{width:`100%`},placeholder:`resume`,value:h.fileVersioning.fields??[],onChange:e=>P(`fileVersioning`,{...h.fileVersioning,fields:e})})]}),(0,l.jsxs)(`div`,{style:{flex:.7},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`How many to keep`}),(0,l.jsx)(s.Input,{size:`small`,type:`number`,min:1,value:h.fileVersioning.keep??2,onChange:e=>P(`fileVersioning`,{...h.fileVersioning,keep:Number(e.target.value)||1})})]}),(0,l.jsxs)(`div`,{style:{flex:1.4},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Where the files are grouped`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`candidates/{recordId}/resume`,value:h.fileVersioning.s3Prefix??``,onChange:e=>P(`fileVersioning`,{...h.fileVersioning,s3Prefix:e.target.value})})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:10},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!h.fileVersioning.deleteEvicted,onChange:e=>P(`fileVersioning`,{...h.fileVersioning,deleteEvicted:e})}),(0,l.jsx)($,{style:{fontSize:13},children:`Also delete the file once it drops off the end`})]}),(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:6},children:`Leave that switch OFF unless you are sure. With it off, an older file simply stops being shown and can still be recovered. With it on, it is deleted from storage permanently and cannot be brought back. Keeping 2 means a third upload pushes the first one off the end.`})]})]}),(0,l.jsx)(LT,{icon:(0,l.jsx)(c.DatabaseOutlined,{}),title:`Denormalizations`,description:`Copy fields from ANOTHER module's record onto this payload before insert (e.g. a submission snapshotting job title/client).`,rules:h.denormalizations??[],columns:R,onAdd:()=>w({index:null,rule:null}),onEdit:(e,t)=>w({index:e,rule:t}),onDelete:e=>P(`denormalizations`,(h.denormalizations??[]).filter((t,n)=>n!==e))}),(0,l.jsx)(LT,{icon:(0,l.jsx)(c.ApartmentOutlined,{}),title:`Array Enrichments`,description:`Enrich a payload array of ids (e.g. recruitersData) into objects carrying looked-up fields (name, email) before insert.`,rules:h.arrayEnrichments??[],columns:z,onAdd:()=>E({index:null,rule:null}),onEdit:(e,t)=>E({index:e,rule:t}),onDelete:e=>P(`arrayEnrichments`,(h.arrayEnrichments??[]).filter((t,n)=>n!==e))}),(0,l.jsx)(LT,{icon:(0,l.jsx)(c.DatabaseOutlined,{}),title:`File Field Maps`,description:`Turn an uploaded file field into a nested object (location + filename + who/when) or an array of such objects, instead of a flat S3 path string — needed for schemas like resume/passport/visa.`,rules:h.fileFieldMaps??[],columns:B,onAdd:()=>O({index:null,rule:null}),onEdit:(e,t)=>O({index:e,rule:t}),onDelete:e=>P(`fileFieldMaps`,(h.fileFieldMaps??[]).filter((t,n)=>n!==e))}),(0,l.jsxs)(Z,{title:`Sanitize Fields`,styles:{body:{paddingTop:8}},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:8},children:`Trim and HTML-escape these payload fields before anything else runs — basic XSS-safety for free-text fields (e.g. firstName/lastName) that might later be embedded in an HTML activity comment or email.`}),(0,l.jsx)(s.Select,{mode:`tags`,style:{width:`100%`},placeholder:`firstName, lastName, email`,value:h.sanitizeFields??[],onChange:e=>P(`sanitizeFields`,e)})]}),(0,l.jsxs)(Z,{title:`Defaults`,styles:{body:{paddingTop:8}},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:8},children:`Set a field only when the payload doesn't already carry a non-blank value — status defaults, empty arrays.`}),(0,l.jsx)(DT,{rows:AT(h.defaults),onChange:e=>P(`defaults`,jT(e)),keyPlaceholder:`internalSubmissionStatus.internalSubmissionStatusText`,valuePlaceholder:`"Under Evaluation"`})]}),(0,l.jsx)(LT,{icon:(0,l.jsx)(c.ApartmentOutlined,{}),title:`Hierarchy Expansions`,description:`Walk the reporting chain up (toward admin) or down (toward a team) from a seed user, publishing the result as {{hierarchy.<name>}} for Related Updates / Notify to use.`,rules:h.hierarchyExpands??[],columns:V,onAdd:()=>A({index:null,rule:null}),onEdit:(e,t)=>A({index:e,rule:t}),onDelete:e=>P(`hierarchyExpands`,(h.hierarchyExpands??[]).filter((t,n)=>n!==e))}),(0,l.jsx)(LT,{icon:(0,l.jsx)(c.ThunderboltOutlined,{}),title:`Related Updates`,description:`Best-effort side-effect writes to other collections after a successful insert — board state, activity logs. Combine with ForEach + a Hierarchy Expansion to seed one document per user in a chain.`,rules:h.relatedUpdates??[],columns:ee,onAdd:()=>M({index:null,rule:null}),onEdit:(e,t)=>M({index:e,rule:t}),onDelete:e=>P(`relatedUpdates`,(h.relatedUpdates??[]).filter((t,n)=>n!==e))}),(0,l.jsxs)(Z,{title:`Notify`,styles:{body:{paddingTop:8}},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:10},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!h.notify,onChange:e=>P(`notify`,e?{action:``,subjectDefault:``,bodyDefault:``,toReportingManager:!1,toHierarchy:``}:null)}),(0,l.jsx)($,{style:{fontSize:13},children:`Send a best-effort email after a successful insert`})]}),h.notify&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Action (matched against an EmailTemplates doc)`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`internalSubmit`,value:h.notify.action??``,onChange:e=>P(`notify`,{...h.notify,action:e.target.value}),className:`fg-mono-input`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Notify entire hierarchy chain`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},allowClear:!0,placeholder:`pick a Hierarchy Expansion`,value:h.notify.toHierarchy||void 0,onChange:e=>P(`notify`,{...h.notify,toHierarchy:e??``}),options:N.map(e=>({value:e,label:e}))})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:12},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:!!h.notify.toReportingManager,onChange:e=>P(`notify`,{...h.notify,toReportingManager:e})}),(0,l.jsx)($,{style:{fontSize:13},children:`Also notify the caller's direct reporting manager`})]}),(0,l.jsxs)(`div`,{style:{marginTop:12},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Default subject`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`New submission`,value:h.notify.subjectDefault??``,onChange:e=>P(`notify`,{...h.notify,subjectDefault:e.target.value})})]}),(0,l.jsxs)(`div`,{style:{marginTop:12},children:[(0,l.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Default body (used when no EmailTemplates doc matches)`}),(0,l.jsx)(s.Input.TextArea,{rows:4,value:h.notify.bodyDefault??``,onChange:e=>P(`notify`,{...h.notify,bodyDefault:e.target.value}),className:`fg-mono-input`})]})]})]}),(0,l.jsxs)(Z,{title:`Cache Invalidate`,styles:{body:{paddingTop:8}},children:[(0,l.jsxs)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:8},children:[`Redis key patterns (with `,`{{field}}`,` tokens) to SCAN+DEL after a successful insert.`]}),(0,l.jsx)(s.Select,{mode:`tags`,style:{width:`100%`},placeholder:`jobs:{{tenantId}}:{{businessId}}:{{businessUnitId}}:*`,value:h.cacheInvalidate??[],onChange:e=>P(`cacheInvalidate`,e)})]})]})]})}),(0,l.jsx)(MT,{open:!!C,rule:C?.rule,onClose:()=>w(null),onSave:e=>{P(`denormalizations`,C.index===null?[...h.denormalizations??[],e]:(h.denormalizations??[]).map((t,n)=>n===C.index?e:t)),w(null)}},C?`denorm-${C.index??`new`}`:`denorm-closed`),(0,l.jsx)(NT,{open:!!T,rule:T?.rule,onClose:()=>E(null),onSave:e=>{P(`arrayEnrichments`,T.index===null?[...h.arrayEnrichments??[],e]:(h.arrayEnrichments??[]).map((t,n)=>n===T.index?e:t)),E(null)}},T?`enrich-${T.index??`new`}`:`enrich-closed`),(0,l.jsx)(PT,{open:!!D,rule:D?.rule,onClose:()=>O(null),onSave:e=>{P(`fileFieldMaps`,D.index===null?[...h.fileFieldMaps??[],e]:(h.fileFieldMaps??[]).map((t,n)=>n===D.index?e:t)),O(null)}},D?`filemap-${D.index??`new`}`:`filemap-closed`),(0,l.jsx)(FT,{open:!!k,rule:k?.rule,onClose:()=>A(null),onSave:e=>{P(`hierarchyExpands`,k.index===null?[...h.hierarchyExpands??[],e]:(h.hierarchyExpands??[]).map((t,n)=>n===k.index?e:t)),A(null)}},k?`hier-${k.index??`new`}`:`hier-closed`),(0,l.jsx)(IT,{open:!!j,rule:j?.rule,hierarchyNames:N,onClose:()=>M(null),onSave:e=>{P(`relatedUpdates`,j.index===null?[...h.relatedUpdates??[],e]:(h.relatedUpdates??[]).map((t,n)=>n===j.index?e:t)),M(null)}},j?`ru-${j.index??`new`}`:`ru-closed`)]})}var{Text:BT}=s.Typography,VT=[`beforeCreate`,`afterCreate`,`beforeUpdate`,`afterUpdate`,`beforeDelete`,`afterDelete`],HT=[`sanitizeFields`,`generateSequence`,`duplicateCheck`,`copyFields`,`arrayEnrich`,`setDefaults`,`resolve`,`updateRelated`,`notify`,`invalidateCache`,`webhook`,`linkDocuments`,`captureFileUrls`,`resolveUploads`],UT={resolveUploads:{text:`Turn one submit into a list with ONE ENTRY PER UPLOADED FILE, so the actions after it can create one record per document instead of a single record holding all of them. Works for both shapes: a repeatable (Add Row) group gives one entry per row — carrying that row’s own values — and a multi-file upload field gives one entry per file. Publishes {{uploads.<as>}} (all entries), {{uploads.<as>First}} (the first, as an object) and {{uploads.<as>Rest}} (all but the first). Each entry has groupName, groupLabel, groupModule, fieldName, rowIndex, fileName, uniqueName, contentType, fileSize, s3Key, tenantId/businessId/businessUnitId, the row under "row", and the row’s own values at the top level. Leave "groups" empty for every group with an upload field. Set "heading" to "label" to use the group heading text instead of its name — note the heading changes whenever an admin renames the group, while the name does not.`,sample:{as:`docs`,groups:[],includeEmptyRows:!1,heading:`name`}},updateRelated:{text:`Update this record or another configured collection with values from the event. For uploaded files, after* workflows can read {{__uploads.<field>.fieldName|fileName|contentType|fileSize|s3Key|uniqueName}}. Add a $notEmpty condition on the upload s3Key so unrelated edits do not run it. To create one record PER FILE, run resolveUploads first, then set forEach to "uploads.<as>Rest" with insertIfMissing (an extraFilter on {{forEach.value.s3Key}} keeps a re-save from inserting duplicates). "unset" removes exact fields and "unsetPrefixes" removes a repeatable upload’s generated keys (document[0], document[1], …) in the SAME write — use it on the record being reused as the first row, and put that action LAST with Stop on error enabled so nothing is cleared when the inserts failed.`,sample:{targetModule:`documents`,matchField:`_id`,scopeTenant:!0,set:{module:`{{module}}`,moduleRefId:`{{_id}}`,fieldName:`{{__uploads.docPan.fieldName}}`,fileName:`{{__uploads.docPan.fileName}}`,contentType:`{{__uploads.docPan.contentType}}`,fileSize:`{{__uploads.docPan.fileSize}}`,s3Key:`{{__uploads.docPan.s3Key}}`,uniqueName:`{{__uploads.docPan.uniqueName}}`}}},linkDocuments:{text:`Share one record’s uploaded files with another, without making a second copy. Used so a submission shows the candidate’s résumé and paperwork, and anything uploaded during the submission appears on the candidate too. Both records get the list of document ids written onto them.`,sample:{sourceModule:`candidates`,sourceIdField:`applicantId`,targetModule:`submissions`,linkField:`documentIds`,fieldNames:[],backLink:!0}},captureFileUrls:{text:`File a document that was generated elsewhere and handed to us as a link — a formatted résumé or an attestation PDF — so it sits with every other attachment instead of being a loose field on the record.`,sample:{linkField:`documentIds`,files:[{urlField:`resumeUrl`,nameField:`resumeFileName`,fieldName:`formattedResume`,defaultName:`Formatted Resume.pdf`},{urlField:`attestationUrl`,nameField:`attestationFileName`,fieldName:`attestation`,defaultName:`Attestation.pdf`}]}}};function WT(e){return JSON.stringify(e??{},null,2)}function GT({action:e,onChange:t,onRemove:n}){let[r,i]=(0,o.useState)(()=>WT(e.config)),[a,u]=(0,o.useState)(!1);return(0,l.jsxs)(`div`,{style:{border:`1px solid #e2e8f0`,borderRadius:8,padding:10,marginTop:8},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`},children:[(0,l.jsx)(s.Select,{size:`small`,style:{width:200},showSearch:!0,value:e.type||void 0,placeholder:`action type`,options:HT.map(e=>({value:e})),onChange:n=>{let r=e.config&&Object.keys(e.config).length>0,i=UT[n]?.sample;t(r||!i?{...e,type:n}:{...e,type:n,config:i})}}),a&&(0,l.jsx)(s.Tag,{color:`red`,children:`invalid JSON`}),(0,l.jsx)(s.Button,{size:`small`,type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{}),style:{marginLeft:`auto`},onClick:n})]}),UT[e.type]&&(0,l.jsx)(`p`,{style:{margin:`8px 0 0`,fontSize:12,color:`#64748b`,lineHeight:1.5},children:UT[e.type].text}),(0,l.jsx)(s.Input.TextArea,{rows:Math.min(14,Math.max(3,r.split(`
17
- `).length)),value:r,className:`fg-mono-input`,style:{marginTop:8,fontSize:12},onChange:n=>{i(n.target.value);try{t({...e,config:JSON.parse(n.target.value||`{}`)}),u(!1)}catch{u(!0)}}})]})}function KT({open:e,doc:t,moduleOptions:n,onClose:r,onSave:i}){let[a,u]=(0,o.useState)(()=>({key:``,module:``,event:`afterCreate`,order:10,isActive:!0,stopOnError:!1,condition:{},actions:[],...t??{}})),[d,f]=(0,o.useState)(()=>WT(t?.condition)),[p,m]=(0,o.useState)(!1),h=(e,t)=>u(n=>({...n,[e]:t}));return(0,l.jsx)(s.Modal,{open:e,onCancel:r,width:840,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,l.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,l.jsx)(c.ApartmentOutlined,{}),` `,t?`Edit Workflow`:`New Workflow`]}),footer:(0,l.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,l.jsx)(s.Button,{onClick:r,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),onClick:()=>{if(!a.key?.trim())return s.message.error(`Key is required`);if(!a.module?.trim())return s.message.error(`Module is required`);if(p)return s.message.error(`Condition JSON is invalid`);if(!(a.actions??[]).length)return s.message.error(`At least one action is required`);if((a.actions??[]).some(e=>!e.type))return s.message.error(`Every action needs a type`);let e={...a};delete e.id,delete e._id,i(e)},children:`Save Workflow`})]}),children:(0,l.jsxs)(`div`,{className:`fg-form-section`,children:[(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)(BT,{type:`secondary`,style:{fontSize:12},children:`Key`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`jobs-create-after`,value:a.key??``,onChange:e=>h(`key`,e.target.value),className:`fg-mono-input`,disabled:!!t})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)(BT,{type:`secondary`,style:{fontSize:12},children:`Module`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},showSearch:!0,value:a.module||void 0,options:n,onChange:e=>h(`module`,e),placeholder:`jobs`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)(BT,{type:`secondary`,style:{fontSize:12},children:`Event`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},value:a.event,options:VT.map(e=>({value:e})),onChange:e=>h(`event`,e)})]}),(0,l.jsxs)(`div`,{style:{width:90},children:[(0,l.jsx)(BT,{type:`secondary`,style:{fontSize:12},children:`Order`}),(0,l.jsx)(s.InputNumber,{size:`small`,style:{width:`100%`},value:a.order??10,onChange:e=>h(`order`,e??10)})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:24,marginTop:12},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:a.isActive!==!1,onChange:e=>h(`isActive`,e)}),(0,l.jsx)(BT,{style:{fontSize:13},children:`Active`})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:a.stopOnError===!0,onChange:e=>h(`stopOnError`,e)}),(0,l.jsx)(s.Tooltip,{title:`Off (default): if an action fails after the record is saved, it is logged and the next action still runs — right for independent side effects like a notification and a cache clear. On: the remaining actions are skipped, for a sequence whose later steps are only safe because the earlier ones worked (creating records and THEN clearing the data they came from).`,children:(0,l.jsx)(BT,{style:{fontSize:13},children:`Stop on error`})})]})]}),(0,l.jsxs)(`div`,{style:{marginTop:12},children:[(0,l.jsxs)(BT,{type:`secondary`,style:{fontSize:12},children:[`Condition (all must match the payload; empty = always run) `,p&&(0,l.jsx)(s.Tag,{color:`red`,children:`invalid JSON`})]}),(0,l.jsx)(s.Input.TextArea,{rows:2,value:d,className:`fg-mono-input`,style:{fontSize:12},onChange:e=>{f(e.target.value);try{h(`condition`,JSON.parse(e.target.value||`{}`)),m(!1)}catch{m(!0)}}})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginTop:14},children:[(0,l.jsx)(BT,{strong:!0,style:{fontSize:13},children:`Actions (run in order)`}),(0,l.jsx)(s.Button,{size:`small`,type:`dashed`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>h(`actions`,[...a.actions??[],{type:``,config:{}}]),children:`Add Action`})]}),(a.actions??[]).map((e,t)=>(0,l.jsx)(GT,{action:e,onChange:e=>h(`actions`,a.actions.map((n,r)=>r===t?e:n)),onRemove:()=>h(`actions`,a.actions.filter((e,n)=>n!==t))},t)),(0,l.jsxs)(BT,{type:`secondary`,style:{fontSize:11,display:`block`,marginTop:8},children:[`Config supports `,(0,l.jsx)(`code`,{children:`{{field.path}}`}),`, `,(0,l.jsx)(`code`,{children:`{{now}}`}),`, `,(0,l.jsx)(`code`,{children:`{{__userId}}`}),`,`,` `,(0,l.jsx)(`code`,{children:`{{__userName}}`}),`, and `,(0,l.jsx)(`code`,{children:`{{hierarchy.<name>}}`}),` from a `,(0,l.jsx)(`code`,{children:`resolve`}),` action.`]})]})})}function qT(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)([]),[a,u]=(0,o.useState)(!0),[d,f]=(0,o.useState)(``),[p,m]=(0,o.useState)(null),[h,g]=(0,o.useState)(``),[_,v]=(0,o.useState)(0);(0,o.useEffect)(()=>{let e=!1;return n.Qr(`workflows`).then(n=>{e||t(n)}).catch(t=>{e||f(t?.message||`Failed to load workflows`)}).finally(()=>{e||u(!1)}),()=>{e=!0}},[_]),(0,o.useEffect)(()=>{n.xr().then(e=>i(Gx(e).map(({value:e,label:t})=>({value:e,label:t})))).catch(()=>i([]))},[]);let y=()=>{u(!0),f(``),v(e=>e+1)};async function b(e){try{await n.ci(`workflows`,e),s.message.success(`Workflow "${e.key}" saved`),m(null),y()}catch(e){s.message.error(e?.message||`Could not save workflow`)}}async function x(e){try{await n.lr(`workflows`,e),s.message.success(`Workflow "${e}" deleted`),y()}catch(e){s.message.error(e?.message||`Could not delete workflow`)}}async function S(e,t){let r={...e};delete r.id,delete r._id;try{await n.ci(`workflows`,{...r,isActive:t}),y()}catch(e){s.message.error(e?.message||`Could not update workflow`)}}let C=(0,o.useMemo)(()=>e.filter(e=>!h||e.module===h),[e,h]);return(0,l.jsxs)(`div`,{className:`fg-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.ApartmentOutlined,{}),title:`Workflows`,extra:(0,l.jsxs)(s.Space,{size:8,children:[(0,l.jsx)(s.Select,{size:`small`,style:{minWidth:160},allowClear:!0,placeholder:`Filter by module`,options:r,value:h||void 0,onChange:e=>g(e??``)}),(0,l.jsx)(s.Button,{size:`small`,icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:y,children:`Reload`}),(0,l.jsx)(s.Button,{type:`primary`,size:`small`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>m({doc:null}),children:`New Workflow`})]}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsxs)(BT,{type:`secondary`,style:{fontSize:13},children:[`Event-driven behavior per module — reference ids, duplicate checks, snapshots, hierarchy fan-outs, board updates, notifications, cache — executed by the platform Workflow Engine on every create/update/delete.`,(0,l.jsx)(s.Tag,{style:{marginLeft:8},children:`before*`}),` actions can block the write; `,(0,l.jsx)(s.Tag,{children:`after*`}),` actions are best-effort.`]})]}),(0,l.jsxs)(Z,{styles:{body:{paddingTop:8}},children:[d&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,message:d,style:{marginBottom:12}}),(0,l.jsxs)(s.Spin,{spinning:a,children:[(0,l.jsxs)(`div`,{style:{marginBottom:8},children:[(0,l.jsx)(s.Badge,{count:C.length,showZero:!0,color:`var(--color-brand)`}),` `,(0,l.jsx)(BT,{type:`secondary`,style:{fontSize:12},children:`workflows`})]}),(0,l.jsx)(s.Table,{rowKey:`key`,dataSource:C,columns:[{title:`Key`,dataIndex:`key`,key:`key`,render:e=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Module`,dataIndex:`module`,key:`module`,width:130,render:e=>(0,l.jsx)(s.Tag,{color:`geekblue`,children:e})},{title:`Event`,dataIndex:`event`,key:`event`,width:130,render:e=>(0,l.jsx)(s.Tag,{color:String(e).startsWith(`before`)?`purple`:`green`,children:e})},{title:`Actions`,key:`acts`,render:(e,t)=>(0,l.jsx)(s.Space,{size:4,wrap:!0,children:(t.actions??[]).map((e,t)=>(0,l.jsx)(s.Tag,{style:{margin:0},children:e.type},t))})},{title:`Order`,dataIndex:`order`,key:`order`,width:70,align:`center`},{title:`Active`,key:`active`,width:80,align:`center`,render:(e,t)=>(0,l.jsx)(s.Switch,{size:`small`,checked:t.isActive!==!1,onChange:e=>S(t,e)})},{title:``,key:`ops`,width:90,align:`right`,render:(e,t)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Tooltip,{title:`Edit`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>m({doc:t})})}),(0,l.jsx)(s.Popconfirm,{title:`Delete workflow "${t.key}"?`,onConfirm:()=>x(t.key),children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})]})}],pagination:!1,size:`small`,className:`fg-table`,locale:{emptyText:(0,l.jsx)(s.Empty,{description:`No workflows configured.`,image:s.Empty.PRESENTED_IMAGE_SIMPLE})}})]})]}),(0,l.jsx)(KT,{open:!!p,doc:p?.doc,moduleOptions:r,onClose:()=>m(null),onSave:b},p?p.doc?.key??`new`:`closed`)]})}var{Text:JT}=s.Typography,YT=e=>e?._id??e?.id,XT=`masters`;function ZT(){return{tenantId:localStorage.getItem(`tenantId`)||``,businessId:localStorage.getItem(`businessId`)||``,businessUnitId:localStorage.getItem(`businessUnitId`)||``}}function QT(e){return e&&typeof e==`object`?e.$oid??e.oid??e.id??``:e??``}function $T(e,t){return t.map(t=>QT(e?.[t])).find(e=>e!=null&&e!==``)??``}function eE(e,t){return[[t.tenantId,[`tid`,`tenantId`]],[t.businessId,[`bid`,`businessId`]],[t.businessUnitId,[`buid`,`businessUnitId`]]].every(([t,n])=>{if(!t)return!0;let r=String($T(e,n));return!r||r===String(t)})}function tE(e){return Array.isArray(e?.masterFeeds)?e.masterFeeds:[]}function nE(e){return e.reduce((e,t)=>Math.max(e,Number(t?.uniqueId)||0),0)+1}function rE(e){return Array.isArray(e?.taxHistory)?e.taxHistory:[]}function iE(e){let t=e?.taxValue;if(t!=null&&t!==``)return Number(t);let n=rE(e).at(-1),r=n?.taxValue??n?.value;return r!=null&&r!==``?Number(r):void 0}function aE(e){if(!e)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(t)}function oE(e){let t=rE(e).at(-1);return t?.updatedAt??t?.timestamp??e?.updatedAt}function sE({open:e,record:t,onClose:r,onSaved:i}){let[a]=s.Form.useForm(),[c,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)([]),[p,m]=(0,o.useState)(!1),h=(0,o.useRef)(null),g=!!t;(0,o.useEffect)(()=>{e&&queueMicrotask(()=>{a.resetFields(),a.setFieldsValue({name:t?.name??void 0,taxValue:iE(t)}),f(t?.name?[{label:t.name,value:t.name}]:[])})},[e,t,a]);function _(e){if(h.current&&clearTimeout(h.current),!e||e.trim().length<2){f([]);return}m(!0),h.current=setTimeout(()=>{n.Mr(e.trim()).then(f).catch(()=>f([])).finally(()=>m(!1))},350)}async function v(){let e=await a.validateFields(),r=Number(e.taxValue),o={name:e.name,taxValue:r,taxHistory:{taxValue:r}};u(!0);try{g?await n._i(`locations`,YT(t),o):await n.$n(`locations`,o),s.message.success(g?`Tax updated`:`Location and tax created`),i()}catch(e){s.message.error(e?.message||`Could not save location and tax`)}finally{u(!1)}}return(0,l.jsx)(s.Modal,{open:e,onCancel:r,onOk:v,confirmLoading:c,destroyOnHidden:!0,title:g?`Edit Tax — ${t?.name??``}`:`New Location`,children:(0,l.jsxs)(s.Form,{form:a,layout:`vertical`,children:[(0,l.jsx)(s.Form.Item,{name:`name`,label:`Location`,rules:[{required:!0,message:`Location is required`}],tooltip:g?`Location cannot be changed once created — only the tax is editable.`:`Search and pick from the location master.`,children:(0,l.jsx)(s.Select,{showSearch:!0,disabled:g,placeholder:`Type at least 2 characters to search…`,filterOption:!1,onSearch:_,notFoundContent:p?`Searching…`:null,options:d})}),(0,l.jsx)(s.Form.Item,{name:`taxValue`,label:`Tax`,rules:[{required:!0,message:`Tax is required`},{type:`number`,min:0,max:100,message:`Tax must be between 0 and 100`}],children:(0,l.jsx)(s.InputNumber,{style:{width:`100%`},min:0,max:100,step:.01,suffix:`%`,placeholder:`8.875`,autoFocus:g})})]})})}function cE({record:e}){let t=[...rE(e)].reverse();return t.length?(0,l.jsx)(s.Space,{direction:`vertical`,size:4,style:{padding:`4px 8px`},children:t.map((e,t)=>(0,l.jsxs)(s.Space,{size:10,children:[(0,l.jsxs)(s.Tag,{color:t===0?`green`:`default`,style:{margin:0},children:[e.taxValue??e.value,`%`]}),(0,l.jsx)(JT,{type:`secondary`,style:{fontSize:12},children:aE(e.updatedAt??e.timestamp)}),t===0&&(0,l.jsx)(JT,{type:`secondary`,style:{fontSize:12},children:`(current)`})]},t))}):(0,l.jsx)(s.Empty,{image:s.Empty.PRESENTED_IMAGE_SIMPLE,description:`No tax history yet`})}function lE(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(null);function p(){i(!0),n.Zr(`locations`).then(({items:e})=>t(e)).catch(e=>s.message.error(e?.message||`Could not load locations`)).finally(()=>i(!1))}(0,o.useEffect)(()=>{queueMicrotask(p)},[]);async function m(e){try{await n.cr(`locations`,e),s.message.success(`Location deleted`),p()}catch(e){s.message.error(e?.message||`Could not delete location`)}}return(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsx)(Z,{title:`${e.length} location${e.length===1?``:`s`}`,extra:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:p,children:`Reload`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>{f(null),u(!0)},children:`New location`})]}),children:(0,l.jsx)(s.Table,{rowKey:YT,columns:[{title:`Location`,dataIndex:`name`,key:`name`},{title:`Tax`,key:`taxValue`,width:100,render:(e,t)=>{let n=iE(t);return Number.isFinite(n)?(0,l.jsxs)(s.Tag,{color:`blue`,children:[n,`%`]}):`—`}},{title:`Tax updated`,key:`taxUpdatedAt`,render:(e,t)=>aE(oE(t))},{title:`Created`,key:`createdAt`,responsive:[`lg`],render:(e,t)=>aE(t?.createdAt)},{title:``,key:`actions`,width:90,render:(e,t)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Tooltip,{title:`Edit tax`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{f(t),u(!0)}})}),(0,l.jsx)(s.Popconfirm,{title:`Delete this location?`,onConfirm:()=>m(YT(t)),children:(0,l.jsx)(s.Tooltip,{title:`Delete`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})})]})}],dataSource:e,loading:r,size:`small`,pagination:!1,className:`fg-table`,expandable:{expandedRowRender:e=>(0,l.jsx)(cE,{record:e}),rowExpandable:e=>rE(e).length>0},locale:{emptyText:`No locations yet. Click "New location" to add one.`}})}),(0,l.jsx)(sE,{open:a,record:d,onClose:()=>u(!1),onSaved:()=>{u(!1),p()}})]})}function uE({open:e,record:t,onClose:r,onSaved:i}){let[a]=s.Form.useForm(),[u,d]=(0,o.useState)(!1),f=!!t,p=s.Form.useWatch(`masterName`,a),m=s.Form.useWatch(`masterFeeds`,a)??[],h=[`clientsubmissionstatus`,`clientsubmission`,`clientsubmissions`].includes(String(p??t?.masterName??``).trim().toLowerCase()),g=m.map(e=>({label:String(e?.name??``).trim()||`Status ${e?.uniqueId??``}`,value:Number(e?.uniqueId)})).filter(e=>Number.isInteger(e.value)&&e.value>0);function _(e,t){if(!t){a.setFieldValue([`masterFeeds`,e,`isInitialStatus`],!1);return}(a.getFieldValue(`masterFeeds`)??[]).forEach((t,n)=>{a.setFieldValue([`masterFeeds`,n,`isInitialStatus`],n===e)})}function v(e,t){a.setFieldValue([`masterFeeds`,e,`isTerminalStatus`],t),t&&a.setFieldValue([`masterFeeds`,e,`allowedNextStatusIds`],[])}(0,o.useEffect)(()=>{e&&queueMicrotask(()=>{a.resetFields();let e=t?.masterName??``,n=[`clientsubmissionstatus`,`clientsubmission`,`clientsubmissions`].includes(String(e).trim().toLowerCase()),r=tE(t),i=r.length?r.map(e=>({...e})):[{uniqueId:1,name:``,type:`neutral`,status:!0,isdeleted:!1}];if(n&&!i.some(e=>e?.status!==!1&&e?.isdeleted!==!0&&e?.isInitialStatus===!0)){let e=i.findIndex(e=>e?.status!==!1&&e?.isdeleted!==!0);e>=0&&(i=i.map((t,n)=>({...t,isInitialStatus:n===e,isTerminalStatus:t?.isTerminalStatus===!0,allowedNextStatusIds:Array.isArray(t?.allowedNextStatusIds)?t.allowedNextStatusIds:[]})))}a.setFieldsValue({masterName:e,schemaVersion:t?.schemaVersion??1,masterFeeds:i})})},[e,t,a]),(0,o.useEffect)(()=>{!e||!h||(Number(a.getFieldValue(`schemaVersion`))||1)<2&&a.setFieldValue(`schemaVersion`,2)},[e,h,a]);async function y(){let e=await a.validateFields(),r=ZT(),o=[`clientsubmissionstatus`,`clientsubmission`,`clientsubmissions`].includes(String(e.masterName??``).trim().toLowerCase()),c=(e.masterFeeds??[]).map((e,t)=>{let n=Number(e.uniqueId)||t+1,r=o&&e.isTerminalStatus===!0,i=o&&!r?[...new Set((e.allowedNextStatusIds??[]).map(Number).filter(e=>Number.isInteger(e)&&e>0&&e!==n))]:[];return{uniqueId:n,name:String(e.name??``).trim(),type:String(e.type??``).trim(),status:e.status!==!1,...o?{isInitialStatus:e.isInitialStatus===!0,isTerminalStatus:r,allowedNextStatusIds:i}:{},isdeleted:e.isdeleted===!0}}).filter(e=>e.name);if(o){let e=c.filter(e=>e.status&&!e.isdeleted&&e.isInitialStatus);if(e.length===0){let t=c.findIndex(e=>e.status&&!e.isdeleted);t>=0&&(c[t]={...c[t],isInitialStatus:!0},e=[c[t]],a.setFieldValue([`masterFeeds`,t,`isInitialStatus`],!0))}if(e.length!==1){s.message.error(`Client Submission Status must have exactly one active Initial Status.`);return}}let l={...r,tid:r.tenantId,bid:r.businessId,buid:r.businessUnitId,schemaVersion:o?Math.max(2,Number(e.schemaVersion)||2):Number(e.schemaVersion)||1,masterName:e.masterName.trim(),masterFeeds:c};d(!0);try{f?await n._i(XT,YT(t),l):await n.$n(XT,l),s.message.success(f?`Master value updated`:`Master value created`),i()}catch(e){s.message.error(e?.message||`Could not save master value`)}finally{d(!1)}}return(0,l.jsx)(s.Modal,{open:e,onCancel:r,onOk:y,confirmLoading:u,destroyOnHidden:!0,title:f?`Edit Master Feed`:`New Master Feed`,width:1040,children:(0,l.jsxs)(s.Form,{form:a,layout:`vertical`,children:[(0,l.jsx)(s.Form.Item,{name:`masterName`,label:`Master Name`,rules:[{required:!0,message:`Master name is required`}],children:(0,l.jsx)(s.Input,{placeholder:`blacklistType`,autoFocus:!f,disabled:f})}),(0,l.jsx)(s.Form.Item,{name:`schemaVersion`,label:`Schema Version`,children:(0,l.jsx)(s.InputNumber,{min:1,style:{width:`100%`}})}),(0,l.jsx)(s.Form.List,{name:`masterFeeds`,children:(e,{add:t,remove:n})=>(0,l.jsxs)(s.Space,{direction:`vertical`,style:{width:`100%`},size:10,children:[e.map(({key:e,name:t})=>(0,l.jsxs)(s.Space,{align:`baseline`,wrap:!0,children:[(0,l.jsx)(s.Form.Item,{name:[t,`uniqueId`],label:`ID`,rules:[{required:!0,message:`ID required`}],children:(0,l.jsx)(s.InputNumber,{min:1,style:{width:90}})}),(0,l.jsx)(s.Form.Item,{name:[t,`name`],label:`Name`,rules:[{required:!0,message:`Name required`}],children:(0,l.jsx)(s.Input,{placeholder:`Dropdown label`,style:{width:280}})}),(0,l.jsx)(s.Form.Item,{name:[t,`type`],label:`Type`,children:(0,l.jsx)(s.Select,{allowClear:!0,placeholder:`Select type`,style:{width:120},options:[{label:`Positive`,value:`positive`},{label:`Neutral`,value:`neutral`},{label:`Negative`,value:`negative`}]})}),(0,l.jsx)(s.Form.Item,{name:[t,`status`],label:`Status`,initialValue:!0,children:(0,l.jsx)(s.Select,{style:{width:110},options:[{label:`Active`,value:!0},{label:`Inactive`,value:!1}]})}),(0,l.jsx)(s.Form.Item,{name:[t,`isdeleted`],label:`Deleted`,initialValue:!1,children:(0,l.jsx)(s.Select,{style:{width:110},options:[{label:`No`,value:!1},{label:`Yes`,value:!0}]})}),h&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.Form.Item,{name:[t,`isInitialStatus`],label:`Initial`,initialValue:!1,tooltip:`The initial status is the only option shown before a candidate has a client submission status. Only one active initial status is allowed.`,children:(0,l.jsx)(s.Select,{style:{width:100},onChange:e=>_(t,e===!0),options:[{label:`Yes`,value:!0},{label:`No`,value:!1}]})}),(0,l.jsx)(s.Form.Item,{name:[t,`isTerminalStatus`],label:`End Status`,initialValue:!1,tooltip:`End Status stops the configured client submission flow. Once reached, Change Status is hidden and no next statuses are allowed.`,children:(0,l.jsx)(s.Select,{style:{width:105},onChange:e=>v(t,e===!0),options:[{label:`Yes`,value:!0},{label:`No`,value:!1}]})}),(0,l.jsx)(s.Form.Item,{noStyle:!0,shouldUpdate:(e,n)=>e?.masterFeeds?.[t]?.isTerminalStatus!==n?.masterFeeds?.[t]?.isTerminalStatus||e?.masterFeeds?.[t]?.uniqueId!==n?.masterFeeds?.[t]?.uniqueId||e?.masterFeeds!==n?.masterFeeds,children:({getFieldValue:e})=>{let n=e([`masterFeeds`,t,`isTerminalStatus`])===!0,r=Number(e([`masterFeeds`,t,`uniqueId`]));return(0,l.jsx)(s.Form.Item,{name:[t,`allowedNextStatusIds`],label:`Allowed Next Statuses`,tooltip:n?`End Status cannot move to another status.`:`Only these statuses will appear after the current status is saved.`,children:(0,l.jsx)(s.Select,{mode:`multiple`,allowClear:!0,disabled:n,placeholder:n?`End status`:`Select next statuses`,style:{minWidth:280},options:g.filter(e=>e.value!==r)})})}})]}),(0,l.jsx)(s.Tooltip,{title:`Remove row`,children:(0,l.jsx)(s.Button,{type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{}),onClick:()=>n(t)})})]},e)),(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>t({uniqueId:nE(a.getFieldValue(`masterFeeds`)??[]),name:``,type:`neutral`,status:!0,isdeleted:!1,...h?{isInitialStatus:!1,isTerminalStatus:!1,allowedNextStatusIds:[]}:{}}),children:`Add feed value`})]})})]})})}function dE(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(null),[p,m]=(0,o.useState)(``);function h(){let e=ZT();i(!0),n.Zr(XT,{limit:500}).then(({items:n})=>{let r=n.filter(t=>eE(t,e));t(r)}).catch(e=>s.message.error(e?.message||`Could not load master values`)).finally(()=>i(!1))}(0,o.useEffect)(()=>{queueMicrotask(h)},[]);async function g(e){try{await n.cr(XT,e),s.message.success(`Master value deleted`),h()}catch(e){s.message.error(e?.message||`Could not delete master value`)}}let _=p?e.filter(e=>String(e?.masterName??``).toLowerCase()===p.toLowerCase()):e,v=[...new Set(e.map(e=>e?.masterName).filter(Boolean))].sort((e,t)=>String(e).localeCompare(String(t))).map(e=>({label:e,value:e}));return(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsx)(Z,{title:`${_.length} master${_.length===1?``:`s`}`,extra:(0,l.jsxs)(s.Space,{wrap:!0,children:[(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,placeholder:`Filter master name`,value:p||void 0,options:v,onChange:e=>m(e??``),style:{minWidth:220}}),(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:h,children:`Reload`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>{f(null),u(!0)},children:`New master`})]}),children:(0,l.jsx)(s.Table,{rowKey:YT,columns:[{title:`Master Name`,dataIndex:`masterName`,key:`masterName`,width:180},{title:`Feed Values`,key:`masterFeeds`,render:(e,t)=>(0,l.jsx)(s.Space,{wrap:!0,children:tE(t).filter(e=>!e.isdeleted).map(e=>(0,l.jsx)(s.Tag,{color:e.status===!1?`default`:`blue`,children:e.name},e.uniqueId??e.name))})},{title:`Count`,key:`count`,width:90,render:(e,t)=>tE(t).filter(e=>!e.isdeleted).length},{title:`Updated`,key:`updatedAt`,responsive:[`lg`],render:(e,t)=>aE(t?.updatedAt)},{title:``,key:`actions`,width:90,render:(e,t)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Tooltip,{title:`Edit`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{f(t),u(!0)}})}),(0,l.jsx)(s.Popconfirm,{title:`Delete this master?`,onConfirm:()=>g(YT(t)),children:(0,l.jsx)(s.Tooltip,{title:`Delete`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})})]})}],dataSource:_,loading:r,size:`small`,pagination:{pageSize:10,showSizeChanger:!0},className:`fg-table`,locale:{emptyText:`No masters yet. Click "New master" to add one.`}})}),(0,l.jsx)(uE,{open:a,record:d,onClose:()=>u(!1),onSaved:()=>{u(!1),h()}})]})}function fE(){return(0,l.jsxs)(`div`,{className:`fg-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.DatabaseOutlined,{}),title:`Master Collections`,children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(JT,{type:`secondary`,style:{fontSize:13},children:`Create, update, and delete master documents, then customize multiple dropdown values inside masterFeeds. Records are saved with the current tenant, business, business unit, and master name.`})]}),(0,l.jsx)(dE,{}),(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.DatabaseOutlined,{}),title:`Location Tax Master`,children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(JT,{type:`secondary`,style:{fontSize:13},children:`Pick a location from the master list and set its tax. Once added, only the tax can be changed — every change is kept in a timeline with its timestamp. Expand a row to see the full tax history.`})]}),(0,l.jsx)(lE,{})]})}var{Text:pE}=s.Typography,mE={employerMsaValidityDays:365,referralMsaValidityDays:365,expiryWarningDays:30};function hE(){let[e]=s.Form.useForm(),[t,r]=(0,o.useState)(!0),[i,a]=(0,o.useState)(!1),u=async()=>{r(!0);try{let t=await n.Ur();e.setFieldsValue({...mE,...t||{}})}catch(t){s.message.error(t?.message||`Could not load PO/MSA settings`),e.setFieldsValue(mE)}finally{r(!1)}};return(0,o.useEffect)(()=>{u()},[]),(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.SettingOutlined,{}),title:`PO/MSA Validity Settings`,extra:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:u,disabled:i,children:`Reload`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),loading:i,onClick:async()=>{try{let t=await e.validateFields();a(!0);let r=await n.si(t);e.setFieldsValue({...mE,...r||t}),s.message.success(`PO/MSA validity settings saved`)}catch(e){e?.errorFields||s.message.error(e?.message||`Could not save PO/MSA settings`)}finally{a(!1)}},children:`Save`})]}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(pE,{type:`secondary`,children:`Configure how long a signed MSA remains valid. Employer/referral status is calculated from the signed MSA date plus these values; no validity period is hardcoded in the onboarding UI.`})]}),(0,l.jsx)(Z,{title:`Validity Rules`,children:(0,l.jsx)(s.Spin,{spinning:t,children:(0,l.jsxs)(s.Form,{form:e,layout:`vertical`,initialValues:mE,style:{maxWidth:620},children:[(0,l.jsx)(s.Form.Item,{name:`employerMsaValidityDays`,label:`Employer MSA Validity Days`,tooltip:`Number of days an employer MSA remains active from its signed date.`,rules:[{required:!0,message:`Employer MSA validity is required`}],children:(0,l.jsx)(s.InputNumber,{min:1,max:3650,precision:0,style:{width:`100%`},addonAfter:`days`})}),(0,l.jsx)(s.Form.Item,{name:`referralMsaValidityDays`,label:`Referral MSA Validity Days`,tooltip:`Number of days a referral MSA remains active from its signed date.`,rules:[{required:!0,message:`Referral MSA validity is required`}],children:(0,l.jsx)(s.InputNumber,{min:1,max:3650,precision:0,style:{width:`100%`},addonAfter:`days`})}),(0,l.jsx)(s.Form.Item,{name:`expiryWarningDays`,label:`Expiry Warning Days`,tooltip:`Reserved for upcoming-expiry indicators and notifications.`,rules:[{required:!0,message:`Expiry warning days is required`}],children:(0,l.jsx)(s.InputNumber,{min:0,max:3650,precision:0,style:{width:`100%`},addonAfter:`days`})})]})})})]})}var{Text:gE,Title:_E}=s.Typography,vE=[{value:`Dashboard`,label:`Dashboard`,icon:(0,l.jsx)(c.DashboardOutlined,{})},{value:`ClientManagement`,label:`Client Management`,icon:(0,l.jsx)(c.BankOutlined,{})},{value:`EmployerManagement`,label:`Employer / Referral`,icon:(0,l.jsx)(c.TeamOutlined,{})},{value:`Candidates`,label:`Candidates`,icon:(0,l.jsx)(c.UsergroupAddOutlined,{})},{value:`Jobs`,label:`Jobs`,icon:(0,l.jsx)(c.FileTextOutlined,{})},{value:`Submissions`,label:`Submissions`,icon:(0,l.jsx)(c.FileTextOutlined,{})},{value:`Onboarding`,label:`Onboarding`,icon:(0,l.jsx)(c.UserOutlined,{})},{value:`Assignments`,label:`Assignments`,icon:(0,l.jsx)(c.AppstoreOutlined,{})},{value:`Timesheet`,label:`Timesheet`,icon:(0,l.jsx)(c.CalendarOutlined,{})},{value:`Campaign`,label:`Campaign`,icon:(0,l.jsx)(c.TeamOutlined,{})},{value:`FileProtectOutlined`,label:`PO / MSA`,icon:(0,l.jsx)(c.FileProtectOutlined,{})},{value:`FolderOpenOutlined`,label:`Batches`,icon:(0,l.jsx)(c.FolderOpenOutlined,{})},{value:`BankOutlined`,label:`Billing / Finance`,icon:(0,l.jsx)(c.BankOutlined,{})},{value:`SettingOutlined`,label:`Settings / Admin`,icon:(0,l.jsx)(c.SettingOutlined,{})},{value:`UploadOutlined`,label:`Upload`,icon:(0,l.jsx)(c.UploadOutlined,{})},{value:`AppstoreOutlined`,label:`General Module`,icon:(0,l.jsx)(c.AppstoreOutlined,{})}];function yE({option:e}){return(0,l.jsxs)(s.Space,{size:8,children:[(0,l.jsx)(`span`,{style:{display:`inline-flex`,fontSize:16},children:e.icon}),(0,l.jsx)(`span`,{children:e.label}),(0,l.jsx)(gE,{type:`secondary`,style:{fontSize:11},children:e.value})]})}function bE(e,t){let n=localStorage.getItem(`menu`);if(n)try{let r=JSON.parse(n),i=Array.isArray(r)?r:r?.menu;if(!Array.isArray(i))return;let a=String(e??t.menu_key??``).trim().toLowerCase(),o=e=>e.map(e=>{let n=String(e?.key??``).trim().toLowerCase()===a?{...e,icon:t.icon??e.icon,label:t.menu_name??e.label,status:String(t.status??e.status??`ACTIVE`).toLowerCase()}:e;return Array.isArray(n?.children)?{...n,children:o(n.children)}:n}),s=o(i);localStorage.setItem(`menu`,JSON.stringify(Array.isArray(r)?s:{...r,menu:s})),window.dispatchEvent(new Event(`menu:updated`))}catch{}}function xE(){let[e]=s.Form.useForm(),[t,n]=(0,o.useState)([]),[r,i]=(0,o.useState)(!0),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(null),[p,m]=(0,o.useState)(!1);async function h(){i(!0);try{n(await mx())}catch(e){s.message.error(e.message||`Unable to load menus`)}finally{i(!1)}}(0,o.useEffect)(()=>{h()},[]);let g=(0,o.useMemo)(()=>t.filter(e=>!d||e.menu_id!==d.menu_id).map(e=>({label:e.menu_name,value:e.menu_id})),[d,t]);function _(){f(null),e.resetFields(),e.setFieldsValue({menu_type:`MENU`,display_order:t.length+1,status:`ACTIVE`}),m(!0)}function v(t){f(t),e.setFieldsValue(t),m(!0)}async function y(e){u(!0);try{d?(await gx(d.menu_id,e),bE(d.menu_key,e)):await hx(e),s.message.success(d?`Menu updated`:`Menu created`),m(!1),await h()}catch(e){s.message.error(e.message||`Unable to save menu`)}finally{u(!1)}}async function b(e){try{await _x(e),s.message.success(`Menu deleted`),await h()}catch(e){s.message.error(e.message||`Unable to delete menu`)}}return(0,l.jsxs)(`section`,{className:`admin-section`,children:[(0,l.jsxs)(`div`,{className:`admin-section-head`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(_E,{level:4,children:`Menus`}),(0,l.jsx)(gE,{type:`secondary`,children:`Manage records in the MongoDB menus collection.`})]}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:_,children:`Add Menu`})]}),(0,l.jsx)(s.Table,{rowKey:`menu_id`,loading:r,columns:[{title:`Name`,dataIndex:`menu_name`},{title:`Key`,dataIndex:`menu_key`,render:e=>(0,l.jsx)(s.Tag,{children:e})},{title:`Route / API`,dataIndex:`api_url`},{title:`Icon`,dataIndex:`icon`,width:170,render:e=>(0,l.jsx)(s.Tag,{children:e||`Auto`})},{title:`Type`,dataIndex:`menu_type`,width:110},{title:`Order`,dataIndex:`display_order`,width:80},{title:`Status`,dataIndex:`status`,width:100,render:e=>(0,l.jsx)(s.Tag,{color:e===`ACTIVE`?`green`:`default`,children:e})},{title:``,key:`actions`,width:90,render:(e,t)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Button,{"aria-label":`Edit menu`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>v(t)}),(0,l.jsx)(s.Popconfirm,{title:`Delete menu?`,onConfirm:()=>b(t.menu_id),children:(0,l.jsx)(s.Button,{"aria-label":`Delete menu`,danger:!0,size:`small`,icon:(0,l.jsx)(c.DeleteOutlined,{})})})]})}],dataSource:t,size:`small`,pagination:{pageSize:10}}),(0,l.jsx)(s.Modal,{title:d?`Edit Menu`:`Add Menu`,open:p,onCancel:()=>m(!1),onOk:()=>e.submit(),confirmLoading:a,destroyOnHidden:!0,children:(0,l.jsxs)(s.Form,{form:e,layout:`vertical`,onFinish:y,children:[(0,l.jsx)(s.Form.Item,{name:`menu_name`,label:`Menu name`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{})}),(0,l.jsx)(s.Form.Item,{name:`menu_key`,label:`Menu key`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`jobs`})}),(0,l.jsx)(s.Form.Item,{name:`api_url`,label:`Route / API URL`,children:(0,l.jsx)(s.Input,{placeholder:`/jobs`})}),(0,l.jsx)(s.Form.Item,{name:`component_name`,label:`Component`,children:(0,l.jsx)(s.Input,{placeholder:`Jobs`})}),(0,l.jsxs)(`div`,{className:`admin-form-row`,children:[(0,l.jsx)(s.Form.Item,{name:`menu_type`,label:`Type`,children:(0,l.jsx)(s.Select,{options:[{value:`MENU`},{value:`FOOTER`},{value:`CHILD`}]})}),(0,l.jsx)(s.Form.Item,{name:`parent_menu_id`,label:`Parent`,children:(0,l.jsx)(s.Select,{allowClear:!0,options:g})})]}),(0,l.jsxs)(`div`,{className:`admin-form-row`,children:[(0,l.jsx)(s.Form.Item,{name:`display_order`,label:`Display order`,children:(0,l.jsx)(s.InputNumber,{min:0})}),(0,l.jsx)(s.Form.Item,{name:`status`,label:`Status`,children:(0,l.jsx)(s.Select,{options:[{value:`ACTIVE`},{value:`INACTIVE`}]})})]}),(0,l.jsx)(s.Form.Item,{name:`icon`,label:`Sidebar icon`,extra:`Saved in the menus collection and used dynamically in the application sidebar.`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,placeholder:`Select sidebar icon`,optionFilterProp:`label`,options:vE.map(({value:e,label:t})=>({value:e,label:t})),optionRender:e=>{let t=e?.value??e?.data?.value,n=vE.find(e=>e.value===t);return n?(0,l.jsx)(yE,{option:n}):t}})})]})})]})}var{Content:SE,Header:CE,Sider:wE}=s.Layout,{Text:TE,Title:EE}=s.Typography;function DE(e){return String(e??``).trim().replace(/[\s_-]+/g,` `).toUpperCase()}function OE(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function kE(e){return String(e||``).trim().toLowerCase()}function AE(e){return e?.key||e?.collectionName||e?.value||``}function jE(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=AE(e);if(!t)return;let o=kE(e.key||t),s=kE(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||OE(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=kE(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:OE(t),value:t,disabled:!1}))}),n}function ME(e){return DE(e?.user_type_name??e?.userTypeName??e?.name)===`SUPER ADMIN`}function NE(e){return`${e?.first_name??e?.firstName??``} ${e?.last_name??e?.lastName??``}`.trim()||e?.username||e?.userName||e?.email||`User ${e?.user_id??e?.userId??``}`}function PE(e){return e.flatMap(e=>{let t=e.menu_id??e.menuId??e.MenuID,n=e.menu_name??e.menuName??e.MenuName??`Menu ${t??``}`,r=e.menu_key??e.menuKey??e.MenuKey??``,i=e.permissions??e.Permissions??{};return Object.entries(i).map(([e,i])=>{let a=i.permission_id??i.permissionId??i.PermissionID,o=i.permission_key??i.permissionKey??i.PermissionKey??e,s=i.value??i.Value??i.access_value??i.accessValue??i;return{key:`${r??n??t}:${a??o}`,menuId:t,menuName:n,menuKey:r,permissionId:a,permissionKey:o,accessValue:+(Number(s)===1)}})})}function FE(e){return String(e.menuKey??e.menuName??e.menuId).trim().toLowerCase()}var IE=[{permissionId:null,permissionKey:`sendApprove`,permissionName:`Send Approve`}];function LE(e){let t=Array.isArray(e)?e:e?.permissions??e?.actions??e?.data??e,n=(Array.isArray(t)?t:Object.values(t??{})).map(e=>({permissionId:e.permission_id??e.permissionId??e.legacyPermissionId??e.id??null,permissionKey:e.permission_key??e.permissionKey??e.key,permissionName:e.permission_name??e.permissionName??e.name??e.label})).filter(e=>e.permissionKey),r=new Set(n.map(e=>String(e.permissionKey).trim().toLowerCase()));return IE.forEach(e=>{r.has(e.permissionKey.toLowerCase())||n.push(e)}),n}function RE(e={}){return String(e.permissionName??``).trim()||String(e.permissionKey??``).replaceAll(`_`,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/\b\w/g,e=>e.toUpperCase())}function zE({title:e,description:t,selectedName:n,loading:r,saving:i,rows:a,onChange:o,onMove:u,onSave:d}){let f=Object.values(a.reduce((e,t)=>{let n=FE(t);return e[n]||(e[n]={key:n,menuName:t.menuName,menuKey:t.menuKey,permissions:[]}),e[n].permissions.push(t),e},{}));return(0,l.jsxs)(`section`,{className:`admin-editor`,children:[(0,l.jsxs)(`div`,{className:`admin-section-head`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(EE,{level:4,children:e}),(0,l.jsx)(TE,{type:`secondary`,children:n||t})]}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),loading:i,disabled:!n||a.length===0,onClick:d,children:`Save`})]}),r?(0,l.jsx)(`div`,{className:`admin-loading`,children:(0,l.jsx)(s.Spin,{})}):f.length?(0,l.jsx)(s.Table,{size:`small`,rowKey:`key`,columns:[{title:`Menu`,dataIndex:`menuName`,width:220,render:(e,t)=>(0,l.jsxs)(`div`,{className:`admin-menu-order-cell`,children:[(0,l.jsxs)(`div`,{className:`admin-menu-cell`,children:[(0,l.jsx)(`span`,{children:e}),(0,l.jsx)(TE,{type:`secondary`,children:t.menuKey})]}),(0,l.jsxs)(s.Space,{size:2,children:[(0,l.jsx)(s.Button,{size:`small`,type:`text`,icon:(0,l.jsx)(c.ArrowUpOutlined,{}),onClick:()=>u(t.key,-1),"aria-label":`Move ${e} up`}),(0,l.jsx)(s.Button,{size:`small`,type:`text`,icon:(0,l.jsx)(c.ArrowDownOutlined,{}),onClick:()=>u(t.key,1),"aria-label":`Move ${e} down`})]})]})},{title:`Actions`,dataIndex:`permissions`,render:e=>(0,l.jsx)(`div`,{className:`admin-permission-controls`,children:e.filter(e=>Sx(e.menuName??e.menuKey,e.permissionKey)).map(e=>(0,l.jsx)(`label`,{className:`admin-permission-control`,children:(0,l.jsx)(s.Checkbox,{checked:e.accessValue===1,onChange:t=>o(e.key,+!!t.target.checked),"aria-label":`${e.menuName} ${e.permissionKey}`,children:RE(e)})},e.key))})}],dataSource:f,pagination:!1,scroll:{y:420}}):(0,l.jsx)(s.Empty,{description:`Select a record to customize permissions`})]})}function BE({onLogout:e}){let[r]=s.Form.useForm(),[i]=s.Form.useForm(),[a,u]=(0,o.useState)(`users`),[d,f]=(0,o.useState)(!0),[p,m]=(0,o.useState)(!1),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)([]),[y,b]=(0,o.useState)(0),[x,S]=(0,o.useState)(1),[C,w]=(0,o.useState)(10),[T,E]=(0,o.useState)(``),[D,O]=(0,o.useState)(!1),[k,A]=(0,o.useState)([]),[j,M]=(0,o.useState)([]),[N,P]=(0,o.useState)([]),[F,I]=(0,o.useState)(null),[L,R]=(0,o.useState)([]),[z,B]=(0,o.useState)(!1),[V,ee]=(0,o.useState)(null),[te,ne]=(0,o.useState)(!1),[re,ie]=(0,o.useState)(null),[ae,oe]=(0,o.useState)([]),[se,H]=(0,o.useState)(!1),[ce,le]=(0,o.useState)(!1),[ue,de]=(0,o.useState)(null),[fe,pe]=(0,o.useState)(!1),[me,he]=(0,o.useState)(null),[ge,_e]=(0,o.useState)(`listView`),[ve,ye]=(0,o.useState)([]),[be,xe]=(0,o.useState)([]),[Se,Ce]=(0,o.useState)(!1),[we,U]=(0,o.useState)(!1),W=t.d(),Te=(0,o.useMemo)(()=>ve.filter(e=>!e.disabled),[ve]),Ee=!Se&&Te.length===0,De=(0,o.useCallback)(async()=>{Ce(!0);try{let[e,t]=await Promise.all([n.Or(),n.br()]),r=jE(e.modules,t),i=new Set(r.filter(e=>!e.disabled).map(e=>e.value));ye(r),xe(e=>e.filter(e=>i.has(e)))}catch{s.message.error(`Failed to load seed status`)}finally{Ce(!1)}},[]);(0,o.useEffect)(()=>{De()},[De]);async function Oe(){if(be.length===0){s.message.warning(Ee?`All modules already seeded.`:`Select at least one module to seed.`);return}U(!0);try{await n.ui(be),s.message.success(`User type field config seeded`),xe([]),await De()}catch(e){s.message.error(e?.message||`Seed failed`)}finally{U(!1)}}async function ke(){f(!0);try{let[e,t,n]=await Promise.allSettled([ux(),mx(),vx()]),r=e.status===`fulfilled`?e.value:[];e.status===`rejected`&&s.message.error(e.reason?.message||`Unable to load user types`),A(r??[]),M(t.status===`fulfilled`?t.value??[]:[]),P(n.status===`fulfilled`?LE(n.value):[]),I((r??[])[0]?.user_type_id??null)}catch(e){s.message.error(e.message||`Unable to load admin data`)}finally{f(!1)}}(0,o.useEffect)(()=>{queueMicrotask(()=>{ke()})},[]);let Ae=(0,o.useCallback)(async()=>{O(!0);try{let{users:e,total:t}=await ax({limit:C,offset:(x-1)*C,search:T});v(e??[]),b(t??0)}catch(e){s.message.error(e?.message||`Unable to load users`),v([]),b(0)}finally{O(!1)}},[x,C,T]);(0,o.useEffect)(()=>{Ae()},[Ae]),(0,o.useEffect)(()=>{queueMicrotask(()=>{if(!F){R([]);return}m(!0),console.log(`DEBUG requesting role permissions for selectedUserTypeId=`,F,`localStorage scope=`,{tenantId:localStorage.getItem(`tenantId`),businessId:localStorage.getItem(`businessId`),businessUnitId:localStorage.getItem(`businessUnitId`)}),yx(F).then(e=>{console.log(`DEBUG raw groups from /get-role-details`,e);let t=PE(e??[]);console.log(`DEBUG savedRows (jobs only)`,t.filter(e=>FE(e)===`jobs`||FE(e)===`job`));let n=new Map(t.map(e=>[`${FE(e)}:${String(e.permissionKey).toLowerCase()}`,e.accessValue]));console.log(`DEBUG savedAccess keys`,[...n.keys()]),console.log(`DEBUG menus (jobs only)`,j.filter(e=>String(e.menu_key??e.menu_name??e.menu_id).trim().toLowerCase()===`jobs`));let r=j.flatMap(e=>N.map(t=>{let r=String(e.menu_key??e.menu_name??e.menu_id).trim().toLowerCase(),i=String(t.permissionKey).toLowerCase();return{key:`${e.menu_key??e.menu_name??e.menu_id}:${t.permissionId??t.permissionKey}`,menuId:e.menu_id,menuName:e.menu_name,menuKey:e.menu_key,permissionId:t.permissionId,permissionKey:t.permissionKey,accessValue:n.get(`${r}:${i}`)??0}}));console.log(`DEBUG final rows (jobs only)`,r.filter(e=>FE(e)===`jobs`||FE(e)===`job`)),R(r)}).catch(e=>s.message.error(e.message||`Unable to load role permissions`)).finally(()=>m(!1))})},[F,j,N]);let je=(0,o.useMemo)(()=>k.find(e=>e.user_type_id===F),[F,k]),Me=(0,o.useMemo)(()=>k.reduce((e,t)=>({...e,[t.user_type_id]:t.user_type_name}),{}),[k]),Ne=(0,o.useMemo)(()=>_.reduce((e,t)=>({...e,[t.user_id]:NE(t)}),{}),[_]),G=(0,o.useMemo)(()=>k.filter(e=>!ME(e)),[k]),Pe=(0,o.useMemo)(()=>_.filter(e=>!ME({user_type_id:e.user_type_id,user_type_name:Me[e.user_type_id]})),[Me,_]);(0,o.useEffect)(()=>{if(!z){oe([]);return}let e=Number(r.getFieldValue(`user_type_id`)??0);if(!e){oe([]);return}let t=!1;return H(!0),ox(e).then(e=>{t||oe(e.filter(e=>!V||e.user_id!==V.user_id))}).catch(e=>{t||(s.message.error(e.message||`Unable to load reporting users`),oe([]))}).finally(()=>{t||H(!1)}),()=>{t=!0}},[V,r,z]);let Fe=(0,o.useMemo)(()=>{let e=ae.map(e=>({label:NE(e),value:e.user_id})),t=Number(V?.reporting_id??V?.reportingId??0);return!t||e.some(e=>Number(e.value)===t)?e:[{label:V?.reportingName??V?.reporting_name??Ne[t]??`User ${t}`,value:t},...e]},[V,ae,Ne]),Ie=(0,o.useMemo)(()=>{let e=G.map(e=>({label:e.user_type_name,value:e.user_type_id}));if(!V)return e;let t=Number(V.user_type_id??0);return e.some(e=>Number(e.value)===t)?e:[{label:Me[t]??V.userType??V.roleName??(t>0?`Type ${t}`:`Unassigned`),value:t},...e]},[V,G,Me]);k.length,j.length;let Le=[{key:`form-groups`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.AppstoreAddOutlined,{}),` Form Groups`]}),title:`Form Groups`,description:`Build module add and edit form groups with validations, dropdowns, and custom forms.`,component:(0,l.jsx)(IC,{})},{key:`detail-groups`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.BgColorsOutlined,{}),` Detail Groups`]}),title:`Detail Groups`,description:`Control detail-view labels, rendering, lookups, merged fields, and display defaults.`,component:(0,l.jsx)(mw,{})},{key:`actions`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.ThunderboltOutlined,{}),` Actions`]}),title:`Actions`,description:`Manage row action buttons and their visibility rules from one workspace.`,component:(0,l.jsx)(rT,{})},{key:`templates`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.MailOutlined,{}),` Templates`]}),title:`Templates`,description:`Manage reusable email templates and signatures.`,component:(0,l.jsx)(hT,{})},{key:`ai-services`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.ThunderboltOutlined,{}),` AI Services`]}),title:`AI Services`,description:`Register the AI and automation services used by admin-configured AI actions.`,component:(0,l.jsx)(yT,{})},{key:`bgc-integration`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.SafetyCertificateOutlined,{}),` Integrations`]}),title:`Integrations`,description:`Manage manual and API integrations used across application workflows.`,component:(0,l.jsx)(TT,{})},{key:`automations`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.ApartmentOutlined,{}),` Automations`]}),title:`Automations`,description:`Reference ids, duplicate checks, cross-module snapshots, reporting-chain hierarchy expansion, board updates, notifications, and cache invalidation — per module, config-driven.`,component:(0,l.jsx)(zT,{})},{key:`workflows`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.ApartmentOutlined,{}),` Workflows`]}),title:`Workflows`,description:`Event-driven behavior per module (beforeCreate/afterCreate/…): the metadata the platform Workflow Engine executes — where the jobs, candidates, and submissions create flows live.`,component:(0,l.jsx)(qT,{})},{key:`po-msa-settings`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.SafetyCertificateOutlined,{}),` PO/MSA Settings`]}),title:`PO/MSA Settings`,description:`Configure employer and referral MSA validity and expiry warning days.`,component:(0,l.jsx)(hE,{})},{key:`masters`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.AppstoreAddOutlined,{}),` Masters`]}),title:`Masters`,description:`Shared Location and Tax lists used across modules (e.g. the submission form’s W2 employer section).`,component:(0,l.jsx)(fE,{})}],Re=[{key:`users`,icon:(0,l.jsx)(c.UserOutlined,{}),label:`Users`},{key:`roles`,icon:(0,l.jsx)(c.TeamOutlined,{}),label:`User Types`},{key:`menus`,icon:(0,l.jsx)(c.MenuOutlined,{}),label:`Menus`},{key:`configurations`,icon:(0,l.jsx)(c.AppstoreAddOutlined,{}),label:`Configurations`},{key:`integrations`,icon:(0,l.jsx)(c.SafetyCertificateOutlined,{}),label:`Integrations`}];function ze(e,t){R(n=>{let r=n.filter(t=>t.key===e).length;return console.log(`DEBUG updateRolePermission`,{key:e,value:t,matchCount:r}),n.map(n=>n.key===e?{...n,accessValue:t}:n)})}async function Be(){g(!0);try{console.log(`DEBUG saveRolePermissions jobs rows`,L.filter(e=>FE(e)===`jobs`||FE(e)===`job`)),await bx(F,L.map(e=>({menu_id:e.menuId,menu_name:e.menuName,menu_key:e.menuKey,permission_id:e.permissionId,permission_key:e.permissionKey,access_value:e.accessValue,updated_by:W?.userId??null}))),s.message.success(`Role permissions updated`)}catch(e){s.message.error(e.message||`Unable to save role permissions`)}finally{g(!1)}}function K(){ee(null),r.resetFields(),r.setFieldsValue({status:`ACTIVE`,user_type_id:G[0]?.user_type_id,reporting_id:0}),B(!0)}function q(e){ee(e),r.setFieldsValue({first_name:e.first_name,last_name:e.last_name,username:e.username,email:e.email,mobile:e.mobile,user_type_id:e.user_type_id,reporting_id:e.reporting_id??e.reportingId??0,profile_image:e.profile_image,status:e.status}),B(!0)}async function Ve(e){ne(!0);try{let t={...e,status:e.status===1||e.status===`1`||e.status===!0?`ACTIVE`:e.status===0||e.status===`0`||e.status===!1?`INACTIVE`:String(e.status??`ACTIVE`).toUpperCase(),updated_by:W?.userId??null,created_by:W?.userId??null};t.password||delete t.password,V?(await cx(V.user_id,t),s.message.success(`User updated`)):(await sx(t),s.message.success(`User created`)),B(!1),ee(null),await Ae()}catch(e){s.message.error(e.message||`Unable to save user`)}finally{ne(!1)}}async function J(e){ie(e);try{await lx(e),s.message.success(`User deleted`),await Ae()}catch(e){s.message.error(e.message||`Unable to delete user`)}finally{ie(null)}}function He(e,t){_e(`listView`),he({kind:e,record:t}),e===`role`&&I(t.user_type_id)}function Ue(e,t){R(n=>{let r=[...new Set(n.map(FE))],i=r.indexOf(e),a=i+t;if(i<0||a<0||a>=r.length)return n;[r[i],r[a]]=[r[a],r[i]];let o=new Map(r.map((e,t)=>[e,t]));return[...n].sort((e,t)=>o.get(FE(e))-o.get(FE(t)))})}function We(){de(null),i.resetFields(),i.setFieldsValue({status:`ACTIVE`}),le(!0)}function Ge(e){de(e),le(!0),i.setFieldsValue(e)}async function Ke(e){pe(!0);try{let t=W?.userId??null,n=!!ue,r=n?await fx(ue.user_type_id,{...e,updated_by:t}):await dx({...e,created_by:t,visible_menu_ids:[]}),i=r.user_type_id;s.message.success(n?`User type updated`:`User type created. Customize its menus and permissions.`),le(!1),await ke(),I(i),n||(_e(`permissions`),he({kind:`role`,record:{...e,...r,user_type_id:i,user_type_name:r.user_type_name??e.user_type_name}}))}catch(e){s.message.error(e.message||`Unable to save role`)}finally{pe(!1)}}async function Y(e){try{await px(e),s.message.success(`Role deleted`),await ke()}catch(e){s.message.error(e.message||`Unable to delete role`)}}return(0,l.jsxs)(s.Layout,{className:`admin-shell`,children:[(0,l.jsx)(wE,{width:248,className:`admin-sider`,children:(0,l.jsxs)(`div`,{className:`admin-sidebar-nav`,children:[(0,l.jsx)(TE,{className:`admin-sidebar-title`,children:`Admin Menu`}),(0,l.jsx)(s.Menu,{theme:`dark`,mode:`inline`,selectedKeys:[a],onClick:({key:e})=>u(e),items:Re})]})}),(0,l.jsx)(s.Layout,{children:(0,l.jsxs)(SE,{className:`admin-content`,children:[(0,l.jsx)(l.Fragment,{children:(0,l.jsx)(s.Tabs,{activeKey:a,onChange:u,tabBarStyle:{display:`none`},items:[{key:`users`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.UserOutlined,{}),` Users`]}),children:(0,l.jsx)(`div`,{className:`admin-stack`,children:(0,l.jsxs)(`section`,{className:`admin-section`,children:[(0,l.jsxs)(`div`,{className:`admin-section-head`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(EE,{level:4,children:`Users`}),(0,l.jsx)(TE,{type:`secondary`,children:`Create and manage users with non-super-admin user types.`})]}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:K,children:`Add`})]}),(0,l.jsx)(km,{listName:`Users`,loading:D,fields:[{label:`Name`,value:`first_name`,render:(e,t)=>`${e??``} ${t.last_name??``}`.trim()||t.username},{label:`Email`,value:`email`},{label:`User Type`,value:`user_type_id`,width:160,render:(e,t)=>Me[e]||t?.userType||t?.user_type||(Number(e)>0?`Type ${e}`:`—`)},{label:`Reporting Manager`,value:`reporting_id`,width:180,render:(e,t)=>Ne[e]||t?.reportingName||t?.reporting_name||(Number(e)>0?`User ${e}`:`None`)},{label:`Status`,value:`status`,width:110,sorter:!1,render:e=>(0,l.jsx)(s.Tag,{color:e===`ACTIVE`?`green`:`default`,children:e})},{label:`Actions`,value:`_actions`,width:150,sorter:!1,render:(e,t)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Button,{"aria-label":`Edit user`,icon:(0,l.jsx)(c.EditOutlined,{}),size:`small`,onClick:()=>q(t)}),(0,l.jsx)(s.Popconfirm,{title:`Delete user?`,description:`This removes the user from the auth database.`,okText:`Delete`,okButtonProps:{danger:!0},onConfirm:()=>J(t.user_id),children:(0,l.jsx)(s.Button,{danger:!0,"aria-label":`Delete user`,icon:(0,l.jsx)(c.DeleteOutlined,{}),loading:re===t.user_id,size:`small`})})]})}],dataSource:Pe.map(e=>({...e,key:e.user_id})),total:y,current:x,pageSize:C,onPageChange:S,onPageSizeChange:e=>{w(e),S(1)},onSearch:e=>{E(e??``),S(1)},rowSelection:!1})]})})},{key:`roles`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.TeamOutlined,{}),` User Types`]}),children:(0,l.jsxs)(`div`,{className:`admin-stack`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.AppstoreOutlined,{}),title:`Field Config Seed`,style:{marginBottom:12},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[(0,l.jsx)(`div`,{style:{minWidth:320,flex:1},children:(0,l.jsx)(s.Select,{mode:`multiple`,allowClear:!0,showSearch:!0,value:be,options:ve,placeholder:Ee?`All modules already seeded`:`Select modules or collections to seed`,disabled:Se||we||Ee,loading:Se,onChange:xe,style:{width:`100%`}})}),(0,l.jsx)(s.Button,{type:`primary`,loading:we,disabled:Se||be.length===0,onClick:Oe,children:`Seed Field Config`})]}),(0,l.jsx)(TE,{type:`secondary`,style:{display:`block`,marginTop:8,fontSize:12},children:Ee?`Seed is disabled because all configured modules already have user type field config data.`:`Already seeded modules are disabled. New modules or collections can still be seeded.`})]}),(0,l.jsxs)(`section`,{className:`admin-section`,children:[(0,l.jsxs)(`div`,{className:`admin-section-head`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(EE,{level:4,children:`User Types`}),(0,l.jsx)(TE,{type:`secondary`,children:`Role level permissions are inherited by users.`})]}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:We,children:`Add Role`})]}),(0,l.jsx)(km,{listName:`User Types`,loading:d,fields:[{label:`User Type`,value:`user_type_name`},{label:`Description`,value:`description`},{label:`Status`,value:`status`,width:110,sorter:!1,render:e=>(0,l.jsx)(s.Tag,{color:e===`ACTIVE`?`green`:`default`,children:e})},{label:`Actions`,value:`_actions`,width:260,sorter:!1,render:(e,t)=>{let n=Number(t.role_type)===1;return(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Button,{"aria-label":`Configure role`,size:`small`,onClick:()=>He(`role`,t),children:`Config`}),(0,l.jsx)(s.Button,{"aria-label":`Edit role`,disabled:!n,icon:(0,l.jsx)(c.EditOutlined,{}),size:`small`,onClick:()=>Ge(t)}),n&&!ME(t)&&(0,l.jsx)(s.Popconfirm,{title:`Delete role?`,onConfirm:()=>Y(t.user_type_id),children:(0,l.jsx)(s.Button,{"aria-label":`Delete role`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{}),size:`small`})})]})}}],dataSource:k.map(e=>({...e,key:e.user_type_id,roleId:e.user_type_id,roleName:e.user_type_name})),total:k.length,rowSelection:!1})]})]})},{key:`menus`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.MenuOutlined,{}),` Menus`]}),children:(0,l.jsx)(xE,{})},{key:`configurations`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.AppstoreAddOutlined,{}),` Configurations`]}),children:(0,l.jsxs)(`section`,{className:`admin-section admin-config-workspace`,children:[(0,l.jsxs)(`div`,{className:`admin-section-head`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(EE,{level:4,children:`Configuration Center`}),(0,l.jsx)(TE,{type:`secondary`,children:`CORE-THEME admin modules embedded into the admin dashboard.`})]}),(0,l.jsxs)(s.Tag,{color:`blue`,children:[Le.length,` configurations`]})]}),(0,l.jsx)(s.Tabs,{className:`admin-config-tabs`,defaultActiveKey:`form-groups`,tabPosition:`left`,items:Le.map(e=>({key:e.key,label:e.label,children:(0,l.jsxs)(`div`,{className:`admin-config-panel`,children:[(0,l.jsx)(`div`,{className:`admin-config-panel-head`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(EE,{level:4,children:e.title}),(0,l.jsx)(TE,{type:`secondary`,children:e.description})]})}),(0,l.jsx)(`div`,{className:`admin-config-panel-body`,children:e.component})]})}))})]})},{key:`integrations`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.SafetyCertificateOutlined,{}),` Integrations`]}),children:(0,l.jsxs)(`section`,{className:`admin-section admin-config-workspace`,children:[(0,l.jsx)(`div`,{className:`admin-section-head`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(EE,{level:4,children:`Integrations`}),(0,l.jsx)(TE,{type:`secondary`,children:`Configure external services used by onboarding and other workflows.`})]})}),(0,l.jsx)(`div`,{className:`admin-config-panel`,children:(0,l.jsx)(`div`,{className:`admin-config-panel-body`,children:(0,l.jsx)(TT,{})})})]})}]})}),(0,l.jsxs)(s.Modal,{className:`uss-modal`,title:`Configure User Type: ${me?.record?.user_type_name??``}`,open:!!me,onCancel:()=>he(null),footer:null,destroyOnHidden:!0,width:900,children:[(0,l.jsx)(`div`,{className:`uss-config-toggle`,style:{marginBottom:12},children:[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`},{key:`actions`,label:`Actions`}].map(e=>(0,l.jsx)(`button`,{type:`button`,className:`uss-config-btn${ge===e.key?` active`:``}`,onClick:()=>_e(e.key),children:e.label},e.key))}),me&&ge===`permissions`?(0,l.jsx)(zE,{title:`Role Permissions`,description:`Configure menu permissions for this user type`,selectedName:je?.user_type_name,loading:p,saving:h,rows:L,onChange:ze,onMove:Ue,onSave:Be}):me&&ge===`actions`?(0,l.jsx)(iS,{role:{...me.record,roleId:me.record.user_type_id,roleName:me.record.user_type_name}},`${me.record?.user_type_id}-actions`):me&&ge===`form`?(0,l.jsx)(Xx,{role:{...me.record,roleId:me.record.user_type_id,roleName:me.record.user_type_name}},`${me.record?.user_type_id}-form`):me?(0,l.jsx)(zx,{role:{...me.record,roleId:me.record.user_type_id,roleName:me.record.user_type_name},configType:ge},`${me.record?.user_type_id}-${ge}`):null]}),(0,l.jsx)(s.Modal,{className:`admin-role-modal`,title:ue?`Edit User Type`:`Create User Type`,open:ce,onCancel:()=>le(!1),onOk:()=>i.submit(),okText:ue?`Save`:`Next`,confirmLoading:fe,destroyOnHidden:!0,width:900,children:(0,l.jsxs)(s.Form,{form:i,layout:`vertical`,onFinish:Ke,children:[(0,l.jsx)(s.Form.Item,{name:`user_type_name`,label:`Role name`,rules:[{required:!0,message:`Role name is required`}],children:(0,l.jsx)(s.Input,{placeholder:`Recruiter`})}),(0,l.jsx)(s.Form.Item,{name:`description`,label:`Description`,children:(0,l.jsx)(s.Input.TextArea,{rows:3})}),(0,l.jsx)(s.Form.Item,{name:`status`,label:`Status`,children:(0,l.jsx)(s.Select,{options:[{value:`ACTIVE`},{value:`INACTIVE`}]})})]})}),(0,l.jsx)(s.Modal,{className:`admin-user-modal`,title:V?`Edit User`:`Add User`,open:z,onCancel:()=>B(!1),onOk:()=>r.submit(),confirmLoading:te,destroyOnHidden:!0,children:(0,l.jsxs)(s.Form,{form:r,layout:`vertical`,requiredMark:!1,onFinish:Ve,children:[(0,l.jsxs)(`div`,{className:`admin-form-row`,children:[(0,l.jsx)(s.Form.Item,{label:`First Name`,name:`first_name`,rules:[{required:!0,message:`First name is required`}],children:(0,l.jsx)(s.Input,{placeholder:`John`})}),(0,l.jsx)(s.Form.Item,{label:`Last Name`,name:`last_name`,children:(0,l.jsx)(s.Input,{placeholder:`Doe`})})]}),(0,l.jsx)(s.Form.Item,{label:`Username`,name:`username`,rules:[{required:!0,message:`Username is required`}],children:(0,l.jsx)(s.Input,{placeholder:`john.doe`})}),(0,l.jsx)(s.Form.Item,{label:`Email`,name:`email`,rules:[{required:!0,message:`Email is required`},{type:`email`,message:`Enter a valid email`}],children:(0,l.jsx)(s.Input,{placeholder:`john@example.com`})}),(0,l.jsx)(s.Form.Item,{label:`Password`,name:`password`,rules:V?[]:[{required:!0,message:`Password is required`}],children:(0,l.jsx)(s.Input.Password,{placeholder:V?`Leave empty to keep current password`:`Password`})}),(0,l.jsxs)(`div`,{className:`admin-form-row`,children:[(0,l.jsx)(s.Form.Item,{label:`Mobile`,name:`mobile`,children:(0,l.jsx)(s.Input,{placeholder:`9999999999`})}),(0,l.jsx)(s.Form.Item,{label:`User Type`,name:`user_type_id`,rules:[{required:!0,message:`User type is required`}],children:(0,l.jsx)(s.Select,{placeholder:`Select user type`,onChange:()=>{oe([]),queueMicrotask(()=>{let e=Number(r.getFieldValue(`user_type_id`)??0);e&&(H(!0),ox(e).then(e=>{oe(e.filter(e=>!V||e.user_id!==V.user_id))}).catch(e=>{s.message.error(e.message||`Unable to load reporting users`),oe([])}).finally(()=>{H(!1)}))})},options:Ie})})]}),(0,l.jsx)(s.Form.Item,{label:`Reporting Manager`,name:`reporting_id`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,loading:se,placeholder:`Select reporting manager`,optionFilterProp:`label`,options:[{label:`None`,value:0},...Fe]})}),(0,l.jsx)(s.Form.Item,{label:`Profile Image`,name:`profile_image`,children:(0,l.jsx)(s.Input,{placeholder:`https://...`})}),(0,l.jsx)(s.Form.Item,{label:`Status`,name:`status`,children:(0,l.jsx)(s.Select,{options:[{label:`ACTIVE`,value:`ACTIVE`},{label:`INACTIVE`,value:`INACTIVE`}]})})]})})]})})]})}var VE=BE;function HE(e,t){return String(e||t).replace(/\/\*$/,``).replace(/\/+$/,``)||t}function UE({loginPath:e=`/login`,adminPath:t=`/admin`,fallbackPath:n=`/`}){let r=(0,d.useNavigate)(),i=HE(e,`/login`),a=HE(t,`/admin`),o=`${a}/*`;return(0,l.jsxs)(d.Routes,{children:[(0,l.jsx)(d.Route,{path:i,element:(0,l.jsx)(db,{defaultRedirectPath:a,onLogin:()=>r(a,{replace:!0})})}),(0,l.jsx)(d.Route,{path:o,element:(0,l.jsx)(rb,{loginPath:i,children:(0,l.jsx)(ub,{children:(0,l.jsx)(VE,{onLogout:()=>r(i,{replace:!0})})})})}),(0,l.jsx)(d.Route,{path:n,element:(0,l.jsx)(d.Navigate,{to:a,replace:!0})}),(0,l.jsx)(d.Route,{path:`*`,element:(0,l.jsx)(d.Navigate,{to:a,replace:!0})})]})}function WE(e){return(0,l.jsx)(d.BrowserRouter,{children:(0,l.jsx)(UE,{...e})})}function GE(e){return Array.isArray(e)?e.map(String).map(e=>e.trim()).filter(Boolean):String(e??``).split(`,`).map(e=>e.trim()).filter(Boolean)}function KE(e){return GE(e).every(e=>/^[^,\s@]+@[^,\s@]+\.[^\s@]{2,}$/.test(e))}var{Text:qE}=s.Typography,JE=new Set([`file`,`document`,`attachment`]);function YE(e){return JE.has(String(e?.type??``).trim().toLowerCase())}function XE(e){return String(e??``).trim().toLowerCase().replace(/[^a-z0-9]/g,``)}function ZE(e){return e?typeof e==`string`?e:String(typeof e==`object`?e?._id??e?.id??e?.$oid??``:e):``}function QE(e,t,n){if(!e)return``;let r=XE(t),i=XE(n);if(!r||r===i||r.replace(/s$/,``)===i.replace(/s$/,``))return ZE(e?._id??e?.id);let a=r.replace(/s$/,``),o=[`${a}Id`,`${r}Id`,a,r,`${a}._id`,`${r}._id`];for(let t of o){let n=ZE(nD(e,t));if(n)return n}return``}async function $E(e){let t=e?.fileUrl??e?.url??e?.downloadUrl;if(!t)return null;let n=await fetch(t);if(!n.ok)throw Error(`Unable to load attachment ${e?.fileName||``}`.trim());let r=await n.blob(),i=e?.fileName??e?.uploadedFileName??e?.uniqueName??`attachment`;return new File([r],i,{type:e?.contentType||r.type||`application/octet-stream`})}async function eD(e,t,r){if(!t)return[];let i=[];(e?.placeholders??[]).forEach(e=>{(e?.holders??[]).filter(YE).forEach(a=>{let o=QE(t,e?.moduleName,r);o&&i.push((async()=>{let t=await n.yn(e.moduleName,o,a.value);return Promise.all((t?.data??[]).map($E))})())})});let a=(await Promise.all(i)).flat().filter(Boolean),o=new Set;return a.filter(e=>{let t=`${e.name}:${e.size}:${e.type}`;return!o.has(t)&&(o.add(t),!0)})}function tD(e,t){return[...new Set([...GE(e),...GE(t)])].join(`, `)}function nD(e,t,n=``){let r=String(n??``).trim().toLowerCase();return String(t??``).split(`.`).reduce((e,t)=>{let n=e;return Array.isArray(n)&&r===`last`&&(n=n.at(-1)),n?.[t]},e)}function rD(e,t,n){if(!n)return String(e??``);let r=new Map;return(t??[]).forEach(e=>(e.holders??[]).forEach(e=>{r.set(e.key,YE(e)?``:nD(n,e.value,e.arrayMode))})),String(e??``).replace(/{{\.?([\w.]+)}}/g,(e,t)=>{let n=r.get(t);return n==null?e:String(n)})}function iD({value:e,onChange:t,defaultTemplateId:r=``,ready:i=!0,title:a=`Mail`,hint:u,bccHint:d,afterBcc:f,beforeFields:p,className:m=``,contextRecords:h=[],moduleName:g=``}){let _=(0,o.useRef)(``),v=n=>t?.({...e,...n});async function y(t,n=!1){if(t)try{let r=await ww(t),i=h[0],a=await eD(r,i,g);v({to:tD(e.to,(r?.toMail??[]).map(e=>rD(e,r?.placeholders,i))),cc:tD(e.cc,(r?.ccMail??[]).map(e=>rD(e,r?.placeholders,i))),bcc:tD(e.bcc,(r?.bccMail??[]).map(e=>rD(e,r?.placeholders,i))),subject:rD(r?.subject,r?.placeholders,i),contents:rD(r?.body,r?.placeholders,i),attachments:a}),n||s.message.success(`Loaded ${r?.name||`email template`}`)}catch(e){n||s.message.error(e?.message||`Could not load email template`)}}return(0,o.useEffect)(()=>{!i||!r||_.current===r||(_.current=r,y(r,!0))},[r,i]),(0,l.jsxs)(`div`,{className:`common-mail-composer ${m}`.trim(),children:[(0,l.jsx)(`div`,{className:`mail-popup__header`,children:(0,l.jsxs)(`div`,{className:`mail-popup__header-brand`,children:[(0,l.jsx)(`span`,{className:`dynamic-popup__header-icon-box`,children:(0,l.jsx)(c.MailOutlined,{})}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`span`,{className:`dynamic-popup__header-label`,children:a}),u&&(0,l.jsx)(qE,{type:`secondary`,className:`mail-popup__header-hint`,children:u})]})]})}),(0,l.jsxs)(`div`,{className:`mail-popup__body`,children:[p&&(0,l.jsxs)(l.Fragment,{children:[p,(0,l.jsx)(s.Divider,{})]}),(0,l.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,l.jsx)(qE,{type:`secondary`,className:`mail-popup__field-label`,children:`To`}),(0,l.jsx)(s.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`],value:GE(e.to),onChange:e=>v({to:e.join(`, `)}),variant:`borderless`,className:`mail-popup__recipient-select`,placeholder:`Add email addresses`}),(0,l.jsxs)(`div`,{className:`mail-popup__cc-bcc-actions`,children:[!e.showCc&&(0,l.jsx)(`span`,{className:`mail-popup__cc-bcc-link`,onClick:()=>v({showCc:!0}),children:`Cc`}),!e.showBcc&&(0,l.jsx)(`span`,{className:`mail-popup__cc-bcc-link`,onClick:()=>v({showBcc:!0}),children:`Bcc`})]})]}),(0,l.jsx)(s.Divider,{}),e.showCc&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,l.jsx)(qE,{type:`secondary`,className:`mail-popup__field-label`,children:`Cc`}),(0,l.jsx)(s.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`],value:GE(e.cc),onChange:e=>v({cc:e.join(`, `)}),variant:`borderless`,className:`mail-popup__recipient-select`})]}),(0,l.jsx)(s.Divider,{})]}),e.showBcc&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,l.jsx)(qE,{type:`secondary`,className:`mail-popup__field-label`,children:`Bcc`}),(0,l.jsx)(s.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`],value:GE(e.bcc),onChange:e=>v({bcc:e.join(`, `)}),variant:`borderless`,className:`mail-popup__recipient-select`,placeholder:d})]}),f,(0,l.jsx)(s.Divider,{})]}),(0,l.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,l.jsx)(qE,{type:`secondary`,className:`mail-popup__field-label`,children:`Subject`}),(0,l.jsx)(s.Input,{variant:`borderless`,value:e.subject,onChange:e=>v({subject:e.target.value}),placeholder:`Enter subject`,className:`mail-popup__field-input`})]}),(0,l.jsx)(s.Divider,{}),!!e.attachments?.length&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,l.jsx)(qE,{type:`secondary`,className:`mail-popup__field-label`,children:`Attachments`}),(0,l.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:6,padding:`4px 0`},children:e.attachments.map((e,t)=>(0,l.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,l.jsx)(c.PaperClipOutlined,{}),e.name]},`${e.name}:${e.size}:${t}`))})]}),(0,l.jsx)(s.Divider,{})]}),(0,l.jsxs)(`div`,{className:`mail-popup__message-section`,children:[(0,l.jsx)(qE,{type:`secondary`,className:`mail-popup__message-label`,children:`Message`}),(0,l.jsx)(n.Dn,{value:e.contents,onChange:e=>v({contents:e})})]})]})]})}var{Text:aD}=s.Typography,oD=/^[a-fA-F0-9]{24}$/,sD=new Set([`file`,`document`,`attachment`]);async function cD(e){let t=e?.fileUrl??e?.url??e?.downloadUrl;if(!t)return null;let n=await fetch(t);if(!n.ok)throw Error(`Unable to load attachment ${e?.fileName||``}`.trim());let r=await n.blob(),i=e?.fileName??e?.uploadedFileName??e?.uniqueName??`attachment`;return new File([r],i,{type:e?.contentType||r.type||`application/octet-stream`})}async function lD(e,t,r=[]){let i=String(e??``);if(!i||!r.length||!t)return{contents:i,attachments:[]};let a=(await n.Vr(t).catch(()=>[])).filter(e=>sD.has(String(e?.type??``).trim().toLowerCase())).filter(e=>{let t=String(e?.value??e?.field??e?.fieldKey??e?.key??e?.name??``).replace(/^\./,``);return t&&(i.includes(`{{.${t}}}`)||i.includes(`{{${t}}}`))});if(!a.length)return{contents:i,attachments:[]};let o=[];for(let e of a){let a=String(e?.value??e?.field??e?.fieldKey??e?.key??e?.name??``).replace(/^\./,``);i=i.replaceAll(`{{.${a}}}`,``).replaceAll(`{{${a}}}`,``);for(let e of r){let r=String(e?._id??e?.id??``);if(!oD.test(r))continue;let i=await n.yn(t,r,a).catch(()=>({data:[]})),s=await Promise.all((i?.data??[]).map(cD));o.push(...s.filter(Boolean))}}let s=new Set,c=o.filter(e=>{let t=`${e.name}:${e.size}:${e.type}`;return!s.has(t)&&(s.add(t),!0)});return{contents:i,attachments:c}}function uD(e){return e===!0?!0:typeof e==`number`?e===1:typeof e==`string`&&[`true`,`1`,`yes`,`y`,`on`].includes(e.trim().toLowerCase())}function dD(e){return[`candidate`,`candidates`].includes(String(e??``).trim().toLowerCase())}function fD(e,...t){for(let n of t){let t=String(n).split(`.`).reduce((e,t)=>e?.[t],e);if(t!=null&&String(t).trim()!==``)return t}}function pD(e){return[fD(e,`jobReferenceId`,`clientJobId`,`jobCode`,`reqId`,`jobId`),fD(e,`jobTitle`,`title`,`name`)].filter(Boolean).join(` - `)||String(fD(e,`_id`,`id`)??`Job`)}function mD(e){let t=fD(e,`_id`,`id`,`jobId`);return t?{value:String(t),label:pD(e),raw:e}:null}function hD(e=[],t=[]){let n=[...t,`email`,`candidateEmail`,`candidate_email`,`emailId`,`mailId`,`alternateEmail`,`altEmail`,`basicDetails.email`,`basicDetails.alternateEmail`,`basicDetails.altEmail`,`candidate.email`,`candidate.emailId`,`submission.email`,`submission.candidateEmail`].filter(Boolean);return e.flatMap(e=>n.map(t=>fD(e,t))).flatMap(e=>Array.isArray(e)?e:[e]).flatMap(GE)}function gD(e){return e?.data?.record??e?.record??e?.data??e}function _D(e){let t=fD(e,`jobId`,`job_id`,`job._id`,`job.id`,`jobs._id`,`jobs.id`);return typeof t==`object`?fD(t,`_id`,`id`,`$oid`):t}function vD(e={}){return{subject:e.subject??e.Subject??``,contents:e.contents??e.Contents??e.body??e.Body??``,toMail:e.toMail??e.ToMail??[],ccMail:e.ccMail??e.CcMail??[],bccMail:e.bccMail??e.BccMail??[]}}function yD(){let e=(0,d.useNavigate)(),{state:t={}}=(0,d.useLocation)(),{selectedIds:r=[],selectedRecords:i=[],recipients:a=[],subject:c=``,onSend:u,moduleName:f=``,popupAction:p={}}=t,m=uD(p.requireJobId)||uD(t.requireJobId)||dD(f),h=(0,o.useMemo)(()=>[p.recipientField,p.recipientPath,t.recipientField,t.recipientPath],[p.recipientField,p.recipientPath,t.recipientField,t.recipientPath]),g=r.join(`|`),_=(0,o.useMemo)(()=>[...a,...hD(i,h)],[a,i,h]),v=String(t.jobId??_D(i[0])??``).trim(),y=r[0]??i[0]?._id??i[0]?.id??``,[b,x]=(0,o.useState)(v),[S,C]=(0,o.useState)(m?v:String(v||y||``)),[w,T]=(0,o.useState)({to:[...new Set(_)].join(`, `),cc:``,bcc:``,subject:c,contents:``,attachments:[],showCc:!1,showBcc:!1}),[E,D]=(0,o.useState)(!S),[O,k]=(0,o.useState)(!1),[A,j]=(0,o.useState)([]),[M,N]=(0,o.useState)(!1),[P,F]=(0,o.useState)(!1),I=(0,o.useRef)(!1),L=(0,o.useRef)(``),R=(0,o.useRef)(0);(0,o.useEffect)(()=>{if(!dD(f)||I.current||GE(w.to).length>0||r.length===0||L.current===g)return;let e=!1;return L.current=g,Promise.all(r.map(e=>n.hn(f,e).catch(()=>null))).then(t=>{if(e)return;let n=hD(t.map(gD).filter(Boolean),h);n.length&&T(e=>GE(e.to).length>0?e:{...e,to:[...new Set(n)].join(`, `)})}),()=>{e=!0}},[w.to,f,h,g,r]),(0,o.useEffect)(()=>{if(!S){D(!0);return}let e=++R.current,t=!1;async function n(){D(!1),k(!0),T(e=>({...e,contents:``}));try{let n=vD(await sn(S)),r=await lD(n.contents||``,f,i),a=r.contents;if(a.trim())try{a=await cn(a,n.subject||c)}catch(n){!t&&e===R.current&&s.message.warning(n?.message||`Mail content formatting failed. Showing original content.`)}if(t||e!==R.current)return;T(e=>({...e,subject:n.subject||e.subject,to:n.toMail?.length?Array.isArray(n.toMail)?n.toMail.join(`, `):String(n.toMail):e.to,cc:n.ccMail?.length?Array.isArray(n.ccMail)?n.ccMail.join(`, `):String(n.ccMail):e.cc,bcc:n.bccMail?.length?Array.isArray(n.bccMail)?n.bccMail.join(`, `):String(n.bccMail):e.bcc,contents:a||r.contents||e.contents,attachments:r.attachments,showCc:e.showCc||!!n.ccMail?.length,showBcc:e.showBcc||!!n.bccMail?.length}))}catch(n){!t&&e===R.current&&m&&s.message.error(n?.message||`Could not load mail template for this Job ID`)}finally{!t&&e===R.current&&(D(!0),k(!1))}}return n(),()=>{t=!0}},[S,m]);function z(e=b){let t=String(e??``).trim();if(!oD.test(t)){C(``),t&&s.message.warning(`Enter a valid 24-character Job ID`);return}if(t===S){C(``),queueMicrotask(()=>C(t));return}C(t)}function B(e,t){if(!e){C(``),x(``);return}let n=t?.label??``;x(String(n||(e??``))),z(e)}function V(e){let t=String(e??``).trim();if(x(t),t.length<3){j([]);return}N(!0),oe(t).then(e=>{let t=(Array.isArray(e)?e:[]).map(mD).filter(Boolean);j(t)}).catch(e=>s.message.error(e?.message||`Unable to search jobs`)).finally(()=>N(!1))}let ee=E&&(!m||oD.test(S))&&GE(w.to).length+GE(w.cc).length+GE(w.bcc).length>0&&KE(w.to)&&KE(w.cc)&&KE(w.bcc)&&w.subject.trim()&&w.contents.trim();async function te(){if(!(!ee||P)){F(!0);try{await ln({jobId:S,toMail:GE(w.to),ccMail:GE(w.cc),bccMail:GE(w.bcc),subject:w.subject,contents:w.contents,attachments:w.attachments??[]}),s.message.success(`Mail sent successfully`),typeof u==`function`&&u({...w,message:w.contents,selectedIds:r}),e(-1)}catch(e){s.message.error(e?.message||`Failed to send mail`)}finally{F(!1)}}}function ne(e){e?.to!==w.to&&(I.current=!0),T(e)}return(0,l.jsx)(s.Drawer,{open:!0,placement:`right`,onClose:()=>e(-1),closable:!1,rootClassName:`mail-popup`,width:620,maskClosable:!1,footer:(0,l.jsxs)(`div`,{className:`mail-popup__footer`,children:[(0,l.jsx)(s.Button,{onClick:()=>e(-1),children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:P,disabled:!ee,onClick:te,children:`Send`})]}),children:(0,l.jsx)(s.Spin,{spinning:O,tip:`Loading mail content...`,size:`large`,children:(0,l.jsx)(iD,{value:w,onChange:ne,moduleName:f,defaultTemplateId:m?``:p.defaultTemplateId??t.defaultTemplateId??``,ready:E,contextRecords:i,beforeFields:m?(0,l.jsxs)(`div`,{className:`mail-popup__job-row`,children:[(0,l.jsx)(aD,{type:`secondary`,className:`mail-popup__field-label`,children:`Job Title / ID`}),(0,l.jsx)(s.Select,{showSearch:!0,allowClear:!0,filterOption:!1,value:S||void 0,searchValue:b,onSearch:V,onChange:B,onClear:()=>{C(``),x(``),j([])},placeholder:`Minimum 3 characters`,notFoundContent:M||O?(0,l.jsx)(s.Spin,{size:`small`}):null,options:A,className:`mail-popup__job-input`})]}):null})})})}var{Text:bD}=s.Typography,xD=2,SD=`overview.summary.role summary.job summary.role overview.job description.description.about the role.about the job.job title.role.responsibilities.roles responsibilities.roles and responsibilities.roles & responsibilities.key responsibilities.requirements.required skills.preferred skills.technical skills.key skills.skills.competencies.nice to have.good to have.qualifications.required qualifications.preferred qualifications.education.experience.benefits`.split(`.`),CD=new Set(SD),wD=/(education|qualification)/i,TD=/(skill|competenc)/i,ED=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),DD=e=>e.replace(/\w[^\s/]*/g,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()),OD=e=>[...new Set(e)];function kD(e){let t=String(e);return t=t.replace(/<\s*(br|\/p|\/div|\/h[1-6]|\/li|\/tr)\s*\/?>/gi,`
17
+ `).length)),value:r,className:`fg-mono-input`,style:{marginTop:8,fontSize:12},onChange:n=>{i(n.target.value);try{t({...e,config:JSON.parse(n.target.value||`{}`)}),u(!1)}catch{u(!0)}}})]})}function KT({open:e,doc:t,moduleOptions:n,onClose:r,onSave:i}){let[a,u]=(0,o.useState)(()=>({key:``,module:``,event:`afterCreate`,order:10,isActive:!0,stopOnError:!1,condition:{},actions:[],...t??{}})),[d,f]=(0,o.useState)(()=>WT(t?.condition)),[p,m]=(0,o.useState)(!1),h=(e,t)=>u(n=>({...n,[e]:t}));return(0,l.jsx)(s.Modal,{open:e,onCancel:r,width:840,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,l.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,l.jsx)(c.ApartmentOutlined,{}),` `,t?`Edit Workflow`:`New Workflow`]}),footer:(0,l.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,l.jsx)(s.Button,{onClick:r,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),onClick:()=>{if(!a.key?.trim())return s.message.error(`Key is required`);if(!a.module?.trim())return s.message.error(`Module is required`);if(p)return s.message.error(`Condition JSON is invalid`);if(!(a.actions??[]).length)return s.message.error(`At least one action is required`);if((a.actions??[]).some(e=>!e.type))return s.message.error(`Every action needs a type`);let e={...a};delete e.id,delete e._id,i(e)},children:`Save Workflow`})]}),children:(0,l.jsxs)(`div`,{className:`fg-form-section`,children:[(0,l.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)(BT,{type:`secondary`,style:{fontSize:12},children:`Key`}),(0,l.jsx)(s.Input,{size:`small`,placeholder:`jobs-create-after`,value:a.key??``,onChange:e=>h(`key`,e.target.value),className:`fg-mono-input`,disabled:!!t})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)(BT,{type:`secondary`,style:{fontSize:12},children:`Module`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},showSearch:!0,value:a.module||void 0,options:n,onChange:e=>h(`module`,e),placeholder:`jobs`})]}),(0,l.jsxs)(`div`,{style:{flex:1},children:[(0,l.jsx)(BT,{type:`secondary`,style:{fontSize:12},children:`Event`}),(0,l.jsx)(s.Select,{size:`small`,style:{width:`100%`},value:a.event,options:VT.map(e=>({value:e})),onChange:e=>h(`event`,e)})]}),(0,l.jsxs)(`div`,{style:{width:90},children:[(0,l.jsx)(BT,{type:`secondary`,style:{fontSize:12},children:`Order`}),(0,l.jsx)(s.InputNumber,{size:`small`,style:{width:`100%`},value:a.order??10,onChange:e=>h(`order`,e??10)})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:24,marginTop:12},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:a.isActive!==!1,onChange:e=>h(`isActive`,e)}),(0,l.jsx)(BT,{style:{fontSize:13},children:`Active`})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(s.Switch,{size:`small`,checked:a.stopOnError===!0,onChange:e=>h(`stopOnError`,e)}),(0,l.jsx)(s.Tooltip,{title:`Off (default): if an action fails after the record is saved, it is logged and the next action still runs — right for independent side effects like a notification and a cache clear. On: the remaining actions are skipped, for a sequence whose later steps are only safe because the earlier ones worked (creating records and THEN clearing the data they came from).`,children:(0,l.jsx)(BT,{style:{fontSize:13},children:`Stop on error`})})]})]}),(0,l.jsxs)(`div`,{style:{marginTop:12},children:[(0,l.jsxs)(BT,{type:`secondary`,style:{fontSize:12},children:[`Condition (all must match the payload; empty = always run) `,p&&(0,l.jsx)(s.Tag,{color:`red`,children:`invalid JSON`})]}),(0,l.jsx)(s.Input.TextArea,{rows:2,value:d,className:`fg-mono-input`,style:{fontSize:12},onChange:e=>{f(e.target.value);try{h(`condition`,JSON.parse(e.target.value||`{}`)),m(!1)}catch{m(!0)}}})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginTop:14},children:[(0,l.jsx)(BT,{strong:!0,style:{fontSize:13},children:`Actions (run in order)`}),(0,l.jsx)(s.Button,{size:`small`,type:`dashed`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>h(`actions`,[...a.actions??[],{type:``,config:{}}]),children:`Add Action`})]}),(a.actions??[]).map((e,t)=>(0,l.jsx)(GT,{action:e,onChange:e=>h(`actions`,a.actions.map((n,r)=>r===t?e:n)),onRemove:()=>h(`actions`,a.actions.filter((e,n)=>n!==t))},t)),(0,l.jsxs)(BT,{type:`secondary`,style:{fontSize:11,display:`block`,marginTop:8},children:[`Config supports `,(0,l.jsx)(`code`,{children:`{{field.path}}`}),`, `,(0,l.jsx)(`code`,{children:`{{now}}`}),`, `,(0,l.jsx)(`code`,{children:`{{__userId}}`}),`,`,` `,(0,l.jsx)(`code`,{children:`{{__userName}}`}),`, and `,(0,l.jsx)(`code`,{children:`{{hierarchy.<name>}}`}),` from a `,(0,l.jsx)(`code`,{children:`resolve`}),` action.`]})]})})}function qT(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)([]),[a,u]=(0,o.useState)(!0),[d,f]=(0,o.useState)(``),[p,m]=(0,o.useState)(null),[h,g]=(0,o.useState)(``),[_,v]=(0,o.useState)(0);(0,o.useEffect)(()=>{let e=!1;return n.Qr(`workflows`).then(n=>{e||t(n)}).catch(t=>{e||f(t?.message||`Failed to load workflows`)}).finally(()=>{e||u(!1)}),()=>{e=!0}},[_]),(0,o.useEffect)(()=>{n.xr().then(e=>i(Gx(e).map(({value:e,label:t})=>({value:e,label:t})))).catch(()=>i([]))},[]);let y=()=>{u(!0),f(``),v(e=>e+1)};async function b(e){try{await n.ci(`workflows`,e),s.message.success(`Workflow "${e.key}" saved`),m(null),y()}catch(e){s.message.error(e?.message||`Could not save workflow`)}}async function x(e){try{await n.lr(`workflows`,e),s.message.success(`Workflow "${e}" deleted`),y()}catch(e){s.message.error(e?.message||`Could not delete workflow`)}}async function S(e,t){let r={...e};delete r.id,delete r._id;try{await n.ci(`workflows`,{...r,isActive:t}),y()}catch(e){s.message.error(e?.message||`Could not update workflow`)}}let C=(0,o.useMemo)(()=>e.filter(e=>!h||e.module===h),[e,h]);return(0,l.jsxs)(`div`,{className:`fg-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.ApartmentOutlined,{}),title:`Workflows`,extra:(0,l.jsxs)(s.Space,{size:8,children:[(0,l.jsx)(s.Select,{size:`small`,style:{minWidth:160},allowClear:!0,placeholder:`Filter by module`,options:r,value:h||void 0,onChange:e=>g(e??``)}),(0,l.jsx)(s.Button,{size:`small`,icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:y,children:`Reload`}),(0,l.jsx)(s.Button,{type:`primary`,size:`small`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>m({doc:null}),children:`New Workflow`})]}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsxs)(BT,{type:`secondary`,style:{fontSize:13},children:[`Event-driven behavior per module — reference ids, duplicate checks, snapshots, hierarchy fan-outs, board updates, notifications, cache — executed by the platform Workflow Engine on every create/update/delete.`,(0,l.jsx)(s.Tag,{style:{marginLeft:8},children:`before*`}),` actions can block the write; `,(0,l.jsx)(s.Tag,{children:`after*`}),` actions are best-effort.`]})]}),(0,l.jsxs)(Z,{styles:{body:{paddingTop:8}},children:[d&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,message:d,style:{marginBottom:12}}),(0,l.jsxs)(s.Spin,{spinning:a,children:[(0,l.jsxs)(`div`,{style:{marginBottom:8},children:[(0,l.jsx)(s.Badge,{count:C.length,showZero:!0,color:`var(--color-brand)`}),` `,(0,l.jsx)(BT,{type:`secondary`,style:{fontSize:12},children:`workflows`})]}),(0,l.jsx)(s.Table,{rowKey:`key`,dataSource:C,columns:[{title:`Key`,dataIndex:`key`,key:`key`,render:e=>(0,l.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Module`,dataIndex:`module`,key:`module`,width:130,render:e=>(0,l.jsx)(s.Tag,{color:`geekblue`,children:e})},{title:`Event`,dataIndex:`event`,key:`event`,width:130,render:e=>(0,l.jsx)(s.Tag,{color:String(e).startsWith(`before`)?`purple`:`green`,children:e})},{title:`Actions`,key:`acts`,render:(e,t)=>(0,l.jsx)(s.Space,{size:4,wrap:!0,children:(t.actions??[]).map((e,t)=>(0,l.jsx)(s.Tag,{style:{margin:0},children:e.type},t))})},{title:`Order`,dataIndex:`order`,key:`order`,width:70,align:`center`},{title:`Active`,key:`active`,width:80,align:`center`,render:(e,t)=>(0,l.jsx)(s.Switch,{size:`small`,checked:t.isActive!==!1,onChange:e=>S(t,e)})},{title:``,key:`ops`,width:90,align:`right`,render:(e,t)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Tooltip,{title:`Edit`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>m({doc:t})})}),(0,l.jsx)(s.Popconfirm,{title:`Delete workflow "${t.key}"?`,onConfirm:()=>x(t.key),children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})]})}],pagination:!1,size:`small`,className:`fg-table`,locale:{emptyText:(0,l.jsx)(s.Empty,{description:`No workflows configured.`,image:s.Empty.PRESENTED_IMAGE_SIMPLE})}})]})]}),(0,l.jsx)(KT,{open:!!p,doc:p?.doc,moduleOptions:r,onClose:()=>m(null),onSave:b},p?p.doc?.key??`new`:`closed`)]})}var{Text:JT}=s.Typography,YT=e=>e?._id??e?.id,XT=`masters`;function ZT(){return{tenantId:localStorage.getItem(`tenantId`)||``,businessId:localStorage.getItem(`businessId`)||``,businessUnitId:localStorage.getItem(`businessUnitId`)||``}}function QT(e){return e&&typeof e==`object`?e.$oid??e.oid??e.id??``:e??``}function $T(e,t){return t.map(t=>QT(e?.[t])).find(e=>e!=null&&e!==``)??``}function eE(e,t){return[[t.tenantId,[`tid`,`tenantId`]],[t.businessId,[`bid`,`businessId`]],[t.businessUnitId,[`buid`,`businessUnitId`]]].every(([t,n])=>{if(!t)return!0;let r=String($T(e,n));return!r||r===String(t)})}function tE(e){return Array.isArray(e?.masterFeeds)?e.masterFeeds:[]}function nE(e){return e.reduce((e,t)=>Math.max(e,Number(t?.uniqueId)||0),0)+1}function rE(e){return Array.isArray(e?.taxHistory)?e.taxHistory:[]}function iE(e){let t=e?.taxValue;if(t!=null&&t!==``)return Number(t);let n=rE(e).at(-1),r=n?.taxValue??n?.value;return r!=null&&r!==``?Number(r):void 0}function aE(e){if(!e)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(t)}function oE(e){let t=rE(e).at(-1);return t?.updatedAt??t?.timestamp??e?.updatedAt}function sE({open:e,record:t,onClose:r,onSaved:i}){let[a]=s.Form.useForm(),[c,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)([]),[p,m]=(0,o.useState)(!1),h=(0,o.useRef)(null),g=!!t;(0,o.useEffect)(()=>{e&&queueMicrotask(()=>{a.resetFields(),a.setFieldsValue({name:t?.name??void 0,taxValue:iE(t)}),f(t?.name?[{label:t.name,value:t.name}]:[])})},[e,t,a]);function _(e){if(h.current&&clearTimeout(h.current),!e||e.trim().length<2){f([]);return}m(!0),h.current=setTimeout(()=>{n.Mr(e.trim()).then(f).catch(()=>f([])).finally(()=>m(!1))},350)}async function v(){let e=await a.validateFields(),r=Number(e.taxValue),o={name:e.name,taxValue:r,taxHistory:{taxValue:r}};u(!0);try{g?await n._i(`locations`,YT(t),o):await n.$n(`locations`,o),s.message.success(g?`Tax updated`:`Location and tax created`),i()}catch(e){s.message.error(e?.message||`Could not save location and tax`)}finally{u(!1)}}return(0,l.jsx)(s.Modal,{open:e,onCancel:r,onOk:v,confirmLoading:c,destroyOnHidden:!0,title:g?`Edit Tax — ${t?.name??``}`:`New Location`,children:(0,l.jsxs)(s.Form,{form:a,layout:`vertical`,children:[(0,l.jsx)(s.Form.Item,{name:`name`,label:`Location`,rules:[{required:!0,message:`Location is required`}],tooltip:g?`Location cannot be changed once created — only the tax is editable.`:`Search and pick from the location master.`,children:(0,l.jsx)(s.Select,{showSearch:!0,disabled:g,placeholder:`Type at least 2 characters to search…`,filterOption:!1,onSearch:_,notFoundContent:p?`Searching…`:null,options:d})}),(0,l.jsx)(s.Form.Item,{name:`taxValue`,label:`Tax`,rules:[{required:!0,message:`Tax is required`},{type:`number`,min:0,max:100,message:`Tax must be between 0 and 100`}],children:(0,l.jsx)(s.InputNumber,{style:{width:`100%`},min:0,max:100,step:.01,suffix:`%`,placeholder:`8.875`,autoFocus:g})})]})})}function cE({record:e}){let t=[...rE(e)].reverse();return t.length?(0,l.jsx)(s.Space,{direction:`vertical`,size:4,style:{padding:`4px 8px`},children:t.map((e,t)=>(0,l.jsxs)(s.Space,{size:10,children:[(0,l.jsxs)(s.Tag,{color:t===0?`green`:`default`,style:{margin:0},children:[e.taxValue??e.value,`%`]}),(0,l.jsx)(JT,{type:`secondary`,style:{fontSize:12},children:aE(e.updatedAt??e.timestamp)}),t===0&&(0,l.jsx)(JT,{type:`secondary`,style:{fontSize:12},children:`(current)`})]},t))}):(0,l.jsx)(s.Empty,{image:s.Empty.PRESENTED_IMAGE_SIMPLE,description:`No tax history yet`})}function lE(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(null);function p(){i(!0),n.Zr(`locations`).then(({items:e})=>t(e)).catch(e=>s.message.error(e?.message||`Could not load locations`)).finally(()=>i(!1))}(0,o.useEffect)(()=>{queueMicrotask(p)},[]);async function m(e){try{await n.cr(`locations`,e),s.message.success(`Location deleted`),p()}catch(e){s.message.error(e?.message||`Could not delete location`)}}return(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsx)(Z,{title:`${e.length} location${e.length===1?``:`s`}`,extra:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:p,children:`Reload`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>{f(null),u(!0)},children:`New location`})]}),children:(0,l.jsx)(s.Table,{rowKey:YT,columns:[{title:`Location`,dataIndex:`name`,key:`name`},{title:`Tax`,key:`taxValue`,width:100,render:(e,t)=>{let n=iE(t);return Number.isFinite(n)?(0,l.jsxs)(s.Tag,{color:`blue`,children:[n,`%`]}):`—`}},{title:`Tax updated`,key:`taxUpdatedAt`,render:(e,t)=>aE(oE(t))},{title:`Created`,key:`createdAt`,responsive:[`lg`],render:(e,t)=>aE(t?.createdAt)},{title:``,key:`actions`,width:90,render:(e,t)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Tooltip,{title:`Edit tax`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{f(t),u(!0)}})}),(0,l.jsx)(s.Popconfirm,{title:`Delete this location?`,onConfirm:()=>m(YT(t)),children:(0,l.jsx)(s.Tooltip,{title:`Delete`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})})]})}],dataSource:e,loading:r,size:`small`,pagination:!1,className:`fg-table`,expandable:{expandedRowRender:e=>(0,l.jsx)(cE,{record:e}),rowExpandable:e=>rE(e).length>0},locale:{emptyText:`No locations yet. Click "New location" to add one.`}})}),(0,l.jsx)(sE,{open:a,record:d,onClose:()=>u(!1),onSaved:()=>{u(!1),p()}})]})}function uE({open:e,record:t,onClose:r,onSaved:i}){let[a]=s.Form.useForm(),[u,d]=(0,o.useState)(!1),f=!!t,p=s.Form.useWatch(`masterName`,a),m=s.Form.useWatch(`masterFeeds`,a)??[],h=[`clientsubmissionstatus`,`clientsubmission`,`clientsubmissions`].includes(String(p??t?.masterName??``).trim().toLowerCase()),g=m.map(e=>({label:String(e?.name??``).trim()||`Status ${e?.uniqueId??``}`,value:Number(e?.uniqueId)})).filter(e=>Number.isInteger(e.value)&&e.value>0);function _(e,t){if(!t){a.setFieldValue([`masterFeeds`,e,`isInitialStatus`],!1);return}(a.getFieldValue(`masterFeeds`)??[]).forEach((t,n)=>{a.setFieldValue([`masterFeeds`,n,`isInitialStatus`],n===e)})}function v(e,t){a.setFieldValue([`masterFeeds`,e,`isTerminalStatus`],t),t&&a.setFieldValue([`masterFeeds`,e,`allowedNextStatusIds`],[])}(0,o.useEffect)(()=>{e&&queueMicrotask(()=>{a.resetFields();let e=t?.masterName??``,n=[`clientsubmissionstatus`,`clientsubmission`,`clientsubmissions`].includes(String(e).trim().toLowerCase()),r=tE(t),i=r.length?r.map(e=>({...e})):[{uniqueId:1,name:``,type:`neutral`,status:!0,isdeleted:!1}];if(n&&!i.some(e=>e?.status!==!1&&e?.isdeleted!==!0&&e?.isInitialStatus===!0)){let e=i.findIndex(e=>e?.status!==!1&&e?.isdeleted!==!0);e>=0&&(i=i.map((t,n)=>({...t,isInitialStatus:n===e,isTerminalStatus:t?.isTerminalStatus===!0,allowedNextStatusIds:Array.isArray(t?.allowedNextStatusIds)?t.allowedNextStatusIds:[]})))}a.setFieldsValue({masterName:e,schemaVersion:t?.schemaVersion??1,masterFeeds:i})})},[e,t,a]),(0,o.useEffect)(()=>{!e||!h||(Number(a.getFieldValue(`schemaVersion`))||1)<2&&a.setFieldValue(`schemaVersion`,2)},[e,h,a]);async function y(){let e=await a.validateFields(),r=ZT(),o=[`clientsubmissionstatus`,`clientsubmission`,`clientsubmissions`].includes(String(e.masterName??``).trim().toLowerCase()),c=(e.masterFeeds??[]).map((e,t)=>{let n=Number(e.uniqueId)||t+1,r=o&&e.isTerminalStatus===!0,i=o&&!r?[...new Set((e.allowedNextStatusIds??[]).map(Number).filter(e=>Number.isInteger(e)&&e>0&&e!==n))]:[];return{uniqueId:n,name:String(e.name??``).trim(),type:String(e.type??``).trim(),status:e.status!==!1,...o?{isInitialStatus:e.isInitialStatus===!0,isTerminalStatus:r,allowedNextStatusIds:i}:{},isdeleted:e.isdeleted===!0}}).filter(e=>e.name);if(o){let e=c.filter(e=>e.status&&!e.isdeleted&&e.isInitialStatus);if(e.length===0){let t=c.findIndex(e=>e.status&&!e.isdeleted);t>=0&&(c[t]={...c[t],isInitialStatus:!0},e=[c[t]],a.setFieldValue([`masterFeeds`,t,`isInitialStatus`],!0))}if(e.length!==1){s.message.error(`Client Submission Status must have exactly one active Initial Status.`);return}}let l={...r,tid:r.tenantId,bid:r.businessId,buid:r.businessUnitId,schemaVersion:o?Math.max(2,Number(e.schemaVersion)||2):Number(e.schemaVersion)||1,masterName:e.masterName.trim(),masterFeeds:c};d(!0);try{f?await n._i(XT,YT(t),l):await n.$n(XT,l),s.message.success(f?`Master value updated`:`Master value created`),i()}catch(e){s.message.error(e?.message||`Could not save master value`)}finally{d(!1)}}return(0,l.jsx)(s.Modal,{open:e,onCancel:r,onOk:y,confirmLoading:u,destroyOnHidden:!0,title:f?`Edit Master Feed`:`New Master Feed`,width:1040,children:(0,l.jsxs)(s.Form,{form:a,layout:`vertical`,children:[(0,l.jsx)(s.Form.Item,{name:`masterName`,label:`Master Name`,rules:[{required:!0,message:`Master name is required`}],children:(0,l.jsx)(s.Input,{placeholder:`blacklistType`,autoFocus:!f,disabled:f})}),(0,l.jsx)(s.Form.Item,{name:`schemaVersion`,label:`Schema Version`,children:(0,l.jsx)(s.InputNumber,{min:1,style:{width:`100%`}})}),(0,l.jsx)(s.Form.List,{name:`masterFeeds`,children:(e,{add:t,remove:n})=>(0,l.jsxs)(s.Space,{direction:`vertical`,style:{width:`100%`},size:10,children:[e.map(({key:e,name:t})=>(0,l.jsxs)(s.Space,{align:`baseline`,wrap:!0,children:[(0,l.jsx)(s.Form.Item,{name:[t,`uniqueId`],label:`ID`,rules:[{required:!0,message:`ID required`}],children:(0,l.jsx)(s.InputNumber,{min:1,style:{width:90}})}),(0,l.jsx)(s.Form.Item,{name:[t,`name`],label:`Name`,rules:[{required:!0,message:`Name required`}],children:(0,l.jsx)(s.Input,{placeholder:`Dropdown label`,style:{width:280}})}),(0,l.jsx)(s.Form.Item,{name:[t,`type`],label:`Type`,children:(0,l.jsx)(s.Select,{allowClear:!0,placeholder:`Select type`,style:{width:120},options:[{label:`Positive`,value:`positive`},{label:`Neutral`,value:`neutral`},{label:`Negative`,value:`negative`}]})}),(0,l.jsx)(s.Form.Item,{name:[t,`status`],label:`Status`,initialValue:!0,children:(0,l.jsx)(s.Select,{style:{width:110},options:[{label:`Active`,value:!0},{label:`Inactive`,value:!1}]})}),(0,l.jsx)(s.Form.Item,{name:[t,`isdeleted`],label:`Deleted`,initialValue:!1,children:(0,l.jsx)(s.Select,{style:{width:110},options:[{label:`No`,value:!1},{label:`Yes`,value:!0}]})}),h&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.Form.Item,{name:[t,`isInitialStatus`],label:`Initial`,initialValue:!1,tooltip:`The initial status is the only option shown before a candidate has a client submission status. Only one active initial status is allowed.`,children:(0,l.jsx)(s.Select,{style:{width:100},onChange:e=>_(t,e===!0),options:[{label:`Yes`,value:!0},{label:`No`,value:!1}]})}),(0,l.jsx)(s.Form.Item,{name:[t,`isTerminalStatus`],label:`End Status`,initialValue:!1,tooltip:`End Status stops the configured client submission flow. Once reached, Change Status is hidden and no next statuses are allowed.`,children:(0,l.jsx)(s.Select,{style:{width:105},onChange:e=>v(t,e===!0),options:[{label:`Yes`,value:!0},{label:`No`,value:!1}]})}),(0,l.jsx)(s.Form.Item,{noStyle:!0,shouldUpdate:(e,n)=>e?.masterFeeds?.[t]?.isTerminalStatus!==n?.masterFeeds?.[t]?.isTerminalStatus||e?.masterFeeds?.[t]?.uniqueId!==n?.masterFeeds?.[t]?.uniqueId||e?.masterFeeds!==n?.masterFeeds,children:({getFieldValue:e})=>{let n=e([`masterFeeds`,t,`isTerminalStatus`])===!0,r=Number(e([`masterFeeds`,t,`uniqueId`]));return(0,l.jsx)(s.Form.Item,{name:[t,`allowedNextStatusIds`],label:`Allowed Next Statuses`,tooltip:n?`End Status cannot move to another status.`:`Only these statuses will appear after the current status is saved.`,children:(0,l.jsx)(s.Select,{mode:`multiple`,allowClear:!0,disabled:n,placeholder:n?`End status`:`Select next statuses`,style:{minWidth:280},options:g.filter(e=>e.value!==r)})})}})]}),(0,l.jsx)(s.Tooltip,{title:`Remove row`,children:(0,l.jsx)(s.Button,{type:`text`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{}),onClick:()=>n(t)})})]},e)),(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>t({uniqueId:nE(a.getFieldValue(`masterFeeds`)??[]),name:``,type:`neutral`,status:!0,isdeleted:!1,...h?{isInitialStatus:!1,isTerminalStatus:!1,allowedNextStatusIds:[]}:{}}),children:`Add feed value`})]})})]})})}function dE(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(null),[p,m]=(0,o.useState)(``);function h(){let e=ZT();i(!0),n.Zr(XT,{limit:500}).then(({items:n})=>{let r=n.filter(t=>eE(t,e));t(r)}).catch(e=>s.message.error(e?.message||`Could not load master values`)).finally(()=>i(!1))}(0,o.useEffect)(()=>{queueMicrotask(h)},[]);async function g(e){try{await n.cr(XT,e),s.message.success(`Master value deleted`),h()}catch(e){s.message.error(e?.message||`Could not delete master value`)}}let _=p?e.filter(e=>String(e?.masterName??``).toLowerCase()===p.toLowerCase()):e,v=[...new Set(e.map(e=>e?.masterName).filter(Boolean))].sort((e,t)=>String(e).localeCompare(String(t))).map(e=>({label:e,value:e}));return(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsx)(Z,{title:`${_.length} master${_.length===1?``:`s`}`,extra:(0,l.jsxs)(s.Space,{wrap:!0,children:[(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,placeholder:`Filter master name`,value:p||void 0,options:v,onChange:e=>m(e??``),style:{minWidth:220}}),(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:h,children:`Reload`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>{f(null),u(!0)},children:`New master`})]}),children:(0,l.jsx)(s.Table,{rowKey:YT,columns:[{title:`Master Name`,dataIndex:`masterName`,key:`masterName`,width:180},{title:`Feed Values`,key:`masterFeeds`,render:(e,t)=>(0,l.jsx)(s.Space,{wrap:!0,children:tE(t).filter(e=>!e.isdeleted).map(e=>(0,l.jsx)(s.Tag,{color:e.status===!1?`default`:`blue`,children:e.name},e.uniqueId??e.name))})},{title:`Count`,key:`count`,width:90,render:(e,t)=>tE(t).filter(e=>!e.isdeleted).length},{title:`Updated`,key:`updatedAt`,responsive:[`lg`],render:(e,t)=>aE(t?.updatedAt)},{title:``,key:`actions`,width:90,render:(e,t)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Tooltip,{title:`Edit`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{f(t),u(!0)}})}),(0,l.jsx)(s.Popconfirm,{title:`Delete this master?`,onConfirm:()=>g(YT(t)),children:(0,l.jsx)(s.Tooltip,{title:`Delete`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{})})})})]})}],dataSource:_,loading:r,size:`small`,pagination:{pageSize:10,showSizeChanger:!0},className:`fg-table`,locale:{emptyText:`No masters yet. Click "New master" to add one.`}})}),(0,l.jsx)(uE,{open:a,record:d,onClose:()=>u(!1),onSaved:()=>{u(!1),h()}})]})}function fE(){return(0,l.jsxs)(`div`,{className:`fg-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.DatabaseOutlined,{}),title:`Master Collections`,children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(JT,{type:`secondary`,style:{fontSize:13},children:`Create, update, and delete master documents, then customize multiple dropdown values inside masterFeeds. Records are saved with the current tenant, business, business unit, and master name.`})]}),(0,l.jsx)(dE,{}),(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.DatabaseOutlined,{}),title:`Location Tax Master`,children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(JT,{type:`secondary`,style:{fontSize:13},children:`Pick a location from the master list and set its tax. Once added, only the tax can be changed — every change is kept in a timeline with its timestamp. Expand a row to see the full tax history.`})]}),(0,l.jsx)(lE,{})]})}var{Text:pE}=s.Typography,mE={employerMsaValidityDays:365,referralMsaValidityDays:365,expiryWarningDays:30};function hE(){let[e]=s.Form.useForm(),[t,r]=(0,o.useState)(!0),[i,a]=(0,o.useState)(!1),u=async()=>{r(!0);try{let t=await n.Ur();e.setFieldsValue({...mE,...t||{}})}catch(t){s.message.error(t?.message||`Could not load PO/MSA settings`),e.setFieldsValue(mE)}finally{r(!1)}};return(0,o.useEffect)(()=>{u()},[]),(0,l.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.SettingOutlined,{}),title:`PO/MSA Validity Settings`,extra:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:u,disabled:i,children:`Reload`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),loading:i,onClick:async()=>{try{let t=await e.validateFields();a(!0);let r=await n.si(t);e.setFieldsValue({...mE,...r||t}),s.message.success(`PO/MSA validity settings saved`)}catch(e){e?.errorFields||s.message.error(e?.message||`Could not save PO/MSA settings`)}finally{a(!1)}},children:`Save`})]}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(pE,{type:`secondary`,children:`Configure how long a signed MSA remains valid. Employer/referral status is calculated from the signed MSA date plus these values; no validity period is hardcoded in the onboarding UI.`})]}),(0,l.jsx)(Z,{title:`Validity Rules`,children:(0,l.jsx)(s.Spin,{spinning:t,children:(0,l.jsxs)(s.Form,{form:e,layout:`vertical`,initialValues:mE,style:{maxWidth:620},children:[(0,l.jsx)(s.Form.Item,{name:`employerMsaValidityDays`,label:`Employer MSA Validity Days`,tooltip:`Number of days an employer MSA remains active from its signed date.`,rules:[{required:!0,message:`Employer MSA validity is required`}],children:(0,l.jsx)(s.InputNumber,{min:1,max:3650,precision:0,style:{width:`100%`},addonAfter:`days`})}),(0,l.jsx)(s.Form.Item,{name:`referralMsaValidityDays`,label:`Referral MSA Validity Days`,tooltip:`Number of days a referral MSA remains active from its signed date.`,rules:[{required:!0,message:`Referral MSA validity is required`}],children:(0,l.jsx)(s.InputNumber,{min:1,max:3650,precision:0,style:{width:`100%`},addonAfter:`days`})}),(0,l.jsx)(s.Form.Item,{name:`expiryWarningDays`,label:`Expiry Warning Days`,tooltip:`Reserved for upcoming-expiry indicators and notifications.`,rules:[{required:!0,message:`Expiry warning days is required`}],children:(0,l.jsx)(s.InputNumber,{min:0,max:3650,precision:0,style:{width:`100%`},addonAfter:`days`})})]})})})]})}var{Text:gE,Title:_E}=s.Typography,vE=[{value:`Dashboard`,label:`Dashboard`,icon:(0,l.jsx)(c.DashboardOutlined,{})},{value:`ClientManagement`,label:`Client Management`,icon:(0,l.jsx)(c.BankOutlined,{})},{value:`EmployerManagement`,label:`Employer / Referral`,icon:(0,l.jsx)(c.TeamOutlined,{})},{value:`Candidates`,label:`Candidates`,icon:(0,l.jsx)(c.UsergroupAddOutlined,{})},{value:`Jobs`,label:`Jobs`,icon:(0,l.jsx)(c.FileTextOutlined,{})},{value:`Submissions`,label:`Submissions`,icon:(0,l.jsx)(c.FileTextOutlined,{})},{value:`Onboarding`,label:`Onboarding`,icon:(0,l.jsx)(c.UserOutlined,{})},{value:`Assignments`,label:`Assignments`,icon:(0,l.jsx)(c.AppstoreOutlined,{})},{value:`Timesheet`,label:`Timesheet`,icon:(0,l.jsx)(c.CalendarOutlined,{})},{value:`Campaign`,label:`Campaign`,icon:(0,l.jsx)(c.TeamOutlined,{})},{value:`FileProtectOutlined`,label:`PO / MSA`,icon:(0,l.jsx)(c.FileProtectOutlined,{})},{value:`FolderOpenOutlined`,label:`Batches`,icon:(0,l.jsx)(c.FolderOpenOutlined,{})},{value:`BankOutlined`,label:`Billing / Finance`,icon:(0,l.jsx)(c.BankOutlined,{})},{value:`SettingOutlined`,label:`Settings / Admin`,icon:(0,l.jsx)(c.SettingOutlined,{})},{value:`UploadOutlined`,label:`Upload`,icon:(0,l.jsx)(c.UploadOutlined,{})},{value:`AppstoreOutlined`,label:`General Module`,icon:(0,l.jsx)(c.AppstoreOutlined,{})}];function yE({option:e}){return(0,l.jsxs)(s.Space,{size:8,children:[(0,l.jsx)(`span`,{style:{display:`inline-flex`,fontSize:16},children:e.icon}),(0,l.jsx)(`span`,{children:e.label}),(0,l.jsx)(gE,{type:`secondary`,style:{fontSize:11},children:e.value})]})}function bE(e,t){let n=localStorage.getItem(`menu`);if(n)try{let r=JSON.parse(n),i=Array.isArray(r)?r:r?.menu;if(!Array.isArray(i))return;let a=String(e??t.menu_key??``).trim().toLowerCase(),o=e=>e.map(e=>{let n=String(e?.key??``).trim().toLowerCase()===a?{...e,icon:t.icon??e.icon,label:t.menu_name??e.label,status:String(t.status??e.status??`ACTIVE`).toLowerCase()}:e;return Array.isArray(n?.children)?{...n,children:o(n.children)}:n}),s=o(i);localStorage.setItem(`menu`,JSON.stringify(Array.isArray(r)?s:{...r,menu:s})),window.dispatchEvent(new Event(`menu:updated`))}catch{}}function xE(){let[e]=s.Form.useForm(),[t,n]=(0,o.useState)([]),[r,i]=(0,o.useState)(!0),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(null),[p,m]=(0,o.useState)(!1);async function h(){i(!0);try{n(await mx())}catch(e){s.message.error(e.message||`Unable to load menus`)}finally{i(!1)}}(0,o.useEffect)(()=>{h()},[]);let g=(0,o.useMemo)(()=>t.filter(e=>!d||e.menu_id!==d.menu_id).map(e=>({label:e.menu_name,value:e.menu_id})),[d,t]);function _(){f(null),e.resetFields(),e.setFieldsValue({menu_type:`MENU`,display_order:t.length+1,status:`ACTIVE`}),m(!0)}function v(t){f(t),e.setFieldsValue(t),m(!0)}async function y(e){u(!0);try{d?(await gx(d.menu_id,e),bE(d.menu_key,e)):await hx(e),s.message.success(d?`Menu updated`:`Menu created`),m(!1),await h()}catch(e){s.message.error(e.message||`Unable to save menu`)}finally{u(!1)}}async function b(e){try{await _x(e),s.message.success(`Menu deleted`),await h()}catch(e){s.message.error(e.message||`Unable to delete menu`)}}return(0,l.jsxs)(`section`,{className:`admin-section`,children:[(0,l.jsxs)(`div`,{className:`admin-section-head`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(_E,{level:4,children:`Menus`}),(0,l.jsx)(gE,{type:`secondary`,children:`Manage records in the MongoDB menus collection.`})]}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:_,children:`Add Menu`})]}),(0,l.jsx)(s.Table,{rowKey:`menu_id`,loading:r,columns:[{title:`Name`,dataIndex:`menu_name`},{title:`Key`,dataIndex:`menu_key`,render:e=>(0,l.jsx)(s.Tag,{children:e})},{title:`Route / API`,dataIndex:`api_url`},{title:`Icon`,dataIndex:`icon`,width:170,render:e=>(0,l.jsx)(s.Tag,{children:e||`Auto`})},{title:`Type`,dataIndex:`menu_type`,width:110},{title:`Order`,dataIndex:`display_order`,width:80},{title:`Status`,dataIndex:`status`,width:100,render:e=>(0,l.jsx)(s.Tag,{color:e===`ACTIVE`?`green`:`default`,children:e})},{title:``,key:`actions`,width:90,render:(e,t)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Button,{"aria-label":`Edit menu`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>v(t)}),(0,l.jsx)(s.Popconfirm,{title:`Delete menu?`,onConfirm:()=>b(t.menu_id),children:(0,l.jsx)(s.Button,{"aria-label":`Delete menu`,danger:!0,size:`small`,icon:(0,l.jsx)(c.DeleteOutlined,{})})})]})}],dataSource:t,size:`small`,pagination:{pageSize:10}}),(0,l.jsx)(s.Modal,{title:d?`Edit Menu`:`Add Menu`,open:p,onCancel:()=>m(!1),onOk:()=>e.submit(),confirmLoading:a,destroyOnHidden:!0,children:(0,l.jsxs)(s.Form,{form:e,layout:`vertical`,onFinish:y,children:[(0,l.jsx)(s.Form.Item,{name:`menu_name`,label:`Menu name`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{})}),(0,l.jsx)(s.Form.Item,{name:`menu_key`,label:`Menu key`,rules:[{required:!0}],children:(0,l.jsx)(s.Input,{placeholder:`jobs`})}),(0,l.jsx)(s.Form.Item,{name:`api_url`,label:`Route / API URL`,children:(0,l.jsx)(s.Input,{placeholder:`/jobs`})}),(0,l.jsx)(s.Form.Item,{name:`component_name`,label:`Component`,children:(0,l.jsx)(s.Input,{placeholder:`Jobs`})}),(0,l.jsxs)(`div`,{className:`admin-form-row`,children:[(0,l.jsx)(s.Form.Item,{name:`menu_type`,label:`Type`,children:(0,l.jsx)(s.Select,{options:[{value:`MENU`},{value:`FOOTER`},{value:`CHILD`}]})}),(0,l.jsx)(s.Form.Item,{name:`parent_menu_id`,label:`Parent`,children:(0,l.jsx)(s.Select,{allowClear:!0,options:g})})]}),(0,l.jsxs)(`div`,{className:`admin-form-row`,children:[(0,l.jsx)(s.Form.Item,{name:`display_order`,label:`Display order`,children:(0,l.jsx)(s.InputNumber,{min:0})}),(0,l.jsx)(s.Form.Item,{name:`status`,label:`Status`,children:(0,l.jsx)(s.Select,{options:[{value:`ACTIVE`},{value:`INACTIVE`}]})})]}),(0,l.jsx)(s.Form.Item,{name:`icon`,label:`Sidebar icon`,extra:`Saved in the menus collection and used dynamically in the application sidebar.`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,placeholder:`Select sidebar icon`,optionFilterProp:`label`,options:vE.map(({value:e,label:t})=>({value:e,label:t})),optionRender:e=>{let t=e?.value??e?.data?.value,n=vE.find(e=>e.value===t);return n?(0,l.jsx)(yE,{option:n}):t}})})]})})]})}var{Content:SE,Header:CE,Sider:wE}=s.Layout,{Text:TE,Title:EE}=s.Typography;function DE(e){return String(e??``).trim().replace(/[\s_-]+/g,` `).toUpperCase()}function OE(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function kE(e){return String(e||``).trim().toLowerCase()}function AE(e){return e?.key||e?.collectionName||e?.value||``}function jE(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=AE(e);if(!t)return;let o=kE(e.key||t),s=kE(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||OE(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=kE(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:OE(t),value:t,disabled:!1}))}),n}function ME(e){return DE(e?.user_type_name??e?.userTypeName??e?.name)===`SUPER ADMIN`}function NE(e){return`${e?.first_name??e?.firstName??``} ${e?.last_name??e?.lastName??``}`.trim()||e?.username||e?.userName||e?.email||`User ${e?.user_id??e?.userId??``}`}function PE(e){return e.flatMap(e=>{let t=e.menu_id??e.menuId??e.MenuID,n=e.menu_name??e.menuName??e.MenuName??`Menu ${t??``}`,r=e.menu_key??e.menuKey??e.MenuKey??``,i=e.permissions??e.Permissions??{};return Object.entries(i).map(([e,i])=>{let a=i.permission_id??i.permissionId??i.PermissionID,o=i.permission_key??i.permissionKey??i.PermissionKey??e,s=i.value??i.Value??i.access_value??i.accessValue??i;return{key:`${r??n??t}:${a??o}`,menuId:t,menuName:n,menuKey:r,permissionId:a,permissionKey:o,accessValue:+(Number(s)===1)}})})}function FE(e){return String(e.menuKey??e.menuName??e.menuId).trim().toLowerCase()}var IE=[{permissionId:null,permissionKey:`sendApprove`,permissionName:`Send Approve`}];function LE(e){let t=Array.isArray(e)?e:e?.permissions??e?.actions??e?.data??e,n=(Array.isArray(t)?t:Object.values(t??{})).map(e=>({permissionId:e.permission_id??e.permissionId??e.legacyPermissionId??e.id??null,permissionKey:e.permission_key??e.permissionKey??e.key,permissionName:e.permission_name??e.permissionName??e.name??e.label})).filter(e=>e.permissionKey),r=new Set(n.map(e=>String(e.permissionKey).trim().toLowerCase()));return IE.forEach(e=>{r.has(e.permissionKey.toLowerCase())||n.push(e)}),n}function RE(e={}){return String(e.permissionName??``).trim()||String(e.permissionKey??``).replaceAll(`_`,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/\b\w/g,e=>e.toUpperCase())}function zE({title:e,description:t,selectedName:n,loading:r,saving:i,rows:a,onChange:o,onMove:u,onSave:d}){let f=Object.values(a.reduce((e,t)=>{let n=FE(t);return e[n]||(e[n]={key:n,menuName:t.menuName,menuKey:t.menuKey,permissions:[]}),e[n].permissions.push(t),e},{}));return(0,l.jsxs)(`section`,{className:`admin-editor`,children:[(0,l.jsxs)(`div`,{className:`admin-section-head`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(EE,{level:4,children:e}),(0,l.jsx)(TE,{type:`secondary`,children:n||t})]}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),loading:i,disabled:!n||a.length===0,onClick:d,children:`Save`})]}),r?(0,l.jsx)(`div`,{className:`admin-loading`,children:(0,l.jsx)(s.Spin,{})}):f.length?(0,l.jsx)(s.Table,{size:`small`,rowKey:`key`,columns:[{title:`Menu`,dataIndex:`menuName`,width:220,render:(e,t)=>(0,l.jsxs)(`div`,{className:`admin-menu-order-cell`,children:[(0,l.jsxs)(`div`,{className:`admin-menu-cell`,children:[(0,l.jsx)(`span`,{children:e}),(0,l.jsx)(TE,{type:`secondary`,children:t.menuKey})]}),(0,l.jsxs)(s.Space,{size:2,children:[(0,l.jsx)(s.Button,{size:`small`,type:`text`,icon:(0,l.jsx)(c.ArrowUpOutlined,{}),onClick:()=>u(t.key,-1),"aria-label":`Move ${e} up`}),(0,l.jsx)(s.Button,{size:`small`,type:`text`,icon:(0,l.jsx)(c.ArrowDownOutlined,{}),onClick:()=>u(t.key,1),"aria-label":`Move ${e} down`})]})]})},{title:`Actions`,dataIndex:`permissions`,render:e=>(0,l.jsx)(`div`,{className:`admin-permission-controls`,children:e.filter(e=>Sx(e.menuName??e.menuKey,e.permissionKey)).map(e=>(0,l.jsx)(`label`,{className:`admin-permission-control`,children:(0,l.jsx)(s.Checkbox,{checked:e.accessValue===1,onChange:t=>o(e.key,+!!t.target.checked),"aria-label":`${e.menuName} ${e.permissionKey}`,children:RE(e)})},e.key))})}],dataSource:f,pagination:!1,scroll:{y:420}}):(0,l.jsx)(s.Empty,{description:`Select a record to customize permissions`})]})}function BE({onLogout:e}){let[r]=s.Form.useForm(),[i]=s.Form.useForm(),[a,u]=(0,o.useState)(`users`),[d,f]=(0,o.useState)(!0),[p,m]=(0,o.useState)(!1),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)([]),[y,b]=(0,o.useState)(0),[x,S]=(0,o.useState)(1),[C,w]=(0,o.useState)(10),[T,E]=(0,o.useState)(``),[D,O]=(0,o.useState)(!1),[k,A]=(0,o.useState)([]),[j,M]=(0,o.useState)([]),[N,P]=(0,o.useState)([]),[F,I]=(0,o.useState)(null),[L,R]=(0,o.useState)([]),[z,B]=(0,o.useState)(!1),[V,ee]=(0,o.useState)(null),[te,ne]=(0,o.useState)(!1),[re,ie]=(0,o.useState)(null),[ae,oe]=(0,o.useState)([]),[se,H]=(0,o.useState)(!1),[ce,le]=(0,o.useState)(!1),[ue,de]=(0,o.useState)(null),[fe,pe]=(0,o.useState)(!1),[me,he]=(0,o.useState)(null),[ge,_e]=(0,o.useState)(`listView`),[ve,ye]=(0,o.useState)([]),[be,xe]=(0,o.useState)([]),[Se,Ce]=(0,o.useState)(!1),[we,U]=(0,o.useState)(!1),W=t.d(),Te=(0,o.useMemo)(()=>ve.filter(e=>!e.disabled),[ve]),Ee=!Se&&Te.length===0,De=(0,o.useCallback)(async()=>{Ce(!0);try{let[e,t]=await Promise.all([n.Or(),n.br()]),r=jE(e.modules,t),i=new Set(r.filter(e=>!e.disabled).map(e=>e.value));ye(r),xe(e=>e.filter(e=>i.has(e)))}catch{s.message.error(`Failed to load seed status`)}finally{Ce(!1)}},[]);(0,o.useEffect)(()=>{De()},[De]);async function Oe(){if(be.length===0){s.message.warning(Ee?`All modules already seeded.`:`Select at least one module to seed.`);return}U(!0);try{await n.ui(be),s.message.success(`User type field config seeded`),xe([]),await De()}catch(e){s.message.error(e?.message||`Seed failed`)}finally{U(!1)}}async function ke(){f(!0);try{let[e,t,n]=await Promise.allSettled([ux(),mx(),vx()]),r=e.status===`fulfilled`?e.value:[];e.status===`rejected`&&s.message.error(e.reason?.message||`Unable to load user types`),A(r??[]),M(t.status===`fulfilled`?t.value??[]:[]),P(n.status===`fulfilled`?LE(n.value):[]),I((r??[])[0]?.user_type_id??null)}catch(e){s.message.error(e.message||`Unable to load admin data`)}finally{f(!1)}}(0,o.useEffect)(()=>{queueMicrotask(()=>{ke()})},[]);let Ae=(0,o.useCallback)(async()=>{O(!0);try{let{users:e,total:t}=await ax({limit:C,offset:(x-1)*C,search:T});v(e??[]),b(t??0)}catch(e){s.message.error(e?.message||`Unable to load users`),v([]),b(0)}finally{O(!1)}},[x,C,T]);(0,o.useEffect)(()=>{Ae()},[Ae]),(0,o.useEffect)(()=>{queueMicrotask(()=>{if(!F){R([]);return}m(!0),console.log(`DEBUG requesting role permissions for selectedUserTypeId=`,F,`localStorage scope=`,{tenantId:localStorage.getItem(`tenantId`),businessId:localStorage.getItem(`businessId`),businessUnitId:localStorage.getItem(`businessUnitId`)}),yx(F).then(e=>{console.log(`DEBUG raw groups from /get-role-details`,e);let t=PE(e??[]);console.log(`DEBUG savedRows (jobs only)`,t.filter(e=>FE(e)===`jobs`||FE(e)===`job`));let n=new Map(t.map(e=>[`${FE(e)}:${String(e.permissionKey).toLowerCase()}`,e.accessValue]));console.log(`DEBUG savedAccess keys`,[...n.keys()]),console.log(`DEBUG menus (jobs only)`,j.filter(e=>String(e.menu_key??e.menu_name??e.menu_id).trim().toLowerCase()===`jobs`));let r=j.flatMap(e=>N.map(t=>{let r=String(e.menu_key??e.menu_name??e.menu_id).trim().toLowerCase(),i=String(t.permissionKey).toLowerCase();return{key:`${e.menu_key??e.menu_name??e.menu_id}:${t.permissionId??t.permissionKey}`,menuId:e.menu_id,menuName:e.menu_name,menuKey:e.menu_key,permissionId:t.permissionId,permissionKey:t.permissionKey,accessValue:n.get(`${r}:${i}`)??0}}));console.log(`DEBUG final rows (jobs only)`,r.filter(e=>FE(e)===`jobs`||FE(e)===`job`)),R(r)}).catch(e=>s.message.error(e.message||`Unable to load role permissions`)).finally(()=>m(!1))})},[F,j,N]);let je=(0,o.useMemo)(()=>k.find(e=>e.user_type_id===F),[F,k]),Me=(0,o.useMemo)(()=>k.reduce((e,t)=>({...e,[t.user_type_id]:t.user_type_name}),{}),[k]),Ne=(0,o.useMemo)(()=>_.reduce((e,t)=>({...e,[t.user_id]:NE(t)}),{}),[_]),G=(0,o.useMemo)(()=>k.filter(e=>!ME(e)),[k]),Pe=(0,o.useMemo)(()=>_.filter(e=>!ME({user_type_id:e.user_type_id,user_type_name:Me[e.user_type_id]})),[Me,_]);(0,o.useEffect)(()=>{if(!z){oe([]);return}let e=Number(r.getFieldValue(`user_type_id`)??0);if(!e){oe([]);return}let t=!1;return H(!0),ox(e).then(e=>{t||oe(e.filter(e=>!V||e.user_id!==V.user_id))}).catch(e=>{t||(s.message.error(e.message||`Unable to load reporting users`),oe([]))}).finally(()=>{t||H(!1)}),()=>{t=!0}},[V,r,z]);let Fe=(0,o.useMemo)(()=>{let e=ae.map(e=>({label:NE(e),value:e.user_id})),t=Number(V?.reporting_id??V?.reportingId??0);return!t||e.some(e=>Number(e.value)===t)?e:[{label:V?.reportingName??V?.reporting_name??Ne[t]??`User ${t}`,value:t},...e]},[V,ae,Ne]),Ie=(0,o.useMemo)(()=>{let e=G.map(e=>({label:e.user_type_name,value:e.user_type_id}));if(!V)return e;let t=Number(V.user_type_id??0);return e.some(e=>Number(e.value)===t)?e:[{label:Me[t]??V.userType??V.roleName??(t>0?`Type ${t}`:`Unassigned`),value:t},...e]},[V,G,Me]);k.length,j.length;let Le=[{key:`form-groups`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.AppstoreAddOutlined,{}),` Form Groups`]}),title:`Form Groups`,description:`Build module add and edit form groups with validations, dropdowns, and custom forms.`,component:(0,l.jsx)(IC,{})},{key:`detail-groups`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.BgColorsOutlined,{}),` Detail Groups`]}),title:`Detail Groups`,description:`Control detail-view labels, rendering, lookups, merged fields, and display defaults.`,component:(0,l.jsx)(mw,{})},{key:`actions`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.ThunderboltOutlined,{}),` Actions`]}),title:`Actions`,description:`Manage row action buttons and their visibility rules from one workspace.`,component:(0,l.jsx)(rT,{})},{key:`templates`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.MailOutlined,{}),` Templates`]}),title:`Templates`,description:`Manage reusable email templates and signatures.`,component:(0,l.jsx)(hT,{})},{key:`ai-services`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.ThunderboltOutlined,{}),` AI Services`]}),title:`AI Services`,description:`Register the AI and automation services used by admin-configured AI actions.`,component:(0,l.jsx)(yT,{})},{key:`bgc-integration`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.SafetyCertificateOutlined,{}),` Integrations`]}),title:`Integrations`,description:`Manage manual and API integrations used across application workflows.`,component:(0,l.jsx)(TT,{})},{key:`automations`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.ApartmentOutlined,{}),` Automations`]}),title:`Automations`,description:`Reference ids, duplicate checks, cross-module snapshots, reporting-chain hierarchy expansion, board updates, notifications, and cache invalidation — per module, config-driven.`,component:(0,l.jsx)(zT,{})},{key:`workflows`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.ApartmentOutlined,{}),` Workflows`]}),title:`Workflows`,description:`Event-driven behavior per module (beforeCreate/afterCreate/…): the metadata the platform Workflow Engine executes — where the jobs, candidates, and submissions create flows live.`,component:(0,l.jsx)(qT,{})},{key:`po-msa-settings`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.SafetyCertificateOutlined,{}),` PO/MSA Settings`]}),title:`PO/MSA Settings`,description:`Configure employer and referral MSA validity and expiry warning days.`,component:(0,l.jsx)(hE,{})},{key:`masters`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.AppstoreAddOutlined,{}),` Masters`]}),title:`Masters`,description:`Shared Location and Tax lists used across modules (e.g. the submission form’s W2 employer section).`,component:(0,l.jsx)(fE,{})}],Re=[{key:`users`,icon:(0,l.jsx)(c.UserOutlined,{}),label:`Users`},{key:`roles`,icon:(0,l.jsx)(c.TeamOutlined,{}),label:`User Types`},{key:`menus`,icon:(0,l.jsx)(c.MenuOutlined,{}),label:`Menus`},{key:`configurations`,icon:(0,l.jsx)(c.AppstoreAddOutlined,{}),label:`Configurations`},{key:`integrations`,icon:(0,l.jsx)(c.SafetyCertificateOutlined,{}),label:`Integrations`}];function ze(e,t){R(n=>{let r=n.filter(t=>t.key===e).length;return console.log(`DEBUG updateRolePermission`,{key:e,value:t,matchCount:r}),n.map(n=>n.key===e?{...n,accessValue:t}:n)})}async function Be(){g(!0);try{console.log(`DEBUG saveRolePermissions jobs rows`,L.filter(e=>FE(e)===`jobs`||FE(e)===`job`)),await bx(F,L.map(e=>({menu_id:e.menuId,menu_name:e.menuName,menu_key:e.menuKey,permission_id:e.permissionId,permission_key:e.permissionKey,access_value:e.accessValue,updated_by:W?.userId??null}))),s.message.success(`Role permissions updated`)}catch(e){s.message.error(e.message||`Unable to save role permissions`)}finally{g(!1)}}function K(){ee(null),r.resetFields(),r.setFieldsValue({status:`ACTIVE`,user_type_id:G[0]?.user_type_id,reporting_id:0}),B(!0)}function q(e){ee(e),r.setFieldsValue({first_name:e.first_name,last_name:e.last_name,username:e.username,email:e.email,mobile:e.mobile,user_type_id:e.user_type_id,reporting_id:e.reporting_id??e.reportingId??0,profile_image:e.profile_image,status:e.status}),B(!0)}async function Ve(e){ne(!0);try{let t={...e,status:e.status===1||e.status===`1`||e.status===!0?`ACTIVE`:e.status===0||e.status===`0`||e.status===!1?`INACTIVE`:String(e.status??`ACTIVE`).toUpperCase(),updated_by:W?.userId??null,created_by:W?.userId??null};t.password||delete t.password,V?(await cx(V.user_id,t),s.message.success(`User updated`)):(await sx(t),s.message.success(`User created`)),B(!1),ee(null),await Ae()}catch(e){s.message.error(e.message||`Unable to save user`)}finally{ne(!1)}}async function J(e){ie(e);try{await lx(e),s.message.success(`User deleted`),await Ae()}catch(e){s.message.error(e.message||`Unable to delete user`)}finally{ie(null)}}function He(e,t){_e(`listView`),he({kind:e,record:t}),e===`role`&&I(t.user_type_id)}function Ue(e,t){R(n=>{let r=[...new Set(n.map(FE))],i=r.indexOf(e),a=i+t;if(i<0||a<0||a>=r.length)return n;[r[i],r[a]]=[r[a],r[i]];let o=new Map(r.map((e,t)=>[e,t]));return[...n].sort((e,t)=>o.get(FE(e))-o.get(FE(t)))})}function We(){de(null),i.resetFields(),i.setFieldsValue({status:`ACTIVE`}),le(!0)}function Ge(e){de(e),le(!0),i.setFieldsValue(e)}async function Ke(e){pe(!0);try{let t=W?.userId??null,n=!!ue,r=n?await fx(ue.user_type_id,{...e,updated_by:t}):await dx({...e,created_by:t,visible_menu_ids:[]}),i=r.user_type_id;s.message.success(n?`User type updated`:`User type created. Customize its menus and permissions.`),le(!1),await ke(),I(i),n||(_e(`permissions`),he({kind:`role`,record:{...e,...r,user_type_id:i,user_type_name:r.user_type_name??e.user_type_name}}))}catch(e){s.message.error(e.message||`Unable to save role`)}finally{pe(!1)}}async function Y(e){try{await px(e),s.message.success(`Role deleted`),await ke()}catch(e){s.message.error(e.message||`Unable to delete role`)}}return(0,l.jsxs)(s.Layout,{className:`admin-shell`,children:[(0,l.jsx)(wE,{width:248,className:`admin-sider`,children:(0,l.jsxs)(`div`,{className:`admin-sidebar-nav`,children:[(0,l.jsx)(TE,{className:`admin-sidebar-title`,children:`Admin Menu`}),(0,l.jsx)(s.Menu,{theme:`dark`,mode:`inline`,selectedKeys:[a],onClick:({key:e})=>u(e),items:Re})]})}),(0,l.jsx)(s.Layout,{children:(0,l.jsxs)(SE,{className:`admin-content`,children:[(0,l.jsx)(l.Fragment,{children:(0,l.jsx)(s.Tabs,{activeKey:a,onChange:u,tabBarStyle:{display:`none`},items:[{key:`users`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.UserOutlined,{}),` Users`]}),children:(0,l.jsx)(`div`,{className:`admin-stack`,children:(0,l.jsxs)(`section`,{className:`admin-section`,children:[(0,l.jsxs)(`div`,{className:`admin-section-head`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(EE,{level:4,children:`Users`}),(0,l.jsx)(TE,{type:`secondary`,children:`Create and manage users with non-super-admin user types.`})]}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:K,children:`Add`})]}),(0,l.jsx)(km,{listName:`Users`,loading:D,fields:[{label:`Name`,value:`first_name`,render:(e,t)=>`${e??``} ${t.last_name??``}`.trim()||t.username},{label:`Email`,value:`email`},{label:`User Type`,value:`user_type_id`,width:160,render:(e,t)=>Me[e]||t?.userType||t?.user_type||(Number(e)>0?`Type ${e}`:`—`)},{label:`Reporting Manager`,value:`reporting_id`,width:180,render:(e,t)=>Ne[e]||t?.reportingName||t?.reporting_name||(Number(e)>0?`User ${e}`:`None`)},{label:`Status`,value:`status`,width:110,sorter:!1,render:e=>(0,l.jsx)(s.Tag,{color:e===`ACTIVE`?`green`:`default`,children:e})},{label:`Actions`,value:`_actions`,width:150,sorter:!1,render:(e,t)=>(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Button,{"aria-label":`Edit user`,icon:(0,l.jsx)(c.EditOutlined,{}),size:`small`,onClick:()=>q(t)}),(0,l.jsx)(s.Popconfirm,{title:`Delete user?`,description:`This removes the user from the auth database.`,okText:`Delete`,okButtonProps:{danger:!0},onConfirm:()=>J(t.user_id),children:(0,l.jsx)(s.Button,{danger:!0,"aria-label":`Delete user`,icon:(0,l.jsx)(c.DeleteOutlined,{}),loading:re===t.user_id,size:`small`})})]})}],dataSource:Pe.map(e=>({...e,key:e.user_id})),total:y,current:x,pageSize:C,onPageChange:S,onPageSizeChange:e=>{w(e),S(1)},onSearch:e=>{E(e??``),S(1)},rowSelection:!1})]})})},{key:`roles`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.TeamOutlined,{}),` User Types`]}),children:(0,l.jsxs)(`div`,{className:`admin-stack`,children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.AppstoreOutlined,{}),title:`Field Config Seed`,style:{marginBottom:12},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[(0,l.jsx)(`div`,{style:{minWidth:320,flex:1},children:(0,l.jsx)(s.Select,{mode:`multiple`,allowClear:!0,showSearch:!0,value:be,options:ve,placeholder:Ee?`All modules already seeded`:`Select modules or collections to seed`,disabled:Se||we||Ee,loading:Se,onChange:xe,style:{width:`100%`}})}),(0,l.jsx)(s.Button,{type:`primary`,loading:we,disabled:Se||be.length===0,onClick:Oe,children:`Seed Field Config`})]}),(0,l.jsx)(TE,{type:`secondary`,style:{display:`block`,marginTop:8,fontSize:12},children:Ee?`Seed is disabled because all configured modules already have user type field config data.`:`Already seeded modules are disabled. New modules or collections can still be seeded.`})]}),(0,l.jsxs)(`section`,{className:`admin-section`,children:[(0,l.jsxs)(`div`,{className:`admin-section-head`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(EE,{level:4,children:`User Types`}),(0,l.jsx)(TE,{type:`secondary`,children:`Role level permissions are inherited by users.`})]}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:We,children:`Add Role`})]}),(0,l.jsx)(km,{listName:`User Types`,loading:d,fields:[{label:`User Type`,value:`user_type_name`},{label:`Description`,value:`description`},{label:`Status`,value:`status`,width:110,sorter:!1,render:e=>(0,l.jsx)(s.Tag,{color:e===`ACTIVE`?`green`:`default`,children:e})},{label:`Actions`,value:`_actions`,width:260,sorter:!1,render:(e,t)=>{let n=Number(t.role_type)===1;return(0,l.jsxs)(s.Space,{size:4,children:[(0,l.jsx)(s.Button,{"aria-label":`Configure role`,size:`small`,onClick:()=>He(`role`,t),children:`Config`}),(0,l.jsx)(s.Button,{"aria-label":`Edit role`,disabled:!n,icon:(0,l.jsx)(c.EditOutlined,{}),size:`small`,onClick:()=>Ge(t)}),n&&!ME(t)&&(0,l.jsx)(s.Popconfirm,{title:`Delete role?`,onConfirm:()=>Y(t.user_type_id),children:(0,l.jsx)(s.Button,{"aria-label":`Delete role`,danger:!0,icon:(0,l.jsx)(c.DeleteOutlined,{}),size:`small`})})]})}}],dataSource:k.map(e=>({...e,key:e.user_type_id,roleId:e.user_type_id,roleName:e.user_type_name})),total:k.length,rowSelection:!1})]})]})},{key:`menus`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.MenuOutlined,{}),` Menus`]}),children:(0,l.jsx)(xE,{})},{key:`configurations`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.AppstoreAddOutlined,{}),` Configurations`]}),children:(0,l.jsxs)(`section`,{className:`admin-section admin-config-workspace`,children:[(0,l.jsxs)(`div`,{className:`admin-section-head`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(EE,{level:4,children:`Configuration Center`}),(0,l.jsx)(TE,{type:`secondary`,children:`CORE-THEME admin modules embedded into the admin dashboard.`})]}),(0,l.jsxs)(s.Tag,{color:`blue`,children:[Le.length,` configurations`]})]}),(0,l.jsx)(s.Tabs,{className:`admin-config-tabs`,defaultActiveKey:`form-groups`,tabPosition:`left`,items:Le.map(e=>({key:e.key,label:e.label,children:(0,l.jsxs)(`div`,{className:`admin-config-panel`,children:[(0,l.jsx)(`div`,{className:`admin-config-panel-head`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(EE,{level:4,children:e.title}),(0,l.jsx)(TE,{type:`secondary`,children:e.description})]})}),(0,l.jsx)(`div`,{className:`admin-config-panel-body`,children:e.component})]})}))})]})},{key:`integrations`,label:(0,l.jsxs)(`span`,{children:[(0,l.jsx)(c.SafetyCertificateOutlined,{}),` Integrations`]}),children:(0,l.jsxs)(`section`,{className:`admin-section admin-config-workspace`,children:[(0,l.jsx)(`div`,{className:`admin-section-head`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(EE,{level:4,children:`Integrations`}),(0,l.jsx)(TE,{type:`secondary`,children:`Configure external services used by onboarding and other workflows.`})]})}),(0,l.jsx)(`div`,{className:`admin-config-panel`,children:(0,l.jsx)(`div`,{className:`admin-config-panel-body`,children:(0,l.jsx)(TT,{})})})]})}]})}),(0,l.jsxs)(s.Modal,{className:`uss-modal`,title:`Configure User Type: ${me?.record?.user_type_name??``}`,open:!!me,onCancel:()=>he(null),footer:null,destroyOnHidden:!0,width:900,children:[(0,l.jsx)(`div`,{className:`uss-config-toggle`,style:{marginBottom:12},children:[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`},{key:`actions`,label:`Actions`}].map(e=>(0,l.jsx)(`button`,{type:`button`,className:`uss-config-btn${ge===e.key?` active`:``}`,onClick:()=>_e(e.key),children:e.label},e.key))}),me&&ge===`permissions`?(0,l.jsx)(zE,{title:`Role Permissions`,description:`Configure menu permissions for this user type`,selectedName:je?.user_type_name,loading:p,saving:h,rows:L,onChange:ze,onMove:Ue,onSave:Be}):me&&ge===`actions`?(0,l.jsx)(iS,{role:{...me.record,roleId:me.record.user_type_id,roleName:me.record.user_type_name}},`${me.record?.user_type_id}-actions`):me&&ge===`form`?(0,l.jsx)(Xx,{role:{...me.record,roleId:me.record.user_type_id,roleName:me.record.user_type_name}},`${me.record?.user_type_id}-form`):me?(0,l.jsx)(zx,{role:{...me.record,roleId:me.record.user_type_id,roleName:me.record.user_type_name},configType:ge},`${me.record?.user_type_id}-${ge}`):null]}),(0,l.jsx)(s.Modal,{className:`admin-role-modal`,title:ue?`Edit User Type`:`Create User Type`,open:ce,onCancel:()=>le(!1),onOk:()=>i.submit(),okText:ue?`Save`:`Next`,confirmLoading:fe,destroyOnHidden:!0,width:900,children:(0,l.jsxs)(s.Form,{form:i,layout:`vertical`,onFinish:Ke,children:[(0,l.jsx)(s.Form.Item,{name:`user_type_name`,label:`Role name`,rules:[{required:!0,message:`Role name is required`}],children:(0,l.jsx)(s.Input,{placeholder:`Recruiter`})}),(0,l.jsx)(s.Form.Item,{name:`description`,label:`Description`,children:(0,l.jsx)(s.Input.TextArea,{rows:3})}),(0,l.jsx)(s.Form.Item,{name:`status`,label:`Status`,children:(0,l.jsx)(s.Select,{options:[{value:`ACTIVE`},{value:`INACTIVE`}]})})]})}),(0,l.jsx)(s.Modal,{className:`admin-user-modal`,title:V?`Edit User`:`Add User`,open:z,onCancel:()=>B(!1),onOk:()=>r.submit(),confirmLoading:te,destroyOnHidden:!0,children:(0,l.jsxs)(s.Form,{form:r,layout:`vertical`,requiredMark:!1,onFinish:Ve,children:[(0,l.jsxs)(`div`,{className:`admin-form-row`,children:[(0,l.jsx)(s.Form.Item,{label:`First Name`,name:`first_name`,rules:[{required:!0,message:`First name is required`}],children:(0,l.jsx)(s.Input,{placeholder:`John`})}),(0,l.jsx)(s.Form.Item,{label:`Last Name`,name:`last_name`,children:(0,l.jsx)(s.Input,{placeholder:`Doe`})})]}),(0,l.jsx)(s.Form.Item,{label:`Username`,name:`username`,rules:[{required:!0,message:`Username is required`}],children:(0,l.jsx)(s.Input,{placeholder:`john.doe`})}),(0,l.jsx)(s.Form.Item,{label:`Email`,name:`email`,rules:[{required:!0,message:`Email is required`},{type:`email`,message:`Enter a valid email`}],children:(0,l.jsx)(s.Input,{placeholder:`john@example.com`})}),(0,l.jsx)(s.Form.Item,{label:`Password`,name:`password`,rules:V?[]:[{required:!0,message:`Password is required`}],children:(0,l.jsx)(s.Input.Password,{placeholder:V?`Leave empty to keep current password`:`Password`})}),(0,l.jsxs)(`div`,{className:`admin-form-row`,children:[(0,l.jsx)(s.Form.Item,{label:`Mobile`,name:`mobile`,children:(0,l.jsx)(s.Input,{placeholder:`9999999999`})}),(0,l.jsx)(s.Form.Item,{label:`User Type`,name:`user_type_id`,rules:[{required:!0,message:`User type is required`}],children:(0,l.jsx)(s.Select,{placeholder:`Select user type`,onChange:()=>{oe([]),queueMicrotask(()=>{let e=Number(r.getFieldValue(`user_type_id`)??0);e&&(H(!0),ox(e).then(e=>{oe(e.filter(e=>!V||e.user_id!==V.user_id))}).catch(e=>{s.message.error(e.message||`Unable to load reporting users`),oe([])}).finally(()=>{H(!1)}))})},options:Ie})})]}),(0,l.jsx)(s.Form.Item,{label:`Reporting Manager`,name:`reporting_id`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,loading:se,placeholder:`Select reporting manager`,optionFilterProp:`label`,options:[{label:`None`,value:0},...Fe]})}),(0,l.jsx)(s.Form.Item,{label:`Profile Image`,name:`profile_image`,children:(0,l.jsx)(s.Input,{placeholder:`https://...`})}),(0,l.jsx)(s.Form.Item,{label:`Status`,name:`status`,children:(0,l.jsx)(s.Select,{options:[{label:`ACTIVE`,value:`ACTIVE`},{label:`INACTIVE`,value:`INACTIVE`}]})})]})})]})})]})}var VE=BE;function HE(e,t){return String(e||t).replace(/\/\*$/,``).replace(/\/+$/,``)||t}function UE({loginPath:e=`/login`,adminPath:t=`/admin`,fallbackPath:n=`/`}){let r=(0,d.useNavigate)(),i=HE(e,`/login`),a=HE(t,`/admin`),o=`${a}/*`;return(0,l.jsxs)(d.Routes,{children:[(0,l.jsx)(d.Route,{path:i,element:(0,l.jsx)(db,{defaultRedirectPath:a,onLogin:()=>r(a,{replace:!0})})}),(0,l.jsx)(d.Route,{path:o,element:(0,l.jsx)(rb,{loginPath:i,children:(0,l.jsx)(ub,{children:(0,l.jsx)(VE,{onLogout:()=>r(i,{replace:!0})})})})}),(0,l.jsx)(d.Route,{path:n,element:(0,l.jsx)(d.Navigate,{to:a,replace:!0})}),(0,l.jsx)(d.Route,{path:`*`,element:(0,l.jsx)(d.Navigate,{to:a,replace:!0})})]})}function WE(e){return(0,l.jsx)(d.BrowserRouter,{children:(0,l.jsx)(UE,{...e})})}function GE(e){return Array.isArray(e)?e.map(String).map(e=>e.trim()).filter(Boolean):String(e??``).split(`,`).map(e=>e.trim()).filter(Boolean)}function KE(e){return GE(e).every(e=>/^[^,\s@]+@[^,\s@]+\.[^\s@]{2,}$/.test(e))}var{Text:qE}=s.Typography,JE=new Set([`file`,`document`,`attachment`]);function YE(e){return JE.has(String(e?.type??``).trim().toLowerCase())}function XE(e){return String(e??``).trim().toLowerCase().replace(/[^a-z0-9]/g,``)}function ZE(e){return e?typeof e==`string`?e:String(typeof e==`object`?e?._id??e?.id??e?.$oid??``:e):``}function QE(e,t,n){if(!e)return``;let r=XE(t),i=XE(n);if(!r||r===i||r.replace(/s$/,``)===i.replace(/s$/,``))return ZE(e?._id??e?.id);let a=r.replace(/s$/,``),o=[`${a}Id`,`${r}Id`,a,r,`${a}._id`,`${r}._id`];for(let t of o){let n=ZE(rD(e,t));if(n)return n}return``}async function $E(e){let t=e?.fileUrl??e?.url??e?.downloadUrl;if(!t)return null;let n=await fetch(t);if(!n.ok)throw Error(`Unable to load attachment ${e?.fileName||``}`.trim());let r=await n.blob(),i=e?.fileName??e?.uploadedFileName??e?.uniqueName??`attachment`;return new File([r],i,{type:e?.contentType||r.type||`application/octet-stream`})}async function eD(e,t,r){if(!t)return[];let i=[];(e?.placeholders??[]).forEach(e=>{(e?.holders??[]).filter(YE).forEach(a=>{let o=QE(t,e?.moduleName,r);o&&i.push((async()=>{let t=await n.yn(e.moduleName,o,a.value);return Promise.all((t?.data??[]).map($E))})())})});let a=(await Promise.all(i)).flat().filter(Boolean),o=new Set;return a.filter(e=>{let t=`${e.name}:${e.size}:${e.type}`;return!o.has(t)&&(o.add(t),!0)})}function tD(e,t){return[...new Set([...GE(e),...GE(t)])].join(`, `)}function nD(e=[],t=[]){let n=new Set;return[...e,...t].filter(e=>{if(!e)return!1;let t=`${e.name}:${e.size}:${e.type}`;return!n.has(t)&&(n.add(t),!0)})}function rD(e,t,n=``){let r=String(n??``).trim().toLowerCase();return String(t??``).split(`.`).reduce((e,t)=>{let n=e;return Array.isArray(n)&&r===`last`&&(n=n.at(-1)),n?.[t]},e)}function iD(e,t,n){if(!n)return String(e??``);let r=new Map;return(t??[]).forEach(e=>(e.holders??[]).forEach(e=>{r.set(e.key,YE(e)?``:rD(n,e.value,e.arrayMode))})),String(e??``).replace(/{{\.?([\w.]+)}}/g,(e,t)=>{let n=r.get(t);return n==null?e:String(n)})}function aD({value:e,onChange:t,defaultTemplateId:r=``,ready:i=!0,title:a=`Mail`,hint:u,bccHint:d,afterBcc:f,beforeFields:p,className:m=``,contextRecords:h=[],moduleName:g=``}){let _=(0,o.useRef)(``),v=n=>t?.({...e,...n});async function y(t,n=!1){if(t)try{let r=await ww(t),i=h[0],a=await eD(r,i,g);v({to:tD(e.to,(r?.toMail??[]).map(e=>iD(e,r?.placeholders,i))),cc:tD(e.cc,(r?.ccMail??[]).map(e=>iD(e,r?.placeholders,i))),bcc:tD(e.bcc,(r?.bccMail??[]).map(e=>iD(e,r?.placeholders,i))),subject:iD(r?.subject,r?.placeholders,i),contents:iD(r?.body,r?.placeholders,i),attachments:nD(e.attachments,a)}),n||s.message.success(`Loaded ${r?.name||`email template`}`)}catch(e){n||s.message.error(e?.message||`Could not load email template`)}}return(0,o.useEffect)(()=>{!i||!r||_.current===r||(_.current=r,y(r,!0))},[r,i]),(0,l.jsxs)(`div`,{className:`common-mail-composer ${m}`.trim(),children:[(0,l.jsx)(`div`,{className:`mail-popup__header`,children:(0,l.jsxs)(`div`,{className:`mail-popup__header-brand`,children:[(0,l.jsx)(`span`,{className:`dynamic-popup__header-icon-box`,children:(0,l.jsx)(c.MailOutlined,{})}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`span`,{className:`dynamic-popup__header-label`,children:a}),u&&(0,l.jsx)(qE,{type:`secondary`,className:`mail-popup__header-hint`,children:u})]})]})}),(0,l.jsxs)(`div`,{className:`mail-popup__body`,children:[p&&(0,l.jsxs)(l.Fragment,{children:[p,(0,l.jsx)(s.Divider,{})]}),(0,l.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,l.jsx)(qE,{type:`secondary`,className:`mail-popup__field-label`,children:`To`}),(0,l.jsx)(s.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`],value:GE(e.to),onChange:e=>v({to:e.join(`, `)}),variant:`borderless`,className:`mail-popup__recipient-select`,placeholder:`Add email addresses`}),(0,l.jsxs)(`div`,{className:`mail-popup__cc-bcc-actions`,children:[!e.showCc&&(0,l.jsx)(`span`,{className:`mail-popup__cc-bcc-link`,onClick:()=>v({showCc:!0}),children:`Cc`}),!e.showBcc&&(0,l.jsx)(`span`,{className:`mail-popup__cc-bcc-link`,onClick:()=>v({showBcc:!0}),children:`Bcc`})]})]}),(0,l.jsx)(s.Divider,{}),e.showCc&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,l.jsx)(qE,{type:`secondary`,className:`mail-popup__field-label`,children:`Cc`}),(0,l.jsx)(s.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`],value:GE(e.cc),onChange:e=>v({cc:e.join(`, `)}),variant:`borderless`,className:`mail-popup__recipient-select`})]}),(0,l.jsx)(s.Divider,{})]}),e.showBcc&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,l.jsx)(qE,{type:`secondary`,className:`mail-popup__field-label`,children:`Bcc`}),(0,l.jsx)(s.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`],value:GE(e.bcc),onChange:e=>v({bcc:e.join(`, `)}),variant:`borderless`,className:`mail-popup__recipient-select`,placeholder:d})]}),f,(0,l.jsx)(s.Divider,{})]}),(0,l.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,l.jsx)(qE,{type:`secondary`,className:`mail-popup__field-label`,children:`Subject`}),(0,l.jsx)(s.Input,{variant:`borderless`,value:e.subject,onChange:e=>v({subject:e.target.value}),placeholder:`Enter subject`,className:`mail-popup__field-input`})]}),(0,l.jsx)(s.Divider,{}),!!e.attachments?.length&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,l.jsx)(qE,{type:`secondary`,className:`mail-popup__field-label`,children:`Attachments`}),(0,l.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:6,padding:`4px 0`},children:e.attachments.map((e,t)=>(0,l.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,l.jsx)(c.PaperClipOutlined,{}),e.name]},`${e.name}:${e.size}:${t}`))})]}),(0,l.jsx)(s.Divider,{})]}),(0,l.jsxs)(`div`,{className:`mail-popup__message-section`,children:[(0,l.jsx)(qE,{type:`secondary`,className:`mail-popup__message-label`,children:`Message`}),(0,l.jsx)(n.Dn,{value:e.contents,onChange:e=>v({contents:e})})]})]})]})}var{Text:oD}=s.Typography,sD=/^[a-fA-F0-9]{24}$/,cD=new Set([`file`,`document`,`attachment`]);async function lD(e){let t=e?.fileUrl??e?.url??e?.downloadUrl;if(!t)return null;let n=await fetch(t);if(!n.ok)throw Error(`Unable to load attachment ${e?.fileName||``}`.trim());let r=await n.blob(),i=e?.fileName??e?.uploadedFileName??e?.uniqueName??`attachment`;return new File([r],i,{type:e?.contentType||r.type||`application/octet-stream`})}async function uD(e,t,r=[]){let i=String(e??``);if(!i||!r.length||!t)return{contents:i,attachments:[]};let a=(await n.Vr(t).catch(()=>[])).filter(e=>cD.has(String(e?.type??``).trim().toLowerCase())).filter(e=>{let t=String(e?.value??e?.field??e?.fieldKey??e?.key??e?.name??``).replace(/^\./,``);return t&&(i.includes(`{{.${t}}}`)||i.includes(`{{${t}}}`))});if(!a.length)return{contents:i,attachments:[]};let o=[];for(let e of a){let a=String(e?.value??e?.field??e?.fieldKey??e?.key??e?.name??``).replace(/^\./,``);i=i.replaceAll(`{{.${a}}}`,``).replaceAll(`{{${a}}}`,``);for(let e of r){let r=String(e?._id??e?.id??``);if(!sD.test(r))continue;let i=await n.yn(t,r,a).catch(()=>({data:[]})),s=await Promise.all((i?.data??[]).map(lD));o.push(...s.filter(Boolean))}}let s=new Set,c=o.filter(e=>{let t=`${e.name}:${e.size}:${e.type}`;return!s.has(t)&&(s.add(t),!0)});return{contents:i,attachments:c}}function dD(e){return e===!0?!0:typeof e==`number`?e===1:typeof e==`string`&&[`true`,`1`,`yes`,`y`,`on`].includes(e.trim().toLowerCase())}function fD(e){return[`candidate`,`candidates`].includes(String(e??``).trim().toLowerCase())}function pD(e,...t){for(let n of t){let t=String(n).split(`.`).reduce((e,t)=>e?.[t],e);if(t!=null&&String(t).trim()!==``)return t}}function mD(e){return[pD(e,`jobReferenceId`,`clientJobId`,`jobCode`,`reqId`,`jobId`),pD(e,`jobTitle`,`title`,`name`)].filter(Boolean).join(` - `)||String(pD(e,`_id`,`id`)??`Job`)}function hD(e){let t=pD(e,`_id`,`id`,`jobId`);return t?{value:String(t),label:mD(e),raw:e}:null}function gD(e=[],t=[]){let n=[...t,`email`,`candidateEmail`,`candidate_email`,`emailId`,`mailId`,`alternateEmail`,`altEmail`,`basicDetails.email`,`basicDetails.alternateEmail`,`basicDetails.altEmail`,`candidate.email`,`candidate.emailId`,`submission.email`,`submission.candidateEmail`].filter(Boolean);return e.flatMap(e=>n.map(t=>pD(e,t))).flatMap(e=>Array.isArray(e)?e:[e]).flatMap(GE)}function _D(e){return e?.data?.record??e?.record??e?.data??e}function vD(e){let t=pD(e,`jobId`,`job_id`,`job._id`,`job.id`,`jobs._id`,`jobs.id`);return typeof t==`object`?pD(t,`_id`,`id`,`$oid`):t}function yD(e={}){return{subject:e.subject??e.Subject??``,contents:e.contents??e.Contents??e.body??e.Body??``,toMail:e.toMail??e.ToMail??[],ccMail:e.ccMail??e.CcMail??[],bccMail:e.bccMail??e.BccMail??[]}}function bD(){let e=(0,d.useNavigate)(),{state:t={}}=(0,d.useLocation)(),{selectedIds:r=[],selectedRecords:i=[],recipients:a=[],subject:c=``,contents:u=``,attachments:f=[],onSend:p,moduleName:m=``,popupAction:h={}}=t,g=dD(h.requireJobId)||dD(t.requireJobId)||fD(m),_=(0,o.useMemo)(()=>[h.recipientField,h.recipientPath,t.recipientField,t.recipientPath],[h.recipientField,h.recipientPath,t.recipientField,t.recipientPath]),v=r.join(`|`),y=(0,o.useMemo)(()=>[...a,...gD(i,_)],[a,i,_]),b=String(t.jobId??vD(i[0])??``).trim(),x=r[0]??i[0]?._id??i[0]?.id??``,[S,C]=(0,o.useState)(b),[w,T]=(0,o.useState)(g?b:String(b||x||``)),[E,D]=(0,o.useState)({to:[...new Set(y)].join(`, `),cc:``,bcc:``,subject:c,contents:u,attachments:f,showCc:!1,showBcc:!1}),[O,k]=(0,o.useState)(!w),[A,j]=(0,o.useState)(!1),[M,N]=(0,o.useState)([]),[P,F]=(0,o.useState)(!1),[I,L]=(0,o.useState)(!1),R=(0,o.useRef)(!1),z=(0,o.useRef)(``),B=(0,o.useRef)(0);(0,o.useEffect)(()=>{if(!fD(m)||R.current||GE(E.to).length>0||r.length===0||z.current===v)return;let e=!1;return z.current=v,Promise.all(r.map(e=>n.hn(m,e).catch(()=>null))).then(t=>{if(e)return;let n=gD(t.map(_D).filter(Boolean),_);n.length&&D(e=>GE(e.to).length>0?e:{...e,to:[...new Set(n)].join(`, `)})}),()=>{e=!0}},[E.to,m,_,v,r]),(0,o.useEffect)(()=>{if(!w){k(!0);return}let e=++B.current,t=!1;async function n(){k(!1),j(!0),D(e=>({...e,contents:``}));try{let n=yD(await sn(w)),r=await uD(n.contents||``,m,i),a=r.contents;if(a.trim())try{a=await cn(a,n.subject||c)}catch(n){!t&&e===B.current&&s.message.warning(n?.message||`Mail content formatting failed. Showing original content.`)}if(t||e!==B.current)return;D(e=>({...e,subject:n.subject||e.subject,to:n.toMail?.length?Array.isArray(n.toMail)?n.toMail.join(`, `):String(n.toMail):e.to,cc:n.ccMail?.length?Array.isArray(n.ccMail)?n.ccMail.join(`, `):String(n.ccMail):e.cc,bcc:n.bccMail?.length?Array.isArray(n.bccMail)?n.bccMail.join(`, `):String(n.bccMail):e.bcc,contents:a||r.contents||e.contents,attachments:r.attachments,showCc:e.showCc||!!n.ccMail?.length,showBcc:e.showBcc||!!n.bccMail?.length}))}catch(n){!t&&e===B.current&&g&&s.message.error(n?.message||`Could not load mail template for this Job ID`)}finally{!t&&e===B.current&&(k(!0),j(!1))}}return n(),()=>{t=!0}},[w,g]);function V(e=S){let t=String(e??``).trim();if(!sD.test(t)){T(``),t&&s.message.warning(`Enter a valid 24-character Job ID`);return}if(t===w){T(``),queueMicrotask(()=>T(t));return}T(t)}function ee(e,t){if(!e){T(``),C(``);return}let n=t?.label??``;C(String(n||(e??``))),V(e)}function te(e){let t=String(e??``).trim();if(C(t),t.length<3){N([]);return}F(!0),oe(t).then(e=>{let t=(Array.isArray(e)?e:[]).map(hD).filter(Boolean);N(t)}).catch(e=>s.message.error(e?.message||`Unable to search jobs`)).finally(()=>F(!1))}let ne=O&&(!g||sD.test(w))&&GE(E.to).length+GE(E.cc).length+GE(E.bcc).length>0&&KE(E.to)&&KE(E.cc)&&KE(E.bcc)&&E.subject.trim()&&E.contents.trim();async function re(){if(!(!ne||I)){L(!0);try{await ln({jobId:w,toMail:GE(E.to),ccMail:GE(E.cc),bccMail:GE(E.bcc),subject:E.subject,contents:E.contents,attachments:E.attachments??[]}),s.message.success(`Mail sent successfully`),typeof p==`function`&&p({...E,message:E.contents,selectedIds:r}),e(-1)}catch(e){s.message.error(e?.message||`Failed to send mail`)}finally{L(!1)}}}function ie(e){e?.to!==E.to&&(R.current=!0),D(e)}return(0,l.jsx)(s.Drawer,{open:!0,placement:`right`,onClose:()=>e(-1),closable:!1,rootClassName:`mail-popup`,width:620,maskClosable:!1,footer:(0,l.jsxs)(`div`,{className:`mail-popup__footer`,children:[(0,l.jsx)(s.Button,{onClick:()=>e(-1),children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:I,disabled:!ne,onClick:re,children:`Send`})]}),children:(0,l.jsx)(s.Spin,{spinning:A,tip:`Loading mail content...`,size:`large`,children:(0,l.jsx)(aD,{value:E,onChange:ie,moduleName:m,defaultTemplateId:g?``:h.defaultTemplateId??t.defaultTemplateId??``,ready:O,contextRecords:i,beforeFields:g?(0,l.jsxs)(`div`,{className:`mail-popup__job-row`,children:[(0,l.jsx)(oD,{type:`secondary`,className:`mail-popup__field-label`,children:`Job Title / ID`}),(0,l.jsx)(s.Select,{showSearch:!0,allowClear:!0,filterOption:!1,value:w||void 0,searchValue:S,onSearch:te,onChange:ee,onClear:()=>{T(``),C(``),N([])},placeholder:`Minimum 3 characters`,notFoundContent:P||A?(0,l.jsx)(s.Spin,{size:`small`}):null,options:M,className:`mail-popup__job-input`})]}):null})})})}var{Text:xD}=s.Typography,SD=2,CD=`overview.summary.role summary.job summary.role overview.job description.description.about the role.about the job.job title.role.responsibilities.roles responsibilities.roles and responsibilities.roles & responsibilities.key responsibilities.requirements.required skills.preferred skills.technical skills.key skills.skills.competencies.nice to have.good to have.qualifications.required qualifications.preferred qualifications.education.experience.benefits`.split(`.`),wD=new Set(CD),TD=/(education|qualification)/i,ED=/(skill|competenc)/i,DD=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),OD=e=>e.replace(/\w[^\s/]*/g,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()),kD=e=>[...new Set(e)];function AD(e){let t=String(e);return t=t.replace(/<\s*(br|\/p|\/div|\/h[1-6]|\/li|\/tr)\s*\/?>/gi,`
18
18
  `).replace(/<\s*li[^>]*>/gi,`
19
19
  `).replace(/<[^>]+>/g,` `),t=t.replace(/&nbsp;/gi,` `).replace(/&amp;/gi,`&`).replace(/&lt;/gi,`<`).replace(/&gt;/gi,`>`).replace(/&#39;|&apos;/gi,`'`).replace(/&quot;/gi,`"`),t.replace(/[ \t\f\v]+/g,` `).replace(/\n{2,}/g,`
20
- `).trim()}function AD(e){return e.replace(/•/g,`
21
- `).split(/\n+/).map(e=>e.trim().replace(/^[-–—•]\s*/,``).trim()).filter(Boolean)}function jD(e){return AD(e.replace(/(?:^|\s)[-–—]\s+/g,`
22
- `))}function MD(e){let t=e.match(/^([A-Za-z][A-Za-z&/ ]{1,28}?)\s*:\s*(\S.+)$/);if(!t)return null;let n=t[1].trim(),r=t[2].trim();return n.split(/\s+/).length>3||r.length>60?null:{fieldKey:n.toLowerCase().replace(/\s+/g,`-`),fieldLabel:DD(n),value:r}}function ND(e){let t=e.toLowerCase().replace(/[\s:.\-–—]+$/,``).trim();return CD.has(t)?wD.test(t)?`education`:TD.test(t)?`keySkills`:`overview`:null}function PD(e){let t=[],n={overview:[],keySkills:[],education:[]},r=`overview`;return e.forEach(e=>{let i=ND(e);if(i){r=i;return}if(r===`overview`){let n=MD(e);if(n){t.push(n);return}}n[r].push(e)}),{meta:t,overview:OD(n.overview),keySkills:OD(n.keySkills),education:OD(n.education)}}function FD(e){let t=[...SD].sort((e,t)=>t.length-e.length),n=RegExp(`\\b(${t.map(ED).join(`|`)})\\b\\s*:?`,`gi`),r=[...e.matchAll(n)];if(!r.length)return{meta:[],overview:OD(jD(e)),keySkills:[],education:[]};let i={overview:[],keySkills:[],education:[]},a=e.slice(0,r[0].index).trim();return a&&i.overview.push(...jD(a)),r.forEach((t,n)=>{let a=t[1].trim().toLowerCase(),o=t.index+t[0].length,s=n+1<r.length?r[n+1].index:e.length,c=jD(e.slice(o,s).trim());if(!c.length)return;let l=wD.test(a)?`education`:TD.test(a)?`keySkills`:`overview`;i[l].push(...c)}),{meta:[],overview:OD(i.overview),keySkills:OD(i.keySkills),education:OD(i.education)}}function ID(e){let t=kD(e);if(!t)return{meta:[],overview:[],keySkills:[],education:[]};let n=AD(t);return n.length>=4?PD(n):FD(t)}function LD({items:e}){return(0,l.jsx)(`ul`,{className:`jdv-ats-bullets`,children:e.map((e,t)=>(0,l.jsx)(`li`,{className:`jdv-ats-bullet-item`,children:e},t))})}function RD({raw:e=``,meta:t=[]}){let[n,r]=(0,o.useState)(!1),i=(0,o.useMemo)(()=>ID(e),[e]),a=t.length?t:i.meta,s=[];if(i.overview.length&&s.push({key:`overview`,title:`Overview`,items:i.overview}),i.keySkills.length&&s.push({key:`keySkills`,title:`Key Skills`,items:i.keySkills,card:!0,icon:`🛠️`}),i.education.length&&s.push({key:`education`,title:`Education`,items:i.education,card:!0,icon:`🎓`}),!a.length&&!s.length)return(0,l.jsx)(bD,{type:`secondary`,children:`No description available.`});let c=n?s:s.slice(0,xD),u=s.length-xD;return(0,l.jsxs)(`div`,{className:`jdv-ats-desc`,children:[a.length>0&&(0,l.jsx)(`div`,{className:`jdv-ats-meta-grid`,children:a.map(({fieldKey:e,fieldLabel:t,value:n})=>(0,l.jsxs)(`div`,{className:`jdv-ats-meta-row`,children:[(0,l.jsx)(`span`,{className:`jdv-ats-meta-key`,children:t}),(0,l.jsx)(`span`,{className:`jdv-ats-meta-val`,children:n})]},e??t))}),(0,l.jsx)(`div`,{className:`jdv-ats-sections`,children:c.map(e=>e.card?(0,l.jsxs)(`div`,{className:`education-block`,children:[(0,l.jsxs)(`div`,{className:`education-header`,children:[(0,l.jsx)(`span`,{children:e.icon}),(0,l.jsx)(`span`,{children:e.title})]}),(0,l.jsx)(`ul`,{className:`education-list`,children:e.items.map((e,t)=>(0,l.jsx)(`li`,{className:`education-list-item`,children:e},t))})]},e.key):(0,l.jsxs)(`div`,{className:`jdv-ats-section`,children:[(0,l.jsx)(`div`,{className:`jdv-ats-section-hd`,children:(0,l.jsx)(`span`,{children:e.title})}),(0,l.jsx)(LD,{items:e.items})]},e.key))}),u>0&&(0,l.jsx)(`span`,{className:`jdv-desc-toggle`,onClick:()=>r(e=>!e),children:n?`Show less`:`Show more (${u} more section${u>1?`s`:``})`})]})}var{Text:zD}=s.Typography;function BD(e){return e?e.trim().split(/\s+/).slice(0,2).map(e=>e[0].toUpperCase()).join(``):`?`}function VD(e){return e?e.name?e.name:e.fullName?e.fullName:e.firstName||e.lastName?[e.firstName,e.lastName].filter(Boolean).join(` `):e.candidateName??e.clientName??e.jobTitle??``:``}function HD(e){return e?e.email??e.emailId??e.emailAddress??``:``}function UD(e){return e?e.status?e.status:e.stage?e.stage:typeof e.isActive==`boolean`?e.isActive?`Active`:`Inactive`:``:``}function WD(e){return e==null||e===``?`-`:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?e.join(`, `):typeof e==`object`?e.label??e.name??Object.values(e).join(` `):String(e)}var GD=[`jobDescription`,`description`,`rawDescription`,`jobDescriptionText`];function KD(e){return String(e??``).toLowerCase()===`job`}function qD(e){let t=GD.includes(e.field),n=/description/i.test(e.label??``);return t||n}function JD({record:e}){let t=VD(e),n=HD(e),r=UD(e);return!t&&!n?null:(0,l.jsxs)(`div`,{className:`preview-profile-card`,children:[(0,l.jsxs)(`div`,{className:`preview-profile-card__info`,children:[(0,l.jsx)(s.Avatar,{className:`preview-profile-card__avatar`,children:BD(t)}),(0,l.jsxs)(`div`,{className:`preview-profile-card__text`,children:[t&&(0,l.jsx)(`span`,{className:`preview-profile-card__name`,children:t}),n&&(0,l.jsx)(`span`,{className:`preview-profile-card__email`,children:n})]})]}),r&&(0,l.jsx)(s.Tag,{className:`preview-profile-card__status`,children:r})]})}function YD({fields:e,moduleName:t,centralDocuments:r=[]}){let[i,a]=(0,o.useState)([]),[s,c]=(0,o.useState)(0),[u,d]=(0,o.useState)(!1);if(!e?.length)return null;function f(e){let t=String(e?.type??``).trim().toLowerCase(),n=`${e?.field??``} ${e?.label??``}`;return[`file`,`document`,`upload`].includes(t)||/resume|cv|document|attachment/i.test(n)}function p(e,t){a(e),c(t),d(!0)}return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`preview-field-grid`,children:e.map(e=>{let i=e.value,a=Array.isArray(i)&&i.length>0,o=KD(t)&&qD(e)&&typeof i==`string`&&i.trim(),s=f(e)?r.filter(t=>{let n=String(t?.fieldName??t?.field??t?.formField??t?.key??``).trim().toLowerCase(),r=String(e?.field??``).trim().toLowerCase();if(n&&r&&n===r)return!0;let i=`${e?.field??``} ${e?.label??``}`;return/resume|cv/i.test(i)?/resume|cv/i.test(`${n} ${t?.fileName??``} ${t?.name??``}`):!1}).map(t=>({name:t?.fileName||t?.name||t?.uploadedFileName||t?.originalName||e?.label||`Document`,url:t?.fileUrl||t?.downloadUrl||t?.signedUrl||t?.url||``,type:t?.mimeType||t?.contentType||t?.type})).filter(e=>e.url):[],c=f(e)?s.length?s:n.Bt(i).filter(e=>e.url):[];return c.length?(0,l.jsxs)(`div`,{className:`preview-field-card preview-field-card--documents`,children:[(0,l.jsx)(`span`,{className:`preview-field-card__label`,children:e.label}),(0,l.jsx)(`div`,{className:`preview-document-list`,children:c.map((e,t)=>(0,l.jsxs)(`button`,{type:`button`,className:`preview-document-link`,onClick:()=>p(c,t),title:`Preview ${e.name||`document`}`,children:[(0,l.jsx)(`span`,{className:`preview-document-link__icon`,"aria-hidden":`true`,children:`▣`}),(0,l.jsx)(`span`,{className:`preview-document-link__name`,children:e.name||`Document ${t+1}`}),(0,l.jsx)(`span`,{className:`preview-document-link__action`,children:`Preview`})]},`${e.url}-${t}`))})]},e.field??e.label):a?i.map((t,n)=>(0,l.jsxs)(`div`,{className:`preview-field-card`,children:[(0,l.jsxs)(`span`,{className:`preview-field-card__label`,children:[e.label,i.length>1?` (${n+1})`:``]}),(0,l.jsx)(`span`,{className:`preview-field-card__value`,children:WD(t)})]},`${e.field??e.label}-${n}`)):o?(0,l.jsxs)(`div`,{className:`preview-field-card preview-field-card--description`,children:[(0,l.jsx)(`span`,{className:`preview-field-card__label`,children:e.label}),(0,l.jsx)(`div`,{className:`preview-field-card__description`,children:(0,l.jsx)(RD,{raw:i})})]},e.field??e.label):(0,l.jsxs)(`div`,{className:`preview-field-card`,children:[(0,l.jsx)(`span`,{className:`preview-field-card__label`,children:e.label}),(0,l.jsx)(`span`,{className:`preview-field-card__value`,children:WD(i)})]},e.field??e.label)})}),(0,l.jsx)(n.En,{documents:i,open:u,onClose:()=>d(!1),initialIndex:s})]})}function XD(){let e=(0,d.useNavigate)(),{moduleName:t=``,record:r=null}=(0,d.useLocation)().state??{},i=r?.id??r?._id,[c,u]=(0,o.useState)([]),[f,p]=(0,o.useState)(!!(t&&i)),[m,h]=(0,o.useState)(null),[g,_]=(0,o.useState)([]),[v,y]=(0,o.useState)(0),b=(0,o.useRef)(null),x=(0,o.useRef)(null),S=(0,o.useRef)([]),C=(0,o.useRef)([]);(0,o.useEffect)(()=>{if(!t||!i)return;let e=!1;return Promise.all([a.r({module:t,id:i}),n.yn(t,i).catch(()=>({data:[]}))]).then(([t,n])=>{e||(u(Array.isArray(t)?t:[]),_(Array.isArray(n)?n:n?.data??[]),p(!1))}).catch(t=>{e||(h(t.message||`Failed to load preview`),_([]),p(!1))}),()=>{e=!0}},[t,i]);function w(){e(-1)}function T(e,t){return e?.label??e?.name??`Section ${t+1}`}function E(e){let t=b.current,n=C.current[e];if(!t||!n)return;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=(t.querySelector(`.preview-stepper-wrap`)?.offsetHeight??0)+12,o=t.scrollTop+i.top-r.top-a;y(e),t.scrollTo({top:Math.max(0,o),behavior:`smooth`})}function D(){let e=b.current;if(!e||!C.current.length)return;let t=e.getBoundingClientRect().top+(e.querySelector(`.preview-stepper-wrap`)?.offsetHeight??0)+24,n=0;C.current.forEach((e,r)=>{e&&e.getBoundingClientRect().top<=t&&(n=r)}),y(e=>e===n?e:n)}(0,o.useEffect)(()=>{let e=x.current,t=S.current[v];if(!e||!t)return;let n=t.offsetLeft-(e.clientWidth-t.offsetWidth)/2,r=Math.max(0,e.scrollWidth-e.clientWidth);e.scrollTo({left:Math.min(Math.max(0,n),r),behavior:`smooth`})},[v,c.length]);function O(){return c.length?(0,l.jsx)(`div`,{ref:x,className:`preview-stepper-wrap`,"aria-label":`Preview sections`,children:(0,l.jsx)(`div`,{className:`preview-stepper`,children:c.map((e,t)=>(0,l.jsxs)(`div`,{className:`preview-stepper__segment`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`preview-stepper__item`,ref:e=>{S.current[t]=e},onClick:()=>E(t),"aria-current":v===t?`step`:void 0,title:`Go to ${T(e,t)}`,children:[(0,l.jsx)(`span`,{className:[`preview-stepper__circle`,t<v?`preview-stepper__circle--done`:``,t===v?`preview-stepper__circle--active`:``].filter(Boolean).join(` `),children:t+1}),(0,l.jsx)(`span`,{className:[`preview-stepper__label`,t===v?`preview-stepper__label--active`:``].filter(Boolean).join(` `),children:T(e,t)})]}),t<c.length-1&&(0,l.jsx)(`span`,{className:[`preview-stepper__line`,t<v?`preview-stepper__line--done`:``].filter(Boolean).join(` `),"aria-hidden":`true`})]},e.name??e.id??t))})}):null}let k=(0,l.jsxs)(`div`,{className:`preview-modal-header`,children:[(0,l.jsx)(`span`,{className:`preview-modal-module`,children:t.toUpperCase()}),(0,l.jsx)(`span`,{className:`preview-modal-title`,children:t?` Details`:`Preview`})]}),A=(0,l.jsx)(`div`,{className:`wizard-footer preview-scroll-footer`,children:(0,l.jsx)(`div`,{className:`wizard-footer-nav`,children:(0,l.jsx)(s.Button,{onClick:w,children:`Close`})})});function j(){return!t||!i?(0,l.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:`Preview id is missing.`}):f?(0,l.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:(0,l.jsx)(s.Spin,{size:`small`})}):m?(0,l.jsx)(`div`,{className:`job-preview-content job-preview-status job-preview-error`,children:m}):c.length?(0,l.jsx)(`div`,{className:`preview-section-list`,children:c.map((e,n)=>(0,l.jsxs)(`section`,{ref:e=>{C.current[n]=e},className:`preview-section-card`,"data-section-index":n,children:[(0,l.jsxs)(`div`,{className:`preview-section-card__header`,children:[(0,l.jsx)(`span`,{className:`preview-section-card__number`,children:n+1}),(0,l.jsx)(`span`,{className:`preview-section-card__title`,children:T(e,n)})]}),(0,l.jsx)(`div`,{className:`preview-section-card__body`,children:e.fields?.length>0?(0,l.jsx)(YD,{fields:e.fields,moduleName:t,centralDocuments:g}):(0,l.jsx)(zD,{type:`secondary`,children:`No fields in this group.`})})]},e.name??e.id??n))}):(0,l.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:`No form groups found.`})}return(0,l.jsx)(s.Modal,{centered:!0,className:`wizard-modal preview-modal preview-scroll-modal`,footer:A,open:!0,title:k,width:`min(900px, calc(100vw - 32px))`,onCancel:w,maskClosable:!1,children:(0,l.jsxs)(`div`,{ref:b,className:`wizard-body preview-scroll-body`,onScroll:D,children:[!f&&!m&&c.length>0&&O(),r&&(0,l.jsx)(JD,{record:r}),j()]})})}var{Text:ZD}=s.Typography,{TextArea:QD}=s.Input,$D=[{key:`basic`,title:`Basic Info`,description:`General details`,fields:[{name:`firstName`,label:`First Name`,type:`input`,required:!0,placeholder:`Enter first name`,span:12},{name:`lastName`,label:`Last Name`,type:`input`,required:!0,placeholder:`Enter last name`,span:12},{name:`email`,label:`Email Address`,type:`input`,required:!0,placeholder:`Enter email address`,rules:[{type:`email`,message:`Please enter a valid email`}]},{name:`phone`,label:`Phone`,type:`input`,placeholder:`Enter phone number`}]},{key:`details`,title:`Details`,description:`Additional info`,fields:[{name:`role`,label:`Role`,type:`select`,required:!0,placeholder:`Select a role`,span:12,options:[{label:`Developer`,value:`developer`},{label:`Designer`,value:`designer`},{label:`Manager`,value:`manager`},{label:`Analyst`,value:`analyst`}]},{name:`department`,label:`Department`,type:`select`,placeholder:`Select department`,span:12,options:[{label:`Engineering`,value:`engineering`},{label:`Product`,value:`product`},{label:`Operations`,value:`operations`},{label:`Finance`,value:`finance`}]},{name:`notes`,label:`Notes`,type:`textarea`,placeholder:`Any additional notes...`}]},{key:`confirm`,title:`Confirm`,description:`Review & submit`,isReview:!0}];function eO(e){switch(e.type){case`select`:return(0,l.jsx)(s.Select,{placeholder:e.placeholder,options:e.options,style:{width:`100%`}});case`textarea`:return(0,l.jsx)(QD,{rows:3,placeholder:e.placeholder});case`number`:return(0,l.jsx)(s.InputNumber,{placeholder:e.placeholder,style:{width:`100%`}});default:return(0,l.jsx)(s.Input,{type:e.inputType||`text`,placeholder:e.placeholder})}}function tO({steps:e,form:t}){let n=t.getFieldsValue(),r=e.filter(e=>!e.isReview);return r.some(e=>(e.fields||[]).some(e=>n[e.name]!==void 0&&n[e.name]!==``))?(0,l.jsxs)(`div`,{className:`wizard-review-content`,children:[r.map(e=>(0,l.jsxs)(`div`,{className:`wizard-review-section`,children:[(0,l.jsx)(ZD,{className:`wizard-review-section-title`,children:e.title}),(0,l.jsx)(`div`,{className:`wizard-review-grid`,children:(e.fields||[]).map(e=>{let t=n[e.name],r=t===void 0||t===``||t===null?`—`:String(t);return(0,l.jsxs)(`div`,{className:`wizard-review-row`,children:[(0,l.jsx)(`span`,{className:`wizard-review-label`,children:e.label}),(0,l.jsx)(`span`,{className:`wizard-review-separator`,children:`:`}),(0,l.jsx)(`span`,{className:`wizard-review-value`,children:r})]},e.name)})})]},e.key)),(0,l.jsxs)(`div`,{className:`wizard-review-confirm-note`,children:[(0,l.jsx)(c.CheckCircleOutlined,{className:`wizard-review-confirm-icon`}),(0,l.jsx)(ZD,{type:`secondary`,children:`Please review the information above before submitting.`})]})]}):(0,l.jsx)(`div`,{className:`wizard-review-empty`,children:(0,l.jsx)(ZD,{type:`secondary`,children:`No data entered yet.`})})}function nO(){let[e]=s.Form.useForm(),t=(0,d.useNavigate)(),{title:n=`Wizard`,moduleName:r=``,steps:i=$D,onSubmit:a}=(0,d.useLocation)().state??{},[c,u]=(0,o.useState)(0),f=i[c],p=c===i.length-1,m=c===0;function h(){t(-1)}function g(){let t=(f.fields||[]).map(e=>e.name);e.validateFields(t.length>0?t:void 0).then(()=>{u(e=>e+1)})}function _(){u(e=>e-1)}function v(){let n=e.getFieldsValue();typeof a==`function`&&a(n),t(-1)}let y=i.map((e,t)=>({title:e.title,description:e.description,status:t<c?`finish`:t===c?`process`:`wait`})),b=r?`${n} — ${r}`:n;return(0,l.jsxs)(s.Modal,{open:!0,title:b,footer:(0,l.jsxs)(`div`,{className:`wizard-footer`,children:[(0,l.jsx)(s.Button,{onClick:h,children:`Cancel`}),(0,l.jsxs)(`div`,{className:`wizard-footer-nav`,children:[!m&&(0,l.jsx)(s.Button,{onClick:_,children:`Back`}),p?(0,l.jsx)(s.Button,{type:`primary`,onClick:v,children:`Submit`}):(0,l.jsx)(s.Button,{type:`primary`,onClick:g,children:`Next`})]})]}),onCancel:h,width:`min(680px, calc(100vw - 32px))`,centered:!0,className:`wizard-modal`,children:[(0,l.jsx)(`div`,{className:`wizard-steps-container`,children:(0,l.jsx)(s.Steps,{current:c,items:y,size:`small`,className:`wizard-steps`})}),(0,l.jsx)(`div`,{className:`wizard-body`,children:(0,l.jsxs)(s.Form,{form:e,layout:`vertical`,children:[i.filter(e=>!e.isReview).map((e,t)=>(0,l.jsx)(`div`,{style:{display:t===c?`block`:`none`},children:(0,l.jsx)(s.Row,{gutter:16,children:(e.fields||[]).map(e=>(0,l.jsx)(s.Col,{span:e.span||24,children:(0,l.jsx)(s.Form.Item,{name:e.name,label:e.label,rules:[...e.required?[{required:!0,message:`${e.label} is required`}]:[],...e.rules||[]],children:eO(e)})},e.name))})},e.key)),f.isReview&&(0,l.jsx)(tO,{steps:i,form:e})]})})]})}function rO({titleText:e,titleIcon:t}){let n=t===`delete`;return(0,l.jsxs)(`span`,{className:`dynamic-popup__header`,children:[(0,l.jsx)(`span`,{className:`dynamic-popup__header-icon-box${n?` dynamic-popup__header-icon-box--danger`:``}`,children:n?(0,l.jsx)(c.DeleteOutlined,{}):(0,l.jsx)(c.AppstoreOutlined,{})}),(0,l.jsx)(`span`,{className:`dynamic-popup__header-label`,children:e})]})}function iO({note:e,description:t,showSelectedCount:r,count:i,itemLabel:a,bodyText:o,deleteError:s}){return(0,l.jsxs)(l.Fragment,{children:[e&&(0,l.jsx)(n.On,{variant:`body`,color:`secondary`,className:`dynamic-popup__note`,children:e}),t&&(0,l.jsx)(n.On,{variant:`body`,className:`dynamic-popup__description`,children:t}),r&&i>0&&(0,l.jsxs)(n.On,{variant:`body`,className:`dynamic-popup__selected-count`,children:[`Changing status for `,(0,l.jsx)(`strong`,{children:i}),` selected `,a,`.`]}),o&&(0,l.jsx)(n.On,{variant:`body`,children:o}),s&&(0,l.jsx)(n.On,{variant:`caption`,color:`danger`,className:`dynamic-popup__error`,children:s})]})}function aO({footerNote:e}){return e?(0,l.jsx)(n.On,{variant:`caption`,color:`secondary`,className:`dynamic-popup__footer-note`,children:e}):null}function oO(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t?.[n]??``).trim()}function sO(e){return String(e).replace(/\(\s*\)/g,``).replace(/\s+/g,` `).replace(/(^|\s)([-–—·|])(?=\s*\2)/g,``).replace(/^[\s\-–—·|]+/,``).replace(/[\s\-–—·|]+$/,``).trim()}function cO(e){if(!e)return!1;let t=new Date(e).getTime();return Number.isNaN(t)||t<=0?!1:t<=Date.now()+864e5}function lO(e){if(!cO(e))return``;let t=new Date(e),n=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date,i=Math.round((n(r)-n(t))/864e5);if(i<=0)return`Today`;if(i===1)return`Yesterday`;if(i<=30)return`${i} days ago`;let a=(r.getFullYear()-t.getFullYear())*12+(r.getMonth()-t.getMonth());if(r.getDate()<t.getDate()&&--a,a=Math.max(1,a),a<12)return`${a} month${a===1?``:`s`} ago`;let o=Math.floor(a/12);return`${o} year${o===1?``:`s`} ago`}function uO(e){let t=Array.isArray(e?.submissionHistory)?e.submissionHistory:[],n=[e?.lastSubmittedAt,e?.submittedAt,e?.updatedAt,...t.map(e=>e?.submittedAt||e?.updatedAt)].filter(Boolean);return n.length?n.reduce((e,t)=>new Date(t)>new Date(e)?t:e):null}function dO(e){let t=Array.isArray(e?.submissionHistory)?e.submissionHistory:[],n=[e?.lastSubmittedAt,e?.submittedAt,...t.map(e=>e?.submittedAt)].filter(Boolean);return n.length?n.reduce((e,t)=>new Date(t)>new Date(e)?t:e):null}function fO(e,t){if(typeof e==`string`)return{label:e,value:e};if(e?.label!==void 0&&e?.value!==void 0&&!t?.labelTemplate&&!t?.valueKey)return e;let{labelKey:n,valueKey:r,labelTemplate:i}=t??{},a=i?.includes(`{lastdate}`)?{...e,lastdate:lO(uO(e))}:e,o=(i?sO(oO(i,a)):null)||(n?e?.[n]:null)||e?.name||e?.fullName||e?.candidateName||e?.title||e?.displayName||e?.text||e?.applicantReferenceId||e?.applicantRefrenceId||String(Object.values(e||{})[0]??``),s=(r?e?.[r]:null)??e?.id??e?._id??e?.applicantReferenceId??e?.applicantRefrenceId??String(Object.values(e||{})[0]??``),c=e?.disabled===!0||e?.disable===!0,l=String(e?.optionNote??``).trim(),u={label:l?`${String(o)} — ${l}`:String(o),value:String(s),_raw:e};if(c&&(u.disabled=!0),l&&(u.title=l),e?.isSubmitted===!0||e?.alreadySubmitted===!0){u.alreadySubmitted=!0,u.existingSubmissionId=String(e?.existingSubmissionId??e?.jobSubmissionId??e?.submissionId??``);let t=e?.submittedAt||dO(e);t&&(u.submittedAt=t)}if(e?.isFromSubmission===!0&&e?.submissionId){u.isFromSubmission=!0,u.priorSubmissionId=String(e.submissionId);let t=e?.lastSubmittedAt||dO(e);t&&(u.priorSubmittedAt=t)}return u}function pO(e,t){return(t?.[e.optionsKey]??e.defaultOptions??[]).map(t=>fO(t,e))}function mO(e={}){return{selectedIds:[],selectedRecords:[],moduleName:``,removedIds:[],...e}}var hO=`DD MMM YYYY`,gO=`DD MMM YYYY, h:mm A`;function _O(e,t){if(e==null||e===``)return``;let n=(0,u.default)(e);return n.isValid()?t===`relative`?lO(e)||(cO(e)?n.format(hO):`Not updated`):cO(e)?n.format(hO):``:String(e)}function vO(e,t){return e?String(e).includes(`{`)?sO(oO(e,t)):String(t?.[e]??e).trim():``}function yO(e){if(e?.alreadySubmitted){let t=e?.submittedAt?(0,u.default)(e.submittedAt):null;return{tone:`blocked`,tooltip:t?.isValid()?`Already submitted to this job on ${t.format(gO)}`:`Already submitted to this job — a candidate can only be submitted once per job`}}if(e?.isFromSubmission){let t=e?.priorSubmittedAt?(0,u.default)(e.priorSubmittedAt):null;return{tone:`history`,tooltip:t?.isValid()?`Previously submitted on ${t.format(gO)} — this form will prefill from it`:`Submitted to another job before — this form will prefill from it`}}return null}function bO(e,t){return e?.alreadySubmitted||!e?.disabled?``:String(t?.message??e?.title??``).trim()}function xO({meta:e}){return(0,l.jsx)(`div`,{className:`dynamic-popup__option-dates`,children:e.map(e=>(0,l.jsxs)(o.Fragment,{children:[(0,l.jsx)(`span`,{className:`dynamic-popup__option-date-label`,children:e.label}),(0,l.jsx)(`span`,{className:`dynamic-popup__option-date-value`,children:e.text})]},e.label))})}function SO({option:e,layout:t}){let n=e?._raw??e??{},r=vO(t.id,n),i=vO(t.title,n)||String(e?.label??``),a=vO(t.subtitle,n),o=vO(t.titleAccent?.key,n),u=vO(t.titleAccent?.toneKey,n),d=t.titleAccent?.prefix??``,f=(t.meta??[]).map(e=>({label:e.label,text:_O(n?.[e.key],e.type)})).filter(e=>e.text),p=bO(e,n),m=yO(e);return(0,l.jsxs)(`div`,{className:`dynamic-popup__option`,children:[(0,l.jsx)(`span`,{className:`dynamic-popup__option-tick${m?` dynamic-popup__option-tick--${m.tone}`:``}`,children:m&&(0,l.jsx)(s.Tooltip,{title:m.tooltip,placement:`topLeft`,children:(0,l.jsx)(c.CheckCircleFilled,{"aria-label":m.tooltip})})}),(0,l.jsxs)(`div`,{className:`dynamic-popup__option-main`,children:[(0,l.jsxs)(`div`,{className:`dynamic-popup__option-head`,children:[r&&(0,l.jsx)(`span`,{className:`dynamic-popup__option-id`,children:r}),(0,l.jsxs)(`span`,{className:`dynamic-popup__option-title`,children:[(0,l.jsx)(`span`,{className:`dynamic-popup__option-title-text`,children:i}),o&&(0,l.jsx)(`span`,{className:`dynamic-popup__option-title-accent${u?` dynamic-popup__option-title-accent--${u}`:``}`,children:`${d}${o}`})]}),p&&(0,l.jsx)(`span`,{className:`dynamic-popup__option-flag`,children:p})]}),a&&(0,l.jsx)(`div`,{className:`dynamic-popup__option-sub`,children:a})]}),e?.alreadySubmitted?(0,l.jsx)(`span`,{className:`dynamic-popup__option-onjob`,children:`On this job`}):f.length>0&&(0,l.jsx)(xO,{meta:f})]})}var{Text:CO}=s.Typography,{TextArea:wO}=s.Input,TO=[{label:`$`,value:`$`},{label:`EUR`,value:`EUR`},{label:`GBP`,value:`GBP`},{label:`INR`,value:`INR`}],EO=[{label:`Hourly`,value:`Hourly`},{label:`Daily`,value:`Daily`},{label:`Weekly`,value:`Weekly`},{label:`Monthly`,value:`Monthly`},{label:`Yearly`,value:`Yearly`}];function DO(e=[]){return e.map(e=>{if(!e||typeof e!=`object`)return e;let t=[e.value,e.user_id,e.userId,e.USER_ID,e.legacyUserId,e.id,e._id].find(e=>e!=null&&String(e).trim()!==``),n=t==null?``:String(t).trim();return{...e,value:n}}).filter(e=>typeof e!=`object`||!e||String(e.value??``).trim()!==``)}function OO({field:e,value:t,onChange:n}){return(0,l.jsx)(s.Input,{value:t,onChange:n,placeholder:e.placeholder,maxLength:e.maxLength,prefix:(0,l.jsx)(c.CrownOutlined,{})})}function kO({field:e,value:t,onChange:n}){return(0,l.jsx)(wO,{value:t,onChange:n,rows:e.rows??5,placeholder:e.placeholder})}function AO({field:e,options:t,value:n,onChange:r}){let i=DO(t);return(0,l.jsx)(s.Select,{showSearch:!0,value:n,onChange:r,options:i,placeholder:e.placeholder,className:`dynamic-popup__field-select`,optionFilterProp:`label`,prefix:(0,l.jsx)(c.CrownOutlined,{})})}function jO({field:e,options:t,value:n,onChange:r}){let i=DO(t);return(0,l.jsx)(s.Select,{mode:`multiple`,showSearch:!0,value:n,onChange:r,options:i,placeholder:e.placeholder,className:`dynamic-popup__field-select`,optionFilterProp:`label`,prefix:(0,l.jsx)(c.CrownOutlined,{})})}function MO({field:e,options:t,onSearch:n,value:r,onChange:i,popupContext:a}){let o=DO(t),u=e.optionLayout,d=new Map(o.map(e=>[String(e?.value??``),e]));async function f(t,n){if(e.multiple){i?.(Array.isArray(t)?t:[]);return}let r=n??d.get(String(t??``));(typeof e.onSelectGuard!=`function`||await e.onSelectGuard({value:t,option:r,field:e,popupContext:a,confirm:s.Modal.confirm})!==!1)&&i?.(t)}return(0,l.jsx)(s.Select,{mode:e.multiple?`multiple`:void 0,showSearch:!0,filterOption:!1,notFoundContent:e.notFoundContent??null,value:r,onChange:f,options:o,placeholder:e.placeholder,onSearch:n,className:`dynamic-popup__field-select${u?` dynamic-popup__field-select--rich`:``}`,popupClassName:u?`dynamic-popup__option-dropdown`:void 0,listHeight:u?340:void 0,optionLabelProp:`label`,optionRender:u?e=>(0,l.jsx)(SO,{option:e?.data??e,layout:u}):void 0,prefix:(0,l.jsx)(c.CrownOutlined,{})})}function NO({field:e,mentionOpts:t,onMentionSearch:n,value:r,onChange:i}){let a=Number(e.maxLength)>0?Number(e.maxLength):void 0,o=String(r??``).length;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.Mentions,{value:r,onChange:i,rows:e.rows??5,placeholder:e.placeholder,prefix:`@`,options:t,onSearch:n,maxLength:a,className:`dynamic-popup__mention-textarea`}),a?(0,l.jsxs)(`div`,{className:`dynamic-popup__char-count`,style:{textAlign:`right`,fontSize:12,marginTop:4,color:o>a*.9?`#b45309`:`#8c8c8c`},children:[o,` / `,a]}):null]})}function PO({field:e={},value:t={},onChange:n}){let r=t.period??`Hourly`,i=t.isRange??!1;function a(e){n?.({...t,...e})}(0,o.useEffect)(()=>{let e={};t.currency??(e.currency=`$`),t.period??(e.period=`Hourly`),Object.keys(e).length&&n?.({...t,...e})},[]);let c=Number(i?t.maxAmount:t.amount),u=i&&t.minAmount!=null&&t.maxAmount!=null&&Number(t.maxAmount)<=Number(t.minAmount),d=e.rateCeiling!=null&&Number.isFinite(c)&&c>Number(e.rateCeiling);return(0,l.jsxs)(`div`,{children:[(0,l.jsxs)(s.Space.Compact,{style:{width:`100%`},children:[i?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.InputNumber,{controls:!1,placeholder:`From`,value:t.minAmount,onChange:e=>a({minAmount:e}),style:{flex:1}}),(0,l.jsx)(s.InputNumber,{controls:!1,placeholder:`To`,value:t.maxAmount,onChange:e=>a({maxAmount:e}),style:{flex:1}})]}):(0,l.jsx)(s.InputNumber,{controls:!1,placeholder:`0`,value:t.amount,onChange:e=>a({amount:e}),style:{flex:2}}),(0,l.jsx)(s.Select,{value:t.currency??`$`,options:TO,onChange:e=>a({currency:e}),style:{width:80}}),(0,l.jsx)(s.Select,{value:r,options:EO,onChange:e=>a({period:e}),style:{width:110}})]}),(u||d)&&(0,l.jsxs)(`div`,{style:{marginTop:4},children:[u&&(0,l.jsx)(CO,{type:`danger`,style:{fontSize:12,display:`block`},children:`To rate must be greater than From rate.`}),d&&(0,l.jsxs)(CO,{type:`danger`,style:{fontSize:12,display:`block`},children:[`Rate must not exceed the client rate (`,e.rateCeiling,`).`]})]}),(0,l.jsxs)(s.Space,{size:`small`,style:{marginTop:8},children:[(0,l.jsx)(s.Switch,{checked:i,onChange:e=>a({isRange:e})}),(0,l.jsx)(`span`,{children:`Range`})]})]})}function FO({field:e,value:t,onChange:n}){return(0,l.jsx)(s.DatePicker,{value:t,onChange:n,placeholder:e.placeholder??`Select date`,style:{width:`100%`},format:`YYYY-MM-DD`})}function IO({field:e,checked:t,onChange:n}){return(0,l.jsx)(s.Checkbox,{checked:t,onChange:n,children:e.checkboxLabel})}function LO({field:e,value:t,onChange:n}){return(0,l.jsx)(s.InputNumber,{value:t,onChange:n,min:e.min,max:e.max,placeholder:e.placeholder,style:{width:`100%`}})}function RO({options:e,value:t,onChange:n}){return(0,l.jsx)(s.Radio.Group,{value:t,onChange:n,options:e})}var zO={input:OO,text:OO,textarea:kO,select:AO,"multi-select":jO,"search-select":MO,"mention-textarea":NO,"candidate-rate":PO,"priority-checkbox":IO,"date-picker":FO,number:LO,radio:RO};function BO(e){return e===`priority-checkbox`?{valuePropName:`checked`}:{}}var VO=new Set([`input`,`text`,`textarea`,`mention-textarea`]);function HO({form:e,fields:t,initialValues:r,dynamicOptions:i,popupContext:a,extraData:o,removedIds:c,setRemovedIds:u,showAlreadyAssigned:d,onValuesChange:f,getSearchHandler:p,getMentionSearchHandler:m,mentionOptions:h}){let g=(o?.recruitersData??[]).filter(e=>{let t=String(e?.user_id??e?.id??e?.userId??``);return t&&!c.includes(t)}),_=d&&o,v=new Set(d?g.map(e=>String(e?.user_id??e?.id??e?.userId??``).trim()).filter(Boolean):[]),y=e=>v.size===0||!Array.isArray(e)?e:e.filter(e=>!v.has(String((e&&typeof e==`object`?e.value??e.id:e)??``).trim()));return!t.length&&!_?null:(0,l.jsxs)(l.Fragment,{children:[_&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`dynamic-popup__already-assigned`,children:[(0,l.jsx)(n.On,{variant:`caption`,color:`secondary`,children:`Already Assigned People`}),(0,l.jsx)(`div`,{style:{marginTop:6,display:`flex`,flexWrap:`wrap`,gap:6},children:g.length===0?(0,l.jsx)(n.On,{variant:`caption`,color:`secondary`,children:`No one is currently assigned to this job.`}):g.map(e=>{let t=String(e?.user_id??e?.id??e?.userId??``),n=e?.name??e?.user_name??e?.userName??e?.email??`Assigned user`;return(0,l.jsx)(s.Tag,{closable:!0,onClose:()=>{t&&u(e=>Array.from(new Set([...e,t])))},children:n},t||n)})})]}),(0,l.jsx)(s.Divider,{style:{margin:`12px 0`}})]}),t.length>0&&(0,l.jsx)(s.Form,{form:e,layout:`vertical`,initialValues:r,onValuesChange:(e,t)=>f(t),children:UO(t).map(e=>WO(e,e=>{let t=y(i[e.name]??pO(e,a)),r=p(e),o=m(e),c=h[e.name]??[],u=BO(e.type),d=zO[e.type],f=[];return e.required&&f.push({required:!0,message:`${e.label||`This field`} is required`}),typeof e.validator==`function`&&f.push({validator:(t,n)=>{let r=e.validator(n,a);return r?Promise.reject(Error(r)):Promise.resolve()}}),VO.has(e.type)&&f.push(n.cn({label:e.label,field:e.name,type:e.type})),(0,l.jsx)(s.Form.Item,{name:e.name,label:e.label,rules:f,...u,children:d?(0,l.jsx)(d,{field:e,options:t,onSearch:r,mentionOpts:c,onMentionSearch:o,popupContext:a}):null},e.name)}))})]})}function UO(e){let t=[];for(let n of e){let e=t[t.length-1];n.inlineRow&&e?.inlineRow===n.inlineRow?e.fields.push(n):t.push({inlineRow:n.inlineRow,fields:[n]})}return t.map(e=>e.fields)}function WO(e,t){return e.length===1?t(e[0]):(0,l.jsx)(`div`,{style:{display:`flex`,gap:8,alignItems:`flex-start`},children:e.map((e,n)=>(0,l.jsx)(`div`,{style:{flex:n===0?2:1,minWidth:0},children:t(e)},e.name))},`row-${e.map(e=>e.name).join(`-`)}`)}function GO(e){return[`select`,`multi-select`,`search-select`,`radio`].includes(e?.type)&&e?.dataSource===`master`&&e?.masterName}function KO(e){let t=e?.data??e;return Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.items)?t.items:Array.isArray(t?.rows)?t.rows:Array.isArray(t?.records)?t.records:[]}function qO(e){let t=String(e?.masterName??``).trim().toLowerCase();return t===`clientsubmissions`||t===`clientsubmissionstatus`}function JO(e){if(e==null)return null;if(typeof e==`string`){let t=e.trim();return t?{label:t,value:t,_raw:{name:t}}:null}let t=String(e?.name??e?.clientSubmissionStatusText??e?.label??e?.text??``).trim();if(!t)return null;let n=Number(e?.id??e?.uniqueId??e?.clientSubmissionStatusId??e?.value??0)||0;return{label:t,value:t,_raw:{...e,...n>0?{id:n,uniqueId:n}:{},name:t,type:String(e?.type??e?.clientSubmissionStatusType??``).trim(),isInitialStatus:e?.isInitialStatus===!0,isTerminalStatus:e?.isTerminalStatus===!0,allowedNextStatusIds:Array.isArray(e?.allowedNextStatusIds)?e.allowedNextStatusIds.map(Number).filter(e=>Number.isInteger(e)&&e>0):[]}}}function YO(e,t){return qO(t)?JO(e):fO(e,t)}function XO(e){let t=e?.clientSubmissionStatus,n=Number((t&&typeof t==`object`?t?.clientSubmissionStatusId??t?.id??t?.uniqueId:void 0)??e?.clientSubmissionStatusId??e?.clientStatusId??e?.[`clientSubmissionStatus.clientSubmissionStatusId`]??0)||0,r=t&&typeof t==`object`?t?.clientSubmissionStatusText??t?.name??t?.text??t?.label:t;return{id:n,text:String(r??e?.clientSubmissionStatusText??e?.clientStatus??e?.clientStatusText??e?.[`clientSubmissionStatus.clientSubmissionStatusText`]??``).trim()}}function ZO(e){let t=Number(e?.id??0)||0,n=String(e?.text??``).trim();return n&&n.toLowerCase()===`not submitted`?!0:t<=0&&!n}function QO(e){return Number(e?._raw?.id??e?._raw?.uniqueId??0)||0}function $O(e){let t=e?._raw?.allowedNextStatusIds;return Array.isArray(t)?t.map(Number).filter(e=>Number.isInteger(e)&&e>0):[]}function ek(e){let t=e?.data??e;return t?Array.isArray(t)?t[0]??null:t?.record&&typeof t.record==`object`?t.record:t?.data&&typeof t.data==`object`&&!Array.isArray(t.data)?t.data:typeof t==`object`?t:null:null}function tk(e){return(Array.isArray(e?.selectedRecords)?e.selectedRecords.filter(Boolean):[]).some(e=>!ZO(XO(e)))?!0:!ZO(XO(e??{}))}async function nk(e,n){if(tk(e))return e;let r=e?.selectedIds?.[0]??e?.selectedRecords?.[0]?._id??e?.selectedRecords?.[0]?.id;if(!r)return e;let i=String(e?.moduleName??`submissions`).trim()||`submissions`,a=new URLSearchParams({module:i,id:String(r)});n&&a.set(`app_id`,n);try{let r=ek(await t.o(t.x,`/module-data-detail?${a.toString()}`,{headers:n?{"X-App-Id":n}:void 0}));if(!r)return e;let i=Array.isArray(e?.selectedRecords)?e.selectedRecords:[];return{...e,selectedRecords:i.length?i.map((e,t)=>t===0?{...e,...r}:e):[r]}}catch(t){return console.warn(`[DynamicPopup] Could not load selected submission detail for client status transition:`,t),e}}function rk(e,t){if(!Array.isArray(e)||!e.length)return[];if(!e.some(e=>e?._raw?.isInitialStatus===!0||e?._raw?.isTerminalStatus===!0||Array.isArray(e?._raw?.allowedNextStatusIds)))return e;let n=Array.isArray(t?.selectedRecords)?t.selectedRecords.filter(Boolean):[],r={clientSubmissionStatus:t?.clientSubmissionStatus,clientSubmissionStatusId:t?.clientSubmissionStatusId,clientSubmissionStatusText:t?.clientSubmissionStatusText,clientStatus:t?.clientStatus,clientStatusId:t?.clientStatusId,clientStatusText:t?.clientStatusText,"clientSubmissionStatus.clientSubmissionStatusId":t?.[`clientSubmissionStatus.clientSubmissionStatusId`],"clientSubmissionStatus.clientSubmissionStatusText":t?.[`clientSubmissionStatus.clientSubmissionStatusText`]},i=n.length?n:[r];return e.filter(t=>i.every(n=>{let i=XO(n);if(ZO(i)){let e=XO(r);ZO(e)||(i=e)}if(ZO(i))return t?._raw?.isInitialStatus===!0;let a=e.find(e=>{let t=QO(e),n=String(e?.label??``).trim();return i.id>0&&t===i.id||i.text&&n.toLowerCase()===i.text.toLowerCase()});return!a||a?._raw?.isTerminalStatus===!0?!1:$O(a).includes(QO(t))}))}function ik({open:e,config:n,api:r,fields:i,popupContext:a,formValues:s}){let[c,l]=(0,o.useState)({}),[u,d]=(0,o.useState)(null);return(0,o.useEffect)(()=>{e||(l({}),d(null))},[e]),(0,o.useEffect)(()=>{if(!e||!n||!r.getOptions)return;let t=new AbortController;return i.forEach(e=>{!e.fetchOptionsKey||e.fetchOptionsParamKey||Promise.resolve(r.getOptions(e,void 0,a)).then(n=>{t.signal.aborted||l(t=>({...t,[e.name]:n}))}).catch(n=>{t.signal.aborted||console.error(`[DynamicPopup] Failed to load options for field "${e.name}":`,n)})}),()=>t.abort()},[e,r,n,i,a]),(0,o.useEffect)(()=>{if(!e||!n)return;let r=i.filter(GO);if(!r.length)return;let o=new AbortController;return r.forEach(e=>{let n=new URLSearchParams({masterName:e.masterName,offset:`0`,limit:String(e.limit??50)}),r=String(t.b??``).trim();r&&n.set(`app_id`,r),t.o(t.x,`/masters/dropdown?${n.toString()}`,{headers:r?{"X-App-Id":r}:void 0}).then(async t=>{if(o.signal.aborted)return;let n=KO(t).map(t=>YO(t,e)).filter(Boolean),i=a;if(qO(e)&&(i=await nk(a,r)),o.signal.aborted)return;let s=qO(e)?rk(n,i):n;l(t=>({...t,[e.name]:s}))}).catch(t=>{o.signal.aborted||console.error(`[DynamicPopup] Failed to load master options for field "${e.name}":`,t)})}),()=>o.abort()},[e,n,i,a]),(0,o.useEffect)(()=>{if(!e||!n||!r.getOptions)return;let t=i.filter(e=>e.fetchOptionsKey&&e.fetchOptionsParamKey);if(!t.length)return;let o=new AbortController;return t.forEach(e=>{let t=s[e.fetchOptionsParamKey]??a[e.fetchOptionsParamKey],n={[e.fetchOptionsParamKey]:t};Promise.resolve(r.getOptions(e,n,a)).then(t=>{o.signal.aborted||l(n=>({...n,[e.name]:t}))}).catch(t=>{o.signal.aborted||console.error(`[DynamicPopup] Failed to load param-dependent options for "${e.name}":`,t)})}),()=>o.abort()},[e,r,n,i,s,a]),(0,o.useEffect)(()=>{if(!e||!n||!r.loadExtraData)return;let t=new AbortController;return Promise.resolve(r.loadExtraData(a)).then(e=>{t.signal.aborted||d(e)}).catch(e=>{t.signal.aborted||(console.error(`[DynamicPopup] Failed to load extra data:`,e),d(null))}),()=>t.abort()},[e,r,n,a]),{dynamicOptions:c,setDynamicOptions:l,extraData:u}}var ak=500,ok=3;function sk({api:e,open:t,fields:n=[],popupContext:r,setDynamicOptions:i}){let[a,s]=(0,o.useState)({}),c=(0,o.useRef)({}),l=(0,o.useRef)({}),u=(0,o.useRef)({}),d=(0,o.useCallback)((t,n)=>{let a=e.searchOptions??e.searchFetcher;if(typeof a!=`function`)return;l.current[t.name]?.abort();let o=new AbortController;return l.current[t.name]=o,Promise.resolve(a(t,n,r)).then(e=>{if(o.signal.aborted)return;let n=Array.isArray(e)?e:e?.items??e?.list??[];i(e=>({...e,[t.name]:n.map(e=>fO(e,t))}))}).catch(e=>{o.signal.aborted||console.error(`[DynamicPopup] Search failed for field "${t.name}":`,e)}),o},[e,r,i]),f=n.filter(e=>(e.searchFetchKey||e.searchFetcher)&&e.preloadOptions!==!1),p=f.map(e=>e.name).join(`|`),m=(0,o.useRef)({runSearch:d,preloadFields:f});(0,o.useEffect)(()=>{m.current={runSearch:d,preloadFields:f}}),(0,o.useEffect)(()=>{if(!t||!p)return;let{runSearch:e,preloadFields:n}=m.current,r=n.map(t=>e(t,``)).filter(Boolean);return()=>r.forEach(e=>e.abort())},[t,p]);function h(t){if(!t.searchFetchKey&&!t.searchFetcher||typeof(e.searchOptions??e.searchFetcher)!=`function`)return;let n=t.searchMinLength??ok;return e=>{clearTimeout(c.current[t.name]);let r=e.length<n?``:e;c.current[t.name]=setTimeout(()=>{d(t,r)},ak)}}function g(t){let n=e.getMentionOptions??e.mentionFetcher;if(typeof n==`function`)return e=>{u.current[t.name]?.abort();let i=new AbortController;u.current[t.name]=i,Promise.resolve(n(t,e,r)).then(e=>{if(i.signal.aborted)return;let n=Array.isArray(e)?e:e?.items??e?.list??[];s(e=>({...e,[t.name]:n.map(e=>({value:e.user_name??e.userName??e.username??String(e),label:e.user_name??e.userName??e.username??String(e)}))}))}).catch(e=>{i.signal.aborted||console.error(`[DynamicPopup] Mention search failed for field "${t.name}":`,e)})}}return{mentionOptions:a,getSearchHandler:h,getMentionSearchHandler:g}}function ck({form:e,config:t,api:n,popupContext:r,resolvedIds:i,dynamicOptions:a,extraData:c,removedIds:l,removalOnlySubmit:u=!1,fields:d,onClose:f,onSubmit:p}){let[m,h]=(0,o.useState)(!1),[g,_]=(0,o.useState)(null);async function v(e){let t={resolvedIds:i,dynamicOptions:a,extraData:c,removedIds:l};if(typeof n.submit==`function`)return n.submit(e,r,t);if(typeof p==`function`)return p(e,r,t)}function y(){if(t){if(!d.length){if(t.mode===`delete`&&typeof n.deleteItems==`function`){h(!0),_(null),Promise.resolve(n.deleteItems(i,r)).then(()=>{s.message.success(t.successMessage||`Deleted successfully`),f({success:!0})}).catch(e=>{let t=e?.message||`Delete failed. Please try again.`;_(t),h(!1),s.message.error(t)});return}if(typeof n.onOk==`function`){h(!0),Promise.resolve(n.onOk(r)).then(()=>f({success:!0})).catch(e=>{let t=e?.message||`Failed. Please try again.`;s.message.error(t),h(!1)});return}if(typeof n.submit==`function`){h(!0),Promise.resolve(v({})).then(e=>{e?.cancelled||e?.navigated||(s.message.success(t.successMessage||`Saved successfully`),f({success:!0}))}).catch(e=>{s.message.error(e?.message||`Failed. Please try again.`)}).finally(()=>h(!1));return}f();return}if(u){h(!0),Promise.resolve(v(e.getFieldsValue())).then(e=>{e?.cancelled||e?.navigated||(s.message.success(t.successMessage||`Saved successfully`),f({success:!0}))}).catch(e=>{s.message.error(e?.message||`Failed. Please try again.`)}).finally(()=>h(!1));return}e.validateFields().then(async e=>{h(!0);try{let n=await v(e);if(n?.cancelled||n?.navigated)return;s.message.success(t.successMessage||`Saved successfully`),f({success:!0})}catch(e){s.message.error(e?.message||`Failed. Please try again.`)}finally{h(!1)}}).catch(()=>{})}}function b(){h(!1),_(null)}return{handleOk:y,confirming:m,deleteError:g,resetSubmitState:b}}function lk({open:e=!0,config:t,context:n={},onClose:r,onSubmit:i,api:a={}}){let[c]=s.Form.useForm(),[d,f]=(0,o.useState)({}),[p,m]=(0,o.useState)([]),h=s.Form.useWatch([],c,{preserve:!0})??{},g=(0,o.useMemo)(()=>mO(n),[n]),{selectedIds:_=[],selectedRecords:v=[],moduleName:y=``}=g,b=(0,o.useMemo)(()=>_.map((e,t)=>{let n=v[t];return n?.id??n?._id??e}),[_,v]),x=(0,o.useMemo)(()=>t?typeof t.getFields==`function`?t.getFields(g):t.fields??[]:[],[t,g]),S=(0,o.useMemo)(()=>{let e={};return x.forEach(t=>{let n=g[t.initialValueKey];!t.initialValueKey||n===void 0||(e[t.name]=t.type===`date-picker`?(0,u.default)(n):n)}),e},[x,g]),{dynamicOptions:C,setDynamicOptions:w,extraData:T}=ik({open:e,config:t,api:a,fields:x,popupContext:g,formValues:d}),{mentionOptions:E,getSearchHandler:D,getMentionSearchHandler:O}=sk({api:a,open:e,fields:x,popupContext:g,setDynamicOptions:w});function k(e){typeof r==`function`&&r(e)}let A=x.filter(e=>e.required),j=A.every(e=>{let t=h[e.name];return!(t==null||t===``||Array.isArray(t)&&t.length===0||typeof t==`object`&&!Array.isArray(t)&&Object.keys(t).length===0)}),M=(g.removedIds??[]).length,N=p.length>M,P=A.some(e=>{let t=h[e.name];return!(t==null||t===``||Array.isArray(t)&&t.length===0)}),{handleOk:F,confirming:I,deleteError:L,resetSubmitState:R}=ck({form:c,config:t,api:a,popupContext:g,resolvedIds:b,dynamicOptions:C,extraData:T,removedIds:p,removalOnlySubmit:!!t?.allowRemovalOnlySubmit&&N&&!P,fields:x,onClose:k,onSubmit:i});(0,o.useEffect)(()=>{e&&(c.resetFields(),f(S??{}),m(g.removedIds??[]),R())},[e,S]);let z=!!t?.autoSubmitWhenNoFields&&x.length===0;(0,o.useEffect)(()=>{!e||!z||F()},[e,z]);let B=_.length,V=String(y).replace(/s$/i,``),ee=B===1?V:y,te=v[0]??{},ne=t?.getTitleText?t.getTitleText(B,ee,te,g):t?.title,re=B===1?te.jobTitle??te.title??te.name??te.fullName??te.candidateName??null:null,ie=t?.getBodyText?t.getBodyText(B,V,ee,re,g):t?.bodyText??null,ae=typeof t?.getNote==`function`?t.getNote(g):t?.note,oe=t?.disabledUntilFilled&&!j&&!N;if(!t||!e||z)return null;let se=t.component;return se?(0,l.jsx)(s.Modal,{open:e,title:t.title||t.getTitleText?(0,l.jsx)(rO,{titleText:ne,titleIcon:t.titleIcon}):null,footer:null,width:t.width??760,centered:!0,maskClosable:!1,onCancel:()=>k(),className:`dynamic-popup${t.className?` ${t.className}`:``}`,children:(0,l.jsx)(se,{context:g,selectedIds:b,selectedRecords:v,moduleName:y,onClose:k})}):(0,l.jsxs)(s.Modal,{open:e,title:(0,l.jsx)(rO,{titleText:ne,titleIcon:t.titleIcon}),okText:t.okText||`OK`,cancelText:t.cancelText??`Cancel`,onOk:F,onCancel:()=>k(),okButtonProps:{danger:t.okButtonDanger,disabled:oe,loading:I},cancelButtonProps:{disabled:I},closable:!I,maskClosable:!1,width:t.width??480,centered:!0,className:`dynamic-popup${t.className?` ${t.className}`:``}`,children:[(0,l.jsx)(iO,{note:ae,description:t.description,showSelectedCount:t.showSelectedCount,count:B,itemLabel:ee,bodyText:ie,deleteError:L}),(0,l.jsx)(aO,{footerNote:t.footerNote}),(0,l.jsx)(HO,{form:c,fields:x,initialValues:S,dynamicOptions:C,popupContext:g,extraData:T,removedIds:p,setRemovedIds:m,showAlreadyAssigned:t.showAlreadyAssigned,onValuesChange:f,getSearchHandler:D,getMentionSearchHandler:O,mentionOptions:E})]})}var uk={mode:`delete`,getTitleText:(e,t)=>`Delete ${e>0?`${e} `:``}${t}`,titleIcon:`delete`,okText:`Delete`,okButtonDanger:!0,width:420,getBodyText:(e,t,n,r)=>r?`Are you sure you want to delete the ${r} ${t}?`:e>1?`Are you sure you want to delete ${e} selected ${n}?`:`Are you sure you want to delete this ${t}?`,footerNote:`This action cannot be undone.`,fields:[]},dk={deleteItems:async(e,t)=>{await ae(t.moduleName,e)}},fk=new Map;async function pk(e){return e?(fk.has(e)||fk.set(e,a.r({module:e}).catch(t=>(fk.delete(e),console.warn(`[in-progress gate] could not read ${e} form groups:`,t),[]))),fk.get(e)):[]}function mk(e=[],t){return e.some(e=>{let r=n.C(e,t);return r&&r.severity!==`allow`})}async function hk({targetModule:e,sourceModule:t,recordId:r,region:i}={}){let o={severity:`allow`,message:``,group:null};if(!e||!t||!r)return o;let s=i??n.Hn().region;try{let i=await pk(e);if(!mk(i,s))return o;let c=await a.r({module:t,id:r}),l={};for(let e of c){let t=e?.payloadKey||e?.name;t&&Array.isArray(e?.rows)&&(l[t]=e.rows)}return n.D(i,s,l)}catch(e){return console.warn(`[in-progress gate] check skipped:`,e),o}}var gk=`Already submitted`,_k=`submissions`,vk=`candidates`,yk=864e5,bk=90,xk=`This candidate was created or last updated more than 90 days ago. Only candidates created or updated within the last 90 days can be selected. Please update this candidate first.`,Sk=[`createdAt`,`createdDate`,`dateCreated`,`created_on`,`createdOn`],Ck=[`updatedAt`,`updatedDate`,`lastUpdatedAt`,`lastUpdatedDate`,`modifiedAt`,`modifiedDate`];function wk(e,t){for(let n of t){let t=e?.[n];if(!t)continue;let r=new Date(t);if(!Number.isNaN(r.getTime()))return r}return null}function Tk(e){return wk(e,Sk)}function Ek(e){return wk(e,Ck)}function Dk(e){if(!(e instanceof Date)||Number.isNaN(e.getTime()))return null;let t=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();return Math.max(0,Math.floor((t(new Date)-t(e))/yk))}function Ok(e){return e===null?``:e<=14?`green`:e<=89?`yellow`:`red`}function kk(e,t=bk){if(!e)return!1;let n=Date.now()-t*yk,r=Tk(e),i=Ek(e),a=r&&r.getTime()>=n,o=i&&i.getTime()>=n;return!a&&!o}function Ak(e){let t=Tk(e);if(!t)return{createdAgo:``,createdAgoTone:``};let n=lO(t);return n?{createdAgo:n,createdAgoTone:Ok(Dk(t))}:{createdAgo:``,createdAgoTone:``}}function jk(e){return{...e,...Ak(e),isStaleCandidate:kk(e)}}function Mk(e){return String(e?.applicantId??e?._id??e?.id??``)}var Nk=null;async function Pk(){return Nk||=n.Lr(vk).then(e=>e?.strategies?.duplicateCheck?.editRoute??``).catch(()=>``),Nk}async function Fk(e){let t=Mk(e);if(!t)return``;let n=await Pk();return n?n.replace(/:(_?id)\b/g,encodeURIComponent(t)):``}async function Ik({option:e,popupContext:t,confirm:n}){let r=e?._raw??e??{},i=Mk(r);if(i){let e=await hk({targetModule:_k,sourceModule:vk,recordId:i});if(e.severity===`block`)return new Promise(t=>{n({title:`This candidate cannot be submitted`,content:e.message,okText:`Pick someone else`,cancelText:`Close`,onOk:()=>t(!1),onCancel:()=>t(!1)})})}if(!kk(r))return!0;let a=t?.navigate;return!a||!i?!1:new Promise(e=>{n({title:`Candidate update required`,content:xk,okText:`OK`,cancelText:`Cancel`,onOk:async()=>{let t=await Fk(r);t&&a(t),e(!1)},onCancel:()=>e(!1)})})}function Lk(e,t,n){return{...e,label:`${e.label} - ${gk}`,disabled:!0,title:`${gk}${t?` (submission ${t})`:``}`,alreadySubmitted:!0,existingSubmissionId:t||``,...n?{submittedAt:n}:{}}}var Rk={searchOptions:async(e,t,n)=>{if(e.searchFetchKey===`quickSubmitJobList`){let e=n.selectedRecords?.[0]??{},r=e.id??e._id??n.selectedIds?.[0],i,a=!0;try{i=await Ee({searchQuery:t,candidateId:r})}catch{a=!1;let e=await Nn({searchQuery:t,candidateId:r});i=Array.isArray(e?.data)?e.data:[]}let o=i.map(e=>({label:[e.jobReferenceId??e.clientJobReferenceId,e.jobTitle].filter(Boolean).join(` - `)||String(e._id??``),value:e._id??``,_raw:e}));if(a)return o.map(e=>{if(e._raw?.isSubmitted||e._raw?.alreadySubmitted)return Lk(e,e._raw?.jobSubmissionId||``,e._raw?.submittedAt||``);if(e._raw?.disable){let t=String(e._raw?.message??``).trim();return{...e,disabled:!0,label:t?`${e.label} - ${t}`:e.label,title:t}}return e});let s=await Oe({applicantId:r,jobIds:o.map(e=>e.value)}).catch(()=>new Map);return o.map(e=>{let t=s.get(String(e.value));return t?Lk(e,t.submissionId,t.submittedAt):e})}if(e.searchFetchKey===`quickSubmitCandidates`){let e=n.selectedRecords?.[0]??{},r=n.jobId??e.jobId??e.id??e._id??n.selectedIds?.[0],i,a=new Map;try{i=await De({search:t,jobId:r})}catch{let e=await es({isFromSubmission:n.isFromSubmission,jobId:r,submissionId:n.submissionId,search:t});i=Array.isArray(e)?e:[],a=await Oe({jobId:r,applicantIds:i.map(Mk)}).catch(()=>new Map)}return i.map(e=>jk(e)).map(e=>{let t=a.get(Mk(e));if(!(t||e?.isSubmitted===!0||e?.alreadySubmitted===!0))return e;let n=t?.submissionId||e?.jobSubmissionId||``,r=t?.submittedAt||e?.submittedAt||``;return{...e,disabled:!0,optionNote:gk,isSubmitted:!0,alreadySubmitted:!0,existingSubmissionId:n,...r?{submittedAt:r}:{}}})}return[]},submit:async(e,t,n)=>{let{navigate:r,selectedRecords:i=[],selectedIds:a=[],moduleName:o}=t,s=i[0]??{},c,l;t.jobId?(c=t.jobId,l=s.id??s._id??a[0]??``):o===`candidate`?(c=e.jobId??``,l=s.id??s._id??a[0]??``):(c=s.jobId??s.id??s._id??a[0]??``,l=e.candidate??``);let u=n?.dynamicOptions?.candidate?.find(e=>Mk(e?._raw)===String(l)),d=n?.dynamicOptions?.jobId?.find(e=>String(e?.value)===String(c)),f=u?._raw?.isSubmitted||u?._raw?.alreadySubmitted||d?.alreadySubmitted||d?._raw?.isSubmitted||d?._raw?.alreadySubmitted;if(!c||!l)throw Error(`Select both a job and a candidate to quick submit.`);if(kk(u?._raw))throw Error(xk);let p=await hk({targetModule:_k,sourceModule:vk,recordId:l});if(p.severity===`block`)throw Error(p.message);let m=f,h=u?._raw?.existingSubmissionId||u?._raw?.jobSubmissionId||d?.existingSubmissionId||d?._raw?.jobSubmissionId||``;try{let e=await Te({jobId:c,applicantId:l});m||=!!e?.exists,h=e?.submissionId||h}catch(e){throw Error(`Could not verify existing submissions (${e?.message??`request failed`}). Please try again.`,{cause:e})}if(m)throw Error(`This candidate is already submitted for this job${h?` (submission ${h})`:``}.`);let g=new URLSearchParams;l&&g.set(`candidateId`,l);let _=u?.priorSubmissionId||u?._raw?.submissionId||d?.priorSubmissionId||d?._raw?.submissionId||``;_?(g.set(`submissionId`,String(_)),g.set(`isFromSubmission`,`true`)):g.set(`isFromSubmission`,`false`);let v=Zo($o({jobId:c,applicantId:l}).catch(()=>[]));return r(`/submission-create/${c}?${g.toString()}`,{state:{relevantSkillsToken:v}}),{navigated:!0}}},zk={title:`Submit`,okText:`Submit`,width:640,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getNote:e=>e.moduleName===`candidate`?`Note: Select a job to submit this candidate.`:`Note: Select a candidate to submit for this job`,getFields:e=>e.jobId?[]:e.moduleName===`candidate`?[{name:`jobId`,label:`Job list`,type:`search-select`,required:!0,placeholder:`Search Job ID / job name - or pick a recent job`,searchFetchKey:`quickSubmitJobList`,optionLayout:{id:`{jobReferenceId}`,title:`{jobTitle}`,subtitle:`{clientJobReferenceId}`,meta:[{label:`Created`,key:`createdAt`,type:`date`},{label:`Updated`,key:`updatedAt`,type:`relative`}]}}]:[{name:`candidate`,label:`Candidate`,type:`search-select`,required:!0,placeholder:`Search candidate name / email - or pick a recent candidate`,optionsKey:`candidateOptions`,searchFetchKey:`quickSubmitCandidates`,labelTemplate:`{applicantRefrenceId} - {firstName} {lastName} - {createdAgo}`,valueKey:`applicantId`,optionLayout:{id:`{applicantRefrenceId}`,title:`{firstName} {lastName}`,titleAccent:{key:`createdAgo`,toneKey:`createdAgoTone`,prefix:` - `},subtitle:`{designation} - {email}`,meta:[{label:`Created`,key:`createdAt`,type:`date`},{label:`Updated`,key:`updatedAt`,type:`relative`}]},onSelectGuard:Ik}]},Bk={title:`Add Notes & Share`,okText:`Save & Share`,width:480,fields:[{name:`notes`,label:`Notes`,type:`mention-textarea`,required:!0,rows:5,maxLength:2e3,placeholder:`Add your notes on the job. Use '@' to mention someone.`,mentionFetchKey:`mentionUsers`}]},Vk=e=>e?.data??e;async function Hk({relatedId:e,notes:n,title:r,notesFor:i}){return Vk(await hn(t.x,`/notes`,{method:`POST`,body:JSON.stringify({relatedId:e,notes:n,title:r,notesFor:i})}))}var Uk={getMentionOptions:async(e,t)=>se(t),submit:async(e,t)=>{let n=Array.isArray(t.selectedIds)?t.selectedIds[0]:t.selectedIds;if(!n)throw Error(`Please select a record before adding a note.`);await Hk({relatedId:String(n),notes:e.notes,notesFor:t.moduleName})}},Wk={name:`jobId`,label:`Job Title / ID`,type:`search-select`,multiple:!0,required:!0,placeholder:`Minimum 3 characters`,searchFetchKey:`tagToJobJobList`,valueKey:`_id`,labelTemplate:`{jobReferenceId} - {jobTitle}`},Gk={name:`hiringStage`,label:`Hiring stage`,type:`select`,required:!0,optionsKey:`hiringStageOptions`,defaultOptions:[{label:`Shortlisted`,value:`shortlisted`},{label:`Pipeline`,value:`pipeline`}],initialValueKey:`hiringStage`},Kk={title:`Tag to Job`,okText:`Tag`,width:480,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getFields:e=>e.jobId&&e.hiringStage?[]:e.jobId?[Gk]:[Wk,Gk]},qk=e=>e?.data??e;function Jk(e){return Array.isArray(e)&&e.every(e=>e&&typeof e==`object`&&`Key`in e)?e.reduce((e,{Key:t,Value:n})=>(e[t]=n,e),{}):e}function Yk(e){return e?Array.isArray(e.data)?e.data.map(Jk):e.stage&&Array.isArray(e.stage.data)?e.stage.data.map(Jk):Array.isArray(e)?e.map(Jk):[]:[]}async function Xk(e=1,n=10){let r=await t.o(t.x,`/workflow/list/all?page=${e}&limit=${n}`),i=qk(r),a=Array.isArray(i)?i:i?.data??[];return{items:a,total:Number(r?.total??i?.total)||a.length,page:e,limit:n}}async function Zk(e,n){let r=qk(await t.o(t.x,`/workflow/${e}/stage/${n}`));return Array.isArray(r)?{data:r}:r}async function Qk(e,n){if(!e||!n)return null;try{let r=new URLSearchParams({module:e,limit:`1`,offset:`0`,scope:`allJobs`,filters:JSON.stringify([{field:`_id`,op:`in`,values:[String(n)],operator:`and`}])}),i=qk(await t.o(t.x,`/module-data-list?${r}`));if(Array.isArray(i))return i[0]??null;if(i?.data&&Array.isArray(i.data))return i.data[0]??null;let a=i?.rows??i?.records??i?.items??i?.list;return Array.isArray(a)?a[0]??null:i??null}catch(t){return console.error(`[getModuleRecordById] failed: ${e}/${n}`,t),null}}async function $k(e){return qk(await t.o(t.C,`/source/workflow-instance`,{method:`POST`,body:JSON.stringify(e)}))}var eA={pipeline:`pipeline`,goodfited:`goodfited`,contacted:`contacted`,submitted:`submitted`,shortlisted:`shortlisted`,interviewinprogress:`interviewInprogress`,selected:`selected`},tA=`Already submitted`;function nA(e,...t){for(let n of t){let t=String(n).split(`.`).reduce((e,t)=>e?.[t],e);if(t!=null&&t!==``)return t}}function rA(e){let t=String(e??``).trim();return t?eA[t.toLowerCase()]??t:``}function iA(e,t=``){return String(nA(e,`candidateId`,`candidate_id`,`applicantId`,`applicantID`,`applicantReferenceId`,`applicantRefrenceId`,`_id`,`id`)??t??``)}function aA(e){return String(nA(e,`_id`,`id`,`candidateId`,`candidate_id`,`applicantId`,`applicantID`)??``)}function oA(e,t,n){let r=String(e.jobTitle??``).trim();return{...e,jobTitle:r?`${r} (${tA})`:`(${tA})`,disabled:!0,title:tA,alreadySubmitted:!0,existingSubmissionId:t||``,...n?{submittedAt:n}:{}}}function sA(e,t){let n=String(t??``).trim();return n?/already submitted/i.test(n)?`${e} (${tA})`:/fulfilled/i.test(n)?`${e} (Fullfilled)`:`${e} (${n})`:e}function cA(e){let t=String(e.jobReferenceId??e.clientJobReferenceId??``).trim(),n=String(e.jobTitle??``).trim();return{...e,jobReferenceId:t,jobTitle:n}}function lA(e){return dA(e).map(e=>e.id)}function uA(e,t=``){return(nA(e,`candidateName`,`candidate_name`,`fullName`,`name`)??[nA(e,`firstName`,`first_name`),nA(e,`lastName`,`last_name`)].filter(Boolean).join(` `)??t)||`Unknown candidate`}function dA(e){let t=Array.isArray(e?.selectedIds)?e.selectedIds:[],n=Array.isArray(e?.selectedRecords)?e.selectedRecords:[],r=[],i=new Set,a=Math.max(t.length,n.length);for(let e=0;e<a;e+=1){let a=n[e]??{},o=t[e]?String(t[e]):``,s=iA(a,o);!s||i.has(s)||(i.add(s),r.push({id:s,name:uA(a,o),record:a,selectedId:o||s}))}return r}function fA(e,t){return Array.isArray(e?.jobId)?e.jobId.map(String).filter(Boolean):e?.jobId?[String(e.jobId)]:Array.isArray(t?.jobId)?t.jobId.map(String).filter(Boolean):t?.jobId?[String(t.jobId)]:[]}function pA(e,t=``){let n=String(e?.jobTitle??e?._raw?.jobTitle??``).trim();if(n)return n;let r=String(e?.label??e?._raw?.label??``).trim();return r.includes(` - `)?r.split(` - `).slice(1).join(` - `).trim():r||String(t??``)}function mA(e,t=``){return pA(e,t)}function hA(e,t,n){let r=[...new Set(fA(e,t))],i=Array.isArray(n?.dynamicOptions?.jobId)?n.dynamicOptions.jobId:[],a=new Map(i.map(e=>[String(e?._id??e?.value??``),e]));return r.map(e=>{let t=a.get(String(e))??{};return{id:String(e),label:mA(t,e),record:t}})}function gA(e){return e.filter(e=>e.blockedCandidates.length>0).map(e=>`${e.job.label} - ${e.blockedCandidates.map(e=>e.name).join(`, `)}`).join(` | `)}function _A(e){return e.filter(e=>e.allowedCandidates.length>0).map(e=>`${e.job.label} - ${e.allowedCandidates.map(e=>e.name).join(`, `)}`).join(` | `)}function vA(e,t){let n=aA(e);if(!n)return null;let r=uA(e,t)||void 0,i={candidateId:String(n),candidateName:r,phone:nA(e,`phone`,`phoneNumber`,`phone_number`,`mobile`,`mobileNumber`,`mobile_number`),source:nA(e,`source`,`sourceType`,`candidateSource`,`profileSource`),submittedAt:nA(e,`submittedAt`,`lastSubmittedAt`,`updatedAt`),remarks:nA(e,`remarks`,`comment`,`comments`,`notes`),assignedRecruiter:nA(e,`assignedRecruiter`,`recruiterName`,`ownerName`,`assignedToName`),screeningStatus:nA(e,`screeningStatus`,`screening.status`,`screeningResult`),screeningScore:nA(e,`screeningScore`,`screening.score`,`score`),assignedDate:nA(e,`assignedDate`,`assignedAt`,`createdAt`)};return Object.fromEntries(Object.entries(i).filter(([,e])=>e!=null&&e!==``))}var yA={searchOptions:async(e,t,n)=>{if(e.searchFetchKey===`tagToJobJobList`){let e=lA(n),r=e.length===1?e[0]:``,i,a=!1;if(r)try{i=await Ee({searchQuery:t,candidateId:r}),a=!0}catch{a=!1}Array.isArray(i)||(i=await oe(t));let o=i.map(cA);if(a)return o.map(e=>{if(e?.isSubmitted||e?.alreadySubmitted)return oA(e,e?.jobSubmissionId||e?.submissionId||``,e?.submittedAt||``);if(e?.disable){let t=String(e?.message??``).trim();return{...e,jobTitle:e.jobTitle?sA(e.jobTitle,t):`(${t})`,disabled:!0,optionNote:t,title:t}}return e});if(!r)return o;let s=await Oe({applicantId:r,jobIds:o.map(e=>e._id).filter(Boolean)}).catch(()=>new Map);return o.map(e=>{let t=s.get(String(e._id));return t?oA(e,t.submissionId,t.submittedAt):e})}return[]},submit:async(e,t,r)=>{let i=rA(e.hiringStage??t.hiringStage),a=dA(t),o=hA(e,t,r);if(!o.length||!a.length)return{cancelled:!0};let s=[];for(let e of o){let t=await Oe({jobId:e.id,applicantIds:a.map(e=>e.id)}).catch(()=>new Map);s.push({job:e,blockedCandidates:a.filter(e=>t.has(String(e.id))),allowedCandidates:a.filter(e=>!t.has(String(e.id)))})}let c=gA(s),l=_A(s),u=s.filter(e=>e.allowedCandidates.length>0);if(!u.length)return await n.Wt({tone:`duplicate`,title:`Selected candidates are already submitted`,body:`Every selected candidate is already submitted to the selected jobs. Choose different jobs to continue.`,facts:[{label:`Blocked combinations`,value:c}],okText:`Close`}),{cancelled:!0};if(s.some(e=>e.blockedCandidates.length>0)&&!await n.Ut({tone:`duplicate`,title:`Some candidate-job combinations are already submitted`,body:`Those combinations will be skipped. Continue tagging the remaining valid combinations?`,facts:[{label:`Will be skipped`,value:c},{label:`Will be tagged`,value:l}],okText:`Tag remaining`,cancelText:`Cancel`,footnote:`Already submitted combinations will be left unchanged.`}))return{cancelled:!0};for(let e of u){for(let t of e.allowedCandidates){let n=vA(t.record??{},t.selectedId);await $k({jobId:e.job.id,module:`jobs`,currentStage:i,...n?{candidateDetails:n}:{}})}await ue({jobId:e.job.id,candidateIds:e.allowedCandidates.map(e=>e.selectedId||e.id),hiringStage:i})}}},bA={title:`Change Status`,okText:`Apply`,width:420,showSelectedCount:!0,fields:[{name:`status`,label:`New Status`,type:`select`,required:!0,placeholder:`Select a status`,dataSource:`master`,masterName:`clientSubmissions`,labelKey:`name`,valueKey:`name`,initialValueKey:`currentStatus`,defaultOptions:[{label:`Active`,value:`active`},{label:`Inactive`,value:`inactive`},{label:`Pending`,value:`pending`},{label:`Closed`,value:`closed`}]}]};function xA(e,t){let n=String(e??``).trim().toLowerCase();return(Array.isArray(t?.status)?t.status:[]).find(e=>String(e?.value??``).trim().toLowerCase()===n||String(e?.label??``).trim().toLowerCase()===n||String(e?._raw?.name??``).trim().toLowerCase()===n)??null}var SA={submit:async(e,t,n)=>{let r=xA(e.status,n?.dynamicOptions),i=r?._raw??{},a={clientSubmissionStatusText:String(i.name??r?.label??e.status??``).trim(),clientSubmissionStatusId:Number(i.id??i.uniqueId??0)||0,clientSubmissionStatusType:String(i.type??``).trim()};await ie(t.moduleName,t.selectedIds,a)}},CA={getTitleText:e=>`Remove ${e>1?`${e} Candidates`:`Candidate`} from Shortlist`,titleIcon:`delete`,okText:`Remove`,okButtonDanger:!0,width:420,getBodyText:e=>e>1?`Are you sure you want to remove ${e} selected candidates from the shortlist?`:`Are you sure you want to remove this candidate from the shortlist?`,footerNote:`The candidate will be moved back to the pipeline.`,fields:[]},wA={onOk:async e=>{await ke({jobId:e.jobId??e.selectedIds[0],candidateIds:e.selectedIds})}},TA={title:`Add to Groups`,description:`Select a group to add the selected candidate(s) to`,okText:`Add to Group`,width:480,disabledUntilFilled:!0,fields:[{name:`groupId`,label:`Group`,type:`select`,required:!0,placeholder:`Select a group`,fetchOptionsKey:`candidateGroups`}]},EA={getOptions:async e=>e.fetchOptionsKey===`candidateGroups`?de():[],submit:async(e,t,{dynamicOptions:n})=>{let r=(n.groupId??[]).find(t=>String(t.value)===String(e.groupId));await fe({candidateIds:t.selectedIds,groupId:e.groupId,groupName:r?.label??``})}},DA=[{title:`Name`,key:`name`,render:(e,t)=>t.name||`${t.first_name??``} ${t.last_name??``}`.trim()||t.user_name||`Assigned user`},{title:`Role`,dataIndex:`role_name`,key:`role`,render:e=>e||`-`},{title:`Reporting`,dataIndex:`reporting_name`,key:`reporting`,render:e=>e||`-`}];function OA({selectedIds:e,onClose:t}){let n=e?.[0],[r,i]=(0,o.useState)(!0),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)({assignedUsers:[],totalSubmissions:0,message:``}),[p,m]=(0,o.useState)([]);(0,o.useEffect)(()=>{let e=!1;return i(!0),Promise.all([me(n).catch(t=>(e||s.message.error(t?.message??`Failed to load self-assign details`),{assignedUsers:[],totalSubmissions:0,message:``})),_e(n).catch(()=>({recruitersData:[]}))]).then(([t,n])=>{e||(f(t),m(Array.isArray(n?.recruitersData)?n.recruitersData:[]))}).finally(()=>{e||i(!1)}),()=>{e=!0}},[n]);let h=async()=>{u(!0);try{await pe({jobIds:[n]}),s.message.success(`Job assigned successfully`),t?.({success:!0})}catch(e){s.message.error(e?.message??`Failed to assign job`)}finally{u(!1)}};if(r)return(0,l.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,l.jsx)(s.Spin,{size:`large`})});let g=p.map(e=>({user_id:e.recruiterId??e.id??e.user_id,name:e.name??``,role_name:e.role_name??e.roleName??``,reporting_name:e.reporting_name??e.reportingName??``})),_=new Map(g.map(e=>[String(e.user_id??``),e])),v=(d.assignedUsers?.length??0)>0?d.assignedUsers.map(e=>{let t=e.user_id??e.userId??e.recruiterId??e.id,n=_.get(String(t??``))??{};return{...e,user_id:t,name:n.name||e.name||``,role_name:n.role_name||e.role_name||e.roleName||``,reporting_name:n.reporting_name||e.reporting_name||e.reportingName||``}}):g,y=v.length>0;return(0,l.jsxs)(`div`,{className:`self-assign-popup-body`,children:[y?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{style:{fontWeight:700,marginBottom:8},children:`Team Members Allocated`}),(0,l.jsx)(s.Table,{columns:DA,dataSource:v,pagination:!1,rowKey:e=>e.user_id??`${e.first_name}-${e.last_name}`,size:`small`,className:`mb-3 no-header-bg`,scroll:{y:200}}),(0,l.jsxs)(`div`,{className:`warning-card`,style:{display:`flex`,alignItems:`center`,gap:8,marginTop:12},children:[(0,l.jsx)(c.ExclamationCircleFilled,{style:{color:`#faad14`,fontSize:18}}),(0,l.jsx)(`div`,{style:{fontSize:13},children:`These users are already assigned to this job. Do you still want to assign yourself as well?`})]})]}):(0,l.jsx)(`div`,{style:{padding:`8px 0`},children:d.message||`No one is currently assigned to this job. Do you want to assign yourself?`}),(0,l.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:12,marginTop:24},children:[(0,l.jsx)(s.Button,{size:`small`,onClick:()=>t?.(),disabled:a,children:`No`}),(0,l.jsx)(s.Button,{type:`primary`,size:`small`,onClick:h,loading:a,children:`Yes`})]})]})}OA.propTypes={selectedIds:f.default.array,onClose:f.default.func};var kA={title:`Self Assign`,width:480,className:`self-assign-modal`,component:OA},AA={submit:async()=>{}};function jA(e={}){let t=Array.isArray(e.jobPayDetails)?e.jobPayDetails[e.jobPayDetails.length-1]:e.jobPayDetails??e.clientBudget??{},n=Number(t.clientBudgetEnd),r=Number(t.clientBudgetStart);return Number.isFinite(n)&&n>0?n:Number.isFinite(r)&&r>0?r:null}var MA={getTitleText:(e,t,n)=>{let r=n?.jobTitle||n?.title||``;return r?`Assign - ${r}`:`Assign`},okText:`Assign`,width:520,disabledUntilFilled:!0,showAlreadyAssigned:!0,allowRemovalOnlySubmit:!0,getFields:e=>(jA(e?.selectedRecords?.[0]??{}),[{name:`assignToUserId`,label:`Assign to`,type:`multi-select`,required:!0,placeholder:`Select recruiter(s)`,fetchOptionsKey:`assignToUsers`}])},NA={getOptions:async e=>e.fetchOptionsKey===`assignToUsers`?ge():[],loadExtraData:async e=>_e(e.selectedIds[0]),submit:async(e,t,{removedIds:n,extraData:r})=>{await xe({jobIds:t.selectedIds,userId:e.assignToUserId,removedIds:n,existingRecruiters:r?.recruitersData})}},PA={title:`Add Sticky Notes`,getTitleText:(e,t,n,r)=>r.editingNoteId?`Edit Sticky Notes`:`Add Sticky Notes`,okText:`Save`,width:480,fields:[{name:`heading`,label:`Heading`,type:`input`,required:!0,placeholder:`Enter heading`,initialValueKey:`editingHeading`},{name:`targetDate`,label:`Target Date`,type:`date-picker`,required:!1,initialValueKey:`editingTargetDate`},{name:`comments`,label:`Comments`,type:`mention-textarea`,required:!0,rows:5,placeholder:`Enter your note here... Use '@' to mention someone.`,mentionFetchKey:`mentionUsers`,initialValueKey:`editingComments`}]},FA={getMentionOptions:async(e,t)=>se(t),submit:async(e,t)=>{let n=e.targetDate?e.targetDate.toISOString():``;t.editingNoteId?await ce(t.editingNoteId,{title:e.heading,targetDate:n,notes:e.comments}):await H({relatedIds:t.selectedIds,module:t.moduleName,title:e.heading,targetDate:n,notes:e.comments}),window.dispatchEvent(new Event(`sticky-notes:refresh`))}},IA={title:`Move to Onboarding`,bodyText:`Are you sure you want to move this candidate to onboarding?`,okText:`Yes`,cancelText:`No`,width:420,successMessage:`Moved to onboarding successfully`,successNavigate:`/onboarding`,fields:[{name:`sendOnboardingEmail`,type:`priority-checkbox`,checkboxLabel:`Send Onboarding Email`}]},LA={submit:async(e,t)=>{await Se({submissionId:t.selectedRecords?.[0]?.submissionId,isMail:e.sendOnboardingEmail})}};function RA(e){return Array.isArray(e)?e[e.length-1]??{}:e&&typeof e==`object`?e:{}}var zA={USD:`$`,INR:`₹`,EUR:`€`,GBP:`£`};function BA(e,t,n){let r=RA(e?.[t])[n];if(r!=null&&r!==``)return r;let i=e?.[`${t}.${n}`];return i!=null&&i!==``?i:void 0}function VA(e){let t=e.selectedRecords?.[0]??{},n=BA(t,`candidateRate`,`candidateAcceptedRate`)??BA(t,`candidateBudget`,`candidateBudgetStart`);if(n===void 0||Number(n)===0)return null;let r=BA(t,`candidateRate`,`candidateAcceptedCurrency`)??BA(t,`candidateBudget`,`candidateBudgetCurrency`);return{amount:n,symbol:BA(t,`candidateRate`,`candidateAcceptedCurrencySymbol`)??BA(t,`candidateBudget`,`candidateBudgetCurrencySymbol`)??zA[String(r??``).toUpperCase()]??(r||`$`),unit:BA(t,`candidateRate`,`candidateAcceptedPayUnit`)??BA(t,`candidateBudget`,`candidateBudgetUnit`)??``}}var HA={title:`Approve Rate`,okText:`Approve`,width:520,className:`medium-modal`,successMessage:`Rate approved`,getBodyText:(e,t,n,r,i)=>{let a=VA(i);return`Candidate Rate: ${a?`${a.symbol}${a.amount}${a.unit?`/${a.unit}`:``}`:`-`}`},fields:[{name:`candidateProposedRate`,label:`Proposed Rate`,type:`number`,required:!0,placeholder:`Amount`,min:0,inlineRow:`proposedRate`,validator:(e,t)=>{if(e==null||e===``)return;let n=VA(t);if(n&&Number(e)<=Number(n.amount))return`Proposed rate must be greater than Candidate Rate`}},{name:`candidateProposedRateCurrency`,label:`Currency`,type:`select`,required:!0,inlineRow:`proposedRate`,defaultOptions:[{label:`$ USD`,value:`$`},{label:`₹ INR`,value:`₹`},{label:`€ EUR`,value:`€`}]},{name:`candidateProposedRateUnit`,label:`Unit`,type:`select`,required:!0,inlineRow:`proposedRate`,defaultOptions:[{label:`Year`,value:`yr`},{label:`Month`,value:`mo`},{label:`Week`,value:`wk`},{label:`Hour`,value:`hr`},{label:`Daily`,value:`day`}]},{name:`submitVia`,label:`Submit Via`,type:`radio`,required:!0,defaultOptions:[{label:`Mail`,value:`Mail`},{label:`VMS`,value:`VMS`}]}]},UA={submit:async(e,t)=>{let n=t.selectedIds[0];if(await Ce(n,{candidateProposedRate:e.candidateProposedRate,candidateProposedRateCurrency:e.candidateProposedRateCurrency,candidateProposedRateUnit:e.candidateProposedRateUnit,submitVia:e.submitVia}),e.submitVia===`VMS`)try{await we(n)}catch{s.message.warning(`Approved. VMS notification could not be sent — use Send Mail to notify the client.`)}else s.message.info(`Approved — use Send Mail to notify the client.`)}};async function WA(e,n={}){let r=t.u();if(!r){let e=Error(`Authentication required`);throw e.status=401,e}let i=await fetch(`${t.T}${e}`,{...n,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${r}`,...n.headers}});if(i.status===401&&t.h(),!i.ok){let e=Error(`API ${i.status}: ${i.statusText}`);throw e.status=i.status,e}return i.json()}async function GA(e){let t=await WA(`/mail-form?${new URLSearchParams({submissionId:e,submissionType:`manager`}).toString()}`);return t.data??t}function KA(e){return Array.isArray(e)?e[e.length-1]:e}function qA(e={}){let t=KA(e?.proposedRate)?.candidateProposedRate??e?.candidateProposedRate??e?.proposedRateValue,n=Number(t);return Number.isFinite(n)?n:0}function JA(e,t={}){let n=KA((e?.record?.job??e?.job??t?.job??{})?.jobPayDetails)??{},r=e?.record?.submission??t??{},i=KA(r?.clientBudget)??r?.clientBudget??{},a=n?.clientBudgetEnd??n?.clientBudgetStart??i?.clientBudgetEnd??i?.clientBudgetStart,o=Number(a);return Number.isFinite(o)?o:0}function YA(e={}){let t=String(e?.currencyRaw??``).trim().toUpperCase(),n=String(e?.currency??``).trim();return n&&!/^[A-Z]{3}$/i.test(n)?n:t===`USD`||n.toUpperCase()===`USD`?`$`:t===`INR`||n.toUpperCase()===`INR`?`₹`:t===`EUR`||n.toUpperCase()===`EUR`?`€`:t===`GBP`||n.toUpperCase()===`GBP`?`£`:n||t}function XA(e={}){return String(e?.rateUnit??`hr`).trim().replace(/^\/+/,``)||`hr`}function ZA(e,t={}){let n=Number(e);return Number.isFinite(n)?`${YA(t)}${n}/${XA(t)}`:``}function QA(e,t,n){if(n==null||n===``)return String(e??``);let r=String(e??``),i=String(n),a=!1,o=RegExp(`(<(?:td|th)[^>]*>[\\s\\S]*?${t}[\\s\\S]*?</(?:td|th)>\\s*<(?:td|th)[^>]*>)([\\s\\S]*?)(</(?:td|th)>)`,`gi`);r=r.replace(o,(e,t,n,r)=>(a=!0,`${t}${i}${r}`));let s=RegExp(`(<(?:strong|b)[^>]*>\\s*${t}\\s*:?\\s*</(?:strong|b)>\\s*)([\\s\\S]*?)(?=</(?:li|p|div)>)`,`gi`);if(r=r.replace(s,(e,t)=>(a=!0,`${t}${i}`)),!a){let e=RegExp(`(${t}\\s*:?[ \\t]*)([^<\\r\\n]*)`,`gi`);r=r.replace(e,(e,t)=>`${t}${i}`)}return r}function $A(e,t,n,r,i){let a=Number(n?.proposedRate),o=Number.isFinite(a)?a:qA(t),s=Number(n?.clientJobRate),c=Number.isFinite(s)&&s>0?s:JA(r,i),l={proposedRate:o,jobBillRate:c},u=String(e??``).replace(/{{\.?((?:proposedRate)|(?:jobBillRate))}}/g,(e,t)=>{let n=l[t];return n==null?e:String(n)});return u=QA(u,`(?:Proposed\\s*Rate|Pay\\s*Rate)`,ZA(o,n)),u=QA(u,`(?:Job\\s*)?Bill\\s*Rate`,ZA(c,n)),u}function ej(...e){return e.map(e=>e==null?``:String(e).trim()).find(Boolean)??``}var tj=(e,t)=>!!e&&e.toLowerCase()===ej(t).toLowerCase();function nj(e,t,n){let r=ej(t.submittedBy);return ej(tj(r,n)||tj(r,e.submitSource)||tj(r,e.supplierName)||tj(r,e.source)||tj(r,e.candidateSource)?``:r,e.signatureEmail)}function rj(e,t={}){let n=t.employerName??e.supplierName??e.submitSource;return{client:t.clientName??e.clientName,role:t.jobTitle??e.jobTitle??e.designation,reqId:t.reqId??e.jobClientRefrenceId??e.mspReqId??e.submissionId,name:t.candidateName||[e.firstName,e.lastName].filter(Boolean).join(` `)||e.candidateFullName,location:t.jobLocation??e.city??e.currentLocation??e.jobLocation,vendor:n,submittedBy:nj(e,t,n),submittedAt:t.createdAt??e.createdAt,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function ij(e){let t=e?.$oid??e?._id?.$oid??e?._id??e?.id?.$oid??e?.id??e;if(t==null||typeof t==`object`)return``;let n=String(t).trim();return/^[a-f\d]{24}$/i.test(n)?n:``}function aj(...e){for(let t of e){let e=[t?.jobId,t?.JobId,t?.job_id,t?.jobDetails?._id,t?.jobDetails?.id,t?.job?._id,t?.job?.id,t?.submission?.jobId,t?.submission?.JobId,t?.submission?.job_id,t?.submission?.jobDetails?._id,t?.submission?.jobDetails?.id,t?.submission?.job?._id,t?.submission?.job?.id,t?.recordMeta?.jobId,t?.recordMeta?.JobId,t?.recordMeta?.job_id,t?.submission?.recordMeta?.jobId,t?.submission?.recordMeta?.JobId,t?.submission?.recordMeta?.job_id].map(ij).find(Boolean);if(e)return e}return``}function oj(e){if(!e?.referralId)return{};let t=Number(e.referralRate??e.referalRate??0)||0,n=String(e.referralType??e.referalType??`RECURRING`).trim()||`RECURRING`,r=e.referralId??e.referalId;return{referralId:r,referalId:r,referralRate:t,referalRate:t,referralType:n,referalType:n,referralEnabled:!0,referalEnabled:!0,isReferralApplicable:!0,referralDetails:{referralId:r,referalId:r,referralRate:t,referalRate:t,referralType:n,referalType:n,referralEnabled:!0,referalEnabled:!0,isReferralApplicable:!0}}}function sj(e=``){return String(e??``).replace(/map\[[^\]]*(?:resume|document|attachment|file)[^\]]*\]/gi,``).replace(/<p>\s*<\/p>/gi,``).replace(/(?:<br\s*\/?>\s*){3,}/gi,`<br><br>`).trim()}function cj(...e){for(let t of e){let e=[t?.candidateId,t?.applicantId,t?.candidate?._id,t?.candidate?.id,t?.submission?.candidateId,t?.submission?.applicantId,t?.recordMeta?.candidateId,t?.recordMeta?.applicantId].map(ij).find(Boolean);if(e)return e}return``}async function lj(e){let t=e?.fileUrl??e?.downloadUrl??e?.url;if(!t)return null;let n=await fetch(t);if(!n.ok)throw Error(`Unable to load ${e?.fileName||`resume`}`);let r=await n.blob(),i=e?.fileName??e?.uploadedFileName??e?.originalName??e?.uniqueName??`resume`;return new File([r],i,{type:e?.contentType||r.type||`application/octet-stream`})}async function uj(e,r,i){let a=[],o=await n.yn(`submissions`,e,`resume`).catch(()=>({data:[]}));a.push(...o?.data??[]);let s=cj(r?.record?.submission,i,r?.record);if(!s){let n=await t.o(t.x,`/module/list?module=submissions&id=${encodeURIComponent(e)}`).catch(()=>({})),r=n?.data??n??{};s=cj((Array.isArray(r?.data)?r.data:Array.isArray(r)?r:[])[0])}if(s){let e=await n.yn(`candidates`,s,`resume`).catch(()=>({data:[]}));a.push(...e?.data??[])}let c=(await Promise.all(a.map(lj))).filter(Boolean),l=new Set;return c.filter(e=>{let t=`${e.name}:${e.size}:${e.type}`;return!l.has(t)&&(l.add(t),!0)})}function dj(e={}){return{to:(e.to??e.To??[]).map(e=>e.email??e.Email??e).filter(Boolean).join(`, `),cc:(e.cc??e.Cc??[]).map(e=>e.email??e.Email??e).filter(Boolean).join(`, `),bcc:(e.bcc??e.Bcc??[]).map(e=>e.email??e.Email??e).filter(Boolean).join(`, `),subject:e.subject??e.Subject??``,contents:sj(e.content?.value??e.Content?.Value??e.contents??e.body??``)}}function fj({context:e,selectedIds:t,selectedRecords:n,moduleName:r,onClose:i}){let a=n?.[0]??{},c=t?.[0]??Z_(a),[u,d]=(0,o.useState)(null),[f,p]=(0,o.useState)(!0),[m,h]=(0,o.useState)([]),[g,_]=(0,o.useState)(!1),[v,y]=(0,o.useState)(`vms`),[b,x]=(0,o.useState)(null),[S,C]=(0,o.useState)(null),[w,T]=(0,o.useState)(!1),[E,D]=(0,o.useState)(!1),[O,k]=(0,o.useState)(!1),[A,j]=(0,o.useState)(!1),[M,N]=(0,o.useState)({to:``,cc:``,bcc:``,subject:``,contents:``,attachments:[],showCc:!1,showBcc:!1});(0,o.useEffect)(()=>{let e=!1;return Rv(c,a).then(t=>{e||d(t)}).catch(t=>{e||(s.message.error(t?.message??`Unable to load finance details`),d({record:{submission:a},lookups:{},display:{}}))}).finally(()=>{e||p(!1)}),()=>{e=!0}},[c]),(0,o.useEffect)(()=>{let e=!1;return qv().then(t=>{e||h(t)}).catch(()=>{}),()=>{e=!0}},[]);let P=async()=>{if(b){if(v===`mail`){_(!1),D(!0),k(!0);try{let[e,t]=await Promise.all([GA(c).then(dj),uj(c,u,a).catch(e=>(console.warn(`Unable to resolve resume attachment:`,e),[]))]),n=u?.record?.submission??a;N({to:$A(e.to,n,b,u,a),cc:$A(e.cc,n,b,u,a),bcc:$A(e.bcc,n,b,u,a),subject:$A(e.subject,n,b,u,a),contents:$A(e.contents,n,b,u,a),attachments:t,showCc:!!e.cc,showBcc:!!e.bcc})}catch(e){s.message.error(e?.message??`Unable to prepare approval mail`)}finally{k(!1)}return}T(!0);try{await Ce(c,{candidateProposedRate:b.proposedRate,candidateProposedRateCurrency:b.currencyRaw??b.currency,candidateProposedRateUnit:b.rateUnit,submitVia:`VMS`,...oj(S)}),s.message.success(`Submission approved`),_(!1),x(null),C(null),i?.({success:!0})}catch(e){s.message.error(e?.message??`Unable to approve submission`)}finally{T(!1)}}},F=!O&&GE(M.to).length>0&&KE(M.to)&&KE(M.cc)&&KE(M.bcc)&&M.subject.trim()&&M.contents.trim(),I=async()=>{if(!b||!F||A)return;j(!0);let e={candidateProposedRate:b.proposedRate,candidateProposedRateCurrency:b.currencyRaw??b.currency,candidateProposedRateUnit:b.rateUnit};try{await Ce(c,{...e,submitVia:`VMS`,...oj(S)});let t=aj(u?.record,a);if(!t)s.message.warning(`Submission approved, but job details were not available to send mail`);else try{await ln({jobId:t,toMail:GE(M.to),ccMail:GE(M.cc),bccMail:GE(M.bcc),subject:M.subject,contents:M.contents,attachments:M.attachments??[]}),s.message.success(`Approval mail sent and submission approved`)}catch(e){s.message.warning(e?.message?`Submission approved, but mail was not sent: ${e.message}`:`Submission approved, but mail was not sent`)}D(!1),x(null),C(null),i?.({success:!0})}catch(e){s.message.error(e?.message??`Unable to send approval mail`)}finally{j(!1)}},L=(0,o.useMemo)(()=>({submissionApprove:async({computed:e,referral:t})=>{x(e),C(t??null),y(`vms`),_(!0)},submissionReject:async()=>{e?.navigate?.(`/popup/reject`,{replace:!0,state:{background:e?.background??null,selectedIds:t,selectedRecords:n,moduleName:r}})}}),[e,t,n,r]);return f||!u?(0,l.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,l.jsx)(s.Spin,{size:`large`})}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(Dv,{type:T_,record:u.record,lookups:u.lookups,identity:rj(a,u.display),referralOptions:m,onAddReferral:()=>e?.navigate?.(`/referrals-create`),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:L,onClose:()=>i?.(),variant:`popup`}),(0,l.jsx)(s.Modal,{title:`Choose approval method`,open:g,okText:`Approve`,confirmLoading:w,onOk:P,onCancel:()=>{w||(_(!1),x(null),C(null))},children:(0,l.jsxs)(s.Radio.Group,{value:v,onChange:e=>y(e.target.value),style:{display:`grid`,gap:12},children:[(0,l.jsx)(s.Radio,{value:`vms`,children:`Via VMS`}),(0,l.jsx)(s.Radio,{value:`mail`,children:`Via Mail`})]})}),(0,l.jsx)(s.Drawer,{open:E,placement:`right`,onClose:()=>{A||D(!1)},closable:!1,rootClassName:`mail-popup`,width:620,maskClosable:!1,footer:(0,l.jsxs)(`div`,{className:`mail-popup__footer`,children:[(0,l.jsx)(s.Button,{onClick:()=>D(!1),disabled:A,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:A,disabled:!F,onClick:I,children:`Send`})]}),children:O?(0,l.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,l.jsx)(s.Spin,{size:`large`})}):(0,l.jsx)(iD,{value:M,onChange:N,moduleName:`submissions`,ready:!O,title:`Submit Via Mail`,contextRecords:[u.record?.submission??a]})})]})}fj.propTypes={context:f.default.object,selectedIds:f.default.array,selectedRecords:f.default.array,moduleName:f.default.string,onClose:f.default.func};var pj={title:`Manager Approve`,width:780,className:`fa-modal manager-approve-modal`,component:fj},mj={submit:async()=>{}};function hj(...e){return e.map(e=>e==null?``:String(e).trim()).find(Boolean)??``}var gj=(e,t)=>!!e&&e.toLowerCase()===hj(t).toLowerCase();function _j(e,t,n){let r=hj(t.submittedBy);return hj(gj(r,n)||gj(r,e.submitSource)||gj(r,e.supplierName)||gj(r,e.source)||gj(r,e.candidateSource)?``:r,e.signatureEmail)}function vj(e,t={}){let n=t.employerName??e.supplierName??e.submitSource;return{client:t.clientName??e.clientName,role:t.jobTitle??e.jobTitle??e.designation,reqId:t.reqId??e.jobClientRefrenceId??e.mspReqId??e.submissionId,name:t.candidateName||[e.firstName,e.lastName].filter(Boolean).join(` `)||e.candidateFullName,location:t.jobLocation??e.city??e.currentLocation??e.jobLocation,vendor:n,submittedBy:_j(e,t,n),submittedAt:t.createdAt??e.createdAt,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function yj(e){let t=Array.isArray(e)?e:[];for(let e=t.length-1;e>=0;--e)if(String(t[e]?.activityType??``).trim().toLowerCase()===`cfo rejected`)return t[e];return null}function bj(e){return String(e??``).toLowerCase().replace(/\b\w/g,e=>e.toUpperCase())}function xj({selectedIds:e,selectedRecords:t,onClose:r}){let i=t?.[0]??{},a=e?.[0]??Z_(i),[c,u]=(0,o.useState)(null),[d,f]=(0,o.useState)(``),[p,m]=(0,o.useState)(!0);(0,o.useEffect)(()=>{let e=!1;return m(!0),Promise.all([Rv(a,i),n.pn(`submission`,a).catch(()=>[])]).then(([t,n])=>{if(e)return;let r=yj(n);f(Z_(t?.meta?.workforceEngagementId??i?.onboarding?.workforceEngagementId??i?.workforceEngagementId));let a=t?.meta?.rejectReasonComments||r?.activityComments||``;u({...t,record:{...t.record,submission:{...t.record.submission,cfoRejectionReason:a?bj(a):``,cfoRejectedAt:t?.meta?.rejectedAt??r?.activityTime??null}}})}).catch(t=>{e||(s.message.error(t?.message??`Unable to load finance details`),u({record:{submission:i},lookups:{},display:{}}))}).finally(()=>{e||m(!1)}),()=>{e=!0}},[a]);let h=(0,o.useMemo)(()=>({submissionReapproveSend:async({computed:e})=>{await U(d,{submissionId:a,billRate:e.proposedRate,payRate:e.employerRate,currency:e.currencyRaw??e.currency,rateUnit:e.rateUnit,vmsPercent:e.clientVmsPercent}),await Ce(a,{candidateProposedRate:e.proposedRate,candidateProposedRateCurrency:e.currencyRaw??e.currency,candidateProposedRateUnit:e.rateUnit,submitVia:`Mail`,context:`resend`}),s.message.success(`Re-approved and sent for CFO approval`),r?.({success:!0})}}),[a,d,r]);return p||!c?(0,l.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,l.jsx)(s.Spin,{size:`large`})}):(0,l.jsx)(Dv,{type:k_,record:c.record,lookups:c.lookups,identity:vj(i,c.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:h,onClose:()=>r?.(),variant:`popup`})}xj.propTypes={selectedIds:f.default.array,selectedRecords:f.default.array,onClose:f.default.func};var Sj={title:`Re-Approve`,width:780,className:`fa-modal manager-approve-modal`,component:xj},Cj={submit:async()=>{}},wj=[{id:1,name:`Re-Submission`},{id:2,name:`Candidate doesn't fit into the profile`},{id:3,name:`Incomplete candidate details - (Re-Submission)`}],Tj={title:`Reject`,okText:`Reject`,okButtonDanger:!0,width:480,successMessage:`Submission rejected successfully`,fields:[{name:`rejectReason`,label:`Rejection Reasons`,type:`select`,required:!0,placeholder:`Select rejection reasons`,defaultOptions:wj.map(e=>({label:e.name,value:e.id}))},{name:`rejectReasonComments`,label:`Comments`,type:`textarea`,required:!0,rows:4}]},Ej={submit:async(e,t)=>{let n=wj.find(t=>String(t.id)===String(e.rejectReason));await W({submissionId:t.selectedIds[0],rejectReasonId:e.rejectReason,rejectReason:n?.name??``,rejectReasonComments:e.rejectReasonComments})}},Dj={delete:uk,"quick-submit":zk,"add-notes":Bk,"tag-to-job":Kk,"change-status":bA,"remove-from-shortlist":CA,"add-to-groups":TA,"self-assign":kA,"others-assign":MA,"sticky-notes":PA,"move-to-onboarding":IA,"approve-rate":HA,"manager-approve":pj,"manager-reapprove":Sj,reject:Tj},Oj={delete:dk,"quick-submit":Rk,"add-notes":Uk,"tag-to-job":yA,"change-status":SA,"remove-from-shortlist":wA,"add-to-groups":EA,"self-assign":AA,"others-assign":NA,"sticky-notes":FA,"move-to-onboarding":LA,"approve-rate":UA,"manager-approve":mj,"manager-reapprove":Cj,reject:Ej};function kj(e){let t=e?.data??e;return Array.isArray(t)?t:t?.data??t?.rows??t?.records??t?.items??t?.list??[]}function Aj(e,...t){for(let n of t){let t=String(n).split(`.`).reduce((e,t)=>e?.[t],e);if(t!=null&&t!==``)return t}return``}function jj(e){let t=String(Aj(e,`isDeleted`,`deleted`)).toLowerCase(),n=String(Aj(e,`assignmentStatus`,`status`)).toLowerCase();return t!==`true`&&t!==`1`&&![`removed`,`inactive`,`deleted`].includes(n)}function Mj(e){let t=Aj(e,`candidateName`,`candidate_name`,`fullName`,`name`);return t?String(t):[Aj(e,`firstName`,`first_name`),Aj(e,`lastName`,`last_name`)].filter(Boolean).join(` `)||`Unnamed candidate`}function Nj(e){return String(Aj(e,`candidateId`,`candidate_id`,`candidate._id`,`candidate.id`))}function Pj(e){return String(Aj(e,`workforceEngagementId`,`engagementId`,`_id`,`id`))}function Fj(e){return String(Aj(e,`batchName`,`name`,`title`,`batch_name`))}function Ij({open:e=!0,context:r={},onClose:i}){let[a,c]=(0,o.useState)([]),[u,d]=(0,o.useState)([]),[f,p]=(0,o.useState)(``),[m,h]=(0,o.useState)(!0),[g,_]=(0,o.useState)(!1),[v,y]=(0,o.useState)(``),[b,x]=(0,o.useState)(new Map),S=String(r.selectedIds?.[0]??r.selectedRecords?.[0]?._id??r.selectedRecords?.[0]?.id??r.batchId??``);(0,o.useEffect)(()=>{if(!e)return;let t=!1;return Promise.resolve().then(()=>(t||h(!0),Promise.all([n.Sn(`onboarding`,200,0),n.Sn(`batchCandidates`,1e3,0).catch(()=>[])]))).then(([e,n])=>{t||(c(kj(e)),x(new Map(kj(n).filter(jj).map(e=>[String(Aj(e,`candidateId`,`candidate_id`)),e]).filter(([e])=>e))))}).catch(e=>{t||y(e.message||`Unable to load onboarding candidates`)}).finally(()=>{t||h(!1)}),()=>{t=!0}},[e]);let C=(0,o.useMemo)(()=>{let e=f.trim().toLowerCase();return e?a.filter(t=>[Mj(t),Aj(t,`email`,`candidateEmail`,`candidate_email`),Aj(t,`status`,`onboardingStatus`,`onboarding_status`)].some(t=>String(t).toLowerCase().includes(e))):a},[a,f]);async function w(){if(!S){y(`Select a batch before adding candidates`);return}let e=a.filter(e=>u.includes(Pj(e)));if(!e.length)return;let o=e.map(e=>({record:e,assignment:b.get(Nj(e))})).filter(e=>e.assignment);if(o.length){let e=o.map(({record:e})=>Mj(e)).join(`, `);y(`${e} ${o.length===1?`is`:`are`} already added to a batch. Each candidate can be added to only one batch.`);return}_(!0),y(``);try{let{userId:a}=t.s(),o=Fj(r.selectedRecords?.[0])||Fj(r);await Promise.all(e.map(e=>n.$n(`batchCandidates`,{schemaVersion:1,batchId:S,batchName:o,candidateId:Nj(e),workforceEngagementId:Pj(e),source:`ONBOARDING`,assignmentStatus:`ASSIGNED`,assignedAt:new Date().toISOString(),assignedBy:a??0,isDeleted:!1}))),s.message.success(`${e.length} candidate${e.length===1?``:`s`} added to the batch`),i?.({refresh:!0})}catch(e){y(e.message||`Unable to add candidates to the batch`)}finally{_(!1)}}return(0,l.jsxs)(s.Modal,{open:e,title:`Add Candidate to Batch`,okText:`Add`,onOk:w,onCancel:()=>i?.(),okButtonProps:{disabled:u.length===0||!S,loading:g},cancelButtonProps:{disabled:g},closable:!g,maskClosable:!1,width:760,centered:!0,children:[v&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,message:v,style:{marginBottom:12}}),(0,l.jsx)(s.Input.Search,{allowClear:!0,placeholder:`Search onboarding candidates`,value:f,onChange:e=>p(e.target.value),style:{marginBottom:12}}),(0,l.jsx)(s.Table,{rowKey:e=>Pj(e),columns:[{title:`Candidate`,key:`candidate`,render:(e,t)=>Mj(t)},{title:`Email`,key:`email`,render:(e,t)=>Aj(t,`email`,`candidateEmail`,`candidate_email`)||`—`},{title:`Onboarding status`,key:`status`,render:(e,t)=>Aj(t,`status`,`onboardingStatus`,`onboarding_status`)||`—`}],dataSource:C,loading:m,size:`small`,pagination:{pageSize:10,showSizeChanger:!1},rowSelection:{selectedRowKeys:u,onChange:d,getCheckboxProps:e=>{let t=b.get(Nj(e));return{disabled:!Nj(e)||!Pj(e)||!!t,title:t?`Candidate is already added to a batch`:void 0}}},locale:{emptyText:m?`Loading candidates…`:`No onboarding candidates found`}})]})}var Lj={text:`input`,string:`input`,textarea:`textarea`,date:`date-picker`,datepicker:`date-picker`,multiselect:`multi-select`,lookup:`search-select`};function Rj(e){if(!e)return null;let t=[...e.groups??[]].sort((e,t)=>Number(e.order??0)-Number(t.order??0)).flatMap(e=>[...e.fields??[]].filter(e=>e.show!==0&&e.show!==!1).sort((e,t)=>Number(e.order??0)-Number(t.order??0)).map(e=>({...e,name:e.name??e.field,label:e.label??e.field,type:Lj[String(e.type??`text`).toLowerCase()]??e.type??`input`,required:e.required??e.req===1,options:(e.options??[]).map(e=>({label:e.label??e.name??e.value,value:e.value??e.id??e.label}))}))),n=zj(e.successNavigate);return{title:e.label,fields:t,...n?{successNavigate:n}:{}}}function zj(e){let t=String(e??``).trim();return!t||!t.startsWith(`/`)||t.startsWith(`//`)||/^[a-z][a-z0-9+.-]*:/i.test(t)?null:t}function Bj(e,t=[]){if(!e||!Array.isArray(t)||!t.length)return e;let n=new Map(t.filter(e=>e?.name).map(e=>[String(e.name),e]));return n.size?{...e,fields:(e.fields??[]).map(r=>{let i=n.get(String(r.name))??n.get(String(r.label))??(n.size===1&&(e.fields??[]).length===1?t[0]:null);if(!i)return r;let{name:a,...o}=i;return{...r,...o}})}:e}function Vj({apiMap:e={},extraConfigs:r={}}){let i=(0,o.useMemo)(()=>({...Oj,...e}),[e]),a=(0,o.useMemo)(()=>{let e={...Dj};return Object.entries(r).forEach(([t,n])=>{e[t]={...e[t]??{},...n}}),e},[r]),{popupKey:s}=(0,d.useParams)(),c=(0,d.useNavigate)(),{state:u={}}=(0,d.useLocation)(),[f,p]=(0,o.useState)({key:``,config:null});(0,o.useEffect)(()=>{let e=!1;if(!s||!u.moduleName)return;let t=`${u.moduleName}:${s}`;return n.Tr(u.moduleName,`popup`,s).then(n=>{e||p({key:t,config:Rj(n[0])})}).catch(()=>{e||p({key:t,config:null})}),()=>{e=!0}},[s,u.moduleName]);let m=(0,o.useMemo)(()=>{let e=a[s],t=`${u.moduleName}:${s}`,n=f.key===t?f.config:null;return Bj(n?{...e,...n}:e,u.popupAction?.popupFieldOverrides)},[f,a,s,u.moduleName,u.popupAction?.popupFieldOverrides]),h=(0,o.useMemo)(()=>({selectedIds:u.selectedIds??[],selectedRecords:u.selectedRecords??[],moduleName:u.moduleName??``,navigate:c,background:u.background??null,...u.popupContext??{}}),[c,u.selectedIds,u.selectedRecords,u.moduleName,u.popupContext,u.background]),g=(0,o.useMemo)(()=>{let e=u.popupAction;return e?.apiPath?{submit:(n,r)=>{let i=String(e.apiMethod||`POST`).toUpperCase();return t.o(t.x,e.apiPath.startsWith(`/`)?e.apiPath:`/${e.apiPath}`,{method:i,body:[`GET`,`DELETE`].includes(i)?void 0:JSON.stringify({...n,selectedIds:r.selectedIds,selectedRecords:r.selectedRecords,moduleName:r.moduleName})})}}:{}},[u.popupAction]),_=e=>{let t=u.background;if(e?.success&&m?.successNavigate){c(m.successNavigate,{replace:!0,state:{refreshTimestamp:Date.now()}});return}if(e?.success&&t?.pathname){c(`${t.pathname}${t.search??``}`,{replace:!0,state:{...t.state??{},refreshTimestamp:Date.now()}});return}c(-1)};return s===`add-batch-candidate`?(0,l.jsx)(Ij,{open:!0,context:h,onClose:_}):(0,l.jsx)(lk,{open:!0,config:m,context:h,onClose:_,api:{...i[s]??{},...g}})}var Hj={title:`Vendor Share`,maxVendorSelect:1e3,defaultTab:`myVendor`,defaultPageSize:10,vendorTabs:[{key:`myVendor`,label:`My Vendors`},{key:`allVendor`,label:`All Vendors`}],vendorColumns:[{title:`Vendor Name`,dataIndex:`vendorName`,key:`vendorName`},{title:`Email`,dataIndex:`vendorEmail`,key:`vendorEmail`},{title:`Location`,dataIndex:`vendorLocation`,key:`vendorLocation`},{title:`Updated On`,dataIndex:`updatedOn`,key:`updatedOn`}]},Uj={getVendorList:({jobId:e,limit:t,offset:n,type:r})=>on({jobId:e,limit:t,offset:n,sortBy:`new`,type:r}),getMailDetails:e=>sn(e),submit:({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})=>ln({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})},Wj=Hj.vendorColumns.map(e=>({...e,render:e=>e||`-`}));function Gj(){let e=(0,d.useNavigate)(),t=(0,d.useLocation)(),{selectedIds:n=[],selectedRecords:r=[],recipients:i=[],subject:a=``,onSend:u,moduleName:f=``,popupAction:p={}}=t.state??{},m=n[0]??r[0]?._id??r[0]?.id,[h,g]=(0,o.useState)({to:i.join(`, `),cc:``,bcc:``,subject:a,contents:``,showCc:!1,showBcc:!1}),[_,v]=(0,o.useState)(!m),[y,b]=(0,o.useState)(Hj.defaultTab),[x,S]=(0,o.useState)(``),[C,w]=(0,o.useState)([]),[T,E]=(0,o.useState)(0),[D,O]=(0,o.useState)(0),[k,A]=(0,o.useState)(0),[j,M]=(0,o.useState)(1),[N,P]=(0,o.useState)(Hj.defaultPageSize),[F,I]=(0,o.useState)(!1),[L,R]=(0,o.useState)([]);(0,o.useEffect)(()=>{if(!m)return;let e=!1;I(!0);let t=x?100:N,n=x?0:(j-1)*N;return Uj.getVendorList({jobId:m,limit:t,offset:n,type:y}).then(t=>{if(e)return;let n=t?.data?.vendorList??t?.data??[],r=t?.data?.myVendorCount??0,i=t?.data?.allVendorCount??0;w(Array.isArray(n)?n:[]),E(r),O(i),A(y===`myVendor`?r:i)}).catch(()=>{e||(w([]),A(0))}).finally(()=>{e||I(!1)}),()=>{e=!0}},[m,y,j,N,x]),(0,o.useEffect)(()=>{m&&Uj.getMailDetails(m).then(e=>g(t=>({...t,subject:e.subject||t.subject,contents:e.contents||t.contents,to:e.toMail?.length?Array.isArray(e.toMail)?e.toMail.join(`, `):String(e.toMail):t.to,cc:e.ccMail?.length?Array.isArray(e.ccMail)?e.ccMail.join(`, `):String(e.ccMail):t.cc}))).catch(()=>{}).finally(()=>v(!0))},[m]);let z=(0,o.useMemo)(()=>L.map(e=>C.find(t=>t.vendorId===e)?.vendorEmail??``).filter(Boolean),[L,C]),B=(0,o.useMemo)(()=>({...h,bcc:[...new Set([...GE(h.bcc),...z])].join(`, `),showBcc:h.showBcc||z.length>0}),[h,z]);function V(e){let t=new Set(z);g({...e,bcc:GE(e.bcc).filter(e=>!t.has(e)).join(`, `)})}let ee=(GE(B.to).length||GE(B.bcc).length)&&KE(B.to)&&KE(B.cc)&&KE(B.bcc)&&B.subject.trim(),te=e=>e===`myVendor`?T:D;function ne(){e(-1)}function re(){ee&&Uj.submit({jobId:m,toMail:GE(B.to),ccMail:GE(B.cc),bccMail:GE(B.bcc),subject:B.subject,contents:B.contents}).then(t=>{t?.status===!0?(s.message.success(t?.data||`Mail sent successfully.`),typeof u==`function`&&u({...B,message:B.contents,selectedIds:n}),e(-1)):s.message.error(t?.message||t?.data||`Failed to send mail. Please try again.`)}).catch(e=>{s.message.error(e?.message||`Failed to send mail. Please try again.`)})}let ie=(0,o.useMemo)(()=>{if(!x)return C;let e=x.toLowerCase();return C.filter(t=>(t.vendorName??``).toLowerCase().includes(e)||(t.vendorEmail??``).toLowerCase().includes(e)||(t.vendorLocation??``).toLowerCase().includes(e))},[C,x]);return(0,l.jsx)(s.Drawer,{open:!0,placement:`right`,onClose:ne,closable:!1,rootClassName:`vendor-share`,width:`95%`,footer:(0,l.jsxs)(`div`,{className:`vendor-share__footer`,children:[(0,l.jsx)(s.Button,{onClick:ne,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,disabled:!ee,onClick:re,children:`Send`})]}),children:(0,l.jsxs)(`div`,{className:`vendor-share__body`,children:[(0,l.jsxs)(`div`,{className:`vendor-share__left`,children:[(0,l.jsxs)(`div`,{className:`vendor-share__vendor-header`,children:[(0,l.jsxs)(`div`,{className:`vendor-share__vendor-header-row`,children:[(0,l.jsx)(s.Button,{type:`text`,icon:(0,l.jsx)(c.CloseOutlined,{}),onClick:ne,size:`small`,style:{marginRight:8}}),(0,l.jsx)(`span`,{className:`dynamic-popup__header-icon-box`,children:(0,l.jsx)(c.TeamOutlined,{})}),(0,l.jsx)(`span`,{className:`dynamic-popup__header-label`,children:`Vendor List`}),(0,l.jsxs)(`div`,{className:`vendor-share__vendor-search`,children:[(0,l.jsx)(c.SearchOutlined,{className:`vendor-share__search-icon`}),(0,l.jsx)(s.Input,{variant:`borderless`,placeholder:`Search vendor`,value:x,onChange:e=>{S(e.target.value),M(1)},className:`vendor-share__search-input`})]})]}),(0,l.jsx)(`div`,{className:`vendor-share__vendor-tabs`,children:Hj.vendorTabs.map(e=>(0,l.jsxs)(`span`,{className:`vendor-share__vendor-tab${y===e.key?` vendor-share__vendor-tab--active`:``}`,onClick:()=>{b(e.key),M(1),R([])},children:[e.label,` (`,te(e.key),`)`]},e.key))})]}),(0,l.jsx)(`div`,{className:`vendor-share__vendor-table-wrapper`,children:(0,l.jsx)(s.Table,{rowKey:e=>e.vendorId,columns:Wj,dataSource:ie,loading:F,pagination:!1,size:`small`,rowSelection:{selectedRowKeys:L,onChange:e=>{e.length>Hj.maxVendorSelect||R(e)}},scroll:{y:`calc(100vh - 340px)`}})}),(0,l.jsx)(`div`,{className:`vendor-share__vendor-footer`,children:(0,l.jsx)(ze,{current:j,pageSize:N,total:k,onChange:e=>M(e),onPageSizeChange:e=>P(e)})})]}),(0,l.jsx)(`div`,{className:`vendor-share__right`,children:(0,l.jsx)(iD,{value:B,onChange:V,moduleName:f,defaultTemplateId:p.defaultTemplateId??t.state?.defaultTemplateId??``,ready:_,contextRecords:r,title:`Share`,hint:`Select vendors or add email addresses`,bccHint:`Vendor emails are added automatically`,afterBcc:L.length>0?(0,l.jsxs)(`div`,{className:`vendor-share__selected-count`,children:[L.length,` / `,Hj.maxVendorSelect,` Vendors selected`]}):null})})]})})}var Kj={EMAIL:/^[a-zA-Z0-9._%+-]+@[a-zA-Z][a-zA-Z-]*\.[a-zA-Z]{2,}$/,PHONE:/^[0-9]{10}$/,PASSWORD:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/,ALPHABETS:/^[A-Za-z ]+$/,ALPHANUMERIC:/^(?!\s)[A-Za-z0-9 ]+$/,NUMBER:/^[0-9]+$/,URL:/^(https?:\/\/)?(www\.)?([a-zA-Z0-9-]+\.)+(com|org|net|in|co|io|gov|edu)(\/[^\s]*)?$/i,CANDIDATE_ID:/^[A-Za-z0-9-]+$/,REMARKS:/^[A-Za-z0-9\s.,'"\-()!?/@#$%&]*$/,DESIGNATION:/^[a-zA-Z0-9\s,.\-&()]{2,100}$/,DOB:/^(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])\/\d{4}$/,COMPANY_NAME:/^[A-Za-z0-9\s&.,'()-]+$/,FIRST_NAME:/^[A-Z][a-zA-Z]*$/,FULL_NAME:/^[A-Z][a-zA-Z]*(?: [A-Z][a-zA-Z]*)*$/,NO_SPACES:/^\S+$/,STARTS_WITH_CAPITAL:/^[A-Z].*$/},qj={SINGLE_FILE_COUNT:1,MULTI_FILE_COUNT:5,MAX_FILE_SIZE:2,ALLOWED_FILE_TYPES:[`image/jpeg`,`image/png`,`application/pdf`]},Jj={REQUIRED:e=>`Mandatory Field`,INVALID_EMAIL:`Please enter a valid email address.`,INVALID_PHONE:`Phone number must contain exactly 10 digits.`,INVALID_PASSWORD:`Password must contain uppercase, lowercase, number, special character and minimum 8 characters.`,INVALID_ALPHABETS:`Only alphabets and spaces are allowed.`,INVALID_ALPHANUMERIC:`Only letters, numbers and spaces are allowed.`,INVALID_NUMBER:`Only numbers are allowed.`,INVALID_URL:`Please enter a valid URL.`,INVALID_CANDIDATE_ID:e=>`${e} can contain only letters, numbers and hyphens.`,INVALID_REMARKS:`Remarks contain invalid characters.`,INVALID_DESIGNATION:`Designation contains invalid characters.`,INVALID_DOB:`DOB must be in MM/DD/YYYY format.`,INVALID_LINKEDIN:`Please enter a valid LinkedIn URL.`,INVALID_COMPANY_NAME:`Company name contains invalid characters.`,INVALID_FIRST_NAME:`First letter must be capital and spaces are not allowed.`,INVALID_FULL_NAME:`Each word must start with a capital letter.`,NO_SPACES_ALLOWED:`Spaces are not allowed.`,MUST_START_WITH_CAPITAL:`First letter must be capital.`,INVALID_FILE_TYPE:`Only JPG, PNG and PDF files are allowed.`,INVALID_FILE_SIZE:`File upload must be ${qj.MAX_FILE_SIZE} MB below.`,INVALID_FILE_TYPE:`Only JPG, PNG and PDF files are allowed.`,SINGLE_FILE_ONLY:`Only one file can be uploaded.`},Yj={FIRST_NAME_MIN:3,FIRST_NAME_MAX:30},Xj={REMARKS_MIN:10,REMARKS_MAX:250},Zj={removeSpaces:(e=``)=>e.replace(/\s/g,``),capitalizeFirstLetter:(e=``)=>e.charAt(0).toUpperCase()+e.slice(1),capitalizeWords:(e=``)=>e.replace(/\b\w/g,e=>e.toUpperCase()),removeExtraSpaces:(e=``)=>e.replace(/\s+/g,` `).trim(),firstNameFormatter:(e=``)=>e.replace(/\s+/g,` `).trimStart().replace(/\b\w/g,e=>e.toUpperCase()),fullNameFormatter:(e=``)=>e.replace(/\s+/g,` `).trimStart().replace(/\b\w/g,e=>e.toUpperCase()),phoneFormatter:(e=``)=>e.replace(/\D/g,``).slice(0,10),dobFormatter:(e=``)=>{let t=e.replace(/\D/g,``);return t.length<=2?t:t.length<=4?`${t.slice(0,2)}/${t.slice(2)}`:`${t.slice(0,2)}/${t.slice(2,4)}/${t.slice(4,8)}`}},Qj={required:(e=`Field`)=>({required:!0,message:Jj.REQUIRED(e)}),email:()=>({pattern:Kj.EMAIL,message:Jj.INVALID_EMAIL}),phone:()=>({pattern:Kj.PHONE,message:Jj.INVALID_PHONE}),password:()=>({pattern:Kj.PASSWORD,message:Jj.INVALID_PASSWORD}),alphabets:()=>({pattern:Kj.ALPHABETS,message:Jj.INVALID_ALPHABETS}),alphanumeric:()=>({pattern:Kj.ALPHANUMERIC,message:Jj.INVALID_ALPHANUMERIC}),number:()=>({pattern:Kj.NUMBER,message:Jj.INVALID_NUMBER}),url:()=>({pattern:Kj.URL,message:Jj.INVALID_URL}),candidateId:(e=`ID`)=>({pattern:Kj.CANDIDATE_ID,message:Jj.INVALID_CANDIDATE_ID(e)}),remarks:()=>({pattern:Kj.REMARKS,message:Jj.INVALID_REMARKS,REMARKS_MIN:`Remarks must be at least ${Xj.REMARKS_MIN} characters.`,REMARKS_MAX:`Remarks must not exceed ${Xj.REMARKS_MAX} characters.`}),designation:()=>({pattern:Kj.DESIGNATION,message:Jj.INVALID_DESIGNATION}),dob:(e=!0)=>({validator:(t,n)=>{if(!n)return e?Promise.reject(Error(`Date of Birth is required.`)):Promise.resolve();if(!Kj.DOB.test(n))return Promise.reject(Error(Jj.INVALID_DOB));let r=(0,u.default)(n,`MM/DD/YYYY`,!0);if(!r.isValid())return Promise.reject(Error(Jj.INVALID_DOB));let i=(0,u.default)().endOf(`day`);return r.isAfter(i)?Promise.reject(Error(`Date of Birth cannot be a future date.`)):i.diff(r,`year`)<21?Promise.reject(Error(`Age must be at least 21 years.`)):Promise.resolve()}}),linkedin:()=>({pattern:Kj.LINKEDIN,message:Jj.INVALID_LINKEDIN}),companyName:()=>({pattern:Kj.COMPANY_NAME,message:Jj.INVALID_COMPANY_NAME}),firstName:()=>({pattern:Kj.FIRST_NAME,message:Jj.INVALID_FIRST_NAME,FIRST_NAME_MIN:`First Name must be at least ${Yj.FIRST_NAME_MIN} characters.`,FIRST_NAME_MAX:`First Name must not exceed ${Yj.FIRST_NAME_MAX} characters.`}),firstNameMinLength:()=>({min:Yj.FIRST_NAME_MIN,message:Jj.FIRST_NAME_MIN}),firstNameMaxLength:()=>({max:Yj.FIRST_NAME_MAX,message:Jj.FIRST_NAME_MAX}),remarksMinLength:()=>({min:Xj.REMARKS_MIN,message:Jj.REMARKS_MIN}),remarksMaxLength:()=>({max:Xj.REMARKS_MAX,message:Jj.REMARKS_MAX}),fullName:()=>({pattern:Kj.FULL_NAME,message:Jj.INVALID_FULL_NAME}),noSpaces:()=>({pattern:Kj.NO_SPACES,message:Jj.NO_SPACES_ALLOWED}),startsWithCapital:()=>({pattern:Kj.STARTS_WITH_CAPITAL,message:Jj.MUST_START_WITH_CAPITAL}),fileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();for(let e of t){let t=e.originFileObj||e;if(!(t.size/1024/1024<=qj.MAX_FILE_SIZE))return s.message.error(Jj.INVALID_FILE_SIZE),Promise.reject(Error(Jj.INVALID_FILE_SIZE));if(!qj.ALLOWED_FILE_TYPES.includes(t.type))return Promise.reject(Error(Jj.INVALID_FILE_TYPE))}return Promise.resolve()}}),singleFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>qj.SINGLE_FILE_COUNT)return Promise.reject(Error(Jj.SINGLE_FILE_ONLY));let n=t[0];return n.size/1024/1024<qj.MAX_FILE_SIZE?qj.ALLOWED_FILE_TYPES.includes(n.type)?Promise.resolve():Promise.reject(Error(Jj.INVALID_FILE_TYPE)):Promise.reject(Error(Jj.INVALID_FILE_SIZE))}}),multiFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>qj.MULTI_FILE_COUNT)return Promise.reject(Error(Jj.INVALID_FILE_COUNT));for(let e of t){if(!(e.size/1024/1024<qj.MAX_FILE_SIZE))return Promise.reject(Error(Jj.INVALID_FILE_SIZE));if(!qj.ALLOWED_FILE_TYPES.includes(e.type))return Promise.reject(Error(Jj.INVALID_FILE_TYPE))}return Promise.resolve()}})},$j={beforeUpload:e=>[`image/jpeg`,`image/png`,`application/pdf`].includes(e.type)?e.size/1024/1024<=2?!1:(s.message.error(`File upload must be 2 MB below.`),s.Upload.LIST_IGNORE):(s.message.error(`Only JPG, PNG and PDF files are allowed.`),s.Upload.LIST_IGNORE)},eM=()=>{let[e]=s.Form.useForm();return(0,l.jsx)(`div`,{style:{padding:24},children:(0,l.jsxs)(s.Form,{form:e,layout:`vertical`,onFinish:e=>{console.log(`Form Values:`,e)},autoComplete:`off`,children:[(0,l.jsxs)(s.Row,{gutter:16,children:[(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Email`,name:`email`,rules:[Qj.required(`Email`),Qj.email()],children:(0,l.jsx)(s.Input,{})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Phone Number`,name:`phone`,rules:[Qj.required(`Phone Number`),Qj.phone()],validateTrigger:[`onBlur`,`onChange`],children:(0,l.jsx)(s.Input,{maxLength:10,onChange:t=>{e.setFieldsValue({phone:Zj.phoneFormatter(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Password`,name:`password`,rules:[Qj.required(`Password`),Qj.password()],children:(0,l.jsx)(s.Input.Password,{})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Full Name`,name:`fullName`,rules:[Qj.required(`Full Name`),Qj.alphabets(),Qj.firstNameMinLength(),Qj.firstNameMaxLength()],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({fullName:Zj.firstNameFormatter(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Username`,name:`username`,rules:[Qj.required(`Username`),Qj.alphanumeric()],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({username:Zj.removeExtraSpaces(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Website URL`,name:`website`,rules:[Qj.required(`Website URL`),Qj.url()],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({website:Zj.removeExtraSpaces(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`MSP Req ID`,name:`mspreqID`,rules:[Qj.required(`MSP Req ID`),Qj.candidateId(`MSP Req ID`)],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({mspreqID:Zj.removeExtraSpaces(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Candidate ID`,name:`candidateId`,rules:[Qj.required(`Candidate ID`),Qj.candidateId(`Candidate ID`)],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({candidateId:Zj.removeExtraSpaces(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:24,children:(0,l.jsx)(s.Form.Item,{label:`Remarks`,name:`remarks`,rules:[Qj.required(`Remarks`),Qj.remarks(),Qj.remarksMinLength(),Qj.remarksMaxLength()],children:(0,l.jsx)(s.Input.TextArea,{rows:4})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Designation`,name:`designation`,rules:[Qj.required(`Designation`),Qj.designation()],children:(0,l.jsx)(s.Input,{})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Date of Birth`,name:`dob`,rules:[Qj.dob()],children:(0,l.jsx)(s.Input,{placeholder:`MM/DD/YYYY`,maxLength:10,onChange:t=>{e.setFieldsValue({dob:Zj.dobFormatter(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Company Name`,name:`companyName`,rules:[Qj.required(`Company Name`),Qj.companyName()],children:(0,l.jsx)(s.Input,{})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{name:`contractType`,label:`Contract Type`,children:(0,l.jsxs)(s.Select,{showSearch:!0,allowClear:!0,filterOption:(e,t)=>(t?.label??``).toLowerCase().includes(e.toLowerCase()),children:[(0,l.jsx)(s.Select.Option,{value:`C2C`,label:`C2C`,children:`C2C`}),(0,l.jsx)(s.Select.Option,{value:`W2-Contract`,label:`W2-Contract`,children:`W2-Contract`}),(0,l.jsx)(s.Select.Option,{value:`W2-Fulltime`,label:`W2-Fulltime`,children:`W2-Fulltime`}),(0,l.jsx)(s.Select.Option,{value:`1099`,label:`1099`,children:`1099`})]})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{name:`candidateProposedRateCurrency`,label:`Currency`,children:(0,l.jsxs)(s.Select,{showSearch:!0,allowClear:!0,children:[(0,l.jsx)(s.Select.Option,{value:`$`,children:`$`}),(0,l.jsx)(s.Select.Option,{value:`₹`,children:`₹`}),(0,l.jsx)(s.Select.Option,{value:`€`,children:`€`}),(0,l.jsx)(s.Select.Option,{value:`zł`,children:`zł`}),(0,l.jsx)(s.Select.Option,{value:`£`,children:`£`}),(0,l.jsx)(s.Select.Option,{value:`kr`,children:`kr`}),(0,l.jsx)(s.Select.Option,{value:`Fr`,children:`Fr`}),(0,l.jsx)(s.Select.Option,{value:`kr`,children:`kr`})]})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Resume new`,name:`resume`,children:(0,l.jsx)(s.Upload,{beforeUpload:$j.beforeUpload,maxCount:1,children:(0,l.jsx)(s.Button,{children:`Upload Resume`})})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Documents`,name:`documents`,valuePropName:`fileList`,getValueFromEvent:e=>e?.fileList,rules:[Qj.multiFileUpload()],children:(0,l.jsx)(s.Upload,{multiple:!0,beforeUpload:$j.beforeUpload,children:(0,l.jsx)(s.Button,{children:`Upload Documents`})})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Upload File`,name:`file`,valuePropName:`fileList`,getValueFromEvent:e=>e?.fileList,rules:[Qj.fileUpload()],children:(0,l.jsx)(s.Upload,{beforeUpload:$j.beforeUpload,maxCount:1,children:(0,l.jsx)(s.Button,{children:`Upload`})})})})]}),(0,l.jsx)(s.Row,{children:(0,l.jsx)(s.Form.List,{name:`users`,children:(e,{add:t,remove:n})=>(0,l.jsxs)(l.Fragment,{children:[e.map(({key:e,name:t,...r})=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{required:!0,...r,rules:[{required:!0,message:`First name is requried`}],name:[t,`first`],children:(0,l.jsx)(s.Input,{placeholder:`First Name`})})}),(0,l.jsx)(s.Col,{span:11,children:(0,l.jsx)(s.Form.Item,{...r,required:!0,name:[t,`last`],children:(0,l.jsx)(s.Input,{placeholder:`Last Name`})})}),(0,l.jsx)(s.Col,{span:1,children:(0,l.jsx)(c.MinusCircleOutlined,{onClick:()=>n(t)})})]})),(0,l.jsx)(s.Form.Item,{children:(0,l.jsx)(s.Button,{type:`dashed`,onClick:()=>t(),block:!0,icon:(0,l.jsx)(c.PlusOutlined,{}),children:`Add field`})})]})})}),(0,l.jsxs)(s.Form.Item,{children:[(0,l.jsx)(s.Button,{type:`primary`,htmlType:`submit`,children:`Submit`}),(0,l.jsx)(s.Button,{style:{marginLeft:10},onClick:()=>e.resetFields(),children:`Reset`})]})]})})};function tM(e){return(0,l.jsx)(ub,{children:(0,l.jsx)(BE,{...e})})}var{Text:nM}=s.Typography,rM=[{label:`Total Jobs`,value:1697,icon:`fileText`},{label:`Active Jobs`,value:1685,icon:`checkCircle`},{label:`My Jobs`,value:600,icon:`user`}],iM={fileText:(0,l.jsx)(c.FileTextOutlined,{}),checkCircle:(0,l.jsx)(c.CheckCircleOutlined,{}),user:(0,l.jsx)(c.UserOutlined,{}),filter:(0,l.jsx)(c.FilterOutlined,{})};function aM({stats:e=rM}){return(0,l.jsx)(s.Card,{children:(0,l.jsx)(s.Row,{gutter:[12,12],children:e.map(e=>(0,l.jsx)(s.Col,{xs:24,sm:24,md:8,lg:8,xl:8,children:(0,l.jsxs)(s.Card,{className:`stats-inner-card`,children:[(0,l.jsxs)(s.Space,{align:`center`,children:[iM[e.icon]??iM.fileText,(0,l.jsx)(nM,{children:e.label})]}),(0,l.jsx)(s.Statistic,{value:e.value})]})},e.label))})})}var{Text:oM}=s.Typography;function sM(e){return e?.USER_NAME??e?.user_name??e?.username??e?.name??e?.full_name??e?.fullName??e?.email??`User ${e?.USER_ID??e?.user_id??`?`}`}function cM(e){return{...e,key:e.USER_ID??e.user_id??e.userId??e.id??e._id,_name:sM(e),_email:e.email??e.EMAIL??e.user_email??``,_role:e.role_name??e.roleName??e.ROLE_NAME??``,_rawRef:e}}function lM(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(0),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(1),[p,m]=(0,o.useState)(10),[h,g]=(0,o.useState)(``),_=(0,o.useCallback)(async({offset:e,limit:r,searchQuery:a}={})=>{u(!0);try{let o=await n.vr({offset:e,limit:r,searchQuery:a??``}),s=(o.users??[]).map(cM);t(s),i(o.total??s.length)}catch{s.message.error(`Failed to load users`)}finally{u(!1)}},[]);return(0,o.useEffect)(()=>{queueMicrotask(()=>{_({offset:(d-1)*p,limit:p,searchQuery:h})})},[_,d,p,h]),(0,l.jsx)(Z,{icon:(0,l.jsx)(c.TeamOutlined,{}),title:`Users`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,l.jsx)(km,{listName:`Users`,dataSource:e,fields:[{label:`Name`,value:`_name`,width:220,render:(e,t)=>(0,l.jsxs)(`div`,{children:[(0,l.jsx)(oM,{strong:!0,style:{fontSize:13},children:e}),t._email&&(0,l.jsx)(`div`,{style:{fontSize:11,color:`var(--color-text-muted)`},children:t._email})]})},{label:`Role`,value:`_role`,width:180}],loading:a,total:r,current:d,pageSize:p,onPageChange:e=>f(e),onPageSizeChange:e=>{m(e),f(1)},onSearch:e=>{g(e),f(1)}})})}var{Text:uM}=s.Typography,dM=[{key:`job`,label:`Jobs`},{key:`candidate`,label:`Candidates`},{key:`submissions`,label:`Submissions`}],fM=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`}];function pM({field:e,index:t,onToggle:n,onReorder:r}){let i=(0,o.useRef)(null),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(!1);function p(e){i.current=t,e.dataTransfer.effectAllowed=`move`,f(!0)}function m(){f(!1),u(!1)}function h(e){e.preventDefault(),u(!0)}function g(){u(!1)}function _(e){e.preventDefault(),u(!1),i.current!==null&&i.current!==t&&r(i.current,t),i.current=null}return(0,l.jsxs)(`div`,{draggable:!0,onDragStart:p,onDragEnd:m,onDragOver:h,onDragLeave:g,onDrop:_,className:`uss-field-row with-edit${a?` drag-over`:``}${d?` dragging`:``}`,children:[(0,l.jsx)(`span`,{className:`uss-drag-handle`,children:(0,l.jsx)(c.HolderOutlined,{})}),(0,l.jsxs)(`span`,{className:`uss-field-name`,children:[e.fieldName,(0,l.jsx)(`span`,{className:`uss-field-key`,children:e.fieldKey})]}),(0,l.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,l.jsx)(s.Switch,{size:`small`,checked:e.isVisible,onChange:e=>n(t,`isVisible`,e)})}),(0,l.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,l.jsx)(s.Switch,{size:`small`,checked:!!e.isEditable,onChange:e=>n(t,`isEditable`,e)})}),(0,l.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,l.jsx)(s.Switch,{size:`small`,checked:!!e.ismandatory,onChange:e=>n(t,`ismandatory`,e)})})]})}function mM({team:e,configType:t}){let[r,i]=(0,o.useState)({}),[a,c]=(0,o.useState)(!1),[u,d]=(0,o.useState)({}),[f,p]=(0,o.useState)(`job`);(0,o.useEffect)(()=>{e&&(c(!0),n.Xr(e,t).then(i).catch(()=>s.message.error(`Failed to load field config`)).finally(()=>c(!1)))},[e,t]);let m=r[f]??[];function h(e,t){i(n=>({...n,[e]:typeof t==`function`?t(n[e]??[]):t}))}function g(e,t,n){h(f,r=>r.map((r,i)=>i===e?{...r,[t]:n}:r))}function _(e,t){h(f,n=>{let r=[...n],[i]=r.splice(e,1);return r.splice(t,0,i),r.map((e,t)=>({...e,order:t}))})}async function v(){let r=f;d(e=>({...e,[r]:!0}));try{await n.Si(e,r,m,t),s.message.success(`Saved`)}catch{s.message.error(`Save failed`)}finally{d(e=>({...e,[r]:!1}))}}return(0,l.jsxs)(s.Spin,{spinning:a,children:[(0,l.jsx)(s.Tabs,{size:`small`,activeKey:f,onChange:p,items:dM.map(e=>({key:e.key,label:e.label}))}),(0,l.jsxs)(`div`,{className:`uss-field-header with-edit`,children:[(0,l.jsx)(`span`,{}),(0,l.jsx)(`span`,{children:`Field`}),(0,l.jsx)(`span`,{style:{textAlign:`center`},children:`Visible`}),(0,l.jsx)(`span`,{style:{textAlign:`center`},children:`Editable`}),(0,l.jsx)(`span`,{style:{textAlign:`center`},children:`Mandatory`})]}),(0,l.jsxs)(`div`,{className:`uss-field-list`,children:[m.length===0&&!a&&(0,l.jsx)(`div`,{className:`uss-empty`,children:`No fields found.`}),m.map((e,t)=>(0,l.jsx)(pM,{field:e,index:t,onToggle:g,onReorder:_},e.fieldKey??t))]}),(0,l.jsx)(`div`,{className:`uss-modal-footer`,children:(0,l.jsxs)(s.Button,{type:`primary`,size:`small`,loading:u[f],onClick:v,children:[`Save `,dM.find(e=>e.key===f)?.label]})})]})}function hM(){let[e,t]=(0,o.useState)(null),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(`listView`),[p,m]=(0,o.useState)([]),[h,g]=(0,o.useState)(0),[_,v]=(0,o.useState)(!1),[y,b]=(0,o.useState)(``),[x,S]=(0,o.useState)(!1),C=(0,o.useCallback)(async()=>{v(!0);try{let e=await n._r();m(e.teams),g(e.total)}catch{s.message.error(`Failed to load teams`)}finally{v(!1)}},[]);(0,o.useEffect)(()=>{C()},[C]);function w(e){t(e),f(`listView`),i(!0)}function T(e){t(e),b(e.teamName??``),u(!0)}async function E(){if(!y.trim()){s.message.warning(`Team name is required`);return}S(!0);try{await n.xi(e,{teamName:y.trim(),managerId:e.managerId,memberIds:e.memberIds}),s.message.success(`Team updated`),u(!1),C()}catch{s.message.error(`Failed to update team`)}finally{S(!1)}}return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(Z,{icon:(0,l.jsx)(c.TeamOutlined,{}),title:`Teams`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,l.jsx)(km,{listName:`Teams`,dataSource:p,fields:[{label:`Team Name`,value:`teamName`,width:200},{label:`Manager`,value:`manager`,width:200},{label:`Members`,value:`memberCount`,width:90,sorter:!1},{label:`Actions`,value:`_actions`,width:160,sorter:!1,render:(e,t)=>(0,l.jsxs)(`div`,{style:{display:`flex`,gap:4},children:[(0,l.jsx)(s.Button,{size:`small`,type:`link`,onClick:()=>T(t),children:`Edit`}),(0,l.jsx)(s.Button,{size:`small`,type:`link`,onClick:()=>w(t),children:`Configure`})]})}],loading:_,total:h})}),(0,l.jsx)(s.Modal,{open:a,onCancel:()=>u(!1),title:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(c.TeamOutlined,{style:{color:`var(--color-brand)`,marginRight:6}}),`Edit Team`]}),width:420,footer:null,destroyOnClose:!0,children:(0,l.jsxs)(`div`,{className:`uss-edit-team-body`,style:{paddingTop:12},children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`uss-edit-team-label`,children:`Team Name`}),(0,l.jsx)(s.Input,{value:y,onChange:e=>b(e.target.value),onPressEnter:E,placeholder:`Enter team name`})]}),(0,l.jsxs)(`div`,{className:`uss-modal-footer`,children:[(0,l.jsx)(s.Button,{onClick:()=>u(!1),children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:x,onClick:E,children:`Save`})]})]})}),(0,l.jsxs)(s.Modal,{className:`uss-modal`,open:r,onCancel:()=>i(!1),title:(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(c.TeamOutlined,{style:{color:`var(--color-brand)`}}),(0,l.jsxs)(`span`,{children:[`Configure: `,e?.teamName]})]}),width:720,footer:null,destroyOnClose:!0,children:[(0,l.jsx)(`div`,{style:{marginBottom:12},children:(0,l.jsx)(`div`,{className:`uss-config-toggle`,children:fM.map(e=>(0,l.jsx)(`button`,{className:`uss-config-btn${d===e.key?` active`:``}`,onClick:()=>f(e.key),children:e.label},e.key))})}),e&&(0,l.jsx)(mM,{team:e,configType:d},`${e?.teamId}-${d}`)]})]})}var gM=[`view`,`add`,`edit`,`delete`],_M={view:`View`,add:`Add`,edit:`Edit`,delete:`Delete`,sourcing:`Sourcing`,assign:`Assign`,share:`Share`,change_status:`Status`,my_jobs:`My Jobs`,all_jobs:`All Jobs`,po_msa:`PO MSA`,reApprove:`ReApprove`,sendApprove:`Send Approve`};function vM(e){return _M[e]??e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function yM(e){let t=gM.filter(t=>e.includes(t)),n=e.filter(e=>!gM.includes(e)).sort();return[...t,...n]}function bM(e){let t=new Set;return Object.values(e).forEach(({permissions:e})=>Object.keys(e??{}).forEach(e=>t.add(e))),yM([...t])}function xM(e){let t=0,n=0;return Object.entries(e).forEach(([e,{permissions:r}])=>{Object.entries(r??{}).forEach(([r,{value:i}])=>{Sx(e,r)&&(n++,i===`1`&&t++)})}),{enabled:t,total:n}}function SM(e={}){if(!e||typeof e!=`object`)return e;let t=Object.keys(e).find(e=>String(e).trim().toLowerCase()===`onboarding`);if(!t)return e;let n=e[t]??{},r={...n.permissions??{}};for(let e of[`sendApprove`,`reApprove`])Object.keys(r).some(t=>t.toLowerCase()===e.toLowerCase())||(r[e]={id:0,value:`0`});return{...e,[t]:{...n,permissions:r}}}function CM({value:e,onSave:t,className:n}){let[r,i]=(0,o.useState)(!1),[a,s]=(0,o.useState)(e);(0,o.useEffect)(()=>{s(e)},[e]);function u(){i(!1);let n=a.trim();n&&n!==e?t(n):s(e)}return r?(0,l.jsx)(`input`,{autoFocus:!0,className:`perm-inline-input${n?` ${n}`:``}`,value:a,style:{width:Math.max(48,a.length*8)},onChange:e=>s(e.target.value),onBlur:u,onKeyDown:t=>{t.key===`Enter`&&u(),t.key===`Escape`&&(i(!1),s(e)),t.stopPropagation()},onClick:e=>e.stopPropagation()}):(0,l.jsxs)(`span`,{className:`perm-editable-name${n?` ${n}`:``}`,onDoubleClick:e=>{e.stopPropagation(),i(!0)},children:[e,(0,l.jsx)(c.EditOutlined,{className:`perm-name-edit-icon`})]})}function wM({entry:e,label:t,onToggle:n,onLabelSave:r}){let[i,a]=(0,o.useState)(!1),[u,d]=(0,o.useState)(t),f=e?.value===`1`,p=!!e;(0,o.useEffect)(()=>{d(t)},[t]);function m(){a(!1);let e=u.trim();e&&e!==t?r(e):d(t)}return(0,l.jsx)(s.Tooltip,{title:p?f?`Click to disable`:`Click to enable`:`Not applicable for this module`,children:(0,l.jsxs)(`div`,{className:`perm-action-pill${f?` on`:``}${p?``:` na`}`,onClick:()=>{!i&&p&&n()},children:[(0,l.jsx)(`span`,{className:`perm-action-pill-dot${f?` on`:``}`}),i?(0,l.jsx)(`input`,{autoFocus:!0,className:`perm-pill-input`,value:u,style:{width:Math.max(36,u.length*7)},onChange:e=>d(e.target.value),onBlur:m,onKeyDown:e=>{e.key===`Enter`&&m(),e.key===`Escape`&&(a(!1),d(t)),e.stopPropagation()},onClick:e=>e.stopPropagation()}):(0,l.jsx)(`span`,{className:`perm-action-pill-label`,onDoubleClick:e=>{e.stopPropagation(),a(!0)},children:t}),f&&!i&&(0,l.jsx)(c.CheckOutlined,{className:`perm-action-pill-check`})]})})}function TM({menuName:e,menuData:t,permKeys:n,onChange:r,displayName:i,actionLabels:a,onModuleLabelSave:o,onActionLabelSave:s}){let c=t?.permissions??{},u=n.filter(t=>Sx(e,t)),d=u.filter(e=>c[e]?.value===`1`).length,f=u.filter(e=>c[e]).length,p=f>0&&d===f;return(0,l.jsxs)(`div`,{className:`perm-module-card${p?` all-on`:d>0&&!p?` some-on`:``}`,children:[(0,l.jsxs)(`div`,{className:`perm-module-card-header`,children:[(0,l.jsx)(CM,{value:i,onSave:t=>o(e,t),className:`perm-module-card-name`}),f>0&&(0,l.jsxs)(`span`,{className:`perm-module-card-badge${d>0?` active`:``}`,children:[d,`/`,f]})]}),(0,l.jsx)(`div`,{className:`perm-module-card-body`,children:u.map(t=>(0,l.jsx)(wM,{entry:c[t],label:a[t]??vM(t),onToggle:()=>r(e,t),onLabelSave:e=>s(t,e)},t))})]})}function EM({role:e,moduleLabels:t={},actionLabels:r={},onModuleLabelSave:i=()=>{},onActionLabelSave:a=()=>{}}){let[u,d]=(0,o.useState)({}),[f,p]=(0,o.useState)({}),[m,h]=(0,o.useState)(!1),[g,_]=(0,o.useState)(!1),[v,y]=(0,o.useState)(!1),b=n.Gr(e);(0,o.useEffect)(()=>{b&&(h(!0),y(!1),n.Jr(b).then(e=>{let t=SM(e);d(t),p(t)}).catch(()=>s.message.error(`Failed to load permissions`)).finally(()=>h(!1)))},[b]);function x(e,t){y(!0),p(n=>{let r=n[e]??{menuId:u[e]?.menuId??0,permissions:{}},i=r.permissions?.[t]??{id:0,value:`0`};return{...n,[e]:{...r,permissions:{...r.permissions,[t]:{...i,value:i.value===`1`?`0`:`1`}}}}})}async function S(){_(!0);try{await n.yi(b,f),d(f),y(!1),s.message.success(`Permissions saved`)}catch(e){s.message.error(e?.message||`Save failed`)}finally{_(!1)}}let C=(0,o.useMemo)(()=>Object.keys(f).sort(),[f]),w=(0,o.useMemo)(()=>bM(f),[f]),{enabled:T,total:E}=(0,o.useMemo)(()=>xM(f),[f]);return(0,l.jsxs)(s.Spin,{spinning:m,children:[(0,l.jsxs)(`div`,{className:`perm-panel-header`,children:[(0,l.jsxs)(`div`,{className:`perm-panel-title`,children:[(0,l.jsx)(c.LockOutlined,{style:{color:`var(--color-brand)`,marginRight:6}}),(0,l.jsx)(`span`,{children:e?.roleName}),!m&&E>0&&(0,l.jsxs)(s.Tag,{color:`blue`,style:{marginLeft:8,fontSize:11},children:[T,`/`,E,` enabled`]})]}),(0,l.jsx)(s.Button,{type:`primary`,size:`small`,icon:(0,l.jsx)(c.UnlockOutlined,{}),loading:g,disabled:!v,onClick:S,children:`Save Changes`})]}),(0,l.jsxs)(`div`,{className:`perm-hint`,children:[(0,l.jsx)(c.InfoCircleOutlined,{className:`perm-hint-icon`}),(0,l.jsxs)(`span`,{children:[`Click a pill to toggle. `,(0,l.jsx)(`strong`,{children:`Double-click`}),` a module name or action label to rename it — labels are saved locally.`]})]}),C.length===0&&!m?(0,l.jsx)(`div`,{className:`perm-empty`,children:`No permission entries found for this role.`}):(0,l.jsx)(`div`,{className:`perm-cards-grid`,children:C.map(e=>(0,l.jsx)(TM,{menuName:e,menuData:f[e],permKeys:w,onChange:x,displayName:t[e]??e,actionLabels:r,onModuleLabelSave:i,onActionLabelSave:a},e))})]})}var{Text:DM}=s.Typography,OM=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`}];function kM(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function AM(e){return String(e||``).trim().toLowerCase()}function jM(e){return e?.key||e?.collectionName||e?.value||``}function MM(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=jM(e);if(!t)return;let o=AM(e.key||t),s=AM(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||kM(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=AM(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:kM(t),value:t,disabled:!1}))}),n}function NM(){let[e,t]=(0,o.useState)(null),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(`listView`),[d,f]=(0,o.useState)([]),[p,m]=(0,o.useState)(0),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)([]),[y,b]=(0,o.useState)([]),[x,S]=(0,o.useState)(!1),[C,w]=(0,o.useState)(!1),T=(0,o.useMemo)(()=>_.filter(e=>!e.disabled),[_]),E=!x&&T.length===0,D=(0,o.useCallback)(async()=>{g(!0);try{let e=await n.gr();f(e.roles),m(e.total)}catch{s.message.error(`Failed to load roles`)}finally{g(!1)}},[]),O=(0,o.useCallback)(async()=>{S(!0);try{let[e,t]=await Promise.all([n.Or(),n.br()]),r=MM(e.modules,t),i=new Set(r.filter(e=>!e.disabled).map(e=>e.value));v(r),b(e=>e.filter(e=>i.has(e)))}catch{s.message.error(`Failed to load seed status`)}finally{S(!1)}},[]);(0,o.useEffect)(()=>{D()},[D]),(0,o.useEffect)(()=>{O()},[O]);async function k(){if(y.length===0){s.message.warning(E?`All modules already seeded.`:`Select at least one module to seed.`);return}w(!0);try{await n.ui(y),s.message.success(`Role field config seeded`),b([]),await O()}catch(e){s.message.error(e?.message||`Seed failed`)}finally{w(!1)}}function A(e,n=`listView`){t(e),u(n),i(!0)}return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.AppstoreOutlined,{}),title:`Field Config Seed`,style:{marginBottom:12},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[(0,l.jsx)(`div`,{style:{minWidth:320,flex:1},children:(0,l.jsx)(s.Select,{mode:`multiple`,allowClear:!0,showSearch:!0,value:y,options:_,placeholder:E?`All modules already seeded`:`Select modules or collections to seed`,disabled:x||C||E,loading:x,onChange:b,style:{width:`100%`}})}),(0,l.jsx)(s.Button,{type:`primary`,loading:C,disabled:x||y.length===0,onClick:k,children:`Seed Field Config`})]}),(0,l.jsx)(DM,{type:`secondary`,style:{display:`block`,marginTop:8,fontSize:12},children:E?`Seed is disabled because all configured modules already have role field config data.`:`Already seeded modules are disabled. New modules or collections can still be seeded.`})]}),(0,l.jsx)(Z,{icon:(0,l.jsx)(c.SafetyOutlined,{}),title:`Roles`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,l.jsx)(km,{listName:`Roles`,dataSource:d,fields:[{label:`Role Name`,value:`roleName`,width:200},{label:`Description`,value:`description`,width:240},{label:`Users`,value:`userCount`,width:70,sorter:!1},{label:`Actions`,value:`_configure`,width:200,sorter:!1,render:(e,t)=>(0,l.jsxs)(s.Space,{size:2,children:[(0,l.jsx)(s.Button,{size:`small`,type:`link`,onClick:()=>A(t),children:`Configure`}),(0,l.jsx)(s.Button,{size:`small`,type:`link`,icon:(0,l.jsx)(c.LockOutlined,{}),onClick:()=>A(t,`permissions`),children:`Permissions`})]})}],loading:h,total:p})}),(0,l.jsxs)(s.Modal,{className:`uss-modal`,open:r,onCancel:()=>i(!1),title:(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(c.SafetyOutlined,{style:{color:`var(--color-brand)`}}),(0,l.jsxs)(`span`,{children:[`Configure: `,e?.roleName]})]}),width:720,footer:null,destroyOnClose:!0,children:[(0,l.jsx)(`div`,{style:{marginBottom:12},children:(0,l.jsx)(`div`,{className:`uss-config-toggle`,children:OM.map(e=>(0,l.jsx)(`button`,{className:`uss-config-btn${a===e.key?` active`:``}`,onClick:()=>u(e.key),children:e.label},e.key))})}),e&&(a===`permissions`?(0,l.jsx)(EM,{role:e},e?.roleId):(0,l.jsx)(zx,{role:e,configType:a},`${e?.roleId}-${a}`))]})]})}var PM=`perm-module-labels`,FM=`perm-action-labels`;function IM(e){try{return JSON.parse(localStorage.getItem(e)??`{}`)}catch{return{}}}function LM(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function RM({label:e,onSave:t,onDelete:n,loading:r}){let[i,a]=(0,o.useState)(!1),[u,d]=(0,o.useState)(e);function f(){a(!1);let n=u.trim();n&&n!==e?t(n):d(e)}return(0,l.jsxs)(`div`,{className:`perm-manage-row`,children:[i?(0,l.jsx)(`input`,{autoFocus:!0,className:`perm-inline-input`,value:u,style:{flex:1,minWidth:0},onChange:e=>d(e.target.value),onBlur:f,onKeyDown:t=>{t.key===`Enter`&&f(),t.key===`Escape`&&(a(!1),d(e))}}):(0,l.jsx)(`span`,{className:`perm-manage-row-label`,children:e}),(0,l.jsxs)(`div`,{className:`perm-manage-row-actions`,children:[(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{d(e),a(!0)},loading:r}),(0,l.jsx)(s.Popconfirm,{title:`Delete this item?`,onConfirm:n,okText:`Delete`,cancelText:`Cancel`,okType:`danger`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.DeleteOutlined,{}),danger:!0})})]})]})}function zM({open:e,onClose:t}){let[r,i]=(0,o.useState)(`modules`),[a,u]=(0,o.useState)([]),[d,f]=(0,o.useState)(!1),[p,m]=(0,o.useState)(``),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)([]),[y,b]=(0,o.useState)(!1),[x,S]=(0,o.useState)(``),[C,w]=(0,o.useState)(``),[T,E]=(0,o.useState)(!1);(0,o.useEffect)(()=>{e&&(D(),O())},[e]);async function D(){f(!0);try{u(await n.Fr())}catch{s.message.error(`Failed to load modules`)}finally{f(!1)}}async function O(){b(!0);try{v(await n.Pr())}catch{s.message.error(`Failed to load actions`)}finally{b(!1)}}async function k(){let e=p.trim();if(!e){s.message.warning(`Enter a module name`);return}g(!0);try{let t=await n.Zn({menuName:e});u(e=>[...e,t]),m(``),s.message.success(`Module added`)}catch{s.message.error(`Failed to add module`)}finally{g(!1)}}async function A(e,t){try{await n.hi(e,{menuName:t}),u(n=>n.map(n=>n.MENUID===e?{...n,MENUNAME:t}:n))}catch{s.message.error(`Failed to update module`)}}async function j(e){try{await n.or(e),u(t=>t.filter(t=>t.MENUID!==e)),s.message.success(`Module deleted`)}catch{s.message.error(`Failed to delete module`)}}async function M(){let e=x.trim(),t=C.trim().toLowerCase().replace(/\s+/g,`_`);if(!e||!t){s.message.warning(`Enter both name and key`);return}E(!0);try{let r=await n.Xn({permissionName:e,permissionKey:t});v(e=>[...e,r]),S(``),w(``),s.message.success(`Action added`)}catch(e){s.message.error(e?.message?.includes(`409`)||e?.status===409?`Permission key already exists`:`Failed to add action`)}finally{E(!1)}}async function N(e,t){try{await n.mi(e,{permissionName:t}),v(n=>n.map(n=>n.permissionId===e?{...n,permissionName:t}:n))}catch{s.message.error(`Failed to update action`)}}async function P(e){try{await n.ar(e),v(t=>t.filter(t=>t.permissionId!==e)),s.message.success(`Action deleted`)}catch{s.message.error(`Failed to delete action`)}}let F=[{key:`modules`,label:`Modules`,children:(0,l.jsxs)(s.Spin,{spinning:d,children:[(0,l.jsxs)(`div`,{className:`perm-manage-add-row`,children:[(0,l.jsx)(s.Input,{placeholder:`Module name`,value:p,onChange:e=>m(e.target.value),onPressEnter:k,style:{flex:1},size:`small`}),(0,l.jsx)(s.Button,{type:`primary`,size:`small`,icon:(0,l.jsx)(c.PlusOutlined,{}),loading:h,onClick:k,children:`Add`})]}),(0,l.jsxs)(`div`,{className:`perm-manage-list`,children:[a.length===0&&!d&&(0,l.jsx)(`div`,{className:`perm-empty`,style:{paddingTop:24},children:`No modules found`}),a.map(e=>(0,l.jsx)(RM,{label:e.MENUNAME,onSave:t=>A(e.MENUID,t),onDelete:()=>j(e.MENUID)},e.MENUID))]})]})},{key:`actions`,label:`Actions`,children:(0,l.jsxs)(s.Spin,{spinning:y,children:[(0,l.jsxs)(`div`,{className:`perm-manage-add-row`,children:[(0,l.jsx)(s.Input,{placeholder:`Action name (e.g. Approve)`,value:x,onChange:e=>S(e.target.value),style:{flex:1},size:`small`}),(0,l.jsx)(s.Input,{placeholder:`Key (e.g. approve)`,value:C,onChange:e=>w(e.target.value),onPressEnter:M,style:{width:140},size:`small`}),(0,l.jsx)(s.Button,{type:`primary`,size:`small`,icon:(0,l.jsx)(c.PlusOutlined,{}),loading:T,onClick:M,children:`Add`})]}),(0,l.jsxs)(`div`,{className:`perm-manage-list`,children:[_.length===0&&!y&&(0,l.jsx)(`div`,{className:`perm-empty`,style:{paddingTop:24},children:`No actions found`}),_.map(e=>(0,l.jsx)(RM,{label:`${e.permissionName} (${e.permissionKey})`,onSave:t=>N(e.permissionId,t),onDelete:()=>P(e.permissionId)},e.permissionId))]})]})}];return(0,l.jsx)(s.Modal,{open:e,onCancel:t,title:(0,l.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(c.SettingOutlined,{style:{color:`var(--color-brand)`}}),`Manage Modules & Actions`]}),width:520,footer:null,destroyOnClose:!0,children:(0,l.jsx)(s.Tabs,{activeKey:r,onChange:i,size:`small`,items:F})})}function BM(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(null),[d,f]=(0,o.useState)(``),[p,m]=(0,o.useState)(!1),[h,g]=(0,o.useState)(()=>IM(PM)),[_,v]=(0,o.useState)(()=>IM(FM)),y=(0,o.useCallback)((e,t)=>{g(n=>{let r={...n,[e]:t};return LM(PM,r),r})},[]),b=(0,o.useCallback)((e,t)=>{v(n=>{let r={...n,[e]:t};return LM(FM,r),r})},[]);function x(){g({}),v({}),LM(PM,{}),LM(FM,{}),s.message.success(`Labels reset to defaults`)}let S=(0,o.useCallback)(async()=>{i(!0);try{let{roles:e}=await n.gr();t(e),e.length>0&&u(e[0])}catch{s.message.error(`Failed to load roles`)}finally{i(!1)}},[]);(0,o.useEffect)(()=>{S()},[S]);let C=(0,o.useMemo)(()=>{let t=d.trim().toLowerCase();return t?e.filter(e=>e.roleName.toLowerCase().includes(t)):e},[e,d]),w=Object.keys(h).length>0||Object.keys(_).length>0;return(0,l.jsxs)(`div`,{className:`perm-page`,children:[(0,l.jsxs)(Z,{className:`perm-left-card`,icon:(0,l.jsx)(c.SafetyOutlined,{}),title:`Roles`,bodyStyle:{padding:0},children:[(0,l.jsx)(`div`,{className:`perm-role-search`,children:(0,l.jsx)(s.Input,{prefix:(0,l.jsx)(c.SearchOutlined,{}),placeholder:`Search roles…`,allowClear:!0,size:`small`,value:d,onChange:e=>f(e.target.value)})}),(0,l.jsx)(s.Spin,{spinning:r,children:(0,l.jsxs)(`div`,{className:`perm-role-list`,children:[C.length===0&&!r&&(0,l.jsx)(`div`,{className:`perm-role-empty`,children:`No roles found`}),C.map(e=>{let t=a?.roleId===e.roleId,n=e.description&&e.description!==`N/A`?e.description:e.roleType===0?`Default role`:`Custom role`;return(0,l.jsxs)(`div`,{className:`perm-role-item${t?` active`:``}`,onClick:()=>u(e),children:[(0,l.jsx)(`div`,{className:`perm-role-item-name`,children:e.roleName}),(0,l.jsx)(`div`,{className:`perm-role-item-desc`,children:n})]},e.roleId)})]})})]}),(0,l.jsx)(Z,{className:`perm-right-card`,icon:(0,l.jsx)(c.LockOutlined,{}),title:`Module Permissions`,extra:(0,l.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[w&&(0,l.jsx)(`button`,{className:`perm-reset-btn`,onClick:x,children:`Reset labels`}),(0,l.jsx)(s.Button,{size:`small`,icon:(0,l.jsx)(c.SettingOutlined,{}),onClick:()=>m(!0),children:`Manage`})]}),bodyStyle:{padding:`12px 16px`},children:a?(0,l.jsx)(EM,{role:a,moduleLabels:h,actionLabels:_,onModuleLabelSave:y,onActionLabelSave:b},a.roleId):(0,l.jsx)(`div`,{className:`perm-empty`,children:`Select a role from the left to manage its permissions.`})}),(0,l.jsx)(zM,{open:p,onClose:()=>m(!1)})]})}var{Title:VM,Text:HM}=s.Typography,UM=[{label:`In Progress`,value:107,sub:`Under review`,color:`blue`},{label:`Hired`,value:2,sub:`Onboarded`,color:`green`},{label:`Project Completed`,value:2,sub:`Project cycle closed`,color:`purple`},{label:`Archive`,value:2,sub:`No longer active`,color:`peach`}];function WM({items:e=UM}){return(0,l.jsx)(s.Card,{className:`onboarding-card`,title:(0,l.jsx)(VM,{level:5,children:`Onboarding`}),extra:(0,l.jsx)(s.Button,{type:`link`,children:`View all`}),children:(0,l.jsx)(s.Row,{gutter:[12,12],children:e.map(e=>(0,l.jsx)(s.Col,{xs:12,sm:6,md:6,lg:12,xl:12,children:(0,l.jsxs)(`div`,{className:`onboarding-item ${e.color}`,children:[(0,l.jsx)(HM,{className:`onboarding-item-label`,children:e.label}),(0,l.jsx)(s.Statistic,{value:e.value,className:`onboarding-stat`}),(0,l.jsx)(`div`,{className:`onboarding-item-footer`,children:(0,l.jsx)(HM,{className:`onboarding-item-sub`,children:e.sub})})]})},e.label))})})}var{Text:GM,Title:KM}=s.Typography,qM=[{group:`Dashboard`,items:[{id:`dashboard`,label:`Admin Dashboard`,icon:(0,l.jsx)(c.DashboardOutlined,{})}]},{group:`Settings`,items:[{id:`org`,label:`Organization`,icon:(0,l.jsx)(c.BankOutlined,{}),heading:`Organization Settings`,desc:`Manage your company profile and location details`,cards:[{label:`Company Information`,icon:(0,l.jsx)(c.BankOutlined,{}),desc:`Manage company profile, address and business details.`},{label:`Location`,icon:(0,l.jsx)(c.BuildOutlined,{}),desc:`Manage office locations, branches and regions.`}]},{id:`users`,label:`Users`,icon:(0,l.jsx)(c.UserOutlined,{}),heading:`Users`,desc:`Manage platform users and configure their field views.`,component:`users`},{id:`teams`,label:`Teams`,icon:(0,l.jsx)(c.TeamOutlined,{}),heading:`Teams`,desc:`Organize users into teams and configure field visibility per team.`,component:`teams`},{id:`roles`,label:`Roles`,icon:(0,l.jsx)(c.SafetyOutlined,{}),heading:`Roles`,desc:`Control permissions and configure field visibility per role.`,component:`roles`},{id:`permissions`,label:`Permissions`,icon:(0,l.jsx)(c.LockOutlined,{}),heading:`Permissions`,desc:`Manage module-wise action permissions (view, add, edit, delete, and more) per role.`,component:`permissions`},{id:`templates`,label:`Templates`,icon:(0,l.jsx)(c.FileTextOutlined,{}),heading:`Templates`,desc:`Email and signature templates for communications`,component:`templates`},{id:`ai-services`,label:`AI Services`,icon:(0,l.jsx)(c.ThunderboltOutlined,{}),heading:`AI Services`,desc:`Register the AI/automation backends (base URL + auth) that admin-configured AI Actions call.`,component:`ai-services`},{id:`bgc-integration`,label:`Integrations`,icon:(0,l.jsx)(c.SafetyOutlined,{}),heading:`Integrations`,desc:`Manage manual and API integrations used across application workflows.`,component:`bgc-integration`}]},{group:`Clients`,items:[{id:`clients`,label:`Clients`,icon:(0,l.jsx)(c.BankOutlined,{}),heading:`Clients`,desc:`Manage client accounts and settings`,cards:[{label:`Clients`,icon:(0,l.jsx)(c.BankOutlined,{}),desc:`Manage client companies and account details.`}]}]},{group:`Forms`,items:[{id:`form-groups`,label:`Form Groups`,icon:(0,l.jsx)(c.AppstoreAddOutlined,{}),heading:`Form Groups`,desc:`Define field groups for module add/edit forms with validations and dropdown sources.`,component:`form-groups`},{id:`detail-groups`,label:`Detail Groups`,icon:(0,l.jsx)(c.AppstoreOutlined,{}),heading:`Detail Groups`,desc:`Customize the detail view per module: labels, prefix/suffix, colour, capitalization, reference lookups and merged fields.`,component:`detail-groups`},{id:`row-actions`,label:`Actions`,icon:(0,l.jsx)(c.ToolOutlined,{}),heading:`Actions`,desc:`Configure which action buttons appear per row in each module's list view, scoped per role.`,component:`row-actions`}]},{group:`Master`,items:[{id:`jobs`,label:`Jobs`,icon:(0,l.jsx)(c.AppstoreOutlined,{}),heading:`Jobs Master`,desc:`Configure job sources and status types`,cards:[{label:`Sources`,icon:(0,l.jsx)(c.AppstoreOutlined,{}),desc:`Manage job source master values.`},{label:`Job Status`,icon:(0,l.jsx)(c.CheckCircleOutlined,{}),desc:`Configure job workflow status.`}]},{id:`candidates`,label:`Candidates`,icon:(0,l.jsx)(c.UserOutlined,{}),heading:`Candidates Master`,desc:`Skills, sources and work authorization settings`,cards:[{label:`Sources`,icon:(0,l.jsx)(c.AppstoreOutlined,{}),desc:`Manage candidate source values.`},{label:`Skills`,icon:(0,l.jsx)(c.SettingOutlined,{}),desc:`Manage skill master data.`},{label:`Work Authorization`,icon:(0,l.jsx)(c.SafetyOutlined,{}),desc:`Manage visa and authorization types.`}]},{id:`submissions`,label:`Submissions`,icon:(0,l.jsx)(c.FileTextOutlined,{}),heading:`Submissions Master`,desc:`Rejection reasons and submission status configuration`,cards:[{label:`Rejection Reasons`,icon:(0,l.jsx)(c.FileTextOutlined,{}),desc:`Manage common rejection reasons.`},{label:`Client Submission Status`,icon:(0,l.jsx)(c.CheckCircleOutlined,{}),desc:`Manage client submission statuses.`}]},{id:`clientmaster`,label:`Client Master`,icon:(0,l.jsx)(c.BankOutlined,{}),heading:`Client Master`,desc:`Payment terms, client types and contact types`,cards:[{label:`Payment Terms`,icon:(0,l.jsx)(c.FileTextOutlined,{}),desc:`Manage billing and payment terms.`},{label:`Client Type`,icon:(0,l.jsx)(c.AppstoreOutlined,{}),desc:`Classify client business types.`},{label:`Client Contact Type`,icon:(0,l.jsx)(c.TeamOutlined,{}),desc:`Manage client contact categories.`}]}]}],JM=[{label:`Sourced`,count:312,color:`#378ADD`,pct:35},{label:`Screened`,count:223,color:`#7F77DD`,pct:25},{label:`Interview`,count:161,color:`#1D9E75`,pct:18},{label:`Offered`,count:107,color:`#EF9F27`,pct:12},{label:`Rejected`,count:89,color:`#E24B4A`,pct:10}],YM=[{name:`Tcs`,jobs:14,candidates:86},{name:`Empasis`,jobs:9,candidates:64},{name:`NovaSystems`,jobs:7,candidates:51},{name:`Brightwave`,jobs:5,candidates:38}],XM=[{text:`New candidate Ravi Kumar added to Java Developer role`,time:`2 min ago`,color:`#378ADD`},{text:`Submission approved by Acme Corp for Sr. React Dev`,time:`18 min ago`,color:`#1D9E75`},{text:`User Priya S. added to Recruiters team`,time:`1 hr ago`,color:`#7F77DD`},{text:`Job Data Analyst — TechFlow moved to archived`,time:`3 hr ago`,color:`#EF9F27`},{text:`Candidate rejected — work authorization mismatch`,time:`5 hr ago`,color:`#E24B4A`}];function ZM(){return(0,l.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:16},children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.DashboardOutlined,{}),title:`Admin Dashboard`,children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(KM,{level:5,children:`Admin Dashboard`}),(0,l.jsx)(GM,{type:`secondary`,children:`Overview of jobs, candidates, onboarding and recent activity`})]}),(0,l.jsx)(`div`,{className:`admin-dashboard-stats`,children:(0,l.jsx)(aM,{stats:[{label:`Total Jobs`,value:1697,icon:`fileText`},{label:`Active Jobs`,value:1685,icon:`checkCircle`},{label:`My Jobs`,value:600,icon:`user`},{label:`Total Candidates`,value:4320,icon:`team`},{label:`Submissions`,value:892,icon:`fileText`}]})}),(0,l.jsxs)(`div`,{className:`admin-dashboard-mid-row`,children:[(0,l.jsx)(WM,{}),(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.AppstoreOutlined,{}),title:`Candidate Pipeline`,children:[(0,l.jsx)(GM,{type:`secondary`,style:{fontSize:12},children:`By stage (892 total)`}),(0,l.jsx)(`div`,{className:`admin-pipeline-bar`,children:JM.map(e=>(0,l.jsx)(`div`,{className:`admin-pipeline-seg`,style:{width:`${e.pct}%`,background:e.color}},e.label))}),(0,l.jsx)(`div`,{className:`admin-pipeline-legend`,children:JM.map(e=>(0,l.jsxs)(`div`,{className:`admin-pipeline-legend-item`,children:[(0,l.jsx)(`span`,{className:`admin-pipeline-dot`,style:{background:e.color}}),e.label,` `,e.count]},e.label))}),(0,l.jsx)(`div`,{className:`admin-divider`}),(0,l.jsx)(GM,{strong:!0,style:{fontSize:12},children:`Submission status`}),(0,l.jsxs)(`div`,{className:`admin-sub-status-list`,style:{marginTop:6},children:[(0,l.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,l.jsx)(GM,{style:{fontSize:13},children:`Pending client review`}),(0,l.jsx)(`span`,{className:`admin-badge warn`,children:`312`})]}),(0,l.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,l.jsx)(GM,{style:{fontSize:13},children:`Client approved`}),(0,l.jsx)(`span`,{className:`admin-badge success`,children:`248`})]}),(0,l.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,l.jsx)(GM,{style:{fontSize:13},children:`Rejected`}),(0,l.jsx)(`span`,{className:`admin-badge danger`,children:`89`})]})]})]})]}),(0,l.jsxs)(`div`,{className:`admin-dashboard-bottom-row`,children:[(0,l.jsx)(Z,{icon:(0,l.jsx)(c.BankOutlined,{}),title:`Top Clients`,extra:(0,l.jsx)(s.Button,{type:`link`,size:`small`,children:`View all`}),children:YM.map(e=>(0,l.jsxs)(`div`,{className:`admin-client-row`,children:[(0,l.jsxs)(`div`,{className:`admin-client-left`,children:[(0,l.jsx)(`div`,{className:`admin-client-icon`,children:(0,l.jsx)(c.BankOutlined,{})}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`admin-client-name`,children:e.name}),(0,l.jsxs)(`div`,{className:`admin-client-sub`,children:[e.jobs,` open jobs`]})]})]}),(0,l.jsxs)(`div`,{className:`admin-client-right`,children:[(0,l.jsx)(`div`,{className:`admin-client-val`,children:e.candidates}),(0,l.jsx)(`div`,{className:`admin-client-sub`,children:`candidates`})]})]},e.name))}),(0,l.jsx)(Z,{icon:(0,l.jsx)(c.BellOutlined,{}),title:`Recent Activity`,children:XM.map((e,t)=>(0,l.jsxs)(`div`,{className:`admin-activity-row`,children:[(0,l.jsx)(`div`,{className:`admin-activity-dot`,style:{background:e.color}}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`admin-activity-text`,children:e.text}),(0,l.jsx)(`div`,{className:`admin-activity-time`,children:e.time})]})]},t))})]}),(0,l.jsx)(Z,{icon:(0,l.jsx)(c.SettingOutlined,{}),title:`Admin Configuration Overview`,extra:(0,l.jsx)(s.Button,{type:`link`,size:`small`,children:`Manage`}),children:(0,l.jsxs)(s.Row,{gutter:[24,0],children:[(0,l.jsxs)(s.Col,{span:8,children:[(0,l.jsx)(GM,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`Settings`}),[[`Organization`,2],[`User Settings`,4],[`Templates`,2]].map(([e,t])=>(0,l.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,l.jsx)(GM,{style:{fontSize:12},children:e}),(0,l.jsxs)(`span`,{className:`admin-badge info`,children:[t,` items`]})]},e))]}),(0,l.jsxs)(s.Col,{span:8,children:[(0,l.jsx)(GM,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`Master`}),[[`Jobs`,2],[`Candidates`,3],[`Submissions`,2]].map(([e,t])=>(0,l.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,l.jsx)(GM,{style:{fontSize:12},children:e}),(0,l.jsxs)(`span`,{className:`admin-badge info`,children:[t,` items`]})]},e))]}),(0,l.jsxs)(s.Col,{span:8,children:[(0,l.jsx)(GM,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`System`}),[[`Total Groups`,4],[`Total Modules`,9],[`Config Items`,19]].map(([e,t])=>(0,l.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,l.jsx)(GM,{style:{fontSize:12},children:e}),(0,l.jsx)(GM,{strong:!0,style:{fontSize:12},children:t})]},e))]})]})})]})}function QM({activeSection:e,activeGroup:t,filteredCards:n,searchText:r,setSearchText:i,allItems:a,handleNav:o}){return(0,l.jsxs)(s.Row,{gutter:[16,16],children:[(0,l.jsx)(s.Col,{span:24,children:(0,l.jsxs)(Z,{icon:e?.icon,title:e?.heading,extra:(0,l.jsx)(s.Input,{className:`admin-search`,prefix:(0,l.jsx)(c.SearchOutlined,{}),placeholder:`Search settings…`,allowClear:!0,value:r,onChange:e=>i(e.target.value)}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)(KM,{level:5,children:e?.heading}),(0,l.jsx)(GM,{type:`secondary`,children:e?.desc})]})}),(0,l.jsx)(s.Col,{xs:24,xl:16,style:{alignSelf:`flex-start`},children:(0,l.jsx)(Z,{icon:(0,l.jsx)(c.AppstoreOutlined,{}),title:`Configuration Items`,extra:(0,l.jsxs)(GM,{type:`secondary`,children:[n.length,` item`,n.length===1?``:`s`]}),children:(0,l.jsx)(s.Row,{gutter:[14,14],children:n.length>0?n.map(e=>(0,l.jsx)(s.Col,{xs:24,sm:12,xl:8,children:(0,l.jsxs)(`div`,{className:`admin-config-item`,children:[(0,l.jsx)(`div`,{className:`admin-config-top-bar`}),(0,l.jsxs)(`div`,{className:`admin-config-body`,children:[(0,l.jsx)(`div`,{className:`admin-config-icon`,children:e.icon}),(0,l.jsxs)(`div`,{className:`admin-config-text`,children:[(0,l.jsx)(`span`,{className:`admin-config-label`,children:e.label}),(0,l.jsx)(`span`,{className:`admin-config-desc`,children:e.desc})]})]}),(0,l.jsx)(`div`,{className:`admin-config-divider`}),(0,l.jsx)(s.Button,{type:`link`,size:`small`,className:`admin-config-manage`,icon:(0,l.jsx)(c.RightOutlined,{}),iconPosition:`end`,children:`Manage`})]})},e.label)):(0,l.jsx)(s.Col,{span:24,children:(0,l.jsx)(`div`,{className:`admin-config-empty`,children:(0,l.jsx)(s.Empty,{description:`No settings found`,image:s.Empty.PRESENTED_IMAGE_SIMPLE})})})})})}),(0,l.jsx)(s.Col,{xs:24,xl:8,style:{alignSelf:`flex-start`},children:(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.FileTextOutlined,{}),title:`Section Overview`,children:[(0,l.jsx)(`div`,{className:`admin-overview-list`,children:qM.filter(e=>e.group!==`Dashboard`).map(e=>{let n=e.group===t?.group;return(0,l.jsxs)(`div`,{className:`admin-overview-item${n?` active`:``}`,onClick:()=>{let t=e.items[0];t&&o(t.id)},children:[(0,l.jsxs)(`div`,{className:`admin-overview-left`,children:[(0,l.jsx)(`div`,{className:`admin-overview-icon`,children:e.items[0]?.icon}),(0,l.jsxs)(`div`,{className:`admin-overview-text`,children:[(0,l.jsx)(`span`,{className:`admin-overview-name`,children:e.group}),(0,l.jsxs)(`span`,{className:`admin-overview-sub`,children:[e.items.length,` module`,e.items.length===1?``:`s`]})]})]}),(0,l.jsx)(`span`,{className:`admin-overview-count${n?` active`:``}`,children:e.items.length})]},e.group)})}),(0,l.jsxs)(`div`,{className:`admin-overview-footer`,children:[(0,l.jsx)(`span`,{className:`admin-overview-footer-label`,children:`Total configuration items`}),(0,l.jsx)(`span`,{className:`admin-overview-footer-value`,children:a.filter(e=>e.cards).reduce((e,t)=>e+t.cards.length,0)})]})]})})]})}function $M(){let[e,t]=(0,o.useState)(`dashboard`),[n,r]=(0,o.useState)(``),i=(0,o.useMemo)(()=>qM.flatMap(e=>e.items),[]),a=(0,o.useMemo)(()=>i.find(t=>t.id===e),[i,e]),u=(0,o.useMemo)(()=>qM.find(t=>t.items.some(t=>t.id===e)),[e]),d=(0,o.useMemo)(()=>{if(!a?.cards)return[];let e=n.trim().toLowerCase();return e?a.cards.filter(t=>t.label.toLowerCase().includes(e)||t.desc.toLowerCase().includes(e)):a.cards},[a,n]),f=(0,o.useMemo)(()=>qM.map(e=>({key:e.group,type:`group`,label:e.group,children:e.items.map(e=>({key:e.id,icon:e.icon,label:e.label}))})),[]),p=e=>{t(e),r(``)};return e===`dashboard`||a?.heading,(0,l.jsxs)(`main`,{className:`admin-page`,children:[(0,l.jsx)(`div`,{className:`admin-breadcrumb`,children:(0,l.jsx)(s.Breadcrumb,{items:[{title:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(c.HomeOutlined,{}),` Home`]})},{title:`Admin`}]})}),(0,l.jsxs)(s.Row,{gutter:[16,16],className:`admin-wrapper`,children:[(0,l.jsx)(s.Col,{xs:24,lg:6,xl:5,children:(0,l.jsxs)(Z,{title:`Admin Console`,icon:(0,l.jsx)(c.SettingOutlined,{}),children:[(0,l.jsxs)(`div`,{className:`admin-sidebar-banner`,children:[(0,l.jsx)(`span`,{className:`admin-sidebar-banner-title`,children:`Admin Panel`}),(0,l.jsx)(`span`,{className:`admin-sidebar-banner-sub`,children:`Configuration Center`}),(0,l.jsxs)(s.Row,{gutter:[8,0],children:[(0,l.jsx)(s.Col,{span:12,children:(0,l.jsxs)(`div`,{className:`admin-sidebar-pill`,children:[(0,l.jsx)(`span`,{className:`admin-sidebar-pill-label`,children:`Groups`}),(0,l.jsx)(`span`,{className:`admin-sidebar-pill-value`,children:qM.length})]})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsxs)(`div`,{className:`admin-sidebar-pill`,children:[(0,l.jsx)(`span`,{className:`admin-sidebar-pill-label`,children:`Modules`}),(0,l.jsx)(`span`,{className:`admin-sidebar-pill-value`,children:i.length})]})})]})]}),(0,l.jsx)(s.Menu,{mode:`inline`,selectedKeys:[e],items:f,onClick:({key:e})=>p(e),className:`admin-sidebar-menu`})]})}),(0,l.jsx)(s.Col,{xs:24,lg:18,xl:19,children:e===`dashboard`?(0,l.jsx)(ZM,{}):a?.component===`form-groups`?(0,l.jsx)(IC,{}):a?.component===`detail-groups`?(0,l.jsx)(mw,{}):a?.component===`row-actions`?(0,l.jsx)(rT,{}):a?.component===`users`?(0,l.jsx)(lM,{}):a?.component===`teams`?(0,l.jsx)(hM,{}):a?.component===`roles`?(0,l.jsx)(NM,{}):a?.component===`permissions`?(0,l.jsx)(BM,{}):a?.component===`templates`?(0,l.jsx)(hT,{}):a?.component===`ai-services`?(0,l.jsx)(yT,{}):a?.component===`bgc-integration`?(0,l.jsx)(TT,{}):(0,l.jsx)(QM,{activeSection:a,activeGroup:u,filteredCards:d,searchText:n,setSearchText:r,allItems:i,handleNav:p})})]})]})}var{Title:eN}=s.Typography;function tN(){let e=(0,d.useNavigate)(),{state:t}=(0,d.useLocation)(),n=t?.moduleName||`stickyNotes`,r=t?.title||`Sticky Notes`,i={...t?.request,params:{...t?.request?.params,limit:200,offset:0}};return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(s.Button,{type:`text`,icon:(0,l.jsx)(c.ArrowLeftOutlined,{}),onClick:()=>e(-1),style:{marginBottom:12},children:`Back`}),(0,l.jsx)(Pt,{moduleName:n,title:r,columns:4,request:i,viewAll:!1})]})}var{Text:nN,Title:rN}=s.Typography,iN=10485760,aN=`/templates/test_cases_flow_template.base64.txt`,oN=`test_cases_flow_template.xlsx`,sN=`module | subModule | step_order | description | actions | key | value | expected | scenario`,cN={idle:0,module_set:1,encoding:1,validating:2,preview:3,inserting:3,done:4,error:1},lN=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Bulk upload`,href:`/bulk-upload`}];function uN(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result).split(`,`)[1]),r.onerror=n,r.readAsDataURL(e)})}function dN(e){return e.filter(e=>e.row_status===`valid`).map(e=>{let t={...e};return delete t.row_status,delete t.errors,t})}function fN(e){return e.flatMap(e=>(e.errors??[]).map(t=>({id:e.id,...t})))}function pN({errors:e}){return(0,l.jsx)(`div`,{className:`bulk-tooltip-errors`,children:(e??[]).map((e,t)=>(0,l.jsx)(`div`,{children:e.message},`${e.field}-${t}`))})}function mN({errors:e,expanded:t,onToggle:n,onSummaryClick:r}){return e.length===0?null:(0,l.jsxs)(`div`,{className:`bulk-error-banner`,children:[(0,l.jsxs)(`div`,{className:`bulk-error-summary`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`bulk-error-summary-main`,onClick:r,"aria-label":`Scroll to first invalid row`,children:[(0,l.jsx)(c.ExclamationCircleOutlined,{className:`bulk-error-icon`}),(0,l.jsxs)(`span`,{children:[e.length,` validation error(s) found`]})]}),(0,l.jsx)(s.Button,{type:`link`,onClick:n,"aria-expanded":t,children:t?`Hide Errors`:`View Errors`})]}),t&&(0,l.jsx)(`div`,{className:`bulk-error-list`,role:`region`,"aria-label":`Validation error details`,children:e.map((e,t)=>(0,l.jsxs)(`div`,{className:`bulk-error-line`,children:[(0,l.jsxs)(`span`,{className:`bulk-row-chip`,children:[`Row `,e.id]}),(0,l.jsx)(`span`,{children:e.message})]},`${e.id}-${e.field}-${t}`))})]})}function hN({rows:e,view:t,onViewChange:n,onConfirm:r,onReset:i,saving:a,firstInvalidRowId:o,firstInvalidRowRef:u}){let d=e.filter(e=>e.row_status===`invalid`),f=t===`errors`?d:e,p=d.length>0||a;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(s.Row,{justify:`space-between`,align:`middle`,gutter:[16,16],className:`bulk-table-toolbar`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsxs)(s.Space.Compact,{children:[(0,l.jsx)(s.Button,{type:t===`all`?`primary`:`default`,onClick:()=>n(`all`),children:`All rows`}),(0,l.jsx)(s.Button,{type:t===`errors`?`primary`:`default`,onClick:()=>n(`errors`),children:`Errors only`})]})}),(0,l.jsx)(s.Col,{children:(0,l.jsxs)(nN,{type:`secondary`,children:[e.length,` row(s)`]})})]}),(0,l.jsx)(`div`,{className:`bulk-table-wrap`,children:(0,l.jsxs)(`table`,{className:`bulk-preview-table`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:`bulk-col-row`,children:`Row`}),(0,l.jsx)(`th`,{className:`bulk-col-flow`,children:`Submodule`}),(0,l.jsx)(`th`,{className:`bulk-col-description`,children:`Description`}),(0,l.jsx)(`th`,{className:`bulk-col-keyword`,children:`Action`}),(0,l.jsx)(`th`,{className:`bulk-col-target`,children:`Key`}),(0,l.jsx)(`th`,{className:`bulk-col-status`,children:`Status`}),(0,l.jsx)(`th`,{className:`bulk-col-error`,children:`Error`})]})}),(0,l.jsx)(`tbody`,{children:f.map(e=>{let t=e.errors??[],n=e.row_status===`invalid`;return(0,l.jsxs)(`tr`,{ref:n&&e.id===o?u:null,className:n?`bulk-row-invalid`:``,children:[(0,l.jsx)(`td`,{children:e.id}),(0,l.jsx)(`td`,{title:e.submodule,children:e.submodule}),(0,l.jsx)(`td`,{title:e.description,children:e.description?e.description:(0,l.jsx)(`span`,{className:`bulk-empty-text`,children:`-empty-`})}),(0,l.jsx)(`td`,{children:(0,l.jsx)(`code`,{className:`bulk-code-chip`,children:e.actions})}),(0,l.jsx)(`td`,{title:e.key,children:e.key}),(0,l.jsx)(`td`,{children:n?(0,l.jsx)(s.Tag,{color:`red`,children:`Error`}):(0,l.jsx)(s.Tag,{color:`green`,children:`Valid`})}),(0,l.jsx)(`td`,{children:n?(0,l.jsx)(s.Tooltip,{title:(0,l.jsx)(pN,{errors:t}),placement:`left`,children:(0,l.jsxs)(`button`,{type:`button`,className:`bulk-error-info`,"aria-label":`View ${t.length} error(s) for row ${e.id}`,children:[(0,l.jsx)(c.InfoCircleOutlined,{}),(0,l.jsx)(s.Badge,{count:t.length,size:`small`})]})}):(0,l.jsx)(`span`,{className:`bulk-error-none`,children:`-`})})]},`${e.id}-${e.step_order}`)})})]})}),(0,l.jsxs)(s.Space,{className:`bulk-actions`,children:[(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:i,children:`Reset`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),loading:a,disabled:p,onClick:r,children:d.length>0?`Fix ${d.length} error(s) to proceed`:`Save to database`})]})]})}function gN(){let e=(0,d.useNavigate)(),r=(0,o.useMemo)(()=>t.l(),[]),i=(0,o.useRef)(null),a=(0,o.useRef)(null),[u,f]=(0,o.useState)([]),[p,m]=(0,o.useState)(``),[h,g]=(0,o.useState)(`idle`),[_,v]=(0,o.useState)(!1),[y,b]=(0,o.useState)(null),[x,S]=(0,o.useState)([]),[C,w]=(0,o.useState)(`all`),[T,E]=(0,o.useState)(null),[D,O]=(0,o.useState)(null),[k,A]=(0,o.useState)(!1),j=u.map(e=>({value:e.modulename,label:e.modulename})),M=fN(x),N=h===`encoding`||h===`validating`,P=!!p&&!N,F=cN[h]??0,I=x.find(e=>e.row_status===`invalid`)?.id,L=(0,o.useCallback)(()=>{m(``),g(`idle`),v(!1),b(null),S([]),w(`all`),E(null),O(null),i.current&&(i.current.value=``)},[]);(0,o.useEffect)(()=>{async function e(){try{let e=await Db({project:r?.name??``,activeOnly:!0});f(e?.items??[])}catch(e){console.error(e),s.message.error(`Unable to load modules.`)}}e()},[r?.name]);let R=e=>{m(e??``),S([]),O(null),E(null),b(null),A(!1),g(e?`module_set`:`idle`)},z=async e=>{if(!e||!P)return;let t=e.name.split(`.`).pop()?.toLowerCase();if(![`xlsx`,`csv`].includes(t)){g(`module_set`),E({message:`Invalid file type. Please upload an Excel .xlsx or CSV .csv file.`});return}if(e.size>iN){g(`module_set`),E({message:`File must be 10 MB or smaller.`});return}E(null),S([]),O(null),b({name:e.name,size:e.size}),g(`encoding`);try{let n=await uN(e);g(`validating`);let i=await Sb({filename:e.name,project:r?.name??``,module:p,file_base64:n,file_type:t});S(i?.rows??[]),w(`all`),g(`preview`)}catch(e){console.error(e),E(e.payload??{code:`NETWORK_ERROR`,message:e.message||`Could not reach the server.`}),g(`error`)}},B=async()=>{try{let e=await fetch(aN);if(!e.ok)throw Error(`Template file not found (${e.status})`);let t=(await e.text()).trim(),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);let i=new Blob([r],{type:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=oN,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(a),s.message.success(`Sample template downloaded.`)}catch(e){console.error(e),s.message.error(`Unable to download sample template.`)}},V=async()=>{g(`inserting`),E(null);try{let t=await Cb({project:r?.name??``,module:p,uploaded_by:localStorage.getItem(`user_Email`)??``,rows:dN(x)});O(t),g(`done`),s.message.success(`Bulk upload saved. Redirecting to view test cases...`),window.setTimeout(()=>e(`/viewTestCase`),900)}catch(e){console.error(e),E(e.payload??{code:`NETWORK_ERROR`,message:e.message||`Could not reach the server.`}),g(`preview`)}},ee=(0,o.useCallback)(()=>{a.current?.scrollIntoView({behavior:`smooth`,block:`center`})},[]),te=[`bulk-dropzone`,_?`bulk-dropzone-dragging`:``,y?`bulk-dropzone-has-file`:``,T&&h!==`preview`?`bulk-dropzone-error`:``,p?``:`bulk-dropzone-disabled`].filter(Boolean).join(` `);return(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:lN})}),r?.name&&(0,l.jsx)(s.Col,{children:(0,l.jsx)(nN,{strong:!0,children:r.name})})]}),(0,l.jsxs)(`div`,{className:`zt-page zt-page-wide bulk-page`,children:[(0,l.jsxs)(`div`,{className:`bulk-header`,children:[(0,l.jsx)(rN,{level:3,children:`Bulk upload test cases`}),(0,l.jsxs)(s.Space,{direction:`vertical`,size:4,children:[(0,l.jsx)(nN,{type:`secondary`,children:sN}),(0,l.jsx)(nN,{type:`secondary`,children:`Use the sample template for the required columns. Uploaded rows are saved as Active by default.`})]})]}),(0,l.jsx)(`div`,{className:`bulk-stepbar`,children:[`Select`,`Upload`,`Validate`,`Save`].map((e,t)=>(0,l.jsxs)(`span`,{className:t<F?`bulk-step-active`:``,children:[t+1,` `,e]},e))}),(0,l.jsx)(s.Card,{className:`v1-card zt-fall`,title:`1. Module selector`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,className:`bulk-module-select`,placeholder:`Choose a module`,options:j,value:p||void 0,onChange:R})}),p&&(0,l.jsxs)(s.Card,{className:`v1-card zt-fall`,title:`2. File upload`,extra:(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.DownloadOutlined,{}),onClick:B,children:`Download Sample Template`}),children:[(0,l.jsx)(s.Alert,{type:`info`,showIcon:!0,message:`First time uploading?`,description:`Download the sample template, keep the column names unchanged, fill your test steps, and upload either .xlsx or .csv.`,className:`bulk-inline-alert`}),(0,l.jsxs)(`button`,{type:`button`,className:te,disabled:!P,onClick:()=>i.current?.click(),onDragOver:e=>{e.preventDefault(),P&&v(!0)},onDragLeave:()=>v(!1),onDrop:e=>{e.preventDefault(),v(!1),z(e.dataTransfer.files?.[0])},children:[(0,l.jsx)(c.CloudUploadOutlined,{className:`bulk-upload-icon`}),y?(0,l.jsxs)(`span`,{className:`bulk-file-chip`,children:[y.name,` - `,Math.ceil(y.size/1024),` KB`]}):(0,l.jsx)(`span`,{children:`Drag & drop here, or click to browse`})]}),(0,l.jsx)(`input`,{ref:i,hidden:!0,type:`file`,accept:`.xlsx,.csv`,onChange:e=>z(e.target.files?.[0])}),N&&(0,l.jsx)(s.Progress,{percent:h===`encoding`?45:82,showInfo:!1,size:`small`}),T&&h!==`preview`&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`})]}),x.length>0&&(0,l.jsxs)(s.Card,{className:`v1-card zt-fall`,title:`3. Validation result`,children:[(0,l.jsx)(mN,{errors:M,expanded:k,onToggle:()=>A(e=>!e),onSummaryClick:ee}),T&&h===`preview`&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`}),(0,l.jsx)(hN,{rows:x,view:C,onViewChange:w,onConfirm:V,onReset:L,saving:h===`inserting`,firstInvalidRowId:I,firstInvalidRowRef:a})]}),D&&h===`done`&&(0,l.jsxs)(s.Card,{className:`v1-card zt-fall`,title:`4. Upload complete`,children:[(0,l.jsxs)(s.Row,{gutter:[16,16],className:`bulk-metrics`,children:[(0,l.jsx)(s.Col,{xs:24,md:8,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(nN,{children:`Total`}),(0,l.jsx)(`strong`,{children:x.length})]})}),(0,l.jsx)(s.Col,{xs:24,md:8,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(nN,{children:`Inserted`}),(0,l.jsx)(`strong`,{children:D.inserted??0})]})}),(0,l.jsx)(s.Col,{xs:24,md:8,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(nN,{children:`Failed`}),(0,l.jsx)(`strong`,{children:D.failed??0})]})})]}),(0,l.jsx)(s.Alert,{type:`success`,showIcon:!0,icon:(0,l.jsx)(c.CheckCircleOutlined,{}),message:`${D.inserted??0} test cases saved to database - module: ${p}`,className:`bulk-inline-alert`}),(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:L,children:`Upload another file`})]})]})]})}var _N=[{value:`navigate`,label:`Navigate`},{value:`fill`,label:`Fill`},{value:`click`,label:`Click`},{value:`select`,label:`Select`},{value:`press_key`,label:`Press Key`},{value:`type_and_select`,label:`Type and Select`},{value:`type_and_select_modal`,label:`Type and Select (Modal)`},{value:`upload_file`,label:`Upload File`},{value:`check_checkbox`,label:`Check Checkbox`},{value:`check_filter_checkbox`,label:`Check Filter Checkbox`},{value:`select_page_size`,label:`Select Page Size`},{value:`check_n_checkboxes`,label:`Check N Checkboxes`},{value:`store_text`,label:`Store Text`},{value:`reset_session`,label:`Reset Session`},{value:`switch_to_new_tab`,label:`Switch To New Tab`},{value:`close_tab`,label:`Close Tab`},{value:`assert_visible`,label:`Assert Visible`},{value:`assert_hidden`,label:`Assert Hidden`},{value:`assert_text`,label:`Assert Text`},{value:`assert_url`,label:`Assert URL`},{value:`assert_body_contains`,label:`Assert Body Contains`},{value:`assert_button_disabled`,label:`Assert Button Disabled`},{value:`assert_field_error`,label:`Assert Field Error`},{value:`assert_field_accepted`,label:`Assert Field Accepted`},{value:`assert_children_disabled`,label:`Assert Children Disabled`},{value:`assert_children_visible`,label:`Assert Children Visible`},{value:`assert_element_count`,label:`Assert Element Count`},{value:`assert_toast`,label:`Assert Toast`},{value:`assert_toast_success`,label:`Assert Toast Success`},{value:`assert_toast_error`,label:`Assert Toast Error`},{value:`wait_for_visible`,label:`Wait For Visible`},{value:`wait_for_hidden`,label:`Wait For Hidden`},{value:`wait_for_text`,label:`Wait For Text`}],{Text:vN}=s.Typography,yN=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}],bN={tags:`regression`,active:1},xN={module:{dbName:`Modules`,formField:`module`,label:`Module`}};function SN(e=[]){return e.map(e=>({value:e,label:e}))}function CN(e=``){return String(e??``).trim()}function wN(e=``){return CN(e).toLowerCase()}function TN(e=[]){let t=new Map;return e.forEach(e=>{let n=CN(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function EN(e=[],t,n){let r=CN(t).toLowerCase(),i=CN(n).toLowerCase();return e.reduce((e,t)=>{let n=CN(t?.module).toLowerCase(),a=CN(t?.flow).toLowerCase();if(n!==r||a!==i)return e;let o=Number(t?.step_order)||0;return Math.max(e,o)},0)+1}function DN({icon:e,title:t}){return(0,l.jsxs)(s.Space,{size:10,align:`center`,children:[(0,l.jsx)(`div`,{className:`v1-section-icon-box`,children:e}),(0,l.jsx)(vN,{strong:!0,className:`v1-section-label`,children:t})]})}function ON(){let[e]=s.Form.useForm(),[t]=s.Form.useForm(),[r,i]=(0,o.useState)([]),[a,u]=(0,o.useState)([]),[f,p]=(0,o.useState)([]),[m,h]=(0,o.useState)(!1),[g,_]=(0,o.useState)(!1),[v,y]=(0,o.useState)({open:!1,typeKey:`module`}),[b,x]=(0,o.useState)(!1),[S,C]=(0,o.useState)(!1),[w,T]=(0,o.useState)(!1),E=(0,d.useNavigate)(),D=xN[v.typeKey],O=(0,o.useMemo)(()=>SN(r),[r]),k=s.Form.useWatch(`module`,e),A=s.Form.useWatch(`flow`,e),j=!!CN(k),M=!!CN(A),N=!j,P=!j||!M,F=(e,t=[])=>{e===`module`&&i(t)},I=async()=>{h(!0);try{let e=await _b(xN.module.dbName);i(e?.items??[])}catch(e){console.error(`Unable to load testing options:`,e),s.message.error(`Unable to load testing options.`)}finally{h(!1)}},L=(0,o.useCallback)(async t=>{let n=CN(t);if(u([]),p([]),e.setFieldsValue({step_order:void 0}),n){_(!0);try{let e=await xb({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];u(t),p(TN(t))}catch(e){console.error(`Unable to load flows:`,e),s.message.error(`Unable to load flows.`)}finally{_(!1)}}},[e]),R=(0,o.useCallback)(async(t,n,r)=>{let i=CN(t),a=CN(n);if(!i||!a){e.setFieldsValue({step_order:void 0});return}C(!0);try{e.setFieldsValue({step_order:EN(r,i,a)})}catch(e){console.error(`Unable to load step order:`,e),s.message.error(`Unable to load step order.`)}finally{C(!1)}},[e]);(0,o.useEffect)(()=>{Promise.resolve().then(I)},[]),(0,o.useEffect)(()=>{Promise.resolve().then(()=>L(k))},[L,k]),(0,o.useEffect)(()=>{Promise.resolve().then(()=>R(k,A,a))},[a,R,A,k]);let z=async t=>{let n={module:CN(t.module),flow:CN(t.flow),step_order:Number(t.step_order),description:CN(t.description),keyword:wN(t.keyword),target:CN(t.target),value:CN(t.value),expected:CN(t.expected),tags:t.tags?CN(t.tags):bN.tags,active:Number(t.active)};T(!0);try{await bb(n),s.message.success(`Test case details saved successfully.`),e.resetFields(),u([]),p([])}catch(e){console.error(`Unable to save test case:`,e),s.message.error(`Unable to save test case.`)}finally{T(!1)}},B=(t,n)=>{e.setFieldsValue({[t]:CN(n)})},V=t=>{e.setFieldsValue({module:CN(t),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:bN.tags,value:void 0,expected:void 0})},ee=t=>{e.setFieldsValue({flow:CN(t),step_order:void 0})},te=e=>{let n=xN[e];y({open:!0,typeKey:e}),t.setFieldsValue({name:``,type:n.label})},ne=()=>{y(e=>({...e,open:!1})),t.resetFields()},re=async()=>{try{let n=CN((await t.validateFields()).name),r=await vb({name:n,type:D.dbName});F(v.typeKey,r?.items??[]),e.setFieldsValue({[D.formField]:n}),s.message.success(`${D.label} added successfully.`),ne()}catch(e){if(e?.errorFields)return;console.error(`Unable to save testing option:`,e),s.message.error(`Unable to add ${D.label.toLowerCase()}.`)}finally{x(!1)}};return(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:yN})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`link`,onClick:()=>E(`/zinnext-home`),children:`View Table`})})]}),(0,l.jsx)(`div`,{className:`v1-page`,children:(0,l.jsxs)(`div`,{className:`v1-page-inner`,children:[(0,l.jsx)(`div`,{className:`v1-page-header`,children:(0,l.jsxs)(s.Space,{align:`center`,size:10,children:[(0,l.jsx)(c.ProfileOutlined,{className:`v1-outer-icon`}),(0,l.jsx)(`div`,{children:(0,l.jsx)(vN,{strong:!0,style:{fontSize:16},children:`Add Test Case`})})]})}),(0,l.jsx)(Z,{children:(0,l.jsxs)(s.Form,{form:e,className:`v1-form`,layout:`vertical`,colon:!1,requiredMark:(e,{required:t})=>(0,l.jsxs)(l.Fragment,{children:[e,t&&(0,l.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),initialValues:bN,onFinish:z,autoComplete:`off`,children:[(0,l.jsx)(s.Card,{className:`v1-card`,title:(0,l.jsx)(DN,{icon:(0,l.jsx)(c.FileTextOutlined,{}),title:`Test Case Details`}),extra:(0,l.jsx)(vN,{type:`secondary`,className:`v1-card-subtitle`,children:`Module, flow, step order and execution data`}),children:(0,l.jsxs)(s.Row,{gutter:[24,0],children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsxs)(s.Space.Compact,{style:{width:`100%`},children:[(0,l.jsx)(s.Form.Item,{label:`Module`,name:`module`,style:{flex:1},children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,loading:m,optionFilterProp:`label`,placeholder:`Select module`,options:O,onChange:V})}),(0,l.jsx)(s.Button,{"aria-label":`Add module`,icon:(0,l.jsx)(c.PlusOutlined,{}),style:{marginTop:30},onClick:()=>te(`module`)})]})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Flow`,name:`flow`,children:(0,l.jsx)(s.AutoComplete,{maxLength:100,allowClear:!0,disabled:N,options:f,placeholder:g?`Loading flows`:`Enter flow`,onChange:ee,filterOption:(e,t)=>t?.value?.toLowerCase().includes(e.toLowerCase())})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Step Order`,name:`step_order`,validateTrigger:[`onBlur`,`onChange`],children:(0,l.jsx)(s.Input,{maxLength:10,disabled:!0,placeholder:S?`Loading step order`:`Step order`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Action`,name:`keyword`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,disabled:P,optionFilterProp:`label`,placeholder:`Select action`,options:_N,onChange:t=>e.setFieldsValue({keyword:wN(t)})})})}),(0,l.jsx)(s.Col,{xs:24,children:(0,l.jsx)(s.Form.Item,{label:`Description`,name:`description`,children:(0,l.jsx)(s.Input.TextArea,{rows:3,maxLength:255,disabled:P,placeholder:`Enter description`,showCount:!0,onBlur:e=>B(`description`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Key`,name:`target`,children:(0,l.jsx)(s.Input,{maxLength:255,disabled:P,placeholder:`Enter target`,onBlur:e=>B(`target`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Tags`,name:`tags`,children:(0,l.jsx)(s.Input,{maxLength:200,disabled:P,placeholder:`Enter tags`,prefix:(0,l.jsx)(c.TagsOutlined,{className:`v1-input-icon`}),onBlur:e=>B(`tags`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Value`,name:`value`,children:(0,l.jsx)(s.Input.TextArea,{rows:4,disabled:P,placeholder:`Enter value`,onBlur:e=>B(`value`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Expected`,name:`expected`,children:(0,l.jsx)(s.Input.TextArea,{rows:4,disabled:P,placeholder:`Enter expected result`,onBlur:e=>B(`expected`,e.target.value)})})})]})}),(0,l.jsx)(`div`,{className:`v1-form-actions`,children:(0,l.jsx)(s.Form.Item,{children:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{type:`primary`,htmlType:`submit`,loading:w,disabled:P,children:`Submit`}),(0,l.jsx)(s.Button,{onClick:()=>{e.resetFields(),u([]),p([])},children:`Reset`})]})})})]})}),(0,l.jsx)(s.Modal,{title:`Add ${D.label}`,open:v.open,confirmLoading:b,okText:`Add`,onCancel:ne,onOk:()=>{x(!0),re()},destroyOnHidden:!0,children:(0,l.jsxs)(s.Form,{form:t,layout:`vertical`,colon:!1,className:`v1-form`,requiredMark:(e,{required:t})=>(0,l.jsxs)(l.Fragment,{children:[e,t&&(0,l.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),children:[(0,l.jsx)(s.Form.Item,{label:`Name`,name:`name`,children:(0,l.jsx)(s.Input,{maxLength:100,placeholder:`Enter ${D.label.toLowerCase()} name`,onBlur:e=>{t.setFieldsValue({name:CN(e.target.value)})}})}),(0,l.jsx)(s.Form.Item,{label:`Type`,name:`type`,children:(0,l.jsx)(s.Input,{disabled:!0})})]})})]})})]})}var{Text:kN}=s.Typography,AN=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`}];function jN(e=``){return String(e??``).trim()}function MN(e=[],t){return e.map(e=>({value:e.id,label:e[t]}))}var NN=[{label:`Step`,value:`step_order`,width:70},{label:`Action`,value:`actions`,width:140},{label:`Key`,value:`key`,width:160,ellipsis:!0},{label:`Value`,value:`value`,ellipsis:!0},{label:`Description`,value:`description`,ellipsis:!0},{label:`Scenario`,value:`scenario`,width:110,render:e=>e===1?(0,l.jsx)(s.Tag,{color:`green`,children:`Positive`}):(0,l.jsx)(s.Tag,{color:`red`,children:`Negative`})}],PN={key:!1,value:!1,expected:!1};function FN(e,t){return t?e[t]??PN:PN}function IN(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function LN(){let[e]=s.Form.useForm(),r=(0,d.useNavigate)(),[i]=(0,d.useSearchParams)(),a=i.get(`edit`),u=!!a,f=(0,o.useMemo)(()=>t.l(),[]),[p,m]=(0,o.useState)([]),[h,g]=(0,o.useState)([]),[_,v]=(0,o.useState)([]),[y,b]=(0,o.useState)(_N),[x,S]=(0,o.useState)({}),[C,w]=(0,o.useState)(!1),[T,E]=(0,o.useState)(!1),[D,O]=(0,o.useState)(!1),[k,A]=(0,o.useState)(!1),[j,M]=(0,o.useState)(!1),N=s.Form.useWatch(`module`,e),P=s.Form.useWatch(`submodule`,e),F=s.Form.useWatch(`actions`,e),I=!!N,L=!!P,R=(0,o.useMemo)(()=>FN(x,F),[x,F]),z=(0,o.useMemo)(()=>MN(p,`modulename`),[p]),B=(0,o.useMemo)(()=>MN(h,`submodulename`),[h]),V=(0,o.useMemo)(()=>p.find(e=>e.id===N)?.modulename??``,[p,N]),ee=(0,o.useMemo)(()=>h.find(e=>e.id===P)?.submodulename??``,[P,h]),te=(0,o.useCallback)(async()=>{try{let e=await yb();Array.isArray(e?.options)&&e.options.length>0&&b(e.options),e?.rules&&typeof e.rules==`object`&&S(e.rules)}catch(e){console.error(`Unable to load action field rules:`,e),s.message.error(`Unable to load action validation rules.`)}},[]),ne=(0,o.useCallback)(async e=>{if(!e){m([]);return}w(!0);try{let t=await Db({project:e,activeOnly:!0});m(t?.items??[])}catch(e){console.error(`Unable to load modules:`,e),s.message.error(`Unable to load modules.`)}finally{w(!1)}},[]),re=(0,o.useCallback)(async(e,t)=>{if(!e||!t){g([]);return}E(!0);try{let n=await Ab({project:e,module:t,activeOnly:!0});g(n?.items??[])}catch(e){console.error(`Unable to load submodules:`,e),s.message.error(`Unable to load submodules.`)}finally{E(!1)}},[]),ie=(0,o.useCallback)(async(t,n,r,i=``)=>{if(!t||!n||!r){v([]),e.setFieldsValue({step_order:void 0});return}O(!0);try{let[a,o]=await Promise.all([Nb({product_parent_ID:t,module_parent_ID:n,submodule_parent_ID:r,actions:i,limit:1e3}),Ib({product_parent_ID:t,module_parent_ID:n,submodule_parent_ID:r})]);v(a?.items??[]),e.setFieldsValue({step_order:o?.step_order??1})}catch(e){console.error(`Unable to load flows:`,e),s.message.error(`Unable to load flows.`)}finally{O(!1)}},[e]),ae=(0,o.useCallback)(async(e=``)=>{if(!(!f?.id||!N||!P)){O(!0);try{let t=await Nb({product_parent_ID:f.id,module_parent_ID:N,submodule_parent_ID:P,actions:e,limit:1e3});v(t?.items??[])}catch(e){console.error(`Unable to load action flows:`,e),s.message.error(`Unable to load action steps.`)}finally{O(!1)}}},[f?.id,N,P]),oe=(0,o.useCallback)(async()=>{if(!(!a||!f?.name)){M(!0);try{let t=await Fb(a);await re(f.name,t.module);let n=await Nb({product_parent_ID:t.product_parent_ID,module_parent_ID:t.module_parent_ID,submodule_parent_ID:t.submodule_parent_ID,limit:1e3});v(n?.items??[]),e.setFieldsValue({module:t.module_parent_ID,submodule:t.submodule_parent_ID,step_order:t.step_order,actions:t.actions,key:t.key,value:t.value,expected:t.expected,description:t.description,scenario:t.scenario===1,active:Number(t.active)!==0})}catch(e){console.error(`Unable to load test flow:`,e),s.message.error(`Unable to load test flow for edit.`),r(`/viewTestCase`)}finally{M(!1)}}},[a,e,re,r,f?.name]);return(0,o.useEffect)(()=>{if(!f){r(`/select-project`,{replace:!0});return}Promise.resolve().then(async()=>{await te(),await ne(f.name),a&&await oe()})},[f,r,te,ne,a,oe]),f?(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:AN})}),(0,l.jsx)(s.Col,{children:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.ProjectOutlined,{}),(0,l.jsx)(kN,{strong:!0,children:f.name})]})})]}),(0,l.jsx)(`div`,{className:`zt-page`,children:(0,l.jsxs)(s.Form,{form:e,layout:`vertical`,colon:!1,className:`v1-form`,initialValues:{scenario:!0,active:!0},onFinish:async t=>{let n={product_parent_ID:Number(f?.id),module_parent_ID:Number(t.module),submodule_parent_ID:Number(t.submodule),description:jN(t.description),actions:jN(t.actions),key:jN(t.key),value:jN(t.value),expected:jN(t.expected),scenario:+!!t.scenario,active:+!!t.active};A(!0);try{if(u){await Lb(a,{...n,step_order:Number(t.step_order)}),s.message.success(`Test case updated successfully.`),r(`/viewTestCase`);return}await Pb(n),s.message.success(`Step saved (#${t.step_order}).`),e.setFieldsValue({actions:void 0,key:void 0,value:void 0,expected:void 0,description:void 0}),await ie(n.product_parent_ID,n.module_parent_ID,n.submodule_parent_ID)}catch(e){console.error(`Unable to save test case:`,e),s.message.error(u?`Unable to update test case.`:`Unable to save step.`)}finally{A(!1)}},autoComplete:`off`,disabled:j,children:[(0,l.jsx)(s.Card,{className:`v1-card zt-fall`,title:(0,l.jsxs)(s.Space,{size:8,className:`zt-section-title`,children:[(0,l.jsx)(`span`,{className:`zt-step-tag`,children:`1`}),(0,l.jsx)(`span`,{children:`Module & Submodule`})]}),children:(0,l.jsxs)(s.Row,{gutter:[24,0],align:`bottom`,children:[(0,l.jsx)(s.Col,{xs:24,md:6,children:(0,l.jsx)(s.Form.Item,{label:`Module`,name:`module`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,loading:C,placeholder:`Select module`,options:z,onChange:t=>{let n=p.find(e=>e.id===t)?.modulename??``;e.setFieldsValue({module:t,submodule:void 0,step_order:void 0,actions:void 0,key:void 0,value:void 0,expected:void 0}),IN(e,[`actions`,`key`,`value`,`expected`]),g([]),v([]),re(f?.name,n)}})})}),(0,l.jsx)(s.Col,{xs:24,md:6,children:(0,l.jsx)(s.Form.Item,{label:`Submodule`,name:`submodule`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,disabled:!I,loading:T,placeholder:I?`Select submodule`:`Select module first`,options:B,onChange:t=>{e.setFieldsValue({submodule:t,actions:void 0,key:void 0,value:void 0,expected:void 0}),IN(e,[`actions`,`key`,`value`,`expected`]),ie(f?.id,N,t)}})})}),(0,l.jsx)(s.Col,{xs:24,md:6,children:(0,l.jsx)(s.Form.Item,{label:`Scenario`,name:`scenario`,valuePropName:`checked`,children:(0,l.jsx)(s.Switch,{disabled:!L,checkedChildren:`Positive`,unCheckedChildren:`Negative`})})}),(0,l.jsx)(s.Col,{xs:24,md:6,children:(0,l.jsx)(s.Form.Item,{label:`Active`,name:`active`,valuePropName:`checked`,children:(0,l.jsx)(s.Switch,{checkedChildren:`Active`,unCheckedChildren:`Inactive`})})})]})}),L&&(0,l.jsxs)(s.Card,{className:`v1-card zt-fall`,title:(0,l.jsxs)(s.Space,{size:8,className:`zt-section-title`,children:[(0,l.jsx)(`span`,{className:`zt-step-tag`,children:`2`}),(0,l.jsx)(c.FileTextOutlined,{}),(0,l.jsx)(`span`,{children:`Step Details`})]}),extra:(0,l.jsxs)(kN,{type:`secondary`,children:[V,` / `,ee]}),children:[(0,l.jsxs)(s.Row,{gutter:[24,0],children:[(0,l.jsx)(s.Col,{xs:24,md:6,children:(0,l.jsx)(s.Form.Item,{label:`Step Order`,name:`step_order`,children:(0,l.jsx)(s.Input,{disabled:!0,placeholder:D?`Loading…`:`Auto`})})}),(0,l.jsx)(s.Col,{xs:24,md:18,children:(0,l.jsx)(s.Form.Item,{label:`Action`,name:`actions`,rules:[{required:!0,message:`Mandatory Field`}],children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,placeholder:`Select action`,options:y,onChange:t=>{let n=FN(x,t);e.setFieldsValue({actions:t,key:n.key?e.getFieldValue(`key`):void 0,value:n.value?e.getFieldValue(`value`):void 0,expected:n.expected?e.getFieldValue(`expected`):void 0}),IN(e,[`key`,`value`,`expected`]),ae(t||``)}})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Key`,name:`key`,rules:[{required:R.key,message:`Key is required for this action`}],children:(0,l.jsx)(s.Input,{maxLength:255,disabled:F&&!R.key,placeholder:F?R.key?`Required — Enter selector / locator`:`Not needed for this action`:`Select an action first`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Value`,name:`value`,rules:[{required:R.value,message:`Value is required for this action`}],children:(0,l.jsx)(s.Input.TextArea,{rows:1,autoSize:{minRows:1,maxRows:4},disabled:F&&!R.value,placeholder:F?R.value?`Required — Enter value`:`Not needed for this action`:`Select an action first`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Expected`,name:`expected`,rules:[{required:R.expected,message:`Expected result is required for this action`}],children:(0,l.jsx)(s.Input.TextArea,{rows:2,disabled:F&&!R.expected,placeholder:F?R.expected?`Required — Enter expected result`:`Not needed for this action`:`Select an action first`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Description`,name:`description`,children:(0,l.jsx)(s.Input.TextArea,{rows:2,maxLength:255,showCount:!0,placeholder:`Enter description`})})})]}),(0,l.jsxs)(s.Space,{className:`zt-actions`,children:[(0,l.jsx)(s.Button,{onClick:()=>{if(u){r(`/viewTestCase`);return}e.resetFields(),g([]),v([]),E(!1),O(!1)},children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,htmlType:`submit`,loading:k||j,children:u?`Update Test Case`:`Save & Continue`})]})]},`${N}-${P}`),L&&(0,l.jsx)(s.Card,{className:`v1-card zt-fall`,title:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.TableOutlined,{}),(0,l.jsx)(`span`,{children:`Added Steps`})]}),extra:(0,l.jsx)(s.Tag,{children:F?`${_.length} ${F} step(s)`:`${_.length} step(s)`}),children:(0,l.jsx)(km,{listName:`Added Steps`,loading:D,fields:NN,dataSource:_,current:1,pageSize:Math.max(_.length,1),total:_.length,rowSelection:!1,className:`zt-list-plain zt-list-static`})})]})})]}):null}var{Text:RN}=s.Typography,zN=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`}];function BN(){let e=(0,d.useNavigate)(),r=(0,o.useMemo)(()=>t.l(),[]),[i,a]=(0,o.useState)([]),[u,f]=(0,o.useState)({}),[p,m]=(0,o.useState)(!1),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)(``),[y,b]=(0,o.useState)(!1),[x,S]=(0,o.useState)(1),[C,w]=(0,o.useState)(10),T=(0,o.useCallback)(async e=>{if(!e){a([]);return}m(!0);try{let[t,n]=await Promise.all([Db({project:e}),Ab({project:e})]);a(t?.items??[]);let r={};(n?.items??[]).forEach(e=>{let t=e.modulename;r[t]=(r[t]??0)+1}),f(r)}catch(e){console.error(e),s.message.error(`Unable to load modules.`)}finally{m(!1)}},[]);(0,o.useEffect)(()=>{if(!r){e(`/select-project`,{replace:!0});return}Promise.resolve().then(()=>T(r.name))},[r,e,T]);let E=async(e,t)=>{try{await kb(e.id,+!!t),a(n=>n.map(n=>n.id===e.id?{...n,active:+!!t}:n)),s.message.success(`Module ${t?`activated`:`deactivated`}.`)}catch(e){console.error(e),s.message.error(`Unable to update module status.`)}},D=async()=>{let e=_.trim();if(!e){s.message.warning(`Enter a module name.`);return}b(!0);try{await Ob({project:r.name,modulename:e}),s.message.success(`Module added.`),g(!1),v(``),S(1),T(r.name)}catch(e){console.error(e),s.message.error(`Unable to add module (maybe it already exists).`)}finally{b(!1)}},O=t=>{e(`/test-cases/zinnext/submodules?module=${encodeURIComponent(t.modulename)}`)};return r?(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:zN})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`link`,onClick:()=>e(`/addTestCase`),children:`Back to Form`})})]}),(0,l.jsxs)(`div`,{className:`zt-page`,children:[(0,l.jsx)(s.Card,{className:`v1-card zt-bar`,children:(0,l.jsxs)(s.Row,{gutter:[16,16],align:`middle`,justify:`space-between`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.ProjectOutlined,{}),(0,l.jsx)(`span`,{children:`Project:`}),(0,l.jsx)(RN,{strong:!0,children:r.name})]})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>g(!0),children:`Add Module`})})]})}),(0,l.jsx)(s.Card,{className:`v1-card zt-fall`,title:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.AppstoreOutlined,{}),(0,l.jsx)(`span`,{children:`Modules`})]}),children:(0,l.jsx)(km,{listName:`Modules`,loading:p,fields:[{label:`Module`,value:`modulename`},{label:`Submodules`,value:`submoduleCount`,width:140,render:(e,t)=>(0,l.jsxs)(s.Button,{type:`link`,className:`zt-count-link`,onClick:()=>O(t),children:[u[t.modulename]??0,` submodule(s)`]})},{label:`Active`,value:`active`,width:120,render:(e,t)=>(0,l.jsx)(s.Switch,{checked:e===1,checkedChildren:`On`,unCheckedChildren:`Off`,onChange:e=>E(t,e)})}],dataSource:i,current:x,pageSize:C,total:i.length,onPageChange:S,onPageSizeChange:e=>{S(1),w(e)},rowSelection:!1,className:`zt-list-plain`})})]}),(0,l.jsx)(s.Modal,{title:`Add Module`,open:h,confirmLoading:y,okText:`Add`,onOk:D,onCancel:()=>{g(!1),v(``)},destroyOnHidden:!0,children:(0,l.jsxs)(s.Space,{direction:`vertical`,className:`zt-modal-stack`,children:[(0,l.jsxs)(RN,{type:`secondary`,children:[`Project: `,(0,l.jsx)(`b`,{children:r.name})]}),(0,l.jsx)(s.Input,{placeholder:`Enter module name`,maxLength:100,value:_,onChange:e=>v(e.target.value),onPressEnter:D})]})})]}):null}var{Text:VN}=s.Typography,HN=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`},{label:`Manage Submodules`,href:`/test-cases/zinnext/submodules`}];function UN(){let e=(0,d.useNavigate)(),[r]=(0,d.useSearchParams)(),i=(0,o.useMemo)(()=>t.l(),[]),a=r.get(`module`)??``,[u,f]=(0,o.useState)([]),[p,m]=(0,o.useState)(!1),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)(``),[y,b]=(0,o.useState)(!1),[x,S]=(0,o.useState)(1),[C,w]=(0,o.useState)(10),T=(0,o.useCallback)(async(e,t)=>{if(!e||!t){f([]);return}m(!0);try{let n=await Ab({project:e,module:t});f(n?.items??[])}catch(e){console.error(e),s.message.error(`Unable to load submodules.`)}finally{m(!1)}},[]);(0,o.useEffect)(()=>{if(!i){e(`/select-project`,{replace:!0});return}if(!a){e(`/manageModules`,{replace:!0});return}Promise.resolve().then(()=>T(i.name,a))},[i,a,e,T]);let E=async(e,t)=>{try{await Mb(e.id,+!!t),f(n=>n.map(n=>n.id===e.id?{...n,active:+!!t}:n)),s.message.success(`Submodule ${t?`activated`:`deactivated`}.`)}catch(e){console.error(e),s.message.error(`Unable to update submodule status.`)}},D=async()=>{let e=_.trim();if(!e){s.message.warning(`Enter a submodule name.`);return}b(!0);try{await jb({project:i.name,modulename:a,submodulename:e}),s.message.success(`Submodule added.`),g(!1),v(``),S(1),T(i.name,a)}catch(e){console.error(e),s.message.error(`Unable to add submodule (maybe it already exists).`)}finally{b(!1)}};return!i||!a?null:(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:HN})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`link`,onClick:()=>e(`/manageModules`),children:`Back to Modules`})})]}),(0,l.jsxs)(`div`,{className:`zt-page`,children:[(0,l.jsx)(s.Card,{className:`v1-card zt-bar`,children:(0,l.jsxs)(s.Row,{gutter:[16,16],align:`middle`,justify:`space-between`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsxs)(s.Space,{size:16,wrap:!0,className:`zt-section-title`,children:[(0,l.jsxs)(s.Space,{size:6,children:[(0,l.jsx)(c.ProjectOutlined,{}),(0,l.jsx)(`span`,{children:`Project:`}),(0,l.jsx)(VN,{strong:!0,children:i.name})]}),(0,l.jsxs)(s.Space,{size:6,children:[(0,l.jsx)(c.AppstoreOutlined,{}),(0,l.jsx)(`span`,{children:`Module:`}),(0,l.jsx)(VN,{strong:!0,children:a})]})]})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>g(!0),children:`Add Submodule`})})]})}),(0,l.jsx)(s.Card,{className:`v1-card zt-fall`,title:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.AppstoreOutlined,{}),(0,l.jsx)(`span`,{children:`Submodules`})]}),children:(0,l.jsx)(km,{listName:`Submodules`,loading:p,fields:[{label:`Submodule`,value:`submodulename`},{label:`Active`,value:`active`,width:120,render:(e,t)=>(0,l.jsx)(s.Switch,{checked:e===1,checkedChildren:`On`,unCheckedChildren:`Off`,onChange:e=>E(t,e)})}],dataSource:u,current:x,pageSize:C,total:u.length,onPageChange:S,onPageSizeChange:e=>{S(1),w(e)},rowSelection:!1,className:`zt-list-plain`})})]}),(0,l.jsx)(s.Modal,{title:`Add Submodule`,open:h,confirmLoading:y,okText:`Add`,onOk:D,onCancel:()=>{g(!1),v(``)},destroyOnHidden:!0,children:(0,l.jsxs)(s.Space,{direction:`vertical`,className:`zt-modal-stack`,children:[(0,l.jsxs)(VN,{type:`secondary`,children:[`Project: `,(0,l.jsx)(`b`,{children:i.name}),` \xA0|\xA0 Module: `,(0,l.jsx)(`b`,{children:a})]}),(0,l.jsx)(s.Input,{placeholder:`Enter submodule name`,maxLength:100,value:_,onChange:e=>v(e.target.value),onPressEnter:D})]})})]})}var{Text:WN}=s.Typography,GN=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Table`,href:`/viewTestCase`}];function KN(){let e=(0,d.useNavigate)(),[r,i]=(0,o.useState)([]),[a,u]=(0,o.useState)(0),[f,p]=(0,o.useState)(!1),m=(0,o.useMemo)(()=>t.l(),[]),[h,g]=(0,o.useState)(``),[_,v]=(0,o.useState)(1),[y,b]=(0,o.useState)(20),[x,S]=(0,o.useState)(null),C=(0,o.useCallback)(async(e={})=>{p(!0);try{let t=await Nb({product_parent_ID:e.project??m?.id??``,search:e.search??h??``,limit:e.pageSize??y,offset:((e.page??_)-1)*(e.pageSize??y)});i(t?.items??[]),u(t?.total??0)}catch(e){console.error(e),s.message.error(`Unable to load test flows.`)}finally{p(!1)}},[m?.id,h,_,y]),w=e=>{s.Modal.confirm({title:`Delete Test Case`,icon:(0,l.jsx)(c.ExclamationCircleOutlined,{}),content:`Are you sure you want to delete this test case?`,okText:`Delete`,okButtonProps:{danger:!0,loading:x===e.id},cancelText:`Cancel`,async onOk(){S(e.id);try{await Rb(e.id),s.message.success(`Test case deleted successfully.`);let t=r.length===1&&_>1?_-1:_;v(t),await C({page:t})}catch(e){throw console.error(`Unable to delete test flow:`,e),s.message.error(`Unable to delete test case.`),e}finally{S(null)}}})};return(0,o.useEffect)(()=>{Promise.resolve().then(()=>{if(!m?.id){e(`/select-project`,{replace:!0});return}C({page:1})})},[]),(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:GN})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`link`,onClick:()=>e(`/addTestCase`),children:`Back to Form`})})]}),(0,l.jsx)(`div`,{className:`zt-page zt-page-wide`,children:(0,l.jsxs)(s.Card,{className:`v1-card`,title:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.TableOutlined,{}),(0,l.jsx)(`span`,{children:`Test Flows`})]}),extra:(0,l.jsxs)(WN,{type:`secondary`,children:[a,` row(s)`]}),children:[(0,l.jsxs)(s.Space,{wrap:!0,className:`zt-toolbar`,children:[(0,l.jsx)(s.Input.Search,{allowClear:!0,className:`zt-search-filter`,placeholder:`Search module / key / description`,value:h,onChange:e=>g(e.target.value),onSearch:()=>{v(1),C({page:1})}}),(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:()=>C(),children:`Refresh`})]}),(0,l.jsx)(km,{listName:`Test Flows`,loading:f,fields:[{label:`Actions`,value:`rowActions`,width:112,fixed:`left`,sorter:!1,render:(t,n)=>(0,l.jsxs)(s.Space,{size:4,className:`zt-row-actions`,children:[(0,l.jsx)(s.Tooltip,{title:`Edit`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>e(`/addTestCase?edit=${n.id}`)})}),(0,l.jsx)(s.Tooltip,{title:`Delete`,children:(0,l.jsx)(s.Button,{danger:!0,type:`text`,size:`small`,icon:(0,l.jsx)(c.DeleteOutlined,{}),loading:x===n.id,onClick:()=>w(n)})})]})},{label:`ID`,value:`id`,width:70,fixed:`left`},{label:`Project`,value:`project`,width:130},{label:`Module`,value:`module`,width:130},{label:`Submodule`,value:`submodule`,width:140},{label:`Step`,value:`step_order`,width:70},{label:`Action`,value:`actions`,width:140},{label:`Key`,value:`key`,width:160,ellipsis:!0},{label:`Value`,value:`value`,width:200,ellipsis:!0},{label:`Expected`,value:`expected`,width:180,ellipsis:!0},{label:`Description`,value:`description`,width:180,ellipsis:!0},{label:`Scenario`,value:`scenario`,width:110,render:e=>e===1?(0,l.jsx)(s.Tag,{color:`green`,children:`Positive`}):(0,l.jsx)(s.Tag,{color:`red`,children:`Negative`})},{label:`Active`,value:`active`,width:90,render:e=>e===1?(0,l.jsx)(s.Tag,{color:`blue`,children:`Active`}):(0,l.jsx)(s.Tag,{children:`Inactive`})}],dataSource:r,current:_,pageSize:y,total:a,onPageChange:e=>{v(e),C({page:e})},onPageSizeChange:e=>{v(1),b(e),C({page:1,pageSize:e})},rowSelection:!1,className:`zt-list-plain`})]})})]})}var qN=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}];function JN(){return(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsx)(n.t,{items:qN}),(0,l.jsx)(Jo,{moduleName:`test-flows`,rowKey:`id`})]})}var{Text:YN}=s.Typography,XN=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}],ZN={tags:`regression`,active:1},QN={module:{dbName:`Modules`,formField:`module`,label:`Module`}},$N={key:!1,value:!1,expected:!1};function eP(e,t){return t?e[t]??$N:$N}function tP(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function nP(e=[]){return e.map(e=>({value:e,label:e}))}function rP(e=``){return String(e??``).trim()}function iP(e=[]){let t=new Map;return e.forEach(e=>{let n=rP(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function aP(e=[],t,n){let r=rP(t).toLowerCase(),i=rP(n).toLowerCase();return e.reduce((e,t)=>{let n=rP(t?.module).toLowerCase(),a=rP(t?.flow).toLowerCase();if(n!==r||a!==i)return e;let o=Number(t?.step_order)||0;return Math.max(e,o)},0)+1}function oP({icon:e,title:t}){return(0,l.jsxs)(s.Space,{size:10,align:`center`,children:[(0,l.jsx)(`div`,{className:`v1-section-icon-box`,children:e}),(0,l.jsx)(YN,{strong:!0,className:`v1-section-label`,children:t})]})}function sP(){let[e]=s.Form.useForm(),[t]=s.Form.useForm(),[r,i]=(0,o.useState)([]),[a,u]=(0,o.useState)([]),[f,p]=(0,o.useState)([]),[m,h]=(0,o.useState)(_N),[g,_]=(0,o.useState)({}),[v,y]=(0,o.useState)(!1),[b,x]=(0,o.useState)(!1),[S,C]=(0,o.useState)({open:!1,typeKey:`module`}),[w,T]=(0,o.useState)(!1),[E,D]=(0,o.useState)(!1),[O,k]=(0,o.useState)(!1),A=(0,d.useNavigate)(),j=QN[S.typeKey],M=(0,o.useMemo)(()=>nP(r),[r]),N=s.Form.useWatch(`module`,e),P=s.Form.useWatch(`flow`,e),F=s.Form.useWatch(`keyword`,e),I=!!rP(N),L=!!rP(P),R=!I,z=!I||!L,B=(0,o.useMemo)(()=>eP(g,F),[g,F]),V=(e,t=[])=>{e===`module`&&i(t)},ee=async()=>{y(!0);try{let e=await _b(QN.module.dbName);i(e?.items??[])}catch(e){console.error(`Unable to load testing options:`,e),s.message.error(`Unable to load testing options.`)}finally{y(!1)}},te=async()=>{try{let e=await yb();Array.isArray(e?.options)&&e.options.length>0&&h(e.options),e?.rules&&typeof e.rules==`object`&&_(e.rules)}catch(e){console.error(`Unable to load action field rules:`,e),s.message.error(`Unable to load action validation rules.`)}},ne=(0,o.useCallback)(async t=>{let n=rP(t);if(u([]),p([]),e.setFieldsValue({step_order:void 0}),n){x(!0);try{let e=await Tb({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];u(t),p(iP(t))}catch(e){console.error(`Unable to load flows:`,e),s.message.error(`Unable to load flows.`)}finally{x(!1)}}},[e]),re=(0,o.useCallback)(async(t,n,r)=>{let i=rP(t),a=rP(n);if(!i||!a){e.setFieldsValue({step_order:void 0});return}D(!0);try{e.setFieldsValue({step_order:aP(r,i,a)})}catch(e){console.error(`Unable to load step order:`,e),s.message.error(`Unable to load step order.`)}finally{D(!1)}},[e]);(0,o.useEffect)(()=>{Promise.resolve().then(async()=>{await Promise.all([ee(),te()])})},[]),(0,o.useEffect)(()=>{Promise.resolve().then(()=>ne(N))},[ne,N]),(0,o.useEffect)(()=>{Promise.resolve().then(()=>re(N,P,a))},[a,re,P,N]);let ie=async t=>{let n={module:rP(t.module),flow:rP(t.flow),step_order:Number(t.step_order),description:rP(t.description),keyword:rP(t.keyword),target:rP(t.target),value:rP(t.value),expected:rP(t.expected),tags:t.tags?rP(t.tags):ZN.tags,active:Number(t.active)};k(!0);try{await wb(n),s.message.success(`LMS case details saved successfully.`),e.resetFields(),u([]),p([])}catch(e){console.error(`Unable to save LMS case:`,e),s.message.error(`Unable to save LMS case.`)}finally{k(!1)}},ae=(t,n)=>{e.setFieldsValue({[t]:rP(n)})},oe=t=>{e.setFieldsValue({module:rP(t),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:ZN.tags,value:void 0,expected:void 0}),tP(e,[`keyword`,`target`,`value`,`expected`])},se=t=>{e.setFieldsValue({flow:rP(t),step_order:void 0,keyword:void 0,target:void 0,value:void 0,expected:void 0}),tP(e,[`keyword`,`target`,`value`,`expected`])},H=t=>{let n=eP(g,t);e.setFieldsValue({keyword:rP(t),target:n.key?e.getFieldValue(`target`):void 0,value:n.value?e.getFieldValue(`value`):void 0,expected:n.expected?e.getFieldValue(`expected`):void 0}),tP(e,[`target`,`value`,`expected`])},ce=e=>{let n=QN[e];C({open:!0,typeKey:e}),t.setFieldsValue({name:``,type:n.label})},le=()=>{C(e=>({...e,open:!1})),t.resetFields()},ue=async()=>{try{let n=rP((await t.validateFields()).name),r=await vb({name:n,type:j.dbName});V(S.typeKey,r?.items??[]),e.setFieldsValue({[j.formField]:n}),s.message.success(`${j.label} added successfully.`),le()}catch(e){if(e?.errorFields)return;console.error(`Unable to save testing option:`,e),s.message.error(`Unable to add ${j.label.toLowerCase()}.`)}finally{T(!1)}};return(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:XN})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`link`,onClick:()=>A(`/lms-home`),children:`View Table`})})]}),(0,l.jsx)(`div`,{className:`v1-page`,children:(0,l.jsxs)(`div`,{className:`v1-page-inner`,children:[(0,l.jsx)(`div`,{className:`v1-page-header`,children:(0,l.jsxs)(s.Space,{align:`center`,size:10,children:[(0,l.jsx)(c.ProfileOutlined,{className:`v1-outer-icon`}),(0,l.jsx)(`div`,{children:(0,l.jsx)(YN,{strong:!0,style:{fontSize:16},children:`Add LMS Case`})})]})}),(0,l.jsx)(Z,{children:(0,l.jsxs)(s.Form,{form:e,className:`v1-form`,layout:`vertical`,colon:!1,requiredMark:(e,{required:t})=>(0,l.jsxs)(l.Fragment,{children:[e,t&&(0,l.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),initialValues:ZN,onFinish:ie,autoComplete:`off`,children:[(0,l.jsx)(s.Card,{className:`v1-card`,title:(0,l.jsx)(oP,{icon:(0,l.jsx)(c.FileTextOutlined,{}),title:`LMS Case Details`}),extra:(0,l.jsx)(YN,{type:`secondary`,className:`v1-card-subtitle`,children:`Module, flow, step order and execution data`}),children:(0,l.jsxs)(s.Row,{gutter:[24,0],children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsxs)(s.Space.Compact,{style:{width:`100%`},children:[(0,l.jsx)(s.Form.Item,{label:`Module`,name:`module`,style:{flex:1},children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,loading:v,optionFilterProp:`label`,placeholder:`Select module`,options:M,onChange:oe})}),(0,l.jsx)(s.Button,{"aria-label":`Add module`,icon:(0,l.jsx)(c.PlusOutlined,{}),style:{marginTop:30},onClick:()=>ce(`module`)})]})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Flow`,name:`flow`,children:(0,l.jsx)(s.AutoComplete,{maxLength:100,allowClear:!0,disabled:R,options:f,placeholder:b?`Loading flows`:`Enter flow`,onChange:se,filterOption:(e,t)=>t?.value?.toLowerCase().includes(e.toLowerCase())})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Step Order`,name:`step_order`,validateTrigger:[`onBlur`,`onChange`],children:(0,l.jsx)(s.Input,{maxLength:10,disabled:!0,placeholder:E?`Loading step order`:`Step order`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Action`,name:`keyword`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,disabled:z,optionFilterProp:`label`,placeholder:`Select action`,options:m,onChange:H})})}),(0,l.jsx)(s.Col,{xs:24,children:(0,l.jsx)(s.Form.Item,{label:`Description`,name:`description`,children:(0,l.jsx)(s.Input.TextArea,{rows:3,maxLength:255,disabled:z,placeholder:`Enter description`,showCount:!0,onBlur:e=>ae(`description`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Key`,name:`target`,rules:[{required:B.key,message:`Key is required for this action`}],children:(0,l.jsx)(s.Input,{maxLength:255,disabled:z||!!F&&!B.key,placeholder:z?`Select module and flow first`:F?B.key?`Required — Enter selector / locator`:`Not needed for this action`:`Select an action first`,onBlur:e=>ae(`target`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Tags`,name:`tags`,children:(0,l.jsx)(s.Input,{maxLength:200,disabled:z,placeholder:`Enter tags`,prefix:(0,l.jsx)(c.TagsOutlined,{className:`v1-input-icon`}),onBlur:e=>ae(`tags`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Value`,name:`value`,rules:[{required:B.value,message:`Value is required for this action`}],children:(0,l.jsx)(s.Input.TextArea,{rows:4,disabled:z||!!F&&!B.value,placeholder:z?`Select module and flow first`:F?B.value?`Required — Enter value`:`Not needed for this action`:`Select an action first`,onBlur:e=>ae(`value`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Expected`,name:`expected`,rules:[{required:B.expected,message:`Expected result is required for this action`}],children:(0,l.jsx)(s.Input.TextArea,{rows:4,disabled:z||!!F&&!B.expected,placeholder:z?`Select module and flow first`:F?B.expected?`Required — Enter expected result`:`Not needed for this action`:`Select an action first`,onBlur:e=>ae(`expected`,e.target.value)})})})]})}),(0,l.jsx)(`div`,{className:`v1-form-actions`,children:(0,l.jsx)(s.Form.Item,{children:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{type:`primary`,htmlType:`submit`,loading:O,disabled:z,children:`Submit`}),(0,l.jsx)(s.Button,{onClick:()=>{e.resetFields(),u([]),p([])},children:`Reset`})]})})})]})}),(0,l.jsx)(s.Modal,{title:`Add ${j.label}`,open:S.open,confirmLoading:w,okText:`Add`,onCancel:le,onOk:()=>{T(!0),ue()},destroyOnHidden:!0,children:(0,l.jsxs)(s.Form,{form:t,layout:`vertical`,colon:!1,className:`v1-form`,requiredMark:(e,{required:t})=>(0,l.jsxs)(l.Fragment,{children:[e,t&&(0,l.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),children:[(0,l.jsx)(s.Form.Item,{label:`Name`,name:`name`,children:(0,l.jsx)(s.Input,{maxLength:100,placeholder:`Enter ${j.label.toLowerCase()} name`,onBlur:e=>{t.setFieldsValue({name:rP(e.target.value)})}})}),(0,l.jsx)(s.Form.Item,{label:`Type`,name:`type`,children:(0,l.jsx)(s.Input,{disabled:!0})})]})})]})})]})}var cP=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}];function lP(){return(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsx)(n.t,{items:cP}),(0,l.jsx)(Jo,{moduleName:`lms-flows`,rowKey:`id`})]})}var uP=[`referenceId`,`ReferenceId`,`candidateId`,`CandidateId`,`entityId`,`EntityId`,`id`,`Id`,`_id`];function dP(e=uP){return function(t){if(!t||typeof t!=`object`)return``;for(let n of e){let e=t[n];if(e!=null&&e!==``)return String(e)}return``}}function fP(e,t=uP){if(!e||typeof e!=`object`)return[];let n=[];for(let r of t){let t=e[r];t!=null&&t!==``&&n.push(String(t))}return n}var pP=dP();function mP(e){return typeof e==`function`?e:typeof e==`string`?dP([e]):Array.isArray(e)?dP(e):pP}function hP(e,t,n){return!t||typeof t!=`object`?e:{...t,...e,id:e?.id??t?.id??n}}function gP(e,t,n={}){return{status:`success`,total:t,data:{data:e,...n}}}var _P=[`fields`,`fieldConfig`,`tabs`,`tabField`,`actionRules`,`actions`,`columnActions`];function vP(e){let t=e?.data??e,n={};for(let r of _P){let i=e?.[r]??t?.[r];i==null||Array.isArray(i)&&i.length===0||(n[r]=i)}return n}var yP=e=>String(e??``).replace(/[^a-zA-Z0-9]/g,``).toLowerCase();function bP(e,t,n){let r=(Array.isArray(n)?n:[n]).map(yP).filter(Boolean),i=r.length?e.findIndex(e=>r.includes(yP(e?.value))||r.includes(yP(e?.label))):-1;if(i===-1)return[...e,...t];let a=Number(e[i]?.order),o=Number.isFinite(a)?t.map((e,n)=>e.order==null||e.order===``?{...e,order:a+(n+1)/(t.length+1)}:e):t;return[...e.slice(0,i+1),...o,...e.slice(i+1)]}var xP=(e,t)=>pi(e,t).rows,SP=(e,t)=>{let{rows:n,total:r}=pi(e,t);return{rows:n,total:r}};function CP(e,t){return function(n,r,i,a={}){return e(t??n,r,i,a)}}function wP(e){return!e||typeof e!=`object`||typeof(e.fetchByKeys??e.fetch??e.function)!=`function`?null:{...e,fetchByKeys:typeof e.fetchByKeys==`function`?e.fetchByKeys:null,fetch:typeof e.fetch==`function`?e.fetch:null,function:typeof e.function==`function`?e.function:null,extractRows:typeof e.extractRows==`function`?e.extractRows:xP,mergeRow:typeof e.mergeRow==`function`?e.mergeRow:hP,fetchById:typeof e.fetchById==`function`?e.fetchById:null}}function TP({fetchSecondaryByKeys:e,fetchSecondary:t,extractSecondaryRows:n,fetchSecondaryById:r,secondaryKey:i,mergeRow:a,secondaryFetchLimit:o}){return!e&&!t&&!r?[]:[wP({key:i,fetchByKeys:e?(t,n,r)=>e(t,n,r):null,function:t?({moduleName:e,options:n})=>t(e,o,0,n):null,extractRows:n,fetchById:r,mergeRow:a})].filter(Boolean)}function EP(e){if(typeof e==`function`)return t=>{let n=e(t);return n==null||n===``?[]:[String(n)]};let t=typeof e==`string`?[e]:Array.isArray(e)&&e.length?e:uP;return e=>fP(e,t)}function DP(e,t){let n=new Map;return e.forEach(e=>{for(let r of t(e))n.has(r)||n.set(r,e)}),n}function OP({moduleName:e,limit:t,offset:n,options:r,keys:i,primaryResponse:a,primaryRows:o,pageRows:s,total:c,source:l}){return{moduleName:e,limit:t,offset:n,options:r,keys:i,primaryResponse:a,primaryRows:o,pageRows:s,total:c,source:l}}async function kP(e,t){if(typeof e.args==`function`){let n=e.args(t);return(e.fetch??e.function??e.fetchByKeys)(...Array.isArray(n)?n:[n])}if(Array.isArray(e.args))return(e.fetch??e.function??e.fetchByKeys)(...e.args);if(e.fetchByKeys&&Array.isArray(t.keys))return e.fetchByKeys(t.moduleName,t.keys,t.options,t);let n=e.fetch??e.function;return typeof n==`function`?n(t):null}function AP({fetchPrimaryPage:e,extractPrimaryPage:t=SP,fetchSecondaryByKeys:n,joinSources:r=[],fetchPrimary:i,extractPrimaryRows:a=xP,fetchSecondary:o,extractSecondaryRows:s=xP,fetchSecondaryById:c,primaryKey:l,secondaryKey:u,mergeRow:d=hP,secondaryFetchLimit:f=200,extraFields:p=[],extraFieldsAfter:m}){let h=Array.isArray(r)&&r.length?r.map(wP).filter(Boolean):TP({fetchSecondaryByKeys:n,fetchSecondary:o,extractSecondaryRows:s,fetchSecondaryById:c,secondaryKey:u,mergeRow:d,secondaryFetchLimit:f}),g=0;async function _(e,t,n,r){if(!e.fetchById||!r)return null;try{let i=await e.fetchById(n,r);return i&&t(i).includes(String(r))?i:null}catch(e){return console.error(`[mergedListApi] per-id join lookup failed for "${r}"`,e),null}}async function v(e,t,n,r,i){if(!n)return e;let a=t.extractRows(n,r)??[],o=mP(t.primaryKey??l),s=EP(t.key),c=DP(a,s);return Promise.all(e.map(async e=>{let n=o(e),a=c.get(n)??(i()?null:await _(t,s,r,n));return t.mergeRow(e,a,n)}))}async function y(e,t,n,r){let i=e;for(let e of t)i=await v(i,e.source,e.response,n,r);return i}function b(e,t,n){let r={};for(let e of n){if(!e)continue;let t=vP(e);for(let e of Object.keys(t))r[e]??(r[e]=t[e])}return p.length&&(r.fields=bP(r.fields??[],p,m)),gP(e,t,r)}async function x({moduleName:e,limit:t,offset:n,options:r,primaryResponse:i,primaryRows:a,pageRows:o,total:s}){return Promise.all(h.map(async c=>{try{let u=mP(c.primaryKey??l),d=[...new Set(o.map(u).filter(Boolean))];return c.fetchByKeys&&d.length===0?{source:c,response:null}:{source:c,response:await kP(c,OP({moduleName:e,limit:t,offset:n,options:r,keys:d,primaryResponse:i,primaryRows:a,pageRows:o,total:s,source:c}))}}catch(e){return console.error(`[mergedListApi] join fetch failed — rendering page without that join`,e),{source:c,response:null}}}))}async function S(n,r,i,a,o){let s=await e(n,r,i,a),c=t(s,n)??{},l=Array.isArray(c.rows)?c.rows:[],u=Number.isFinite(Number(c.total))?Number(c.total):l.length,d=await x({moduleName:n,limit:r,offset:i,options:a,primaryResponse:s,primaryRows:l,pageRows:l,total:u});return b(await y(l,d,n,o),u,[s,...d.map(e=>e.response)])}async function C(e,t,n,r,o){let s=await i(e,t,n,r),c=a(s,e)??[],l=c.length,u=c.slice(n,n+t),d=await x({moduleName:e,limit:t,offset:n,options:r,primaryResponse:s,primaryRows:c,pageRows:u,total:l});return b(await y(u,d,e,o),l,[s,...d.map(e=>e.response)])}return async function(t,n=10,r=0,i={}){let a=++g,o=()=>a!==g;return e?S(t,n,r,i,o):C(t,n,r,i,o)}}function jP(e,t,n={}){return AP({fetchPrimary:()=>Zk(e,t),extractPrimaryRows:Yk,fetchSecondary:Cn,fetchSecondaryById:Qk,secondaryFetchLimit:n.moduleFetchLimit??200})}function MP(e){let t=String(e??``).trim().split(/[^a-zA-Z0-9]+/).filter(Boolean);return t.length?`${t.map((e,t)=>t===0?e.toLowerCase():e[0].toUpperCase()+e.slice(1).toLowerCase()).join(``)}Count`:``}function NP(e){let t=Array.isArray(e?.stages)?e.stages:[];if(!t.length)return e;let n={};for(let e of t){let t=MP(e?.stageName);t&&(n[t]=Number(e?.count)||0)}return{...n,...e}}var PP=e=>{let t=Number(e?.targetSubmission??e?.targetSubmissions);return Number.isFinite(t)&&t>0?t:null};function FP({submittedCountField:e=`submittedCount`,progressField:t=`targetSubmissionProgress`}={}){return function(n,r,i){let a=hP(n,r,i),o=PP(a);return o!=null&&(a[t]=`${Number(a?.[e])||0} of ${o}`),a}}function IP(e={}){let t=FP();return AP({primaryKey:`_id`,extraFields:e.extraFields,extraFieldsAfter:e.extraFieldsAfter,fetchPrimaryPage:Cn,joinSources:[{key:`entityId`,fetchByKeys:(e,t,n,r)=>{let i=Math.max(1,Number(r?.limit)||10);return Xk(Math.floor((Number(r?.offset)||0)/i)+1,i)},extractRows:e=>(e?.items??[]).map(NP),mergeRow:(e,n,r)=>{let i=t(e,n,r);return n?._id&&(i.workflowId=n._id),i}}]})}async function LP(e,t=10,n=0,r={},i={}){return pi(await IP(i)(e,t,n,r),e)}async function RP(e,t,n,r=10,i=0,a={}){return pi(await jP(e,t)(n,r,i,a),n)}typeof window<`u`&&(window.__CORE_THEME_BUILD__=`2026-09-10T18:20:17.029Z`);var zP=tM,BP=Vb($M),VP=Vb(tN),HP=Vb(gN),UP=Vb(ON),WP=Vb(LN),GP=Vb(BN),KP=Vb(UN),qP=Vb(KN),JP=Vb(JN),YP=Vb(sP),XP=Vb(lP);exports.ADMIN_API_URL=t.v,exports.ADMIN_APP_ID=t.y,exports.APP_ID=t.b,exports.AUTH_URL=t.x,exports.ActivityNotesCard=Uc,exports.ActivityTab=Rc,exports.AddBatchCandidatePopup=Ij,exports.AddFormV1=xc,exports.AdminDashboard=tM,exports.AdminDashboardContent=BE,exports.AdminPage=zP,exports.AppAlert=Sc,exports.AppButton=n.ft,exports.AppShell=ub,exports.ApprovalActionBar=y_,exports.AssigneeAvatars=Wc,exports.AuthGuard=rb,exports.BILLING_STATUS_FLOW=$d,exports.BOOLEAN_API_KEYS=ag,exports.BOOLEAN_PARSEABLE_API_KEYS=Wm,exports.BULK_UPLOAD_DEFAULT_ACCEPT=Gc,exports.BULK_UPLOAD_DEFAULT_MAX_SIZE_MB=Kc,exports.Breadcrumb=n.t,exports.BulkUploadPage=HP,exports.BulkUploadPanel=el,exports.CANDIDATES_URL=t.S,exports.CONTRACT_C2C=U_,exports.CONTRACT_W2=H_,exports.CURRENCY_SYMBOLS=cu,exports.CalendarCard=A,exports.CoreThemeAdminApp=WE,exports.CoreThemeAdminRoutes=UE,exports.CustomPagination=ze,exports.DEFAULT_HOURS_POLICY=Vg,exports.DEFAULT_RESULTS_VIEW=tg,exports.DayLogModal=d_,exports.DescriptionBlock=pl,exports.DetailHeaderCard=np,exports.DetailViewPage=lp,exports.DetailViewV1=Qu,exports.DocumentViewer=n.En,exports.DynamicCards=Pt,exports.DynamicPopup=lk,exports.DynamicPopupRoute=Vj,exports.DynamicTabs=P,exports.EditFormV1=sm,exports.FIELD_TYPE_REGISTRY=Th,exports.FINANCE_APPROVAL_CONFIG=P_,exports.FINANCE_TYPE_CFO=D_,exports.FINANCE_TYPE_ONBOARDING_MANAGER=E_,exports.FINANCE_TYPE_ONBOARDING_MANAGER_REAPPROVE=A_,exports.FINANCE_TYPE_ONLY_FINANCE=O_,exports.FINANCE_TYPE_SUBMISSION_MANAGER=T_,exports.FINANCE_TYPE_SUBMISSION_MANAGER_REAPPROVE=k_,exports.FileListCard=Jv,exports.FinanceApprovalPanel=Dv,exports.FinanceAvatar=Ff,exports.FinanceBadge=zf,exports.FinanceDayCell=x_,exports.FinanceDivider=Df,exports.FinanceEmployeeCell=If,exports.FinanceEmptyState=wf,exports.FinanceEquation=Of,exports.FinanceHistoryTimeline=Mf,exports.FinanceHoursGrid=Cf,exports.FinanceKpiRow=Sf,exports.FinanceLine=Ef,exports.FinanceListToolbar=Bg,exports.FinanceMarginBadge=Bf,exports.FinanceMoneyCell=Rf,exports.FinanceRecordsTable=Uf,exports.FinanceRowChevron=Vf,exports.FinanceSection=Tf,exports.FinanceStatusPill=xf,exports.FinanceTextCell=Lf,exports.FinanceTimesheetAnalysis=C_,exports.FinanceWorkflowSteps=kf,exports.HOURS_MESSAGES=Hg,exports.Header=Cy,exports.HierarchyUserFilter=zt,exports.JOBS_URL=t.C,exports.LegacyAdminPage=BP,exports.ListView=Jo,exports.LmsHomePage=XP,exports.LmsTestForm=YP,exports.Login=db,exports.MailPopup=yD,exports.ManageModules=GP,exports.ManageSubmodules=KP,exports.ModuleRowActions=gm,exports.NotesPanel=v_,exports.NotesTab=Hc,exports.OPEN_AS_OPTIONS=Kh,exports.PAYROLL_STATUS_FLOW=ef,exports.POPUP_CONFIGS=Dj,exports.ParamCardView=Cm,exports.ParamListView=km,exports.PeriodBadgeTag=e_,exports.PreviewPopup=XD,exports.ProjectSelect=Bb,exports.ProofUploadPreview=__,exports.QuickLogBar=m_,exports.QuickLogSelectionBar=f_,exports.RESULTS_VIEW_OPTIONS=eg,exports.RejectionReasonModal=p_,exports.SUBMISSIONS_URL=t.T,exports.SearchBuilderV1=jg,exports.Sidebar=$y,exports.StatusBadge=Ng,exports.StatusBadgeTag=$g,exports.StickyNotesFullPage=VP,exports.StylishDynamicTabs=Fg,exports.TemplateEditor=Lg,exports.TestForm=UP,exports.TestingHomePage=JP,exports.TimelineGroups=Ac,exports.TimesheetDayCell=c_,exports.TipTapEditor=n.Dn,exports.UserForm=eM,exports.VendorShareDrawer=Gj,exports.ViewSummaryWidget=zi,exports.WizardPopup=nO,exports.ZinnextTableView=qP,exports.ZinnextTestForm=WP,exports.appNow=n.jn,exports.applyIntegrationStatus=n.qn,exports.approveSubmission=Ce,exports.buildAcceptAttr=Zc,exports.buildBooleanRequest=ug,exports.buildCsv=hf,exports.buildDailyRows=lf,exports.buildDayGradient=o_,exports.buildRateHistoryEntries=mv,exports.buildWeeklyRollup=ff,exports.clearSelectedProject=t.i,exports.colors=n.An,exports.computeFinance=ov,exports.computeHoursPolicy=Jg,exports.computeMarginBand=pf,exports.conditionMatches=n.i,exports.configureCoreTheme=t.E,exports.configuredFieldLabel=n.a,exports.createAllWorkflowsListFetcher=IP,exports.createMergedListFetcher=AP,exports.createModuleListFetchAdapter=CP,exports.createWorkflowStageListFetcher=jP,exports.currencySymbol=lu,exports.defaultMergeRow=hP,exports.deleteIntegrationConfig=n.ir,exports.deriveDayStats=cf,exports.describeCapacity=Xg,exports.downloadCsv=yf,exports.evaluateShowIfWith=n.o,exports.findEmployerRow=ev,exports.flattenGroups=Q_,exports.formatAmount=hu,exports.formatApp=n.Mn,exports.formatAppDateTime=n.Nn,exports.formatFileSize=Xc,exports.formatFinanceMoney=hv,exports.formatHours=Wd,exports.formatMoney=gu,exports.formatPercent=Kd,exports.formatRate=_u,exports.getActivity=n.pn,exports.getAllWorkflowsModuleList=LP,exports.getAppTimeZone=n.Pn,exports.getApprovalDate=Xd,exports.getBgcIntegrationConfig=n.Sr,exports.getBgcIntegrationSummary=n.Cr,exports.getBillingActionStates=tf,exports.getBooleanEligibleTypes=jh,exports.getCurrentRoleName=t.c,exports.getFieldLabel=_f,exports.getFieldType=Dh,exports.getFileExtension=Yc,exports.getFinanceApprovalConfig=z_,exports.getFormGroupsRaw=Lv,exports.getIntegrationConfig=n.kr,exports.getIntegrationConfigs=n.Ar,exports.getIntegrationSummary=n.jr,exports.getModuleConfig=Ie,exports.getModuleDataDetail=n.hn,exports.getPayrollActionStates=nf,exports.getPeriodBadgeConfig=Re,exports.getSearchPopup=Uh,exports.getSelectedProject=t.l,exports.getStoredToken=t.u,exports.getStoredUser=t.d,exports.getUserRoles=t.f,exports.getVMSApprove=we,exports.getValueStyle=vf,exports.getWorkflowStageModuleList=RP,exports.getWorkflowSteps=rf,exports.humanizeEvent=Yd,Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return ys}}),exports.indexFieldConfig=gf,exports.initialsOf=qd,exports.insertTokenAtCursor=Jm,exports.isBooleanEligible=Oh,exports.isBooleanParsable=Km,exports.isTester=t.p,exports.logout=t.h,exports.marginIncludesReferral=V_,exports.matchLocationTax=av,Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return _p}}),exports.normalizeContract=nv,Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return tl}}),exports.rateUnitLabel=du,exports.rateUnitShort=pu,exports.readActionButtons=Xh,exports.reconcileHours=Yg,exports.registerFieldType=Eh,exports.registerSearchPopup=Hh,exports.rejectSubmission=W,exports.resolveActivityMeta=Fc,exports.resolveAndCompute=sv,exports.resolveDayKind=Kg,exports.resolveFinanceInputs=iv,exports.resolveMergeKey=pP,exports.resolveMergedListKey=pP,exports.resolveOpenAs=Jh,exports.resolveRejectionReason=B_,exports.resolveResultsSearchPlaceholder=ig,exports.resolveResultsView=rg,exports.resolveSubmissionFinance=Rv,exports.saveBgcIntegrationConfig=n.ti,exports.saveIntegrationConfig=n.ii,exports.setSelectedProject=t._,exports.showIfConditions=n.c,exports.stageCountKey=MP,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return fb}}),exports.testIntegrationConnection=n.di,exports.toApp=n.In,exports.toNumber=mu,exports.tzLabel=n.Ln,exports.tzShortLabel=n.Rn,exports.unregisterSearchPopup=Wh,exports.useDropdownFields=zn,exports.useDropdownValues=Bi,exports.useEditForm=Yv,exports.useFieldConfig=Bn,exports.useFilterFields=Vn,exports.useMenuPermission=rr,exports.useModuleActions=lm,exports.useRecordRefresh=op,exports.validateBooleanQuery=qm,exports.validateBulkFile=Qc,exports.withAdminAppId=t.D,exports.withAppId=t.O,exports.withAuthGuard=Vb;
20
+ `).trim()}function jD(e){return e.replace(/•/g,`
21
+ `).split(/\n+/).map(e=>e.trim().replace(/^[-–—•]\s*/,``).trim()).filter(Boolean)}function MD(e){return jD(e.replace(/(?:^|\s)[-–—]\s+/g,`
22
+ `))}function ND(e){let t=e.match(/^([A-Za-z][A-Za-z&/ ]{1,28}?)\s*:\s*(\S.+)$/);if(!t)return null;let n=t[1].trim(),r=t[2].trim();return n.split(/\s+/).length>3||r.length>60?null:{fieldKey:n.toLowerCase().replace(/\s+/g,`-`),fieldLabel:OD(n),value:r}}function PD(e){let t=e.toLowerCase().replace(/[\s:.\-–—]+$/,``).trim();return wD.has(t)?TD.test(t)?`education`:ED.test(t)?`keySkills`:`overview`:null}function FD(e){let t=[],n={overview:[],keySkills:[],education:[]},r=`overview`;return e.forEach(e=>{let i=PD(e);if(i){r=i;return}if(r===`overview`){let n=ND(e);if(n){t.push(n);return}}n[r].push(e)}),{meta:t,overview:kD(n.overview),keySkills:kD(n.keySkills),education:kD(n.education)}}function ID(e){let t=[...CD].sort((e,t)=>t.length-e.length),n=RegExp(`\\b(${t.map(DD).join(`|`)})\\b\\s*:?`,`gi`),r=[...e.matchAll(n)];if(!r.length)return{meta:[],overview:kD(MD(e)),keySkills:[],education:[]};let i={overview:[],keySkills:[],education:[]},a=e.slice(0,r[0].index).trim();return a&&i.overview.push(...MD(a)),r.forEach((t,n)=>{let a=t[1].trim().toLowerCase(),o=t.index+t[0].length,s=n+1<r.length?r[n+1].index:e.length,c=MD(e.slice(o,s).trim());if(!c.length)return;let l=TD.test(a)?`education`:ED.test(a)?`keySkills`:`overview`;i[l].push(...c)}),{meta:[],overview:kD(i.overview),keySkills:kD(i.keySkills),education:kD(i.education)}}function LD(e){let t=AD(e);if(!t)return{meta:[],overview:[],keySkills:[],education:[]};let n=jD(t);return n.length>=4?FD(n):ID(t)}function RD({items:e}){return(0,l.jsx)(`ul`,{className:`jdv-ats-bullets`,children:e.map((e,t)=>(0,l.jsx)(`li`,{className:`jdv-ats-bullet-item`,children:e},t))})}function zD({raw:e=``,meta:t=[]}){let[n,r]=(0,o.useState)(!1),i=(0,o.useMemo)(()=>LD(e),[e]),a=t.length?t:i.meta,s=[];if(i.overview.length&&s.push({key:`overview`,title:`Overview`,items:i.overview}),i.keySkills.length&&s.push({key:`keySkills`,title:`Key Skills`,items:i.keySkills,card:!0,icon:`🛠️`}),i.education.length&&s.push({key:`education`,title:`Education`,items:i.education,card:!0,icon:`🎓`}),!a.length&&!s.length)return(0,l.jsx)(xD,{type:`secondary`,children:`No description available.`});let c=n?s:s.slice(0,SD),u=s.length-SD;return(0,l.jsxs)(`div`,{className:`jdv-ats-desc`,children:[a.length>0&&(0,l.jsx)(`div`,{className:`jdv-ats-meta-grid`,children:a.map(({fieldKey:e,fieldLabel:t,value:n})=>(0,l.jsxs)(`div`,{className:`jdv-ats-meta-row`,children:[(0,l.jsx)(`span`,{className:`jdv-ats-meta-key`,children:t}),(0,l.jsx)(`span`,{className:`jdv-ats-meta-val`,children:n})]},e??t))}),(0,l.jsx)(`div`,{className:`jdv-ats-sections`,children:c.map(e=>e.card?(0,l.jsxs)(`div`,{className:`education-block`,children:[(0,l.jsxs)(`div`,{className:`education-header`,children:[(0,l.jsx)(`span`,{children:e.icon}),(0,l.jsx)(`span`,{children:e.title})]}),(0,l.jsx)(`ul`,{className:`education-list`,children:e.items.map((e,t)=>(0,l.jsx)(`li`,{className:`education-list-item`,children:e},t))})]},e.key):(0,l.jsxs)(`div`,{className:`jdv-ats-section`,children:[(0,l.jsx)(`div`,{className:`jdv-ats-section-hd`,children:(0,l.jsx)(`span`,{children:e.title})}),(0,l.jsx)(RD,{items:e.items})]},e.key))}),u>0&&(0,l.jsx)(`span`,{className:`jdv-desc-toggle`,onClick:()=>r(e=>!e),children:n?`Show less`:`Show more (${u} more section${u>1?`s`:``})`})]})}var{Text:BD}=s.Typography;function VD(e){return e?e.trim().split(/\s+/).slice(0,2).map(e=>e[0].toUpperCase()).join(``):`?`}function HD(e){return e?e.name?e.name:e.fullName?e.fullName:e.firstName||e.lastName?[e.firstName,e.lastName].filter(Boolean).join(` `):e.candidateName??e.clientName??e.jobTitle??``:``}function UD(e){return e?e.email??e.emailId??e.emailAddress??``:``}function WD(e){return e?e.status?e.status:e.stage?e.stage:typeof e.isActive==`boolean`?e.isActive?`Active`:`Inactive`:``:``}function GD(e){return e==null||e===``?`-`:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?e.join(`, `):typeof e==`object`?e.label??e.name??Object.values(e).join(` `):String(e)}var KD=[`jobDescription`,`description`,`rawDescription`,`jobDescriptionText`];function qD(e){return String(e??``).toLowerCase()===`job`}function JD(e){let t=KD.includes(e.field),n=/description/i.test(e.label??``);return t||n}function YD({record:e}){let t=HD(e),n=UD(e),r=WD(e);return!t&&!n?null:(0,l.jsxs)(`div`,{className:`preview-profile-card`,children:[(0,l.jsxs)(`div`,{className:`preview-profile-card__info`,children:[(0,l.jsx)(s.Avatar,{className:`preview-profile-card__avatar`,children:VD(t)}),(0,l.jsxs)(`div`,{className:`preview-profile-card__text`,children:[t&&(0,l.jsx)(`span`,{className:`preview-profile-card__name`,children:t}),n&&(0,l.jsx)(`span`,{className:`preview-profile-card__email`,children:n})]})]}),r&&(0,l.jsx)(s.Tag,{className:`preview-profile-card__status`,children:r})]})}function XD({fields:e,moduleName:t,centralDocuments:r=[]}){let[i,a]=(0,o.useState)([]),[s,c]=(0,o.useState)(0),[u,d]=(0,o.useState)(!1);if(!e?.length)return null;function f(e){let t=String(e?.type??``).trim().toLowerCase(),n=`${e?.field??``} ${e?.label??``}`;return[`file`,`document`,`upload`].includes(t)||/resume|cv|document|attachment/i.test(n)}function p(e,t){a(e),c(t),d(!0)}return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`preview-field-grid`,children:e.map(e=>{let i=e.value,a=Array.isArray(i)&&i.length>0,o=qD(t)&&JD(e)&&typeof i==`string`&&i.trim(),s=f(e)?r.filter(t=>{let n=String(t?.fieldName??t?.field??t?.formField??t?.key??``).trim().toLowerCase(),r=String(e?.field??``).trim().toLowerCase();if(n&&r&&n===r)return!0;let i=`${e?.field??``} ${e?.label??``}`;return/resume|cv/i.test(i)?/resume|cv/i.test(`${n} ${t?.fileName??``} ${t?.name??``}`):!1}).map(t=>({name:t?.fileName||t?.name||t?.uploadedFileName||t?.originalName||e?.label||`Document`,url:t?.fileUrl||t?.downloadUrl||t?.signedUrl||t?.url||``,type:t?.mimeType||t?.contentType||t?.type})).filter(e=>e.url):[],c=f(e)?s.length?s:n.Bt(i).filter(e=>e.url):[];return c.length?(0,l.jsxs)(`div`,{className:`preview-field-card preview-field-card--documents`,children:[(0,l.jsx)(`span`,{className:`preview-field-card__label`,children:e.label}),(0,l.jsx)(`div`,{className:`preview-document-list`,children:c.map((e,t)=>(0,l.jsxs)(`button`,{type:`button`,className:`preview-document-link`,onClick:()=>p(c,t),title:`Preview ${e.name||`document`}`,children:[(0,l.jsx)(`span`,{className:`preview-document-link__icon`,"aria-hidden":`true`,children:`▣`}),(0,l.jsx)(`span`,{className:`preview-document-link__name`,children:e.name||`Document ${t+1}`}),(0,l.jsx)(`span`,{className:`preview-document-link__action`,children:`Preview`})]},`${e.url}-${t}`))})]},e.field??e.label):a?i.map((t,n)=>(0,l.jsxs)(`div`,{className:`preview-field-card`,children:[(0,l.jsxs)(`span`,{className:`preview-field-card__label`,children:[e.label,i.length>1?` (${n+1})`:``]}),(0,l.jsx)(`span`,{className:`preview-field-card__value`,children:GD(t)})]},`${e.field??e.label}-${n}`)):o?(0,l.jsxs)(`div`,{className:`preview-field-card preview-field-card--description`,children:[(0,l.jsx)(`span`,{className:`preview-field-card__label`,children:e.label}),(0,l.jsx)(`div`,{className:`preview-field-card__description`,children:(0,l.jsx)(zD,{raw:i})})]},e.field??e.label):(0,l.jsxs)(`div`,{className:`preview-field-card`,children:[(0,l.jsx)(`span`,{className:`preview-field-card__label`,children:e.label}),(0,l.jsx)(`span`,{className:`preview-field-card__value`,children:GD(i)})]},e.field??e.label)})}),(0,l.jsx)(n.En,{documents:i,open:u,onClose:()=>d(!1),initialIndex:s})]})}function ZD(){let e=(0,d.useNavigate)(),{moduleName:t=``,record:r=null}=(0,d.useLocation)().state??{},i=r?.id??r?._id,[c,u]=(0,o.useState)([]),[f,p]=(0,o.useState)(!!(t&&i)),[m,h]=(0,o.useState)(null),[g,_]=(0,o.useState)([]),[v,y]=(0,o.useState)(0),b=(0,o.useRef)(null),x=(0,o.useRef)(null),S=(0,o.useRef)([]),C=(0,o.useRef)([]);(0,o.useEffect)(()=>{if(!t||!i)return;let e=!1;return Promise.all([a.r({module:t,id:i}),n.yn(t,i).catch(()=>({data:[]}))]).then(([t,n])=>{e||(u(Array.isArray(t)?t:[]),_(Array.isArray(n)?n:n?.data??[]),p(!1))}).catch(t=>{e||(h(t.message||`Failed to load preview`),_([]),p(!1))}),()=>{e=!0}},[t,i]);function w(){e(-1)}function T(e,t){return e?.label??e?.name??`Section ${t+1}`}function E(e){let t=b.current,n=C.current[e];if(!t||!n)return;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=(t.querySelector(`.preview-stepper-wrap`)?.offsetHeight??0)+12,o=t.scrollTop+i.top-r.top-a;y(e),t.scrollTo({top:Math.max(0,o),behavior:`smooth`})}function D(){let e=b.current;if(!e||!C.current.length)return;let t=e.getBoundingClientRect().top+(e.querySelector(`.preview-stepper-wrap`)?.offsetHeight??0)+24,n=0;C.current.forEach((e,r)=>{e&&e.getBoundingClientRect().top<=t&&(n=r)}),y(e=>e===n?e:n)}(0,o.useEffect)(()=>{let e=x.current,t=S.current[v];if(!e||!t)return;let n=t.offsetLeft-(e.clientWidth-t.offsetWidth)/2,r=Math.max(0,e.scrollWidth-e.clientWidth);e.scrollTo({left:Math.min(Math.max(0,n),r),behavior:`smooth`})},[v,c.length]);function O(){return c.length?(0,l.jsx)(`div`,{ref:x,className:`preview-stepper-wrap`,"aria-label":`Preview sections`,children:(0,l.jsx)(`div`,{className:`preview-stepper`,children:c.map((e,t)=>(0,l.jsxs)(`div`,{className:`preview-stepper__segment`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`preview-stepper__item`,ref:e=>{S.current[t]=e},onClick:()=>E(t),"aria-current":v===t?`step`:void 0,title:`Go to ${T(e,t)}`,children:[(0,l.jsx)(`span`,{className:[`preview-stepper__circle`,t<v?`preview-stepper__circle--done`:``,t===v?`preview-stepper__circle--active`:``].filter(Boolean).join(` `),children:t+1}),(0,l.jsx)(`span`,{className:[`preview-stepper__label`,t===v?`preview-stepper__label--active`:``].filter(Boolean).join(` `),children:T(e,t)})]}),t<c.length-1&&(0,l.jsx)(`span`,{className:[`preview-stepper__line`,t<v?`preview-stepper__line--done`:``].filter(Boolean).join(` `),"aria-hidden":`true`})]},e.name??e.id??t))})}):null}let k=(0,l.jsxs)(`div`,{className:`preview-modal-header`,children:[(0,l.jsx)(`span`,{className:`preview-modal-module`,children:t.toUpperCase()}),(0,l.jsx)(`span`,{className:`preview-modal-title`,children:t?` Details`:`Preview`})]}),A=(0,l.jsx)(`div`,{className:`wizard-footer preview-scroll-footer`,children:(0,l.jsx)(`div`,{className:`wizard-footer-nav`,children:(0,l.jsx)(s.Button,{onClick:w,children:`Close`})})});function j(){return!t||!i?(0,l.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:`Preview id is missing.`}):f?(0,l.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:(0,l.jsx)(s.Spin,{size:`small`})}):m?(0,l.jsx)(`div`,{className:`job-preview-content job-preview-status job-preview-error`,children:m}):c.length?(0,l.jsx)(`div`,{className:`preview-section-list`,children:c.map((e,n)=>(0,l.jsxs)(`section`,{ref:e=>{C.current[n]=e},className:`preview-section-card`,"data-section-index":n,children:[(0,l.jsxs)(`div`,{className:`preview-section-card__header`,children:[(0,l.jsx)(`span`,{className:`preview-section-card__number`,children:n+1}),(0,l.jsx)(`span`,{className:`preview-section-card__title`,children:T(e,n)})]}),(0,l.jsx)(`div`,{className:`preview-section-card__body`,children:e.fields?.length>0?(0,l.jsx)(XD,{fields:e.fields,moduleName:t,centralDocuments:g}):(0,l.jsx)(BD,{type:`secondary`,children:`No fields in this group.`})})]},e.name??e.id??n))}):(0,l.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:`No form groups found.`})}return(0,l.jsx)(s.Modal,{centered:!0,className:`wizard-modal preview-modal preview-scroll-modal`,footer:A,open:!0,title:k,width:`min(900px, calc(100vw - 32px))`,onCancel:w,maskClosable:!1,children:(0,l.jsxs)(`div`,{ref:b,className:`wizard-body preview-scroll-body`,onScroll:D,children:[!f&&!m&&c.length>0&&O(),r&&(0,l.jsx)(YD,{record:r}),j()]})})}var{Text:QD}=s.Typography,{TextArea:$D}=s.Input,eO=[{key:`basic`,title:`Basic Info`,description:`General details`,fields:[{name:`firstName`,label:`First Name`,type:`input`,required:!0,placeholder:`Enter first name`,span:12},{name:`lastName`,label:`Last Name`,type:`input`,required:!0,placeholder:`Enter last name`,span:12},{name:`email`,label:`Email Address`,type:`input`,required:!0,placeholder:`Enter email address`,rules:[{type:`email`,message:`Please enter a valid email`}]},{name:`phone`,label:`Phone`,type:`input`,placeholder:`Enter phone number`}]},{key:`details`,title:`Details`,description:`Additional info`,fields:[{name:`role`,label:`Role`,type:`select`,required:!0,placeholder:`Select a role`,span:12,options:[{label:`Developer`,value:`developer`},{label:`Designer`,value:`designer`},{label:`Manager`,value:`manager`},{label:`Analyst`,value:`analyst`}]},{name:`department`,label:`Department`,type:`select`,placeholder:`Select department`,span:12,options:[{label:`Engineering`,value:`engineering`},{label:`Product`,value:`product`},{label:`Operations`,value:`operations`},{label:`Finance`,value:`finance`}]},{name:`notes`,label:`Notes`,type:`textarea`,placeholder:`Any additional notes...`}]},{key:`confirm`,title:`Confirm`,description:`Review & submit`,isReview:!0}];function tO(e){switch(e.type){case`select`:return(0,l.jsx)(s.Select,{placeholder:e.placeholder,options:e.options,style:{width:`100%`}});case`textarea`:return(0,l.jsx)($D,{rows:3,placeholder:e.placeholder});case`number`:return(0,l.jsx)(s.InputNumber,{placeholder:e.placeholder,style:{width:`100%`}});default:return(0,l.jsx)(s.Input,{type:e.inputType||`text`,placeholder:e.placeholder})}}function nO({steps:e,form:t}){let n=t.getFieldsValue(),r=e.filter(e=>!e.isReview);return r.some(e=>(e.fields||[]).some(e=>n[e.name]!==void 0&&n[e.name]!==``))?(0,l.jsxs)(`div`,{className:`wizard-review-content`,children:[r.map(e=>(0,l.jsxs)(`div`,{className:`wizard-review-section`,children:[(0,l.jsx)(QD,{className:`wizard-review-section-title`,children:e.title}),(0,l.jsx)(`div`,{className:`wizard-review-grid`,children:(e.fields||[]).map(e=>{let t=n[e.name],r=t===void 0||t===``||t===null?`—`:String(t);return(0,l.jsxs)(`div`,{className:`wizard-review-row`,children:[(0,l.jsx)(`span`,{className:`wizard-review-label`,children:e.label}),(0,l.jsx)(`span`,{className:`wizard-review-separator`,children:`:`}),(0,l.jsx)(`span`,{className:`wizard-review-value`,children:r})]},e.name)})})]},e.key)),(0,l.jsxs)(`div`,{className:`wizard-review-confirm-note`,children:[(0,l.jsx)(c.CheckCircleOutlined,{className:`wizard-review-confirm-icon`}),(0,l.jsx)(QD,{type:`secondary`,children:`Please review the information above before submitting.`})]})]}):(0,l.jsx)(`div`,{className:`wizard-review-empty`,children:(0,l.jsx)(QD,{type:`secondary`,children:`No data entered yet.`})})}function rO(){let[e]=s.Form.useForm(),t=(0,d.useNavigate)(),{title:n=`Wizard`,moduleName:r=``,steps:i=eO,onSubmit:a}=(0,d.useLocation)().state??{},[c,u]=(0,o.useState)(0),f=i[c],p=c===i.length-1,m=c===0;function h(){t(-1)}function g(){let t=(f.fields||[]).map(e=>e.name);e.validateFields(t.length>0?t:void 0).then(()=>{u(e=>e+1)})}function _(){u(e=>e-1)}function v(){let n=e.getFieldsValue();typeof a==`function`&&a(n),t(-1)}let y=i.map((e,t)=>({title:e.title,description:e.description,status:t<c?`finish`:t===c?`process`:`wait`})),b=r?`${n} — ${r}`:n;return(0,l.jsxs)(s.Modal,{open:!0,title:b,footer:(0,l.jsxs)(`div`,{className:`wizard-footer`,children:[(0,l.jsx)(s.Button,{onClick:h,children:`Cancel`}),(0,l.jsxs)(`div`,{className:`wizard-footer-nav`,children:[!m&&(0,l.jsx)(s.Button,{onClick:_,children:`Back`}),p?(0,l.jsx)(s.Button,{type:`primary`,onClick:v,children:`Submit`}):(0,l.jsx)(s.Button,{type:`primary`,onClick:g,children:`Next`})]})]}),onCancel:h,width:`min(680px, calc(100vw - 32px))`,centered:!0,className:`wizard-modal`,children:[(0,l.jsx)(`div`,{className:`wizard-steps-container`,children:(0,l.jsx)(s.Steps,{current:c,items:y,size:`small`,className:`wizard-steps`})}),(0,l.jsx)(`div`,{className:`wizard-body`,children:(0,l.jsxs)(s.Form,{form:e,layout:`vertical`,children:[i.filter(e=>!e.isReview).map((e,t)=>(0,l.jsx)(`div`,{style:{display:t===c?`block`:`none`},children:(0,l.jsx)(s.Row,{gutter:16,children:(e.fields||[]).map(e=>(0,l.jsx)(s.Col,{span:e.span||24,children:(0,l.jsx)(s.Form.Item,{name:e.name,label:e.label,rules:[...e.required?[{required:!0,message:`${e.label} is required`}]:[],...e.rules||[]],children:tO(e)})},e.name))})},e.key)),f.isReview&&(0,l.jsx)(nO,{steps:i,form:e})]})})]})}function iO({titleText:e,titleIcon:t}){let n=t===`delete`;return(0,l.jsxs)(`span`,{className:`dynamic-popup__header`,children:[(0,l.jsx)(`span`,{className:`dynamic-popup__header-icon-box${n?` dynamic-popup__header-icon-box--danger`:``}`,children:n?(0,l.jsx)(c.DeleteOutlined,{}):(0,l.jsx)(c.AppstoreOutlined,{})}),(0,l.jsx)(`span`,{className:`dynamic-popup__header-label`,children:e})]})}function aO({note:e,description:t,showSelectedCount:r,count:i,itemLabel:a,bodyText:o,deleteError:s}){return(0,l.jsxs)(l.Fragment,{children:[e&&(0,l.jsx)(n.On,{variant:`body`,color:`secondary`,className:`dynamic-popup__note`,children:e}),t&&(0,l.jsx)(n.On,{variant:`body`,className:`dynamic-popup__description`,children:t}),r&&i>0&&(0,l.jsxs)(n.On,{variant:`body`,className:`dynamic-popup__selected-count`,children:[`Changing status for `,(0,l.jsx)(`strong`,{children:i}),` selected `,a,`.`]}),o&&(0,l.jsx)(n.On,{variant:`body`,children:o}),s&&(0,l.jsx)(n.On,{variant:`caption`,color:`danger`,className:`dynamic-popup__error`,children:s})]})}function oO({footerNote:e}){return e?(0,l.jsx)(n.On,{variant:`caption`,color:`secondary`,className:`dynamic-popup__footer-note`,children:e}):null}function sO(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t?.[n]??``).trim()}function cO(e){return String(e).replace(/\(\s*\)/g,``).replace(/\s+/g,` `).replace(/(^|\s)([-–—·|])(?=\s*\2)/g,``).replace(/^[\s\-–—·|]+/,``).replace(/[\s\-–—·|]+$/,``).trim()}function lO(e){if(!e)return!1;let t=new Date(e).getTime();return Number.isNaN(t)||t<=0?!1:t<=Date.now()+864e5}function uO(e){if(!lO(e))return``;let t=new Date(e),n=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date,i=Math.round((n(r)-n(t))/864e5);if(i<=0)return`Today`;if(i===1)return`Yesterday`;if(i<=30)return`${i} days ago`;let a=(r.getFullYear()-t.getFullYear())*12+(r.getMonth()-t.getMonth());if(r.getDate()<t.getDate()&&--a,a=Math.max(1,a),a<12)return`${a} month${a===1?``:`s`} ago`;let o=Math.floor(a/12);return`${o} year${o===1?``:`s`} ago`}function dO(e){let t=Array.isArray(e?.submissionHistory)?e.submissionHistory:[],n=[e?.lastSubmittedAt,e?.submittedAt,e?.updatedAt,...t.map(e=>e?.submittedAt||e?.updatedAt)].filter(Boolean);return n.length?n.reduce((e,t)=>new Date(t)>new Date(e)?t:e):null}function fO(e){let t=Array.isArray(e?.submissionHistory)?e.submissionHistory:[],n=[e?.lastSubmittedAt,e?.submittedAt,...t.map(e=>e?.submittedAt)].filter(Boolean);return n.length?n.reduce((e,t)=>new Date(t)>new Date(e)?t:e):null}function pO(e,t){if(typeof e==`string`)return{label:e,value:e};if(e?.label!==void 0&&e?.value!==void 0&&!t?.labelTemplate&&!t?.valueKey)return e;let{labelKey:n,valueKey:r,labelTemplate:i}=t??{},a=i?.includes(`{lastdate}`)?{...e,lastdate:uO(dO(e))}:e,o=(i?cO(sO(i,a)):null)||(n?e?.[n]:null)||e?.name||e?.fullName||e?.candidateName||e?.title||e?.displayName||e?.text||e?.applicantReferenceId||e?.applicantRefrenceId||String(Object.values(e||{})[0]??``),s=(r?e?.[r]:null)??e?.id??e?._id??e?.applicantReferenceId??e?.applicantRefrenceId??String(Object.values(e||{})[0]??``),c=e?.disabled===!0||e?.disable===!0,l=String(e?.optionNote??``).trim(),u={label:l?`${String(o)} — ${l}`:String(o),value:String(s),_raw:e};if(c&&(u.disabled=!0),l&&(u.title=l),e?.isSubmitted===!0||e?.alreadySubmitted===!0){u.alreadySubmitted=!0,u.existingSubmissionId=String(e?.existingSubmissionId??e?.jobSubmissionId??e?.submissionId??``);let t=e?.submittedAt||fO(e);t&&(u.submittedAt=t)}if(e?.isFromSubmission===!0&&e?.submissionId){u.isFromSubmission=!0,u.priorSubmissionId=String(e.submissionId);let t=e?.lastSubmittedAt||fO(e);t&&(u.priorSubmittedAt=t)}return u}function mO(e,t){return(t?.[e.optionsKey]??e.defaultOptions??[]).map(t=>pO(t,e))}function hO(e={}){return{selectedIds:[],selectedRecords:[],moduleName:``,removedIds:[],...e}}var gO=`DD MMM YYYY`,_O=`DD MMM YYYY, h:mm A`;function vO(e,t){if(e==null||e===``)return``;let n=(0,u.default)(e);return n.isValid()?t===`relative`?uO(e)||(lO(e)?n.format(gO):`Not updated`):lO(e)?n.format(gO):``:String(e)}function yO(e,t){return e?String(e).includes(`{`)?cO(sO(e,t)):String(t?.[e]??e).trim():``}function bO(e){if(e?.alreadySubmitted){let t=e?.submittedAt?(0,u.default)(e.submittedAt):null;return{tone:`blocked`,tooltip:t?.isValid()?`Already submitted to this job on ${t.format(_O)}`:`Already submitted to this job — a candidate can only be submitted once per job`}}if(e?.isFromSubmission){let t=e?.priorSubmittedAt?(0,u.default)(e.priorSubmittedAt):null;return{tone:`history`,tooltip:t?.isValid()?`Previously submitted on ${t.format(_O)} — this form will prefill from it`:`Submitted to another job before — this form will prefill from it`}}return null}function xO(e,t){return e?.alreadySubmitted||!e?.disabled?``:String(t?.message??e?.title??``).trim()}function SO({meta:e}){return(0,l.jsx)(`div`,{className:`dynamic-popup__option-dates`,children:e.map(e=>(0,l.jsxs)(o.Fragment,{children:[(0,l.jsx)(`span`,{className:`dynamic-popup__option-date-label`,children:e.label}),(0,l.jsx)(`span`,{className:`dynamic-popup__option-date-value`,children:e.text})]},e.label))})}function CO({option:e,layout:t}){let n=e?._raw??e??{},r=yO(t.id,n),i=yO(t.title,n)||String(e?.label??``),a=yO(t.subtitle,n),o=yO(t.titleAccent?.key,n),u=yO(t.titleAccent?.toneKey,n),d=t.titleAccent?.prefix??``,f=(t.meta??[]).map(e=>({label:e.label,text:vO(n?.[e.key],e.type)})).filter(e=>e.text),p=xO(e,n),m=bO(e);return(0,l.jsxs)(`div`,{className:`dynamic-popup__option`,children:[(0,l.jsx)(`span`,{className:`dynamic-popup__option-tick${m?` dynamic-popup__option-tick--${m.tone}`:``}`,children:m&&(0,l.jsx)(s.Tooltip,{title:m.tooltip,placement:`topLeft`,children:(0,l.jsx)(c.CheckCircleFilled,{"aria-label":m.tooltip})})}),(0,l.jsxs)(`div`,{className:`dynamic-popup__option-main`,children:[(0,l.jsxs)(`div`,{className:`dynamic-popup__option-head`,children:[r&&(0,l.jsx)(`span`,{className:`dynamic-popup__option-id`,children:r}),(0,l.jsxs)(`span`,{className:`dynamic-popup__option-title`,children:[(0,l.jsx)(`span`,{className:`dynamic-popup__option-title-text`,children:i}),o&&(0,l.jsx)(`span`,{className:`dynamic-popup__option-title-accent${u?` dynamic-popup__option-title-accent--${u}`:``}`,children:`${d}${o}`})]}),p&&(0,l.jsx)(`span`,{className:`dynamic-popup__option-flag`,children:p})]}),a&&(0,l.jsx)(`div`,{className:`dynamic-popup__option-sub`,children:a})]}),e?.alreadySubmitted?(0,l.jsx)(`span`,{className:`dynamic-popup__option-onjob`,children:`On this job`}):f.length>0&&(0,l.jsx)(SO,{meta:f})]})}var{Text:wO}=s.Typography,{TextArea:TO}=s.Input,EO=[{label:`$`,value:`$`},{label:`EUR`,value:`EUR`},{label:`GBP`,value:`GBP`},{label:`INR`,value:`INR`}],DO=[{label:`Hourly`,value:`Hourly`},{label:`Daily`,value:`Daily`},{label:`Weekly`,value:`Weekly`},{label:`Monthly`,value:`Monthly`},{label:`Yearly`,value:`Yearly`}];function OO(e=[]){return e.map(e=>{if(!e||typeof e!=`object`)return e;let t=[e.value,e.user_id,e.userId,e.USER_ID,e.legacyUserId,e.id,e._id].find(e=>e!=null&&String(e).trim()!==``),n=t==null?``:String(t).trim();return{...e,value:n}}).filter(e=>typeof e!=`object`||!e||String(e.value??``).trim()!==``)}function kO({field:e,value:t,onChange:n}){return(0,l.jsx)(s.Input,{value:t,onChange:n,placeholder:e.placeholder,maxLength:e.maxLength,prefix:(0,l.jsx)(c.CrownOutlined,{})})}function AO({field:e,value:t,onChange:n}){return(0,l.jsx)(TO,{value:t,onChange:n,rows:e.rows??5,placeholder:e.placeholder})}function jO({field:e,options:t,value:n,onChange:r}){let i=OO(t);return(0,l.jsx)(s.Select,{showSearch:!0,value:n,onChange:r,options:i,placeholder:e.placeholder,className:`dynamic-popup__field-select`,optionFilterProp:`label`,prefix:(0,l.jsx)(c.CrownOutlined,{})})}function MO({field:e,options:t,value:n,onChange:r}){let i=OO(t);return(0,l.jsx)(s.Select,{mode:`multiple`,showSearch:!0,value:n,onChange:r,options:i,placeholder:e.placeholder,className:`dynamic-popup__field-select`,optionFilterProp:`label`,prefix:(0,l.jsx)(c.CrownOutlined,{})})}function NO({field:e,options:t,onSearch:n,value:r,onChange:i,popupContext:a}){let o=OO(t),u=e.optionLayout,d=new Map(o.map(e=>[String(e?.value??``),e]));async function f(t,n){if(e.multiple){i?.(Array.isArray(t)?t:[]);return}let r=n??d.get(String(t??``));(typeof e.onSelectGuard!=`function`||await e.onSelectGuard({value:t,option:r,field:e,popupContext:a,confirm:s.Modal.confirm})!==!1)&&i?.(t)}return(0,l.jsx)(s.Select,{mode:e.multiple?`multiple`:void 0,showSearch:!0,filterOption:!1,notFoundContent:e.notFoundContent??null,value:r,onChange:f,options:o,placeholder:e.placeholder,onSearch:n,className:`dynamic-popup__field-select${u?` dynamic-popup__field-select--rich`:``}`,popupClassName:u?`dynamic-popup__option-dropdown`:void 0,listHeight:u?340:void 0,optionLabelProp:`label`,optionRender:u?e=>(0,l.jsx)(CO,{option:e?.data??e,layout:u}):void 0,prefix:(0,l.jsx)(c.CrownOutlined,{})})}function PO({field:e,mentionOpts:t,onMentionSearch:n,value:r,onChange:i}){let a=Number(e.maxLength)>0?Number(e.maxLength):void 0,o=String(r??``).length;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.Mentions,{value:r,onChange:i,rows:e.rows??5,placeholder:e.placeholder,prefix:`@`,options:t,onSearch:n,maxLength:a,className:`dynamic-popup__mention-textarea`}),a?(0,l.jsxs)(`div`,{className:`dynamic-popup__char-count`,style:{textAlign:`right`,fontSize:12,marginTop:4,color:o>a*.9?`#b45309`:`#8c8c8c`},children:[o,` / `,a]}):null]})}function FO({field:e={},value:t={},onChange:n}){let r=t.period??`Hourly`,i=t.isRange??!1;function a(e){n?.({...t,...e})}(0,o.useEffect)(()=>{let e={};t.currency??(e.currency=`$`),t.period??(e.period=`Hourly`),Object.keys(e).length&&n?.({...t,...e})},[]);let c=Number(i?t.maxAmount:t.amount),u=i&&t.minAmount!=null&&t.maxAmount!=null&&Number(t.maxAmount)<=Number(t.minAmount),d=e.rateCeiling!=null&&Number.isFinite(c)&&c>Number(e.rateCeiling);return(0,l.jsxs)(`div`,{children:[(0,l.jsxs)(s.Space.Compact,{style:{width:`100%`},children:[i?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.InputNumber,{controls:!1,placeholder:`From`,value:t.minAmount,onChange:e=>a({minAmount:e}),style:{flex:1}}),(0,l.jsx)(s.InputNumber,{controls:!1,placeholder:`To`,value:t.maxAmount,onChange:e=>a({maxAmount:e}),style:{flex:1}})]}):(0,l.jsx)(s.InputNumber,{controls:!1,placeholder:`0`,value:t.amount,onChange:e=>a({amount:e}),style:{flex:2}}),(0,l.jsx)(s.Select,{value:t.currency??`$`,options:EO,onChange:e=>a({currency:e}),style:{width:80}}),(0,l.jsx)(s.Select,{value:r,options:DO,onChange:e=>a({period:e}),style:{width:110}})]}),(u||d)&&(0,l.jsxs)(`div`,{style:{marginTop:4},children:[u&&(0,l.jsx)(wO,{type:`danger`,style:{fontSize:12,display:`block`},children:`To rate must be greater than From rate.`}),d&&(0,l.jsxs)(wO,{type:`danger`,style:{fontSize:12,display:`block`},children:[`Rate must not exceed the client rate (`,e.rateCeiling,`).`]})]}),(0,l.jsxs)(s.Space,{size:`small`,style:{marginTop:8},children:[(0,l.jsx)(s.Switch,{checked:i,onChange:e=>a({isRange:e})}),(0,l.jsx)(`span`,{children:`Range`})]})]})}function IO({field:e,value:t,onChange:n}){return(0,l.jsx)(s.DatePicker,{value:t,onChange:n,placeholder:e.placeholder??`Select date`,style:{width:`100%`},format:`YYYY-MM-DD`})}function LO({field:e,checked:t,onChange:n}){return(0,l.jsx)(s.Checkbox,{checked:t,onChange:n,children:e.checkboxLabel})}function RO({field:e,value:t,onChange:n}){return(0,l.jsx)(s.InputNumber,{value:t,onChange:n,min:e.min,max:e.max,placeholder:e.placeholder,style:{width:`100%`}})}function zO({options:e,value:t,onChange:n}){return(0,l.jsx)(s.Radio.Group,{value:t,onChange:n,options:e})}var BO={input:kO,text:kO,textarea:AO,select:jO,"multi-select":MO,"search-select":NO,"mention-textarea":PO,"candidate-rate":FO,"priority-checkbox":LO,"date-picker":IO,number:RO,radio:zO};function VO(e){return e===`priority-checkbox`?{valuePropName:`checked`}:{}}var HO=new Set([`input`,`text`,`textarea`,`mention-textarea`]);function UO({form:e,fields:t,initialValues:r,dynamicOptions:i,popupContext:a,extraData:o,removedIds:c,setRemovedIds:u,showAlreadyAssigned:d,onValuesChange:f,getSearchHandler:p,getMentionSearchHandler:m,mentionOptions:h}){let g=(o?.recruitersData??[]).filter(e=>{let t=String(e?.user_id??e?.id??e?.userId??``);return t&&!c.includes(t)}),_=d&&o,v=new Set(d?g.map(e=>String(e?.user_id??e?.id??e?.userId??``).trim()).filter(Boolean):[]),y=e=>v.size===0||!Array.isArray(e)?e:e.filter(e=>!v.has(String((e&&typeof e==`object`?e.value??e.id:e)??``).trim()));return!t.length&&!_?null:(0,l.jsxs)(l.Fragment,{children:[_&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`dynamic-popup__already-assigned`,children:[(0,l.jsx)(n.On,{variant:`caption`,color:`secondary`,children:`Already Assigned People`}),(0,l.jsx)(`div`,{style:{marginTop:6,display:`flex`,flexWrap:`wrap`,gap:6},children:g.length===0?(0,l.jsx)(n.On,{variant:`caption`,color:`secondary`,children:`No one is currently assigned to this job.`}):g.map(e=>{let t=String(e?.user_id??e?.id??e?.userId??``),n=e?.name??e?.user_name??e?.userName??e?.email??`Assigned user`;return(0,l.jsx)(s.Tag,{closable:!0,onClose:()=>{t&&u(e=>Array.from(new Set([...e,t])))},children:n},t||n)})})]}),(0,l.jsx)(s.Divider,{style:{margin:`12px 0`}})]}),t.length>0&&(0,l.jsx)(s.Form,{form:e,layout:`vertical`,initialValues:r,onValuesChange:(e,t)=>f(t),children:WO(t).map(e=>GO(e,e=>{let t=y(i[e.name]??mO(e,a)),r=p(e),o=m(e),c=h[e.name]??[],u=VO(e.type),d=BO[e.type],f=[];return e.required&&f.push({required:!0,message:`${e.label||`This field`} is required`}),typeof e.validator==`function`&&f.push({validator:(t,n)=>{let r=e.validator(n,a);return r?Promise.reject(Error(r)):Promise.resolve()}}),HO.has(e.type)&&f.push(n.cn({label:e.label,field:e.name,type:e.type})),(0,l.jsx)(s.Form.Item,{name:e.name,label:e.label,rules:f,...u,children:d?(0,l.jsx)(d,{field:e,options:t,onSearch:r,mentionOpts:c,onMentionSearch:o,popupContext:a}):null},e.name)}))})]})}function WO(e){let t=[];for(let n of e){let e=t[t.length-1];n.inlineRow&&e?.inlineRow===n.inlineRow?e.fields.push(n):t.push({inlineRow:n.inlineRow,fields:[n]})}return t.map(e=>e.fields)}function GO(e,t){return e.length===1?t(e[0]):(0,l.jsx)(`div`,{style:{display:`flex`,gap:8,alignItems:`flex-start`},children:e.map((e,n)=>(0,l.jsx)(`div`,{style:{flex:n===0?2:1,minWidth:0},children:t(e)},e.name))},`row-${e.map(e=>e.name).join(`-`)}`)}function KO(e){return[`select`,`multi-select`,`search-select`,`radio`].includes(e?.type)&&e?.dataSource===`master`&&e?.masterName}function qO(e){let t=e?.data??e;return Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.items)?t.items:Array.isArray(t?.rows)?t.rows:Array.isArray(t?.records)?t.records:[]}function JO(e){let t=String(e?.masterName??``).trim().toLowerCase();return t===`clientsubmissions`||t===`clientsubmissionstatus`}function YO(e){if(e==null)return null;if(typeof e==`string`){let t=e.trim();return t?{label:t,value:t,_raw:{name:t}}:null}let t=String(e?.name??e?.clientSubmissionStatusText??e?.label??e?.text??``).trim();if(!t)return null;let n=Number(e?.id??e?.uniqueId??e?.clientSubmissionStatusId??e?.value??0)||0;return{label:t,value:t,_raw:{...e,...n>0?{id:n,uniqueId:n}:{},name:t,type:String(e?.type??e?.clientSubmissionStatusType??``).trim(),isInitialStatus:e?.isInitialStatus===!0,isTerminalStatus:e?.isTerminalStatus===!0,allowedNextStatusIds:Array.isArray(e?.allowedNextStatusIds)?e.allowedNextStatusIds.map(Number).filter(e=>Number.isInteger(e)&&e>0):[]}}}function XO(e,t){return JO(t)?YO(e):pO(e,t)}function ZO(e){let t=e?.clientSubmissionStatus,n=Number((t&&typeof t==`object`?t?.clientSubmissionStatusId??t?.id??t?.uniqueId:void 0)??e?.clientSubmissionStatusId??e?.clientStatusId??e?.[`clientSubmissionStatus.clientSubmissionStatusId`]??0)||0,r=t&&typeof t==`object`?t?.clientSubmissionStatusText??t?.name??t?.text??t?.label:t;return{id:n,text:String(r??e?.clientSubmissionStatusText??e?.clientStatus??e?.clientStatusText??e?.[`clientSubmissionStatus.clientSubmissionStatusText`]??``).trim()}}function QO(e){let t=Number(e?.id??0)||0,n=String(e?.text??``).trim();return n&&n.toLowerCase()===`not submitted`?!0:t<=0&&!n}function $O(e){return Number(e?._raw?.id??e?._raw?.uniqueId??0)||0}function ek(e){let t=e?._raw?.allowedNextStatusIds;return Array.isArray(t)?t.map(Number).filter(e=>Number.isInteger(e)&&e>0):[]}function tk(e){let t=e?.data??e;return t?Array.isArray(t)?t[0]??null:t?.record&&typeof t.record==`object`?t.record:t?.data&&typeof t.data==`object`&&!Array.isArray(t.data)?t.data:typeof t==`object`?t:null:null}function nk(e){return(Array.isArray(e?.selectedRecords)?e.selectedRecords.filter(Boolean):[]).some(e=>!QO(ZO(e)))?!0:!QO(ZO(e??{}))}async function rk(e,n){if(nk(e))return e;let r=e?.selectedIds?.[0]??e?.selectedRecords?.[0]?._id??e?.selectedRecords?.[0]?.id;if(!r)return e;let i=String(e?.moduleName??`submissions`).trim()||`submissions`,a=new URLSearchParams({module:i,id:String(r)});n&&a.set(`app_id`,n);try{let r=tk(await t.o(t.x,`/module-data-detail?${a.toString()}`,{headers:n?{"X-App-Id":n}:void 0}));if(!r)return e;let i=Array.isArray(e?.selectedRecords)?e.selectedRecords:[];return{...e,selectedRecords:i.length?i.map((e,t)=>t===0?{...e,...r}:e):[r]}}catch(t){return console.warn(`[DynamicPopup] Could not load selected submission detail for client status transition:`,t),e}}function ik(e,t){if(!Array.isArray(e)||!e.length)return[];if(!e.some(e=>e?._raw?.isInitialStatus===!0||e?._raw?.isTerminalStatus===!0||Array.isArray(e?._raw?.allowedNextStatusIds)))return e;let n=Array.isArray(t?.selectedRecords)?t.selectedRecords.filter(Boolean):[],r={clientSubmissionStatus:t?.clientSubmissionStatus,clientSubmissionStatusId:t?.clientSubmissionStatusId,clientSubmissionStatusText:t?.clientSubmissionStatusText,clientStatus:t?.clientStatus,clientStatusId:t?.clientStatusId,clientStatusText:t?.clientStatusText,"clientSubmissionStatus.clientSubmissionStatusId":t?.[`clientSubmissionStatus.clientSubmissionStatusId`],"clientSubmissionStatus.clientSubmissionStatusText":t?.[`clientSubmissionStatus.clientSubmissionStatusText`]},i=n.length?n:[r];return e.filter(t=>i.every(n=>{let i=ZO(n);if(QO(i)){let e=ZO(r);QO(e)||(i=e)}if(QO(i))return t?._raw?.isInitialStatus===!0;let a=e.find(e=>{let t=$O(e),n=String(e?.label??``).trim();return i.id>0&&t===i.id||i.text&&n.toLowerCase()===i.text.toLowerCase()});return!a||a?._raw?.isTerminalStatus===!0?!1:ek(a).includes($O(t))}))}function ak({open:e,config:n,api:r,fields:i,popupContext:a,formValues:s}){let[c,l]=(0,o.useState)({}),[u,d]=(0,o.useState)(null);return(0,o.useEffect)(()=>{e||(l({}),d(null))},[e]),(0,o.useEffect)(()=>{if(!e||!n||!r.getOptions)return;let t=new AbortController;return i.forEach(e=>{!e.fetchOptionsKey||e.fetchOptionsParamKey||Promise.resolve(r.getOptions(e,void 0,a)).then(n=>{t.signal.aborted||l(t=>({...t,[e.name]:n}))}).catch(n=>{t.signal.aborted||console.error(`[DynamicPopup] Failed to load options for field "${e.name}":`,n)})}),()=>t.abort()},[e,r,n,i,a]),(0,o.useEffect)(()=>{if(!e||!n)return;let r=i.filter(KO);if(!r.length)return;let o=new AbortController;return r.forEach(e=>{let n=new URLSearchParams({masterName:e.masterName,offset:`0`,limit:String(e.limit??50)}),r=String(t.b??``).trim();r&&n.set(`app_id`,r),t.o(t.x,`/masters/dropdown?${n.toString()}`,{headers:r?{"X-App-Id":r}:void 0}).then(async t=>{if(o.signal.aborted)return;let n=qO(t).map(t=>XO(t,e)).filter(Boolean),i=a;if(JO(e)&&(i=await rk(a,r)),o.signal.aborted)return;let s=JO(e)?ik(n,i):n;l(t=>({...t,[e.name]:s}))}).catch(t=>{o.signal.aborted||console.error(`[DynamicPopup] Failed to load master options for field "${e.name}":`,t)})}),()=>o.abort()},[e,n,i,a]),(0,o.useEffect)(()=>{if(!e||!n||!r.getOptions)return;let t=i.filter(e=>e.fetchOptionsKey&&e.fetchOptionsParamKey);if(!t.length)return;let o=new AbortController;return t.forEach(e=>{let t=s[e.fetchOptionsParamKey]??a[e.fetchOptionsParamKey],n={[e.fetchOptionsParamKey]:t};Promise.resolve(r.getOptions(e,n,a)).then(t=>{o.signal.aborted||l(n=>({...n,[e.name]:t}))}).catch(t=>{o.signal.aborted||console.error(`[DynamicPopup] Failed to load param-dependent options for "${e.name}":`,t)})}),()=>o.abort()},[e,r,n,i,s,a]),(0,o.useEffect)(()=>{if(!e||!n||!r.loadExtraData)return;let t=new AbortController;return Promise.resolve(r.loadExtraData(a)).then(e=>{t.signal.aborted||d(e)}).catch(e=>{t.signal.aborted||(console.error(`[DynamicPopup] Failed to load extra data:`,e),d(null))}),()=>t.abort()},[e,r,n,a]),{dynamicOptions:c,setDynamicOptions:l,extraData:u}}var ok=500,sk=3;function ck({api:e,open:t,fields:n=[],popupContext:r,setDynamicOptions:i}){let[a,s]=(0,o.useState)({}),c=(0,o.useRef)({}),l=(0,o.useRef)({}),u=(0,o.useRef)({}),d=(0,o.useCallback)((t,n)=>{let a=e.searchOptions??e.searchFetcher;if(typeof a!=`function`)return;l.current[t.name]?.abort();let o=new AbortController;return l.current[t.name]=o,Promise.resolve(a(t,n,r)).then(e=>{if(o.signal.aborted)return;let n=Array.isArray(e)?e:e?.items??e?.list??[];i(e=>({...e,[t.name]:n.map(e=>pO(e,t))}))}).catch(e=>{o.signal.aborted||console.error(`[DynamicPopup] Search failed for field "${t.name}":`,e)}),o},[e,r,i]),f=n.filter(e=>(e.searchFetchKey||e.searchFetcher)&&e.preloadOptions!==!1),p=f.map(e=>e.name).join(`|`),m=(0,o.useRef)({runSearch:d,preloadFields:f});(0,o.useEffect)(()=>{m.current={runSearch:d,preloadFields:f}}),(0,o.useEffect)(()=>{if(!t||!p)return;let{runSearch:e,preloadFields:n}=m.current,r=n.map(t=>e(t,``)).filter(Boolean);return()=>r.forEach(e=>e.abort())},[t,p]);function h(t){if(!t.searchFetchKey&&!t.searchFetcher||typeof(e.searchOptions??e.searchFetcher)!=`function`)return;let n=t.searchMinLength??sk;return e=>{clearTimeout(c.current[t.name]);let r=e.length<n?``:e;c.current[t.name]=setTimeout(()=>{d(t,r)},ok)}}function g(t){let n=e.getMentionOptions??e.mentionFetcher;if(typeof n==`function`)return e=>{u.current[t.name]?.abort();let i=new AbortController;u.current[t.name]=i,Promise.resolve(n(t,e,r)).then(e=>{if(i.signal.aborted)return;let n=Array.isArray(e)?e:e?.items??e?.list??[];s(e=>({...e,[t.name]:n.map(e=>({value:e.user_name??e.userName??e.username??String(e),label:e.user_name??e.userName??e.username??String(e)}))}))}).catch(e=>{i.signal.aborted||console.error(`[DynamicPopup] Mention search failed for field "${t.name}":`,e)})}}return{mentionOptions:a,getSearchHandler:h,getMentionSearchHandler:g}}function lk({form:e,config:t,api:n,popupContext:r,resolvedIds:i,dynamicOptions:a,extraData:c,removedIds:l,removalOnlySubmit:u=!1,fields:d,onClose:f,onSubmit:p}){let[m,h]=(0,o.useState)(!1),[g,_]=(0,o.useState)(null);async function v(e){let t={resolvedIds:i,dynamicOptions:a,extraData:c,removedIds:l};if(typeof n.submit==`function`)return n.submit(e,r,t);if(typeof p==`function`)return p(e,r,t)}function y(){if(t){if(!d.length){if(t.mode===`delete`&&typeof n.deleteItems==`function`){h(!0),_(null),Promise.resolve(n.deleteItems(i,r)).then(()=>{s.message.success(t.successMessage||`Deleted successfully`),f({success:!0})}).catch(e=>{let t=e?.message||`Delete failed. Please try again.`;_(t),h(!1),s.message.error(t)});return}if(typeof n.onOk==`function`){h(!0),Promise.resolve(n.onOk(r)).then(()=>f({success:!0})).catch(e=>{let t=e?.message||`Failed. Please try again.`;s.message.error(t),h(!1)});return}if(typeof n.submit==`function`){h(!0),Promise.resolve(v({})).then(e=>{e?.cancelled||e?.navigated||(s.message.success(t.successMessage||`Saved successfully`),f({success:!0}))}).catch(e=>{s.message.error(e?.message||`Failed. Please try again.`)}).finally(()=>h(!1));return}f();return}if(u){h(!0),Promise.resolve(v(e.getFieldsValue())).then(e=>{e?.cancelled||e?.navigated||(s.message.success(t.successMessage||`Saved successfully`),f({success:!0}))}).catch(e=>{s.message.error(e?.message||`Failed. Please try again.`)}).finally(()=>h(!1));return}e.validateFields().then(async e=>{h(!0);try{let n=await v(e);if(n?.cancelled||n?.navigated)return;s.message.success(t.successMessage||`Saved successfully`),f({success:!0})}catch(e){s.message.error(e?.message||`Failed. Please try again.`)}finally{h(!1)}}).catch(()=>{})}}function b(){h(!1),_(null)}return{handleOk:y,confirming:m,deleteError:g,resetSubmitState:b}}function uk({open:e=!0,config:t,context:n={},onClose:r,onSubmit:i,api:a={}}){let[c]=s.Form.useForm(),[d,f]=(0,o.useState)({}),[p,m]=(0,o.useState)([]),h=s.Form.useWatch([],c,{preserve:!0})??{},g=(0,o.useMemo)(()=>hO(n),[n]),{selectedIds:_=[],selectedRecords:v=[],moduleName:y=``}=g,b=(0,o.useMemo)(()=>_.map((e,t)=>{let n=v[t];return n?.id??n?._id??e}),[_,v]),x=(0,o.useMemo)(()=>t?typeof t.getFields==`function`?t.getFields(g):t.fields??[]:[],[t,g]),S=(0,o.useMemo)(()=>{let e={};return x.forEach(t=>{let n=g[t.initialValueKey];!t.initialValueKey||n===void 0||(e[t.name]=t.type===`date-picker`?(0,u.default)(n):n)}),e},[x,g]),{dynamicOptions:C,setDynamicOptions:w,extraData:T}=ak({open:e,config:t,api:a,fields:x,popupContext:g,formValues:d}),{mentionOptions:E,getSearchHandler:D,getMentionSearchHandler:O}=ck({api:a,open:e,fields:x,popupContext:g,setDynamicOptions:w});function k(e){typeof r==`function`&&r(e)}let A=x.filter(e=>e.required),j=A.every(e=>{let t=h[e.name];return!(t==null||t===``||Array.isArray(t)&&t.length===0||typeof t==`object`&&!Array.isArray(t)&&Object.keys(t).length===0)}),M=(g.removedIds??[]).length,N=p.length>M,P=A.some(e=>{let t=h[e.name];return!(t==null||t===``||Array.isArray(t)&&t.length===0)}),{handleOk:F,confirming:I,deleteError:L,resetSubmitState:R}=lk({form:c,config:t,api:a,popupContext:g,resolvedIds:b,dynamicOptions:C,extraData:T,removedIds:p,removalOnlySubmit:!!t?.allowRemovalOnlySubmit&&N&&!P,fields:x,onClose:k,onSubmit:i});(0,o.useEffect)(()=>{e&&(c.resetFields(),f(S??{}),m(g.removedIds??[]),R())},[e,S]);let z=!!t?.autoSubmitWhenNoFields&&x.length===0;(0,o.useEffect)(()=>{!e||!z||F()},[e,z]);let B=_.length,V=String(y).replace(/s$/i,``),ee=B===1?V:y,te=v[0]??{},ne=t?.getTitleText?t.getTitleText(B,ee,te,g):t?.title,re=B===1?te.jobTitle??te.title??te.name??te.fullName??te.candidateName??null:null,ie=t?.getBodyText?t.getBodyText(B,V,ee,re,g):t?.bodyText??null,ae=typeof t?.getNote==`function`?t.getNote(g):t?.note,oe=t?.disabledUntilFilled&&!j&&!N;if(!t||!e||z)return null;let se=t.component;return se?(0,l.jsx)(s.Modal,{open:e,title:t.title||t.getTitleText?(0,l.jsx)(iO,{titleText:ne,titleIcon:t.titleIcon}):null,footer:null,width:t.width??760,centered:!0,maskClosable:!1,onCancel:()=>k(),className:`dynamic-popup${t.className?` ${t.className}`:``}`,children:(0,l.jsx)(se,{context:g,selectedIds:b,selectedRecords:v,moduleName:y,onClose:k})}):(0,l.jsxs)(s.Modal,{open:e,title:(0,l.jsx)(iO,{titleText:ne,titleIcon:t.titleIcon}),okText:t.okText||`OK`,cancelText:t.cancelText??`Cancel`,onOk:F,onCancel:()=>k(),okButtonProps:{danger:t.okButtonDanger,disabled:oe,loading:I},cancelButtonProps:{disabled:I},closable:!I,maskClosable:!1,width:t.width??480,centered:!0,className:`dynamic-popup${t.className?` ${t.className}`:``}`,children:[(0,l.jsx)(aO,{note:ae,description:t.description,showSelectedCount:t.showSelectedCount,count:B,itemLabel:ee,bodyText:ie,deleteError:L}),(0,l.jsx)(oO,{footerNote:t.footerNote}),(0,l.jsx)(UO,{form:c,fields:x,initialValues:S,dynamicOptions:C,popupContext:g,extraData:T,removedIds:p,setRemovedIds:m,showAlreadyAssigned:t.showAlreadyAssigned,onValuesChange:f,getSearchHandler:D,getMentionSearchHandler:O,mentionOptions:E})]})}var dk={mode:`delete`,getTitleText:(e,t)=>`Delete ${e>0?`${e} `:``}${t}`,titleIcon:`delete`,okText:`Delete`,okButtonDanger:!0,width:420,getBodyText:(e,t,n,r)=>r?`Are you sure you want to delete the ${r} ${t}?`:e>1?`Are you sure you want to delete ${e} selected ${n}?`:`Are you sure you want to delete this ${t}?`,footerNote:`This action cannot be undone.`,fields:[]},fk={deleteItems:async(e,t)=>{await ae(t.moduleName,e)}},pk=new Map;async function mk(e){return e?(pk.has(e)||pk.set(e,a.r({module:e}).catch(t=>(pk.delete(e),console.warn(`[in-progress gate] could not read ${e} form groups:`,t),[]))),pk.get(e)):[]}function hk(e=[],t){return e.some(e=>{let r=n.C(e,t);return r&&r.severity!==`allow`})}async function gk({targetModule:e,sourceModule:t,recordId:r,region:i}={}){let o={severity:`allow`,message:``,group:null};if(!e||!t||!r)return o;let s=i??n.Hn().region;try{let i=await mk(e);if(!hk(i,s))return o;let c=await a.r({module:t,id:r}),l={};for(let e of c){let t=e?.payloadKey||e?.name;t&&Array.isArray(e?.rows)&&(l[t]=e.rows)}return n.D(i,s,l)}catch(e){return console.warn(`[in-progress gate] check skipped:`,e),o}}var _k=`Already submitted`,vk=`submissions`,yk=`candidates`,bk=864e5,xk=90,Sk=`This candidate was created or last updated more than 90 days ago. Only candidates created or updated within the last 90 days can be selected. Please update this candidate first.`,Ck=[`createdAt`,`createdDate`,`dateCreated`,`created_on`,`createdOn`],wk=[`updatedAt`,`updatedDate`,`lastUpdatedAt`,`lastUpdatedDate`,`modifiedAt`,`modifiedDate`];function Tk(e,t){for(let n of t){let t=e?.[n];if(!t)continue;let r=new Date(t);if(!Number.isNaN(r.getTime()))return r}return null}function Ek(e){return Tk(e,Ck)}function Dk(e){return Tk(e,wk)}function Ok(e){if(!(e instanceof Date)||Number.isNaN(e.getTime()))return null;let t=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();return Math.max(0,Math.floor((t(new Date)-t(e))/bk))}function kk(e){return e===null?``:e<=14?`green`:e<=89?`yellow`:`red`}function Ak(e,t=xk){if(!e)return!1;let n=Date.now()-t*bk,r=Ek(e),i=Dk(e),a=r&&r.getTime()>=n,o=i&&i.getTime()>=n;return!a&&!o}function jk(e){let t=Ek(e);if(!t)return{createdAgo:``,createdAgoTone:``};let n=uO(t);return n?{createdAgo:n,createdAgoTone:kk(Ok(t))}:{createdAgo:``,createdAgoTone:``}}function Mk(e){return{...e,...jk(e),isStaleCandidate:Ak(e)}}function Nk(e){return String(e?.applicantId??e?._id??e?.id??``)}var Pk=null;async function Fk(){return Pk||=n.Lr(yk).then(e=>e?.strategies?.duplicateCheck?.editRoute??``).catch(()=>``),Pk}async function Ik(e){let t=Nk(e);if(!t)return``;let n=await Fk();return n?n.replace(/:(_?id)\b/g,encodeURIComponent(t)):``}async function Lk({option:e,popupContext:t,confirm:n}){let r=e?._raw??e??{},i=Nk(r);if(i){let e=await gk({targetModule:vk,sourceModule:yk,recordId:i});if(e.severity===`block`)return new Promise(t=>{n({title:`This candidate cannot be submitted`,content:e.message,okText:`Pick someone else`,cancelText:`Close`,onOk:()=>t(!1),onCancel:()=>t(!1)})})}if(!Ak(r))return!0;let a=t?.navigate;return!a||!i?!1:new Promise(e=>{n({title:`Candidate update required`,content:Sk,okText:`OK`,cancelText:`Cancel`,onOk:async()=>{let t=await Ik(r);t&&a(t),e(!1)},onCancel:()=>e(!1)})})}function Rk(e,t,n){return{...e,label:`${e.label} - ${_k}`,disabled:!0,title:`${_k}${t?` (submission ${t})`:``}`,alreadySubmitted:!0,existingSubmissionId:t||``,...n?{submittedAt:n}:{}}}var zk={searchOptions:async(e,t,n)=>{if(e.searchFetchKey===`quickSubmitJobList`){let e=n.selectedRecords?.[0]??{},r=e.id??e._id??n.selectedIds?.[0],i,a=!0;try{i=await Ee({searchQuery:t,candidateId:r})}catch{a=!1;let e=await Nn({searchQuery:t,candidateId:r});i=Array.isArray(e?.data)?e.data:[]}let o=i.map(e=>({label:[e.jobReferenceId??e.clientJobReferenceId,e.jobTitle].filter(Boolean).join(` - `)||String(e._id??``),value:e._id??``,_raw:e}));if(a)return o.map(e=>{if(e._raw?.isSubmitted||e._raw?.alreadySubmitted)return Rk(e,e._raw?.jobSubmissionId||``,e._raw?.submittedAt||``);if(e._raw?.disable){let t=String(e._raw?.message??``).trim();return{...e,disabled:!0,label:t?`${e.label} - ${t}`:e.label,title:t}}return e});let s=await Oe({applicantId:r,jobIds:o.map(e=>e.value)}).catch(()=>new Map);return o.map(e=>{let t=s.get(String(e.value));return t?Rk(e,t.submissionId,t.submittedAt):e})}if(e.searchFetchKey===`quickSubmitCandidates`){let e=n.selectedRecords?.[0]??{},r=n.jobId??e.jobId??e.id??e._id??n.selectedIds?.[0],i,a=new Map;try{i=await De({search:t,jobId:r})}catch{let e=await es({isFromSubmission:n.isFromSubmission,jobId:r,submissionId:n.submissionId,search:t});i=Array.isArray(e)?e:[],a=await Oe({jobId:r,applicantIds:i.map(Nk)}).catch(()=>new Map)}return i.map(e=>Mk(e)).map(e=>{let t=a.get(Nk(e));if(!(t||e?.isSubmitted===!0||e?.alreadySubmitted===!0))return e;let n=t?.submissionId||e?.jobSubmissionId||``,r=t?.submittedAt||e?.submittedAt||``;return{...e,disabled:!0,optionNote:_k,isSubmitted:!0,alreadySubmitted:!0,existingSubmissionId:n,...r?{submittedAt:r}:{}}})}return[]},submit:async(e,t,n)=>{let{navigate:r,selectedRecords:i=[],selectedIds:a=[],moduleName:o}=t,s=i[0]??{},c,l;t.jobId?(c=t.jobId,l=s.id??s._id??a[0]??``):o===`candidate`?(c=e.jobId??``,l=s.id??s._id??a[0]??``):(c=s.jobId??s.id??s._id??a[0]??``,l=e.candidate??``);let u=n?.dynamicOptions?.candidate?.find(e=>Nk(e?._raw)===String(l)),d=n?.dynamicOptions?.jobId?.find(e=>String(e?.value)===String(c)),f=u?._raw?.isSubmitted||u?._raw?.alreadySubmitted||d?.alreadySubmitted||d?._raw?.isSubmitted||d?._raw?.alreadySubmitted;if(!c||!l)throw Error(`Select both a job and a candidate to quick submit.`);if(Ak(u?._raw))throw Error(Sk);let p=await gk({targetModule:vk,sourceModule:yk,recordId:l});if(p.severity===`block`)throw Error(p.message);let m=f,h=u?._raw?.existingSubmissionId||u?._raw?.jobSubmissionId||d?.existingSubmissionId||d?._raw?.jobSubmissionId||``;try{let e=await Te({jobId:c,applicantId:l});m||=!!e?.exists,h=e?.submissionId||h}catch(e){throw Error(`Could not verify existing submissions (${e?.message??`request failed`}). Please try again.`,{cause:e})}if(m)throw Error(`This candidate is already submitted for this job${h?` (submission ${h})`:``}.`);let g=new URLSearchParams;l&&g.set(`candidateId`,l);let _=u?.priorSubmissionId||u?._raw?.submissionId||d?.priorSubmissionId||d?._raw?.submissionId||``;_?(g.set(`submissionId`,String(_)),g.set(`isFromSubmission`,`true`)):g.set(`isFromSubmission`,`false`);let v=Zo($o({jobId:c,applicantId:l}).catch(()=>[]));return r(`/submission-create/${c}?${g.toString()}`,{state:{relevantSkillsToken:v}}),{navigated:!0}}},Bk={title:`Submit`,okText:`Submit`,width:640,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getNote:e=>e.moduleName===`candidate`?`Note: Select a job to submit this candidate.`:`Note: Select a candidate to submit for this job`,getFields:e=>e.jobId?[]:e.moduleName===`candidate`?[{name:`jobId`,label:`Job list`,type:`search-select`,required:!0,placeholder:`Search Job ID / job name - or pick a recent job`,searchFetchKey:`quickSubmitJobList`,optionLayout:{id:`{jobReferenceId}`,title:`{jobTitle}`,subtitle:`{clientJobReferenceId}`,meta:[{label:`Created`,key:`createdAt`,type:`date`},{label:`Updated`,key:`updatedAt`,type:`relative`}]}}]:[{name:`candidate`,label:`Candidate`,type:`search-select`,required:!0,placeholder:`Search candidate name / email - or pick a recent candidate`,optionsKey:`candidateOptions`,searchFetchKey:`quickSubmitCandidates`,labelTemplate:`{applicantRefrenceId} - {firstName} {lastName} - {createdAgo}`,valueKey:`applicantId`,optionLayout:{id:`{applicantRefrenceId}`,title:`{firstName} {lastName}`,titleAccent:{key:`createdAgo`,toneKey:`createdAgoTone`,prefix:` - `},subtitle:`{designation} - {email}`,meta:[{label:`Created`,key:`createdAt`,type:`date`},{label:`Updated`,key:`updatedAt`,type:`relative`}]},onSelectGuard:Lk}]},Vk={title:`Add Notes & Share`,okText:`Save & Share`,width:480,fields:[{name:`notes`,label:`Notes`,type:`mention-textarea`,required:!0,rows:5,maxLength:2e3,placeholder:`Add your notes on the job. Use '@' to mention someone.`,mentionFetchKey:`mentionUsers`}]},Hk=e=>e?.data??e;async function Uk({relatedId:e,notes:n,title:r,notesFor:i}){return Hk(await hn(t.x,`/notes`,{method:`POST`,body:JSON.stringify({relatedId:e,notes:n,title:r,notesFor:i})}))}var Wk={getMentionOptions:async(e,t)=>se(t),submit:async(e,t)=>{let n=Array.isArray(t.selectedIds)?t.selectedIds[0]:t.selectedIds;if(!n)throw Error(`Please select a record before adding a note.`);await Uk({relatedId:String(n),notes:e.notes,notesFor:t.moduleName})}},Gk={name:`jobId`,label:`Job Title / ID`,type:`search-select`,multiple:!0,required:!0,placeholder:`Minimum 3 characters`,searchFetchKey:`tagToJobJobList`,valueKey:`_id`,labelTemplate:`{jobReferenceId} - {jobTitle}`},Kk={name:`hiringStage`,label:`Hiring stage`,type:`select`,required:!0,optionsKey:`hiringStageOptions`,defaultOptions:[{label:`Shortlisted`,value:`shortlisted`},{label:`Pipeline`,value:`pipeline`}],initialValueKey:`hiringStage`},qk={title:`Tag to Job`,okText:`Tag`,width:480,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getFields:e=>e.jobId&&e.hiringStage?[]:e.jobId?[Kk]:[Gk,Kk]},Jk=e=>e?.data??e;function Yk(e){return Array.isArray(e)&&e.every(e=>e&&typeof e==`object`&&`Key`in e)?e.reduce((e,{Key:t,Value:n})=>(e[t]=n,e),{}):e}function Xk(e){return e?Array.isArray(e.data)?e.data.map(Yk):e.stage&&Array.isArray(e.stage.data)?e.stage.data.map(Yk):Array.isArray(e)?e.map(Yk):[]:[]}async function Zk(e=1,n=10){let r=await t.o(t.x,`/workflow/list/all?page=${e}&limit=${n}`),i=Jk(r),a=Array.isArray(i)?i:i?.data??[];return{items:a,total:Number(r?.total??i?.total)||a.length,page:e,limit:n}}async function Qk(e,n){let r=Jk(await t.o(t.x,`/workflow/${e}/stage/${n}`));return Array.isArray(r)?{data:r}:r}async function $k(e,n){if(!e||!n)return null;try{let r=new URLSearchParams({module:e,limit:`1`,offset:`0`,scope:`allJobs`,filters:JSON.stringify([{field:`_id`,op:`in`,values:[String(n)],operator:`and`}])}),i=Jk(await t.o(t.x,`/module-data-list?${r}`));if(Array.isArray(i))return i[0]??null;if(i?.data&&Array.isArray(i.data))return i.data[0]??null;let a=i?.rows??i?.records??i?.items??i?.list;return Array.isArray(a)?a[0]??null:i??null}catch(t){return console.error(`[getModuleRecordById] failed: ${e}/${n}`,t),null}}async function eA(e){return Jk(await t.o(t.C,`/source/workflow-instance`,{method:`POST`,body:JSON.stringify(e)}))}var tA={pipeline:`pipeline`,goodfited:`goodfited`,contacted:`contacted`,submitted:`submitted`,shortlisted:`shortlisted`,interviewinprogress:`interviewInprogress`,selected:`selected`},nA=`Already submitted`;function rA(e,...t){for(let n of t){let t=String(n).split(`.`).reduce((e,t)=>e?.[t],e);if(t!=null&&t!==``)return t}}function iA(e){let t=String(e??``).trim();return t?tA[t.toLowerCase()]??t:``}function aA(e,t=``){return String(rA(e,`candidateId`,`candidate_id`,`applicantId`,`applicantID`,`applicantReferenceId`,`applicantRefrenceId`,`_id`,`id`)??t??``)}function oA(e){return String(rA(e,`_id`,`id`,`candidateId`,`candidate_id`,`applicantId`,`applicantID`)??``)}function sA(e,t,n){let r=String(e.jobTitle??``).trim();return{...e,jobTitle:r?`${r} (${nA})`:`(${nA})`,disabled:!0,title:nA,alreadySubmitted:!0,existingSubmissionId:t||``,...n?{submittedAt:n}:{}}}function cA(e,t){let n=String(t??``).trim();return n?/already submitted/i.test(n)?`${e} (${nA})`:/fulfilled/i.test(n)?`${e} (Fullfilled)`:`${e} (${n})`:e}function lA(e){let t=String(e.jobReferenceId??e.clientJobReferenceId??``).trim(),n=String(e.jobTitle??``).trim();return{...e,jobReferenceId:t,jobTitle:n}}function uA(e){return fA(e).map(e=>e.id)}function dA(e,t=``){return(rA(e,`candidateName`,`candidate_name`,`fullName`,`name`)??[rA(e,`firstName`,`first_name`),rA(e,`lastName`,`last_name`)].filter(Boolean).join(` `)??t)||`Unknown candidate`}function fA(e){let t=Array.isArray(e?.selectedIds)?e.selectedIds:[],n=Array.isArray(e?.selectedRecords)?e.selectedRecords:[],r=[],i=new Set,a=Math.max(t.length,n.length);for(let e=0;e<a;e+=1){let a=n[e]??{},o=t[e]?String(t[e]):``,s=aA(a,o);!s||i.has(s)||(i.add(s),r.push({id:s,name:dA(a,o),record:a,selectedId:o||s}))}return r}function pA(e,t){return Array.isArray(e?.jobId)?e.jobId.map(String).filter(Boolean):e?.jobId?[String(e.jobId)]:Array.isArray(t?.jobId)?t.jobId.map(String).filter(Boolean):t?.jobId?[String(t.jobId)]:[]}function mA(e,t=``){let n=String(e?.jobTitle??e?._raw?.jobTitle??``).trim();if(n)return n;let r=String(e?.label??e?._raw?.label??``).trim();return r.includes(` - `)?r.split(` - `).slice(1).join(` - `).trim():r||String(t??``)}function hA(e,t=``){return mA(e,t)}function gA(e,t,n){let r=[...new Set(pA(e,t))],i=Array.isArray(n?.dynamicOptions?.jobId)?n.dynamicOptions.jobId:[],a=new Map(i.map(e=>[String(e?._id??e?.value??``),e]));return r.map(e=>{let t=a.get(String(e))??{};return{id:String(e),label:hA(t,e),record:t}})}function _A(e){return e.filter(e=>e.blockedCandidates.length>0).map(e=>`${e.job.label} - ${e.blockedCandidates.map(e=>e.name).join(`, `)}`).join(` | `)}function vA(e){return e.filter(e=>e.allowedCandidates.length>0).map(e=>`${e.job.label} - ${e.allowedCandidates.map(e=>e.name).join(`, `)}`).join(` | `)}function yA(e,t){let n=oA(e);if(!n)return null;let r=dA(e,t)||void 0,i={candidateId:String(n),candidateName:r,phone:rA(e,`phone`,`phoneNumber`,`phone_number`,`mobile`,`mobileNumber`,`mobile_number`),source:rA(e,`source`,`sourceType`,`candidateSource`,`profileSource`),submittedAt:rA(e,`submittedAt`,`lastSubmittedAt`,`updatedAt`),remarks:rA(e,`remarks`,`comment`,`comments`,`notes`),assignedRecruiter:rA(e,`assignedRecruiter`,`recruiterName`,`ownerName`,`assignedToName`),screeningStatus:rA(e,`screeningStatus`,`screening.status`,`screeningResult`),screeningScore:rA(e,`screeningScore`,`screening.score`,`score`),assignedDate:rA(e,`assignedDate`,`assignedAt`,`createdAt`)};return Object.fromEntries(Object.entries(i).filter(([,e])=>e!=null&&e!==``))}var bA={searchOptions:async(e,t,n)=>{if(e.searchFetchKey===`tagToJobJobList`){let e=uA(n),r=e.length===1?e[0]:``,i,a=!1;if(r)try{i=await Ee({searchQuery:t,candidateId:r}),a=!0}catch{a=!1}Array.isArray(i)||(i=await oe(t));let o=i.map(lA);if(a)return o.map(e=>{if(e?.isSubmitted||e?.alreadySubmitted)return sA(e,e?.jobSubmissionId||e?.submissionId||``,e?.submittedAt||``);if(e?.disable){let t=String(e?.message??``).trim();return{...e,jobTitle:e.jobTitle?cA(e.jobTitle,t):`(${t})`,disabled:!0,optionNote:t,title:t}}return e});if(!r)return o;let s=await Oe({applicantId:r,jobIds:o.map(e=>e._id).filter(Boolean)}).catch(()=>new Map);return o.map(e=>{let t=s.get(String(e._id));return t?sA(e,t.submissionId,t.submittedAt):e})}return[]},submit:async(e,t,r)=>{let i=iA(e.hiringStage??t.hiringStage),a=fA(t),o=gA(e,t,r);if(!o.length||!a.length)return{cancelled:!0};let s=[];for(let e of o){let t=await Oe({jobId:e.id,applicantIds:a.map(e=>e.id)}).catch(()=>new Map);s.push({job:e,blockedCandidates:a.filter(e=>t.has(String(e.id))),allowedCandidates:a.filter(e=>!t.has(String(e.id)))})}let c=_A(s),l=vA(s),u=s.filter(e=>e.allowedCandidates.length>0);if(!u.length)return await n.Wt({tone:`duplicate`,title:`Selected candidates are already submitted`,body:`Every selected candidate is already submitted to the selected jobs. Choose different jobs to continue.`,facts:[{label:`Blocked combinations`,value:c}],okText:`Close`}),{cancelled:!0};if(s.some(e=>e.blockedCandidates.length>0)&&!await n.Ut({tone:`duplicate`,title:`Some candidate-job combinations are already submitted`,body:`Those combinations will be skipped. Continue tagging the remaining valid combinations?`,facts:[{label:`Will be skipped`,value:c},{label:`Will be tagged`,value:l}],okText:`Tag remaining`,cancelText:`Cancel`,footnote:`Already submitted combinations will be left unchanged.`}))return{cancelled:!0};for(let e of u){for(let t of e.allowedCandidates){let n=yA(t.record??{},t.selectedId);await eA({jobId:e.job.id,module:`jobs`,currentStage:i,...n?{candidateDetails:n}:{}})}await ue({jobId:e.job.id,candidateIds:e.allowedCandidates.map(e=>e.selectedId||e.id),hiringStage:i})}}},xA={title:`Change Status`,okText:`Apply`,width:420,showSelectedCount:!0,fields:[{name:`status`,label:`New Status`,type:`select`,required:!0,placeholder:`Select a status`,dataSource:`master`,masterName:`clientSubmissions`,labelKey:`name`,valueKey:`name`,initialValueKey:`currentStatus`,defaultOptions:[{label:`Active`,value:`active`},{label:`Inactive`,value:`inactive`},{label:`Pending`,value:`pending`},{label:`Closed`,value:`closed`}]}]};function SA(e,t){let n=String(e??``).trim().toLowerCase();return(Array.isArray(t?.status)?t.status:[]).find(e=>String(e?.value??``).trim().toLowerCase()===n||String(e?.label??``).trim().toLowerCase()===n||String(e?._raw?.name??``).trim().toLowerCase()===n)??null}var CA={submit:async(e,t,n)=>{let r=SA(e.status,n?.dynamicOptions),i=r?._raw??{},a={clientSubmissionStatusText:String(i.name??r?.label??e.status??``).trim(),clientSubmissionStatusId:Number(i.id??i.uniqueId??0)||0,clientSubmissionStatusType:String(i.type??``).trim()};await ie(t.moduleName,t.selectedIds,a)}},wA={getTitleText:e=>`Remove ${e>1?`${e} Candidates`:`Candidate`} from Shortlist`,titleIcon:`delete`,okText:`Remove`,okButtonDanger:!0,width:420,getBodyText:e=>e>1?`Are you sure you want to remove ${e} selected candidates from the shortlist?`:`Are you sure you want to remove this candidate from the shortlist?`,footerNote:`The candidate will be moved back to the pipeline.`,fields:[]},TA={onOk:async e=>{await ke({jobId:e.jobId??e.selectedIds[0],candidateIds:e.selectedIds})}},EA={title:`Add to Groups`,description:`Select a group to add the selected candidate(s) to`,okText:`Add to Group`,width:480,disabledUntilFilled:!0,fields:[{name:`groupId`,label:`Group`,type:`select`,required:!0,placeholder:`Select a group`,fetchOptionsKey:`candidateGroups`}]},DA={getOptions:async e=>e.fetchOptionsKey===`candidateGroups`?de():[],submit:async(e,t,{dynamicOptions:n})=>{let r=(n.groupId??[]).find(t=>String(t.value)===String(e.groupId));await fe({candidateIds:t.selectedIds,groupId:e.groupId,groupName:r?.label??``})}},OA=[{title:`Name`,key:`name`,render:(e,t)=>t.name||`${t.first_name??``} ${t.last_name??``}`.trim()||t.user_name||`Assigned user`},{title:`Role`,dataIndex:`role_name`,key:`role`,render:e=>e||`-`},{title:`Reporting`,dataIndex:`reporting_name`,key:`reporting`,render:e=>e||`-`}];function kA({selectedIds:e,onClose:t}){let n=e?.[0],[r,i]=(0,o.useState)(!0),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)({assignedUsers:[],totalSubmissions:0,message:``}),[p,m]=(0,o.useState)([]);(0,o.useEffect)(()=>{let e=!1;return i(!0),Promise.all([me(n).catch(t=>(e||s.message.error(t?.message??`Failed to load self-assign details`),{assignedUsers:[],totalSubmissions:0,message:``})),_e(n).catch(()=>({recruitersData:[]}))]).then(([t,n])=>{e||(f(t),m(Array.isArray(n?.recruitersData)?n.recruitersData:[]))}).finally(()=>{e||i(!1)}),()=>{e=!0}},[n]);let h=async()=>{u(!0);try{await pe({jobIds:[n]}),s.message.success(`Job assigned successfully`),t?.({success:!0})}catch(e){s.message.error(e?.message??`Failed to assign job`)}finally{u(!1)}};if(r)return(0,l.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,l.jsx)(s.Spin,{size:`large`})});let g=p.map(e=>({user_id:e.recruiterId??e.id??e.user_id,name:e.name??``,role_name:e.role_name??e.roleName??``,reporting_name:e.reporting_name??e.reportingName??``})),_=new Map(g.map(e=>[String(e.user_id??``),e])),v=(d.assignedUsers?.length??0)>0?d.assignedUsers.map(e=>{let t=e.user_id??e.userId??e.recruiterId??e.id,n=_.get(String(t??``))??{};return{...e,user_id:t,name:n.name||e.name||``,role_name:n.role_name||e.role_name||e.roleName||``,reporting_name:n.reporting_name||e.reporting_name||e.reportingName||``}}):g,y=v.length>0;return(0,l.jsxs)(`div`,{className:`self-assign-popup-body`,children:[y?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{style:{fontWeight:700,marginBottom:8},children:`Team Members Allocated`}),(0,l.jsx)(s.Table,{columns:OA,dataSource:v,pagination:!1,rowKey:e=>e.user_id??`${e.first_name}-${e.last_name}`,size:`small`,className:`mb-3 no-header-bg`,scroll:{y:200}}),(0,l.jsxs)(`div`,{className:`warning-card`,style:{display:`flex`,alignItems:`center`,gap:8,marginTop:12},children:[(0,l.jsx)(c.ExclamationCircleFilled,{style:{color:`#faad14`,fontSize:18}}),(0,l.jsx)(`div`,{style:{fontSize:13},children:`These users are already assigned to this job. Do you still want to assign yourself as well?`})]})]}):(0,l.jsx)(`div`,{style:{padding:`8px 0`},children:d.message||`No one is currently assigned to this job. Do you want to assign yourself?`}),(0,l.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:12,marginTop:24},children:[(0,l.jsx)(s.Button,{size:`small`,onClick:()=>t?.(),disabled:a,children:`No`}),(0,l.jsx)(s.Button,{type:`primary`,size:`small`,onClick:h,loading:a,children:`Yes`})]})]})}kA.propTypes={selectedIds:f.default.array,onClose:f.default.func};var AA={title:`Self Assign`,width:480,className:`self-assign-modal`,component:kA},jA={submit:async()=>{}};function MA(e={}){let t=Array.isArray(e.jobPayDetails)?e.jobPayDetails[e.jobPayDetails.length-1]:e.jobPayDetails??e.clientBudget??{},n=Number(t.clientBudgetEnd),r=Number(t.clientBudgetStart);return Number.isFinite(n)&&n>0?n:Number.isFinite(r)&&r>0?r:null}var NA={getTitleText:(e,t,n)=>{let r=n?.jobTitle||n?.title||``;return r?`Assign - ${r}`:`Assign`},okText:`Assign`,width:520,disabledUntilFilled:!0,showAlreadyAssigned:!0,allowRemovalOnlySubmit:!0,getFields:e=>(MA(e?.selectedRecords?.[0]??{}),[{name:`assignToUserId`,label:`Assign to`,type:`multi-select`,required:!0,placeholder:`Select recruiter(s)`,fetchOptionsKey:`assignToUsers`}])},PA={getOptions:async e=>e.fetchOptionsKey===`assignToUsers`?ge():[],loadExtraData:async e=>_e(e.selectedIds[0]),submit:async(e,t,{removedIds:n,extraData:r})=>{await xe({jobIds:t.selectedIds,userId:e.assignToUserId,removedIds:n,existingRecruiters:r?.recruitersData})}},FA={title:`Add Sticky Notes`,getTitleText:(e,t,n,r)=>r.editingNoteId?`Edit Sticky Notes`:`Add Sticky Notes`,okText:`Save`,width:480,fields:[{name:`heading`,label:`Heading`,type:`input`,required:!0,placeholder:`Enter heading`,initialValueKey:`editingHeading`},{name:`targetDate`,label:`Target Date`,type:`date-picker`,required:!1,initialValueKey:`editingTargetDate`},{name:`comments`,label:`Comments`,type:`mention-textarea`,required:!0,rows:5,placeholder:`Enter your note here... Use '@' to mention someone.`,mentionFetchKey:`mentionUsers`,initialValueKey:`editingComments`}]},IA={getMentionOptions:async(e,t)=>se(t),submit:async(e,t)=>{let n=e.targetDate?e.targetDate.toISOString():``;t.editingNoteId?await ce(t.editingNoteId,{title:e.heading,targetDate:n,notes:e.comments}):await H({relatedIds:t.selectedIds,module:t.moduleName,title:e.heading,targetDate:n,notes:e.comments}),window.dispatchEvent(new Event(`sticky-notes:refresh`))}},LA={title:`Move to Onboarding`,bodyText:`Are you sure you want to move this candidate to onboarding?`,okText:`Yes`,cancelText:`No`,width:420,successMessage:`Moved to onboarding successfully`,successNavigate:`/onboarding`,fields:[{name:`sendOnboardingEmail`,type:`priority-checkbox`,checkboxLabel:`Send Onboarding Email`}]},RA={submit:async(e,t)=>{await Se({submissionId:t.selectedRecords?.[0]?.submissionId,isMail:e.sendOnboardingEmail})}};function zA(e){return Array.isArray(e)?e[e.length-1]??{}:e&&typeof e==`object`?e:{}}var BA={USD:`$`,INR:`₹`,EUR:`€`,GBP:`£`};function VA(e,t,n){let r=zA(e?.[t])[n];if(r!=null&&r!==``)return r;let i=e?.[`${t}.${n}`];return i!=null&&i!==``?i:void 0}function HA(e){let t=e.selectedRecords?.[0]??{},n=VA(t,`candidateRate`,`candidateAcceptedRate`)??VA(t,`candidateBudget`,`candidateBudgetStart`);if(n===void 0||Number(n)===0)return null;let r=VA(t,`candidateRate`,`candidateAcceptedCurrency`)??VA(t,`candidateBudget`,`candidateBudgetCurrency`);return{amount:n,symbol:VA(t,`candidateRate`,`candidateAcceptedCurrencySymbol`)??VA(t,`candidateBudget`,`candidateBudgetCurrencySymbol`)??BA[String(r??``).toUpperCase()]??(r||`$`),unit:VA(t,`candidateRate`,`candidateAcceptedPayUnit`)??VA(t,`candidateBudget`,`candidateBudgetUnit`)??``}}var UA={title:`Approve Rate`,okText:`Approve`,width:520,className:`medium-modal`,successMessage:`Rate approved`,getBodyText:(e,t,n,r,i)=>{let a=HA(i);return`Candidate Rate: ${a?`${a.symbol}${a.amount}${a.unit?`/${a.unit}`:``}`:`-`}`},fields:[{name:`candidateProposedRate`,label:`Proposed Rate`,type:`number`,required:!0,placeholder:`Amount`,min:0,inlineRow:`proposedRate`,validator:(e,t)=>{if(e==null||e===``)return;let n=HA(t);if(n&&Number(e)<=Number(n.amount))return`Proposed rate must be greater than Candidate Rate`}},{name:`candidateProposedRateCurrency`,label:`Currency`,type:`select`,required:!0,inlineRow:`proposedRate`,defaultOptions:[{label:`$ USD`,value:`$`},{label:`₹ INR`,value:`₹`},{label:`€ EUR`,value:`€`}]},{name:`candidateProposedRateUnit`,label:`Unit`,type:`select`,required:!0,inlineRow:`proposedRate`,defaultOptions:[{label:`Year`,value:`yr`},{label:`Month`,value:`mo`},{label:`Week`,value:`wk`},{label:`Hour`,value:`hr`},{label:`Daily`,value:`day`}]},{name:`submitVia`,label:`Submit Via`,type:`radio`,required:!0,defaultOptions:[{label:`Mail`,value:`Mail`},{label:`VMS`,value:`VMS`}]}]},WA={submit:async(e,t)=>{let n=t.selectedIds[0];if(await Ce(n,{candidateProposedRate:e.candidateProposedRate,candidateProposedRateCurrency:e.candidateProposedRateCurrency,candidateProposedRateUnit:e.candidateProposedRateUnit,submitVia:e.submitVia}),e.submitVia===`VMS`)try{await we(n)}catch{s.message.warning(`Approved. VMS notification could not be sent — use Send Mail to notify the client.`)}else s.message.info(`Approved — use Send Mail to notify the client.`)}};async function GA(e,n={}){let r=t.u();if(!r){let e=Error(`Authentication required`);throw e.status=401,e}let i=await fetch(`${t.T}${e}`,{...n,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${r}`,...n.headers}});if(i.status===401&&t.h(),!i.ok){let e=Error(`API ${i.status}: ${i.statusText}`);throw e.status=i.status,e}return i.json()}async function KA(e){let t=await GA(`/mail-form?${new URLSearchParams({submissionId:e,submissionType:`manager`}).toString()}`);return t.data??t}function qA(e){return Array.isArray(e)?e[e.length-1]:e}function JA(e={}){let t=qA(e?.proposedRate)?.candidateProposedRate??e?.candidateProposedRate??e?.proposedRateValue,n=Number(t);return Number.isFinite(n)?n:0}function YA(e,t={}){let n=qA((e?.record?.job??e?.job??t?.job??{})?.jobPayDetails)??{},r=e?.record?.submission??t??{},i=qA(r?.clientBudget)??r?.clientBudget??{},a=n?.clientBudgetEnd??n?.clientBudgetStart??i?.clientBudgetEnd??i?.clientBudgetStart,o=Number(a);return Number.isFinite(o)?o:0}function XA(e={}){let t=String(e?.currencyRaw??``).trim().toUpperCase(),n=String(e?.currency??``).trim();return n&&!/^[A-Z]{3}$/i.test(n)?n:t===`USD`||n.toUpperCase()===`USD`?`$`:t===`INR`||n.toUpperCase()===`INR`?`₹`:t===`EUR`||n.toUpperCase()===`EUR`?`€`:t===`GBP`||n.toUpperCase()===`GBP`?`£`:n||t}function ZA(e={}){return String(e?.rateUnit??`hr`).trim().replace(/^\/+/,``)||`hr`}function QA(e,t={}){let n=Number(e);return Number.isFinite(n)?`${XA(t)}${n}/${ZA(t)}`:``}function $A(e,t,n){if(n==null||n===``)return String(e??``);let r=String(e??``),i=String(n),a=!1,o=RegExp(`(<(?:td|th)[^>]*>[\\s\\S]*?${t}[\\s\\S]*?</(?:td|th)>\\s*<(?:td|th)[^>]*>)([\\s\\S]*?)(</(?:td|th)>)`,`gi`);r=r.replace(o,(e,t,n,r)=>(a=!0,`${t}${i}${r}`));let s=RegExp(`(<(?:strong|b)[^>]*>\\s*${t}\\s*:?\\s*</(?:strong|b)>\\s*)([\\s\\S]*?)(?=</(?:li|p|div)>)`,`gi`);if(r=r.replace(s,(e,t)=>(a=!0,`${t}${i}`)),!a){let e=RegExp(`(${t}\\s*:?[ \\t]*)([^<\\r\\n]*)`,`gi`);r=r.replace(e,(e,t)=>`${t}${i}`)}return r}function ej(e,t,n,r,i){let a=Number(n?.proposedRate),o=Number.isFinite(a)?a:JA(t),s=Number(n?.clientJobRate),c=Number.isFinite(s)&&s>0?s:YA(r,i),l={proposedRate:o,jobBillRate:c},u=String(e??``).replace(/{{\.?((?:proposedRate)|(?:jobBillRate))}}/g,(e,t)=>{let n=l[t];return n==null?e:String(n)});return u=$A(u,`(?:Proposed\\s*Rate|Pay\\s*Rate)`,QA(o,n)),u=$A(u,`(?:Job\\s*)?Bill\\s*Rate`,QA(c,n)),u}function tj(...e){return e.map(e=>e==null?``:String(e).trim()).find(Boolean)??``}var nj=(e,t)=>!!e&&e.toLowerCase()===tj(t).toLowerCase();function rj(e,t,n){let r=tj(t.submittedBy);return tj(nj(r,n)||nj(r,e.submitSource)||nj(r,e.supplierName)||nj(r,e.source)||nj(r,e.candidateSource)?``:r,e.signatureEmail)}function ij(e,t={}){let n=t.employerName??e.supplierName??e.submitSource;return{client:t.clientName??e.clientName,role:t.jobTitle??e.jobTitle??e.designation,reqId:t.reqId??e.jobClientRefrenceId??e.mspReqId??e.submissionId,name:t.candidateName||[e.firstName,e.lastName].filter(Boolean).join(` `)||e.candidateFullName,location:t.jobLocation??e.city??e.currentLocation??e.jobLocation,vendor:n,submittedBy:rj(e,t,n),submittedAt:t.createdAt??e.createdAt,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function aj(e){let t=e?.$oid??e?._id?.$oid??e?._id??e?.id?.$oid??e?.id??e;if(t==null||typeof t==`object`)return``;let n=String(t).trim();return/^[a-f\d]{24}$/i.test(n)?n:``}function oj(...e){for(let t of e){let e=[t?.jobId,t?.JobId,t?.job_id,t?.jobDetails?._id,t?.jobDetails?.id,t?.job?._id,t?.job?.id,t?.submission?.jobId,t?.submission?.JobId,t?.submission?.job_id,t?.submission?.jobDetails?._id,t?.submission?.jobDetails?.id,t?.submission?.job?._id,t?.submission?.job?.id,t?.recordMeta?.jobId,t?.recordMeta?.JobId,t?.recordMeta?.job_id,t?.submission?.recordMeta?.jobId,t?.submission?.recordMeta?.JobId,t?.submission?.recordMeta?.job_id].map(aj).find(Boolean);if(e)return e}return``}function sj(e){if(!e?.referralId)return{};let t=Number(e.referralRate??e.referalRate??0)||0,n=String(e.referralType??e.referalType??`RECURRING`).trim()||`RECURRING`,r=e.referralId??e.referalId;return{referralId:r,referalId:r,referralRate:t,referalRate:t,referralType:n,referalType:n,referralEnabled:!0,referalEnabled:!0,isReferralApplicable:!0,referralDetails:{referralId:r,referalId:r,referralRate:t,referalRate:t,referralType:n,referalType:n,referralEnabled:!0,referalEnabled:!0,isReferralApplicable:!0}}}function cj(e=``){return String(e??``).replace(/map\[[^\]]*(?:resume|document|attachment|file)[^\]]*\]/gi,``).replace(/<p>\s*<\/p>/gi,``).replace(/(?:<br\s*\/?>\s*){3,}/gi,`<br><br>`).trim()}function lj(...e){for(let t of e){let e=[t?.candidateId,t?.applicantId,t?.candidate?._id,t?.candidate?.id,t?.submission?.candidateId,t?.submission?.applicantId,t?.recordMeta?.candidateId,t?.recordMeta?.applicantId].map(aj).find(Boolean);if(e)return e}return``}async function uj(e){let t=e?.fileUrl??e?.downloadUrl??e?.url;if(!t)return null;let n=await fetch(t);if(!n.ok)throw Error(`Unable to load ${e?.fileName||`resume`}`);let r=await n.blob(),i=e?.fileName??e?.uploadedFileName??e?.originalName??e?.uniqueName??`resume`;return new File([r],i,{type:e?.contentType||r.type||`application/octet-stream`})}async function dj(e,r,i){let a=[],o=await n.yn(`submissions`,e,`resume`).catch(()=>({data:[]}));a.push(...o?.data??[]);let s=lj(r?.record?.submission,i,r?.record);if(!s){let n=await t.o(t.x,`/module/list?module=submissions&id=${encodeURIComponent(e)}`).catch(()=>({})),r=n?.data??n??{};s=lj((Array.isArray(r?.data)?r.data:Array.isArray(r)?r:[])[0])}if(s){let e=await n.yn(`candidates`,s,`resume`).catch(()=>({data:[]}));a.push(...e?.data??[])}let c=(await Promise.all(a.map(uj))).filter(Boolean),l=new Set;return c.filter(e=>{let t=`${e.name}:${e.size}:${e.type}`;return!l.has(t)&&(l.add(t),!0)})}function fj(e={}){return{to:(e.to??e.To??[]).map(e=>e.email??e.Email??e).filter(Boolean).join(`, `),cc:(e.cc??e.Cc??[]).map(e=>e.email??e.Email??e).filter(Boolean).join(`, `),bcc:(e.bcc??e.Bcc??[]).map(e=>e.email??e.Email??e).filter(Boolean).join(`, `),subject:e.subject??e.Subject??``,contents:cj(e.content?.value??e.Content?.Value??e.contents??e.body??``)}}function pj({context:e,selectedIds:t,selectedRecords:n,moduleName:r,onClose:i}){let a=n?.[0]??{},c=t?.[0]??Z_(a),[u,d]=(0,o.useState)(null),[f,p]=(0,o.useState)(!0),[m,h]=(0,o.useState)([]),[g,_]=(0,o.useState)(!1),[v,y]=(0,o.useState)(`vms`),[b,x]=(0,o.useState)(null),[S,C]=(0,o.useState)(null),[w,T]=(0,o.useState)(!1),[E,D]=(0,o.useState)(!1),[O,k]=(0,o.useState)(!1),[A,j]=(0,o.useState)(!1),[M,N]=(0,o.useState)({to:``,cc:``,bcc:``,subject:``,contents:``,attachments:[],showCc:!1,showBcc:!1});(0,o.useEffect)(()=>{let e=!1;return Rv(c,a).then(t=>{e||d(t)}).catch(t=>{e||(s.message.error(t?.message??`Unable to load finance details`),d({record:{submission:a},lookups:{},display:{}}))}).finally(()=>{e||p(!1)}),()=>{e=!0}},[c]),(0,o.useEffect)(()=>{let e=!1;return qv().then(t=>{e||h(t)}).catch(()=>{}),()=>{e=!0}},[]);let P=async()=>{if(b){if(v===`mail`){_(!1),D(!0),k(!0);try{let[e,t]=await Promise.all([KA(c).then(fj),dj(c,u,a).catch(e=>(console.warn(`Unable to resolve resume attachment:`,e),[]))]),n=u?.record?.submission??a;N({to:ej(e.to,n,b,u,a),cc:ej(e.cc,n,b,u,a),bcc:ej(e.bcc,n,b,u,a),subject:ej(e.subject,n,b,u,a),contents:ej(e.contents,n,b,u,a),attachments:t,showCc:!!e.cc,showBcc:!!e.bcc})}catch(e){s.message.error(e?.message??`Unable to prepare approval mail`)}finally{k(!1)}return}T(!0);try{await Ce(c,{candidateProposedRate:b.proposedRate,candidateProposedRateCurrency:b.currencyRaw??b.currency,candidateProposedRateUnit:b.rateUnit,submitVia:`VMS`,...sj(S)}),s.message.success(`Submission approved`),_(!1),x(null),C(null),i?.({success:!0})}catch(e){s.message.error(e?.message??`Unable to approve submission`)}finally{T(!1)}}},F=!O&&GE(M.to).length>0&&KE(M.to)&&KE(M.cc)&&KE(M.bcc)&&M.subject.trim()&&M.contents.trim(),I=async()=>{if(!b||!F||A)return;j(!0);let e={candidateProposedRate:b.proposedRate,candidateProposedRateCurrency:b.currencyRaw??b.currency,candidateProposedRateUnit:b.rateUnit};try{await Ce(c,{...e,submitVia:`VMS`,...sj(S)});let t=oj(u?.record,a);if(!t)s.message.warning(`Submission approved, but job details were not available to send mail`);else try{await ln({jobId:t,toMail:GE(M.to),ccMail:GE(M.cc),bccMail:GE(M.bcc),subject:M.subject,contents:M.contents,attachments:M.attachments??[]}),s.message.success(`Approval mail sent and submission approved`)}catch(e){s.message.warning(e?.message?`Submission approved, but mail was not sent: ${e.message}`:`Submission approved, but mail was not sent`)}D(!1),x(null),C(null),i?.({success:!0})}catch(e){s.message.error(e?.message??`Unable to send approval mail`)}finally{j(!1)}},L=(0,o.useMemo)(()=>({submissionApprove:async({computed:e,referral:t})=>{x(e),C(t??null),y(`vms`),_(!0)},submissionReject:async()=>{e?.navigate?.(`/popup/reject`,{replace:!0,state:{background:e?.background??null,selectedIds:t,selectedRecords:n,moduleName:r}})}}),[e,t,n,r]);return f||!u?(0,l.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,l.jsx)(s.Spin,{size:`large`})}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(Dv,{type:T_,record:u.record,lookups:u.lookups,identity:ij(a,u.display),referralOptions:m,onAddReferral:()=>e?.navigate?.(`/referrals-create`),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:L,onClose:()=>i?.(),variant:`popup`}),(0,l.jsx)(s.Modal,{title:`Choose approval method`,open:g,okText:`Approve`,confirmLoading:w,onOk:P,onCancel:()=>{w||(_(!1),x(null),C(null))},children:(0,l.jsxs)(s.Radio.Group,{value:v,onChange:e=>y(e.target.value),style:{display:`grid`,gap:12},children:[(0,l.jsx)(s.Radio,{value:`vms`,children:`Via VMS`}),(0,l.jsx)(s.Radio,{value:`mail`,children:`Via Mail`})]})}),(0,l.jsx)(s.Drawer,{open:E,placement:`right`,onClose:()=>{A||D(!1)},closable:!1,rootClassName:`mail-popup`,width:620,maskClosable:!1,footer:(0,l.jsxs)(`div`,{className:`mail-popup__footer`,children:[(0,l.jsx)(s.Button,{onClick:()=>D(!1),disabled:A,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:A,disabled:!F,onClick:I,children:`Send`})]}),children:O?(0,l.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,l.jsx)(s.Spin,{size:`large`})}):(0,l.jsx)(aD,{value:M,onChange:N,moduleName:`submissions`,ready:!O,title:`Submit Via Mail`,contextRecords:[u.record?.submission??a]})})]})}pj.propTypes={context:f.default.object,selectedIds:f.default.array,selectedRecords:f.default.array,moduleName:f.default.string,onClose:f.default.func};var mj={title:`Manager Approve`,width:780,className:`fa-modal manager-approve-modal`,component:pj},hj={submit:async()=>{}};function gj(...e){return e.map(e=>e==null?``:String(e).trim()).find(Boolean)??``}var _j=(e,t)=>!!e&&e.toLowerCase()===gj(t).toLowerCase();function vj(e,t,n){let r=gj(t.submittedBy);return gj(_j(r,n)||_j(r,e.submitSource)||_j(r,e.supplierName)||_j(r,e.source)||_j(r,e.candidateSource)?``:r,e.signatureEmail)}function yj(e,t={}){let n=t.employerName??e.supplierName??e.submitSource;return{client:t.clientName??e.clientName,role:t.jobTitle??e.jobTitle??e.designation,reqId:t.reqId??e.jobClientRefrenceId??e.mspReqId??e.submissionId,name:t.candidateName||[e.firstName,e.lastName].filter(Boolean).join(` `)||e.candidateFullName,location:t.jobLocation??e.city??e.currentLocation??e.jobLocation,vendor:n,submittedBy:vj(e,t,n),submittedAt:t.createdAt??e.createdAt,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function bj(e){let t=Array.isArray(e)?e:[];for(let e=t.length-1;e>=0;--e)if(String(t[e]?.activityType??``).trim().toLowerCase()===`cfo rejected`)return t[e];return null}function xj(e){return String(e??``).toLowerCase().replace(/\b\w/g,e=>e.toUpperCase())}function Sj({selectedIds:e,selectedRecords:t,onClose:r}){let i=t?.[0]??{},a=e?.[0]??Z_(i),[c,u]=(0,o.useState)(null),[d,f]=(0,o.useState)(``),[p,m]=(0,o.useState)(!0);(0,o.useEffect)(()=>{let e=!1;return m(!0),Promise.all([Rv(a,i),n.pn(`submission`,a).catch(()=>[])]).then(([t,n])=>{if(e)return;let r=bj(n);f(Z_(t?.meta?.workforceEngagementId??i?.onboarding?.workforceEngagementId??i?.workforceEngagementId));let a=t?.meta?.rejectReasonComments||r?.activityComments||``;u({...t,record:{...t.record,submission:{...t.record.submission,cfoRejectionReason:a?xj(a):``,cfoRejectedAt:t?.meta?.rejectedAt??r?.activityTime??null}}})}).catch(t=>{e||(s.message.error(t?.message??`Unable to load finance details`),u({record:{submission:i},lookups:{},display:{}}))}).finally(()=>{e||m(!1)}),()=>{e=!0}},[a]);let h=(0,o.useMemo)(()=>({submissionReapproveSend:async({computed:e})=>{await U(d,{submissionId:a,billRate:e.proposedRate,payRate:e.employerRate,currency:e.currencyRaw??e.currency,rateUnit:e.rateUnit,vmsPercent:e.clientVmsPercent}),await Ce(a,{candidateProposedRate:e.proposedRate,candidateProposedRateCurrency:e.currencyRaw??e.currency,candidateProposedRateUnit:e.rateUnit,submitVia:`Mail`,context:`resend`}),s.message.success(`Re-approved and sent for CFO approval`),r?.({success:!0})}}),[a,d,r]);return p||!c?(0,l.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,l.jsx)(s.Spin,{size:`large`})}):(0,l.jsx)(Dv,{type:k_,record:c.record,lookups:c.lookups,identity:yj(i,c.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:h,onClose:()=>r?.(),variant:`popup`})}Sj.propTypes={selectedIds:f.default.array,selectedRecords:f.default.array,onClose:f.default.func};var Cj={title:`Re-Approve`,width:780,className:`fa-modal manager-approve-modal`,component:Sj},wj={submit:async()=>{}},Tj=[{id:1,name:`Re-Submission`},{id:2,name:`Candidate doesn't fit into the profile`},{id:3,name:`Incomplete candidate details - (Re-Submission)`}],Ej={title:`Reject`,okText:`Reject`,okButtonDanger:!0,width:480,successMessage:`Submission rejected successfully`,fields:[{name:`rejectReason`,label:`Rejection Reasons`,type:`select`,required:!0,placeholder:`Select rejection reasons`,defaultOptions:Tj.map(e=>({label:e.name,value:e.id}))},{name:`rejectReasonComments`,label:`Comments`,type:`textarea`,required:!0,rows:4}]},Dj={submit:async(e,t)=>{let n=Tj.find(t=>String(t.id)===String(e.rejectReason));await W({submissionId:t.selectedIds[0],rejectReasonId:e.rejectReason,rejectReason:n?.name??``,rejectReasonComments:e.rejectReasonComments})}},Oj={delete:dk,"quick-submit":Bk,"add-notes":Vk,"tag-to-job":qk,"change-status":xA,"remove-from-shortlist":wA,"add-to-groups":EA,"self-assign":AA,"others-assign":NA,"sticky-notes":FA,"move-to-onboarding":LA,"approve-rate":UA,"manager-approve":mj,"manager-reapprove":Cj,reject:Ej},kj={delete:fk,"quick-submit":zk,"add-notes":Wk,"tag-to-job":bA,"change-status":CA,"remove-from-shortlist":TA,"add-to-groups":DA,"self-assign":jA,"others-assign":PA,"sticky-notes":IA,"move-to-onboarding":RA,"approve-rate":WA,"manager-approve":hj,"manager-reapprove":wj,reject:Dj};function Aj(e){let t=e?.data??e;return Array.isArray(t)?t:t?.data??t?.rows??t?.records??t?.items??t?.list??[]}function jj(e,...t){for(let n of t){let t=String(n).split(`.`).reduce((e,t)=>e?.[t],e);if(t!=null&&t!==``)return t}return``}function Mj(e){let t=String(jj(e,`isDeleted`,`deleted`)).toLowerCase(),n=String(jj(e,`assignmentStatus`,`status`)).toLowerCase();return t!==`true`&&t!==`1`&&![`removed`,`inactive`,`deleted`].includes(n)}function Nj(e){let t=jj(e,`candidateName`,`candidate_name`,`fullName`,`name`);return t?String(t):[jj(e,`firstName`,`first_name`),jj(e,`lastName`,`last_name`)].filter(Boolean).join(` `)||`Unnamed candidate`}function Pj(e){return String(jj(e,`candidateId`,`candidate_id`,`candidate._id`,`candidate.id`))}function Fj(e){return String(jj(e,`workforceEngagementId`,`engagementId`,`_id`,`id`))}function Ij(e){return String(jj(e,`batchName`,`name`,`title`,`batch_name`))}function Lj({open:e=!0,context:r={},onClose:i}){let[a,c]=(0,o.useState)([]),[u,d]=(0,o.useState)([]),[f,p]=(0,o.useState)(``),[m,h]=(0,o.useState)(!0),[g,_]=(0,o.useState)(!1),[v,y]=(0,o.useState)(``),[b,x]=(0,o.useState)(new Map),S=String(r.selectedIds?.[0]??r.selectedRecords?.[0]?._id??r.selectedRecords?.[0]?.id??r.batchId??``);(0,o.useEffect)(()=>{if(!e)return;let t=!1;return Promise.resolve().then(()=>(t||h(!0),Promise.all([n.Sn(`onboarding`,200,0),n.Sn(`batchCandidates`,1e3,0).catch(()=>[])]))).then(([e,n])=>{t||(c(Aj(e)),x(new Map(Aj(n).filter(Mj).map(e=>[String(jj(e,`candidateId`,`candidate_id`)),e]).filter(([e])=>e))))}).catch(e=>{t||y(e.message||`Unable to load onboarding candidates`)}).finally(()=>{t||h(!1)}),()=>{t=!0}},[e]);let C=(0,o.useMemo)(()=>{let e=f.trim().toLowerCase();return e?a.filter(t=>[Nj(t),jj(t,`email`,`candidateEmail`,`candidate_email`),jj(t,`status`,`onboardingStatus`,`onboarding_status`)].some(t=>String(t).toLowerCase().includes(e))):a},[a,f]);async function w(){if(!S){y(`Select a batch before adding candidates`);return}let e=a.filter(e=>u.includes(Fj(e)));if(!e.length)return;let o=e.map(e=>({record:e,assignment:b.get(Pj(e))})).filter(e=>e.assignment);if(o.length){let e=o.map(({record:e})=>Nj(e)).join(`, `);y(`${e} ${o.length===1?`is`:`are`} already added to a batch. Each candidate can be added to only one batch.`);return}_(!0),y(``);try{let{userId:a}=t.s(),o=Ij(r.selectedRecords?.[0])||Ij(r);await Promise.all(e.map(e=>n.$n(`batchCandidates`,{schemaVersion:1,batchId:S,batchName:o,candidateId:Pj(e),workforceEngagementId:Fj(e),source:`ONBOARDING`,assignmentStatus:`ASSIGNED`,assignedAt:new Date().toISOString(),assignedBy:a??0,isDeleted:!1}))),s.message.success(`${e.length} candidate${e.length===1?``:`s`} added to the batch`),i?.({refresh:!0})}catch(e){y(e.message||`Unable to add candidates to the batch`)}finally{_(!1)}}return(0,l.jsxs)(s.Modal,{open:e,title:`Add Candidate to Batch`,okText:`Add`,onOk:w,onCancel:()=>i?.(),okButtonProps:{disabled:u.length===0||!S,loading:g},cancelButtonProps:{disabled:g},closable:!g,maskClosable:!1,width:760,centered:!0,children:[v&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,message:v,style:{marginBottom:12}}),(0,l.jsx)(s.Input.Search,{allowClear:!0,placeholder:`Search onboarding candidates`,value:f,onChange:e=>p(e.target.value),style:{marginBottom:12}}),(0,l.jsx)(s.Table,{rowKey:e=>Fj(e),columns:[{title:`Candidate`,key:`candidate`,render:(e,t)=>Nj(t)},{title:`Email`,key:`email`,render:(e,t)=>jj(t,`email`,`candidateEmail`,`candidate_email`)||`—`},{title:`Onboarding status`,key:`status`,render:(e,t)=>jj(t,`status`,`onboardingStatus`,`onboarding_status`)||`—`}],dataSource:C,loading:m,size:`small`,pagination:{pageSize:10,showSizeChanger:!1},rowSelection:{selectedRowKeys:u,onChange:d,getCheckboxProps:e=>{let t=b.get(Pj(e));return{disabled:!Pj(e)||!Fj(e)||!!t,title:t?`Candidate is already added to a batch`:void 0}}},locale:{emptyText:m?`Loading candidates…`:`No onboarding candidates found`}})]})}var Rj={text:`input`,string:`input`,textarea:`textarea`,date:`date-picker`,datepicker:`date-picker`,multiselect:`multi-select`,lookup:`search-select`};function zj(e){if(!e)return null;let t=[...e.groups??[]].sort((e,t)=>Number(e.order??0)-Number(t.order??0)).flatMap(e=>[...e.fields??[]].filter(e=>e.show!==0&&e.show!==!1).sort((e,t)=>Number(e.order??0)-Number(t.order??0)).map(e=>({...e,name:e.name??e.field,label:e.label??e.field,type:Rj[String(e.type??`text`).toLowerCase()]??e.type??`input`,required:e.required??e.req===1,options:(e.options??[]).map(e=>({label:e.label??e.name??e.value,value:e.value??e.id??e.label}))}))),n=Bj(e.successNavigate);return{title:e.label,fields:t,...n?{successNavigate:n}:{}}}function Bj(e){let t=String(e??``).trim();return!t||!t.startsWith(`/`)||t.startsWith(`//`)||/^[a-z][a-z0-9+.-]*:/i.test(t)?null:t}function Vj(e,t=[]){if(!e||!Array.isArray(t)||!t.length)return e;let n=new Map(t.filter(e=>e?.name).map(e=>[String(e.name),e]));return n.size?{...e,fields:(e.fields??[]).map(r=>{let i=n.get(String(r.name))??n.get(String(r.label))??(n.size===1&&(e.fields??[]).length===1?t[0]:null);if(!i)return r;let{name:a,...o}=i;return{...r,...o}})}:e}function Hj({apiMap:e={},extraConfigs:r={}}){let i=(0,o.useMemo)(()=>({...kj,...e}),[e]),a=(0,o.useMemo)(()=>{let e={...Oj};return Object.entries(r).forEach(([t,n])=>{e[t]={...e[t]??{},...n}}),e},[r]),{popupKey:s}=(0,d.useParams)(),c=(0,d.useNavigate)(),{state:u={}}=(0,d.useLocation)(),[f,p]=(0,o.useState)({key:``,config:null});(0,o.useEffect)(()=>{let e=!1;if(!s||!u.moduleName)return;let t=`${u.moduleName}:${s}`;return n.Tr(u.moduleName,`popup`,s).then(n=>{e||p({key:t,config:zj(n[0])})}).catch(()=>{e||p({key:t,config:null})}),()=>{e=!0}},[s,u.moduleName]);let m=(0,o.useMemo)(()=>{let e=a[s],t=`${u.moduleName}:${s}`,n=f.key===t?f.config:null;return Vj(n?{...e,...n}:e,u.popupAction?.popupFieldOverrides)},[f,a,s,u.moduleName,u.popupAction?.popupFieldOverrides]),h=(0,o.useMemo)(()=>({selectedIds:u.selectedIds??[],selectedRecords:u.selectedRecords??[],moduleName:u.moduleName??``,navigate:c,background:u.background??null,...u.popupContext??{}}),[c,u.selectedIds,u.selectedRecords,u.moduleName,u.popupContext,u.background]),g=(0,o.useMemo)(()=>{let e=u.popupAction;return e?.apiPath?{submit:(n,r)=>{let i=String(e.apiMethod||`POST`).toUpperCase();return t.o(t.x,e.apiPath.startsWith(`/`)?e.apiPath:`/${e.apiPath}`,{method:i,body:[`GET`,`DELETE`].includes(i)?void 0:JSON.stringify({...n,selectedIds:r.selectedIds,selectedRecords:r.selectedRecords,moduleName:r.moduleName})})}}:{}},[u.popupAction]),_=e=>{let t=u.background;if(e?.success&&m?.successNavigate){c(m.successNavigate,{replace:!0,state:{refreshTimestamp:Date.now()}});return}if(e?.success&&t?.pathname){c(`${t.pathname}${t.search??``}`,{replace:!0,state:{...t.state??{},refreshTimestamp:Date.now()}});return}c(-1)};return s===`add-batch-candidate`?(0,l.jsx)(Lj,{open:!0,context:h,onClose:_}):(0,l.jsx)(uk,{open:!0,config:m,context:h,onClose:_,api:{...i[s]??{},...g}})}var Uj={title:`Vendor Share`,maxVendorSelect:1e3,defaultTab:`myVendor`,defaultPageSize:10,vendorTabs:[{key:`myVendor`,label:`My Vendors`},{key:`allVendor`,label:`All Vendors`}],vendorColumns:[{title:`Vendor Name`,dataIndex:`vendorName`,key:`vendorName`},{title:`Email`,dataIndex:`vendorEmail`,key:`vendorEmail`},{title:`Location`,dataIndex:`vendorLocation`,key:`vendorLocation`},{title:`Updated On`,dataIndex:`updatedOn`,key:`updatedOn`}]},Wj={getVendorList:({jobId:e,limit:t,offset:n,type:r})=>on({jobId:e,limit:t,offset:n,sortBy:`new`,type:r}),getMailDetails:e=>sn(e),submit:({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})=>ln({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})},Gj=Uj.vendorColumns.map(e=>({...e,render:e=>e||`-`}));function Kj(){let e=(0,d.useNavigate)(),t=(0,d.useLocation)(),{selectedIds:n=[],selectedRecords:r=[],recipients:i=[],subject:a=``,onSend:u,moduleName:f=``,popupAction:p={}}=t.state??{},m=n[0]??r[0]?._id??r[0]?.id,[h,g]=(0,o.useState)({to:i.join(`, `),cc:``,bcc:``,subject:a,contents:``,showCc:!1,showBcc:!1}),[_,v]=(0,o.useState)(!m),[y,b]=(0,o.useState)(Uj.defaultTab),[x,S]=(0,o.useState)(``),[C,w]=(0,o.useState)([]),[T,E]=(0,o.useState)(0),[D,O]=(0,o.useState)(0),[k,A]=(0,o.useState)(0),[j,M]=(0,o.useState)(1),[N,P]=(0,o.useState)(Uj.defaultPageSize),[F,I]=(0,o.useState)(!1),[L,R]=(0,o.useState)([]);(0,o.useEffect)(()=>{if(!m)return;let e=!1;I(!0);let t=x?100:N,n=x?0:(j-1)*N;return Wj.getVendorList({jobId:m,limit:t,offset:n,type:y}).then(t=>{if(e)return;let n=t?.data?.vendorList??t?.data??[],r=t?.data?.myVendorCount??0,i=t?.data?.allVendorCount??0;w(Array.isArray(n)?n:[]),E(r),O(i),A(y===`myVendor`?r:i)}).catch(()=>{e||(w([]),A(0))}).finally(()=>{e||I(!1)}),()=>{e=!0}},[m,y,j,N,x]),(0,o.useEffect)(()=>{m&&Wj.getMailDetails(m).then(e=>g(t=>({...t,subject:e.subject||t.subject,contents:e.contents||t.contents,to:e.toMail?.length?Array.isArray(e.toMail)?e.toMail.join(`, `):String(e.toMail):t.to,cc:e.ccMail?.length?Array.isArray(e.ccMail)?e.ccMail.join(`, `):String(e.ccMail):t.cc}))).catch(()=>{}).finally(()=>v(!0))},[m]);let z=(0,o.useMemo)(()=>L.map(e=>C.find(t=>t.vendorId===e)?.vendorEmail??``).filter(Boolean),[L,C]),B=(0,o.useMemo)(()=>({...h,bcc:[...new Set([...GE(h.bcc),...z])].join(`, `),showBcc:h.showBcc||z.length>0}),[h,z]);function V(e){let t=new Set(z);g({...e,bcc:GE(e.bcc).filter(e=>!t.has(e)).join(`, `)})}let ee=(GE(B.to).length||GE(B.bcc).length)&&KE(B.to)&&KE(B.cc)&&KE(B.bcc)&&B.subject.trim(),te=e=>e===`myVendor`?T:D;function ne(){e(-1)}function re(){ee&&Wj.submit({jobId:m,toMail:GE(B.to),ccMail:GE(B.cc),bccMail:GE(B.bcc),subject:B.subject,contents:B.contents}).then(t=>{t?.status===!0?(s.message.success(t?.data||`Mail sent successfully.`),typeof u==`function`&&u({...B,message:B.contents,selectedIds:n}),e(-1)):s.message.error(t?.message||t?.data||`Failed to send mail. Please try again.`)}).catch(e=>{s.message.error(e?.message||`Failed to send mail. Please try again.`)})}let ie=(0,o.useMemo)(()=>{if(!x)return C;let e=x.toLowerCase();return C.filter(t=>(t.vendorName??``).toLowerCase().includes(e)||(t.vendorEmail??``).toLowerCase().includes(e)||(t.vendorLocation??``).toLowerCase().includes(e))},[C,x]);return(0,l.jsx)(s.Drawer,{open:!0,placement:`right`,onClose:ne,closable:!1,rootClassName:`vendor-share`,width:`95%`,footer:(0,l.jsxs)(`div`,{className:`vendor-share__footer`,children:[(0,l.jsx)(s.Button,{onClick:ne,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,disabled:!ee,onClick:re,children:`Send`})]}),children:(0,l.jsxs)(`div`,{className:`vendor-share__body`,children:[(0,l.jsxs)(`div`,{className:`vendor-share__left`,children:[(0,l.jsxs)(`div`,{className:`vendor-share__vendor-header`,children:[(0,l.jsxs)(`div`,{className:`vendor-share__vendor-header-row`,children:[(0,l.jsx)(s.Button,{type:`text`,icon:(0,l.jsx)(c.CloseOutlined,{}),onClick:ne,size:`small`,style:{marginRight:8}}),(0,l.jsx)(`span`,{className:`dynamic-popup__header-icon-box`,children:(0,l.jsx)(c.TeamOutlined,{})}),(0,l.jsx)(`span`,{className:`dynamic-popup__header-label`,children:`Vendor List`}),(0,l.jsxs)(`div`,{className:`vendor-share__vendor-search`,children:[(0,l.jsx)(c.SearchOutlined,{className:`vendor-share__search-icon`}),(0,l.jsx)(s.Input,{variant:`borderless`,placeholder:`Search vendor`,value:x,onChange:e=>{S(e.target.value),M(1)},className:`vendor-share__search-input`})]})]}),(0,l.jsx)(`div`,{className:`vendor-share__vendor-tabs`,children:Uj.vendorTabs.map(e=>(0,l.jsxs)(`span`,{className:`vendor-share__vendor-tab${y===e.key?` vendor-share__vendor-tab--active`:``}`,onClick:()=>{b(e.key),M(1),R([])},children:[e.label,` (`,te(e.key),`)`]},e.key))})]}),(0,l.jsx)(`div`,{className:`vendor-share__vendor-table-wrapper`,children:(0,l.jsx)(s.Table,{rowKey:e=>e.vendorId,columns:Gj,dataSource:ie,loading:F,pagination:!1,size:`small`,rowSelection:{selectedRowKeys:L,onChange:e=>{e.length>Uj.maxVendorSelect||R(e)}},scroll:{y:`calc(100vh - 340px)`}})}),(0,l.jsx)(`div`,{className:`vendor-share__vendor-footer`,children:(0,l.jsx)(ze,{current:j,pageSize:N,total:k,onChange:e=>M(e),onPageSizeChange:e=>P(e)})})]}),(0,l.jsx)(`div`,{className:`vendor-share__right`,children:(0,l.jsx)(aD,{value:B,onChange:V,moduleName:f,defaultTemplateId:p.defaultTemplateId??t.state?.defaultTemplateId??``,ready:_,contextRecords:r,title:`Share`,hint:`Select vendors or add email addresses`,bccHint:`Vendor emails are added automatically`,afterBcc:L.length>0?(0,l.jsxs)(`div`,{className:`vendor-share__selected-count`,children:[L.length,` / `,Uj.maxVendorSelect,` Vendors selected`]}):null})})]})})}function qj(e){return e?.data??e}async function Jj(e){let n=String(e??``).trim();if(!n)throw Error(`Invoice id is required`);return qj(await t.o(t.x,`/payments/invoice/${encodeURIComponent(n)}`))}function Yj(...e){for(let t of e){let e=String(t??``).trim();if(e&&e!==`undefined`&&e!==`null`)return e}return``}async function Xj(e,t,n){if(!e)return null;let r=await fetch(e);if(!r.ok)throw Error(`Unable to load invoice attachment`);let i=await r.blob();return new File([i],t||`payment-invoice.html`,{type:n||i.type||`text/html`})}function Zj(e){let t=Yj(e?.courseName,`your course`),n=Yj(e?.invoiceNumber,e?.invoiceFileName,e?.transactionId);return{subject:`Payment invoice - ${t}`,contents:`<p>Hello ${Yj(e?.recipientName,`Student`)},</p><p>Please find attached the invoice for your successful payment${n?` (${n})`:``}.</p><p>Thank you.</p>`}}function Qj(){let e=(0,d.useNavigate)(),{id:t}=(0,d.useParams)(),[r,i]=(0,o.useState)(null),[a,u]=(0,o.useState)(``),[f,p]=(0,o.useState)(!0),[m,h]=(0,o.useState)(!1),[g,_]=(0,o.useState)(!1),[v,y]=(0,o.useState)({to:``,cc:``,bcc:``,subject:``,contents:``,attachments:[],showCc:!1,showBcc:!1}),b=(0,o.useMemo)(()=>r?.invoiceUrl?[{id:r.invoiceS3Key||r.invoiceUrl,name:r.invoiceFileName||`payment-invoice.html`,url:r.invoiceUrl,type:r.invoiceContentType||`html`}]:[],[r]);(0,o.useEffect)(()=>{let e=!1;async function n(){p(!0);try{let n=await Jj(t);if(e)return;i(n);let r=Zj(n),a=await Xj(n?.invoiceUrl,n?.invoiceFileName,n?.invoiceContentType).catch(()=>null),o={to:Yj(n?.recipientEmail),cc:``,bcc:``,subject:r.subject,contents:r.contents,attachments:a?[a]:[],showCc:!1,showBcc:!1},s=(await Cw({module:`payments`,action:`invoice`}).catch(()=>[]))[0];if(!s?._id){y(o);return}u(String(s._id));let c=await ww(s._id).catch(()=>null);if(!c){y(o);return}y({...o,to:Yj(o.to,...(c.toMail??[]).map(e=>iD(e,c.placeholders,n))),cc:(c.ccMail??[]).map(e=>iD(e,c.placeholders,n)).filter(Boolean).join(`, `),bcc:(c.bccMail??[]).map(e=>iD(e,c.placeholders,n)).filter(Boolean).join(`, `),subject:Yj(iD(c.subject,c.placeholders,n),o.subject),contents:Yj(iD(c.body,c.placeholders,n),o.contents),showCc:!!c.ccMail?.length,showBcc:!!c.bccMail?.length})}catch(t){e||s.message.error(t?.message||`Unable to load invoice`)}finally{e||p(!1)}}return n(),()=>{e=!0}},[t]);let x=GE(v.to).length>0&&KE(v.to)&&KE(v.cc)&&KE(v.bcc)&&v.subject.trim()&&v.contents.trim();async function S(){if(!(!x||g)){_(!0);try{await ln({jobId:``,toMail:GE(v.to),ccMail:GE(v.cc),bccMail:GE(v.bcc),subject:v.subject,contents:v.contents,attachments:v.attachments}),s.message.success(`Invoice mail sent successfully`),h(!1)}catch(e){s.message.error(e?.message||`Failed to send invoice mail`)}finally{_(!1)}}}return(0,l.jsxs)(s.Drawer,{open:!0,placement:`right`,onClose:()=>e(-1),width:`min(1040px, 96vw)`,title:`Payment Invoice`,extra:(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.MailOutlined,{}),onClick:()=>h(!0),disabled:!r,children:`Send Mail`}),destroyOnClose:!0,children:[(0,l.jsx)(s.Spin,{spinning:f,tip:`Loading invoice...`,children:!f&&!b.length?(0,l.jsx)(s.Alert,{type:`warning`,message:`Invoice document is not available for this payment.`,showIcon:!0}):(0,l.jsx)(`div`,{style:{height:`calc(100vh - 140px)`},children:(0,l.jsx)(n.En,{documents:b,inline:!0})})}),(0,l.jsx)(s.Drawer,{open:m,placement:`right`,onClose:()=>h(!1),width:620,rootClassName:`mail-popup`,destroyOnClose:!0,footer:(0,l.jsxs)(`div`,{className:`mail-popup__footer`,children:[(0,l.jsx)(s.Button,{onClick:()=>h(!1),children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:g,disabled:!x,onClick:S,children:`Send`})]}),children:(0,l.jsx)(aD,{value:v,onChange:y,moduleName:`payments`,defaultTemplateId:a,contextRecords:r?[r]:[],title:`Invoice Mail`,hint:`Customer email and invoice attachment are prefilled.`})})]})}var $j={EMAIL:/^[a-zA-Z0-9._%+-]+@[a-zA-Z][a-zA-Z-]*\.[a-zA-Z]{2,}$/,PHONE:/^[0-9]{10}$/,PASSWORD:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/,ALPHABETS:/^[A-Za-z ]+$/,ALPHANUMERIC:/^(?!\s)[A-Za-z0-9 ]+$/,NUMBER:/^[0-9]+$/,URL:/^(https?:\/\/)?(www\.)?([a-zA-Z0-9-]+\.)+(com|org|net|in|co|io|gov|edu)(\/[^\s]*)?$/i,CANDIDATE_ID:/^[A-Za-z0-9-]+$/,REMARKS:/^[A-Za-z0-9\s.,'"\-()!?/@#$%&]*$/,DESIGNATION:/^[a-zA-Z0-9\s,.\-&()]{2,100}$/,DOB:/^(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])\/\d{4}$/,COMPANY_NAME:/^[A-Za-z0-9\s&.,'()-]+$/,FIRST_NAME:/^[A-Z][a-zA-Z]*$/,FULL_NAME:/^[A-Z][a-zA-Z]*(?: [A-Z][a-zA-Z]*)*$/,NO_SPACES:/^\S+$/,STARTS_WITH_CAPITAL:/^[A-Z].*$/},eM={SINGLE_FILE_COUNT:1,MULTI_FILE_COUNT:5,MAX_FILE_SIZE:2,ALLOWED_FILE_TYPES:[`image/jpeg`,`image/png`,`application/pdf`]},tM={REQUIRED:e=>`Mandatory Field`,INVALID_EMAIL:`Please enter a valid email address.`,INVALID_PHONE:`Phone number must contain exactly 10 digits.`,INVALID_PASSWORD:`Password must contain uppercase, lowercase, number, special character and minimum 8 characters.`,INVALID_ALPHABETS:`Only alphabets and spaces are allowed.`,INVALID_ALPHANUMERIC:`Only letters, numbers and spaces are allowed.`,INVALID_NUMBER:`Only numbers are allowed.`,INVALID_URL:`Please enter a valid URL.`,INVALID_CANDIDATE_ID:e=>`${e} can contain only letters, numbers and hyphens.`,INVALID_REMARKS:`Remarks contain invalid characters.`,INVALID_DESIGNATION:`Designation contains invalid characters.`,INVALID_DOB:`DOB must be in MM/DD/YYYY format.`,INVALID_LINKEDIN:`Please enter a valid LinkedIn URL.`,INVALID_COMPANY_NAME:`Company name contains invalid characters.`,INVALID_FIRST_NAME:`First letter must be capital and spaces are not allowed.`,INVALID_FULL_NAME:`Each word must start with a capital letter.`,NO_SPACES_ALLOWED:`Spaces are not allowed.`,MUST_START_WITH_CAPITAL:`First letter must be capital.`,INVALID_FILE_TYPE:`Only JPG, PNG and PDF files are allowed.`,INVALID_FILE_SIZE:`File upload must be ${eM.MAX_FILE_SIZE} MB below.`,INVALID_FILE_TYPE:`Only JPG, PNG and PDF files are allowed.`,SINGLE_FILE_ONLY:`Only one file can be uploaded.`},nM={FIRST_NAME_MIN:3,FIRST_NAME_MAX:30},rM={REMARKS_MIN:10,REMARKS_MAX:250},iM={removeSpaces:(e=``)=>e.replace(/\s/g,``),capitalizeFirstLetter:(e=``)=>e.charAt(0).toUpperCase()+e.slice(1),capitalizeWords:(e=``)=>e.replace(/\b\w/g,e=>e.toUpperCase()),removeExtraSpaces:(e=``)=>e.replace(/\s+/g,` `).trim(),firstNameFormatter:(e=``)=>e.replace(/\s+/g,` `).trimStart().replace(/\b\w/g,e=>e.toUpperCase()),fullNameFormatter:(e=``)=>e.replace(/\s+/g,` `).trimStart().replace(/\b\w/g,e=>e.toUpperCase()),phoneFormatter:(e=``)=>e.replace(/\D/g,``).slice(0,10),dobFormatter:(e=``)=>{let t=e.replace(/\D/g,``);return t.length<=2?t:t.length<=4?`${t.slice(0,2)}/${t.slice(2)}`:`${t.slice(0,2)}/${t.slice(2,4)}/${t.slice(4,8)}`}},aM={required:(e=`Field`)=>({required:!0,message:tM.REQUIRED(e)}),email:()=>({pattern:$j.EMAIL,message:tM.INVALID_EMAIL}),phone:()=>({pattern:$j.PHONE,message:tM.INVALID_PHONE}),password:()=>({pattern:$j.PASSWORD,message:tM.INVALID_PASSWORD}),alphabets:()=>({pattern:$j.ALPHABETS,message:tM.INVALID_ALPHABETS}),alphanumeric:()=>({pattern:$j.ALPHANUMERIC,message:tM.INVALID_ALPHANUMERIC}),number:()=>({pattern:$j.NUMBER,message:tM.INVALID_NUMBER}),url:()=>({pattern:$j.URL,message:tM.INVALID_URL}),candidateId:(e=`ID`)=>({pattern:$j.CANDIDATE_ID,message:tM.INVALID_CANDIDATE_ID(e)}),remarks:()=>({pattern:$j.REMARKS,message:tM.INVALID_REMARKS,REMARKS_MIN:`Remarks must be at least ${rM.REMARKS_MIN} characters.`,REMARKS_MAX:`Remarks must not exceed ${rM.REMARKS_MAX} characters.`}),designation:()=>({pattern:$j.DESIGNATION,message:tM.INVALID_DESIGNATION}),dob:(e=!0)=>({validator:(t,n)=>{if(!n)return e?Promise.reject(Error(`Date of Birth is required.`)):Promise.resolve();if(!$j.DOB.test(n))return Promise.reject(Error(tM.INVALID_DOB));let r=(0,u.default)(n,`MM/DD/YYYY`,!0);if(!r.isValid())return Promise.reject(Error(tM.INVALID_DOB));let i=(0,u.default)().endOf(`day`);return r.isAfter(i)?Promise.reject(Error(`Date of Birth cannot be a future date.`)):i.diff(r,`year`)<21?Promise.reject(Error(`Age must be at least 21 years.`)):Promise.resolve()}}),linkedin:()=>({pattern:$j.LINKEDIN,message:tM.INVALID_LINKEDIN}),companyName:()=>({pattern:$j.COMPANY_NAME,message:tM.INVALID_COMPANY_NAME}),firstName:()=>({pattern:$j.FIRST_NAME,message:tM.INVALID_FIRST_NAME,FIRST_NAME_MIN:`First Name must be at least ${nM.FIRST_NAME_MIN} characters.`,FIRST_NAME_MAX:`First Name must not exceed ${nM.FIRST_NAME_MAX} characters.`}),firstNameMinLength:()=>({min:nM.FIRST_NAME_MIN,message:tM.FIRST_NAME_MIN}),firstNameMaxLength:()=>({max:nM.FIRST_NAME_MAX,message:tM.FIRST_NAME_MAX}),remarksMinLength:()=>({min:rM.REMARKS_MIN,message:tM.REMARKS_MIN}),remarksMaxLength:()=>({max:rM.REMARKS_MAX,message:tM.REMARKS_MAX}),fullName:()=>({pattern:$j.FULL_NAME,message:tM.INVALID_FULL_NAME}),noSpaces:()=>({pattern:$j.NO_SPACES,message:tM.NO_SPACES_ALLOWED}),startsWithCapital:()=>({pattern:$j.STARTS_WITH_CAPITAL,message:tM.MUST_START_WITH_CAPITAL}),fileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();for(let e of t){let t=e.originFileObj||e;if(!(t.size/1024/1024<=eM.MAX_FILE_SIZE))return s.message.error(tM.INVALID_FILE_SIZE),Promise.reject(Error(tM.INVALID_FILE_SIZE));if(!eM.ALLOWED_FILE_TYPES.includes(t.type))return Promise.reject(Error(tM.INVALID_FILE_TYPE))}return Promise.resolve()}}),singleFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>eM.SINGLE_FILE_COUNT)return Promise.reject(Error(tM.SINGLE_FILE_ONLY));let n=t[0];return n.size/1024/1024<eM.MAX_FILE_SIZE?eM.ALLOWED_FILE_TYPES.includes(n.type)?Promise.resolve():Promise.reject(Error(tM.INVALID_FILE_TYPE)):Promise.reject(Error(tM.INVALID_FILE_SIZE))}}),multiFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>eM.MULTI_FILE_COUNT)return Promise.reject(Error(tM.INVALID_FILE_COUNT));for(let e of t){if(!(e.size/1024/1024<eM.MAX_FILE_SIZE))return Promise.reject(Error(tM.INVALID_FILE_SIZE));if(!eM.ALLOWED_FILE_TYPES.includes(e.type))return Promise.reject(Error(tM.INVALID_FILE_TYPE))}return Promise.resolve()}})},oM={beforeUpload:e=>[`image/jpeg`,`image/png`,`application/pdf`].includes(e.type)?e.size/1024/1024<=2?!1:(s.message.error(`File upload must be 2 MB below.`),s.Upload.LIST_IGNORE):(s.message.error(`Only JPG, PNG and PDF files are allowed.`),s.Upload.LIST_IGNORE)},sM=()=>{let[e]=s.Form.useForm();return(0,l.jsx)(`div`,{style:{padding:24},children:(0,l.jsxs)(s.Form,{form:e,layout:`vertical`,onFinish:e=>{console.log(`Form Values:`,e)},autoComplete:`off`,children:[(0,l.jsxs)(s.Row,{gutter:16,children:[(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Email`,name:`email`,rules:[aM.required(`Email`),aM.email()],children:(0,l.jsx)(s.Input,{})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Phone Number`,name:`phone`,rules:[aM.required(`Phone Number`),aM.phone()],validateTrigger:[`onBlur`,`onChange`],children:(0,l.jsx)(s.Input,{maxLength:10,onChange:t=>{e.setFieldsValue({phone:iM.phoneFormatter(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Password`,name:`password`,rules:[aM.required(`Password`),aM.password()],children:(0,l.jsx)(s.Input.Password,{})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Full Name`,name:`fullName`,rules:[aM.required(`Full Name`),aM.alphabets(),aM.firstNameMinLength(),aM.firstNameMaxLength()],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({fullName:iM.firstNameFormatter(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Username`,name:`username`,rules:[aM.required(`Username`),aM.alphanumeric()],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({username:iM.removeExtraSpaces(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Website URL`,name:`website`,rules:[aM.required(`Website URL`),aM.url()],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({website:iM.removeExtraSpaces(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`MSP Req ID`,name:`mspreqID`,rules:[aM.required(`MSP Req ID`),aM.candidateId(`MSP Req ID`)],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({mspreqID:iM.removeExtraSpaces(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Candidate ID`,name:`candidateId`,rules:[aM.required(`Candidate ID`),aM.candidateId(`Candidate ID`)],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({candidateId:iM.removeExtraSpaces(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:24,children:(0,l.jsx)(s.Form.Item,{label:`Remarks`,name:`remarks`,rules:[aM.required(`Remarks`),aM.remarks(),aM.remarksMinLength(),aM.remarksMaxLength()],children:(0,l.jsx)(s.Input.TextArea,{rows:4})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Designation`,name:`designation`,rules:[aM.required(`Designation`),aM.designation()],children:(0,l.jsx)(s.Input,{})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Date of Birth`,name:`dob`,rules:[aM.dob()],children:(0,l.jsx)(s.Input,{placeholder:`MM/DD/YYYY`,maxLength:10,onChange:t=>{e.setFieldsValue({dob:iM.dobFormatter(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Company Name`,name:`companyName`,rules:[aM.required(`Company Name`),aM.companyName()],children:(0,l.jsx)(s.Input,{})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{name:`contractType`,label:`Contract Type`,children:(0,l.jsxs)(s.Select,{showSearch:!0,allowClear:!0,filterOption:(e,t)=>(t?.label??``).toLowerCase().includes(e.toLowerCase()),children:[(0,l.jsx)(s.Select.Option,{value:`C2C`,label:`C2C`,children:`C2C`}),(0,l.jsx)(s.Select.Option,{value:`W2-Contract`,label:`W2-Contract`,children:`W2-Contract`}),(0,l.jsx)(s.Select.Option,{value:`W2-Fulltime`,label:`W2-Fulltime`,children:`W2-Fulltime`}),(0,l.jsx)(s.Select.Option,{value:`1099`,label:`1099`,children:`1099`})]})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{name:`candidateProposedRateCurrency`,label:`Currency`,children:(0,l.jsxs)(s.Select,{showSearch:!0,allowClear:!0,children:[(0,l.jsx)(s.Select.Option,{value:`$`,children:`$`}),(0,l.jsx)(s.Select.Option,{value:`₹`,children:`₹`}),(0,l.jsx)(s.Select.Option,{value:`€`,children:`€`}),(0,l.jsx)(s.Select.Option,{value:`zł`,children:`zł`}),(0,l.jsx)(s.Select.Option,{value:`£`,children:`£`}),(0,l.jsx)(s.Select.Option,{value:`kr`,children:`kr`}),(0,l.jsx)(s.Select.Option,{value:`Fr`,children:`Fr`}),(0,l.jsx)(s.Select.Option,{value:`kr`,children:`kr`})]})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Resume new`,name:`resume`,children:(0,l.jsx)(s.Upload,{beforeUpload:oM.beforeUpload,maxCount:1,children:(0,l.jsx)(s.Button,{children:`Upload Resume`})})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Documents`,name:`documents`,valuePropName:`fileList`,getValueFromEvent:e=>e?.fileList,rules:[aM.multiFileUpload()],children:(0,l.jsx)(s.Upload,{multiple:!0,beforeUpload:oM.beforeUpload,children:(0,l.jsx)(s.Button,{children:`Upload Documents`})})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Upload File`,name:`file`,valuePropName:`fileList`,getValueFromEvent:e=>e?.fileList,rules:[aM.fileUpload()],children:(0,l.jsx)(s.Upload,{beforeUpload:oM.beforeUpload,maxCount:1,children:(0,l.jsx)(s.Button,{children:`Upload`})})})})]}),(0,l.jsx)(s.Row,{children:(0,l.jsx)(s.Form.List,{name:`users`,children:(e,{add:t,remove:n})=>(0,l.jsxs)(l.Fragment,{children:[e.map(({key:e,name:t,...r})=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{required:!0,...r,rules:[{required:!0,message:`First name is requried`}],name:[t,`first`],children:(0,l.jsx)(s.Input,{placeholder:`First Name`})})}),(0,l.jsx)(s.Col,{span:11,children:(0,l.jsx)(s.Form.Item,{...r,required:!0,name:[t,`last`],children:(0,l.jsx)(s.Input,{placeholder:`Last Name`})})}),(0,l.jsx)(s.Col,{span:1,children:(0,l.jsx)(c.MinusCircleOutlined,{onClick:()=>n(t)})})]})),(0,l.jsx)(s.Form.Item,{children:(0,l.jsx)(s.Button,{type:`dashed`,onClick:()=>t(),block:!0,icon:(0,l.jsx)(c.PlusOutlined,{}),children:`Add field`})})]})})}),(0,l.jsxs)(s.Form.Item,{children:[(0,l.jsx)(s.Button,{type:`primary`,htmlType:`submit`,children:`Submit`}),(0,l.jsx)(s.Button,{style:{marginLeft:10},onClick:()=>e.resetFields(),children:`Reset`})]})]})})};function cM(e){return(0,l.jsx)(ub,{children:(0,l.jsx)(BE,{...e})})}var{Text:lM}=s.Typography,uM=[{label:`Total Jobs`,value:1697,icon:`fileText`},{label:`Active Jobs`,value:1685,icon:`checkCircle`},{label:`My Jobs`,value:600,icon:`user`}],dM={fileText:(0,l.jsx)(c.FileTextOutlined,{}),checkCircle:(0,l.jsx)(c.CheckCircleOutlined,{}),user:(0,l.jsx)(c.UserOutlined,{}),filter:(0,l.jsx)(c.FilterOutlined,{})};function fM({stats:e=uM}){return(0,l.jsx)(s.Card,{children:(0,l.jsx)(s.Row,{gutter:[12,12],children:e.map(e=>(0,l.jsx)(s.Col,{xs:24,sm:24,md:8,lg:8,xl:8,children:(0,l.jsxs)(s.Card,{className:`stats-inner-card`,children:[(0,l.jsxs)(s.Space,{align:`center`,children:[dM[e.icon]??dM.fileText,(0,l.jsx)(lM,{children:e.label})]}),(0,l.jsx)(s.Statistic,{value:e.value})]})},e.label))})})}var{Text:pM}=s.Typography;function mM(e){return e?.USER_NAME??e?.user_name??e?.username??e?.name??e?.full_name??e?.fullName??e?.email??`User ${e?.USER_ID??e?.user_id??`?`}`}function hM(e){return{...e,key:e.USER_ID??e.user_id??e.userId??e.id??e._id,_name:mM(e),_email:e.email??e.EMAIL??e.user_email??``,_role:e.role_name??e.roleName??e.ROLE_NAME??``,_rawRef:e}}function gM(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(0),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(1),[p,m]=(0,o.useState)(10),[h,g]=(0,o.useState)(``),_=(0,o.useCallback)(async({offset:e,limit:r,searchQuery:a}={})=>{u(!0);try{let o=await n.vr({offset:e,limit:r,searchQuery:a??``}),s=(o.users??[]).map(hM);t(s),i(o.total??s.length)}catch{s.message.error(`Failed to load users`)}finally{u(!1)}},[]);return(0,o.useEffect)(()=>{queueMicrotask(()=>{_({offset:(d-1)*p,limit:p,searchQuery:h})})},[_,d,p,h]),(0,l.jsx)(Z,{icon:(0,l.jsx)(c.TeamOutlined,{}),title:`Users`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,l.jsx)(km,{listName:`Users`,dataSource:e,fields:[{label:`Name`,value:`_name`,width:220,render:(e,t)=>(0,l.jsxs)(`div`,{children:[(0,l.jsx)(pM,{strong:!0,style:{fontSize:13},children:e}),t._email&&(0,l.jsx)(`div`,{style:{fontSize:11,color:`var(--color-text-muted)`},children:t._email})]})},{label:`Role`,value:`_role`,width:180}],loading:a,total:r,current:d,pageSize:p,onPageChange:e=>f(e),onPageSizeChange:e=>{m(e),f(1)},onSearch:e=>{g(e),f(1)}})})}var{Text:_M}=s.Typography,vM=[{key:`job`,label:`Jobs`},{key:`candidate`,label:`Candidates`},{key:`submissions`,label:`Submissions`}],yM=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`}];function bM({field:e,index:t,onToggle:n,onReorder:r}){let i=(0,o.useRef)(null),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(!1);function p(e){i.current=t,e.dataTransfer.effectAllowed=`move`,f(!0)}function m(){f(!1),u(!1)}function h(e){e.preventDefault(),u(!0)}function g(){u(!1)}function _(e){e.preventDefault(),u(!1),i.current!==null&&i.current!==t&&r(i.current,t),i.current=null}return(0,l.jsxs)(`div`,{draggable:!0,onDragStart:p,onDragEnd:m,onDragOver:h,onDragLeave:g,onDrop:_,className:`uss-field-row with-edit${a?` drag-over`:``}${d?` dragging`:``}`,children:[(0,l.jsx)(`span`,{className:`uss-drag-handle`,children:(0,l.jsx)(c.HolderOutlined,{})}),(0,l.jsxs)(`span`,{className:`uss-field-name`,children:[e.fieldName,(0,l.jsx)(`span`,{className:`uss-field-key`,children:e.fieldKey})]}),(0,l.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,l.jsx)(s.Switch,{size:`small`,checked:e.isVisible,onChange:e=>n(t,`isVisible`,e)})}),(0,l.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,l.jsx)(s.Switch,{size:`small`,checked:!!e.isEditable,onChange:e=>n(t,`isEditable`,e)})}),(0,l.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,l.jsx)(s.Switch,{size:`small`,checked:!!e.ismandatory,onChange:e=>n(t,`ismandatory`,e)})})]})}function xM({team:e,configType:t}){let[r,i]=(0,o.useState)({}),[a,c]=(0,o.useState)(!1),[u,d]=(0,o.useState)({}),[f,p]=(0,o.useState)(`job`);(0,o.useEffect)(()=>{e&&(c(!0),n.Xr(e,t).then(i).catch(()=>s.message.error(`Failed to load field config`)).finally(()=>c(!1)))},[e,t]);let m=r[f]??[];function h(e,t){i(n=>({...n,[e]:typeof t==`function`?t(n[e]??[]):t}))}function g(e,t,n){h(f,r=>r.map((r,i)=>i===e?{...r,[t]:n}:r))}function _(e,t){h(f,n=>{let r=[...n],[i]=r.splice(e,1);return r.splice(t,0,i),r.map((e,t)=>({...e,order:t}))})}async function v(){let r=f;d(e=>({...e,[r]:!0}));try{await n.Si(e,r,m,t),s.message.success(`Saved`)}catch{s.message.error(`Save failed`)}finally{d(e=>({...e,[r]:!1}))}}return(0,l.jsxs)(s.Spin,{spinning:a,children:[(0,l.jsx)(s.Tabs,{size:`small`,activeKey:f,onChange:p,items:vM.map(e=>({key:e.key,label:e.label}))}),(0,l.jsxs)(`div`,{className:`uss-field-header with-edit`,children:[(0,l.jsx)(`span`,{}),(0,l.jsx)(`span`,{children:`Field`}),(0,l.jsx)(`span`,{style:{textAlign:`center`},children:`Visible`}),(0,l.jsx)(`span`,{style:{textAlign:`center`},children:`Editable`}),(0,l.jsx)(`span`,{style:{textAlign:`center`},children:`Mandatory`})]}),(0,l.jsxs)(`div`,{className:`uss-field-list`,children:[m.length===0&&!a&&(0,l.jsx)(`div`,{className:`uss-empty`,children:`No fields found.`}),m.map((e,t)=>(0,l.jsx)(bM,{field:e,index:t,onToggle:g,onReorder:_},e.fieldKey??t))]}),(0,l.jsx)(`div`,{className:`uss-modal-footer`,children:(0,l.jsxs)(s.Button,{type:`primary`,size:`small`,loading:u[f],onClick:v,children:[`Save `,vM.find(e=>e.key===f)?.label]})})]})}function SM(){let[e,t]=(0,o.useState)(null),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(!1),[d,f]=(0,o.useState)(`listView`),[p,m]=(0,o.useState)([]),[h,g]=(0,o.useState)(0),[_,v]=(0,o.useState)(!1),[y,b]=(0,o.useState)(``),[x,S]=(0,o.useState)(!1),C=(0,o.useCallback)(async()=>{v(!0);try{let e=await n._r();m(e.teams),g(e.total)}catch{s.message.error(`Failed to load teams`)}finally{v(!1)}},[]);(0,o.useEffect)(()=>{C()},[C]);function w(e){t(e),f(`listView`),i(!0)}function T(e){t(e),b(e.teamName??``),u(!0)}async function E(){if(!y.trim()){s.message.warning(`Team name is required`);return}S(!0);try{await n.xi(e,{teamName:y.trim(),managerId:e.managerId,memberIds:e.memberIds}),s.message.success(`Team updated`),u(!1),C()}catch{s.message.error(`Failed to update team`)}finally{S(!1)}}return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(Z,{icon:(0,l.jsx)(c.TeamOutlined,{}),title:`Teams`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,l.jsx)(km,{listName:`Teams`,dataSource:p,fields:[{label:`Team Name`,value:`teamName`,width:200},{label:`Manager`,value:`manager`,width:200},{label:`Members`,value:`memberCount`,width:90,sorter:!1},{label:`Actions`,value:`_actions`,width:160,sorter:!1,render:(e,t)=>(0,l.jsxs)(`div`,{style:{display:`flex`,gap:4},children:[(0,l.jsx)(s.Button,{size:`small`,type:`link`,onClick:()=>T(t),children:`Edit`}),(0,l.jsx)(s.Button,{size:`small`,type:`link`,onClick:()=>w(t),children:`Configure`})]})}],loading:_,total:h})}),(0,l.jsx)(s.Modal,{open:a,onCancel:()=>u(!1),title:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(c.TeamOutlined,{style:{color:`var(--color-brand)`,marginRight:6}}),`Edit Team`]}),width:420,footer:null,destroyOnClose:!0,children:(0,l.jsxs)(`div`,{className:`uss-edit-team-body`,style:{paddingTop:12},children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`uss-edit-team-label`,children:`Team Name`}),(0,l.jsx)(s.Input,{value:y,onChange:e=>b(e.target.value),onPressEnter:E,placeholder:`Enter team name`})]}),(0,l.jsxs)(`div`,{className:`uss-modal-footer`,children:[(0,l.jsx)(s.Button,{onClick:()=>u(!1),children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,loading:x,onClick:E,children:`Save`})]})]})}),(0,l.jsxs)(s.Modal,{className:`uss-modal`,open:r,onCancel:()=>i(!1),title:(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(c.TeamOutlined,{style:{color:`var(--color-brand)`}}),(0,l.jsxs)(`span`,{children:[`Configure: `,e?.teamName]})]}),width:720,footer:null,destroyOnClose:!0,children:[(0,l.jsx)(`div`,{style:{marginBottom:12},children:(0,l.jsx)(`div`,{className:`uss-config-toggle`,children:yM.map(e=>(0,l.jsx)(`button`,{className:`uss-config-btn${d===e.key?` active`:``}`,onClick:()=>f(e.key),children:e.label},e.key))})}),e&&(0,l.jsx)(xM,{team:e,configType:d},`${e?.teamId}-${d}`)]})]})}var CM=[`view`,`add`,`edit`,`delete`],wM={view:`View`,add:`Add`,edit:`Edit`,delete:`Delete`,sourcing:`Sourcing`,assign:`Assign`,share:`Share`,change_status:`Status`,my_jobs:`My Jobs`,all_jobs:`All Jobs`,po_msa:`PO MSA`,reApprove:`ReApprove`,sendApprove:`Send Approve`};function TM(e){return wM[e]??e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function EM(e){let t=CM.filter(t=>e.includes(t)),n=e.filter(e=>!CM.includes(e)).sort();return[...t,...n]}function DM(e){let t=new Set;return Object.values(e).forEach(({permissions:e})=>Object.keys(e??{}).forEach(e=>t.add(e))),EM([...t])}function OM(e){let t=0,n=0;return Object.entries(e).forEach(([e,{permissions:r}])=>{Object.entries(r??{}).forEach(([r,{value:i}])=>{Sx(e,r)&&(n++,i===`1`&&t++)})}),{enabled:t,total:n}}function kM(e={}){if(!e||typeof e!=`object`)return e;let t=Object.keys(e).find(e=>String(e).trim().toLowerCase()===`onboarding`);if(!t)return e;let n=e[t]??{},r={...n.permissions??{}};for(let e of[`sendApprove`,`reApprove`])Object.keys(r).some(t=>t.toLowerCase()===e.toLowerCase())||(r[e]={id:0,value:`0`});return{...e,[t]:{...n,permissions:r}}}function AM({value:e,onSave:t,className:n}){let[r,i]=(0,o.useState)(!1),[a,s]=(0,o.useState)(e);(0,o.useEffect)(()=>{s(e)},[e]);function u(){i(!1);let n=a.trim();n&&n!==e?t(n):s(e)}return r?(0,l.jsx)(`input`,{autoFocus:!0,className:`perm-inline-input${n?` ${n}`:``}`,value:a,style:{width:Math.max(48,a.length*8)},onChange:e=>s(e.target.value),onBlur:u,onKeyDown:t=>{t.key===`Enter`&&u(),t.key===`Escape`&&(i(!1),s(e)),t.stopPropagation()},onClick:e=>e.stopPropagation()}):(0,l.jsxs)(`span`,{className:`perm-editable-name${n?` ${n}`:``}`,onDoubleClick:e=>{e.stopPropagation(),i(!0)},children:[e,(0,l.jsx)(c.EditOutlined,{className:`perm-name-edit-icon`})]})}function jM({entry:e,label:t,onToggle:n,onLabelSave:r}){let[i,a]=(0,o.useState)(!1),[u,d]=(0,o.useState)(t),f=e?.value===`1`,p=!!e;(0,o.useEffect)(()=>{d(t)},[t]);function m(){a(!1);let e=u.trim();e&&e!==t?r(e):d(t)}return(0,l.jsx)(s.Tooltip,{title:p?f?`Click to disable`:`Click to enable`:`Not applicable for this module`,children:(0,l.jsxs)(`div`,{className:`perm-action-pill${f?` on`:``}${p?``:` na`}`,onClick:()=>{!i&&p&&n()},children:[(0,l.jsx)(`span`,{className:`perm-action-pill-dot${f?` on`:``}`}),i?(0,l.jsx)(`input`,{autoFocus:!0,className:`perm-pill-input`,value:u,style:{width:Math.max(36,u.length*7)},onChange:e=>d(e.target.value),onBlur:m,onKeyDown:e=>{e.key===`Enter`&&m(),e.key===`Escape`&&(a(!1),d(t)),e.stopPropagation()},onClick:e=>e.stopPropagation()}):(0,l.jsx)(`span`,{className:`perm-action-pill-label`,onDoubleClick:e=>{e.stopPropagation(),a(!0)},children:t}),f&&!i&&(0,l.jsx)(c.CheckOutlined,{className:`perm-action-pill-check`})]})})}function MM({menuName:e,menuData:t,permKeys:n,onChange:r,displayName:i,actionLabels:a,onModuleLabelSave:o,onActionLabelSave:s}){let c=t?.permissions??{},u=n.filter(t=>Sx(e,t)),d=u.filter(e=>c[e]?.value===`1`).length,f=u.filter(e=>c[e]).length,p=f>0&&d===f;return(0,l.jsxs)(`div`,{className:`perm-module-card${p?` all-on`:d>0&&!p?` some-on`:``}`,children:[(0,l.jsxs)(`div`,{className:`perm-module-card-header`,children:[(0,l.jsx)(AM,{value:i,onSave:t=>o(e,t),className:`perm-module-card-name`}),f>0&&(0,l.jsxs)(`span`,{className:`perm-module-card-badge${d>0?` active`:``}`,children:[d,`/`,f]})]}),(0,l.jsx)(`div`,{className:`perm-module-card-body`,children:u.map(t=>(0,l.jsx)(jM,{entry:c[t],label:a[t]??TM(t),onToggle:()=>r(e,t),onLabelSave:e=>s(t,e)},t))})]})}function NM({role:e,moduleLabels:t={},actionLabels:r={},onModuleLabelSave:i=()=>{},onActionLabelSave:a=()=>{}}){let[u,d]=(0,o.useState)({}),[f,p]=(0,o.useState)({}),[m,h]=(0,o.useState)(!1),[g,_]=(0,o.useState)(!1),[v,y]=(0,o.useState)(!1),b=n.Gr(e);(0,o.useEffect)(()=>{b&&(h(!0),y(!1),n.Jr(b).then(e=>{let t=kM(e);d(t),p(t)}).catch(()=>s.message.error(`Failed to load permissions`)).finally(()=>h(!1)))},[b]);function x(e,t){y(!0),p(n=>{let r=n[e]??{menuId:u[e]?.menuId??0,permissions:{}},i=r.permissions?.[t]??{id:0,value:`0`};return{...n,[e]:{...r,permissions:{...r.permissions,[t]:{...i,value:i.value===`1`?`0`:`1`}}}}})}async function S(){_(!0);try{await n.yi(b,f),d(f),y(!1),s.message.success(`Permissions saved`)}catch(e){s.message.error(e?.message||`Save failed`)}finally{_(!1)}}let C=(0,o.useMemo)(()=>Object.keys(f).sort(),[f]),w=(0,o.useMemo)(()=>DM(f),[f]),{enabled:T,total:E}=(0,o.useMemo)(()=>OM(f),[f]);return(0,l.jsxs)(s.Spin,{spinning:m,children:[(0,l.jsxs)(`div`,{className:`perm-panel-header`,children:[(0,l.jsxs)(`div`,{className:`perm-panel-title`,children:[(0,l.jsx)(c.LockOutlined,{style:{color:`var(--color-brand)`,marginRight:6}}),(0,l.jsx)(`span`,{children:e?.roleName}),!m&&E>0&&(0,l.jsxs)(s.Tag,{color:`blue`,style:{marginLeft:8,fontSize:11},children:[T,`/`,E,` enabled`]})]}),(0,l.jsx)(s.Button,{type:`primary`,size:`small`,icon:(0,l.jsx)(c.UnlockOutlined,{}),loading:g,disabled:!v,onClick:S,children:`Save Changes`})]}),(0,l.jsxs)(`div`,{className:`perm-hint`,children:[(0,l.jsx)(c.InfoCircleOutlined,{className:`perm-hint-icon`}),(0,l.jsxs)(`span`,{children:[`Click a pill to toggle. `,(0,l.jsx)(`strong`,{children:`Double-click`}),` a module name or action label to rename it — labels are saved locally.`]})]}),C.length===0&&!m?(0,l.jsx)(`div`,{className:`perm-empty`,children:`No permission entries found for this role.`}):(0,l.jsx)(`div`,{className:`perm-cards-grid`,children:C.map(e=>(0,l.jsx)(MM,{menuName:e,menuData:f[e],permKeys:w,onChange:x,displayName:t[e]??e,actionLabels:r,onModuleLabelSave:i,onActionLabelSave:a},e))})]})}var{Text:PM}=s.Typography,FM=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`}];function IM(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function LM(e){return String(e||``).trim().toLowerCase()}function RM(e){return e?.key||e?.collectionName||e?.value||``}function zM(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=RM(e);if(!t)return;let o=LM(e.key||t),s=LM(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||IM(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=LM(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:IM(t),value:t,disabled:!1}))}),n}function BM(){let[e,t]=(0,o.useState)(null),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(`listView`),[d,f]=(0,o.useState)([]),[p,m]=(0,o.useState)(0),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)([]),[y,b]=(0,o.useState)([]),[x,S]=(0,o.useState)(!1),[C,w]=(0,o.useState)(!1),T=(0,o.useMemo)(()=>_.filter(e=>!e.disabled),[_]),E=!x&&T.length===0,D=(0,o.useCallback)(async()=>{g(!0);try{let e=await n.gr();f(e.roles),m(e.total)}catch{s.message.error(`Failed to load roles`)}finally{g(!1)}},[]),O=(0,o.useCallback)(async()=>{S(!0);try{let[e,t]=await Promise.all([n.Or(),n.br()]),r=zM(e.modules,t),i=new Set(r.filter(e=>!e.disabled).map(e=>e.value));v(r),b(e=>e.filter(e=>i.has(e)))}catch{s.message.error(`Failed to load seed status`)}finally{S(!1)}},[]);(0,o.useEffect)(()=>{D()},[D]),(0,o.useEffect)(()=>{O()},[O]);async function k(){if(y.length===0){s.message.warning(E?`All modules already seeded.`:`Select at least one module to seed.`);return}w(!0);try{await n.ui(y),s.message.success(`Role field config seeded`),b([]),await O()}catch(e){s.message.error(e?.message||`Seed failed`)}finally{w(!1)}}function A(e,n=`listView`){t(e),u(n),i(!0)}return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.AppstoreOutlined,{}),title:`Field Config Seed`,style:{marginBottom:12},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[(0,l.jsx)(`div`,{style:{minWidth:320,flex:1},children:(0,l.jsx)(s.Select,{mode:`multiple`,allowClear:!0,showSearch:!0,value:y,options:_,placeholder:E?`All modules already seeded`:`Select modules or collections to seed`,disabled:x||C||E,loading:x,onChange:b,style:{width:`100%`}})}),(0,l.jsx)(s.Button,{type:`primary`,loading:C,disabled:x||y.length===0,onClick:k,children:`Seed Field Config`})]}),(0,l.jsx)(PM,{type:`secondary`,style:{display:`block`,marginTop:8,fontSize:12},children:E?`Seed is disabled because all configured modules already have role field config data.`:`Already seeded modules are disabled. New modules or collections can still be seeded.`})]}),(0,l.jsx)(Z,{icon:(0,l.jsx)(c.SafetyOutlined,{}),title:`Roles`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,l.jsx)(km,{listName:`Roles`,dataSource:d,fields:[{label:`Role Name`,value:`roleName`,width:200},{label:`Description`,value:`description`,width:240},{label:`Users`,value:`userCount`,width:70,sorter:!1},{label:`Actions`,value:`_configure`,width:200,sorter:!1,render:(e,t)=>(0,l.jsxs)(s.Space,{size:2,children:[(0,l.jsx)(s.Button,{size:`small`,type:`link`,onClick:()=>A(t),children:`Configure`}),(0,l.jsx)(s.Button,{size:`small`,type:`link`,icon:(0,l.jsx)(c.LockOutlined,{}),onClick:()=>A(t,`permissions`),children:`Permissions`})]})}],loading:h,total:p})}),(0,l.jsxs)(s.Modal,{className:`uss-modal`,open:r,onCancel:()=>i(!1),title:(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(c.SafetyOutlined,{style:{color:`var(--color-brand)`}}),(0,l.jsxs)(`span`,{children:[`Configure: `,e?.roleName]})]}),width:720,footer:null,destroyOnClose:!0,children:[(0,l.jsx)(`div`,{style:{marginBottom:12},children:(0,l.jsx)(`div`,{className:`uss-config-toggle`,children:FM.map(e=>(0,l.jsx)(`button`,{className:`uss-config-btn${a===e.key?` active`:``}`,onClick:()=>u(e.key),children:e.label},e.key))})}),e&&(a===`permissions`?(0,l.jsx)(NM,{role:e},e?.roleId):(0,l.jsx)(zx,{role:e,configType:a},`${e?.roleId}-${a}`))]})]})}var VM=`perm-module-labels`,HM=`perm-action-labels`;function UM(e){try{return JSON.parse(localStorage.getItem(e)??`{}`)}catch{return{}}}function WM(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function GM({label:e,onSave:t,onDelete:n,loading:r}){let[i,a]=(0,o.useState)(!1),[u,d]=(0,o.useState)(e);function f(){a(!1);let n=u.trim();n&&n!==e?t(n):d(e)}return(0,l.jsxs)(`div`,{className:`perm-manage-row`,children:[i?(0,l.jsx)(`input`,{autoFocus:!0,className:`perm-inline-input`,value:u,style:{flex:1,minWidth:0},onChange:e=>d(e.target.value),onBlur:f,onKeyDown:t=>{t.key===`Enter`&&f(),t.key===`Escape`&&(a(!1),d(e))}}):(0,l.jsx)(`span`,{className:`perm-manage-row-label`,children:e}),(0,l.jsxs)(`div`,{className:`perm-manage-row-actions`,children:[(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>{d(e),a(!0)},loading:r}),(0,l.jsx)(s.Popconfirm,{title:`Delete this item?`,onConfirm:n,okText:`Delete`,cancelText:`Cancel`,okType:`danger`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.DeleteOutlined,{}),danger:!0})})]})]})}function KM({open:e,onClose:t}){let[r,i]=(0,o.useState)(`modules`),[a,u]=(0,o.useState)([]),[d,f]=(0,o.useState)(!1),[p,m]=(0,o.useState)(``),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)([]),[y,b]=(0,o.useState)(!1),[x,S]=(0,o.useState)(``),[C,w]=(0,o.useState)(``),[T,E]=(0,o.useState)(!1);(0,o.useEffect)(()=>{e&&(D(),O())},[e]);async function D(){f(!0);try{u(await n.Fr())}catch{s.message.error(`Failed to load modules`)}finally{f(!1)}}async function O(){b(!0);try{v(await n.Pr())}catch{s.message.error(`Failed to load actions`)}finally{b(!1)}}async function k(){let e=p.trim();if(!e){s.message.warning(`Enter a module name`);return}g(!0);try{let t=await n.Zn({menuName:e});u(e=>[...e,t]),m(``),s.message.success(`Module added`)}catch{s.message.error(`Failed to add module`)}finally{g(!1)}}async function A(e,t){try{await n.hi(e,{menuName:t}),u(n=>n.map(n=>n.MENUID===e?{...n,MENUNAME:t}:n))}catch{s.message.error(`Failed to update module`)}}async function j(e){try{await n.or(e),u(t=>t.filter(t=>t.MENUID!==e)),s.message.success(`Module deleted`)}catch{s.message.error(`Failed to delete module`)}}async function M(){let e=x.trim(),t=C.trim().toLowerCase().replace(/\s+/g,`_`);if(!e||!t){s.message.warning(`Enter both name and key`);return}E(!0);try{let r=await n.Xn({permissionName:e,permissionKey:t});v(e=>[...e,r]),S(``),w(``),s.message.success(`Action added`)}catch(e){s.message.error(e?.message?.includes(`409`)||e?.status===409?`Permission key already exists`:`Failed to add action`)}finally{E(!1)}}async function N(e,t){try{await n.mi(e,{permissionName:t}),v(n=>n.map(n=>n.permissionId===e?{...n,permissionName:t}:n))}catch{s.message.error(`Failed to update action`)}}async function P(e){try{await n.ar(e),v(t=>t.filter(t=>t.permissionId!==e)),s.message.success(`Action deleted`)}catch{s.message.error(`Failed to delete action`)}}let F=[{key:`modules`,label:`Modules`,children:(0,l.jsxs)(s.Spin,{spinning:d,children:[(0,l.jsxs)(`div`,{className:`perm-manage-add-row`,children:[(0,l.jsx)(s.Input,{placeholder:`Module name`,value:p,onChange:e=>m(e.target.value),onPressEnter:k,style:{flex:1},size:`small`}),(0,l.jsx)(s.Button,{type:`primary`,size:`small`,icon:(0,l.jsx)(c.PlusOutlined,{}),loading:h,onClick:k,children:`Add`})]}),(0,l.jsxs)(`div`,{className:`perm-manage-list`,children:[a.length===0&&!d&&(0,l.jsx)(`div`,{className:`perm-empty`,style:{paddingTop:24},children:`No modules found`}),a.map(e=>(0,l.jsx)(GM,{label:e.MENUNAME,onSave:t=>A(e.MENUID,t),onDelete:()=>j(e.MENUID)},e.MENUID))]})]})},{key:`actions`,label:`Actions`,children:(0,l.jsxs)(s.Spin,{spinning:y,children:[(0,l.jsxs)(`div`,{className:`perm-manage-add-row`,children:[(0,l.jsx)(s.Input,{placeholder:`Action name (e.g. Approve)`,value:x,onChange:e=>S(e.target.value),style:{flex:1},size:`small`}),(0,l.jsx)(s.Input,{placeholder:`Key (e.g. approve)`,value:C,onChange:e=>w(e.target.value),onPressEnter:M,style:{width:140},size:`small`}),(0,l.jsx)(s.Button,{type:`primary`,size:`small`,icon:(0,l.jsx)(c.PlusOutlined,{}),loading:T,onClick:M,children:`Add`})]}),(0,l.jsxs)(`div`,{className:`perm-manage-list`,children:[_.length===0&&!y&&(0,l.jsx)(`div`,{className:`perm-empty`,style:{paddingTop:24},children:`No actions found`}),_.map(e=>(0,l.jsx)(GM,{label:`${e.permissionName} (${e.permissionKey})`,onSave:t=>N(e.permissionId,t),onDelete:()=>P(e.permissionId)},e.permissionId))]})]})}];return(0,l.jsx)(s.Modal,{open:e,onCancel:t,title:(0,l.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(c.SettingOutlined,{style:{color:`var(--color-brand)`}}),`Manage Modules & Actions`]}),width:520,footer:null,destroyOnClose:!0,children:(0,l.jsx)(s.Tabs,{activeKey:r,onChange:i,size:`small`,items:F})})}function qM(){let[e,t]=(0,o.useState)([]),[r,i]=(0,o.useState)(!1),[a,u]=(0,o.useState)(null),[d,f]=(0,o.useState)(``),[p,m]=(0,o.useState)(!1),[h,g]=(0,o.useState)(()=>UM(VM)),[_,v]=(0,o.useState)(()=>UM(HM)),y=(0,o.useCallback)((e,t)=>{g(n=>{let r={...n,[e]:t};return WM(VM,r),r})},[]),b=(0,o.useCallback)((e,t)=>{v(n=>{let r={...n,[e]:t};return WM(HM,r),r})},[]);function x(){g({}),v({}),WM(VM,{}),WM(HM,{}),s.message.success(`Labels reset to defaults`)}let S=(0,o.useCallback)(async()=>{i(!0);try{let{roles:e}=await n.gr();t(e),e.length>0&&u(e[0])}catch{s.message.error(`Failed to load roles`)}finally{i(!1)}},[]);(0,o.useEffect)(()=>{S()},[S]);let C=(0,o.useMemo)(()=>{let t=d.trim().toLowerCase();return t?e.filter(e=>e.roleName.toLowerCase().includes(t)):e},[e,d]),w=Object.keys(h).length>0||Object.keys(_).length>0;return(0,l.jsxs)(`div`,{className:`perm-page`,children:[(0,l.jsxs)(Z,{className:`perm-left-card`,icon:(0,l.jsx)(c.SafetyOutlined,{}),title:`Roles`,bodyStyle:{padding:0},children:[(0,l.jsx)(`div`,{className:`perm-role-search`,children:(0,l.jsx)(s.Input,{prefix:(0,l.jsx)(c.SearchOutlined,{}),placeholder:`Search roles…`,allowClear:!0,size:`small`,value:d,onChange:e=>f(e.target.value)})}),(0,l.jsx)(s.Spin,{spinning:r,children:(0,l.jsxs)(`div`,{className:`perm-role-list`,children:[C.length===0&&!r&&(0,l.jsx)(`div`,{className:`perm-role-empty`,children:`No roles found`}),C.map(e=>{let t=a?.roleId===e.roleId,n=e.description&&e.description!==`N/A`?e.description:e.roleType===0?`Default role`:`Custom role`;return(0,l.jsxs)(`div`,{className:`perm-role-item${t?` active`:``}`,onClick:()=>u(e),children:[(0,l.jsx)(`div`,{className:`perm-role-item-name`,children:e.roleName}),(0,l.jsx)(`div`,{className:`perm-role-item-desc`,children:n})]},e.roleId)})]})})]}),(0,l.jsx)(Z,{className:`perm-right-card`,icon:(0,l.jsx)(c.LockOutlined,{}),title:`Module Permissions`,extra:(0,l.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[w&&(0,l.jsx)(`button`,{className:`perm-reset-btn`,onClick:x,children:`Reset labels`}),(0,l.jsx)(s.Button,{size:`small`,icon:(0,l.jsx)(c.SettingOutlined,{}),onClick:()=>m(!0),children:`Manage`})]}),bodyStyle:{padding:`12px 16px`},children:a?(0,l.jsx)(NM,{role:a,moduleLabels:h,actionLabels:_,onModuleLabelSave:y,onActionLabelSave:b},a.roleId):(0,l.jsx)(`div`,{className:`perm-empty`,children:`Select a role from the left to manage its permissions.`})}),(0,l.jsx)(KM,{open:p,onClose:()=>m(!1)})]})}var{Title:JM,Text:YM}=s.Typography,XM=[{label:`In Progress`,value:107,sub:`Under review`,color:`blue`},{label:`Hired`,value:2,sub:`Onboarded`,color:`green`},{label:`Project Completed`,value:2,sub:`Project cycle closed`,color:`purple`},{label:`Archive`,value:2,sub:`No longer active`,color:`peach`}];function ZM({items:e=XM}){return(0,l.jsx)(s.Card,{className:`onboarding-card`,title:(0,l.jsx)(JM,{level:5,children:`Onboarding`}),extra:(0,l.jsx)(s.Button,{type:`link`,children:`View all`}),children:(0,l.jsx)(s.Row,{gutter:[12,12],children:e.map(e=>(0,l.jsx)(s.Col,{xs:12,sm:6,md:6,lg:12,xl:12,children:(0,l.jsxs)(`div`,{className:`onboarding-item ${e.color}`,children:[(0,l.jsx)(YM,{className:`onboarding-item-label`,children:e.label}),(0,l.jsx)(s.Statistic,{value:e.value,className:`onboarding-stat`}),(0,l.jsx)(`div`,{className:`onboarding-item-footer`,children:(0,l.jsx)(YM,{className:`onboarding-item-sub`,children:e.sub})})]})},e.label))})})}var{Text:QM,Title:$M}=s.Typography,eN=[{group:`Dashboard`,items:[{id:`dashboard`,label:`Admin Dashboard`,icon:(0,l.jsx)(c.DashboardOutlined,{})}]},{group:`Settings`,items:[{id:`org`,label:`Organization`,icon:(0,l.jsx)(c.BankOutlined,{}),heading:`Organization Settings`,desc:`Manage your company profile and location details`,cards:[{label:`Company Information`,icon:(0,l.jsx)(c.BankOutlined,{}),desc:`Manage company profile, address and business details.`},{label:`Location`,icon:(0,l.jsx)(c.BuildOutlined,{}),desc:`Manage office locations, branches and regions.`}]},{id:`users`,label:`Users`,icon:(0,l.jsx)(c.UserOutlined,{}),heading:`Users`,desc:`Manage platform users and configure their field views.`,component:`users`},{id:`teams`,label:`Teams`,icon:(0,l.jsx)(c.TeamOutlined,{}),heading:`Teams`,desc:`Organize users into teams and configure field visibility per team.`,component:`teams`},{id:`roles`,label:`Roles`,icon:(0,l.jsx)(c.SafetyOutlined,{}),heading:`Roles`,desc:`Control permissions and configure field visibility per role.`,component:`roles`},{id:`permissions`,label:`Permissions`,icon:(0,l.jsx)(c.LockOutlined,{}),heading:`Permissions`,desc:`Manage module-wise action permissions (view, add, edit, delete, and more) per role.`,component:`permissions`},{id:`templates`,label:`Templates`,icon:(0,l.jsx)(c.FileTextOutlined,{}),heading:`Templates`,desc:`Email and signature templates for communications`,component:`templates`},{id:`ai-services`,label:`AI Services`,icon:(0,l.jsx)(c.ThunderboltOutlined,{}),heading:`AI Services`,desc:`Register the AI/automation backends (base URL + auth) that admin-configured AI Actions call.`,component:`ai-services`},{id:`bgc-integration`,label:`Integrations`,icon:(0,l.jsx)(c.SafetyOutlined,{}),heading:`Integrations`,desc:`Manage manual and API integrations used across application workflows.`,component:`bgc-integration`}]},{group:`Clients`,items:[{id:`clients`,label:`Clients`,icon:(0,l.jsx)(c.BankOutlined,{}),heading:`Clients`,desc:`Manage client accounts and settings`,cards:[{label:`Clients`,icon:(0,l.jsx)(c.BankOutlined,{}),desc:`Manage client companies and account details.`}]}]},{group:`Forms`,items:[{id:`form-groups`,label:`Form Groups`,icon:(0,l.jsx)(c.AppstoreAddOutlined,{}),heading:`Form Groups`,desc:`Define field groups for module add/edit forms with validations and dropdown sources.`,component:`form-groups`},{id:`detail-groups`,label:`Detail Groups`,icon:(0,l.jsx)(c.AppstoreOutlined,{}),heading:`Detail Groups`,desc:`Customize the detail view per module: labels, prefix/suffix, colour, capitalization, reference lookups and merged fields.`,component:`detail-groups`},{id:`row-actions`,label:`Actions`,icon:(0,l.jsx)(c.ToolOutlined,{}),heading:`Actions`,desc:`Configure which action buttons appear per row in each module's list view, scoped per role.`,component:`row-actions`}]},{group:`Master`,items:[{id:`jobs`,label:`Jobs`,icon:(0,l.jsx)(c.AppstoreOutlined,{}),heading:`Jobs Master`,desc:`Configure job sources and status types`,cards:[{label:`Sources`,icon:(0,l.jsx)(c.AppstoreOutlined,{}),desc:`Manage job source master values.`},{label:`Job Status`,icon:(0,l.jsx)(c.CheckCircleOutlined,{}),desc:`Configure job workflow status.`}]},{id:`candidates`,label:`Candidates`,icon:(0,l.jsx)(c.UserOutlined,{}),heading:`Candidates Master`,desc:`Skills, sources and work authorization settings`,cards:[{label:`Sources`,icon:(0,l.jsx)(c.AppstoreOutlined,{}),desc:`Manage candidate source values.`},{label:`Skills`,icon:(0,l.jsx)(c.SettingOutlined,{}),desc:`Manage skill master data.`},{label:`Work Authorization`,icon:(0,l.jsx)(c.SafetyOutlined,{}),desc:`Manage visa and authorization types.`}]},{id:`submissions`,label:`Submissions`,icon:(0,l.jsx)(c.FileTextOutlined,{}),heading:`Submissions Master`,desc:`Rejection reasons and submission status configuration`,cards:[{label:`Rejection Reasons`,icon:(0,l.jsx)(c.FileTextOutlined,{}),desc:`Manage common rejection reasons.`},{label:`Client Submission Status`,icon:(0,l.jsx)(c.CheckCircleOutlined,{}),desc:`Manage client submission statuses.`}]},{id:`clientmaster`,label:`Client Master`,icon:(0,l.jsx)(c.BankOutlined,{}),heading:`Client Master`,desc:`Payment terms, client types and contact types`,cards:[{label:`Payment Terms`,icon:(0,l.jsx)(c.FileTextOutlined,{}),desc:`Manage billing and payment terms.`},{label:`Client Type`,icon:(0,l.jsx)(c.AppstoreOutlined,{}),desc:`Classify client business types.`},{label:`Client Contact Type`,icon:(0,l.jsx)(c.TeamOutlined,{}),desc:`Manage client contact categories.`}]}]}],tN=[{label:`Sourced`,count:312,color:`#378ADD`,pct:35},{label:`Screened`,count:223,color:`#7F77DD`,pct:25},{label:`Interview`,count:161,color:`#1D9E75`,pct:18},{label:`Offered`,count:107,color:`#EF9F27`,pct:12},{label:`Rejected`,count:89,color:`#E24B4A`,pct:10}],nN=[{name:`Tcs`,jobs:14,candidates:86},{name:`Empasis`,jobs:9,candidates:64},{name:`NovaSystems`,jobs:7,candidates:51},{name:`Brightwave`,jobs:5,candidates:38}],rN=[{text:`New candidate Ravi Kumar added to Java Developer role`,time:`2 min ago`,color:`#378ADD`},{text:`Submission approved by Acme Corp for Sr. React Dev`,time:`18 min ago`,color:`#1D9E75`},{text:`User Priya S. added to Recruiters team`,time:`1 hr ago`,color:`#7F77DD`},{text:`Job Data Analyst — TechFlow moved to archived`,time:`3 hr ago`,color:`#EF9F27`},{text:`Candidate rejected — work authorization mismatch`,time:`5 hr ago`,color:`#E24B4A`}];function iN(){return(0,l.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:16},children:[(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.DashboardOutlined,{}),title:`Admin Dashboard`,children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)($M,{level:5,children:`Admin Dashboard`}),(0,l.jsx)(QM,{type:`secondary`,children:`Overview of jobs, candidates, onboarding and recent activity`})]}),(0,l.jsx)(`div`,{className:`admin-dashboard-stats`,children:(0,l.jsx)(fM,{stats:[{label:`Total Jobs`,value:1697,icon:`fileText`},{label:`Active Jobs`,value:1685,icon:`checkCircle`},{label:`My Jobs`,value:600,icon:`user`},{label:`Total Candidates`,value:4320,icon:`team`},{label:`Submissions`,value:892,icon:`fileText`}]})}),(0,l.jsxs)(`div`,{className:`admin-dashboard-mid-row`,children:[(0,l.jsx)(ZM,{}),(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.AppstoreOutlined,{}),title:`Candidate Pipeline`,children:[(0,l.jsx)(QM,{type:`secondary`,style:{fontSize:12},children:`By stage (892 total)`}),(0,l.jsx)(`div`,{className:`admin-pipeline-bar`,children:tN.map(e=>(0,l.jsx)(`div`,{className:`admin-pipeline-seg`,style:{width:`${e.pct}%`,background:e.color}},e.label))}),(0,l.jsx)(`div`,{className:`admin-pipeline-legend`,children:tN.map(e=>(0,l.jsxs)(`div`,{className:`admin-pipeline-legend-item`,children:[(0,l.jsx)(`span`,{className:`admin-pipeline-dot`,style:{background:e.color}}),e.label,` `,e.count]},e.label))}),(0,l.jsx)(`div`,{className:`admin-divider`}),(0,l.jsx)(QM,{strong:!0,style:{fontSize:12},children:`Submission status`}),(0,l.jsxs)(`div`,{className:`admin-sub-status-list`,style:{marginTop:6},children:[(0,l.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,l.jsx)(QM,{style:{fontSize:13},children:`Pending client review`}),(0,l.jsx)(`span`,{className:`admin-badge warn`,children:`312`})]}),(0,l.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,l.jsx)(QM,{style:{fontSize:13},children:`Client approved`}),(0,l.jsx)(`span`,{className:`admin-badge success`,children:`248`})]}),(0,l.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,l.jsx)(QM,{style:{fontSize:13},children:`Rejected`}),(0,l.jsx)(`span`,{className:`admin-badge danger`,children:`89`})]})]})]})]}),(0,l.jsxs)(`div`,{className:`admin-dashboard-bottom-row`,children:[(0,l.jsx)(Z,{icon:(0,l.jsx)(c.BankOutlined,{}),title:`Top Clients`,extra:(0,l.jsx)(s.Button,{type:`link`,size:`small`,children:`View all`}),children:nN.map(e=>(0,l.jsxs)(`div`,{className:`admin-client-row`,children:[(0,l.jsxs)(`div`,{className:`admin-client-left`,children:[(0,l.jsx)(`div`,{className:`admin-client-icon`,children:(0,l.jsx)(c.BankOutlined,{})}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`admin-client-name`,children:e.name}),(0,l.jsxs)(`div`,{className:`admin-client-sub`,children:[e.jobs,` open jobs`]})]})]}),(0,l.jsxs)(`div`,{className:`admin-client-right`,children:[(0,l.jsx)(`div`,{className:`admin-client-val`,children:e.candidates}),(0,l.jsx)(`div`,{className:`admin-client-sub`,children:`candidates`})]})]},e.name))}),(0,l.jsx)(Z,{icon:(0,l.jsx)(c.BellOutlined,{}),title:`Recent Activity`,children:rN.map((e,t)=>(0,l.jsxs)(`div`,{className:`admin-activity-row`,children:[(0,l.jsx)(`div`,{className:`admin-activity-dot`,style:{background:e.color}}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`admin-activity-text`,children:e.text}),(0,l.jsx)(`div`,{className:`admin-activity-time`,children:e.time})]})]},t))})]}),(0,l.jsx)(Z,{icon:(0,l.jsx)(c.SettingOutlined,{}),title:`Admin Configuration Overview`,extra:(0,l.jsx)(s.Button,{type:`link`,size:`small`,children:`Manage`}),children:(0,l.jsxs)(s.Row,{gutter:[24,0],children:[(0,l.jsxs)(s.Col,{span:8,children:[(0,l.jsx)(QM,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`Settings`}),[[`Organization`,2],[`User Settings`,4],[`Templates`,2]].map(([e,t])=>(0,l.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,l.jsx)(QM,{style:{fontSize:12},children:e}),(0,l.jsxs)(`span`,{className:`admin-badge info`,children:[t,` items`]})]},e))]}),(0,l.jsxs)(s.Col,{span:8,children:[(0,l.jsx)(QM,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`Master`}),[[`Jobs`,2],[`Candidates`,3],[`Submissions`,2]].map(([e,t])=>(0,l.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,l.jsx)(QM,{style:{fontSize:12},children:e}),(0,l.jsxs)(`span`,{className:`admin-badge info`,children:[t,` items`]})]},e))]}),(0,l.jsxs)(s.Col,{span:8,children:[(0,l.jsx)(QM,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`System`}),[[`Total Groups`,4],[`Total Modules`,9],[`Config Items`,19]].map(([e,t])=>(0,l.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,l.jsx)(QM,{style:{fontSize:12},children:e}),(0,l.jsx)(QM,{strong:!0,style:{fontSize:12},children:t})]},e))]})]})})]})}function aN({activeSection:e,activeGroup:t,filteredCards:n,searchText:r,setSearchText:i,allItems:a,handleNav:o}){return(0,l.jsxs)(s.Row,{gutter:[16,16],children:[(0,l.jsx)(s.Col,{span:24,children:(0,l.jsxs)(Z,{icon:e?.icon,title:e?.heading,extra:(0,l.jsx)(s.Input,{className:`admin-search`,prefix:(0,l.jsx)(c.SearchOutlined,{}),placeholder:`Search settings…`,allowClear:!0,value:r,onChange:e=>i(e.target.value)}),children:[(0,l.jsx)(`div`,{className:`admin-accent-bar`}),(0,l.jsx)($M,{level:5,children:e?.heading}),(0,l.jsx)(QM,{type:`secondary`,children:e?.desc})]})}),(0,l.jsx)(s.Col,{xs:24,xl:16,style:{alignSelf:`flex-start`},children:(0,l.jsx)(Z,{icon:(0,l.jsx)(c.AppstoreOutlined,{}),title:`Configuration Items`,extra:(0,l.jsxs)(QM,{type:`secondary`,children:[n.length,` item`,n.length===1?``:`s`]}),children:(0,l.jsx)(s.Row,{gutter:[14,14],children:n.length>0?n.map(e=>(0,l.jsx)(s.Col,{xs:24,sm:12,xl:8,children:(0,l.jsxs)(`div`,{className:`admin-config-item`,children:[(0,l.jsx)(`div`,{className:`admin-config-top-bar`}),(0,l.jsxs)(`div`,{className:`admin-config-body`,children:[(0,l.jsx)(`div`,{className:`admin-config-icon`,children:e.icon}),(0,l.jsxs)(`div`,{className:`admin-config-text`,children:[(0,l.jsx)(`span`,{className:`admin-config-label`,children:e.label}),(0,l.jsx)(`span`,{className:`admin-config-desc`,children:e.desc})]})]}),(0,l.jsx)(`div`,{className:`admin-config-divider`}),(0,l.jsx)(s.Button,{type:`link`,size:`small`,className:`admin-config-manage`,icon:(0,l.jsx)(c.RightOutlined,{}),iconPosition:`end`,children:`Manage`})]})},e.label)):(0,l.jsx)(s.Col,{span:24,children:(0,l.jsx)(`div`,{className:`admin-config-empty`,children:(0,l.jsx)(s.Empty,{description:`No settings found`,image:s.Empty.PRESENTED_IMAGE_SIMPLE})})})})})}),(0,l.jsx)(s.Col,{xs:24,xl:8,style:{alignSelf:`flex-start`},children:(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.FileTextOutlined,{}),title:`Section Overview`,children:[(0,l.jsx)(`div`,{className:`admin-overview-list`,children:eN.filter(e=>e.group!==`Dashboard`).map(e=>{let n=e.group===t?.group;return(0,l.jsxs)(`div`,{className:`admin-overview-item${n?` active`:``}`,onClick:()=>{let t=e.items[0];t&&o(t.id)},children:[(0,l.jsxs)(`div`,{className:`admin-overview-left`,children:[(0,l.jsx)(`div`,{className:`admin-overview-icon`,children:e.items[0]?.icon}),(0,l.jsxs)(`div`,{className:`admin-overview-text`,children:[(0,l.jsx)(`span`,{className:`admin-overview-name`,children:e.group}),(0,l.jsxs)(`span`,{className:`admin-overview-sub`,children:[e.items.length,` module`,e.items.length===1?``:`s`]})]})]}),(0,l.jsx)(`span`,{className:`admin-overview-count${n?` active`:``}`,children:e.items.length})]},e.group)})}),(0,l.jsxs)(`div`,{className:`admin-overview-footer`,children:[(0,l.jsx)(`span`,{className:`admin-overview-footer-label`,children:`Total configuration items`}),(0,l.jsx)(`span`,{className:`admin-overview-footer-value`,children:a.filter(e=>e.cards).reduce((e,t)=>e+t.cards.length,0)})]})]})})]})}function oN(){let[e,t]=(0,o.useState)(`dashboard`),[n,r]=(0,o.useState)(``),i=(0,o.useMemo)(()=>eN.flatMap(e=>e.items),[]),a=(0,o.useMemo)(()=>i.find(t=>t.id===e),[i,e]),u=(0,o.useMemo)(()=>eN.find(t=>t.items.some(t=>t.id===e)),[e]),d=(0,o.useMemo)(()=>{if(!a?.cards)return[];let e=n.trim().toLowerCase();return e?a.cards.filter(t=>t.label.toLowerCase().includes(e)||t.desc.toLowerCase().includes(e)):a.cards},[a,n]),f=(0,o.useMemo)(()=>eN.map(e=>({key:e.group,type:`group`,label:e.group,children:e.items.map(e=>({key:e.id,icon:e.icon,label:e.label}))})),[]),p=e=>{t(e),r(``)};return e===`dashboard`||a?.heading,(0,l.jsxs)(`main`,{className:`admin-page`,children:[(0,l.jsx)(`div`,{className:`admin-breadcrumb`,children:(0,l.jsx)(s.Breadcrumb,{items:[{title:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(c.HomeOutlined,{}),` Home`]})},{title:`Admin`}]})}),(0,l.jsxs)(s.Row,{gutter:[16,16],className:`admin-wrapper`,children:[(0,l.jsx)(s.Col,{xs:24,lg:6,xl:5,children:(0,l.jsxs)(Z,{title:`Admin Console`,icon:(0,l.jsx)(c.SettingOutlined,{}),children:[(0,l.jsxs)(`div`,{className:`admin-sidebar-banner`,children:[(0,l.jsx)(`span`,{className:`admin-sidebar-banner-title`,children:`Admin Panel`}),(0,l.jsx)(`span`,{className:`admin-sidebar-banner-sub`,children:`Configuration Center`}),(0,l.jsxs)(s.Row,{gutter:[8,0],children:[(0,l.jsx)(s.Col,{span:12,children:(0,l.jsxs)(`div`,{className:`admin-sidebar-pill`,children:[(0,l.jsx)(`span`,{className:`admin-sidebar-pill-label`,children:`Groups`}),(0,l.jsx)(`span`,{className:`admin-sidebar-pill-value`,children:eN.length})]})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsxs)(`div`,{className:`admin-sidebar-pill`,children:[(0,l.jsx)(`span`,{className:`admin-sidebar-pill-label`,children:`Modules`}),(0,l.jsx)(`span`,{className:`admin-sidebar-pill-value`,children:i.length})]})})]})]}),(0,l.jsx)(s.Menu,{mode:`inline`,selectedKeys:[e],items:f,onClick:({key:e})=>p(e),className:`admin-sidebar-menu`})]})}),(0,l.jsx)(s.Col,{xs:24,lg:18,xl:19,children:e===`dashboard`?(0,l.jsx)(iN,{}):a?.component===`form-groups`?(0,l.jsx)(IC,{}):a?.component===`detail-groups`?(0,l.jsx)(mw,{}):a?.component===`row-actions`?(0,l.jsx)(rT,{}):a?.component===`users`?(0,l.jsx)(gM,{}):a?.component===`teams`?(0,l.jsx)(SM,{}):a?.component===`roles`?(0,l.jsx)(BM,{}):a?.component===`permissions`?(0,l.jsx)(qM,{}):a?.component===`templates`?(0,l.jsx)(hT,{}):a?.component===`ai-services`?(0,l.jsx)(yT,{}):a?.component===`bgc-integration`?(0,l.jsx)(TT,{}):(0,l.jsx)(aN,{activeSection:a,activeGroup:u,filteredCards:d,searchText:n,setSearchText:r,allItems:i,handleNav:p})})]})]})}var{Title:sN}=s.Typography;function cN(){let e=(0,d.useNavigate)(),{state:t}=(0,d.useLocation)(),n=t?.moduleName||`stickyNotes`,r=t?.title||`Sticky Notes`,i={...t?.request,params:{...t?.request?.params,limit:200,offset:0}};return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(s.Button,{type:`text`,icon:(0,l.jsx)(c.ArrowLeftOutlined,{}),onClick:()=>e(-1),style:{marginBottom:12},children:`Back`}),(0,l.jsx)(Pt,{moduleName:n,title:r,columns:4,request:i,viewAll:!1})]})}var{Text:lN,Title:uN}=s.Typography,dN=10485760,fN=`/templates/test_cases_flow_template.base64.txt`,pN=`test_cases_flow_template.xlsx`,mN=`module | subModule | step_order | description | actions | key | value | expected | scenario`,hN={idle:0,module_set:1,encoding:1,validating:2,preview:3,inserting:3,done:4,error:1},gN=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Bulk upload`,href:`/bulk-upload`}];function _N(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result).split(`,`)[1]),r.onerror=n,r.readAsDataURL(e)})}function vN(e){return e.filter(e=>e.row_status===`valid`).map(e=>{let t={...e};return delete t.row_status,delete t.errors,t})}function yN(e){return e.flatMap(e=>(e.errors??[]).map(t=>({id:e.id,...t})))}function bN({errors:e}){return(0,l.jsx)(`div`,{className:`bulk-tooltip-errors`,children:(e??[]).map((e,t)=>(0,l.jsx)(`div`,{children:e.message},`${e.field}-${t}`))})}function xN({errors:e,expanded:t,onToggle:n,onSummaryClick:r}){return e.length===0?null:(0,l.jsxs)(`div`,{className:`bulk-error-banner`,children:[(0,l.jsxs)(`div`,{className:`bulk-error-summary`,children:[(0,l.jsxs)(`button`,{type:`button`,className:`bulk-error-summary-main`,onClick:r,"aria-label":`Scroll to first invalid row`,children:[(0,l.jsx)(c.ExclamationCircleOutlined,{className:`bulk-error-icon`}),(0,l.jsxs)(`span`,{children:[e.length,` validation error(s) found`]})]}),(0,l.jsx)(s.Button,{type:`link`,onClick:n,"aria-expanded":t,children:t?`Hide Errors`:`View Errors`})]}),t&&(0,l.jsx)(`div`,{className:`bulk-error-list`,role:`region`,"aria-label":`Validation error details`,children:e.map((e,t)=>(0,l.jsxs)(`div`,{className:`bulk-error-line`,children:[(0,l.jsxs)(`span`,{className:`bulk-row-chip`,children:[`Row `,e.id]}),(0,l.jsx)(`span`,{children:e.message})]},`${e.id}-${e.field}-${t}`))})]})}function SN({rows:e,view:t,onViewChange:n,onConfirm:r,onReset:i,saving:a,firstInvalidRowId:o,firstInvalidRowRef:u}){let d=e.filter(e=>e.row_status===`invalid`),f=t===`errors`?d:e,p=d.length>0||a;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(s.Row,{justify:`space-between`,align:`middle`,gutter:[16,16],className:`bulk-table-toolbar`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsxs)(s.Space.Compact,{children:[(0,l.jsx)(s.Button,{type:t===`all`?`primary`:`default`,onClick:()=>n(`all`),children:`All rows`}),(0,l.jsx)(s.Button,{type:t===`errors`?`primary`:`default`,onClick:()=>n(`errors`),children:`Errors only`})]})}),(0,l.jsx)(s.Col,{children:(0,l.jsxs)(lN,{type:`secondary`,children:[e.length,` row(s)`]})})]}),(0,l.jsx)(`div`,{className:`bulk-table-wrap`,children:(0,l.jsxs)(`table`,{className:`bulk-preview-table`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:`bulk-col-row`,children:`Row`}),(0,l.jsx)(`th`,{className:`bulk-col-flow`,children:`Submodule`}),(0,l.jsx)(`th`,{className:`bulk-col-description`,children:`Description`}),(0,l.jsx)(`th`,{className:`bulk-col-keyword`,children:`Action`}),(0,l.jsx)(`th`,{className:`bulk-col-target`,children:`Key`}),(0,l.jsx)(`th`,{className:`bulk-col-status`,children:`Status`}),(0,l.jsx)(`th`,{className:`bulk-col-error`,children:`Error`})]})}),(0,l.jsx)(`tbody`,{children:f.map(e=>{let t=e.errors??[],n=e.row_status===`invalid`;return(0,l.jsxs)(`tr`,{ref:n&&e.id===o?u:null,className:n?`bulk-row-invalid`:``,children:[(0,l.jsx)(`td`,{children:e.id}),(0,l.jsx)(`td`,{title:e.submodule,children:e.submodule}),(0,l.jsx)(`td`,{title:e.description,children:e.description?e.description:(0,l.jsx)(`span`,{className:`bulk-empty-text`,children:`-empty-`})}),(0,l.jsx)(`td`,{children:(0,l.jsx)(`code`,{className:`bulk-code-chip`,children:e.actions})}),(0,l.jsx)(`td`,{title:e.key,children:e.key}),(0,l.jsx)(`td`,{children:n?(0,l.jsx)(s.Tag,{color:`red`,children:`Error`}):(0,l.jsx)(s.Tag,{color:`green`,children:`Valid`})}),(0,l.jsx)(`td`,{children:n?(0,l.jsx)(s.Tooltip,{title:(0,l.jsx)(bN,{errors:t}),placement:`left`,children:(0,l.jsxs)(`button`,{type:`button`,className:`bulk-error-info`,"aria-label":`View ${t.length} error(s) for row ${e.id}`,children:[(0,l.jsx)(c.InfoCircleOutlined,{}),(0,l.jsx)(s.Badge,{count:t.length,size:`small`})]})}):(0,l.jsx)(`span`,{className:`bulk-error-none`,children:`-`})})]},`${e.id}-${e.step_order}`)})})]})}),(0,l.jsxs)(s.Space,{className:`bulk-actions`,children:[(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:i,children:`Reset`}),(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.SaveOutlined,{}),loading:a,disabled:p,onClick:r,children:d.length>0?`Fix ${d.length} error(s) to proceed`:`Save to database`})]})]})}function CN(){let e=(0,d.useNavigate)(),r=(0,o.useMemo)(()=>t.l(),[]),i=(0,o.useRef)(null),a=(0,o.useRef)(null),[u,f]=(0,o.useState)([]),[p,m]=(0,o.useState)(``),[h,g]=(0,o.useState)(`idle`),[_,v]=(0,o.useState)(!1),[y,b]=(0,o.useState)(null),[x,S]=(0,o.useState)([]),[C,w]=(0,o.useState)(`all`),[T,E]=(0,o.useState)(null),[D,O]=(0,o.useState)(null),[k,A]=(0,o.useState)(!1),j=u.map(e=>({value:e.modulename,label:e.modulename})),M=yN(x),N=h===`encoding`||h===`validating`,P=!!p&&!N,F=hN[h]??0,I=x.find(e=>e.row_status===`invalid`)?.id,L=(0,o.useCallback)(()=>{m(``),g(`idle`),v(!1),b(null),S([]),w(`all`),E(null),O(null),i.current&&(i.current.value=``)},[]);(0,o.useEffect)(()=>{async function e(){try{let e=await Db({project:r?.name??``,activeOnly:!0});f(e?.items??[])}catch(e){console.error(e),s.message.error(`Unable to load modules.`)}}e()},[r?.name]);let R=e=>{m(e??``),S([]),O(null),E(null),b(null),A(!1),g(e?`module_set`:`idle`)},z=async e=>{if(!e||!P)return;let t=e.name.split(`.`).pop()?.toLowerCase();if(![`xlsx`,`csv`].includes(t)){g(`module_set`),E({message:`Invalid file type. Please upload an Excel .xlsx or CSV .csv file.`});return}if(e.size>dN){g(`module_set`),E({message:`File must be 10 MB or smaller.`});return}E(null),S([]),O(null),b({name:e.name,size:e.size}),g(`encoding`);try{let n=await _N(e);g(`validating`);let i=await Sb({filename:e.name,project:r?.name??``,module:p,file_base64:n,file_type:t});S(i?.rows??[]),w(`all`),g(`preview`)}catch(e){console.error(e),E(e.payload??{code:`NETWORK_ERROR`,message:e.message||`Could not reach the server.`}),g(`error`)}},B=async()=>{try{let e=await fetch(fN);if(!e.ok)throw Error(`Template file not found (${e.status})`);let t=(await e.text()).trim(),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);let i=new Blob([r],{type:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=pN,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(a),s.message.success(`Sample template downloaded.`)}catch(e){console.error(e),s.message.error(`Unable to download sample template.`)}},V=async()=>{g(`inserting`),E(null);try{let t=await Cb({project:r?.name??``,module:p,uploaded_by:localStorage.getItem(`user_Email`)??``,rows:vN(x)});O(t),g(`done`),s.message.success(`Bulk upload saved. Redirecting to view test cases...`),window.setTimeout(()=>e(`/viewTestCase`),900)}catch(e){console.error(e),E(e.payload??{code:`NETWORK_ERROR`,message:e.message||`Could not reach the server.`}),g(`preview`)}},ee=(0,o.useCallback)(()=>{a.current?.scrollIntoView({behavior:`smooth`,block:`center`})},[]),te=[`bulk-dropzone`,_?`bulk-dropzone-dragging`:``,y?`bulk-dropzone-has-file`:``,T&&h!==`preview`?`bulk-dropzone-error`:``,p?``:`bulk-dropzone-disabled`].filter(Boolean).join(` `);return(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:gN})}),r?.name&&(0,l.jsx)(s.Col,{children:(0,l.jsx)(lN,{strong:!0,children:r.name})})]}),(0,l.jsxs)(`div`,{className:`zt-page zt-page-wide bulk-page`,children:[(0,l.jsxs)(`div`,{className:`bulk-header`,children:[(0,l.jsx)(uN,{level:3,children:`Bulk upload test cases`}),(0,l.jsxs)(s.Space,{direction:`vertical`,size:4,children:[(0,l.jsx)(lN,{type:`secondary`,children:mN}),(0,l.jsx)(lN,{type:`secondary`,children:`Use the sample template for the required columns. Uploaded rows are saved as Active by default.`})]})]}),(0,l.jsx)(`div`,{className:`bulk-stepbar`,children:[`Select`,`Upload`,`Validate`,`Save`].map((e,t)=>(0,l.jsxs)(`span`,{className:t<F?`bulk-step-active`:``,children:[t+1,` `,e]},e))}),(0,l.jsx)(s.Card,{className:`v1-card zt-fall`,title:`1. Module selector`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,className:`bulk-module-select`,placeholder:`Choose a module`,options:j,value:p||void 0,onChange:R})}),p&&(0,l.jsxs)(s.Card,{className:`v1-card zt-fall`,title:`2. File upload`,extra:(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.DownloadOutlined,{}),onClick:B,children:`Download Sample Template`}),children:[(0,l.jsx)(s.Alert,{type:`info`,showIcon:!0,message:`First time uploading?`,description:`Download the sample template, keep the column names unchanged, fill your test steps, and upload either .xlsx or .csv.`,className:`bulk-inline-alert`}),(0,l.jsxs)(`button`,{type:`button`,className:te,disabled:!P,onClick:()=>i.current?.click(),onDragOver:e=>{e.preventDefault(),P&&v(!0)},onDragLeave:()=>v(!1),onDrop:e=>{e.preventDefault(),v(!1),z(e.dataTransfer.files?.[0])},children:[(0,l.jsx)(c.CloudUploadOutlined,{className:`bulk-upload-icon`}),y?(0,l.jsxs)(`span`,{className:`bulk-file-chip`,children:[y.name,` - `,Math.ceil(y.size/1024),` KB`]}):(0,l.jsx)(`span`,{children:`Drag & drop here, or click to browse`})]}),(0,l.jsx)(`input`,{ref:i,hidden:!0,type:`file`,accept:`.xlsx,.csv`,onChange:e=>z(e.target.files?.[0])}),N&&(0,l.jsx)(s.Progress,{percent:h===`encoding`?45:82,showInfo:!1,size:`small`}),T&&h!==`preview`&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`})]}),x.length>0&&(0,l.jsxs)(s.Card,{className:`v1-card zt-fall`,title:`3. Validation result`,children:[(0,l.jsx)(xN,{errors:M,expanded:k,onToggle:()=>A(e=>!e),onSummaryClick:ee}),T&&h===`preview`&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`}),(0,l.jsx)(SN,{rows:x,view:C,onViewChange:w,onConfirm:V,onReset:L,saving:h===`inserting`,firstInvalidRowId:I,firstInvalidRowRef:a})]}),D&&h===`done`&&(0,l.jsxs)(s.Card,{className:`v1-card zt-fall`,title:`4. Upload complete`,children:[(0,l.jsxs)(s.Row,{gutter:[16,16],className:`bulk-metrics`,children:[(0,l.jsx)(s.Col,{xs:24,md:8,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(lN,{children:`Total`}),(0,l.jsx)(`strong`,{children:x.length})]})}),(0,l.jsx)(s.Col,{xs:24,md:8,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(lN,{children:`Inserted`}),(0,l.jsx)(`strong`,{children:D.inserted??0})]})}),(0,l.jsx)(s.Col,{xs:24,md:8,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(lN,{children:`Failed`}),(0,l.jsx)(`strong`,{children:D.failed??0})]})})]}),(0,l.jsx)(s.Alert,{type:`success`,showIcon:!0,icon:(0,l.jsx)(c.CheckCircleOutlined,{}),message:`${D.inserted??0} test cases saved to database - module: ${p}`,className:`bulk-inline-alert`}),(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:L,children:`Upload another file`})]})]})]})}var wN=[{value:`navigate`,label:`Navigate`},{value:`fill`,label:`Fill`},{value:`click`,label:`Click`},{value:`select`,label:`Select`},{value:`press_key`,label:`Press Key`},{value:`type_and_select`,label:`Type and Select`},{value:`type_and_select_modal`,label:`Type and Select (Modal)`},{value:`upload_file`,label:`Upload File`},{value:`check_checkbox`,label:`Check Checkbox`},{value:`check_filter_checkbox`,label:`Check Filter Checkbox`},{value:`select_page_size`,label:`Select Page Size`},{value:`check_n_checkboxes`,label:`Check N Checkboxes`},{value:`store_text`,label:`Store Text`},{value:`reset_session`,label:`Reset Session`},{value:`switch_to_new_tab`,label:`Switch To New Tab`},{value:`close_tab`,label:`Close Tab`},{value:`assert_visible`,label:`Assert Visible`},{value:`assert_hidden`,label:`Assert Hidden`},{value:`assert_text`,label:`Assert Text`},{value:`assert_url`,label:`Assert URL`},{value:`assert_body_contains`,label:`Assert Body Contains`},{value:`assert_button_disabled`,label:`Assert Button Disabled`},{value:`assert_field_error`,label:`Assert Field Error`},{value:`assert_field_accepted`,label:`Assert Field Accepted`},{value:`assert_children_disabled`,label:`Assert Children Disabled`},{value:`assert_children_visible`,label:`Assert Children Visible`},{value:`assert_element_count`,label:`Assert Element Count`},{value:`assert_toast`,label:`Assert Toast`},{value:`assert_toast_success`,label:`Assert Toast Success`},{value:`assert_toast_error`,label:`Assert Toast Error`},{value:`wait_for_visible`,label:`Wait For Visible`},{value:`wait_for_hidden`,label:`Wait For Hidden`},{value:`wait_for_text`,label:`Wait For Text`}],{Text:TN}=s.Typography,EN=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}],DN={tags:`regression`,active:1},ON={module:{dbName:`Modules`,formField:`module`,label:`Module`}};function kN(e=[]){return e.map(e=>({value:e,label:e}))}function AN(e=``){return String(e??``).trim()}function jN(e=``){return AN(e).toLowerCase()}function MN(e=[]){let t=new Map;return e.forEach(e=>{let n=AN(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function NN(e=[],t,n){let r=AN(t).toLowerCase(),i=AN(n).toLowerCase();return e.reduce((e,t)=>{let n=AN(t?.module).toLowerCase(),a=AN(t?.flow).toLowerCase();if(n!==r||a!==i)return e;let o=Number(t?.step_order)||0;return Math.max(e,o)},0)+1}function PN({icon:e,title:t}){return(0,l.jsxs)(s.Space,{size:10,align:`center`,children:[(0,l.jsx)(`div`,{className:`v1-section-icon-box`,children:e}),(0,l.jsx)(TN,{strong:!0,className:`v1-section-label`,children:t})]})}function FN(){let[e]=s.Form.useForm(),[t]=s.Form.useForm(),[r,i]=(0,o.useState)([]),[a,u]=(0,o.useState)([]),[f,p]=(0,o.useState)([]),[m,h]=(0,o.useState)(!1),[g,_]=(0,o.useState)(!1),[v,y]=(0,o.useState)({open:!1,typeKey:`module`}),[b,x]=(0,o.useState)(!1),[S,C]=(0,o.useState)(!1),[w,T]=(0,o.useState)(!1),E=(0,d.useNavigate)(),D=ON[v.typeKey],O=(0,o.useMemo)(()=>kN(r),[r]),k=s.Form.useWatch(`module`,e),A=s.Form.useWatch(`flow`,e),j=!!AN(k),M=!!AN(A),N=!j,P=!j||!M,F=(e,t=[])=>{e===`module`&&i(t)},I=async()=>{h(!0);try{let e=await _b(ON.module.dbName);i(e?.items??[])}catch(e){console.error(`Unable to load testing options:`,e),s.message.error(`Unable to load testing options.`)}finally{h(!1)}},L=(0,o.useCallback)(async t=>{let n=AN(t);if(u([]),p([]),e.setFieldsValue({step_order:void 0}),n){_(!0);try{let e=await xb({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];u(t),p(MN(t))}catch(e){console.error(`Unable to load flows:`,e),s.message.error(`Unable to load flows.`)}finally{_(!1)}}},[e]),R=(0,o.useCallback)(async(t,n,r)=>{let i=AN(t),a=AN(n);if(!i||!a){e.setFieldsValue({step_order:void 0});return}C(!0);try{e.setFieldsValue({step_order:NN(r,i,a)})}catch(e){console.error(`Unable to load step order:`,e),s.message.error(`Unable to load step order.`)}finally{C(!1)}},[e]);(0,o.useEffect)(()=>{Promise.resolve().then(I)},[]),(0,o.useEffect)(()=>{Promise.resolve().then(()=>L(k))},[L,k]),(0,o.useEffect)(()=>{Promise.resolve().then(()=>R(k,A,a))},[a,R,A,k]);let z=async t=>{let n={module:AN(t.module),flow:AN(t.flow),step_order:Number(t.step_order),description:AN(t.description),keyword:jN(t.keyword),target:AN(t.target),value:AN(t.value),expected:AN(t.expected),tags:t.tags?AN(t.tags):DN.tags,active:Number(t.active)};T(!0);try{await bb(n),s.message.success(`Test case details saved successfully.`),e.resetFields(),u([]),p([])}catch(e){console.error(`Unable to save test case:`,e),s.message.error(`Unable to save test case.`)}finally{T(!1)}},B=(t,n)=>{e.setFieldsValue({[t]:AN(n)})},V=t=>{e.setFieldsValue({module:AN(t),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:DN.tags,value:void 0,expected:void 0})},ee=t=>{e.setFieldsValue({flow:AN(t),step_order:void 0})},te=e=>{let n=ON[e];y({open:!0,typeKey:e}),t.setFieldsValue({name:``,type:n.label})},ne=()=>{y(e=>({...e,open:!1})),t.resetFields()},re=async()=>{try{let n=AN((await t.validateFields()).name),r=await vb({name:n,type:D.dbName});F(v.typeKey,r?.items??[]),e.setFieldsValue({[D.formField]:n}),s.message.success(`${D.label} added successfully.`),ne()}catch(e){if(e?.errorFields)return;console.error(`Unable to save testing option:`,e),s.message.error(`Unable to add ${D.label.toLowerCase()}.`)}finally{x(!1)}};return(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:EN})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`link`,onClick:()=>E(`/zinnext-home`),children:`View Table`})})]}),(0,l.jsx)(`div`,{className:`v1-page`,children:(0,l.jsxs)(`div`,{className:`v1-page-inner`,children:[(0,l.jsx)(`div`,{className:`v1-page-header`,children:(0,l.jsxs)(s.Space,{align:`center`,size:10,children:[(0,l.jsx)(c.ProfileOutlined,{className:`v1-outer-icon`}),(0,l.jsx)(`div`,{children:(0,l.jsx)(TN,{strong:!0,style:{fontSize:16},children:`Add Test Case`})})]})}),(0,l.jsx)(Z,{children:(0,l.jsxs)(s.Form,{form:e,className:`v1-form`,layout:`vertical`,colon:!1,requiredMark:(e,{required:t})=>(0,l.jsxs)(l.Fragment,{children:[e,t&&(0,l.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),initialValues:DN,onFinish:z,autoComplete:`off`,children:[(0,l.jsx)(s.Card,{className:`v1-card`,title:(0,l.jsx)(PN,{icon:(0,l.jsx)(c.FileTextOutlined,{}),title:`Test Case Details`}),extra:(0,l.jsx)(TN,{type:`secondary`,className:`v1-card-subtitle`,children:`Module, flow, step order and execution data`}),children:(0,l.jsxs)(s.Row,{gutter:[24,0],children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsxs)(s.Space.Compact,{style:{width:`100%`},children:[(0,l.jsx)(s.Form.Item,{label:`Module`,name:`module`,style:{flex:1},children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,loading:m,optionFilterProp:`label`,placeholder:`Select module`,options:O,onChange:V})}),(0,l.jsx)(s.Button,{"aria-label":`Add module`,icon:(0,l.jsx)(c.PlusOutlined,{}),style:{marginTop:30},onClick:()=>te(`module`)})]})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Flow`,name:`flow`,children:(0,l.jsx)(s.AutoComplete,{maxLength:100,allowClear:!0,disabled:N,options:f,placeholder:g?`Loading flows`:`Enter flow`,onChange:ee,filterOption:(e,t)=>t?.value?.toLowerCase().includes(e.toLowerCase())})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Step Order`,name:`step_order`,validateTrigger:[`onBlur`,`onChange`],children:(0,l.jsx)(s.Input,{maxLength:10,disabled:!0,placeholder:S?`Loading step order`:`Step order`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Action`,name:`keyword`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,disabled:P,optionFilterProp:`label`,placeholder:`Select action`,options:wN,onChange:t=>e.setFieldsValue({keyword:jN(t)})})})}),(0,l.jsx)(s.Col,{xs:24,children:(0,l.jsx)(s.Form.Item,{label:`Description`,name:`description`,children:(0,l.jsx)(s.Input.TextArea,{rows:3,maxLength:255,disabled:P,placeholder:`Enter description`,showCount:!0,onBlur:e=>B(`description`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Key`,name:`target`,children:(0,l.jsx)(s.Input,{maxLength:255,disabled:P,placeholder:`Enter target`,onBlur:e=>B(`target`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Tags`,name:`tags`,children:(0,l.jsx)(s.Input,{maxLength:200,disabled:P,placeholder:`Enter tags`,prefix:(0,l.jsx)(c.TagsOutlined,{className:`v1-input-icon`}),onBlur:e=>B(`tags`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Value`,name:`value`,children:(0,l.jsx)(s.Input.TextArea,{rows:4,disabled:P,placeholder:`Enter value`,onBlur:e=>B(`value`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Expected`,name:`expected`,children:(0,l.jsx)(s.Input.TextArea,{rows:4,disabled:P,placeholder:`Enter expected result`,onBlur:e=>B(`expected`,e.target.value)})})})]})}),(0,l.jsx)(`div`,{className:`v1-form-actions`,children:(0,l.jsx)(s.Form.Item,{children:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{type:`primary`,htmlType:`submit`,loading:w,disabled:P,children:`Submit`}),(0,l.jsx)(s.Button,{onClick:()=>{e.resetFields(),u([]),p([])},children:`Reset`})]})})})]})}),(0,l.jsx)(s.Modal,{title:`Add ${D.label}`,open:v.open,confirmLoading:b,okText:`Add`,onCancel:ne,onOk:()=>{x(!0),re()},destroyOnHidden:!0,children:(0,l.jsxs)(s.Form,{form:t,layout:`vertical`,colon:!1,className:`v1-form`,requiredMark:(e,{required:t})=>(0,l.jsxs)(l.Fragment,{children:[e,t&&(0,l.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),children:[(0,l.jsx)(s.Form.Item,{label:`Name`,name:`name`,children:(0,l.jsx)(s.Input,{maxLength:100,placeholder:`Enter ${D.label.toLowerCase()} name`,onBlur:e=>{t.setFieldsValue({name:AN(e.target.value)})}})}),(0,l.jsx)(s.Form.Item,{label:`Type`,name:`type`,children:(0,l.jsx)(s.Input,{disabled:!0})})]})})]})})]})}var{Text:IN}=s.Typography,LN=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`}];function RN(e=``){return String(e??``).trim()}function zN(e=[],t){return e.map(e=>({value:e.id,label:e[t]}))}var BN=[{label:`Step`,value:`step_order`,width:70},{label:`Action`,value:`actions`,width:140},{label:`Key`,value:`key`,width:160,ellipsis:!0},{label:`Value`,value:`value`,ellipsis:!0},{label:`Description`,value:`description`,ellipsis:!0},{label:`Scenario`,value:`scenario`,width:110,render:e=>e===1?(0,l.jsx)(s.Tag,{color:`green`,children:`Positive`}):(0,l.jsx)(s.Tag,{color:`red`,children:`Negative`})}],VN={key:!1,value:!1,expected:!1};function HN(e,t){return t?e[t]??VN:VN}function UN(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function WN(){let[e]=s.Form.useForm(),r=(0,d.useNavigate)(),[i]=(0,d.useSearchParams)(),a=i.get(`edit`),u=!!a,f=(0,o.useMemo)(()=>t.l(),[]),[p,m]=(0,o.useState)([]),[h,g]=(0,o.useState)([]),[_,v]=(0,o.useState)([]),[y,b]=(0,o.useState)(wN),[x,S]=(0,o.useState)({}),[C,w]=(0,o.useState)(!1),[T,E]=(0,o.useState)(!1),[D,O]=(0,o.useState)(!1),[k,A]=(0,o.useState)(!1),[j,M]=(0,o.useState)(!1),N=s.Form.useWatch(`module`,e),P=s.Form.useWatch(`submodule`,e),F=s.Form.useWatch(`actions`,e),I=!!N,L=!!P,R=(0,o.useMemo)(()=>HN(x,F),[x,F]),z=(0,o.useMemo)(()=>zN(p,`modulename`),[p]),B=(0,o.useMemo)(()=>zN(h,`submodulename`),[h]),V=(0,o.useMemo)(()=>p.find(e=>e.id===N)?.modulename??``,[p,N]),ee=(0,o.useMemo)(()=>h.find(e=>e.id===P)?.submodulename??``,[P,h]),te=(0,o.useCallback)(async()=>{try{let e=await yb();Array.isArray(e?.options)&&e.options.length>0&&b(e.options),e?.rules&&typeof e.rules==`object`&&S(e.rules)}catch(e){console.error(`Unable to load action field rules:`,e),s.message.error(`Unable to load action validation rules.`)}},[]),ne=(0,o.useCallback)(async e=>{if(!e){m([]);return}w(!0);try{let t=await Db({project:e,activeOnly:!0});m(t?.items??[])}catch(e){console.error(`Unable to load modules:`,e),s.message.error(`Unable to load modules.`)}finally{w(!1)}},[]),re=(0,o.useCallback)(async(e,t)=>{if(!e||!t){g([]);return}E(!0);try{let n=await Ab({project:e,module:t,activeOnly:!0});g(n?.items??[])}catch(e){console.error(`Unable to load submodules:`,e),s.message.error(`Unable to load submodules.`)}finally{E(!1)}},[]),ie=(0,o.useCallback)(async(t,n,r,i=``)=>{if(!t||!n||!r){v([]),e.setFieldsValue({step_order:void 0});return}O(!0);try{let[a,o]=await Promise.all([Nb({product_parent_ID:t,module_parent_ID:n,submodule_parent_ID:r,actions:i,limit:1e3}),Ib({product_parent_ID:t,module_parent_ID:n,submodule_parent_ID:r})]);v(a?.items??[]),e.setFieldsValue({step_order:o?.step_order??1})}catch(e){console.error(`Unable to load flows:`,e),s.message.error(`Unable to load flows.`)}finally{O(!1)}},[e]),ae=(0,o.useCallback)(async(e=``)=>{if(!(!f?.id||!N||!P)){O(!0);try{let t=await Nb({product_parent_ID:f.id,module_parent_ID:N,submodule_parent_ID:P,actions:e,limit:1e3});v(t?.items??[])}catch(e){console.error(`Unable to load action flows:`,e),s.message.error(`Unable to load action steps.`)}finally{O(!1)}}},[f?.id,N,P]),oe=(0,o.useCallback)(async()=>{if(!(!a||!f?.name)){M(!0);try{let t=await Fb(a);await re(f.name,t.module);let n=await Nb({product_parent_ID:t.product_parent_ID,module_parent_ID:t.module_parent_ID,submodule_parent_ID:t.submodule_parent_ID,limit:1e3});v(n?.items??[]),e.setFieldsValue({module:t.module_parent_ID,submodule:t.submodule_parent_ID,step_order:t.step_order,actions:t.actions,key:t.key,value:t.value,expected:t.expected,description:t.description,scenario:t.scenario===1,active:Number(t.active)!==0})}catch(e){console.error(`Unable to load test flow:`,e),s.message.error(`Unable to load test flow for edit.`),r(`/viewTestCase`)}finally{M(!1)}}},[a,e,re,r,f?.name]);return(0,o.useEffect)(()=>{if(!f){r(`/select-project`,{replace:!0});return}Promise.resolve().then(async()=>{await te(),await ne(f.name),a&&await oe()})},[f,r,te,ne,a,oe]),f?(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:LN})}),(0,l.jsx)(s.Col,{children:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.ProjectOutlined,{}),(0,l.jsx)(IN,{strong:!0,children:f.name})]})})]}),(0,l.jsx)(`div`,{className:`zt-page`,children:(0,l.jsxs)(s.Form,{form:e,layout:`vertical`,colon:!1,className:`v1-form`,initialValues:{scenario:!0,active:!0},onFinish:async t=>{let n={product_parent_ID:Number(f?.id),module_parent_ID:Number(t.module),submodule_parent_ID:Number(t.submodule),description:RN(t.description),actions:RN(t.actions),key:RN(t.key),value:RN(t.value),expected:RN(t.expected),scenario:+!!t.scenario,active:+!!t.active};A(!0);try{if(u){await Lb(a,{...n,step_order:Number(t.step_order)}),s.message.success(`Test case updated successfully.`),r(`/viewTestCase`);return}await Pb(n),s.message.success(`Step saved (#${t.step_order}).`),e.setFieldsValue({actions:void 0,key:void 0,value:void 0,expected:void 0,description:void 0}),await ie(n.product_parent_ID,n.module_parent_ID,n.submodule_parent_ID)}catch(e){console.error(`Unable to save test case:`,e),s.message.error(u?`Unable to update test case.`:`Unable to save step.`)}finally{A(!1)}},autoComplete:`off`,disabled:j,children:[(0,l.jsx)(s.Card,{className:`v1-card zt-fall`,title:(0,l.jsxs)(s.Space,{size:8,className:`zt-section-title`,children:[(0,l.jsx)(`span`,{className:`zt-step-tag`,children:`1`}),(0,l.jsx)(`span`,{children:`Module & Submodule`})]}),children:(0,l.jsxs)(s.Row,{gutter:[24,0],align:`bottom`,children:[(0,l.jsx)(s.Col,{xs:24,md:6,children:(0,l.jsx)(s.Form.Item,{label:`Module`,name:`module`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,loading:C,placeholder:`Select module`,options:z,onChange:t=>{let n=p.find(e=>e.id===t)?.modulename??``;e.setFieldsValue({module:t,submodule:void 0,step_order:void 0,actions:void 0,key:void 0,value:void 0,expected:void 0}),UN(e,[`actions`,`key`,`value`,`expected`]),g([]),v([]),re(f?.name,n)}})})}),(0,l.jsx)(s.Col,{xs:24,md:6,children:(0,l.jsx)(s.Form.Item,{label:`Submodule`,name:`submodule`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,disabled:!I,loading:T,placeholder:I?`Select submodule`:`Select module first`,options:B,onChange:t=>{e.setFieldsValue({submodule:t,actions:void 0,key:void 0,value:void 0,expected:void 0}),UN(e,[`actions`,`key`,`value`,`expected`]),ie(f?.id,N,t)}})})}),(0,l.jsx)(s.Col,{xs:24,md:6,children:(0,l.jsx)(s.Form.Item,{label:`Scenario`,name:`scenario`,valuePropName:`checked`,children:(0,l.jsx)(s.Switch,{disabled:!L,checkedChildren:`Positive`,unCheckedChildren:`Negative`})})}),(0,l.jsx)(s.Col,{xs:24,md:6,children:(0,l.jsx)(s.Form.Item,{label:`Active`,name:`active`,valuePropName:`checked`,children:(0,l.jsx)(s.Switch,{checkedChildren:`Active`,unCheckedChildren:`Inactive`})})})]})}),L&&(0,l.jsxs)(s.Card,{className:`v1-card zt-fall`,title:(0,l.jsxs)(s.Space,{size:8,className:`zt-section-title`,children:[(0,l.jsx)(`span`,{className:`zt-step-tag`,children:`2`}),(0,l.jsx)(c.FileTextOutlined,{}),(0,l.jsx)(`span`,{children:`Step Details`})]}),extra:(0,l.jsxs)(IN,{type:`secondary`,children:[V,` / `,ee]}),children:[(0,l.jsxs)(s.Row,{gutter:[24,0],children:[(0,l.jsx)(s.Col,{xs:24,md:6,children:(0,l.jsx)(s.Form.Item,{label:`Step Order`,name:`step_order`,children:(0,l.jsx)(s.Input,{disabled:!0,placeholder:D?`Loading…`:`Auto`})})}),(0,l.jsx)(s.Col,{xs:24,md:18,children:(0,l.jsx)(s.Form.Item,{label:`Action`,name:`actions`,rules:[{required:!0,message:`Mandatory Field`}],children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,placeholder:`Select action`,options:y,onChange:t=>{let n=HN(x,t);e.setFieldsValue({actions:t,key:n.key?e.getFieldValue(`key`):void 0,value:n.value?e.getFieldValue(`value`):void 0,expected:n.expected?e.getFieldValue(`expected`):void 0}),UN(e,[`key`,`value`,`expected`]),ae(t||``)}})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Key`,name:`key`,rules:[{required:R.key,message:`Key is required for this action`}],children:(0,l.jsx)(s.Input,{maxLength:255,disabled:F&&!R.key,placeholder:F?R.key?`Required — Enter selector / locator`:`Not needed for this action`:`Select an action first`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Value`,name:`value`,rules:[{required:R.value,message:`Value is required for this action`}],children:(0,l.jsx)(s.Input.TextArea,{rows:1,autoSize:{minRows:1,maxRows:4},disabled:F&&!R.value,placeholder:F?R.value?`Required — Enter value`:`Not needed for this action`:`Select an action first`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Expected`,name:`expected`,rules:[{required:R.expected,message:`Expected result is required for this action`}],children:(0,l.jsx)(s.Input.TextArea,{rows:2,disabled:F&&!R.expected,placeholder:F?R.expected?`Required — Enter expected result`:`Not needed for this action`:`Select an action first`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Description`,name:`description`,children:(0,l.jsx)(s.Input.TextArea,{rows:2,maxLength:255,showCount:!0,placeholder:`Enter description`})})})]}),(0,l.jsxs)(s.Space,{className:`zt-actions`,children:[(0,l.jsx)(s.Button,{onClick:()=>{if(u){r(`/viewTestCase`);return}e.resetFields(),g([]),v([]),E(!1),O(!1)},children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,htmlType:`submit`,loading:k||j,children:u?`Update Test Case`:`Save & Continue`})]})]},`${N}-${P}`),L&&(0,l.jsx)(s.Card,{className:`v1-card zt-fall`,title:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.TableOutlined,{}),(0,l.jsx)(`span`,{children:`Added Steps`})]}),extra:(0,l.jsx)(s.Tag,{children:F?`${_.length} ${F} step(s)`:`${_.length} step(s)`}),children:(0,l.jsx)(km,{listName:`Added Steps`,loading:D,fields:BN,dataSource:_,current:1,pageSize:Math.max(_.length,1),total:_.length,rowSelection:!1,className:`zt-list-plain zt-list-static`})})]})})]}):null}var{Text:GN}=s.Typography,KN=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`}];function qN(){let e=(0,d.useNavigate)(),r=(0,o.useMemo)(()=>t.l(),[]),[i,a]=(0,o.useState)([]),[u,f]=(0,o.useState)({}),[p,m]=(0,o.useState)(!1),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)(``),[y,b]=(0,o.useState)(!1),[x,S]=(0,o.useState)(1),[C,w]=(0,o.useState)(10),T=(0,o.useCallback)(async e=>{if(!e){a([]);return}m(!0);try{let[t,n]=await Promise.all([Db({project:e}),Ab({project:e})]);a(t?.items??[]);let r={};(n?.items??[]).forEach(e=>{let t=e.modulename;r[t]=(r[t]??0)+1}),f(r)}catch(e){console.error(e),s.message.error(`Unable to load modules.`)}finally{m(!1)}},[]);(0,o.useEffect)(()=>{if(!r){e(`/select-project`,{replace:!0});return}Promise.resolve().then(()=>T(r.name))},[r,e,T]);let E=async(e,t)=>{try{await kb(e.id,+!!t),a(n=>n.map(n=>n.id===e.id?{...n,active:+!!t}:n)),s.message.success(`Module ${t?`activated`:`deactivated`}.`)}catch(e){console.error(e),s.message.error(`Unable to update module status.`)}},D=async()=>{let e=_.trim();if(!e){s.message.warning(`Enter a module name.`);return}b(!0);try{await Ob({project:r.name,modulename:e}),s.message.success(`Module added.`),g(!1),v(``),S(1),T(r.name)}catch(e){console.error(e),s.message.error(`Unable to add module (maybe it already exists).`)}finally{b(!1)}},O=t=>{e(`/test-cases/zinnext/submodules?module=${encodeURIComponent(t.modulename)}`)};return r?(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:KN})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`link`,onClick:()=>e(`/addTestCase`),children:`Back to Form`})})]}),(0,l.jsxs)(`div`,{className:`zt-page`,children:[(0,l.jsx)(s.Card,{className:`v1-card zt-bar`,children:(0,l.jsxs)(s.Row,{gutter:[16,16],align:`middle`,justify:`space-between`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.ProjectOutlined,{}),(0,l.jsx)(`span`,{children:`Project:`}),(0,l.jsx)(GN,{strong:!0,children:r.name})]})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>g(!0),children:`Add Module`})})]})}),(0,l.jsx)(s.Card,{className:`v1-card zt-fall`,title:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.AppstoreOutlined,{}),(0,l.jsx)(`span`,{children:`Modules`})]}),children:(0,l.jsx)(km,{listName:`Modules`,loading:p,fields:[{label:`Module`,value:`modulename`},{label:`Submodules`,value:`submoduleCount`,width:140,render:(e,t)=>(0,l.jsxs)(s.Button,{type:`link`,className:`zt-count-link`,onClick:()=>O(t),children:[u[t.modulename]??0,` submodule(s)`]})},{label:`Active`,value:`active`,width:120,render:(e,t)=>(0,l.jsx)(s.Switch,{checked:e===1,checkedChildren:`On`,unCheckedChildren:`Off`,onChange:e=>E(t,e)})}],dataSource:i,current:x,pageSize:C,total:i.length,onPageChange:S,onPageSizeChange:e=>{S(1),w(e)},rowSelection:!1,className:`zt-list-plain`})})]}),(0,l.jsx)(s.Modal,{title:`Add Module`,open:h,confirmLoading:y,okText:`Add`,onOk:D,onCancel:()=>{g(!1),v(``)},destroyOnHidden:!0,children:(0,l.jsxs)(s.Space,{direction:`vertical`,className:`zt-modal-stack`,children:[(0,l.jsxs)(GN,{type:`secondary`,children:[`Project: `,(0,l.jsx)(`b`,{children:r.name})]}),(0,l.jsx)(s.Input,{placeholder:`Enter module name`,maxLength:100,value:_,onChange:e=>v(e.target.value),onPressEnter:D})]})})]}):null}var{Text:JN}=s.Typography,YN=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`},{label:`Manage Submodules`,href:`/test-cases/zinnext/submodules`}];function XN(){let e=(0,d.useNavigate)(),[r]=(0,d.useSearchParams)(),i=(0,o.useMemo)(()=>t.l(),[]),a=r.get(`module`)??``,[u,f]=(0,o.useState)([]),[p,m]=(0,o.useState)(!1),[h,g]=(0,o.useState)(!1),[_,v]=(0,o.useState)(``),[y,b]=(0,o.useState)(!1),[x,S]=(0,o.useState)(1),[C,w]=(0,o.useState)(10),T=(0,o.useCallback)(async(e,t)=>{if(!e||!t){f([]);return}m(!0);try{let n=await Ab({project:e,module:t});f(n?.items??[])}catch(e){console.error(e),s.message.error(`Unable to load submodules.`)}finally{m(!1)}},[]);(0,o.useEffect)(()=>{if(!i){e(`/select-project`,{replace:!0});return}if(!a){e(`/manageModules`,{replace:!0});return}Promise.resolve().then(()=>T(i.name,a))},[i,a,e,T]);let E=async(e,t)=>{try{await Mb(e.id,+!!t),f(n=>n.map(n=>n.id===e.id?{...n,active:+!!t}:n)),s.message.success(`Submodule ${t?`activated`:`deactivated`}.`)}catch(e){console.error(e),s.message.error(`Unable to update submodule status.`)}},D=async()=>{let e=_.trim();if(!e){s.message.warning(`Enter a submodule name.`);return}b(!0);try{await jb({project:i.name,modulename:a,submodulename:e}),s.message.success(`Submodule added.`),g(!1),v(``),S(1),T(i.name,a)}catch(e){console.error(e),s.message.error(`Unable to add submodule (maybe it already exists).`)}finally{b(!1)}};return!i||!a?null:(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:YN})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`link`,onClick:()=>e(`/manageModules`),children:`Back to Modules`})})]}),(0,l.jsxs)(`div`,{className:`zt-page`,children:[(0,l.jsx)(s.Card,{className:`v1-card zt-bar`,children:(0,l.jsxs)(s.Row,{gutter:[16,16],align:`middle`,justify:`space-between`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsxs)(s.Space,{size:16,wrap:!0,className:`zt-section-title`,children:[(0,l.jsxs)(s.Space,{size:6,children:[(0,l.jsx)(c.ProjectOutlined,{}),(0,l.jsx)(`span`,{children:`Project:`}),(0,l.jsx)(JN,{strong:!0,children:i.name})]}),(0,l.jsxs)(s.Space,{size:6,children:[(0,l.jsx)(c.AppstoreOutlined,{}),(0,l.jsx)(`span`,{children:`Module:`}),(0,l.jsx)(JN,{strong:!0,children:a})]})]})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`primary`,icon:(0,l.jsx)(c.PlusOutlined,{}),onClick:()=>g(!0),children:`Add Submodule`})})]})}),(0,l.jsx)(s.Card,{className:`v1-card zt-fall`,title:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.AppstoreOutlined,{}),(0,l.jsx)(`span`,{children:`Submodules`})]}),children:(0,l.jsx)(km,{listName:`Submodules`,loading:p,fields:[{label:`Submodule`,value:`submodulename`},{label:`Active`,value:`active`,width:120,render:(e,t)=>(0,l.jsx)(s.Switch,{checked:e===1,checkedChildren:`On`,unCheckedChildren:`Off`,onChange:e=>E(t,e)})}],dataSource:u,current:x,pageSize:C,total:u.length,onPageChange:S,onPageSizeChange:e=>{S(1),w(e)},rowSelection:!1,className:`zt-list-plain`})})]}),(0,l.jsx)(s.Modal,{title:`Add Submodule`,open:h,confirmLoading:y,okText:`Add`,onOk:D,onCancel:()=>{g(!1),v(``)},destroyOnHidden:!0,children:(0,l.jsxs)(s.Space,{direction:`vertical`,className:`zt-modal-stack`,children:[(0,l.jsxs)(JN,{type:`secondary`,children:[`Project: `,(0,l.jsx)(`b`,{children:i.name}),` \xA0|\xA0 Module: `,(0,l.jsx)(`b`,{children:a})]}),(0,l.jsx)(s.Input,{placeholder:`Enter submodule name`,maxLength:100,value:_,onChange:e=>v(e.target.value),onPressEnter:D})]})})]})}var{Text:ZN}=s.Typography,QN=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Table`,href:`/viewTestCase`}];function $N(){let e=(0,d.useNavigate)(),[r,i]=(0,o.useState)([]),[a,u]=(0,o.useState)(0),[f,p]=(0,o.useState)(!1),m=(0,o.useMemo)(()=>t.l(),[]),[h,g]=(0,o.useState)(``),[_,v]=(0,o.useState)(1),[y,b]=(0,o.useState)(20),[x,S]=(0,o.useState)(null),C=(0,o.useCallback)(async(e={})=>{p(!0);try{let t=await Nb({product_parent_ID:e.project??m?.id??``,search:e.search??h??``,limit:e.pageSize??y,offset:((e.page??_)-1)*(e.pageSize??y)});i(t?.items??[]),u(t?.total??0)}catch(e){console.error(e),s.message.error(`Unable to load test flows.`)}finally{p(!1)}},[m?.id,h,_,y]),w=e=>{s.Modal.confirm({title:`Delete Test Case`,icon:(0,l.jsx)(c.ExclamationCircleOutlined,{}),content:`Are you sure you want to delete this test case?`,okText:`Delete`,okButtonProps:{danger:!0,loading:x===e.id},cancelText:`Cancel`,async onOk(){S(e.id);try{await Rb(e.id),s.message.success(`Test case deleted successfully.`);let t=r.length===1&&_>1?_-1:_;v(t),await C({page:t})}catch(e){throw console.error(`Unable to delete test flow:`,e),s.message.error(`Unable to delete test case.`),e}finally{S(null)}}})};return(0,o.useEffect)(()=>{Promise.resolve().then(()=>{if(!m?.id){e(`/select-project`,{replace:!0});return}C({page:1})})},[]),(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:QN})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`link`,onClick:()=>e(`/addTestCase`),children:`Back to Form`})})]}),(0,l.jsx)(`div`,{className:`zt-page zt-page-wide`,children:(0,l.jsxs)(s.Card,{className:`v1-card`,title:(0,l.jsxs)(s.Space,{size:6,className:`zt-section-title`,children:[(0,l.jsx)(c.TableOutlined,{}),(0,l.jsx)(`span`,{children:`Test Flows`})]}),extra:(0,l.jsxs)(ZN,{type:`secondary`,children:[a,` row(s)`]}),children:[(0,l.jsxs)(s.Space,{wrap:!0,className:`zt-toolbar`,children:[(0,l.jsx)(s.Input.Search,{allowClear:!0,className:`zt-search-filter`,placeholder:`Search module / key / description`,value:h,onChange:e=>g(e.target.value),onSearch:()=>{v(1),C({page:1})}}),(0,l.jsx)(s.Button,{icon:(0,l.jsx)(c.ReloadOutlined,{}),onClick:()=>C(),children:`Refresh`})]}),(0,l.jsx)(km,{listName:`Test Flows`,loading:f,fields:[{label:`Actions`,value:`rowActions`,width:112,fixed:`left`,sorter:!1,render:(t,n)=>(0,l.jsxs)(s.Space,{size:4,className:`zt-row-actions`,children:[(0,l.jsx)(s.Tooltip,{title:`Edit`,children:(0,l.jsx)(s.Button,{type:`text`,size:`small`,icon:(0,l.jsx)(c.EditOutlined,{}),onClick:()=>e(`/addTestCase?edit=${n.id}`)})}),(0,l.jsx)(s.Tooltip,{title:`Delete`,children:(0,l.jsx)(s.Button,{danger:!0,type:`text`,size:`small`,icon:(0,l.jsx)(c.DeleteOutlined,{}),loading:x===n.id,onClick:()=>w(n)})})]})},{label:`ID`,value:`id`,width:70,fixed:`left`},{label:`Project`,value:`project`,width:130},{label:`Module`,value:`module`,width:130},{label:`Submodule`,value:`submodule`,width:140},{label:`Step`,value:`step_order`,width:70},{label:`Action`,value:`actions`,width:140},{label:`Key`,value:`key`,width:160,ellipsis:!0},{label:`Value`,value:`value`,width:200,ellipsis:!0},{label:`Expected`,value:`expected`,width:180,ellipsis:!0},{label:`Description`,value:`description`,width:180,ellipsis:!0},{label:`Scenario`,value:`scenario`,width:110,render:e=>e===1?(0,l.jsx)(s.Tag,{color:`green`,children:`Positive`}):(0,l.jsx)(s.Tag,{color:`red`,children:`Negative`})},{label:`Active`,value:`active`,width:90,render:e=>e===1?(0,l.jsx)(s.Tag,{color:`blue`,children:`Active`}):(0,l.jsx)(s.Tag,{children:`Inactive`})}],dataSource:r,current:_,pageSize:y,total:a,onPageChange:e=>{v(e),C({page:e})},onPageSizeChange:e=>{v(1),b(e),C({page:1,pageSize:e})},rowSelection:!1,className:`zt-list-plain`})]})})]})}var eP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}];function tP(){return(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsx)(n.t,{items:eP}),(0,l.jsx)(Jo,{moduleName:`test-flows`,rowKey:`id`})]})}var{Text:nP}=s.Typography,rP=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}],iP={tags:`regression`,active:1},aP={module:{dbName:`Modules`,formField:`module`,label:`Module`}},oP={key:!1,value:!1,expected:!1};function sP(e,t){return t?e[t]??oP:oP}function cP(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function lP(e=[]){return e.map(e=>({value:e,label:e}))}function uP(e=``){return String(e??``).trim()}function dP(e=[]){let t=new Map;return e.forEach(e=>{let n=uP(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function fP(e=[],t,n){let r=uP(t).toLowerCase(),i=uP(n).toLowerCase();return e.reduce((e,t)=>{let n=uP(t?.module).toLowerCase(),a=uP(t?.flow).toLowerCase();if(n!==r||a!==i)return e;let o=Number(t?.step_order)||0;return Math.max(e,o)},0)+1}function pP({icon:e,title:t}){return(0,l.jsxs)(s.Space,{size:10,align:`center`,children:[(0,l.jsx)(`div`,{className:`v1-section-icon-box`,children:e}),(0,l.jsx)(nP,{strong:!0,className:`v1-section-label`,children:t})]})}function mP(){let[e]=s.Form.useForm(),[t]=s.Form.useForm(),[r,i]=(0,o.useState)([]),[a,u]=(0,o.useState)([]),[f,p]=(0,o.useState)([]),[m,h]=(0,o.useState)(wN),[g,_]=(0,o.useState)({}),[v,y]=(0,o.useState)(!1),[b,x]=(0,o.useState)(!1),[S,C]=(0,o.useState)({open:!1,typeKey:`module`}),[w,T]=(0,o.useState)(!1),[E,D]=(0,o.useState)(!1),[O,k]=(0,o.useState)(!1),A=(0,d.useNavigate)(),j=aP[S.typeKey],M=(0,o.useMemo)(()=>lP(r),[r]),N=s.Form.useWatch(`module`,e),P=s.Form.useWatch(`flow`,e),F=s.Form.useWatch(`keyword`,e),I=!!uP(N),L=!!uP(P),R=!I,z=!I||!L,B=(0,o.useMemo)(()=>sP(g,F),[g,F]),V=(e,t=[])=>{e===`module`&&i(t)},ee=async()=>{y(!0);try{let e=await _b(aP.module.dbName);i(e?.items??[])}catch(e){console.error(`Unable to load testing options:`,e),s.message.error(`Unable to load testing options.`)}finally{y(!1)}},te=async()=>{try{let e=await yb();Array.isArray(e?.options)&&e.options.length>0&&h(e.options),e?.rules&&typeof e.rules==`object`&&_(e.rules)}catch(e){console.error(`Unable to load action field rules:`,e),s.message.error(`Unable to load action validation rules.`)}},ne=(0,o.useCallback)(async t=>{let n=uP(t);if(u([]),p([]),e.setFieldsValue({step_order:void 0}),n){x(!0);try{let e=await Tb({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];u(t),p(dP(t))}catch(e){console.error(`Unable to load flows:`,e),s.message.error(`Unable to load flows.`)}finally{x(!1)}}},[e]),re=(0,o.useCallback)(async(t,n,r)=>{let i=uP(t),a=uP(n);if(!i||!a){e.setFieldsValue({step_order:void 0});return}D(!0);try{e.setFieldsValue({step_order:fP(r,i,a)})}catch(e){console.error(`Unable to load step order:`,e),s.message.error(`Unable to load step order.`)}finally{D(!1)}},[e]);(0,o.useEffect)(()=>{Promise.resolve().then(async()=>{await Promise.all([ee(),te()])})},[]),(0,o.useEffect)(()=>{Promise.resolve().then(()=>ne(N))},[ne,N]),(0,o.useEffect)(()=>{Promise.resolve().then(()=>re(N,P,a))},[a,re,P,N]);let ie=async t=>{let n={module:uP(t.module),flow:uP(t.flow),step_order:Number(t.step_order),description:uP(t.description),keyword:uP(t.keyword),target:uP(t.target),value:uP(t.value),expected:uP(t.expected),tags:t.tags?uP(t.tags):iP.tags,active:Number(t.active)};k(!0);try{await wb(n),s.message.success(`LMS case details saved successfully.`),e.resetFields(),u([]),p([])}catch(e){console.error(`Unable to save LMS case:`,e),s.message.error(`Unable to save LMS case.`)}finally{k(!1)}},ae=(t,n)=>{e.setFieldsValue({[t]:uP(n)})},oe=t=>{e.setFieldsValue({module:uP(t),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:iP.tags,value:void 0,expected:void 0}),cP(e,[`keyword`,`target`,`value`,`expected`])},se=t=>{e.setFieldsValue({flow:uP(t),step_order:void 0,keyword:void 0,target:void 0,value:void 0,expected:void 0}),cP(e,[`keyword`,`target`,`value`,`expected`])},H=t=>{let n=sP(g,t);e.setFieldsValue({keyword:uP(t),target:n.key?e.getFieldValue(`target`):void 0,value:n.value?e.getFieldValue(`value`):void 0,expected:n.expected?e.getFieldValue(`expected`):void 0}),cP(e,[`target`,`value`,`expected`])},ce=e=>{let n=aP[e];C({open:!0,typeKey:e}),t.setFieldsValue({name:``,type:n.label})},le=()=>{C(e=>({...e,open:!1})),t.resetFields()},ue=async()=>{try{let n=uP((await t.validateFields()).name),r=await vb({name:n,type:j.dbName});V(S.typeKey,r?.items??[]),e.setFieldsValue({[j.formField]:n}),s.message.success(`${j.label} added successfully.`),le()}catch(e){if(e?.errorFields)return;console.error(`Unable to save testing option:`,e),s.message.error(`Unable to add ${j.label.toLowerCase()}.`)}finally{T(!1)}};return(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsxs)(s.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,l.jsx)(s.Col,{children:(0,l.jsx)(n.t,{items:rP})}),(0,l.jsx)(s.Col,{children:(0,l.jsx)(s.Button,{type:`link`,onClick:()=>A(`/lms-home`),children:`View Table`})})]}),(0,l.jsx)(`div`,{className:`v1-page`,children:(0,l.jsxs)(`div`,{className:`v1-page-inner`,children:[(0,l.jsx)(`div`,{className:`v1-page-header`,children:(0,l.jsxs)(s.Space,{align:`center`,size:10,children:[(0,l.jsx)(c.ProfileOutlined,{className:`v1-outer-icon`}),(0,l.jsx)(`div`,{children:(0,l.jsx)(nP,{strong:!0,style:{fontSize:16},children:`Add LMS Case`})})]})}),(0,l.jsx)(Z,{children:(0,l.jsxs)(s.Form,{form:e,className:`v1-form`,layout:`vertical`,colon:!1,requiredMark:(e,{required:t})=>(0,l.jsxs)(l.Fragment,{children:[e,t&&(0,l.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),initialValues:iP,onFinish:ie,autoComplete:`off`,children:[(0,l.jsx)(s.Card,{className:`v1-card`,title:(0,l.jsx)(pP,{icon:(0,l.jsx)(c.FileTextOutlined,{}),title:`LMS Case Details`}),extra:(0,l.jsx)(nP,{type:`secondary`,className:`v1-card-subtitle`,children:`Module, flow, step order and execution data`}),children:(0,l.jsxs)(s.Row,{gutter:[24,0],children:[(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsxs)(s.Space.Compact,{style:{width:`100%`},children:[(0,l.jsx)(s.Form.Item,{label:`Module`,name:`module`,style:{flex:1},children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,loading:v,optionFilterProp:`label`,placeholder:`Select module`,options:M,onChange:oe})}),(0,l.jsx)(s.Button,{"aria-label":`Add module`,icon:(0,l.jsx)(c.PlusOutlined,{}),style:{marginTop:30},onClick:()=>ce(`module`)})]})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Flow`,name:`flow`,children:(0,l.jsx)(s.AutoComplete,{maxLength:100,allowClear:!0,disabled:R,options:f,placeholder:b?`Loading flows`:`Enter flow`,onChange:se,filterOption:(e,t)=>t?.value?.toLowerCase().includes(e.toLowerCase())})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Step Order`,name:`step_order`,validateTrigger:[`onBlur`,`onChange`],children:(0,l.jsx)(s.Input,{maxLength:10,disabled:!0,placeholder:E?`Loading step order`:`Step order`})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Action`,name:`keyword`,children:(0,l.jsx)(s.Select,{allowClear:!0,showSearch:!0,disabled:z,optionFilterProp:`label`,placeholder:`Select action`,options:m,onChange:H})})}),(0,l.jsx)(s.Col,{xs:24,children:(0,l.jsx)(s.Form.Item,{label:`Description`,name:`description`,children:(0,l.jsx)(s.Input.TextArea,{rows:3,maxLength:255,disabled:z,placeholder:`Enter description`,showCount:!0,onBlur:e=>ae(`description`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Key`,name:`target`,rules:[{required:B.key,message:`Key is required for this action`}],children:(0,l.jsx)(s.Input,{maxLength:255,disabled:z||!!F&&!B.key,placeholder:z?`Select module and flow first`:F?B.key?`Required — Enter selector / locator`:`Not needed for this action`:`Select an action first`,onBlur:e=>ae(`target`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Tags`,name:`tags`,children:(0,l.jsx)(s.Input,{maxLength:200,disabled:z,placeholder:`Enter tags`,prefix:(0,l.jsx)(c.TagsOutlined,{className:`v1-input-icon`}),onBlur:e=>ae(`tags`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Value`,name:`value`,rules:[{required:B.value,message:`Value is required for this action`}],children:(0,l.jsx)(s.Input.TextArea,{rows:4,disabled:z||!!F&&!B.value,placeholder:z?`Select module and flow first`:F?B.value?`Required — Enter value`:`Not needed for this action`:`Select an action first`,onBlur:e=>ae(`value`,e.target.value)})})}),(0,l.jsx)(s.Col,{xs:24,md:12,children:(0,l.jsx)(s.Form.Item,{label:`Expected`,name:`expected`,rules:[{required:B.expected,message:`Expected result is required for this action`}],children:(0,l.jsx)(s.Input.TextArea,{rows:4,disabled:z||!!F&&!B.expected,placeholder:z?`Select module and flow first`:F?B.expected?`Required — Enter expected result`:`Not needed for this action`:`Select an action first`,onBlur:e=>ae(`expected`,e.target.value)})})})]})}),(0,l.jsx)(`div`,{className:`v1-form-actions`,children:(0,l.jsx)(s.Form.Item,{children:(0,l.jsxs)(s.Space,{children:[(0,l.jsx)(s.Button,{type:`primary`,htmlType:`submit`,loading:O,disabled:z,children:`Submit`}),(0,l.jsx)(s.Button,{onClick:()=>{e.resetFields(),u([]),p([])},children:`Reset`})]})})})]})}),(0,l.jsx)(s.Modal,{title:`Add ${j.label}`,open:S.open,confirmLoading:w,okText:`Add`,onCancel:le,onOk:()=>{T(!0),ue()},destroyOnHidden:!0,children:(0,l.jsxs)(s.Form,{form:t,layout:`vertical`,colon:!1,className:`v1-form`,requiredMark:(e,{required:t})=>(0,l.jsxs)(l.Fragment,{children:[e,t&&(0,l.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),children:[(0,l.jsx)(s.Form.Item,{label:`Name`,name:`name`,children:(0,l.jsx)(s.Input,{maxLength:100,placeholder:`Enter ${j.label.toLowerCase()} name`,onBlur:e=>{t.setFieldsValue({name:uP(e.target.value)})}})}),(0,l.jsx)(s.Form.Item,{label:`Type`,name:`type`,children:(0,l.jsx)(s.Input,{disabled:!0})})]})})]})})]})}var hP=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}];function gP(){return(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsx)(n.t,{items:hP}),(0,l.jsx)(Jo,{moduleName:`lms-flows`,rowKey:`id`})]})}var _P=[`referenceId`,`ReferenceId`,`candidateId`,`CandidateId`,`entityId`,`EntityId`,`id`,`Id`,`_id`];function vP(e=_P){return function(t){if(!t||typeof t!=`object`)return``;for(let n of e){let e=t[n];if(e!=null&&e!==``)return String(e)}return``}}function yP(e,t=_P){if(!e||typeof e!=`object`)return[];let n=[];for(let r of t){let t=e[r];t!=null&&t!==``&&n.push(String(t))}return n}var bP=vP();function xP(e){return typeof e==`function`?e:typeof e==`string`?vP([e]):Array.isArray(e)?vP(e):bP}function SP(e,t,n){return!t||typeof t!=`object`?e:{...t,...e,id:e?.id??t?.id??n}}function CP(e,t,n={}){return{status:`success`,total:t,data:{data:e,...n}}}var wP=[`fields`,`fieldConfig`,`tabs`,`tabField`,`actionRules`,`actions`,`columnActions`];function TP(e){let t=e?.data??e,n={};for(let r of wP){let i=e?.[r]??t?.[r];i==null||Array.isArray(i)&&i.length===0||(n[r]=i)}return n}var EP=e=>String(e??``).replace(/[^a-zA-Z0-9]/g,``).toLowerCase();function DP(e,t,n){let r=(Array.isArray(n)?n:[n]).map(EP).filter(Boolean),i=r.length?e.findIndex(e=>r.includes(EP(e?.value))||r.includes(EP(e?.label))):-1;if(i===-1)return[...e,...t];let a=Number(e[i]?.order),o=Number.isFinite(a)?t.map((e,n)=>e.order==null||e.order===``?{...e,order:a+(n+1)/(t.length+1)}:e):t;return[...e.slice(0,i+1),...o,...e.slice(i+1)]}var OP=(e,t)=>pi(e,t).rows,kP=(e,t)=>{let{rows:n,total:r}=pi(e,t);return{rows:n,total:r}};function AP(e,t){return function(n,r,i,a={}){return e(t??n,r,i,a)}}function jP(e){return!e||typeof e!=`object`||typeof(e.fetchByKeys??e.fetch??e.function)!=`function`?null:{...e,fetchByKeys:typeof e.fetchByKeys==`function`?e.fetchByKeys:null,fetch:typeof e.fetch==`function`?e.fetch:null,function:typeof e.function==`function`?e.function:null,extractRows:typeof e.extractRows==`function`?e.extractRows:OP,mergeRow:typeof e.mergeRow==`function`?e.mergeRow:SP,fetchById:typeof e.fetchById==`function`?e.fetchById:null}}function MP({fetchSecondaryByKeys:e,fetchSecondary:t,extractSecondaryRows:n,fetchSecondaryById:r,secondaryKey:i,mergeRow:a,secondaryFetchLimit:o}){return!e&&!t&&!r?[]:[jP({key:i,fetchByKeys:e?(t,n,r)=>e(t,n,r):null,function:t?({moduleName:e,options:n})=>t(e,o,0,n):null,extractRows:n,fetchById:r,mergeRow:a})].filter(Boolean)}function NP(e){if(typeof e==`function`)return t=>{let n=e(t);return n==null||n===``?[]:[String(n)]};let t=typeof e==`string`?[e]:Array.isArray(e)&&e.length?e:_P;return e=>yP(e,t)}function PP(e,t){let n=new Map;return e.forEach(e=>{for(let r of t(e))n.has(r)||n.set(r,e)}),n}function FP({moduleName:e,limit:t,offset:n,options:r,keys:i,primaryResponse:a,primaryRows:o,pageRows:s,total:c,source:l}){return{moduleName:e,limit:t,offset:n,options:r,keys:i,primaryResponse:a,primaryRows:o,pageRows:s,total:c,source:l}}async function IP(e,t){if(typeof e.args==`function`){let n=e.args(t);return(e.fetch??e.function??e.fetchByKeys)(...Array.isArray(n)?n:[n])}if(Array.isArray(e.args))return(e.fetch??e.function??e.fetchByKeys)(...e.args);if(e.fetchByKeys&&Array.isArray(t.keys))return e.fetchByKeys(t.moduleName,t.keys,t.options,t);let n=e.fetch??e.function;return typeof n==`function`?n(t):null}function LP({fetchPrimaryPage:e,extractPrimaryPage:t=kP,fetchSecondaryByKeys:n,joinSources:r=[],fetchPrimary:i,extractPrimaryRows:a=OP,fetchSecondary:o,extractSecondaryRows:s=OP,fetchSecondaryById:c,primaryKey:l,secondaryKey:u,mergeRow:d=SP,secondaryFetchLimit:f=200,extraFields:p=[],extraFieldsAfter:m}){let h=Array.isArray(r)&&r.length?r.map(jP).filter(Boolean):MP({fetchSecondaryByKeys:n,fetchSecondary:o,extractSecondaryRows:s,fetchSecondaryById:c,secondaryKey:u,mergeRow:d,secondaryFetchLimit:f}),g=0;async function _(e,t,n,r){if(!e.fetchById||!r)return null;try{let i=await e.fetchById(n,r);return i&&t(i).includes(String(r))?i:null}catch(e){return console.error(`[mergedListApi] per-id join lookup failed for "${r}"`,e),null}}async function v(e,t,n,r,i){if(!n)return e;let a=t.extractRows(n,r)??[],o=xP(t.primaryKey??l),s=NP(t.key),c=PP(a,s);return Promise.all(e.map(async e=>{let n=o(e),a=c.get(n)??(i()?null:await _(t,s,r,n));return t.mergeRow(e,a,n)}))}async function y(e,t,n,r){let i=e;for(let e of t)i=await v(i,e.source,e.response,n,r);return i}function b(e,t,n){let r={};for(let e of n){if(!e)continue;let t=TP(e);for(let e of Object.keys(t))r[e]??(r[e]=t[e])}return p.length&&(r.fields=DP(r.fields??[],p,m)),CP(e,t,r)}async function x({moduleName:e,limit:t,offset:n,options:r,primaryResponse:i,primaryRows:a,pageRows:o,total:s}){return Promise.all(h.map(async c=>{try{let u=xP(c.primaryKey??l),d=[...new Set(o.map(u).filter(Boolean))];return c.fetchByKeys&&d.length===0?{source:c,response:null}:{source:c,response:await IP(c,FP({moduleName:e,limit:t,offset:n,options:r,keys:d,primaryResponse:i,primaryRows:a,pageRows:o,total:s,source:c}))}}catch(e){return console.error(`[mergedListApi] join fetch failed — rendering page without that join`,e),{source:c,response:null}}}))}async function S(n,r,i,a,o){let s=await e(n,r,i,a),c=t(s,n)??{},l=Array.isArray(c.rows)?c.rows:[],u=Number.isFinite(Number(c.total))?Number(c.total):l.length,d=await x({moduleName:n,limit:r,offset:i,options:a,primaryResponse:s,primaryRows:l,pageRows:l,total:u});return b(await y(l,d,n,o),u,[s,...d.map(e=>e.response)])}async function C(e,t,n,r,o){let s=await i(e,t,n,r),c=a(s,e)??[],l=c.length,u=c.slice(n,n+t),d=await x({moduleName:e,limit:t,offset:n,options:r,primaryResponse:s,primaryRows:c,pageRows:u,total:l});return b(await y(u,d,e,o),l,[s,...d.map(e=>e.response)])}return async function(t,n=10,r=0,i={}){let a=++g,o=()=>a!==g;return e?S(t,n,r,i,o):C(t,n,r,i,o)}}function RP(e,t,n={}){return LP({fetchPrimary:()=>Qk(e,t),extractPrimaryRows:Xk,fetchSecondary:Cn,fetchSecondaryById:$k,secondaryFetchLimit:n.moduleFetchLimit??200})}function zP(e){let t=String(e??``).trim().split(/[^a-zA-Z0-9]+/).filter(Boolean);return t.length?`${t.map((e,t)=>t===0?e.toLowerCase():e[0].toUpperCase()+e.slice(1).toLowerCase()).join(``)}Count`:``}function BP(e){let t=Array.isArray(e?.stages)?e.stages:[];if(!t.length)return e;let n={};for(let e of t){let t=zP(e?.stageName);t&&(n[t]=Number(e?.count)||0)}return{...n,...e}}var VP=e=>{let t=Number(e?.targetSubmission??e?.targetSubmissions);return Number.isFinite(t)&&t>0?t:null};function HP({submittedCountField:e=`submittedCount`,progressField:t=`targetSubmissionProgress`}={}){return function(n,r,i){let a=SP(n,r,i),o=VP(a);return o!=null&&(a[t]=`${Number(a?.[e])||0} of ${o}`),a}}function UP(e={}){let t=HP();return LP({primaryKey:`_id`,extraFields:e.extraFields,extraFieldsAfter:e.extraFieldsAfter,fetchPrimaryPage:Cn,joinSources:[{key:`entityId`,fetchByKeys:(e,t,n,r)=>{let i=Math.max(1,Number(r?.limit)||10);return Zk(Math.floor((Number(r?.offset)||0)/i)+1,i)},extractRows:e=>(e?.items??[]).map(BP),mergeRow:(e,n,r)=>{let i=t(e,n,r);return n?._id&&(i.workflowId=n._id),i}}]})}async function WP(e,t=10,n=0,r={},i={}){return pi(await UP(i)(e,t,n,r),e)}async function GP(e,t,n,r=10,i=0,a={}){return pi(await RP(e,t)(n,r,i,a),n)}typeof window<`u`&&(window.__CORE_THEME_BUILD__=`2026-09-15T09:35:29.065Z`);var KP=cM,qP=Vb(oN),JP=Vb(cN),YP=Vb(CN),XP=Vb(FN),ZP=Vb(WN),QP=Vb(qN),$P=Vb(XN),eF=Vb($N),tF=Vb(tP),nF=Vb(mP),rF=Vb(gP);exports.ADMIN_API_URL=t.v,exports.ADMIN_APP_ID=t.y,exports.APP_ID=t.b,exports.AUTH_URL=t.x,exports.ActivityNotesCard=Uc,exports.ActivityTab=Rc,exports.AddBatchCandidatePopup=Lj,exports.AddFormV1=xc,exports.AdminDashboard=cM,exports.AdminDashboardContent=BE,exports.AdminPage=KP,exports.AppAlert=Sc,exports.AppButton=n.ft,exports.AppShell=ub,exports.ApprovalActionBar=y_,exports.AssigneeAvatars=Wc,exports.AuthGuard=rb,exports.BILLING_STATUS_FLOW=$d,exports.BOOLEAN_API_KEYS=ag,exports.BOOLEAN_PARSEABLE_API_KEYS=Wm,exports.BULK_UPLOAD_DEFAULT_ACCEPT=Gc,exports.BULK_UPLOAD_DEFAULT_MAX_SIZE_MB=Kc,exports.Breadcrumb=n.t,exports.BulkUploadPage=YP,exports.BulkUploadPanel=el,exports.CANDIDATES_URL=t.S,exports.CONTRACT_C2C=U_,exports.CONTRACT_W2=H_,exports.CURRENCY_SYMBOLS=cu,exports.CalendarCard=A,exports.CoreThemeAdminApp=WE,exports.CoreThemeAdminRoutes=UE,exports.CustomPagination=ze,exports.DEFAULT_HOURS_POLICY=Vg,exports.DEFAULT_RESULTS_VIEW=tg,exports.DayLogModal=d_,exports.DescriptionBlock=pl,exports.DetailHeaderCard=np,exports.DetailViewPage=lp,exports.DetailViewV1=Qu,exports.DocumentViewer=n.En,exports.DynamicCards=Pt,exports.DynamicPopup=uk,exports.DynamicPopupRoute=Hj,exports.DynamicTabs=P,exports.EditFormV1=sm,exports.FIELD_TYPE_REGISTRY=Th,exports.FINANCE_APPROVAL_CONFIG=P_,exports.FINANCE_TYPE_CFO=D_,exports.FINANCE_TYPE_ONBOARDING_MANAGER=E_,exports.FINANCE_TYPE_ONBOARDING_MANAGER_REAPPROVE=A_,exports.FINANCE_TYPE_ONLY_FINANCE=O_,exports.FINANCE_TYPE_SUBMISSION_MANAGER=T_,exports.FINANCE_TYPE_SUBMISSION_MANAGER_REAPPROVE=k_,exports.FileListCard=Jv,exports.FinanceApprovalPanel=Dv,exports.FinanceAvatar=Ff,exports.FinanceBadge=zf,exports.FinanceDayCell=x_,exports.FinanceDivider=Df,exports.FinanceEmployeeCell=If,exports.FinanceEmptyState=wf,exports.FinanceEquation=Of,exports.FinanceHistoryTimeline=Mf,exports.FinanceHoursGrid=Cf,exports.FinanceKpiRow=Sf,exports.FinanceLine=Ef,exports.FinanceListToolbar=Bg,exports.FinanceMarginBadge=Bf,exports.FinanceMoneyCell=Rf,exports.FinanceRecordsTable=Uf,exports.FinanceRowChevron=Vf,exports.FinanceSection=Tf,exports.FinanceStatusPill=xf,exports.FinanceTextCell=Lf,exports.FinanceTimesheetAnalysis=C_,exports.FinanceWorkflowSteps=kf,exports.HOURS_MESSAGES=Hg,exports.Header=Cy,exports.HierarchyUserFilter=zt,exports.JOBS_URL=t.C,exports.LegacyAdminPage=qP,exports.ListView=Jo,exports.LmsHomePage=rF,exports.LmsTestForm=nF,exports.Login=db,exports.MailPopup=bD,exports.ManageModules=QP,exports.ManageSubmodules=$P,exports.ModuleRowActions=gm,exports.NotesPanel=v_,exports.NotesTab=Hc,exports.OPEN_AS_OPTIONS=Kh,exports.PAYROLL_STATUS_FLOW=ef,exports.POPUP_CONFIGS=Oj,exports.ParamCardView=Cm,exports.ParamListView=km,exports.PaymentInvoicePopup=Qj,exports.PeriodBadgeTag=e_,exports.PreviewPopup=ZD,exports.ProjectSelect=Bb,exports.ProofUploadPreview=__,exports.QuickLogBar=m_,exports.QuickLogSelectionBar=f_,exports.RESULTS_VIEW_OPTIONS=eg,exports.RejectionReasonModal=p_,exports.SUBMISSIONS_URL=t.T,exports.SearchBuilderV1=jg,exports.Sidebar=$y,exports.StatusBadge=Ng,exports.StatusBadgeTag=$g,exports.StickyNotesFullPage=JP,exports.StylishDynamicTabs=Fg,exports.TemplateEditor=Lg,exports.TestForm=XP,exports.TestingHomePage=tF,exports.TimelineGroups=Ac,exports.TimesheetDayCell=c_,exports.TipTapEditor=n.Dn,exports.UserForm=sM,exports.VendorShareDrawer=Kj,exports.ViewSummaryWidget=zi,exports.WizardPopup=rO,exports.ZinnextTableView=eF,exports.ZinnextTestForm=ZP,exports.appNow=n.jn,exports.applyIntegrationStatus=n.qn,exports.approveSubmission=Ce,exports.buildAcceptAttr=Zc,exports.buildBooleanRequest=ug,exports.buildCsv=hf,exports.buildDailyRows=lf,exports.buildDayGradient=o_,exports.buildRateHistoryEntries=mv,exports.buildWeeklyRollup=ff,exports.clearSelectedProject=t.i,exports.colors=n.An,exports.computeFinance=ov,exports.computeHoursPolicy=Jg,exports.computeMarginBand=pf,exports.conditionMatches=n.i,exports.configureCoreTheme=t.E,exports.configuredFieldLabel=n.a,exports.createAllWorkflowsListFetcher=UP,exports.createMergedListFetcher=LP,exports.createModuleListFetchAdapter=AP,exports.createWorkflowStageListFetcher=RP,exports.currencySymbol=lu,exports.defaultMergeRow=SP,exports.deleteIntegrationConfig=n.ir,exports.deriveDayStats=cf,exports.describeCapacity=Xg,exports.downloadCsv=yf,exports.evaluateShowIfWith=n.o,exports.findEmployerRow=ev,exports.flattenGroups=Q_,exports.formatAmount=hu,exports.formatApp=n.Mn,exports.formatAppDateTime=n.Nn,exports.formatFileSize=Xc,exports.formatFinanceMoney=hv,exports.formatHours=Wd,exports.formatMoney=gu,exports.formatPercent=Kd,exports.formatRate=_u,exports.getActivity=n.pn,exports.getAllWorkflowsModuleList=WP,exports.getAppTimeZone=n.Pn,exports.getApprovalDate=Xd,exports.getBgcIntegrationConfig=n.Sr,exports.getBgcIntegrationSummary=n.Cr,exports.getBillingActionStates=tf,exports.getBooleanEligibleTypes=jh,exports.getCurrentRoleName=t.c,exports.getFieldLabel=_f,exports.getFieldType=Dh,exports.getFileExtension=Yc,exports.getFinanceApprovalConfig=z_,exports.getFormGroupsRaw=Lv,exports.getIntegrationConfig=n.kr,exports.getIntegrationConfigs=n.Ar,exports.getIntegrationSummary=n.jr,exports.getModuleConfig=Ie,exports.getModuleDataDetail=n.hn,exports.getPayrollActionStates=nf,exports.getPeriodBadgeConfig=Re,exports.getSearchPopup=Uh,exports.getSelectedProject=t.l,exports.getStoredToken=t.u,exports.getStoredUser=t.d,exports.getUserRoles=t.f,exports.getVMSApprove=we,exports.getValueStyle=vf,exports.getWorkflowStageModuleList=GP,exports.getWorkflowSteps=rf,exports.humanizeEvent=Yd,Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return ys}}),exports.indexFieldConfig=gf,exports.initialsOf=qd,exports.insertTokenAtCursor=Jm,exports.isBooleanEligible=Oh,exports.isBooleanParsable=Km,exports.isTester=t.p,exports.logout=t.h,exports.marginIncludesReferral=V_,exports.matchLocationTax=av,Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return _p}}),exports.normalizeContract=nv,Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return tl}}),exports.rateUnitLabel=du,exports.rateUnitShort=pu,exports.readActionButtons=Xh,exports.reconcileHours=Yg,exports.registerFieldType=Eh,exports.registerSearchPopup=Hh,exports.rejectSubmission=W,exports.resolveActivityMeta=Fc,exports.resolveAndCompute=sv,exports.resolveDayKind=Kg,exports.resolveFinanceInputs=iv,exports.resolveMergeKey=bP,exports.resolveMergedListKey=bP,exports.resolveOpenAs=Jh,exports.resolveRejectionReason=B_,exports.resolveResultsSearchPlaceholder=ig,exports.resolveResultsView=rg,exports.resolveSubmissionFinance=Rv,exports.saveBgcIntegrationConfig=n.ti,exports.saveIntegrationConfig=n.ii,exports.setSelectedProject=t._,exports.showIfConditions=n.c,exports.stageCountKey=zP,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return fb}}),exports.testIntegrationConnection=n.di,exports.toApp=n.In,exports.toNumber=mu,exports.tzLabel=n.Ln,exports.tzShortLabel=n.Rn,exports.unregisterSearchPopup=Wh,exports.useDropdownFields=zn,exports.useDropdownValues=Bi,exports.useEditForm=Yv,exports.useFieldConfig=Bn,exports.useFilterFields=Vn,exports.useMenuPermission=rr,exports.useModuleActions=lm,exports.useRecordRefresh=op,exports.validateBooleanQuery=qm,exports.validateBulkFile=Qc,exports.withAdminAppId=t.D,exports.withAppId=t.O,exports.withAuthGuard=Vb;
23
23
  //# sourceMappingURL=index.cjs.map