@realtek/core-theme 0.0.337 → 0.0.338

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.
@@ -19,5 +19,5 @@ Upload the résumé first — we can read the details straight from it`})}),(0,l
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
20
  `).trim()}function JT(e){return e.replace(/•/g,`
21
21
  `).split(/\n+/).map(e=>e.trim().replace(/^[-–—•]\s*/,``).trim()).filter(Boolean)}function YT(e){return JT(e.replace(/(?:^|\s)[-–—]\s+/g,`
22
- `))}function XT(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:GT(n),value:r}}function ZT(e){let t=e.toLowerCase().replace(/[\s:.\-–—]+$/,``).trim();return VT.has(t)?HT.test(t)?`education`:UT.test(t)?`keySkills`:`overview`:null}function QT(e){let t=[],n={overview:[],keySkills:[],education:[]},r=`overview`;return e.forEach(e=>{let i=ZT(e);if(i){r=i;return}if(r===`overview`){let n=XT(e);if(n){t.push(n);return}}n[r].push(e)}),{meta:t,overview:KT(n.overview),keySkills:KT(n.keySkills),education:KT(n.education)}}function $T(e){let t=[...BT].sort((e,t)=>t.length-e.length),n=RegExp(`\\b(${t.map(WT).join(`|`)})\\b\\s*:?`,`gi`),r=[...e.matchAll(n)];if(!r.length)return{meta:[],overview:KT(YT(e)),keySkills:[],education:[]};let i={overview:[],keySkills:[],education:[]},a=e.slice(0,r[0].index).trim();return a&&i.overview.push(...YT(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=YT(e.slice(o,s).trim());if(!c.length)return;let l=HT.test(a)?`education`:UT.test(a)?`keySkills`:`overview`;i[l].push(...c)}),{meta:[],overview:KT(i.overview),keySkills:KT(i.keySkills),education:KT(i.education)}}function eE(e){let t=qT(e);if(!t)return{meta:[],overview:[],keySkills:[],education:[]};let n=JT(t);return n.length>=4?QT(n):$T(t)}function tE({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 nE({raw:e=``,meta:t=[]}){let[n,r]=(0,o.useState)(!1),i=(0,o.useMemo)(()=>eE(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)(RT,{type:`secondary`,children:`No description available.`});let c=n?s:s.slice(0,zT),u=s.length-zT;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)(tE,{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:rE}=s.Typography;function iE(e){return e?e.trim().split(/\s+/).slice(0,2).map(e=>e[0].toUpperCase()).join(``):`?`}function aE(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 oE(e){return e?e.email??e.emailId??e.emailAddress??``:``}function sE(e){return e?e.status?e.status:e.stage?e.stage:typeof e.isActive==`boolean`?e.isActive?`Active`:`Inactive`:``:``}function cE(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 lE=[`jobDescription`,`description`,`rawDescription`,`jobDescriptionText`];function uE(e){return String(e??``).toLowerCase()===`job`}function dE(e){let t=lE.includes(e.field),n=/description/i.test(e.label??``);return t||n}function fE({record:e}){let t=aE(e),n=oE(e),r=sE(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:iE(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 pE({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=uE(t)&&dE(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.Lt(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:cE(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)(nE,{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:cE(i)})]},e.field??e.label)})}),(0,l.jsx)(n.Cn,{documents:i,open:u,onClose:()=>d(!1),initialIndex:s})]})}function mE(){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.gn(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)(pE,{fields:e.fields,moduleName:t,centralDocuments:g}):(0,l.jsx)(rE,{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)(fE,{record:r}),j()]})})}var{Text:hE}=s.Typography,{TextArea:gE}=s.Input,_E=[{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 vE(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)(gE,{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 yE({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)(hE,{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)(hE,{type:`secondary`,children:`Please review the information above before submitting.`})]})]}):(0,l.jsx)(`div`,{className:`wizard-review-empty`,children:(0,l.jsx)(hE,{type:`secondary`,children:`No data entered yet.`})})}function bE(){let[e]=s.Form.useForm(),t=(0,d.useNavigate)(),{title:n=`Wizard`,moduleName:r=``,steps:i=_E,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:vE(e)})},e.name))})},e.key)),f.isReview&&(0,l.jsx)(yE,{steps:i,form:e})]})})]})}function xE({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 SE({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.Tn,{variant:`body`,color:`secondary`,className:`dynamic-popup__note`,children:e}),t&&(0,l.jsx)(n.Tn,{variant:`body`,className:`dynamic-popup__description`,children:t}),r&&i>0&&(0,l.jsxs)(n.Tn,{variant:`body`,className:`dynamic-popup__selected-count`,children:[`Changing status for `,(0,l.jsx)(`strong`,{children:i}),` selected `,a,`.`]}),o&&(0,l.jsx)(n.Tn,{variant:`body`,children:o}),s&&(0,l.jsx)(n.Tn,{variant:`caption`,color:`danger`,className:`dynamic-popup__error`,children:s})]})}function CE({footerNote:e}){return e?(0,l.jsx)(n.Tn,{variant:`caption`,color:`secondary`,className:`dynamic-popup__footer-note`,children:e}):null}function wE(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t?.[n]??``).trim()}function TE(e){return String(e).replace(/\(\s*\)/g,``).replace(/\s+/g,` `).replace(/(^|\s)([-–—·|])(?=\s*\2)/g,``).replace(/^[\s\-–—·|]+/,``).replace(/[\s\-–—·|]+$/,``).trim()}function EE(e){if(!e)return!1;let t=new Date(e).getTime();return Number.isNaN(t)||t<=0?!1:t<=Date.now()+864e5}function DE(e){if(!EE(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 OE(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 kE(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 AE(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:DE(OE(e))}:e,o=(i?TE(wE(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||kE(e);t&&(u.submittedAt=t)}if(e?.isFromSubmission===!0&&e?.submissionId){u.isFromSubmission=!0,u.priorSubmissionId=String(e.submissionId);let t=e?.lastSubmittedAt||kE(e);t&&(u.priorSubmittedAt=t)}return u}function jE(e,t){return(t?.[e.optionsKey]??e.defaultOptions??[]).map(t=>AE(t,e))}function ME(e={}){return{selectedIds:[],selectedRecords:[],moduleName:``,removedIds:[],...e}}var NE=`DD MMM YYYY`,PE=`DD MMM YYYY, h:mm A`;function FE(e,t){if(e==null||e===``)return``;let n=(0,u.default)(e);return n.isValid()?t===`relative`?DE(e)||(EE(e)?n.format(NE):`Not updated`):EE(e)?n.format(NE):``:String(e)}function IE(e,t){return e?String(e).includes(`{`)?TE(wE(e,t)):String(t?.[e]??e).trim():``}function LE(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(PE)}`:`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(PE)} — this form will prefill from it`:`Submitted to another job before — this form will prefill from it`}}return null}function RE(e,t){return e?.alreadySubmitted||!e?.disabled?``:String(t?.message??e?.title??``).trim()}function zE({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 BE({option:e,layout:t}){let n=e?._raw??e??{},r=IE(t.id,n),i=IE(t.title,n)||String(e?.label??``),a=IE(t.subtitle,n),o=IE(t.titleAccent?.key,n),u=IE(t.titleAccent?.toneKey,n),d=t.titleAccent?.prefix??``,f=(t.meta??[]).map(e=>({label:e.label,text:FE(n?.[e.key],e.type)})).filter(e=>e.text),p=RE(e,n),m=LE(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)(zE,{meta:f})]})}var{Text:VE}=s.Typography,{TextArea:HE}=s.Input,UE=[{label:`$`,value:`$`},{label:`EUR`,value:`EUR`},{label:`GBP`,value:`GBP`},{label:`INR`,value:`INR`}],WE=[{label:`Hourly`,value:`Hourly`},{label:`Daily`,value:`Daily`},{label:`Weekly`,value:`Weekly`},{label:`Monthly`,value:`Monthly`},{label:`Yearly`,value:`Yearly`}];function GE(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 KE({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 qE({field:e,value:t,onChange:n}){return(0,l.jsx)(HE,{value:t,onChange:n,rows:e.rows??5,placeholder:e.placeholder})}function JE({field:e,options:t,value:n,onChange:r}){let i=GE(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 YE({field:e,options:t,value:n,onChange:r}){let i=GE(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 XE({field:e,options:t,onSearch:n,value:r,onChange:i,popupContext:a}){let o=GE(t),u=e.optionLayout,d=new Map(o.map(e=>[String(e?.value??``),e]));async function f(t,n){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,{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)(BE,{option:e?.data??e,layout:u}):void 0,prefix:(0,l.jsx)(c.CrownOutlined,{})})}function ZE({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 QE({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:UE,onChange:e=>a({currency:e}),style:{width:80}}),(0,l.jsx)(s.Select,{value:r,options:WE,onChange:e=>a({period:e}),style:{width:110}})]}),(u||d)&&(0,l.jsxs)(`div`,{style:{marginTop:4},children:[u&&(0,l.jsx)(VE,{type:`danger`,style:{fontSize:12,display:`block`},children:`To rate must be greater than From rate.`}),d&&(0,l.jsxs)(VE,{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 $E({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 eD({field:e,checked:t,onChange:n}){return(0,l.jsx)(s.Checkbox,{checked:t,onChange:n,children:e.checkboxLabel})}function tD({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 nD({options:e,value:t,onChange:n}){return(0,l.jsx)(s.Radio.Group,{value:t,onChange:n,options:e})}var rD={input:KE,text:KE,textarea:qE,select:JE,"multi-select":YE,"search-select":XE,"mention-textarea":ZE,"candidate-rate":QE,"priority-checkbox":eD,"date-picker":$E,number:tD,radio:nD};function iD(e){return e===`priority-checkbox`?{valuePropName:`checked`}:{}}var aD=new Set([`input`,`text`,`textarea`,`mention-textarea`]);function oD({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.Tn,{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.Tn,{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:sD(t).map(e=>cD(e,e=>{let t=y(i[e.name]??jE(e,a)),r=p(e),o=m(e),c=h[e.name]??[],u=iD(e.type),d=rD[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()}}),aD.has(e.type)&&f.push(n.an({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 sD(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 cD(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 lD(e){return[`select`,`multi-select`,`search-select`,`radio`].includes(e?.type)&&e?.dataSource===`master`&&e?.masterName}function uD(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 dD(e){let t=String(e?.masterName??``).trim().toLowerCase();return t===`clientsubmissions`||t===`clientsubmissionstatus`}function fD(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 pD(e,t){return dD(t)?fD(e):AE(e,t)}function mD(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 hD(e){let t=Number(e?.id??0)||0,n=String(e?.text??``).trim();return n&&n.toLowerCase()===`not submitted`?!0:t<=0&&!n}function gD(e){return Number(e?._raw?.id??e?._raw?.uniqueId??0)||0}function _D(e){let t=e?._raw?.allowedNextStatusIds;return Array.isArray(t)?t.map(Number).filter(e=>Number.isInteger(e)&&e>0):[]}function vD(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 yD(e){return(Array.isArray(e?.selectedRecords)?e.selectedRecords.filter(Boolean):[]).some(e=>!hD(mD(e)))?!0:!hD(mD(e??{}))}async function bD(e,n){if(yD(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=vD(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 xD(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=mD(n);if(hD(i)){let e=mD(r);hD(e)||(i=e)}if(hD(i))return t?._raw?.isInitialStatus===!0;let a=e.find(e=>{let t=gD(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:_D(a).includes(gD(t))}))}function SD({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(lD);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=uD(t).map(t=>pD(t,e)).filter(Boolean),i=a;if(dD(e)&&(i=await bD(a,r)),o.signal.aborted)return;let s=dD(e)?xD(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 CD=500,wD=3;function TD({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=>AE(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??wD;return e=>{clearTimeout(c.current[t.name]);let r=e.length<n?``:e;c.current[t.name]=setTimeout(()=>{d(t,r)},CD)}}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 ED({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?.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?.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{if((await v(e))?.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 DD({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)(()=>ME(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}=SD({open:e,config:t,api:a,fields:x,popupContext:g,formValues:d}),{mentionOptions:E,getSearchHandler:D,getMentionSearchHandler:O}=TD({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}=ED({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,``),H=B===1?V:y,U=v[0]??{},ee=t?.getTitleText?t.getTitleText(B,H,U,g):t?.title,te=B===1?U.jobTitle??U.title??U.name??U.fullName??U.candidateName??null:null,ne=t?.getBodyText?t.getBodyText(B,V,H,te,g):t?.bodyText??null,re=typeof t?.getNote==`function`?t.getNote(g):t?.note,ie=t?.disabledUntilFilled&&!j&&!N;if(!t||!e||z)return null;let ae=t.component;return ae?(0,l.jsx)(s.Modal,{open:e,title:t.title||t.getTitleText?(0,l.jsx)(xE,{titleText:ee,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)(ae,{context:g,selectedIds:b,selectedRecords:v,moduleName:y,onClose:k})}):(0,l.jsxs)(s.Modal,{open:e,title:(0,l.jsx)(xE,{titleText:ee,titleIcon:t.titleIcon}),okText:t.okText||`OK`,cancelText:t.cancelText??`Cancel`,onOk:F,onCancel:()=>k(),okButtonProps:{danger:t.okButtonDanger,disabled:ie,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)(SE,{note:re,description:t.description,showSelectedCount:t.showSelectedCount,count:B,itemLabel:H,bodyText:ne,deleteError:L}),(0,l.jsx)(CE,{footerNote:t.footerNote}),(0,l.jsx)(oD,{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 OD={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:[]},kD={deleteItems:async(e,t)=>{await re(t.moduleName,e)}},AD=new Map;async function jD(e){return e?(AD.has(e)||AD.set(e,a.r({module:e}).catch(t=>(AD.delete(e),console.warn(`[in-progress gate] could not read ${e} form groups:`,t),[]))),AD.get(e)):[]}function MD(e=[],t){return e.some(e=>{let r=n.C(e,t);return r&&r.severity!==`allow`})}async function ND({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.zn().region;try{let i=await jD(e);if(!MD(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 PD=`Already submitted`,FD=`submissions`,ID=`candidates`,LD=864e5,RD=90,zD=`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.`,BD=[`createdAt`,`createdDate`,`dateCreated`,`created_on`,`createdOn`],VD=[`updatedAt`,`updatedDate`,`lastUpdatedAt`,`lastUpdatedDate`,`modifiedAt`,`modifiedDate`];function HD(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 UD(e){return HD(e,BD)}function WD(e){return HD(e,VD)}function GD(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))/LD))}function KD(e){return e===null?``:e<=14?`green`:e<=89?`yellow`:`red`}function qD(e,t=RD){if(!e)return!1;let n=Date.now()-t*LD,r=UD(e),i=WD(e),a=r&&r.getTime()>=n,o=i&&i.getTime()>=n;return!a&&!o}function JD(e){let t=UD(e);if(!t)return{createdAgo:``,createdAgoTone:``};let n=DE(t);return n?{createdAgo:n,createdAgoTone:KD(GD(t))}:{createdAgo:``,createdAgoTone:``}}function YD(e){return{...e,...JD(e),isStaleCandidate:qD(e)}}function XD(e){return String(e?.applicantId??e?._id??e?.id??``)}var ZD=null;async function QD(){return ZD||=n.Nr(ID).then(e=>e?.strategies?.duplicateCheck?.editRoute??``).catch(()=>``),ZD}async function $D(e){let t=XD(e);if(!t)return``;let n=await QD();return n?n.replace(/:(_?id)\b/g,encodeURIComponent(t)):``}async function eO({option:e,popupContext:t,confirm:n}){let r=e?._raw??e??{},i=XD(r);if(i){let e=await ND({targetModule:FD,sourceModule:ID,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(!qD(r))return!0;let a=t?.navigate;return!a||!i?!1:new Promise(e=>{n({title:`Candidate update required`,content:zD,okText:`OK`,cancelText:`Cancel`,onOk:async()=>{let t=await $D(r);t&&a(t),e(!1)},onCancel:()=>e(!1)})})}function tO(e,t,n){return{...e,label:`${e.label} - ${PD}`,disabled:!0,title:`${PD}${t?` (submission ${t})`:``}`,alreadySubmitted:!0,existingSubmissionId:t||``,...n?{submittedAt:n}:{}}}var nO={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 we({searchQuery:t,candidateId:r})}catch{a=!1;let e=await Rn({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 tO(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 Ee({applicantId:r,jobIds:o.map(e=>e.value)}).catch(()=>new Map);return o.map(e=>{let t=s.get(String(e.value));return t?tO(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 Te({search:t,jobId:r})}catch{let e=await Uo({isFromSubmission:n.isFromSubmission,jobId:r,submissionId:n.submissionId,search:t});i=Array.isArray(e)?e:[],a=await Ee({jobId:r,applicantIds:i.map(XD)}).catch(()=>new Map)}return i.map(e=>YD(e)).map(e=>{let t=a.get(XD(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:PD,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=>XD(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(qD(u?._raw))throw Error(zD);let p=await ND({targetModule:FD,sourceModule:ID,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 Ce({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=Bo(Ho({jobId:c,applicantId:l}).catch(()=>[]));return r(`/submission-create/${c}?${g.toString()}`,{state:{relevantSkillsToken:v}}),{navigated:!0}}},rO={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:eO}]},iO={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`}]},aO=e=>e?.data??e;async function oO({relatedId:e,notes:n,title:r,notesFor:i}){return aO(await bn(t.x,`/notes`,{method:`POST`,body:JSON.stringify({relatedId:e,notes:n,title:r,notesFor:i})}))}var sO={getMentionOptions:async(e,t)=>ae(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 oO({relatedId:String(n),notes:e.notes,notesFor:t.moduleName})}},cO={name:`jobId`,label:`Job Title / ID`,type:`search-select`,required:!0,placeholder:`Minimum 3 characters`,searchFetchKey:`tagToJobJobList`,valueKey:`_id`,labelTemplate:`{jobReferenceId} - {jobTitle}`},lO={name:`hiringStage`,label:`Hiring stage`,type:`select`,required:!0,optionsKey:`hiringStageOptions`,defaultOptions:[{label:`Shortlisted`,value:`shortlisted`},{label:`Pipeline`,value:`pipeline`}],initialValueKey:`hiringStage`},uO={title:`Tag to Job`,okText:`Tag`,width:480,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getFields:e=>e.jobId&&e.hiringStage?[]:e.jobId?[lO]:[cO,lO]},dO=e=>e?.data??e;function fO(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 pO(e){return e?Array.isArray(e.data)?e.data.map(fO):e.stage&&Array.isArray(e.stage.data)?e.stage.data.map(fO):Array.isArray(e)?e.map(fO):[]:[]}async function mO(e=1,n=10){let r=await t.o(t.x,`/workflow/list/all?page=${e}&limit=${n}`),i=dO(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 hO(e,n){let r=dO(await t.o(t.x,`/workflow/${e}/stage/${n}`));return Array.isArray(r)?{data:r}:r}async function gO(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=dO(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 _O(e){return dO(await t.o(t.C,`/source/workflow-instance`,{method:`POST`,body:JSON.stringify(e)}))}var vO={pipeline:`pipeline`,goodfited:`goodfited`,contacted:`contacted`,submitted:`submitted`,shortlisted:`shortlisted`,interviewinprogress:`interviewInprogress`,selected:`selected`};function yO(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 bO(e){let t=String(e??``).trim();return t?vO[t.toLowerCase()]??t:``}function xO(e,t){let n=yO(e,`candidateId`,`candidate_id`,`applicantId`,`applicantID`,`applicantReferenceId`,`applicantRefrenceId`,`_id`,`id`)??t;if(!n)return null;let r=(yO(e,`candidateName`,`candidate_name`,`fullName`,`name`)??[yO(e,`firstName`,`first_name`),yO(e,`lastName`,`last_name`)].filter(Boolean).join(` `))||void 0,i={candidateId:String(n),candidateName:r,phone:yO(e,`phone`,`phoneNumber`,`phone_number`,`mobile`,`mobileNumber`,`mobile_number`),source:yO(e,`source`,`sourceType`,`candidateSource`,`profileSource`),submittedAt:yO(e,`submittedAt`,`lastSubmittedAt`,`updatedAt`),remarks:yO(e,`remarks`,`comment`,`comments`,`notes`),assignedRecruiter:yO(e,`assignedRecruiter`,`recruiterName`,`ownerName`,`assignedToName`),screeningStatus:yO(e,`screeningStatus`,`screening.status`,`screeningResult`),screeningScore:yO(e,`screeningScore`,`screening.score`,`score`),assignedDate:yO(e,`assignedDate`,`assignedAt`,`createdAt`)};return Object.fromEntries(Object.entries(i).filter(([,e])=>e!=null&&e!==``))}var SO={searchOptions:async(e,t)=>e.searchFetchKey===`tagToJobJobList`?ie(t):[],submit:async(e,t)=>{let n=e.jobId??t.jobId,r=bO(e.hiringStage??t.hiringStage),i=Array.isArray(t.selectedIds)?t.selectedIds:[],a=Array.isArray(t.selectedRecords)?t.selectedRecords:[],o=Math.max(i.length,a.length,1);for(let e=0;e<o;e+=1){let t=i[e]?String(i[e]):``,o=xO(a[e]??{},t);await _O({jobId:n,module:`jobs`,currentStage:r,...o?{candidateDetails:o}:{}})}await se({jobId:n,candidateIds:t.selectedIds,hiringStage:r})}},CO={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 wO(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 TO={submit:async(e,t,n)=>{let r=wO(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 ne(t.moduleName,t.selectedIds,a)}},EO={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:[]},DO={onOk:async e=>{await De({jobId:e.jobId??e.selectedIds[0],candidateIds:e.selectedIds})}},OO={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`}]},kO={getOptions:async e=>e.fetchOptionsKey===`candidateGroups`?ce():[],submit:async(e,t,{dynamicOptions:n})=>{let r=(n.groupId??[]).find(t=>String(t.value)===String(e.groupId));await le({candidateIds:t.selectedIds,groupId:e.groupId,groupName:r?.label??``})}},AO=[{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 jO({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([de(n).catch(t=>(e||s.message.error(t?.message??`Failed to load self-assign details`),{assignedUsers:[],totalSubmissions:0,message:``})),me(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 ue({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:AO,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`})]})]})}jO.propTypes={selectedIds:f.default.array,onClose:f.default.func};var MO={title:`Self Assign`,width:480,className:`self-assign-modal`,component:jO},NO={submit:async()=>{}};function PO(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 FO={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=>(PO(e?.selectedRecords?.[0]??{}),[{name:`assignToUserId`,label:`Assign to`,type:`multi-select`,required:!0,placeholder:`Select recruiter(s)`,fetchOptionsKey:`assignToUsers`}])},IO={getOptions:async e=>e.fetchOptionsKey===`assignToUsers`?pe():[],loadExtraData:async e=>me(e.selectedIds[0]),submit:async(e,t,{removedIds:n,extraData:r})=>{await ve({jobIds:t.selectedIds,userId:e.assignToUserId,removedIds:n,existingRecruiters:r?.recruitersData})}},LO={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`}]},RO={getMentionOptions:async(e,t)=>ae(t),submit:async(e,t)=>{let n=e.targetDate?e.targetDate.toISOString():``;t.editingNoteId?await G(t.editingNoteId,{title:e.heading,targetDate:n,notes:e.comments}):await W({relatedIds:t.selectedIds,module:t.moduleName,title:e.heading,targetDate:n,notes:e.comments}),window.dispatchEvent(new Event(`sticky-notes:refresh`))}},zO={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`}]},BO={submit:async(e,t)=>{await ye({submissionId:t.selectedRecords?.[0]?.submissionId,isMail:e.sendOnboardingEmail})}};function VO(e){return Array.isArray(e)?e[e.length-1]??{}:e&&typeof e==`object`?e:{}}var HO={USD:`$`,INR:`₹`,EUR:`€`,GBP:`£`};function UO(e,t,n){let r=VO(e?.[t])[n];if(r!=null&&r!==``)return r;let i=e?.[`${t}.${n}`];return i!=null&&i!==``?i:void 0}function WO(e){let t=e.selectedRecords?.[0]??{},n=UO(t,`candidateRate`,`candidateAcceptedRate`)??UO(t,`candidateBudget`,`candidateBudgetStart`);if(n===void 0||Number(n)===0)return null;let r=UO(t,`candidateRate`,`candidateAcceptedCurrency`)??UO(t,`candidateBudget`,`candidateBudgetCurrency`);return{amount:n,symbol:UO(t,`candidateRate`,`candidateAcceptedCurrencySymbol`)??UO(t,`candidateBudget`,`candidateBudgetCurrencySymbol`)??HO[String(r??``).toUpperCase()]??(r||`$`),unit:UO(t,`candidateRate`,`candidateAcceptedPayUnit`)??UO(t,`candidateBudget`,`candidateBudgetUnit`)??``}}var GO={title:`Approve Rate`,okText:`Approve`,width:520,className:`medium-modal`,successMessage:`Rate approved`,getBodyText:(e,t,n,r,i)=>{let a=WO(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=WO(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`}]}]},KO={submit:async(e,t)=>{let n=t.selectedIds[0];if(await be(n,{candidateProposedRate:e.candidateProposedRate,candidateProposedRateCurrency:e.candidateProposedRateCurrency,candidateProposedRateUnit:e.candidateProposedRateUnit,submitVia:e.submitVia}),e.submitVia===`VMS`)try{await xe(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 qO(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 JO(e){let t=await qO(`/mail-form?${new URLSearchParams({submissionId:e,submissionType:`manager`}).toString()}`);return t.data??t}function YO(e){return Array.isArray(e)?e[e.length-1]:e}function XO(e={}){let t=YO(e?.proposedRate)?.candidateProposedRate??e?.candidateProposedRate??e?.proposedRateValue,n=Number(t);return Number.isFinite(n)?n:0}function ZO(e,t={}){let n=YO((e?.record?.job??e?.job??t?.job??{})?.jobPayDetails)??{},r=e?.record?.submission??t??{},i=YO(r?.clientBudget)??r?.clientBudget??{},a=n?.clientBudgetEnd??n?.clientBudgetStart??i?.clientBudgetEnd??i?.clientBudgetStart,o=Number(a);return Number.isFinite(o)?o:0}function QO(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 $O(e={}){return String(e?.rateUnit??`hr`).trim().replace(/^\/+/,``)||`hr`}function ek(e,t={}){let n=Number(e);return Number.isFinite(n)?`${QO(t)}${n}/${$O(t)}`:``}function tk(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 nk(e,t,n,r,i){let a=Number(n?.proposedRate),o=Number.isFinite(a)?a:XO(t),s=Number(n?.clientJobRate),c=Number.isFinite(s)&&s>0?s:ZO(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=tk(u,`(?:Proposed\\s*Rate|Pay\\s*Rate)`,ek(o,n)),u=tk(u,`(?:Job\\s*)?Bill\\s*Rate`,ek(c,n)),u}function rk(...e){return e.map(e=>e==null?``:String(e).trim()).find(Boolean)??``}var ik=(e,t)=>!!e&&e.toLowerCase()===rk(t).toLowerCase();function ak(e,t,n){let r=rk(t.submittedBy);return rk(ik(r,n)||ik(r,e.submitSource)||ik(r,e.supplierName)||ik(r,e.source)||ik(r,e.candidateSource)?``:r,e.signatureEmail)}function ok(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:ak(e,t,n),submittedAt:t.createdAt??e.createdAt,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function sk(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 ck(...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(sk).find(Boolean);if(e)return e}return``}function lk(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 uk(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 dk(...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(sk).find(Boolean);if(e)return e}return``}async function fk(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 pk(e,r,i){let a=[],o=await n.gn(`submissions`,e,`resume`).catch(()=>({data:[]}));a.push(...o?.data??[]);let s=dk(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=dk((Array.isArray(r?.data)?r.data:Array.isArray(r)?r:[])[0])}if(s){let e=await n.gn(`candidates`,s,`resume`).catch(()=>({data:[]}));a.push(...e?.data??[])}let c=(await Promise.all(a.map(fk))).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 mk(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:uk(e.content?.value??e.Content?.Value??e.contents??e.body??``)}}function hk({context:e,selectedIds:t,selectedRecords:n,moduleName:r,onClose:i}){let a=n?.[0]??{},c=t?.[0]??Bg(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 D_(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 I_().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([JO(c).then(mk),pk(c,u,a).catch(e=>(console.warn(`Unable to resolve resume attachment:`,e),[]))]),n=u?.record?.submission??a;N({to:nk(e.to,n,b,u,a),cc:nk(e.cc,n,b,u,a),bcc:nk(e.bcc,n,b,u,a),subject:nk(e.subject,n,b,u,a),contents:nk(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 be(c,{candidateProposedRate:b.proposedRate,candidateProposedRateCurrency:b.currencyRaw??b.currency,candidateProposedRateUnit:b.rateUnit,submitVia:`VMS`,...lk(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&&lT(M.to).length>0&&uT(M.to)&&uT(M.cc)&&uT(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 be(c,{...e,submitVia:`VMS`,...lk(S)});let t=ck(u?.record,a);if(!t)s.message.warning(`Submission approved, but job details were not available to send mail`);else try{await mn({jobId:t,toMail:lT(M.to),ccMail:lT(M.cc),bccMail:lT(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)(g_,{type:mg,record:u.record,lookups:u.lookups,identity:ok(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)(ST,{value:M,onChange:N,moduleName:`submissions`,ready:!O,title:`Submit Via Mail`,contextRecords:[u.record?.submission??a]})})]})}hk.propTypes={context:f.default.object,selectedIds:f.default.array,selectedRecords:f.default.array,moduleName:f.default.string,onClose:f.default.func};var gk={title:`Manager Approve`,width:780,className:`fa-modal manager-approve-modal`,component:hk},_k={submit:async()=>{}};function vk(...e){return e.map(e=>e==null?``:String(e).trim()).find(Boolean)??``}var yk=(e,t)=>!!e&&e.toLowerCase()===vk(t).toLowerCase();function bk(e,t,n){let r=vk(t.submittedBy);return vk(yk(r,n)||yk(r,e.submitSource)||yk(r,e.supplierName)||yk(r,e.source)||yk(r,e.candidateSource)?``:r,e.signatureEmail)}function xk(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:bk(e,t,n),submittedAt:t.createdAt??e.createdAt,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function Sk(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 Ck(e){return String(e??``).toLowerCase().replace(/\b\w/g,e=>e.toUpperCase())}function wk({selectedIds:e,selectedRecords:t,onClose:r}){let i=t?.[0]??{},a=e?.[0]??Bg(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([D_(a,i),n.un(`submission`,a).catch(()=>[])]).then(([t,n])=>{if(e)return;let r=Sk(n);f(Bg(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?Ck(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 K(d,{submissionId:a,billRate:e.proposedRate,payRate:e.employerRate,currency:e.currencyRaw??e.currency,rateUnit:e.rateUnit,vmsPercent:e.clientVmsPercent}),await be(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)(g_,{type:vg,record:c.record,lookups:c.lookups,identity:xk(i,c.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:h,onClose:()=>r?.(),variant:`popup`})}wk.propTypes={selectedIds:f.default.array,selectedRecords:f.default.array,onClose:f.default.func};var Tk={title:`Re-Approve`,width:780,className:`fa-modal manager-approve-modal`,component:wk},Ek={submit:async()=>{}},Dk=[{id:1,name:`Re-Submission`},{id:2,name:`Candidate doesn't fit into the profile`},{id:3,name:`Incomplete candidate details - (Re-Submission)`}],Ok={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:Dk.map(e=>({label:e.name,value:e.id}))},{name:`rejectReasonComments`,label:`Comments`,type:`textarea`,required:!0,rows:4}]},kk={submit:async(e,t)=>{let n=Dk.find(t=>String(t.id)===String(e.rejectReason));await Se({submissionId:t.selectedIds[0],rejectReasonId:e.rejectReason,rejectReason:n?.name??``,rejectReasonComments:e.rejectReasonComments})}},Ak={delete:OD,"quick-submit":rO,"add-notes":iO,"tag-to-job":uO,"change-status":CO,"remove-from-shortlist":EO,"add-to-groups":OO,"self-assign":MO,"others-assign":FO,"sticky-notes":LO,"move-to-onboarding":zO,"approve-rate":GO,"manager-approve":gk,"manager-reapprove":Tk,reject:Ok},jk={delete:kD,"quick-submit":nO,"add-notes":sO,"tag-to-job":SO,"change-status":TO,"remove-from-shortlist":DO,"add-to-groups":kO,"self-assign":NO,"others-assign":IO,"sticky-notes":RO,"move-to-onboarding":BO,"approve-rate":KO,"manager-approve":_k,"manager-reapprove":Ek,reject:kk};function Mk(e){let t=e?.data??e;return Array.isArray(t)?t:t?.data??t?.rows??t?.records??t?.items??t?.list??[]}function Nk(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 Pk(e){let t=String(Nk(e,`isDeleted`,`deleted`)).toLowerCase(),n=String(Nk(e,`assignmentStatus`,`status`)).toLowerCase();return t!==`true`&&t!==`1`&&![`removed`,`inactive`,`deleted`].includes(n)}function Fk(e){let t=Nk(e,`candidateName`,`candidate_name`,`fullName`,`name`);return t?String(t):[Nk(e,`firstName`,`first_name`),Nk(e,`lastName`,`last_name`)].filter(Boolean).join(` `)||`Unnamed candidate`}function Ik(e){return String(Nk(e,`candidateId`,`candidate_id`,`candidate._id`,`candidate.id`))}function Lk(e){return String(Nk(e,`workforceEngagementId`,`engagementId`,`_id`,`id`))}function Rk(e){return String(Nk(e,`batchName`,`name`,`title`,`batch_name`))}function zk({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.yn(`onboarding`,200,0),n.yn(`batchCandidates`,1e3,0).catch(()=>[])]))).then(([e,n])=>{t||(c(Mk(e)),x(new Map(Mk(n).filter(Pk).map(e=>[String(Nk(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=>[Fk(t),Nk(t,`email`,`candidateEmail`,`candidate_email`),Nk(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(Lk(e)));if(!e.length)return;let o=e.map(e=>({record:e,assignment:b.get(Ik(e))})).filter(e=>e.assignment);if(o.length){let e=o.map(({record:e})=>Fk(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=Rk(r.selectedRecords?.[0])||Rk(r);await Promise.all(e.map(e=>n.Xn(`batchCandidates`,{schemaVersion:1,batchId:S,batchName:o,candidateId:Ik(e),workforceEngagementId:Lk(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=>Lk(e),columns:[{title:`Candidate`,key:`candidate`,render:(e,t)=>Fk(t)},{title:`Email`,key:`email`,render:(e,t)=>Nk(t,`email`,`candidateEmail`,`candidate_email`)||`—`},{title:`Onboarding status`,key:`status`,render:(e,t)=>Nk(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(Ik(e));return{disabled:!Ik(e)||!Lk(e)||!!t,title:t?`Candidate is already added to a batch`:void 0}}},locale:{emptyText:m?`Loading candidates…`:`No onboarding candidates found`}})]})}var Bk={text:`input`,string:`input`,textarea:`textarea`,date:`date-picker`,datepicker:`date-picker`,multiselect:`multi-select`,lookup:`search-select`};function Vk(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:Bk[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=Hk(e.successNavigate);return{title:e.label,fields:t,...n?{successNavigate:n}:{}}}function Hk(e){let t=String(e??``).trim();return!t||!t.startsWith(`/`)||t.startsWith(`//`)||/^[a-z][a-z0-9+.-]*:/i.test(t)?null:t}function Uk(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 Wk({apiMap:e={},extraConfigs:r={}}){let i=(0,o.useMemo)(()=>({...jk,...e}),[e]),a=(0,o.useMemo)(()=>{let e={...Ak};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.xr(u.moduleName,`popup`,s).then(n=>{e||p({key:t,config:Vk(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 Uk(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)(zk,{open:!0,context:h,onClose:_}):(0,l.jsx)(DD,{open:!0,config:m,context:h,onClose:_,api:{...i[s]??{},...g}})}var Gk={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`}]},Kk={getVendorList:({jobId:e,limit:t,offset:n,type:r})=>dn({jobId:e,limit:t,offset:n,sortBy:`new`,type:r}),getMailDetails:e=>fn(e),submit:({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})=>mn({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})},qk=Gk.vendorColumns.map(e=>({...e,render:e=>e||`-`}));function Jk(){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)(Gk.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)(Gk.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 Kk.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&&Kk.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([...lT(h.bcc),...z])].join(`, `),showBcc:h.showBcc||z.length>0}),[h,z]);function V(e){let t=new Set(z);g({...e,bcc:lT(e.bcc).filter(e=>!t.has(e)).join(`, `)})}let H=(lT(B.to).length||lT(B.bcc).length)&&uT(B.to)&&uT(B.cc)&&uT(B.bcc)&&B.subject.trim(),U=e=>e===`myVendor`?T:D;function ee(){e(-1)}function te(){H&&Kk.submit({jobId:m,toMail:lT(B.to),ccMail:lT(B.cc),bccMail:lT(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 ne=(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:ee,closable:!1,rootClassName:`vendor-share`,width:`95%`,footer:(0,l.jsxs)(`div`,{className:`vendor-share__footer`,children:[(0,l.jsx)(s.Button,{onClick:ee,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,disabled:!H,onClick:te,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:ee,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:Gk.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,` (`,U(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:qk,dataSource:ne,loading:F,pagination:!1,size:`small`,rowSelection:{selectedRowKeys:L,onChange:e=>{e.length>Gk.maxVendorSelect||R(e)}},scroll:{y:`calc(100vh - 340px)`}})}),(0,l.jsx)(`div`,{className:`vendor-share__vendor-footer`,children:(0,l.jsx)(Re,{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)(ST,{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,` / `,Gk.maxVendorSelect,` Vendors selected`]}):null})})]})})}var Yk={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].*$/},Xk={SINGLE_FILE_COUNT:1,MULTI_FILE_COUNT:5,MAX_FILE_SIZE:2,ALLOWED_FILE_TYPES:[`image/jpeg`,`image/png`,`application/pdf`]},Zk={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 ${Xk.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.`},Qk={FIRST_NAME_MIN:3,FIRST_NAME_MAX:30},$k={REMARKS_MIN:10,REMARKS_MAX:250},eA={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)}`}},tA={required:(e=`Field`)=>({required:!0,message:Zk.REQUIRED(e)}),email:()=>({pattern:Yk.EMAIL,message:Zk.INVALID_EMAIL}),phone:()=>({pattern:Yk.PHONE,message:Zk.INVALID_PHONE}),password:()=>({pattern:Yk.PASSWORD,message:Zk.INVALID_PASSWORD}),alphabets:()=>({pattern:Yk.ALPHABETS,message:Zk.INVALID_ALPHABETS}),alphanumeric:()=>({pattern:Yk.ALPHANUMERIC,message:Zk.INVALID_ALPHANUMERIC}),number:()=>({pattern:Yk.NUMBER,message:Zk.INVALID_NUMBER}),url:()=>({pattern:Yk.URL,message:Zk.INVALID_URL}),candidateId:(e=`ID`)=>({pattern:Yk.CANDIDATE_ID,message:Zk.INVALID_CANDIDATE_ID(e)}),remarks:()=>({pattern:Yk.REMARKS,message:Zk.INVALID_REMARKS,REMARKS_MIN:`Remarks must be at least ${$k.REMARKS_MIN} characters.`,REMARKS_MAX:`Remarks must not exceed ${$k.REMARKS_MAX} characters.`}),designation:()=>({pattern:Yk.DESIGNATION,message:Zk.INVALID_DESIGNATION}),dob:(e=!0)=>({validator:(t,n)=>{if(!n)return e?Promise.reject(Error(`Date of Birth is required.`)):Promise.resolve();if(!Yk.DOB.test(n))return Promise.reject(Error(Zk.INVALID_DOB));let r=(0,u.default)(n,`MM/DD/YYYY`,!0);if(!r.isValid())return Promise.reject(Error(Zk.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:Yk.LINKEDIN,message:Zk.INVALID_LINKEDIN}),companyName:()=>({pattern:Yk.COMPANY_NAME,message:Zk.INVALID_COMPANY_NAME}),firstName:()=>({pattern:Yk.FIRST_NAME,message:Zk.INVALID_FIRST_NAME,FIRST_NAME_MIN:`First Name must be at least ${Qk.FIRST_NAME_MIN} characters.`,FIRST_NAME_MAX:`First Name must not exceed ${Qk.FIRST_NAME_MAX} characters.`}),firstNameMinLength:()=>({min:Qk.FIRST_NAME_MIN,message:Zk.FIRST_NAME_MIN}),firstNameMaxLength:()=>({max:Qk.FIRST_NAME_MAX,message:Zk.FIRST_NAME_MAX}),remarksMinLength:()=>({min:$k.REMARKS_MIN,message:Zk.REMARKS_MIN}),remarksMaxLength:()=>({max:$k.REMARKS_MAX,message:Zk.REMARKS_MAX}),fullName:()=>({pattern:Yk.FULL_NAME,message:Zk.INVALID_FULL_NAME}),noSpaces:()=>({pattern:Yk.NO_SPACES,message:Zk.NO_SPACES_ALLOWED}),startsWithCapital:()=>({pattern:Yk.STARTS_WITH_CAPITAL,message:Zk.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<=Xk.MAX_FILE_SIZE))return s.message.error(Zk.INVALID_FILE_SIZE),Promise.reject(Error(Zk.INVALID_FILE_SIZE));if(!Xk.ALLOWED_FILE_TYPES.includes(t.type))return Promise.reject(Error(Zk.INVALID_FILE_TYPE))}return Promise.resolve()}}),singleFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>Xk.SINGLE_FILE_COUNT)return Promise.reject(Error(Zk.SINGLE_FILE_ONLY));let n=t[0];return n.size/1024/1024<Xk.MAX_FILE_SIZE?Xk.ALLOWED_FILE_TYPES.includes(n.type)?Promise.resolve():Promise.reject(Error(Zk.INVALID_FILE_TYPE)):Promise.reject(Error(Zk.INVALID_FILE_SIZE))}}),multiFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>Xk.MULTI_FILE_COUNT)return Promise.reject(Error(Zk.INVALID_FILE_COUNT));for(let e of t){if(!(e.size/1024/1024<Xk.MAX_FILE_SIZE))return Promise.reject(Error(Zk.INVALID_FILE_SIZE));if(!Xk.ALLOWED_FILE_TYPES.includes(e.type))return Promise.reject(Error(Zk.INVALID_FILE_TYPE))}return Promise.resolve()}})},nA={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)},rA=()=>{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:[tA.required(`Email`),tA.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:[tA.required(`Phone Number`),tA.phone()],validateTrigger:[`onBlur`,`onChange`],children:(0,l.jsx)(s.Input,{maxLength:10,onChange:t=>{e.setFieldsValue({phone:eA.phoneFormatter(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Password`,name:`password`,rules:[tA.required(`Password`),tA.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:[tA.required(`Full Name`),tA.alphabets(),tA.firstNameMinLength(),tA.firstNameMaxLength()],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({fullName:eA.firstNameFormatter(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Username`,name:`username`,rules:[tA.required(`Username`),tA.alphanumeric()],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({username:eA.removeExtraSpaces(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Website URL`,name:`website`,rules:[tA.required(`Website URL`),tA.url()],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({website:eA.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:[tA.required(`MSP Req ID`),tA.candidateId(`MSP Req ID`)],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({mspreqID:eA.removeExtraSpaces(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Candidate ID`,name:`candidateId`,rules:[tA.required(`Candidate ID`),tA.candidateId(`Candidate ID`)],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({candidateId:eA.removeExtraSpaces(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:24,children:(0,l.jsx)(s.Form.Item,{label:`Remarks`,name:`remarks`,rules:[tA.required(`Remarks`),tA.remarks(),tA.remarksMinLength(),tA.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:[tA.required(`Designation`),tA.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:[tA.dob()],children:(0,l.jsx)(s.Input,{placeholder:`MM/DD/YYYY`,maxLength:10,onChange:t=>{e.setFieldsValue({dob:eA.dobFormatter(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Company Name`,name:`companyName`,rules:[tA.required(`Company Name`),tA.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:nA.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:[tA.multiFileUpload()],children:(0,l.jsx)(s.Upload,{multiple:!0,beforeUpload:nA.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:[tA.fileUpload()],children:(0,l.jsx)(s.Upload,{beforeUpload:nA.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 iA(e){return(0,l.jsx)(Kv,{children:(0,l.jsx)(iT,{...e})})}var{Text:aA}=s.Typography,oA=[{label:`Total Jobs`,value:1697,icon:`fileText`},{label:`Active Jobs`,value:1685,icon:`checkCircle`},{label:`My Jobs`,value:600,icon:`user`}],sA={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 cA({stats:e=oA}){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:[sA[e.icon]??sA.fileText,(0,l.jsx)(aA,{children:e.label})]}),(0,l.jsx)(s.Statistic,{value:e.value})]})},e.label))})})}var{Text:lA}=s.Typography;function uA(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 dA(e){return{...e,key:e.USER_ID??e.user_id??e.userId??e.id??e._id,_name:uA(e),_email:e.email??e.EMAIL??e.user_email??``,_role:e.role_name??e.roleName??e.ROLE_NAME??``,_rawRef:e}}function fA(){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.mr({offset:e,limit:r,searchQuery:a??``}),s=(o.users??[]).map(dA);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)(vm,{listName:`Users`,dataSource:e,fields:[{label:`Name`,value:`_name`,width:220,render:(e,t)=>(0,l.jsxs)(`div`,{children:[(0,l.jsx)(lA,{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:pA}=s.Typography,mA=[{key:`job`,label:`Jobs`},{key:`candidate`,label:`Candidates`},{key:`submissions`,label:`Submissions`}],hA=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`}];function gA({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 _A({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.Wr(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.hi(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:mA.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)(gA,{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 `,mA.find(e=>e.key===f)?.label]})})]})}function vA(){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.pr();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.mi(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)(vm,{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:hA.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)(_A,{team:e,configType:d},`${e?.teamId}-${d}`)]})]})}var yA=[`view`,`add`,`edit`,`delete`],bA={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 xA(e){return bA[e]??e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function SA(e){let t=yA.filter(t=>e.includes(t)),n=e.filter(e=>!yA.includes(e)).sort();return[...t,...n]}function CA(e){let t=new Set;return Object.values(e).forEach(({permissions:e})=>Object.keys(e??{}).forEach(e=>t.add(e))),SA([...t])}function wA(e){let t=0,n=0;return Object.entries(e).forEach(([e,{permissions:r}])=>{Object.entries(r??{}).forEach(([r,{value:i}])=>{nb(e,r)&&(n++,i===`1`&&t++)})}),{enabled:t,total:n}}function TA(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 EA({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 DA({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 OA({menuName:e,menuData:t,permKeys:n,onChange:r,displayName:i,actionLabels:a,onModuleLabelSave:o,onActionLabelSave:s}){let c=t?.permissions??{},u=n.filter(t=>nb(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)(EA,{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)(DA,{entry:c[t],label:a[t]??xA(t),onToggle:()=>r(e,t),onLabelSave:e=>s(t,e)},t))})]})}function kA({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.zr(e);(0,o.useEffect)(()=>{b&&(h(!0),y(!1),n.Hr(b).then(e=>{let t=TA(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.fi(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)(()=>CA(f),[f]),{enabled:T,total:E}=(0,o.useMemo)(()=>wA(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)(OA,{menuName:e,menuData:f[e],permKeys:w,onChange:x,displayName:t[e]??e,actionLabels:r,onModuleLabelSave:i,onActionLabelSave:a},e))})]})}var{Text:AA}=s.Typography,jA=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`}];function MA(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function NA(e){return String(e||``).trim().toLowerCase()}function PA(e){return e?.key||e?.collectionName||e?.value||``}function FA(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=PA(e);if(!t)return;let o=NA(e.key||t),s=NA(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||MA(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=NA(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:MA(t),value:t,disabled:!1}))}),n}function IA(){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.fr();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.wr(),n.gr()]),r=FA(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.ri(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)(AA,{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)(vm,{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:jA.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)(kA,{role:e},e?.roleId):(0,l.jsx)(yb,{role:e,configType:a},`${e?.roleId}-${a}`))]})]})}var LA=`perm-module-labels`,RA=`perm-action-labels`;function zA(e){try{return JSON.parse(localStorage.getItem(e)??`{}`)}catch{return{}}}function BA(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function VA({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 HA({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.jr())}catch{s.message.error(`Failed to load modules`)}finally{f(!1)}}async function O(){b(!0);try{v(await n.Ar())}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.Jn({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.ci(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.rr(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.qn({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.si(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.nr(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)(VA,{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)(VA,{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 UA(){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)(()=>zA(LA)),[_,v]=(0,o.useState)(()=>zA(RA)),y=(0,o.useCallback)((e,t)=>{g(n=>{let r={...n,[e]:t};return BA(LA,r),r})},[]),b=(0,o.useCallback)((e,t)=>{v(n=>{let r={...n,[e]:t};return BA(RA,r),r})},[]);function x(){g({}),v({}),BA(LA,{}),BA(RA,{}),s.message.success(`Labels reset to defaults`)}let S=(0,o.useCallback)(async()=>{i(!0);try{let{roles:e}=await n.fr();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)(kA,{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)(HA,{open:p,onClose:()=>m(!1)})]})}var{Title:WA,Text:GA}=s.Typography,KA=[{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 qA({items:e=KA}){return(0,l.jsx)(s.Card,{className:`onboarding-card`,title:(0,l.jsx)(WA,{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)(GA,{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)(GA,{className:`onboarding-item-sub`,children:e.sub})})]})},e.label))})})}var{Text:JA,Title:YA}=s.Typography,XA=[{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.`}]}]}],ZA=[{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}],QA=[{name:`Tcs`,jobs:14,candidates:86},{name:`Empasis`,jobs:9,candidates:64},{name:`NovaSystems`,jobs:7,candidates:51},{name:`Brightwave`,jobs:5,candidates:38}],$A=[{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 ej(){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)(YA,{level:5,children:`Admin Dashboard`}),(0,l.jsx)(JA,{type:`secondary`,children:`Overview of jobs, candidates, onboarding and recent activity`})]}),(0,l.jsx)(`div`,{className:`admin-dashboard-stats`,children:(0,l.jsx)(cA,{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)(qA,{}),(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.AppstoreOutlined,{}),title:`Candidate Pipeline`,children:[(0,l.jsx)(JA,{type:`secondary`,style:{fontSize:12},children:`By stage (892 total)`}),(0,l.jsx)(`div`,{className:`admin-pipeline-bar`,children:ZA.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:ZA.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)(JA,{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)(JA,{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)(JA,{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)(JA,{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:QA.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:$A.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)(JA,{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)(JA,{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)(JA,{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)(JA,{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)(JA,{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)(JA,{style:{fontSize:12},children:e}),(0,l.jsx)(JA,{strong:!0,style:{fontSize:12},children:t})]},e))]})]})})]})}function tj({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)(YA,{level:5,children:e?.heading}),(0,l.jsx)(JA,{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)(JA,{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:XA.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 nj(){let[e,t]=(0,o.useState)(`dashboard`),[n,r]=(0,o.useState)(``),i=(0,o.useMemo)(()=>XA.flatMap(e=>e.items),[]),a=(0,o.useMemo)(()=>i.find(t=>t.id===e),[i,e]),u=(0,o.useMemo)(()=>XA.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)(()=>XA.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:XA.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)(ej,{}):a?.component===`form-groups`?(0,l.jsx)(dS,{}):a?.component===`detail-groups`?(0,l.jsx)(RS,{}):a?.component===`row-actions`?(0,l.jsx)(DC,{}):a?.component===`users`?(0,l.jsx)(fA,{}):a?.component===`teams`?(0,l.jsx)(vA,{}):a?.component===`roles`?(0,l.jsx)(IA,{}):a?.component===`permissions`?(0,l.jsx)(UA,{}):a?.component===`templates`?(0,l.jsx)(zC,{}):a?.component===`ai-services`?(0,l.jsx)(UC,{}):a?.component===`bgc-integration`?(0,l.jsx)(YC,{}):(0,l.jsx)(tj,{activeSection:a,activeGroup:u,filteredCards:d,searchText:n,setSearchText:r,allItems:i,handleNav:p})})]})]})}var{Title:rj}=s.Typography;function ij(){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:aj,Title:oj}=s.Typography,sj=10485760,cj=`/templates/test_cases_flow_template.base64.txt`,lj=`test_cases_flow_template.xlsx`,uj=`module | subModule | step_order | description | actions | key | value | expected | scenario`,dj={idle:0,module_set:1,encoding:1,validating:2,preview:3,inserting:3,done:4,error:1},fj=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Bulk upload`,href:`/bulk-upload`}];function pj(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 mj(e){return e.filter(e=>e.row_status===`valid`).map(e=>{let t={...e};return delete t.row_status,delete t.errors,t})}function hj(e){return e.flatMap(e=>(e.errors??[]).map(t=>({id:e.id,...t})))}function gj({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 _j({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 vj({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)(aj,{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)(gj,{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 yj(){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=hj(x),N=h===`encoding`||h===`validating`,P=!!p&&!N,F=dj[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 ly({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>sj){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 pj(e);g(`validating`);let i=await iy({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(cj);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=lj,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 ay({project:r?.name??``,module:p,uploaded_by:localStorage.getItem(`user_Email`)??``,rows:mj(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`)}},H=(0,o.useCallback)(()=>{a.current?.scrollIntoView({behavior:`smooth`,block:`center`})},[]),U=[`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:fj})}),r?.name&&(0,l.jsx)(s.Col,{children:(0,l.jsx)(aj,{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)(oj,{level:3,children:`Bulk upload test cases`}),(0,l.jsxs)(s.Space,{direction:`vertical`,size:4,children:[(0,l.jsx)(aj,{type:`secondary`,children:uj}),(0,l.jsx)(aj,{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:U,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)(_j,{errors:M,expanded:k,onToggle:()=>A(e=>!e),onSummaryClick:H}),T&&h===`preview`&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`}),(0,l.jsx)(vj,{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)(aj,{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)(aj,{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)(aj,{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 bj=[{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:xj}=s.Typography,Sj=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}],Cj={tags:`regression`,active:1},wj={module:{dbName:`Modules`,formField:`module`,label:`Module`}};function Tj(e=[]){return e.map(e=>({value:e,label:e}))}function Ej(e=``){return String(e??``).trim()}function Dj(e=``){return Ej(e).toLowerCase()}function Oj(e=[]){let t=new Map;return e.forEach(e=>{let n=Ej(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function kj(e=[],t,n){let r=Ej(t).toLowerCase(),i=Ej(n).toLowerCase();return e.reduce((e,t)=>{let n=Ej(t?.module).toLowerCase(),a=Ej(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 Aj({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)(xj,{strong:!0,className:`v1-section-label`,children:t})]})}function jj(){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=wj[v.typeKey],O=(0,o.useMemo)(()=>Tj(r),[r]),k=s.Form.useWatch(`module`,e),A=s.Form.useWatch(`flow`,e),j=!!Ej(k),M=!!Ej(A),N=!j,P=!j||!M,F=(e,t=[])=>{e===`module`&&i(t)},I=async()=>{h(!0);try{let e=await $v(wj.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=Ej(t);if(u([]),p([]),e.setFieldsValue({step_order:void 0}),n){_(!0);try{let e=await ry({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];u(t),p(Oj(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=Ej(t),a=Ej(n);if(!i||!a){e.setFieldsValue({step_order:void 0});return}C(!0);try{e.setFieldsValue({step_order:kj(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:Ej(t.module),flow:Ej(t.flow),step_order:Number(t.step_order),description:Ej(t.description),keyword:Dj(t.keyword),target:Ej(t.target),value:Ej(t.value),expected:Ej(t.expected),tags:t.tags?Ej(t.tags):Cj.tags,active:Number(t.active)};T(!0);try{await ny(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]:Ej(n)})},V=t=>{e.setFieldsValue({module:Ej(t),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:Cj.tags,value:void 0,expected:void 0})},H=t=>{e.setFieldsValue({flow:Ej(t),step_order:void 0})},U=e=>{let n=wj[e];y({open:!0,typeKey:e}),t.setFieldsValue({name:``,type:n.label})},ee=()=>{y(e=>({...e,open:!1})),t.resetFields()},te=async()=>{try{let n=Ej((await t.validateFields()).name),r=await ey({name:n,type:D.dbName});F(v.typeKey,r?.items??[]),e.setFieldsValue({[D.formField]:n}),s.message.success(`${D.label} added successfully.`),ee()}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:Sj})}),(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)(xj,{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:Cj,onFinish:z,autoComplete:`off`,children:[(0,l.jsx)(s.Card,{className:`v1-card`,title:(0,l.jsx)(Aj,{icon:(0,l.jsx)(c.FileTextOutlined,{}),title:`Test Case Details`}),extra:(0,l.jsx)(xj,{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:()=>U(`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:H,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:bj,onChange:t=>e.setFieldsValue({keyword:Dj(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:ee,onOk:()=>{x(!0),te()},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:Ej(e.target.value)})}})}),(0,l.jsx)(s.Form.Item,{label:`Type`,name:`type`,children:(0,l.jsx)(s.Input,{disabled:!0})})]})})]})})]})}var{Text:Mj}=s.Typography,Nj=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`}];function Pj(e=``){return String(e??``).trim()}function Fj(e=[],t){return e.map(e=>({value:e.id,label:e[t]}))}var Ij=[{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`})}],Lj={key:!1,value:!1,expected:!1};function Rj(e,t){return t?e[t]??Lj:Lj}function zj(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function Bj(){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)(bj),[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)(()=>Rj(x,F),[x,F]),z=(0,o.useMemo)(()=>Fj(p,`modulename`),[p]),B=(0,o.useMemo)(()=>Fj(h,`submodulename`),[h]),V=(0,o.useMemo)(()=>p.find(e=>e.id===N)?.modulename??``,[p,N]),H=(0,o.useMemo)(()=>h.find(e=>e.id===P)?.submodulename??``,[P,h]),U=(0,o.useCallback)(async()=>{try{let e=await ty();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.`)}},[]),ee=(0,o.useCallback)(async e=>{if(!e){m([]);return}w(!0);try{let t=await ly({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)}},[]),te=(0,o.useCallback)(async(e,t)=>{if(!e||!t){g([]);return}E(!0);try{let n=await fy({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)}},[]),ne=(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([hy({product_parent_ID:t,module_parent_ID:n,submodule_parent_ID:r,actions:i,limit:1e3}),vy({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]),re=(0,o.useCallback)(async(e=``)=>{if(!(!f?.id||!N||!P)){O(!0);try{let t=await hy({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]),ie=(0,o.useCallback)(async()=>{if(!(!a||!f?.name)){M(!0);try{let t=await _y(a);await te(f.name,t.module);let n=await hy({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,te,r,f?.name]);return(0,o.useEffect)(()=>{if(!f){r(`/select-project`,{replace:!0});return}Promise.resolve().then(async()=>{await U(),await ee(f.name),a&&await ie()})},[f,r,U,ee,a,ie]),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:Nj})}),(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)(Mj,{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:Pj(t.description),actions:Pj(t.actions),key:Pj(t.key),value:Pj(t.value),expected:Pj(t.expected),scenario:+!!t.scenario,active:+!!t.active};A(!0);try{if(u){await yy(a,{...n,step_order:Number(t.step_order)}),s.message.success(`Test case updated successfully.`),r(`/viewTestCase`);return}await gy(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 ne(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}),zj(e,[`actions`,`key`,`value`,`expected`]),g([]),v([]),te(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}),zj(e,[`actions`,`key`,`value`,`expected`]),ne(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)(Mj,{type:`secondary`,children:[V,` / `,H]}),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=Rj(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}),zj(e,[`key`,`value`,`expected`]),re(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)(vm,{listName:`Added Steps`,loading:D,fields:Ij,dataSource:_,current:1,pageSize:Math.max(_.length,1),total:_.length,rowSelection:!1,className:`zt-list-plain zt-list-static`})})]})})]}):null}var{Text:Vj}=s.Typography,Hj=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`}];function Uj(){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([ly({project:e}),fy({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 dy(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 uy({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:Hj})}),(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)(Vj,{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)(vm,{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)(Vj,{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:Wj}=s.Typography,Gj=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`},{label:`Manage Submodules`,href:`/test-cases/zinnext/submodules`}];function Kj(){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 fy({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 my(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 py({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:Gj})}),(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)(Wj,{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)(Wj,{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)(vm,{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)(Wj,{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:qj}=s.Typography,Jj=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Table`,href:`/viewTestCase`}];function Yj(){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 hy({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 by(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:Jj})}),(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)(qj,{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)(vm,{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 Xj=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}];function Zj(){return(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsx)(n.t,{items:Xj}),(0,l.jsx)(Lo,{moduleName:`test-flows`,rowKey:`id`})]})}var{Text:Qj}=s.Typography,$j=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}],eM={tags:`regression`,active:1},tM={module:{dbName:`Modules`,formField:`module`,label:`Module`}},nM={key:!1,value:!1,expected:!1};function rM(e,t){return t?e[t]??nM:nM}function iM(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function aM(e=[]){return e.map(e=>({value:e,label:e}))}function oM(e=``){return String(e??``).trim()}function sM(e=[]){let t=new Map;return e.forEach(e=>{let n=oM(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function cM(e=[],t,n){let r=oM(t).toLowerCase(),i=oM(n).toLowerCase();return e.reduce((e,t)=>{let n=oM(t?.module).toLowerCase(),a=oM(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 lM({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)(Qj,{strong:!0,className:`v1-section-label`,children:t})]})}function uM(){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)(bj),[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=tM[S.typeKey],M=(0,o.useMemo)(()=>aM(r),[r]),N=s.Form.useWatch(`module`,e),P=s.Form.useWatch(`flow`,e),F=s.Form.useWatch(`keyword`,e),I=!!oM(N),L=!!oM(P),R=!I,z=!I||!L,B=(0,o.useMemo)(()=>rM(g,F),[g,F]),V=(e,t=[])=>{e===`module`&&i(t)},H=async()=>{y(!0);try{let e=await $v(tM.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)}},U=async()=>{try{let e=await ty();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.`)}},ee=(0,o.useCallback)(async t=>{let n=oM(t);if(u([]),p([]),e.setFieldsValue({step_order:void 0}),n){x(!0);try{let e=await sy({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];u(t),p(sM(t))}catch(e){console.error(`Unable to load flows:`,e),s.message.error(`Unable to load flows.`)}finally{x(!1)}}},[e]),te=(0,o.useCallback)(async(t,n,r)=>{let i=oM(t),a=oM(n);if(!i||!a){e.setFieldsValue({step_order:void 0});return}D(!0);try{e.setFieldsValue({step_order:cM(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([H(),U()])})},[]),(0,o.useEffect)(()=>{Promise.resolve().then(()=>ee(N))},[ee,N]),(0,o.useEffect)(()=>{Promise.resolve().then(()=>te(N,P,a))},[a,te,P,N]);let ne=async t=>{let n={module:oM(t.module),flow:oM(t.flow),step_order:Number(t.step_order),description:oM(t.description),keyword:oM(t.keyword),target:oM(t.target),value:oM(t.value),expected:oM(t.expected),tags:t.tags?oM(t.tags):eM.tags,active:Number(t.active)};k(!0);try{await oy(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)}},re=(t,n)=>{e.setFieldsValue({[t]:oM(n)})},ie=t=>{e.setFieldsValue({module:oM(t),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:eM.tags,value:void 0,expected:void 0}),iM(e,[`keyword`,`target`,`value`,`expected`])},ae=t=>{e.setFieldsValue({flow:oM(t),step_order:void 0,keyword:void 0,target:void 0,value:void 0,expected:void 0}),iM(e,[`keyword`,`target`,`value`,`expected`])},W=t=>{let n=rM(g,t);e.setFieldsValue({keyword:oM(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}),iM(e,[`target`,`value`,`expected`])},G=e=>{let n=tM[e];C({open:!0,typeKey:e}),t.setFieldsValue({name:``,type:n.label})},oe=()=>{C(e=>({...e,open:!1})),t.resetFields()},se=async()=>{try{let n=oM((await t.validateFields()).name),r=await ey({name:n,type:j.dbName});V(S.typeKey,r?.items??[]),e.setFieldsValue({[j.formField]:n}),s.message.success(`${j.label} added successfully.`),oe()}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:$j})}),(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)(Qj,{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:eM,onFinish:ne,autoComplete:`off`,children:[(0,l.jsx)(s.Card,{className:`v1-card`,title:(0,l.jsx)(lM,{icon:(0,l.jsx)(c.FileTextOutlined,{}),title:`LMS Case Details`}),extra:(0,l.jsx)(Qj,{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:ie})}),(0,l.jsx)(s.Button,{"aria-label":`Add module`,icon:(0,l.jsx)(c.PlusOutlined,{}),style:{marginTop:30},onClick:()=>G(`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:ae,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:W})})}),(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=>re(`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=>re(`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=>re(`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=>re(`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=>re(`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:oe,onOk:()=>{T(!0),se()},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:oM(e.target.value)})}})}),(0,l.jsx)(s.Form.Item,{label:`Type`,name:`type`,children:(0,l.jsx)(s.Input,{disabled:!0})})]})})]})})]})}var dM=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}];function fM(){return(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsx)(n.t,{items:dM}),(0,l.jsx)(Lo,{moduleName:`lms-flows`,rowKey:`id`})]})}var pM=[`referenceId`,`ReferenceId`,`candidateId`,`CandidateId`,`entityId`,`EntityId`,`id`,`Id`,`_id`];function mM(e=pM){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 hM(e,t=pM){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 gM=mM();function _M(e){return typeof e==`function`?e:typeof e==`string`?mM([e]):Array.isArray(e)?mM(e):gM}function vM(e,t,n){return!t||typeof t!=`object`?e:{...t,...e,id:e?.id??t?.id??n}}function yM(e,t,n={}){return{status:`success`,total:t,data:{data:e,...n}}}var bM=[`fields`,`fieldConfig`,`tabs`,`tabField`,`actionRules`,`actions`,`columnActions`];function xM(e){let t=e?.data??e,n={};for(let r of bM){let i=e?.[r]??t?.[r];i==null||Array.isArray(i)&&i.length===0||(n[r]=i)}return n}var SM=e=>String(e??``).replace(/[^a-zA-Z0-9]/g,``).toLowerCase();function CM(e,t,n){let r=(Array.isArray(n)?n:[n]).map(SM).filter(Boolean),i=r.length?e.findIndex(e=>r.includes(SM(e?.value))||r.includes(SM(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 wM=(e,t)=>ri(e,t).rows,TM=(e,t)=>{let{rows:n,total:r}=ri(e,t);return{rows:n,total:r}};function EM(e,t){return function(n,r,i,a={}){return e(t??n,r,i,a)}}function DM(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:wM,mergeRow:typeof e.mergeRow==`function`?e.mergeRow:vM,fetchById:typeof e.fetchById==`function`?e.fetchById:null}}function OM({fetchSecondaryByKeys:e,fetchSecondary:t,extractSecondaryRows:n,fetchSecondaryById:r,secondaryKey:i,mergeRow:a,secondaryFetchLimit:o}){return!e&&!t&&!r?[]:[DM({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 kM(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:pM;return e=>hM(e,t)}function AM(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 jM({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 MM(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 NM({fetchPrimaryPage:e,extractPrimaryPage:t=TM,fetchSecondaryByKeys:n,joinSources:r=[],fetchPrimary:i,extractPrimaryRows:a=wM,fetchSecondary:o,extractSecondaryRows:s=wM,fetchSecondaryById:c,primaryKey:l,secondaryKey:u,mergeRow:d=vM,secondaryFetchLimit:f=200,extraFields:p=[],extraFieldsAfter:m}){let h=Array.isArray(r)&&r.length?r.map(DM).filter(Boolean):OM({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=_M(t.primaryKey??l),s=kM(t.key),c=AM(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=xM(e);for(let e of Object.keys(t))r[e]??(r[e]=t[e])}return p.length&&(r.fields=CM(r.fields??[],p,m)),yM(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=_M(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 MM(c,jM({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 PM(e,t,n={}){return NM({fetchPrimary:()=>hO(e,t),extractPrimaryRows:pO,fetchSecondary:On,fetchSecondaryById:gO,secondaryFetchLimit:n.moduleFetchLimit??200})}function FM(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 IM(e){let t=Array.isArray(e?.stages)?e.stages:[];if(!t.length)return e;let n={};for(let e of t){let t=FM(e?.stageName);t&&(n[t]=Number(e?.count)||0)}return{...n,...e}}var LM=e=>{let t=Number(e?.targetSubmission??e?.targetSubmissions);return Number.isFinite(t)&&t>0?t:null};function RM({submittedCountField:e=`submittedCount`,progressField:t=`targetSubmissionProgress`}={}){return function(n,r,i){let a=vM(n,r,i),o=LM(a);return o!=null&&(a[t]=`${Number(a?.[e])||0} of ${o}`),a}}function zM(e={}){let t=RM();return NM({primaryKey:`_id`,extraFields:e.extraFields,extraFieldsAfter:e.extraFieldsAfter,fetchPrimaryPage:On,joinSources:[{key:`entityId`,fetchByKeys:(e,t,n,r)=>{let i=Math.max(1,Number(r?.limit)||10);return mO(Math.floor((Number(r?.offset)||0)/i)+1,i)},extractRows:e=>(e?.items??[]).map(IM),mergeRow:(e,n,r)=>{let i=t(e,n,r);return n?._id&&(i.workflowId=n._id),i}}]})}async function BM(e,t=10,n=0,r={},i={}){return ri(await zM(i)(e,t,n,r),e)}async function VM(e,t,n,r=10,i=0,a={}){return ri(await PM(e,t)(n,r,i,a),n)}typeof window<`u`&&(window.__CORE_THEME_BUILD__=`2026-08-21T13:28:17.501Z`);var HM=iA,UM=Cy(nj),WM=Cy(ij),GM=Cy(yj),KM=Cy(jj),qM=Cy(Bj),JM=Cy(Uj),YM=Cy(Kj),XM=Cy(Yj),ZM=Cy(Zj),QM=Cy(uM),$M=Cy(fM);exports.ADMIN_API_URL=t.v,exports.ADMIN_APP_ID=t.y,exports.APP_ID=t.b,exports.AUTH_URL=t.x,exports.ActivityNotesCard=Mc,exports.ActivityTab=Dc,exports.AddBatchCandidatePopup=zk,exports.AddFormV1=uc,exports.AdminDashboard=iA,exports.AdminDashboardContent=iT,exports.AdminPage=HM,exports.AppAlert=dc,exports.AppButton=n.lt,exports.AppShell=Kv,exports.ApprovalActionBar=cg,exports.AssigneeAvatars=Nc,exports.AuthGuard=zv,exports.BILLING_STATUS_FLOW=Hd,exports.BOOLEAN_API_KEYS=Zm,exports.BOOLEAN_PARSEABLE_API_KEYS=Km,exports.BULK_UPLOAD_DEFAULT_ACCEPT=Pc,exports.BULK_UPLOAD_DEFAULT_MAX_SIZE_MB=Fc,exports.Breadcrumb=n.t,exports.BulkUploadPage=GM,exports.BulkUploadPanel=Uc,exports.CANDIDATES_URL=t.S,exports.CONTRACT_C2C=Mg,exports.CONTRACT_W2=jg,exports.CURRENCY_SYMBOLS=Zl,exports.CalendarCard=A,exports.CoreThemeAdminApp=cT,exports.CoreThemeAdminRoutes=sT,exports.CustomPagination=Re,exports.DEFAULT_HOURS_POLICY=Ah,exports.DayLogModal=eg,exports.DescriptionBlock=nl,exports.DetailHeaderCard=Gf,exports.DetailViewPage=Qf,exports.DetailViewV1=Vu,exports.DocumentViewer=n.Cn,exports.DynamicCards=Pt,exports.DynamicPopup=DD,exports.DynamicPopupRoute=Wk,exports.DynamicTabs=P,exports.EditFormV1=Xp,exports.FIELD_TYPE_REGISTRY=km,exports.FINANCE_APPROVAL_CONFIG=Cg,exports.FINANCE_TYPE_CFO=gg,exports.FINANCE_TYPE_ONBOARDING_MANAGER=hg,exports.FINANCE_TYPE_ONBOARDING_MANAGER_REAPPROVE=yg,exports.FINANCE_TYPE_ONLY_FINANCE=_g,exports.FINANCE_TYPE_SUBMISSION_MANAGER=mg,exports.FINANCE_TYPE_SUBMISSION_MANAGER_REAPPROVE=vg,exports.FileListCard=L_,exports.FinanceApprovalPanel=g_,exports.FinanceAvatar=wf,exports.FinanceBadge=Of,exports.FinanceDayCell=ug,exports.FinanceDivider=gf,exports.FinanceEmployeeCell=Tf,exports.FinanceEmptyState=pf,exports.FinanceEquation=_f,exports.FinanceHistoryTimeline=xf,exports.FinanceHoursGrid=ff,exports.FinanceKpiRow=df,exports.FinanceLine=hf,exports.FinanceListToolbar=kh,exports.FinanceMarginBadge=kf,exports.FinanceMoneyCell=Df,exports.FinanceRecordsTable=Mf,exports.FinanceRowChevron=Af,exports.FinanceSection=mf,exports.FinanceStatusPill=uf,exports.FinanceTextCell=Ef,exports.FinanceTimesheetAnalysis=fg,exports.FinanceWorkflowSteps=vf,exports.HOURS_MESSAGES=jh,exports.Header=fv,exports.HierarchyUserFilter=zt,exports.JOBS_URL=t.C,exports.LegacyAdminPage=UM,exports.ListView=Lo,exports.LmsHomePage=$M,exports.LmsTestForm=QM,exports.Login=qv,exports.MailPopup=LT,exports.ManageModules=JM,exports.ManageSubmodules=YM,exports.ModuleRowActions=am,exports.NotesPanel=sg,exports.NotesTab=jc,exports.PAYROLL_STATUS_FLOW=Ud,exports.POPUP_CONFIGS=Ak,exports.ParamCardView=fm,exports.ParamListView=vm,exports.PeriodBadgeTag=Uh,exports.PreviewPopup=mE,exports.ProjectSelect=Sy,exports.ProofUploadPreview=og,exports.QuickLogBar=rg,exports.QuickLogSelectionBar=tg,exports.RejectionReasonModal=ng,exports.SUBMISSIONS_URL=t.T,exports.SearchBuilderV1=bh,exports.Sidebar=Fv,exports.StatusBadge=Sh,exports.StatusBadgeTag=Hh,exports.StickyNotesFullPage=WM,exports.StylishDynamicTabs=wh,exports.TemplateEditor=Eh,exports.TestForm=KM,exports.TestingHomePage=ZM,exports.TimelineGroups=yc,exports.TimesheetDayCell=Zh,exports.TipTapEditor=n.wn,exports.UserForm=rA,exports.VendorShareDrawer=Jk,exports.ViewSummaryWidget=ki,exports.WizardPopup=bE,exports.ZinnextTableView=XM,exports.ZinnextTestForm=qM,exports.appNow=n.On,exports.applyIntegrationStatus=n.Wn,exports.approveSubmission=be,exports.buildAcceptAttr=Bc,exports.buildBooleanRequest=nh,exports.buildCsv=rf,exports.buildDailyRows=Zd,exports.buildDayGradient=Yh,exports.buildRateHistoryEntries=r_,exports.buildWeeklyRollup=ef,exports.clearSelectedProject=t.i,exports.colors=n.Dn,exports.computeFinance=Yg,exports.computeHoursPolicy=Lh,exports.computeMarginBand=tf,exports.conditionMatches=n.i,exports.configureCoreTheme=t.E,exports.configuredFieldLabel=n.a,exports.createAllWorkflowsListFetcher=zM,exports.createMergedListFetcher=NM,exports.createModuleListFetchAdapter=EM,exports.createWorkflowStageListFetcher=PM,exports.currencySymbol=Ql,exports.defaultMergeRow=vM,exports.deleteIntegrationConfig=n.tr,exports.deriveDayStats=Xd,exports.describeCapacity=zh,exports.downloadCsv=cf,exports.evaluateShowIfWith=n.o,exports.findEmployerRow=Ug,exports.flattenGroups=Vg,exports.formatAmount=iu,exports.formatApp=n.kn,exports.formatAppDateTime=n.An,exports.formatFileSize=zc,exports.formatFinanceMoney=i_,exports.formatHours=Nd,exports.formatMoney=au,exports.formatPercent=Fd,exports.formatRate=ou,exports.getActivity=n.un,exports.getAllWorkflowsModuleList=BM,exports.getAppTimeZone=n.jn,exports.getApprovalDate=zd,exports.getBgcIntegrationConfig=n.vr,exports.getBgcIntegrationSummary=n.yr,exports.getBillingActionStates=Wd,exports.getBooleanEligibleTypes=Nm,exports.getCurrentRoleName=t.c,exports.getFieldLabel=of,exports.getFieldType=jm,exports.getFileExtension=Rc,exports.getFinanceApprovalConfig=Og,exports.getFormGroupsRaw=E_,exports.getIntegrationConfig=n.Tr,exports.getIntegrationConfigs=n.Er,exports.getIntegrationSummary=n.Dr,exports.getModuleConfig=Fe,exports.getModuleDataDetail=n.fn,exports.getPayrollActionStates=Gd,exports.getPeriodBadgeConfig=Le,exports.getSelectedProject=t.l,exports.getStoredToken=t.u,exports.getStoredUser=t.d,exports.getUserRoles=t.f,exports.getVMSApprove=xe,exports.getValueStyle=sf,exports.getWorkflowStageModuleList=VM,exports.getWorkflowSteps=Kd,exports.humanizeEvent=Rd,Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return cs}}),exports.indexFieldConfig=af,exports.initialsOf=Id,exports.insertTokenAtCursor=Xm,exports.isBooleanEligible=Mm,exports.isBooleanParsable=Jm,exports.isTester=t.p,exports.logout=t.h,exports.marginIncludesReferral=Ag,exports.matchLocationTax=Jg,Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return op}}),exports.normalizeContract=Gg,Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Wc}}),exports.rateUnitLabel=eu,exports.rateUnitShort=nu,exports.reconcileHours=Rh,exports.registerFieldType=Am,exports.rejectSubmission=Se,exports.resolveActivityMeta=wc,exports.resolveAndCompute=Xg,exports.resolveDayKind=Fh,exports.resolveFinanceInputs=qg,exports.resolveMergeKey=gM,exports.resolveMergedListKey=gM,exports.resolveRejectionReason=kg,exports.resolveSubmissionFinance=D_,exports.saveBgcIntegrationConfig=n.Yr,exports.saveIntegrationConfig=n.Qr,exports.setSelectedProject=t._,exports.showIfConditions=n.c,exports.stageCountKey=FM,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Jv}}),exports.testIntegrationConnection=n.ii,exports.toApp=n.Nn,exports.toNumber=ru,exports.tzLabel=n.Pn,exports.tzShortLabel=n.Fn,exports.useDropdownFields=Wn,exports.useDropdownValues=Ai,exports.useEditForm=R_,exports.useFieldConfig=Gn,exports.useFilterFields=Kn,exports.useMenuPermission=tr,exports.useModuleActions=Qp,exports.useRecordRefresh=Yf,exports.validateBooleanQuery=Ym,exports.validateBulkFile=Vc,exports.withAdminAppId=t.D,exports.withAppId=t.O,exports.withAuthGuard=Cy;
22
+ `))}function XT(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:GT(n),value:r}}function ZT(e){let t=e.toLowerCase().replace(/[\s:.\-–—]+$/,``).trim();return VT.has(t)?HT.test(t)?`education`:UT.test(t)?`keySkills`:`overview`:null}function QT(e){let t=[],n={overview:[],keySkills:[],education:[]},r=`overview`;return e.forEach(e=>{let i=ZT(e);if(i){r=i;return}if(r===`overview`){let n=XT(e);if(n){t.push(n);return}}n[r].push(e)}),{meta:t,overview:KT(n.overview),keySkills:KT(n.keySkills),education:KT(n.education)}}function $T(e){let t=[...BT].sort((e,t)=>t.length-e.length),n=RegExp(`\\b(${t.map(WT).join(`|`)})\\b\\s*:?`,`gi`),r=[...e.matchAll(n)];if(!r.length)return{meta:[],overview:KT(YT(e)),keySkills:[],education:[]};let i={overview:[],keySkills:[],education:[]},a=e.slice(0,r[0].index).trim();return a&&i.overview.push(...YT(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=YT(e.slice(o,s).trim());if(!c.length)return;let l=HT.test(a)?`education`:UT.test(a)?`keySkills`:`overview`;i[l].push(...c)}),{meta:[],overview:KT(i.overview),keySkills:KT(i.keySkills),education:KT(i.education)}}function eE(e){let t=qT(e);if(!t)return{meta:[],overview:[],keySkills:[],education:[]};let n=JT(t);return n.length>=4?QT(n):$T(t)}function tE({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 nE({raw:e=``,meta:t=[]}){let[n,r]=(0,o.useState)(!1),i=(0,o.useMemo)(()=>eE(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)(RT,{type:`secondary`,children:`No description available.`});let c=n?s:s.slice(0,zT),u=s.length-zT;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)(tE,{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:rE}=s.Typography;function iE(e){return e?e.trim().split(/\s+/).slice(0,2).map(e=>e[0].toUpperCase()).join(``):`?`}function aE(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 oE(e){return e?e.email??e.emailId??e.emailAddress??``:``}function sE(e){return e?e.status?e.status:e.stage?e.stage:typeof e.isActive==`boolean`?e.isActive?`Active`:`Inactive`:``:``}function cE(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 lE=[`jobDescription`,`description`,`rawDescription`,`jobDescriptionText`];function uE(e){return String(e??``).toLowerCase()===`job`}function dE(e){let t=lE.includes(e.field),n=/description/i.test(e.label??``);return t||n}function fE({record:e}){let t=aE(e),n=oE(e),r=sE(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:iE(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 pE({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=uE(t)&&dE(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.Lt(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:cE(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)(nE,{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:cE(i)})]},e.field??e.label)})}),(0,l.jsx)(n.Cn,{documents:i,open:u,onClose:()=>d(!1),initialIndex:s})]})}function mE(){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.gn(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)(pE,{fields:e.fields,moduleName:t,centralDocuments:g}):(0,l.jsx)(rE,{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)(fE,{record:r}),j()]})})}var{Text:hE}=s.Typography,{TextArea:gE}=s.Input,_E=[{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 vE(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)(gE,{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 yE({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)(hE,{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)(hE,{type:`secondary`,children:`Please review the information above before submitting.`})]})]}):(0,l.jsx)(`div`,{className:`wizard-review-empty`,children:(0,l.jsx)(hE,{type:`secondary`,children:`No data entered yet.`})})}function bE(){let[e]=s.Form.useForm(),t=(0,d.useNavigate)(),{title:n=`Wizard`,moduleName:r=``,steps:i=_E,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:vE(e)})},e.name))})},e.key)),f.isReview&&(0,l.jsx)(yE,{steps:i,form:e})]})})]})}function xE({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 SE({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.Tn,{variant:`body`,color:`secondary`,className:`dynamic-popup__note`,children:e}),t&&(0,l.jsx)(n.Tn,{variant:`body`,className:`dynamic-popup__description`,children:t}),r&&i>0&&(0,l.jsxs)(n.Tn,{variant:`body`,className:`dynamic-popup__selected-count`,children:[`Changing status for `,(0,l.jsx)(`strong`,{children:i}),` selected `,a,`.`]}),o&&(0,l.jsx)(n.Tn,{variant:`body`,children:o}),s&&(0,l.jsx)(n.Tn,{variant:`caption`,color:`danger`,className:`dynamic-popup__error`,children:s})]})}function CE({footerNote:e}){return e?(0,l.jsx)(n.Tn,{variant:`caption`,color:`secondary`,className:`dynamic-popup__footer-note`,children:e}):null}function wE(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t?.[n]??``).trim()}function TE(e){return String(e).replace(/\(\s*\)/g,``).replace(/\s+/g,` `).replace(/(^|\s)([-–—·|])(?=\s*\2)/g,``).replace(/^[\s\-–—·|]+/,``).replace(/[\s\-–—·|]+$/,``).trim()}function EE(e){if(!e)return!1;let t=new Date(e).getTime();return Number.isNaN(t)||t<=0?!1:t<=Date.now()+864e5}function DE(e){if(!EE(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 OE(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 kE(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 AE(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:DE(OE(e))}:e,o=(i?TE(wE(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||kE(e);t&&(u.submittedAt=t)}if(e?.isFromSubmission===!0&&e?.submissionId){u.isFromSubmission=!0,u.priorSubmissionId=String(e.submissionId);let t=e?.lastSubmittedAt||kE(e);t&&(u.priorSubmittedAt=t)}return u}function jE(e,t){return(t?.[e.optionsKey]??e.defaultOptions??[]).map(t=>AE(t,e))}function ME(e={}){return{selectedIds:[],selectedRecords:[],moduleName:``,removedIds:[],...e}}var NE=`DD MMM YYYY`,PE=`DD MMM YYYY, h:mm A`;function FE(e,t){if(e==null||e===``)return``;let n=(0,u.default)(e);return n.isValid()?t===`relative`?DE(e)||(EE(e)?n.format(NE):`Not updated`):EE(e)?n.format(NE):``:String(e)}function IE(e,t){return e?String(e).includes(`{`)?TE(wE(e,t)):String(t?.[e]??e).trim():``}function LE(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(PE)}`:`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(PE)} — this form will prefill from it`:`Submitted to another job before — this form will prefill from it`}}return null}function RE(e,t){return e?.alreadySubmitted||!e?.disabled?``:String(t?.message??e?.title??``).trim()}function zE({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 BE({option:e,layout:t}){let n=e?._raw??e??{},r=IE(t.id,n),i=IE(t.title,n)||String(e?.label??``),a=IE(t.subtitle,n),o=IE(t.titleAccent?.key,n),u=IE(t.titleAccent?.toneKey,n),d=t.titleAccent?.prefix??``,f=(t.meta??[]).map(e=>({label:e.label,text:FE(n?.[e.key],e.type)})).filter(e=>e.text),p=RE(e,n),m=LE(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)(zE,{meta:f})]})}var{Text:VE}=s.Typography,{TextArea:HE}=s.Input,UE=[{label:`$`,value:`$`},{label:`EUR`,value:`EUR`},{label:`GBP`,value:`GBP`},{label:`INR`,value:`INR`}],WE=[{label:`Hourly`,value:`Hourly`},{label:`Daily`,value:`Daily`},{label:`Weekly`,value:`Weekly`},{label:`Monthly`,value:`Monthly`},{label:`Yearly`,value:`Yearly`}];function GE(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 KE({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 qE({field:e,value:t,onChange:n}){return(0,l.jsx)(HE,{value:t,onChange:n,rows:e.rows??5,placeholder:e.placeholder})}function JE({field:e,options:t,value:n,onChange:r}){let i=GE(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 YE({field:e,options:t,value:n,onChange:r}){let i=GE(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 XE({field:e,options:t,onSearch:n,value:r,onChange:i,popupContext:a}){let o=GE(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)(BE,{option:e?.data??e,layout:u}):void 0,prefix:(0,l.jsx)(c.CrownOutlined,{})})}function ZE({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 QE({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:UE,onChange:e=>a({currency:e}),style:{width:80}}),(0,l.jsx)(s.Select,{value:r,options:WE,onChange:e=>a({period:e}),style:{width:110}})]}),(u||d)&&(0,l.jsxs)(`div`,{style:{marginTop:4},children:[u&&(0,l.jsx)(VE,{type:`danger`,style:{fontSize:12,display:`block`},children:`To rate must be greater than From rate.`}),d&&(0,l.jsxs)(VE,{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 $E({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 eD({field:e,checked:t,onChange:n}){return(0,l.jsx)(s.Checkbox,{checked:t,onChange:n,children:e.checkboxLabel})}function tD({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 nD({options:e,value:t,onChange:n}){return(0,l.jsx)(s.Radio.Group,{value:t,onChange:n,options:e})}var rD={input:KE,text:KE,textarea:qE,select:JE,"multi-select":YE,"search-select":XE,"mention-textarea":ZE,"candidate-rate":QE,"priority-checkbox":eD,"date-picker":$E,number:tD,radio:nD};function iD(e){return e===`priority-checkbox`?{valuePropName:`checked`}:{}}var aD=new Set([`input`,`text`,`textarea`,`mention-textarea`]);function oD({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.Tn,{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.Tn,{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:sD(t).map(e=>cD(e,e=>{let t=y(i[e.name]??jE(e,a)),r=p(e),o=m(e),c=h[e.name]??[],u=iD(e.type),d=rD[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()}}),aD.has(e.type)&&f.push(n.an({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 sD(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 cD(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 lD(e){return[`select`,`multi-select`,`search-select`,`radio`].includes(e?.type)&&e?.dataSource===`master`&&e?.masterName}function uD(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 dD(e){let t=String(e?.masterName??``).trim().toLowerCase();return t===`clientsubmissions`||t===`clientsubmissionstatus`}function fD(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 pD(e,t){return dD(t)?fD(e):AE(e,t)}function mD(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 hD(e){let t=Number(e?.id??0)||0,n=String(e?.text??``).trim();return n&&n.toLowerCase()===`not submitted`?!0:t<=0&&!n}function gD(e){return Number(e?._raw?.id??e?._raw?.uniqueId??0)||0}function _D(e){let t=e?._raw?.allowedNextStatusIds;return Array.isArray(t)?t.map(Number).filter(e=>Number.isInteger(e)&&e>0):[]}function vD(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 yD(e){return(Array.isArray(e?.selectedRecords)?e.selectedRecords.filter(Boolean):[]).some(e=>!hD(mD(e)))?!0:!hD(mD(e??{}))}async function bD(e,n){if(yD(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=vD(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 xD(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=mD(n);if(hD(i)){let e=mD(r);hD(e)||(i=e)}if(hD(i))return t?._raw?.isInitialStatus===!0;let a=e.find(e=>{let t=gD(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:_D(a).includes(gD(t))}))}function SD({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(lD);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=uD(t).map(t=>pD(t,e)).filter(Boolean),i=a;if(dD(e)&&(i=await bD(a,r)),o.signal.aborted)return;let s=dD(e)?xD(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 CD=500,wD=3;function TD({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=>AE(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??wD;return e=>{clearTimeout(c.current[t.name]);let r=e.length<n?``:e;c.current[t.name]=setTimeout(()=>{d(t,r)},CD)}}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 ED({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 DD({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)(()=>ME(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}=SD({open:e,config:t,api:a,fields:x,popupContext:g,formValues:d}),{mentionOptions:E,getSearchHandler:D,getMentionSearchHandler:O}=TD({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}=ED({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,``),H=B===1?V:y,U=v[0]??{},ee=t?.getTitleText?t.getTitleText(B,H,U,g):t?.title,te=B===1?U.jobTitle??U.title??U.name??U.fullName??U.candidateName??null:null,ne=t?.getBodyText?t.getBodyText(B,V,H,te,g):t?.bodyText??null,re=typeof t?.getNote==`function`?t.getNote(g):t?.note,ie=t?.disabledUntilFilled&&!j&&!N;if(!t||!e||z)return null;let ae=t.component;return ae?(0,l.jsx)(s.Modal,{open:e,title:t.title||t.getTitleText?(0,l.jsx)(xE,{titleText:ee,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)(ae,{context:g,selectedIds:b,selectedRecords:v,moduleName:y,onClose:k})}):(0,l.jsxs)(s.Modal,{open:e,title:(0,l.jsx)(xE,{titleText:ee,titleIcon:t.titleIcon}),okText:t.okText||`OK`,cancelText:t.cancelText??`Cancel`,onOk:F,onCancel:()=>k(),okButtonProps:{danger:t.okButtonDanger,disabled:ie,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)(SE,{note:re,description:t.description,showSelectedCount:t.showSelectedCount,count:B,itemLabel:H,bodyText:ne,deleteError:L}),(0,l.jsx)(CE,{footerNote:t.footerNote}),(0,l.jsx)(oD,{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 OD={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:[]},kD={deleteItems:async(e,t)=>{await re(t.moduleName,e)}},AD=new Map;async function jD(e){return e?(AD.has(e)||AD.set(e,a.r({module:e}).catch(t=>(AD.delete(e),console.warn(`[in-progress gate] could not read ${e} form groups:`,t),[]))),AD.get(e)):[]}function MD(e=[],t){return e.some(e=>{let r=n.C(e,t);return r&&r.severity!==`allow`})}async function ND({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.zn().region;try{let i=await jD(e);if(!MD(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 PD=`Already submitted`,FD=`submissions`,ID=`candidates`,LD=864e5,RD=90,zD=`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.`,BD=[`createdAt`,`createdDate`,`dateCreated`,`created_on`,`createdOn`],VD=[`updatedAt`,`updatedDate`,`lastUpdatedAt`,`lastUpdatedDate`,`modifiedAt`,`modifiedDate`];function HD(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 UD(e){return HD(e,BD)}function WD(e){return HD(e,VD)}function GD(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))/LD))}function KD(e){return e===null?``:e<=14?`green`:e<=89?`yellow`:`red`}function qD(e,t=RD){if(!e)return!1;let n=Date.now()-t*LD,r=UD(e),i=WD(e),a=r&&r.getTime()>=n,o=i&&i.getTime()>=n;return!a&&!o}function JD(e){let t=UD(e);if(!t)return{createdAgo:``,createdAgoTone:``};let n=DE(t);return n?{createdAgo:n,createdAgoTone:KD(GD(t))}:{createdAgo:``,createdAgoTone:``}}function YD(e){return{...e,...JD(e),isStaleCandidate:qD(e)}}function XD(e){return String(e?.applicantId??e?._id??e?.id??``)}var ZD=null;async function QD(){return ZD||=n.Nr(ID).then(e=>e?.strategies?.duplicateCheck?.editRoute??``).catch(()=>``),ZD}async function $D(e){let t=XD(e);if(!t)return``;let n=await QD();return n?n.replace(/:(_?id)\b/g,encodeURIComponent(t)):``}async function eO({option:e,popupContext:t,confirm:n}){let r=e?._raw??e??{},i=XD(r);if(i){let e=await ND({targetModule:FD,sourceModule:ID,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(!qD(r))return!0;let a=t?.navigate;return!a||!i?!1:new Promise(e=>{n({title:`Candidate update required`,content:zD,okText:`OK`,cancelText:`Cancel`,onOk:async()=>{let t=await $D(r);t&&a(t),e(!1)},onCancel:()=>e(!1)})})}function tO(e,t,n){return{...e,label:`${e.label} - ${PD}`,disabled:!0,title:`${PD}${t?` (submission ${t})`:``}`,alreadySubmitted:!0,existingSubmissionId:t||``,...n?{submittedAt:n}:{}}}var nO={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 we({searchQuery:t,candidateId:r})}catch{a=!1;let e=await Rn({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 tO(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 Ee({applicantId:r,jobIds:o.map(e=>e.value)}).catch(()=>new Map);return o.map(e=>{let t=s.get(String(e.value));return t?tO(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 Te({search:t,jobId:r})}catch{let e=await Uo({isFromSubmission:n.isFromSubmission,jobId:r,submissionId:n.submissionId,search:t});i=Array.isArray(e)?e:[],a=await Ee({jobId:r,applicantIds:i.map(XD)}).catch(()=>new Map)}return i.map(e=>YD(e)).map(e=>{let t=a.get(XD(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:PD,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=>XD(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(qD(u?._raw))throw Error(zD);let p=await ND({targetModule:FD,sourceModule:ID,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 Ce({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=Bo(Ho({jobId:c,applicantId:l}).catch(()=>[]));return r(`/submission-create/${c}?${g.toString()}`,{state:{relevantSkillsToken:v}}),{navigated:!0}}},rO={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:eO}]},iO={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`}]},aO=e=>e?.data??e;async function oO({relatedId:e,notes:n,title:r,notesFor:i}){return aO(await bn(t.x,`/notes`,{method:`POST`,body:JSON.stringify({relatedId:e,notes:n,title:r,notesFor:i})}))}var sO={getMentionOptions:async(e,t)=>ae(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 oO({relatedId:String(n),notes:e.notes,notesFor:t.moduleName})}},cO={name:`jobId`,label:`Job Title / ID`,type:`search-select`,multiple:!0,required:!0,placeholder:`Minimum 3 characters`,searchFetchKey:`tagToJobJobList`,valueKey:`_id`,labelTemplate:`{jobReferenceId} - {jobTitle}`},lO={name:`hiringStage`,label:`Hiring stage`,type:`select`,required:!0,optionsKey:`hiringStageOptions`,defaultOptions:[{label:`Shortlisted`,value:`shortlisted`},{label:`Pipeline`,value:`pipeline`}],initialValueKey:`hiringStage`},uO={title:`Tag to Job`,okText:`Tag`,width:480,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getFields:e=>e.jobId&&e.hiringStage?[]:e.jobId?[lO]:[cO,lO]},dO=e=>e?.data??e;function fO(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 pO(e){return e?Array.isArray(e.data)?e.data.map(fO):e.stage&&Array.isArray(e.stage.data)?e.stage.data.map(fO):Array.isArray(e)?e.map(fO):[]:[]}async function mO(e=1,n=10){let r=await t.o(t.x,`/workflow/list/all?page=${e}&limit=${n}`),i=dO(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 hO(e,n){let r=dO(await t.o(t.x,`/workflow/${e}/stage/${n}`));return Array.isArray(r)?{data:r}:r}async function gO(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=dO(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 _O(e){return dO(await t.o(t.C,`/source/workflow-instance`,{method:`POST`,body:JSON.stringify(e)}))}var vO={pipeline:`pipeline`,goodfited:`goodfited`,contacted:`contacted`,submitted:`submitted`,shortlisted:`shortlisted`,interviewinprogress:`interviewInprogress`,selected:`selected`},yO=`Already submitted`;function bO(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 xO(e){let t=String(e??``).trim();return t?vO[t.toLowerCase()]??t:``}function SO(e,t=``){return String(bO(e,`candidateId`,`candidate_id`,`applicantId`,`applicantID`,`applicantReferenceId`,`applicantRefrenceId`,`_id`,`id`)??t??``)}function CO(e){return String(bO(e,`_id`,`id`,`candidateId`,`candidate_id`,`applicantId`,`applicantID`)??``)}function wO(e,t,n){let r=String(e.jobTitle??``).trim();return{...e,jobTitle:r?`${r} (${yO})`:`(${yO})`,disabled:!0,title:yO,alreadySubmitted:!0,existingSubmissionId:t||``,...n?{submittedAt:n}:{}}}function TO(e,t){let n=String(t??``).trim();return n?/already submitted/i.test(n)?`${e} (${yO})`:/fulfilled/i.test(n)?`${e} (Fullfilled)`:`${e} (${n})`:e}function EO(e){let t=String(e.jobReferenceId??e.clientJobReferenceId??``).trim(),n=String(e.jobTitle??``).trim();return{...e,jobReferenceId:t,jobTitle:n}}function DO(e){return kO(e).map(e=>e.id)}function OO(e,t=``){return(bO(e,`candidateName`,`candidate_name`,`fullName`,`name`)??[bO(e,`firstName`,`first_name`),bO(e,`lastName`,`last_name`)].filter(Boolean).join(` `)??t)||`Unknown candidate`}function kO(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=SO(a,o);!s||i.has(s)||(i.add(s),r.push({id:s,name:OO(a,o),record:a,selectedId:o||s}))}return r}function AO(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 jO(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 MO(e,t=``){return jO(e,t)}function NO(e,t,n){let r=[...new Set(AO(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:MO(t,e),record:t}})}function PO(e){return e.filter(e=>e.blockedCandidates.length>0).map(e=>`${e.job.label} - ${e.blockedCandidates.map(e=>e.name).join(`, `)}`).join(` | `)}function FO(e){return e.filter(e=>e.allowedCandidates.length>0).map(e=>`${e.job.label} - ${e.allowedCandidates.map(e=>e.name).join(`, `)}`).join(` | `)}function IO(e,t){let n=CO(e);if(!n)return null;let r=OO(e,t)||void 0,i={candidateId:String(n),candidateName:r,phone:bO(e,`phone`,`phoneNumber`,`phone_number`,`mobile`,`mobileNumber`,`mobile_number`),source:bO(e,`source`,`sourceType`,`candidateSource`,`profileSource`),submittedAt:bO(e,`submittedAt`,`lastSubmittedAt`,`updatedAt`),remarks:bO(e,`remarks`,`comment`,`comments`,`notes`),assignedRecruiter:bO(e,`assignedRecruiter`,`recruiterName`,`ownerName`,`assignedToName`),screeningStatus:bO(e,`screeningStatus`,`screening.status`,`screeningResult`),screeningScore:bO(e,`screeningScore`,`screening.score`,`score`),assignedDate:bO(e,`assignedDate`,`assignedAt`,`createdAt`)};return Object.fromEntries(Object.entries(i).filter(([,e])=>e!=null&&e!==``))}var LO={searchOptions:async(e,t,n)=>{if(e.searchFetchKey===`tagToJobJobList`){let e=DO(n),r=e.length===1?e[0]:``,i,a=!1;if(r)try{i=await we({searchQuery:t,candidateId:r}),a=!0}catch{a=!1}Array.isArray(i)||(i=await ie(t));let o=i.map(EO);if(a)return o.map(e=>{if(e?.isSubmitted||e?.alreadySubmitted)return wO(e,e?.jobSubmissionId||e?.submissionId||``,e?.submittedAt||``);if(e?.disable){let t=String(e?.message??``).trim();return{...e,jobTitle:e.jobTitle?TO(e.jobTitle,t):`(${t})`,disabled:!0,optionNote:t,title:t}}return e});if(!r)return o;let s=await Ee({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?wO(e,t.submissionId,t.submittedAt):e})}return[]},submit:async(e,t,r)=>{let i=xO(e.hiringStage??t.hiringStage),a=kO(t),o=NO(e,t,r);if(!o.length||!a.length)return{cancelled:!0};let s=[];for(let e of o){let t=await Ee({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=PO(s),l=FO(s),u=s.filter(e=>e.allowedCandidates.length>0);if(!u.length)return await n.Vt({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.Bt({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=IO(t.record??{},t.selectedId);await _O({jobId:e.job.id,module:`jobs`,currentStage:i,...n?{candidateDetails:n}:{}})}await se({jobId:e.job.id,candidateIds:e.allowedCandidates.map(e=>e.selectedId||e.id),hiringStage:i})}}},RO={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 zO(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 BO={submit:async(e,t,n)=>{let r=zO(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 ne(t.moduleName,t.selectedIds,a)}},VO={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:[]},HO={onOk:async e=>{await De({jobId:e.jobId??e.selectedIds[0],candidateIds:e.selectedIds})}},UO={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`}]},WO={getOptions:async e=>e.fetchOptionsKey===`candidateGroups`?ce():[],submit:async(e,t,{dynamicOptions:n})=>{let r=(n.groupId??[]).find(t=>String(t.value)===String(e.groupId));await le({candidateIds:t.selectedIds,groupId:e.groupId,groupName:r?.label??``})}},GO=[{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 KO({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([de(n).catch(t=>(e||s.message.error(t?.message??`Failed to load self-assign details`),{assignedUsers:[],totalSubmissions:0,message:``})),me(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 ue({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:GO,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`})]})]})}KO.propTypes={selectedIds:f.default.array,onClose:f.default.func};var qO={title:`Self Assign`,width:480,className:`self-assign-modal`,component:KO},JO={submit:async()=>{}};function YO(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 XO={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=>(YO(e?.selectedRecords?.[0]??{}),[{name:`assignToUserId`,label:`Assign to`,type:`multi-select`,required:!0,placeholder:`Select recruiter(s)`,fetchOptionsKey:`assignToUsers`}])},ZO={getOptions:async e=>e.fetchOptionsKey===`assignToUsers`?pe():[],loadExtraData:async e=>me(e.selectedIds[0]),submit:async(e,t,{removedIds:n,extraData:r})=>{await ve({jobIds:t.selectedIds,userId:e.assignToUserId,removedIds:n,existingRecruiters:r?.recruitersData})}},QO={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`}]},$O={getMentionOptions:async(e,t)=>ae(t),submit:async(e,t)=>{let n=e.targetDate?e.targetDate.toISOString():``;t.editingNoteId?await G(t.editingNoteId,{title:e.heading,targetDate:n,notes:e.comments}):await W({relatedIds:t.selectedIds,module:t.moduleName,title:e.heading,targetDate:n,notes:e.comments}),window.dispatchEvent(new Event(`sticky-notes:refresh`))}},ek={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`}]},tk={submit:async(e,t)=>{await ye({submissionId:t.selectedRecords?.[0]?.submissionId,isMail:e.sendOnboardingEmail})}};function nk(e){return Array.isArray(e)?e[e.length-1]??{}:e&&typeof e==`object`?e:{}}var rk={USD:`$`,INR:`₹`,EUR:`€`,GBP:`£`};function ik(e,t,n){let r=nk(e?.[t])[n];if(r!=null&&r!==``)return r;let i=e?.[`${t}.${n}`];return i!=null&&i!==``?i:void 0}function ak(e){let t=e.selectedRecords?.[0]??{},n=ik(t,`candidateRate`,`candidateAcceptedRate`)??ik(t,`candidateBudget`,`candidateBudgetStart`);if(n===void 0||Number(n)===0)return null;let r=ik(t,`candidateRate`,`candidateAcceptedCurrency`)??ik(t,`candidateBudget`,`candidateBudgetCurrency`);return{amount:n,symbol:ik(t,`candidateRate`,`candidateAcceptedCurrencySymbol`)??ik(t,`candidateBudget`,`candidateBudgetCurrencySymbol`)??rk[String(r??``).toUpperCase()]??(r||`$`),unit:ik(t,`candidateRate`,`candidateAcceptedPayUnit`)??ik(t,`candidateBudget`,`candidateBudgetUnit`)??``}}var ok={title:`Approve Rate`,okText:`Approve`,width:520,className:`medium-modal`,successMessage:`Rate approved`,getBodyText:(e,t,n,r,i)=>{let a=ak(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=ak(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`}]}]},sk={submit:async(e,t)=>{let n=t.selectedIds[0];if(await be(n,{candidateProposedRate:e.candidateProposedRate,candidateProposedRateCurrency:e.candidateProposedRateCurrency,candidateProposedRateUnit:e.candidateProposedRateUnit,submitVia:e.submitVia}),e.submitVia===`VMS`)try{await xe(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 ck(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 lk(e){let t=await ck(`/mail-form?${new URLSearchParams({submissionId:e,submissionType:`manager`}).toString()}`);return t.data??t}function uk(e){return Array.isArray(e)?e[e.length-1]:e}function dk(e={}){let t=uk(e?.proposedRate)?.candidateProposedRate??e?.candidateProposedRate??e?.proposedRateValue,n=Number(t);return Number.isFinite(n)?n:0}function fk(e,t={}){let n=uk((e?.record?.job??e?.job??t?.job??{})?.jobPayDetails)??{},r=e?.record?.submission??t??{},i=uk(r?.clientBudget)??r?.clientBudget??{},a=n?.clientBudgetEnd??n?.clientBudgetStart??i?.clientBudgetEnd??i?.clientBudgetStart,o=Number(a);return Number.isFinite(o)?o:0}function pk(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 mk(e={}){return String(e?.rateUnit??`hr`).trim().replace(/^\/+/,``)||`hr`}function hk(e,t={}){let n=Number(e);return Number.isFinite(n)?`${pk(t)}${n}/${mk(t)}`:``}function gk(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 _k(e,t,n,r,i){let a=Number(n?.proposedRate),o=Number.isFinite(a)?a:dk(t),s=Number(n?.clientJobRate),c=Number.isFinite(s)&&s>0?s:fk(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=gk(u,`(?:Proposed\\s*Rate|Pay\\s*Rate)`,hk(o,n)),u=gk(u,`(?:Job\\s*)?Bill\\s*Rate`,hk(c,n)),u}function vk(...e){return e.map(e=>e==null?``:String(e).trim()).find(Boolean)??``}var yk=(e,t)=>!!e&&e.toLowerCase()===vk(t).toLowerCase();function bk(e,t,n){let r=vk(t.submittedBy);return vk(yk(r,n)||yk(r,e.submitSource)||yk(r,e.supplierName)||yk(r,e.source)||yk(r,e.candidateSource)?``:r,e.signatureEmail)}function xk(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:bk(e,t,n),submittedAt:t.createdAt??e.createdAt,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function Sk(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 Ck(...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(Sk).find(Boolean);if(e)return e}return``}function wk(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 Tk(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 Ek(...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(Sk).find(Boolean);if(e)return e}return``}async function Dk(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 Ok(e,r,i){let a=[],o=await n.gn(`submissions`,e,`resume`).catch(()=>({data:[]}));a.push(...o?.data??[]);let s=Ek(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=Ek((Array.isArray(r?.data)?r.data:Array.isArray(r)?r:[])[0])}if(s){let e=await n.gn(`candidates`,s,`resume`).catch(()=>({data:[]}));a.push(...e?.data??[])}let c=(await Promise.all(a.map(Dk))).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 kk(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:Tk(e.content?.value??e.Content?.Value??e.contents??e.body??``)}}function Ak({context:e,selectedIds:t,selectedRecords:n,moduleName:r,onClose:i}){let a=n?.[0]??{},c=t?.[0]??Bg(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 D_(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 I_().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([lk(c).then(kk),Ok(c,u,a).catch(e=>(console.warn(`Unable to resolve resume attachment:`,e),[]))]),n=u?.record?.submission??a;N({to:_k(e.to,n,b,u,a),cc:_k(e.cc,n,b,u,a),bcc:_k(e.bcc,n,b,u,a),subject:_k(e.subject,n,b,u,a),contents:_k(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 be(c,{candidateProposedRate:b.proposedRate,candidateProposedRateCurrency:b.currencyRaw??b.currency,candidateProposedRateUnit:b.rateUnit,submitVia:`VMS`,...wk(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&&lT(M.to).length>0&&uT(M.to)&&uT(M.cc)&&uT(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 be(c,{...e,submitVia:`VMS`,...wk(S)});let t=Ck(u?.record,a);if(!t)s.message.warning(`Submission approved, but job details were not available to send mail`);else try{await mn({jobId:t,toMail:lT(M.to),ccMail:lT(M.cc),bccMail:lT(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)(g_,{type:mg,record:u.record,lookups:u.lookups,identity:xk(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)(ST,{value:M,onChange:N,moduleName:`submissions`,ready:!O,title:`Submit Via Mail`,contextRecords:[u.record?.submission??a]})})]})}Ak.propTypes={context:f.default.object,selectedIds:f.default.array,selectedRecords:f.default.array,moduleName:f.default.string,onClose:f.default.func};var jk={title:`Manager Approve`,width:780,className:`fa-modal manager-approve-modal`,component:Ak},Mk={submit:async()=>{}};function Nk(...e){return e.map(e=>e==null?``:String(e).trim()).find(Boolean)??``}var Pk=(e,t)=>!!e&&e.toLowerCase()===Nk(t).toLowerCase();function Fk(e,t,n){let r=Nk(t.submittedBy);return Nk(Pk(r,n)||Pk(r,e.submitSource)||Pk(r,e.supplierName)||Pk(r,e.source)||Pk(r,e.candidateSource)?``:r,e.signatureEmail)}function Ik(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:Fk(e,t,n),submittedAt:t.createdAt??e.createdAt,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function Lk(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 Rk(e){return String(e??``).toLowerCase().replace(/\b\w/g,e=>e.toUpperCase())}function zk({selectedIds:e,selectedRecords:t,onClose:r}){let i=t?.[0]??{},a=e?.[0]??Bg(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([D_(a,i),n.un(`submission`,a).catch(()=>[])]).then(([t,n])=>{if(e)return;let r=Lk(n);f(Bg(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?Rk(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 K(d,{submissionId:a,billRate:e.proposedRate,payRate:e.employerRate,currency:e.currencyRaw??e.currency,rateUnit:e.rateUnit,vmsPercent:e.clientVmsPercent}),await be(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)(g_,{type:vg,record:c.record,lookups:c.lookups,identity:Ik(i,c.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:h,onClose:()=>r?.(),variant:`popup`})}zk.propTypes={selectedIds:f.default.array,selectedRecords:f.default.array,onClose:f.default.func};var Bk={title:`Re-Approve`,width:780,className:`fa-modal manager-approve-modal`,component:zk},Vk={submit:async()=>{}},Hk=[{id:1,name:`Re-Submission`},{id:2,name:`Candidate doesn't fit into the profile`},{id:3,name:`Incomplete candidate details - (Re-Submission)`}],Uk={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:Hk.map(e=>({label:e.name,value:e.id}))},{name:`rejectReasonComments`,label:`Comments`,type:`textarea`,required:!0,rows:4}]},Wk={submit:async(e,t)=>{let n=Hk.find(t=>String(t.id)===String(e.rejectReason));await Se({submissionId:t.selectedIds[0],rejectReasonId:e.rejectReason,rejectReason:n?.name??``,rejectReasonComments:e.rejectReasonComments})}},Gk={delete:OD,"quick-submit":rO,"add-notes":iO,"tag-to-job":uO,"change-status":RO,"remove-from-shortlist":VO,"add-to-groups":UO,"self-assign":qO,"others-assign":XO,"sticky-notes":QO,"move-to-onboarding":ek,"approve-rate":ok,"manager-approve":jk,"manager-reapprove":Bk,reject:Uk},Kk={delete:kD,"quick-submit":nO,"add-notes":sO,"tag-to-job":LO,"change-status":BO,"remove-from-shortlist":HO,"add-to-groups":WO,"self-assign":JO,"others-assign":ZO,"sticky-notes":$O,"move-to-onboarding":tk,"approve-rate":sk,"manager-approve":Mk,"manager-reapprove":Vk,reject:Wk};function qk(e){let t=e?.data??e;return Array.isArray(t)?t:t?.data??t?.rows??t?.records??t?.items??t?.list??[]}function Jk(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 Yk(e){let t=String(Jk(e,`isDeleted`,`deleted`)).toLowerCase(),n=String(Jk(e,`assignmentStatus`,`status`)).toLowerCase();return t!==`true`&&t!==`1`&&![`removed`,`inactive`,`deleted`].includes(n)}function Xk(e){let t=Jk(e,`candidateName`,`candidate_name`,`fullName`,`name`);return t?String(t):[Jk(e,`firstName`,`first_name`),Jk(e,`lastName`,`last_name`)].filter(Boolean).join(` `)||`Unnamed candidate`}function Zk(e){return String(Jk(e,`candidateId`,`candidate_id`,`candidate._id`,`candidate.id`))}function Qk(e){return String(Jk(e,`workforceEngagementId`,`engagementId`,`_id`,`id`))}function $k(e){return String(Jk(e,`batchName`,`name`,`title`,`batch_name`))}function eA({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.yn(`onboarding`,200,0),n.yn(`batchCandidates`,1e3,0).catch(()=>[])]))).then(([e,n])=>{t||(c(qk(e)),x(new Map(qk(n).filter(Yk).map(e=>[String(Jk(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=>[Xk(t),Jk(t,`email`,`candidateEmail`,`candidate_email`),Jk(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(Qk(e)));if(!e.length)return;let o=e.map(e=>({record:e,assignment:b.get(Zk(e))})).filter(e=>e.assignment);if(o.length){let e=o.map(({record:e})=>Xk(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=$k(r.selectedRecords?.[0])||$k(r);await Promise.all(e.map(e=>n.Xn(`batchCandidates`,{schemaVersion:1,batchId:S,batchName:o,candidateId:Zk(e),workforceEngagementId:Qk(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=>Qk(e),columns:[{title:`Candidate`,key:`candidate`,render:(e,t)=>Xk(t)},{title:`Email`,key:`email`,render:(e,t)=>Jk(t,`email`,`candidateEmail`,`candidate_email`)||`—`},{title:`Onboarding status`,key:`status`,render:(e,t)=>Jk(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(Zk(e));return{disabled:!Zk(e)||!Qk(e)||!!t,title:t?`Candidate is already added to a batch`:void 0}}},locale:{emptyText:m?`Loading candidates…`:`No onboarding candidates found`}})]})}var tA={text:`input`,string:`input`,textarea:`textarea`,date:`date-picker`,datepicker:`date-picker`,multiselect:`multi-select`,lookup:`search-select`};function nA(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:tA[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=rA(e.successNavigate);return{title:e.label,fields:t,...n?{successNavigate:n}:{}}}function rA(e){let t=String(e??``).trim();return!t||!t.startsWith(`/`)||t.startsWith(`//`)||/^[a-z][a-z0-9+.-]*:/i.test(t)?null:t}function iA(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 aA({apiMap:e={},extraConfigs:r={}}){let i=(0,o.useMemo)(()=>({...Kk,...e}),[e]),a=(0,o.useMemo)(()=>{let e={...Gk};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.xr(u.moduleName,`popup`,s).then(n=>{e||p({key:t,config:nA(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 iA(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)(eA,{open:!0,context:h,onClose:_}):(0,l.jsx)(DD,{open:!0,config:m,context:h,onClose:_,api:{...i[s]??{},...g}})}var oA={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`}]},sA={getVendorList:({jobId:e,limit:t,offset:n,type:r})=>dn({jobId:e,limit:t,offset:n,sortBy:`new`,type:r}),getMailDetails:e=>fn(e),submit:({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})=>mn({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})},cA=oA.vendorColumns.map(e=>({...e,render:e=>e||`-`}));function lA(){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)(oA.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)(oA.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 sA.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&&sA.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([...lT(h.bcc),...z])].join(`, `),showBcc:h.showBcc||z.length>0}),[h,z]);function V(e){let t=new Set(z);g({...e,bcc:lT(e.bcc).filter(e=>!t.has(e)).join(`, `)})}let H=(lT(B.to).length||lT(B.bcc).length)&&uT(B.to)&&uT(B.cc)&&uT(B.bcc)&&B.subject.trim(),U=e=>e===`myVendor`?T:D;function ee(){e(-1)}function te(){H&&sA.submit({jobId:m,toMail:lT(B.to),ccMail:lT(B.cc),bccMail:lT(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 ne=(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:ee,closable:!1,rootClassName:`vendor-share`,width:`95%`,footer:(0,l.jsxs)(`div`,{className:`vendor-share__footer`,children:[(0,l.jsx)(s.Button,{onClick:ee,children:`Cancel`}),(0,l.jsx)(s.Button,{type:`primary`,disabled:!H,onClick:te,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:ee,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:oA.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,` (`,U(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:cA,dataSource:ne,loading:F,pagination:!1,size:`small`,rowSelection:{selectedRowKeys:L,onChange:e=>{e.length>oA.maxVendorSelect||R(e)}},scroll:{y:`calc(100vh - 340px)`}})}),(0,l.jsx)(`div`,{className:`vendor-share__vendor-footer`,children:(0,l.jsx)(Re,{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)(ST,{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,` / `,oA.maxVendorSelect,` Vendors selected`]}):null})})]})})}var uA={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].*$/},dA={SINGLE_FILE_COUNT:1,MULTI_FILE_COUNT:5,MAX_FILE_SIZE:2,ALLOWED_FILE_TYPES:[`image/jpeg`,`image/png`,`application/pdf`]},fA={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 ${dA.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.`},pA={FIRST_NAME_MIN:3,FIRST_NAME_MAX:30},mA={REMARKS_MIN:10,REMARKS_MAX:250},hA={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)}`}},gA={required:(e=`Field`)=>({required:!0,message:fA.REQUIRED(e)}),email:()=>({pattern:uA.EMAIL,message:fA.INVALID_EMAIL}),phone:()=>({pattern:uA.PHONE,message:fA.INVALID_PHONE}),password:()=>({pattern:uA.PASSWORD,message:fA.INVALID_PASSWORD}),alphabets:()=>({pattern:uA.ALPHABETS,message:fA.INVALID_ALPHABETS}),alphanumeric:()=>({pattern:uA.ALPHANUMERIC,message:fA.INVALID_ALPHANUMERIC}),number:()=>({pattern:uA.NUMBER,message:fA.INVALID_NUMBER}),url:()=>({pattern:uA.URL,message:fA.INVALID_URL}),candidateId:(e=`ID`)=>({pattern:uA.CANDIDATE_ID,message:fA.INVALID_CANDIDATE_ID(e)}),remarks:()=>({pattern:uA.REMARKS,message:fA.INVALID_REMARKS,REMARKS_MIN:`Remarks must be at least ${mA.REMARKS_MIN} characters.`,REMARKS_MAX:`Remarks must not exceed ${mA.REMARKS_MAX} characters.`}),designation:()=>({pattern:uA.DESIGNATION,message:fA.INVALID_DESIGNATION}),dob:(e=!0)=>({validator:(t,n)=>{if(!n)return e?Promise.reject(Error(`Date of Birth is required.`)):Promise.resolve();if(!uA.DOB.test(n))return Promise.reject(Error(fA.INVALID_DOB));let r=(0,u.default)(n,`MM/DD/YYYY`,!0);if(!r.isValid())return Promise.reject(Error(fA.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:uA.LINKEDIN,message:fA.INVALID_LINKEDIN}),companyName:()=>({pattern:uA.COMPANY_NAME,message:fA.INVALID_COMPANY_NAME}),firstName:()=>({pattern:uA.FIRST_NAME,message:fA.INVALID_FIRST_NAME,FIRST_NAME_MIN:`First Name must be at least ${pA.FIRST_NAME_MIN} characters.`,FIRST_NAME_MAX:`First Name must not exceed ${pA.FIRST_NAME_MAX} characters.`}),firstNameMinLength:()=>({min:pA.FIRST_NAME_MIN,message:fA.FIRST_NAME_MIN}),firstNameMaxLength:()=>({max:pA.FIRST_NAME_MAX,message:fA.FIRST_NAME_MAX}),remarksMinLength:()=>({min:mA.REMARKS_MIN,message:fA.REMARKS_MIN}),remarksMaxLength:()=>({max:mA.REMARKS_MAX,message:fA.REMARKS_MAX}),fullName:()=>({pattern:uA.FULL_NAME,message:fA.INVALID_FULL_NAME}),noSpaces:()=>({pattern:uA.NO_SPACES,message:fA.NO_SPACES_ALLOWED}),startsWithCapital:()=>({pattern:uA.STARTS_WITH_CAPITAL,message:fA.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<=dA.MAX_FILE_SIZE))return s.message.error(fA.INVALID_FILE_SIZE),Promise.reject(Error(fA.INVALID_FILE_SIZE));if(!dA.ALLOWED_FILE_TYPES.includes(t.type))return Promise.reject(Error(fA.INVALID_FILE_TYPE))}return Promise.resolve()}}),singleFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>dA.SINGLE_FILE_COUNT)return Promise.reject(Error(fA.SINGLE_FILE_ONLY));let n=t[0];return n.size/1024/1024<dA.MAX_FILE_SIZE?dA.ALLOWED_FILE_TYPES.includes(n.type)?Promise.resolve():Promise.reject(Error(fA.INVALID_FILE_TYPE)):Promise.reject(Error(fA.INVALID_FILE_SIZE))}}),multiFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>dA.MULTI_FILE_COUNT)return Promise.reject(Error(fA.INVALID_FILE_COUNT));for(let e of t){if(!(e.size/1024/1024<dA.MAX_FILE_SIZE))return Promise.reject(Error(fA.INVALID_FILE_SIZE));if(!dA.ALLOWED_FILE_TYPES.includes(e.type))return Promise.reject(Error(fA.INVALID_FILE_TYPE))}return Promise.resolve()}})},_A={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)},vA=()=>{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:[gA.required(`Email`),gA.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:[gA.required(`Phone Number`),gA.phone()],validateTrigger:[`onBlur`,`onChange`],children:(0,l.jsx)(s.Input,{maxLength:10,onChange:t=>{e.setFieldsValue({phone:hA.phoneFormatter(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Password`,name:`password`,rules:[gA.required(`Password`),gA.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:[gA.required(`Full Name`),gA.alphabets(),gA.firstNameMinLength(),gA.firstNameMaxLength()],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({fullName:hA.firstNameFormatter(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Username`,name:`username`,rules:[gA.required(`Username`),gA.alphanumeric()],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({username:hA.removeExtraSpaces(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Website URL`,name:`website`,rules:[gA.required(`Website URL`),gA.url()],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({website:hA.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:[gA.required(`MSP Req ID`),gA.candidateId(`MSP Req ID`)],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({mspreqID:hA.removeExtraSpaces(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Candidate ID`,name:`candidateId`,rules:[gA.required(`Candidate ID`),gA.candidateId(`Candidate ID`)],children:(0,l.jsx)(s.Input,{onChange:t=>{e.setFieldsValue({candidateId:hA.removeExtraSpaces(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:24,children:(0,l.jsx)(s.Form.Item,{label:`Remarks`,name:`remarks`,rules:[gA.required(`Remarks`),gA.remarks(),gA.remarksMinLength(),gA.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:[gA.required(`Designation`),gA.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:[gA.dob()],children:(0,l.jsx)(s.Input,{placeholder:`MM/DD/YYYY`,maxLength:10,onChange:t=>{e.setFieldsValue({dob:hA.dobFormatter(t.target.value)})}})})}),(0,l.jsx)(s.Col,{span:12,children:(0,l.jsx)(s.Form.Item,{label:`Company Name`,name:`companyName`,rules:[gA.required(`Company Name`),gA.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:_A.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:[gA.multiFileUpload()],children:(0,l.jsx)(s.Upload,{multiple:!0,beforeUpload:_A.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:[gA.fileUpload()],children:(0,l.jsx)(s.Upload,{beforeUpload:_A.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 yA(e){return(0,l.jsx)(Kv,{children:(0,l.jsx)(iT,{...e})})}var{Text:bA}=s.Typography,xA=[{label:`Total Jobs`,value:1697,icon:`fileText`},{label:`Active Jobs`,value:1685,icon:`checkCircle`},{label:`My Jobs`,value:600,icon:`user`}],SA={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 CA({stats:e=xA}){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:[SA[e.icon]??SA.fileText,(0,l.jsx)(bA,{children:e.label})]}),(0,l.jsx)(s.Statistic,{value:e.value})]})},e.label))})})}var{Text:wA}=s.Typography;function TA(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 EA(e){return{...e,key:e.USER_ID??e.user_id??e.userId??e.id??e._id,_name:TA(e),_email:e.email??e.EMAIL??e.user_email??``,_role:e.role_name??e.roleName??e.ROLE_NAME??``,_rawRef:e}}function DA(){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.mr({offset:e,limit:r,searchQuery:a??``}),s=(o.users??[]).map(EA);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)(vm,{listName:`Users`,dataSource:e,fields:[{label:`Name`,value:`_name`,width:220,render:(e,t)=>(0,l.jsxs)(`div`,{children:[(0,l.jsx)(wA,{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:OA}=s.Typography,kA=[{key:`job`,label:`Jobs`},{key:`candidate`,label:`Candidates`},{key:`submissions`,label:`Submissions`}],AA=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`}];function jA({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 MA({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.Wr(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.hi(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:kA.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)(jA,{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 `,kA.find(e=>e.key===f)?.label]})})]})}function NA(){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.pr();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.mi(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)(vm,{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:AA.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)(MA,{team:e,configType:d},`${e?.teamId}-${d}`)]})]})}var PA=[`view`,`add`,`edit`,`delete`],FA={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 IA(e){return FA[e]??e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function LA(e){let t=PA.filter(t=>e.includes(t)),n=e.filter(e=>!PA.includes(e)).sort();return[...t,...n]}function RA(e){let t=new Set;return Object.values(e).forEach(({permissions:e})=>Object.keys(e??{}).forEach(e=>t.add(e))),LA([...t])}function zA(e){let t=0,n=0;return Object.entries(e).forEach(([e,{permissions:r}])=>{Object.entries(r??{}).forEach(([r,{value:i}])=>{nb(e,r)&&(n++,i===`1`&&t++)})}),{enabled:t,total:n}}function BA(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 VA({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 HA({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 UA({menuName:e,menuData:t,permKeys:n,onChange:r,displayName:i,actionLabels:a,onModuleLabelSave:o,onActionLabelSave:s}){let c=t?.permissions??{},u=n.filter(t=>nb(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)(VA,{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)(HA,{entry:c[t],label:a[t]??IA(t),onToggle:()=>r(e,t),onLabelSave:e=>s(t,e)},t))})]})}function WA({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.zr(e);(0,o.useEffect)(()=>{b&&(h(!0),y(!1),n.Hr(b).then(e=>{let t=BA(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.fi(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)(()=>RA(f),[f]),{enabled:T,total:E}=(0,o.useMemo)(()=>zA(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)(UA,{menuName:e,menuData:f[e],permKeys:w,onChange:x,displayName:t[e]??e,actionLabels:r,onModuleLabelSave:i,onActionLabelSave:a},e))})]})}var{Text:GA}=s.Typography,KA=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`}];function qA(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function JA(e){return String(e||``).trim().toLowerCase()}function YA(e){return e?.key||e?.collectionName||e?.value||``}function XA(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=YA(e);if(!t)return;let o=JA(e.key||t),s=JA(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||qA(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=JA(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:qA(t),value:t,disabled:!1}))}),n}function ZA(){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.fr();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.wr(),n.gr()]),r=XA(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.ri(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)(GA,{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)(vm,{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:KA.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)(WA,{role:e},e?.roleId):(0,l.jsx)(yb,{role:e,configType:a},`${e?.roleId}-${a}`))]})]})}var QA=`perm-module-labels`,$A=`perm-action-labels`;function ej(e){try{return JSON.parse(localStorage.getItem(e)??`{}`)}catch{return{}}}function tj(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function nj({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 rj({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.jr())}catch{s.message.error(`Failed to load modules`)}finally{f(!1)}}async function O(){b(!0);try{v(await n.Ar())}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.Jn({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.ci(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.rr(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.qn({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.si(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.nr(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)(nj,{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)(nj,{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 ij(){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)(()=>ej(QA)),[_,v]=(0,o.useState)(()=>ej($A)),y=(0,o.useCallback)((e,t)=>{g(n=>{let r={...n,[e]:t};return tj(QA,r),r})},[]),b=(0,o.useCallback)((e,t)=>{v(n=>{let r={...n,[e]:t};return tj($A,r),r})},[]);function x(){g({}),v({}),tj(QA,{}),tj($A,{}),s.message.success(`Labels reset to defaults`)}let S=(0,o.useCallback)(async()=>{i(!0);try{let{roles:e}=await n.fr();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)(WA,{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)(rj,{open:p,onClose:()=>m(!1)})]})}var{Title:aj,Text:oj}=s.Typography,sj=[{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 cj({items:e=sj}){return(0,l.jsx)(s.Card,{className:`onboarding-card`,title:(0,l.jsx)(aj,{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)(oj,{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)(oj,{className:`onboarding-item-sub`,children:e.sub})})]})},e.label))})})}var{Text:lj,Title:uj}=s.Typography,dj=[{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.`}]}]}],fj=[{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}],pj=[{name:`Tcs`,jobs:14,candidates:86},{name:`Empasis`,jobs:9,candidates:64},{name:`NovaSystems`,jobs:7,candidates:51},{name:`Brightwave`,jobs:5,candidates:38}],mj=[{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 hj(){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)(uj,{level:5,children:`Admin Dashboard`}),(0,l.jsx)(lj,{type:`secondary`,children:`Overview of jobs, candidates, onboarding and recent activity`})]}),(0,l.jsx)(`div`,{className:`admin-dashboard-stats`,children:(0,l.jsx)(CA,{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)(cj,{}),(0,l.jsxs)(Z,{icon:(0,l.jsx)(c.AppstoreOutlined,{}),title:`Candidate Pipeline`,children:[(0,l.jsx)(lj,{type:`secondary`,style:{fontSize:12},children:`By stage (892 total)`}),(0,l.jsx)(`div`,{className:`admin-pipeline-bar`,children:fj.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:fj.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)(lj,{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)(lj,{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)(lj,{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)(lj,{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:pj.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:mj.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)(lj,{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)(lj,{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)(lj,{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)(lj,{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)(lj,{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)(lj,{style:{fontSize:12},children:e}),(0,l.jsx)(lj,{strong:!0,style:{fontSize:12},children:t})]},e))]})]})})]})}function gj({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)(uj,{level:5,children:e?.heading}),(0,l.jsx)(lj,{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)(lj,{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:dj.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 _j(){let[e,t]=(0,o.useState)(`dashboard`),[n,r]=(0,o.useState)(``),i=(0,o.useMemo)(()=>dj.flatMap(e=>e.items),[]),a=(0,o.useMemo)(()=>i.find(t=>t.id===e),[i,e]),u=(0,o.useMemo)(()=>dj.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)(()=>dj.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:dj.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)(hj,{}):a?.component===`form-groups`?(0,l.jsx)(dS,{}):a?.component===`detail-groups`?(0,l.jsx)(RS,{}):a?.component===`row-actions`?(0,l.jsx)(DC,{}):a?.component===`users`?(0,l.jsx)(DA,{}):a?.component===`teams`?(0,l.jsx)(NA,{}):a?.component===`roles`?(0,l.jsx)(ZA,{}):a?.component===`permissions`?(0,l.jsx)(ij,{}):a?.component===`templates`?(0,l.jsx)(zC,{}):a?.component===`ai-services`?(0,l.jsx)(UC,{}):a?.component===`bgc-integration`?(0,l.jsx)(YC,{}):(0,l.jsx)(gj,{activeSection:a,activeGroup:u,filteredCards:d,searchText:n,setSearchText:r,allItems:i,handleNav:p})})]})]})}var{Title:vj}=s.Typography;function yj(){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:bj,Title:xj}=s.Typography,Sj=10485760,Cj=`/templates/test_cases_flow_template.base64.txt`,wj=`test_cases_flow_template.xlsx`,Tj=`module | subModule | step_order | description | actions | key | value | expected | scenario`,Ej={idle:0,module_set:1,encoding:1,validating:2,preview:3,inserting:3,done:4,error:1},Dj=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Bulk upload`,href:`/bulk-upload`}];function Oj(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 kj(e){return e.filter(e=>e.row_status===`valid`).map(e=>{let t={...e};return delete t.row_status,delete t.errors,t})}function Aj(e){return e.flatMap(e=>(e.errors??[]).map(t=>({id:e.id,...t})))}function jj({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 Mj({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 Nj({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)(bj,{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)(jj,{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 Pj(){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=Aj(x),N=h===`encoding`||h===`validating`,P=!!p&&!N,F=Ej[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 ly({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>Sj){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 Oj(e);g(`validating`);let i=await iy({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(Cj);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=wj,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 ay({project:r?.name??``,module:p,uploaded_by:localStorage.getItem(`user_Email`)??``,rows:kj(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`)}},H=(0,o.useCallback)(()=>{a.current?.scrollIntoView({behavior:`smooth`,block:`center`})},[]),U=[`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:Dj})}),r?.name&&(0,l.jsx)(s.Col,{children:(0,l.jsx)(bj,{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)(xj,{level:3,children:`Bulk upload test cases`}),(0,l.jsxs)(s.Space,{direction:`vertical`,size:4,children:[(0,l.jsx)(bj,{type:`secondary`,children:Tj}),(0,l.jsx)(bj,{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:U,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)(Mj,{errors:M,expanded:k,onToggle:()=>A(e=>!e),onSummaryClick:H}),T&&h===`preview`&&(0,l.jsx)(s.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`}),(0,l.jsx)(Nj,{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)(bj,{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)(bj,{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)(bj,{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 Fj=[{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:Ij}=s.Typography,Lj=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}],Rj={tags:`regression`,active:1},zj={module:{dbName:`Modules`,formField:`module`,label:`Module`}};function Bj(e=[]){return e.map(e=>({value:e,label:e}))}function Vj(e=``){return String(e??``).trim()}function Hj(e=``){return Vj(e).toLowerCase()}function Uj(e=[]){let t=new Map;return e.forEach(e=>{let n=Vj(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function Wj(e=[],t,n){let r=Vj(t).toLowerCase(),i=Vj(n).toLowerCase();return e.reduce((e,t)=>{let n=Vj(t?.module).toLowerCase(),a=Vj(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 Gj({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)(Ij,{strong:!0,className:`v1-section-label`,children:t})]})}function Kj(){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=zj[v.typeKey],O=(0,o.useMemo)(()=>Bj(r),[r]),k=s.Form.useWatch(`module`,e),A=s.Form.useWatch(`flow`,e),j=!!Vj(k),M=!!Vj(A),N=!j,P=!j||!M,F=(e,t=[])=>{e===`module`&&i(t)},I=async()=>{h(!0);try{let e=await $v(zj.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=Vj(t);if(u([]),p([]),e.setFieldsValue({step_order:void 0}),n){_(!0);try{let e=await ry({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];u(t),p(Uj(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=Vj(t),a=Vj(n);if(!i||!a){e.setFieldsValue({step_order:void 0});return}C(!0);try{e.setFieldsValue({step_order:Wj(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:Vj(t.module),flow:Vj(t.flow),step_order:Number(t.step_order),description:Vj(t.description),keyword:Hj(t.keyword),target:Vj(t.target),value:Vj(t.value),expected:Vj(t.expected),tags:t.tags?Vj(t.tags):Rj.tags,active:Number(t.active)};T(!0);try{await ny(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]:Vj(n)})},V=t=>{e.setFieldsValue({module:Vj(t),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:Rj.tags,value:void 0,expected:void 0})},H=t=>{e.setFieldsValue({flow:Vj(t),step_order:void 0})},U=e=>{let n=zj[e];y({open:!0,typeKey:e}),t.setFieldsValue({name:``,type:n.label})},ee=()=>{y(e=>({...e,open:!1})),t.resetFields()},te=async()=>{try{let n=Vj((await t.validateFields()).name),r=await ey({name:n,type:D.dbName});F(v.typeKey,r?.items??[]),e.setFieldsValue({[D.formField]:n}),s.message.success(`${D.label} added successfully.`),ee()}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:Lj})}),(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)(Ij,{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:Rj,onFinish:z,autoComplete:`off`,children:[(0,l.jsx)(s.Card,{className:`v1-card`,title:(0,l.jsx)(Gj,{icon:(0,l.jsx)(c.FileTextOutlined,{}),title:`Test Case Details`}),extra:(0,l.jsx)(Ij,{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:()=>U(`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:H,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:Fj,onChange:t=>e.setFieldsValue({keyword:Hj(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:ee,onOk:()=>{x(!0),te()},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:Vj(e.target.value)})}})}),(0,l.jsx)(s.Form.Item,{label:`Type`,name:`type`,children:(0,l.jsx)(s.Input,{disabled:!0})})]})})]})})]})}var{Text:qj}=s.Typography,Jj=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`}];function Yj(e=``){return String(e??``).trim()}function Xj(e=[],t){return e.map(e=>({value:e.id,label:e[t]}))}var Zj=[{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`})}],Qj={key:!1,value:!1,expected:!1};function $j(e,t){return t?e[t]??Qj:Qj}function eM(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function tM(){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)(Fj),[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)(()=>$j(x,F),[x,F]),z=(0,o.useMemo)(()=>Xj(p,`modulename`),[p]),B=(0,o.useMemo)(()=>Xj(h,`submodulename`),[h]),V=(0,o.useMemo)(()=>p.find(e=>e.id===N)?.modulename??``,[p,N]),H=(0,o.useMemo)(()=>h.find(e=>e.id===P)?.submodulename??``,[P,h]),U=(0,o.useCallback)(async()=>{try{let e=await ty();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.`)}},[]),ee=(0,o.useCallback)(async e=>{if(!e){m([]);return}w(!0);try{let t=await ly({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)}},[]),te=(0,o.useCallback)(async(e,t)=>{if(!e||!t){g([]);return}E(!0);try{let n=await fy({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)}},[]),ne=(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([hy({product_parent_ID:t,module_parent_ID:n,submodule_parent_ID:r,actions:i,limit:1e3}),vy({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]),re=(0,o.useCallback)(async(e=``)=>{if(!(!f?.id||!N||!P)){O(!0);try{let t=await hy({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]),ie=(0,o.useCallback)(async()=>{if(!(!a||!f?.name)){M(!0);try{let t=await _y(a);await te(f.name,t.module);let n=await hy({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,te,r,f?.name]);return(0,o.useEffect)(()=>{if(!f){r(`/select-project`,{replace:!0});return}Promise.resolve().then(async()=>{await U(),await ee(f.name),a&&await ie()})},[f,r,U,ee,a,ie]),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:Jj})}),(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)(qj,{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:Yj(t.description),actions:Yj(t.actions),key:Yj(t.key),value:Yj(t.value),expected:Yj(t.expected),scenario:+!!t.scenario,active:+!!t.active};A(!0);try{if(u){await yy(a,{...n,step_order:Number(t.step_order)}),s.message.success(`Test case updated successfully.`),r(`/viewTestCase`);return}await gy(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 ne(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}),eM(e,[`actions`,`key`,`value`,`expected`]),g([]),v([]),te(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}),eM(e,[`actions`,`key`,`value`,`expected`]),ne(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)(qj,{type:`secondary`,children:[V,` / `,H]}),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=$j(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}),eM(e,[`key`,`value`,`expected`]),re(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)(vm,{listName:`Added Steps`,loading:D,fields:Zj,dataSource:_,current:1,pageSize:Math.max(_.length,1),total:_.length,rowSelection:!1,className:`zt-list-plain zt-list-static`})})]})})]}):null}var{Text:nM}=s.Typography,rM=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`}];function iM(){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([ly({project:e}),fy({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 dy(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 uy({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:rM})}),(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)(nM,{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)(vm,{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)(nM,{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:aM}=s.Typography,oM=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`},{label:`Manage Submodules`,href:`/test-cases/zinnext/submodules`}];function sM(){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 fy({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 my(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 py({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:oM})}),(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)(aM,{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)(aM,{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)(vm,{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)(aM,{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:cM}=s.Typography,lM=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Table`,href:`/viewTestCase`}];function uM(){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 hy({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 by(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:lM})}),(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)(cM,{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)(vm,{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 dM=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}];function fM(){return(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsx)(n.t,{items:dM}),(0,l.jsx)(Lo,{moduleName:`test-flows`,rowKey:`id`})]})}var{Text:pM}=s.Typography,mM=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}],hM={tags:`regression`,active:1},gM={module:{dbName:`Modules`,formField:`module`,label:`Module`}},_M={key:!1,value:!1,expected:!1};function vM(e,t){return t?e[t]??_M:_M}function yM(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function bM(e=[]){return e.map(e=>({value:e,label:e}))}function xM(e=``){return String(e??``).trim()}function SM(e=[]){let t=new Map;return e.forEach(e=>{let n=xM(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function CM(e=[],t,n){let r=xM(t).toLowerCase(),i=xM(n).toLowerCase();return e.reduce((e,t)=>{let n=xM(t?.module).toLowerCase(),a=xM(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 wM({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)(pM,{strong:!0,className:`v1-section-label`,children:t})]})}function TM(){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)(Fj),[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=gM[S.typeKey],M=(0,o.useMemo)(()=>bM(r),[r]),N=s.Form.useWatch(`module`,e),P=s.Form.useWatch(`flow`,e),F=s.Form.useWatch(`keyword`,e),I=!!xM(N),L=!!xM(P),R=!I,z=!I||!L,B=(0,o.useMemo)(()=>vM(g,F),[g,F]),V=(e,t=[])=>{e===`module`&&i(t)},H=async()=>{y(!0);try{let e=await $v(gM.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)}},U=async()=>{try{let e=await ty();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.`)}},ee=(0,o.useCallback)(async t=>{let n=xM(t);if(u([]),p([]),e.setFieldsValue({step_order:void 0}),n){x(!0);try{let e=await sy({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];u(t),p(SM(t))}catch(e){console.error(`Unable to load flows:`,e),s.message.error(`Unable to load flows.`)}finally{x(!1)}}},[e]),te=(0,o.useCallback)(async(t,n,r)=>{let i=xM(t),a=xM(n);if(!i||!a){e.setFieldsValue({step_order:void 0});return}D(!0);try{e.setFieldsValue({step_order:CM(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([H(),U()])})},[]),(0,o.useEffect)(()=>{Promise.resolve().then(()=>ee(N))},[ee,N]),(0,o.useEffect)(()=>{Promise.resolve().then(()=>te(N,P,a))},[a,te,P,N]);let ne=async t=>{let n={module:xM(t.module),flow:xM(t.flow),step_order:Number(t.step_order),description:xM(t.description),keyword:xM(t.keyword),target:xM(t.target),value:xM(t.value),expected:xM(t.expected),tags:t.tags?xM(t.tags):hM.tags,active:Number(t.active)};k(!0);try{await oy(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)}},re=(t,n)=>{e.setFieldsValue({[t]:xM(n)})},ie=t=>{e.setFieldsValue({module:xM(t),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:hM.tags,value:void 0,expected:void 0}),yM(e,[`keyword`,`target`,`value`,`expected`])},ae=t=>{e.setFieldsValue({flow:xM(t),step_order:void 0,keyword:void 0,target:void 0,value:void 0,expected:void 0}),yM(e,[`keyword`,`target`,`value`,`expected`])},W=t=>{let n=vM(g,t);e.setFieldsValue({keyword:xM(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}),yM(e,[`target`,`value`,`expected`])},G=e=>{let n=gM[e];C({open:!0,typeKey:e}),t.setFieldsValue({name:``,type:n.label})},oe=()=>{C(e=>({...e,open:!1})),t.resetFields()},se=async()=>{try{let n=xM((await t.validateFields()).name),r=await ey({name:n,type:j.dbName});V(S.typeKey,r?.items??[]),e.setFieldsValue({[j.formField]:n}),s.message.success(`${j.label} added successfully.`),oe()}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:mM})}),(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)(pM,{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:hM,onFinish:ne,autoComplete:`off`,children:[(0,l.jsx)(s.Card,{className:`v1-card`,title:(0,l.jsx)(wM,{icon:(0,l.jsx)(c.FileTextOutlined,{}),title:`LMS Case Details`}),extra:(0,l.jsx)(pM,{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:ie})}),(0,l.jsx)(s.Button,{"aria-label":`Add module`,icon:(0,l.jsx)(c.PlusOutlined,{}),style:{marginTop:30},onClick:()=>G(`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:ae,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:W})})}),(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=>re(`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=>re(`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=>re(`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=>re(`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=>re(`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:oe,onOk:()=>{T(!0),se()},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:xM(e.target.value)})}})}),(0,l.jsx)(s.Form.Item,{label:`Type`,name:`type`,children:(0,l.jsx)(s.Input,{disabled:!0})})]})})]})})]})}var EM=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}];function DM(){return(0,l.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,l.jsx)(n.t,{items:EM}),(0,l.jsx)(Lo,{moduleName:`lms-flows`,rowKey:`id`})]})}var OM=[`referenceId`,`ReferenceId`,`candidateId`,`CandidateId`,`entityId`,`EntityId`,`id`,`Id`,`_id`];function kM(e=OM){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 AM(e,t=OM){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 jM=kM();function MM(e){return typeof e==`function`?e:typeof e==`string`?kM([e]):Array.isArray(e)?kM(e):jM}function NM(e,t,n){return!t||typeof t!=`object`?e:{...t,...e,id:e?.id??t?.id??n}}function PM(e,t,n={}){return{status:`success`,total:t,data:{data:e,...n}}}var FM=[`fields`,`fieldConfig`,`tabs`,`tabField`,`actionRules`,`actions`,`columnActions`];function IM(e){let t=e?.data??e,n={};for(let r of FM){let i=e?.[r]??t?.[r];i==null||Array.isArray(i)&&i.length===0||(n[r]=i)}return n}var LM=e=>String(e??``).replace(/[^a-zA-Z0-9]/g,``).toLowerCase();function RM(e,t,n){let r=(Array.isArray(n)?n:[n]).map(LM).filter(Boolean),i=r.length?e.findIndex(e=>r.includes(LM(e?.value))||r.includes(LM(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 zM=(e,t)=>ri(e,t).rows,BM=(e,t)=>{let{rows:n,total:r}=ri(e,t);return{rows:n,total:r}};function VM(e,t){return function(n,r,i,a={}){return e(t??n,r,i,a)}}function HM(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:zM,mergeRow:typeof e.mergeRow==`function`?e.mergeRow:NM,fetchById:typeof e.fetchById==`function`?e.fetchById:null}}function UM({fetchSecondaryByKeys:e,fetchSecondary:t,extractSecondaryRows:n,fetchSecondaryById:r,secondaryKey:i,mergeRow:a,secondaryFetchLimit:o}){return!e&&!t&&!r?[]:[HM({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 WM(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:OM;return e=>AM(e,t)}function GM(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 KM({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 qM(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 JM({fetchPrimaryPage:e,extractPrimaryPage:t=BM,fetchSecondaryByKeys:n,joinSources:r=[],fetchPrimary:i,extractPrimaryRows:a=zM,fetchSecondary:o,extractSecondaryRows:s=zM,fetchSecondaryById:c,primaryKey:l,secondaryKey:u,mergeRow:d=NM,secondaryFetchLimit:f=200,extraFields:p=[],extraFieldsAfter:m}){let h=Array.isArray(r)&&r.length?r.map(HM).filter(Boolean):UM({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=MM(t.primaryKey??l),s=WM(t.key),c=GM(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=IM(e);for(let e of Object.keys(t))r[e]??(r[e]=t[e])}return p.length&&(r.fields=RM(r.fields??[],p,m)),PM(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=MM(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 qM(c,KM({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 YM(e,t,n={}){return JM({fetchPrimary:()=>hO(e,t),extractPrimaryRows:pO,fetchSecondary:On,fetchSecondaryById:gO,secondaryFetchLimit:n.moduleFetchLimit??200})}function XM(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 ZM(e){let t=Array.isArray(e?.stages)?e.stages:[];if(!t.length)return e;let n={};for(let e of t){let t=XM(e?.stageName);t&&(n[t]=Number(e?.count)||0)}return{...n,...e}}var QM=e=>{let t=Number(e?.targetSubmission??e?.targetSubmissions);return Number.isFinite(t)&&t>0?t:null};function $M({submittedCountField:e=`submittedCount`,progressField:t=`targetSubmissionProgress`}={}){return function(n,r,i){let a=NM(n,r,i),o=QM(a);return o!=null&&(a[t]=`${Number(a?.[e])||0} of ${o}`),a}}function eN(e={}){let t=$M();return JM({primaryKey:`_id`,extraFields:e.extraFields,extraFieldsAfter:e.extraFieldsAfter,fetchPrimaryPage:On,joinSources:[{key:`entityId`,fetchByKeys:(e,t,n,r)=>{let i=Math.max(1,Number(r?.limit)||10);return mO(Math.floor((Number(r?.offset)||0)/i)+1,i)},extractRows:e=>(e?.items??[]).map(ZM),mergeRow:(e,n,r)=>{let i=t(e,n,r);return n?._id&&(i.workflowId=n._id),i}}]})}async function tN(e,t=10,n=0,r={},i={}){return ri(await eN(i)(e,t,n,r),e)}async function nN(e,t,n,r=10,i=0,a={}){return ri(await YM(e,t)(n,r,i,a),n)}typeof window<`u`&&(window.__CORE_THEME_BUILD__=`2026-08-24T09:45:01.778Z`);var rN=yA,iN=Cy(_j),aN=Cy(yj),oN=Cy(Pj),sN=Cy(Kj),cN=Cy(tM),lN=Cy(iM),uN=Cy(sM),dN=Cy(uM),fN=Cy(fM),pN=Cy(TM),mN=Cy(DM);exports.ADMIN_API_URL=t.v,exports.ADMIN_APP_ID=t.y,exports.APP_ID=t.b,exports.AUTH_URL=t.x,exports.ActivityNotesCard=Mc,exports.ActivityTab=Dc,exports.AddBatchCandidatePopup=eA,exports.AddFormV1=uc,exports.AdminDashboard=yA,exports.AdminDashboardContent=iT,exports.AdminPage=rN,exports.AppAlert=dc,exports.AppButton=n.lt,exports.AppShell=Kv,exports.ApprovalActionBar=cg,exports.AssigneeAvatars=Nc,exports.AuthGuard=zv,exports.BILLING_STATUS_FLOW=Hd,exports.BOOLEAN_API_KEYS=Zm,exports.BOOLEAN_PARSEABLE_API_KEYS=Km,exports.BULK_UPLOAD_DEFAULT_ACCEPT=Pc,exports.BULK_UPLOAD_DEFAULT_MAX_SIZE_MB=Fc,exports.Breadcrumb=n.t,exports.BulkUploadPage=oN,exports.BulkUploadPanel=Uc,exports.CANDIDATES_URL=t.S,exports.CONTRACT_C2C=Mg,exports.CONTRACT_W2=jg,exports.CURRENCY_SYMBOLS=Zl,exports.CalendarCard=A,exports.CoreThemeAdminApp=cT,exports.CoreThemeAdminRoutes=sT,exports.CustomPagination=Re,exports.DEFAULT_HOURS_POLICY=Ah,exports.DayLogModal=eg,exports.DescriptionBlock=nl,exports.DetailHeaderCard=Gf,exports.DetailViewPage=Qf,exports.DetailViewV1=Vu,exports.DocumentViewer=n.Cn,exports.DynamicCards=Pt,exports.DynamicPopup=DD,exports.DynamicPopupRoute=aA,exports.DynamicTabs=P,exports.EditFormV1=Xp,exports.FIELD_TYPE_REGISTRY=km,exports.FINANCE_APPROVAL_CONFIG=Cg,exports.FINANCE_TYPE_CFO=gg,exports.FINANCE_TYPE_ONBOARDING_MANAGER=hg,exports.FINANCE_TYPE_ONBOARDING_MANAGER_REAPPROVE=yg,exports.FINANCE_TYPE_ONLY_FINANCE=_g,exports.FINANCE_TYPE_SUBMISSION_MANAGER=mg,exports.FINANCE_TYPE_SUBMISSION_MANAGER_REAPPROVE=vg,exports.FileListCard=L_,exports.FinanceApprovalPanel=g_,exports.FinanceAvatar=wf,exports.FinanceBadge=Of,exports.FinanceDayCell=ug,exports.FinanceDivider=gf,exports.FinanceEmployeeCell=Tf,exports.FinanceEmptyState=pf,exports.FinanceEquation=_f,exports.FinanceHistoryTimeline=xf,exports.FinanceHoursGrid=ff,exports.FinanceKpiRow=df,exports.FinanceLine=hf,exports.FinanceListToolbar=kh,exports.FinanceMarginBadge=kf,exports.FinanceMoneyCell=Df,exports.FinanceRecordsTable=Mf,exports.FinanceRowChevron=Af,exports.FinanceSection=mf,exports.FinanceStatusPill=uf,exports.FinanceTextCell=Ef,exports.FinanceTimesheetAnalysis=fg,exports.FinanceWorkflowSteps=vf,exports.HOURS_MESSAGES=jh,exports.Header=fv,exports.HierarchyUserFilter=zt,exports.JOBS_URL=t.C,exports.LegacyAdminPage=iN,exports.ListView=Lo,exports.LmsHomePage=mN,exports.LmsTestForm=pN,exports.Login=qv,exports.MailPopup=LT,exports.ManageModules=lN,exports.ManageSubmodules=uN,exports.ModuleRowActions=am,exports.NotesPanel=sg,exports.NotesTab=jc,exports.PAYROLL_STATUS_FLOW=Ud,exports.POPUP_CONFIGS=Gk,exports.ParamCardView=fm,exports.ParamListView=vm,exports.PeriodBadgeTag=Uh,exports.PreviewPopup=mE,exports.ProjectSelect=Sy,exports.ProofUploadPreview=og,exports.QuickLogBar=rg,exports.QuickLogSelectionBar=tg,exports.RejectionReasonModal=ng,exports.SUBMISSIONS_URL=t.T,exports.SearchBuilderV1=bh,exports.Sidebar=Fv,exports.StatusBadge=Sh,exports.StatusBadgeTag=Hh,exports.StickyNotesFullPage=aN,exports.StylishDynamicTabs=wh,exports.TemplateEditor=Eh,exports.TestForm=sN,exports.TestingHomePage=fN,exports.TimelineGroups=yc,exports.TimesheetDayCell=Zh,exports.TipTapEditor=n.wn,exports.UserForm=vA,exports.VendorShareDrawer=lA,exports.ViewSummaryWidget=ki,exports.WizardPopup=bE,exports.ZinnextTableView=dN,exports.ZinnextTestForm=cN,exports.appNow=n.On,exports.applyIntegrationStatus=n.Wn,exports.approveSubmission=be,exports.buildAcceptAttr=Bc,exports.buildBooleanRequest=nh,exports.buildCsv=rf,exports.buildDailyRows=Zd,exports.buildDayGradient=Yh,exports.buildRateHistoryEntries=r_,exports.buildWeeklyRollup=ef,exports.clearSelectedProject=t.i,exports.colors=n.Dn,exports.computeFinance=Yg,exports.computeHoursPolicy=Lh,exports.computeMarginBand=tf,exports.conditionMatches=n.i,exports.configureCoreTheme=t.E,exports.configuredFieldLabel=n.a,exports.createAllWorkflowsListFetcher=eN,exports.createMergedListFetcher=JM,exports.createModuleListFetchAdapter=VM,exports.createWorkflowStageListFetcher=YM,exports.currencySymbol=Ql,exports.defaultMergeRow=NM,exports.deleteIntegrationConfig=n.tr,exports.deriveDayStats=Xd,exports.describeCapacity=zh,exports.downloadCsv=cf,exports.evaluateShowIfWith=n.o,exports.findEmployerRow=Ug,exports.flattenGroups=Vg,exports.formatAmount=iu,exports.formatApp=n.kn,exports.formatAppDateTime=n.An,exports.formatFileSize=zc,exports.formatFinanceMoney=i_,exports.formatHours=Nd,exports.formatMoney=au,exports.formatPercent=Fd,exports.formatRate=ou,exports.getActivity=n.un,exports.getAllWorkflowsModuleList=tN,exports.getAppTimeZone=n.jn,exports.getApprovalDate=zd,exports.getBgcIntegrationConfig=n.vr,exports.getBgcIntegrationSummary=n.yr,exports.getBillingActionStates=Wd,exports.getBooleanEligibleTypes=Nm,exports.getCurrentRoleName=t.c,exports.getFieldLabel=of,exports.getFieldType=jm,exports.getFileExtension=Rc,exports.getFinanceApprovalConfig=Og,exports.getFormGroupsRaw=E_,exports.getIntegrationConfig=n.Tr,exports.getIntegrationConfigs=n.Er,exports.getIntegrationSummary=n.Dr,exports.getModuleConfig=Fe,exports.getModuleDataDetail=n.fn,exports.getPayrollActionStates=Gd,exports.getPeriodBadgeConfig=Le,exports.getSelectedProject=t.l,exports.getStoredToken=t.u,exports.getStoredUser=t.d,exports.getUserRoles=t.f,exports.getVMSApprove=xe,exports.getValueStyle=sf,exports.getWorkflowStageModuleList=nN,exports.getWorkflowSteps=Kd,exports.humanizeEvent=Rd,Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return cs}}),exports.indexFieldConfig=af,exports.initialsOf=Id,exports.insertTokenAtCursor=Xm,exports.isBooleanEligible=Mm,exports.isBooleanParsable=Jm,exports.isTester=t.p,exports.logout=t.h,exports.marginIncludesReferral=Ag,exports.matchLocationTax=Jg,Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return op}}),exports.normalizeContract=Gg,Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Wc}}),exports.rateUnitLabel=eu,exports.rateUnitShort=nu,exports.reconcileHours=Rh,exports.registerFieldType=Am,exports.rejectSubmission=Se,exports.resolveActivityMeta=wc,exports.resolveAndCompute=Xg,exports.resolveDayKind=Fh,exports.resolveFinanceInputs=qg,exports.resolveMergeKey=jM,exports.resolveMergedListKey=jM,exports.resolveRejectionReason=kg,exports.resolveSubmissionFinance=D_,exports.saveBgcIntegrationConfig=n.Yr,exports.saveIntegrationConfig=n.Qr,exports.setSelectedProject=t._,exports.showIfConditions=n.c,exports.stageCountKey=XM,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Jv}}),exports.testIntegrationConnection=n.ii,exports.toApp=n.Nn,exports.toNumber=ru,exports.tzLabel=n.Pn,exports.tzShortLabel=n.Fn,exports.useDropdownFields=Wn,exports.useDropdownValues=Ai,exports.useEditForm=R_,exports.useFieldConfig=Gn,exports.useFilterFields=Kn,exports.useMenuPermission=tr,exports.useModuleActions=Qp,exports.useRecordRefresh=Yf,exports.validateBooleanQuery=Ym,exports.validateBulkFile=Vc,exports.withAdminAppId=t.D,exports.withAppId=t.O,exports.withAuthGuard=Cy;
23
23
  //# sourceMappingURL=index.cjs.map