@realtek/core-theme 0.0.221 → 0.0.222
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.
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/index.cjs.map +1 -1
- package/dist-lib/index.js +802 -681
- package/dist-lib/index.js.map +1 -1
- package/dist-lib/style.css +1 -1
- package/package.json +1 -1
package/dist-lib/index.cjs
CHANGED
|
@@ -6,5 +6,5 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
6
6
|
`).replace(/<[^>]+>/g,` `),t=t.replace(/ /gi,` `).replace(/&/gi,`&`).replace(/</gi,`<`).replace(/>/gi,`>`).replace(/'|'/gi,`'`).replace(/"/gi,`"`),t.replace(/[ \t\f\v]+/g,` `).replace(/\n{2,}/g,`
|
|
7
7
|
`).trim()}function _b(e){return e.replace(/•/g,`
|
|
8
8
|
`).split(/\n+/).map(e=>e.trim().replace(/^[-–—•]\s*/,``).trim()).filter(Boolean)}function vb(e){return _b(e.replace(/(?:^|\s)[-–—]\s+/g,`
|
|
9
|
-
`))}function yb(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:mb(n),value:r}}function bb(e){let t=e.toLowerCase().replace(/[\s:.\-–—]+$/,``).trim();return ub.has(t)?db.test(t)?`education`:fb.test(t)?`keySkills`:`overview`:null}function xb(e){let t=[],n={overview:[],keySkills:[],education:[]},r=`overview`;return e.forEach(e=>{let i=bb(e);if(i){r=i;return}if(r===`overview`){let n=yb(e);if(n){t.push(n);return}}n[r].push(e)}),{meta:t,overview:hb(n.overview),keySkills:hb(n.keySkills),education:hb(n.education)}}function Sb(e){let t=[...lb].sort((e,t)=>t.length-e.length),n=RegExp(`\\b(${t.map(pb).join(`|`)})\\b\\s*:?`,`gi`),r=[...e.matchAll(n)];if(!r.length)return{meta:[],overview:hb(vb(e)),keySkills:[],education:[]};let i={overview:[],keySkills:[],education:[]},a=e.slice(0,r[0].index).trim();return a&&i.overview.push(...vb(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=vb(e.slice(o,s).trim());c.length&&i[db.test(a)?`education`:fb.test(a)?`keySkills`:`overview`].push(...c)}),{meta:[],overview:hb(i.overview),keySkills:hb(i.keySkills),education:hb(i.education)}}function Cb(e){let t=gb(e);if(!t)return{meta:[],overview:[],keySkills:[],education:[]};let n=_b(t);return n.length>=4?xb(n):Sb(t)}function wb({items:e}){return(0,o.jsx)(`ul`,{className:`jdv-ats-bullets`,children:e.map((e,t)=>(0,o.jsx)(`li`,{className:`jdv-ats-bullet-item`,children:e},t))})}function Tb({raw:e=``,meta:t=[]}){let[n,i]=(0,r.useState)(!1),a=(0,r.useMemo)(()=>Cb(e),[e]),s=t.length?t:a.meta,c=[];if(a.overview.length&&c.push({key:`overview`,title:`Overview`,items:a.overview}),a.keySkills.length&&c.push({key:`keySkills`,title:`Key Skills`,items:a.keySkills,card:!0,icon:`🛠️`}),a.education.length&&c.push({key:`education`,title:`Education`,items:a.education,card:!0,icon:`🎓`}),!s.length&&!c.length)return(0,o.jsx)(sb,{type:`secondary`,children:`No description available.`});let l=n?c:c.slice(0,cb),u=c.length-cb;return(0,o.jsxs)(`div`,{className:`jdv-ats-desc`,children:[s.length>0&&(0,o.jsx)(`div`,{className:`jdv-ats-meta-grid`,children:s.map(({fieldKey:e,fieldLabel:t,value:n})=>(0,o.jsxs)(`div`,{className:`jdv-ats-meta-row`,children:[(0,o.jsx)(`span`,{className:`jdv-ats-meta-key`,children:t}),(0,o.jsx)(`span`,{className:`jdv-ats-meta-val`,children:n})]},e??t))}),(0,o.jsx)(`div`,{className:`jdv-ats-sections`,children:l.map(e=>e.card?(0,o.jsxs)(`div`,{className:`education-block`,children:[(0,o.jsxs)(`div`,{className:`education-header`,children:[(0,o.jsx)(`span`,{children:e.icon}),(0,o.jsx)(`span`,{children:e.title})]}),(0,o.jsx)(`ul`,{className:`education-list`,children:e.items.map((e,t)=>(0,o.jsx)(`li`,{className:`education-list-item`,children:e},t))})]},e.key):(0,o.jsxs)(`div`,{className:`jdv-ats-section`,children:[(0,o.jsx)(`div`,{className:`jdv-ats-section-hd`,children:(0,o.jsx)(`span`,{children:e.title})}),(0,o.jsx)(wb,{items:e.items})]},e.key))}),u>0&&(0,o.jsx)(`span`,{className:`jdv-desc-toggle`,onClick:()=>i(e=>!e),children:n?`Show less`:`Show more (${u} more section${u>1?`s`:``})`})]})}var{Text:Eb}=i.Typography;function Db(e){return e?e.trim().split(/\s+/).slice(0,2).map(e=>e[0].toUpperCase()).join(``):`?`}function Ob(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 kb(e){return e?e.email??e.emailId??e.emailAddress??``:``}function Ab(e){return e?e.status?e.status:e.stage?e.stage:typeof e.isActive==`boolean`?e.isActive?`Active`:`Inactive`:``:``}function jb(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 Mb=[`jobDescription`,`description`,`rawDescription`,`jobDescriptionText`];function Nb(e){return String(e??``).toLowerCase()===`job`}function Pb(e){let t=Mb.includes(e.field),n=/description/i.test(e.label??``);return t||n}function Fb({steps:e,current:t,onStepClick:n}){return(0,o.jsx)(`div`,{className:`preview-stepper`,children:e.map((i,s)=>{let c=s<t,l=s===t,u=s===e.length-1;return(0,o.jsxs)(r.Fragment,{children:[(0,o.jsxs)(`button`,{type:`button`,className:`preview-stepper__item${l?` preview-stepper__item--active`:``}`,onClick:()=>n(s),"aria-label":`Go to step ${s+1}: ${i.title}`,"aria-current":l?`step`:void 0,children:[(0,o.jsx)(`div`,{className:[`preview-stepper__circle`,c?`preview-stepper__circle--done`:``,l?`preview-stepper__circle--active`:``].filter(Boolean).join(` `),children:c?(0,o.jsx)(a.CheckOutlined,{}):s+1}),(0,o.jsx)(`span`,{className:`preview-stepper__label${l?` preview-stepper__label--active`:``}`,children:i.title})]}),!u&&(0,o.jsx)(`div`,{className:`preview-stepper__line${c?` preview-stepper__line--done`:``}`})]},i.title??s)})})}function Ib({record:e}){let t=Ob(e),n=kb(e),r=Ab(e);return!t&&!n?null:(0,o.jsxs)(`div`,{className:`preview-profile-card`,children:[(0,o.jsxs)(`div`,{className:`preview-profile-card__info`,children:[(0,o.jsx)(i.Avatar,{className:`preview-profile-card__avatar`,children:Db(t)}),(0,o.jsxs)(`div`,{className:`preview-profile-card__text`,children:[t&&(0,o.jsx)(`span`,{className:`preview-profile-card__name`,children:t}),n&&(0,o.jsx)(`span`,{className:`preview-profile-card__email`,children:n})]})]}),r&&(0,o.jsx)(i.Tag,{className:`preview-profile-card__status`,children:r})]})}function Lb({fields:e,moduleName:t}){return e?.length?(0,o.jsx)(`div`,{className:`preview-field-grid`,children:e.map(e=>{let n=e.value,r=Array.isArray(n)&&n.length>0,i=Nb(t)&&Pb(e)&&typeof n==`string`&&n.trim();return r?n.map((t,r)=>(0,o.jsxs)(`div`,{className:`preview-field-card`,children:[(0,o.jsxs)(`span`,{className:`preview-field-card__label`,children:[e.label,n.length>1?` (${r+1})`:``]}),(0,o.jsx)(`span`,{className:`preview-field-card__value`,children:jb(t)})]},`${e.field??e.label}-${r}`)):i?(0,o.jsxs)(`div`,{className:`preview-field-card preview-field-card--description`,children:[(0,o.jsx)(`span`,{className:`preview-field-card__label`,children:e.label}),(0,o.jsx)(`div`,{className:`preview-field-card__description`,children:(0,o.jsx)(Tb,{raw:n})})]},e.field??e.label):(0,o.jsxs)(`div`,{className:`preview-field-card`,children:[(0,o.jsx)(`span`,{className:`preview-field-card__label`,children:e.label}),(0,o.jsx)(`span`,{className:`preview-field-card__value`,children:jb(n)})]},e.field??e.label)})}):null}function Rb(){let t=(0,s.useNavigate)(),{moduleName:n=``,record:c=null}=(0,s.useLocation)().state??{},l=c?.id??c?._id,[u,d]=(0,r.useState)([]),[f,p]=(0,r.useState)(!!(n&&l)),[m,h]=(0,r.useState)(null),[g,_]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(!n||!l)return;let t=!1;return e.Hn({module:n,id:l}).then(e=>{t||(d(Array.isArray(e)?e:[]),p(!1))}).catch(e=>{t||(h(e.message||`Failed to load preview`),p(!1))}),()=>{t=!0}},[n,l]);function v(){t(-1)}let y=u.length,b=y>1,x=u[g],S=y>4?`min(${y*105+80}px, min(95vw, 1200px))`:`min(680px, calc(100vw - 32px))`,C=u.map((e,t)=>({title:e.label??e.name??`Step ${t+1}`})),w=(0,o.jsxs)(`div`,{className:`preview-modal-header`,children:[(0,o.jsx)(`span`,{className:`preview-modal-module`,children:n.toUpperCase()}),(0,o.jsx)(`span`,{className:`preview-modal-title`,children:x?.label??(n?`Preview - ${n}`:`Preview`)})]}),T=(0,o.jsxs)(`div`,{className:`wizard-footer`,children:[b&&(0,o.jsxs)(Eb,{className:`preview-footer-step-count`,children:[`Step `,g+1,` of `,y]}),(0,o.jsxs)(`div`,{className:`wizard-footer-nav`,children:[(0,o.jsx)(i.Button,{onClick:v,children:`Close`}),b&&g>0&&(0,o.jsx)(i.Button,{onClick:()=>_(e=>e-1),children:`Back`}),b&&(g<y-1?(0,o.jsx)(i.Button,{type:`primary`,icon:(0,o.jsx)(a.RightOutlined,{}),iconPosition:`end`,onClick:()=>_(e=>e+1),children:`Next`}):(0,o.jsx)(i.Button,{type:`primary`,onClick:v,children:`Done`}))]})]});function E(){return!n||!l?(0,o.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:`Preview id is missing.`}):f?(0,o.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:(0,o.jsx)(i.Spin,{size:`small`})}):m?(0,o.jsx)(`div`,{className:`job-preview-content job-preview-status job-preview-error`,children:m}):u.length?u.map((e,t)=>(0,o.jsx)(`div`,{style:{display:t===g?`block`:`none`},children:e.fields?.length>0?(0,o.jsx)(Lb,{fields:e.fields,moduleName:n}):(0,o.jsx)(Eb,{type:`secondary`,children:`No fields in this group.`})},e.name??e.id??t)):(0,o.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:`No form groups found.`})}return(0,o.jsxs)(i.Modal,{centered:!0,className:`wizard-modal preview-modal`,footer:T,open:!0,title:w,width:S,onCancel:v,maskClosable:!1,children:[b&&(0,o.jsx)(`div`,{className:`wizard-steps-container`,children:(0,o.jsx)(Fb,{steps:C,current:g,onStepClick:_})}),(0,o.jsxs)(`div`,{className:`wizard-body`,children:[c&&(0,o.jsx)(Ib,{record:c}),E()]})]})}var{Text:zb}=i.Typography,{TextArea:Bb}=i.Input,Vb=[{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 Hb(e){switch(e.type){case`select`:return(0,o.jsx)(i.Select,{placeholder:e.placeholder,options:e.options,style:{width:`100%`}});case`textarea`:return(0,o.jsx)(Bb,{rows:3,placeholder:e.placeholder});case`number`:return(0,o.jsx)(i.InputNumber,{placeholder:e.placeholder,style:{width:`100%`}});default:return(0,o.jsx)(i.Input,{type:e.inputType||`text`,placeholder:e.placeholder})}}function Ub({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,o.jsxs)(`div`,{className:`wizard-review-content`,children:[r.map(e=>(0,o.jsxs)(`div`,{className:`wizard-review-section`,children:[(0,o.jsx)(zb,{className:`wizard-review-section-title`,children:e.title}),(0,o.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,o.jsxs)(`div`,{className:`wizard-review-row`,children:[(0,o.jsx)(`span`,{className:`wizard-review-label`,children:e.label}),(0,o.jsx)(`span`,{className:`wizard-review-separator`,children:`:`}),(0,o.jsx)(`span`,{className:`wizard-review-value`,children:r})]},e.name)})})]},e.key)),(0,o.jsxs)(`div`,{className:`wizard-review-confirm-note`,children:[(0,o.jsx)(a.CheckCircleOutlined,{className:`wizard-review-confirm-icon`}),(0,o.jsx)(zb,{type:`secondary`,children:`Please review the information above before submitting.`})]})]}):(0,o.jsx)(`div`,{className:`wizard-review-empty`,children:(0,o.jsx)(zb,{type:`secondary`,children:`No data entered yet.`})})}function Wb(){let[e]=i.Form.useForm(),t=(0,s.useNavigate)(),{title:n=`Wizard`,moduleName:a=``,steps:c=Vb,onSubmit:l}=(0,s.useLocation)().state??{},[u,d]=(0,r.useState)(0),f=c[u],p=u===c.length-1,m=u===0;function h(){t(-1)}function g(){let t=(f.fields||[]).map(e=>e.name);e.validateFields(t.length>0?t:void 0).then(()=>{d(e=>e+1)})}function _(){d(e=>e-1)}function v(){let n=e.getFieldsValue();typeof l==`function`&&l(n),t(-1)}let y=c.map((e,t)=>({title:e.title,description:e.description,status:t<u?`finish`:t===u?`process`:`wait`}));return(0,o.jsxs)(i.Modal,{open:!0,title:a?`${n} — ${a}`:n,footer:(0,o.jsxs)(`div`,{className:`wizard-footer`,children:[(0,o.jsx)(i.Button,{onClick:h,children:`Cancel`}),(0,o.jsxs)(`div`,{className:`wizard-footer-nav`,children:[!m&&(0,o.jsx)(i.Button,{onClick:_,children:`Back`}),p?(0,o.jsx)(i.Button,{type:`primary`,onClick:v,children:`Submit`}):(0,o.jsx)(i.Button,{type:`primary`,onClick:g,children:`Next`})]})]}),onCancel:h,width:`min(680px, calc(100vw - 32px))`,centered:!0,className:`wizard-modal`,children:[(0,o.jsx)(`div`,{className:`wizard-steps-container`,children:(0,o.jsx)(i.Steps,{current:u,items:y,size:`small`,className:`wizard-steps`})}),(0,o.jsx)(`div`,{className:`wizard-body`,children:(0,o.jsxs)(i.Form,{form:e,layout:`vertical`,children:[c.filter(e=>!e.isReview).map((e,t)=>(0,o.jsx)(`div`,{style:{display:t===u?`block`:`none`},children:(0,o.jsx)(i.Row,{gutter:16,children:(e.fields||[]).map(e=>(0,o.jsx)(i.Col,{span:e.span||24,children:(0,o.jsx)(i.Form.Item,{name:e.name,label:e.label,rules:[...e.required?[{required:!0,message:`${e.label} is required`}]:[],...e.rules||[]],children:Hb(e)})},e.name))})},e.key)),f.isReview&&(0,o.jsx)(Ub,{steps:c,form:e})]})})]})}function Gb({titleText:e,titleIcon:t}){let n=t===`delete`;return(0,o.jsxs)(`span`,{className:`dynamic-popup__header`,children:[(0,o.jsx)(`span`,{className:`dynamic-popup__header-icon-box${n?` dynamic-popup__header-icon-box--danger`:``}`,children:n?(0,o.jsx)(a.DeleteOutlined,{}):(0,o.jsx)(a.AppstoreOutlined,{})}),(0,o.jsx)(`span`,{className:`dynamic-popup__header-label`,children:e})]})}function Kb({note:t,description:n,showSelectedCount:r,count:i,itemLabel:a,bodyText:s,deleteError:c}){return(0,o.jsxs)(o.Fragment,{children:[t&&(0,o.jsx)(e.Xn,{variant:`body`,color:`secondary`,className:`dynamic-popup__note`,children:t}),n&&(0,o.jsx)(e.Xn,{variant:`body`,className:`dynamic-popup__description`,children:n}),r&&i>0&&(0,o.jsxs)(e.Xn,{variant:`body`,className:`dynamic-popup__selected-count`,children:[`Changing status for `,(0,o.jsx)(`strong`,{children:i}),` selected `,a,`.`]}),s&&(0,o.jsx)(e.Xn,{variant:`body`,children:s}),c&&(0,o.jsx)(e.Xn,{variant:`caption`,color:`danger`,className:`dynamic-popup__error`,children:c})]})}function qb({footerNote:t}){return t?(0,o.jsx)(e.Xn,{variant:`caption`,color:`secondary`,className:`dynamic-popup__footer-note`,children:t}):null}function Jb(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t?.[n]??``).trim()}function Yb(e){return String(e).replace(/\(\s*\)/g,``).replace(/\s+/g,` `).replace(/(^|\s)([-–—·|])(?=\s*\2)/g,``).replace(/^[\s\-–—·|]+/,``).replace(/[\s\-–—·|]+$/,``).trim()}function Xb(e){if(!e)return``;let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=Math.round((n(new Date)-n(t))/864e5);return r<=0?`Today`:r===1?`Yesterday`:`${r} days ago`}function Zb(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 Qb(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 $b(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:Xb(Zb(e))}:e,o=(i?Yb(Jb(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||Qb(e);t&&(u.submittedAt=t)}if(e?.isFromSubmission===!0&&e?.submissionId){u.isFromSubmission=!0,u.priorSubmissionId=String(e.submissionId);let t=e?.lastSubmittedAt||Qb(e);t&&(u.priorSubmittedAt=t)}return u}function ex(e,t){return(t?.[e.optionsKey]??e.defaultOptions??[]).map(t=>$b(t,e))}function tx(e={}){return{selectedIds:[],selectedRecords:[],moduleName:``,removedIds:[],...e}}var nx=`DD MMM YYYY`,rx=`DD MMM YYYY, h:mm A`;function ix(e,t){if(e==null||e===``)return``;let n=(0,c.default)(e);return n.isValid()?t===`relative`&&Xb(e)||n.format(nx):String(e)}function ax(e,t){return e?String(e).includes(`{`)?Yb(Jb(e,t)):String(t?.[e]??e).trim():``}function ox(e){if(e?.alreadySubmitted){let t=e?.submittedAt?(0,c.default)(e.submittedAt):null;return{tone:`blocked`,tooltip:t?.isValid()?`Already submitted to this job on ${t.format(rx)}`:`Already submitted to this job — a candidate can only be submitted once per job`}}if(e?.isFromSubmission){let t=e?.priorSubmittedAt?(0,c.default)(e.priorSubmittedAt):null;return{tone:`history`,tooltip:t?.isValid()?`Previously submitted on ${t.format(rx)} — this form will prefill from it`:`Submitted to another job before — this form will prefill from it`}}return null}function sx(e,t){return e?.alreadySubmitted||!e?.disabled?``:String(t?.message??e?.title??``).trim()}function cx({meta:e}){return(0,o.jsx)(`div`,{className:`dynamic-popup__option-dates`,children:e.map(e=>(0,o.jsxs)(r.Fragment,{children:[(0,o.jsx)(`span`,{className:`dynamic-popup__option-date-label`,children:e.label}),(0,o.jsx)(`span`,{className:`dynamic-popup__option-date-value`,children:e.text})]},e.label))})}function lx({option:e,layout:t}){let n=e?._raw??e??{},r=ax(t.id,n),s=ax(t.title,n)||String(e?.label??``),c=ax(t.subtitle,n),l=(t.meta??[]).map(e=>({label:e.label,text:ix(n?.[e.key],e.type)})).filter(e=>e.text),u=sx(e,n),d=ox(e);return(0,o.jsxs)(`div`,{className:`dynamic-popup__option`,children:[(0,o.jsx)(`span`,{className:`dynamic-popup__option-tick${d?` dynamic-popup__option-tick--${d.tone}`:``}`,children:d&&(0,o.jsx)(i.Tooltip,{title:d.tooltip,placement:`topLeft`,children:(0,o.jsx)(a.CheckCircleFilled,{"aria-label":d.tooltip})})}),(0,o.jsxs)(`div`,{className:`dynamic-popup__option-main`,children:[(0,o.jsxs)(`div`,{className:`dynamic-popup__option-head`,children:[r&&(0,o.jsx)(`span`,{className:`dynamic-popup__option-id`,children:r}),(0,o.jsx)(`span`,{className:`dynamic-popup__option-title`,children:s}),u&&(0,o.jsx)(`span`,{className:`dynamic-popup__option-flag`,children:u})]}),c&&(0,o.jsx)(`div`,{className:`dynamic-popup__option-sub`,children:c})]}),e?.alreadySubmitted?(0,o.jsx)(`span`,{className:`dynamic-popup__option-onjob`,children:`On this job`}):l.length>0&&(0,o.jsx)(cx,{meta:l})]})}var{Text:ux}=i.Typography,{TextArea:dx}=i.Input,fx=[{label:`$`,value:`$`},{label:`EUR`,value:`EUR`},{label:`GBP`,value:`GBP`},{label:`INR`,value:`INR`}],px=[{label:`Hourly`,value:`Hourly`},{label:`Daily`,value:`Daily`},{label:`Weekly`,value:`Weekly`},{label:`Monthly`,value:`Monthly`},{label:`Yearly`,value:`Yearly`}];function mx(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 hx({field:e,value:t,onChange:n}){return(0,o.jsx)(i.Input,{value:t,onChange:n,placeholder:e.placeholder,maxLength:e.maxLength,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function gx({field:e,value:t,onChange:n}){return(0,o.jsx)(dx,{value:t,onChange:n,rows:e.rows??5,placeholder:e.placeholder})}function _x({field:e,options:t,value:n,onChange:r}){return(0,o.jsx)(i.Select,{value:n,onChange:r,options:mx(t),placeholder:e.placeholder,className:`dynamic-popup__field-select`,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function vx({field:e,options:t,value:n,onChange:r}){return(0,o.jsx)(i.Select,{mode:`multiple`,value:n,onChange:r,options:mx(t),placeholder:e.placeholder,className:`dynamic-popup__field-select`,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function yx({field:e,options:t,onSearch:n,value:r,onChange:s}){let c=mx(t),l=e.optionLayout;return(0,o.jsx)(i.Select,{showSearch:!0,filterOption:!1,notFoundContent:e.notFoundContent??null,value:r,onChange:s,options:c,placeholder:e.placeholder,onSearch:n,className:`dynamic-popup__field-select${l?` dynamic-popup__field-select--rich`:``}`,popupClassName:l?`dynamic-popup__option-dropdown`:void 0,listHeight:l?340:void 0,optionLabelProp:`label`,optionRender:l?e=>(0,o.jsx)(lx,{option:e?.data??e,layout:l}):void 0,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function bx({field:e,mentionOpts:t,onMentionSearch:n,value:r,onChange:a}){return(0,o.jsx)(i.Mentions,{value:r,onChange:a,rows:e.rows??5,placeholder:e.placeholder,prefix:`@`,options:t,onSearch:n,className:`dynamic-popup__mention-textarea`})}function xx({field:e={},value:t={},onChange:n}){let a=t.period??`Hourly`,s=t.isRange??!1;function c(e){n?.({...t,...e})}(0,r.useEffect)(()=>{let e={};t.currency??(e.currency=`$`),t.period??(e.period=`Hourly`),Object.keys(e).length&&n?.({...t,...e})},[]);let l=Number(s?t.maxAmount:t.amount),u=s&&t.minAmount!=null&&t.maxAmount!=null&&Number(t.maxAmount)<=Number(t.minAmount),d=e.rateCeiling!=null&&Number.isFinite(l)&&l>Number(e.rateCeiling);return(0,o.jsxs)(`div`,{children:[(0,o.jsxs)(i.Space.Compact,{style:{width:`100%`},children:[s?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.InputNumber,{controls:!1,placeholder:`From`,value:t.minAmount,onChange:e=>c({minAmount:e}),style:{flex:1}}),(0,o.jsx)(i.InputNumber,{controls:!1,placeholder:`To`,value:t.maxAmount,onChange:e=>c({maxAmount:e}),style:{flex:1}})]}):(0,o.jsx)(i.InputNumber,{controls:!1,placeholder:`0`,value:t.amount,onChange:e=>c({amount:e}),style:{flex:2}}),(0,o.jsx)(i.Select,{value:t.currency??`$`,options:fx,onChange:e=>c({currency:e}),style:{width:80}}),(0,o.jsx)(i.Select,{value:a,options:px,onChange:e=>c({period:e}),style:{width:110}})]}),(u||d)&&(0,o.jsxs)(`div`,{style:{marginTop:4},children:[u&&(0,o.jsx)(ux,{type:`danger`,style:{fontSize:12,display:`block`},children:`To rate must be greater than From rate.`}),d&&(0,o.jsxs)(ux,{type:`danger`,style:{fontSize:12,display:`block`},children:[`Rate must not exceed the client rate (`,e.rateCeiling,`).`]})]}),(0,o.jsxs)(i.Space,{size:`small`,style:{marginTop:8},children:[(0,o.jsx)(i.Switch,{checked:s,onChange:e=>c({isRange:e})}),(0,o.jsx)(`span`,{children:`Range`})]})]})}function Sx({field:e,value:t,onChange:n}){return(0,o.jsx)(i.DatePicker,{value:t,onChange:n,placeholder:e.placeholder??`Select date`,style:{width:`100%`},format:`YYYY-MM-DD`})}function Cx({field:e,checked:t,onChange:n}){return(0,o.jsx)(i.Checkbox,{checked:t,onChange:n,children:e.checkboxLabel})}function wx({field:e,value:t,onChange:n}){return(0,o.jsx)(i.InputNumber,{value:t,onChange:n,min:e.min,max:e.max,placeholder:e.placeholder,style:{width:`100%`}})}function Tx({options:e,value:t,onChange:n}){return(0,o.jsx)(i.Radio.Group,{value:t,onChange:n,options:e})}var Ex={input:hx,text:hx,textarea:gx,select:_x,"multi-select":vx,"search-select":yx,"mention-textarea":bx,"candidate-rate":xx,"priority-checkbox":Cx,"date-picker":Sx,number:wx,radio:Tx};function Dx(e){return e===`priority-checkbox`?{valuePropName:`checked`}:{}}var Ox=new Set([`input`,`text`,`textarea`,`mention-textarea`]);function kx({form:t,fields:n,initialValues:r,dynamicOptions:a,popupContext:s,extraData:c,removedIds:l,setRemovedIds:u,showAlreadyAssigned:d,onValuesChange:f,getSearchHandler:p,getMentionSearchHandler:m,mentionOptions:h}){let g=d&&c;return!n.length&&!g?null:(0,o.jsxs)(o.Fragment,{children:[g&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`dynamic-popup__already-assigned`,children:[(0,o.jsx)(e.Xn,{variant:`caption`,color:`secondary`,children:`Already Assigned People`}),(0,o.jsx)(`div`,{style:{marginTop:6,display:`flex`,flexWrap:`wrap`,gap:6},children:(c?.recruitersData??[]).filter(e=>{let t=String(e?.user_id??e?.id??e?.userId??``);return t&&!l.includes(t)}).map(e=>{let t=String(e?.user_id??e?.id??e?.userId??``),n=e?.name??e?.user_name??e?.userName??e?.email??t;return(0,o.jsx)(i.Tag,{closable:!0,onClose:()=>{t&&u(e=>Array.from(new Set([...e,t])))},children:n},t||n)})})]}),(0,o.jsx)(i.Divider,{style:{margin:`12px 0`}})]}),n.length>0&&(0,o.jsx)(i.Form,{form:t,layout:`vertical`,initialValues:r,onValuesChange:(e,t)=>f(t),children:Ax(n).map(t=>jx(t,t=>{let n=a[t.name]??ex(t,s),r=p(t),c=m(t),l=h[t.name]??[],u=Dx(t.type),d=Ex[t.type],f=[];return t.required&&f.push({required:!0,message:`${t.label||`This field`} is required`}),typeof t.validator==`function`&&f.push({validator:(e,n)=>{let r=t.validator(n,s);return r?Promise.reject(Error(r)):Promise.resolve()}}),Ox.has(t.type)&&f.push(e.q({label:t.label,field:t.name,type:t.type})),(0,o.jsx)(i.Form.Item,{name:t.name,label:t.label,rules:f,...u,children:d?(0,o.jsx)(d,{field:t,options:n,onSearch:r,mentionOpts:l,onMentionSearch:c}):null},t.name)}))})]})}function Ax(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 jx(e,t){return e.length===1?t(e[0]):(0,o.jsx)(`div`,{style:{display:`flex`,gap:8,alignItems:`flex-start`},children:e.map((e,n)=>(0,o.jsx)(`div`,{style:{flex:n===0?2:1,minWidth:0},children:t(e)},e.name))},`row-${e.map(e=>e.name).join(`-`)}`)}function Mx({open:e,config:t,api:n,fields:i,popupContext:a,formValues:o}){let[s,c]=(0,r.useState)({}),[l,u]=(0,r.useState)(null);return(0,r.useEffect)(()=>{e||(c({}),u(null))},[e]),(0,r.useEffect)(()=>{if(!e||!t||!n.getOptions)return;let r=new AbortController;return i.forEach(e=>{!e.fetchOptionsKey||e.fetchOptionsParamKey||Promise.resolve(n.getOptions(e,void 0,a)).then(t=>{r.signal.aborted||c(n=>({...n,[e.name]:t}))}).catch(t=>{r.signal.aborted||console.error(`[DynamicPopup] Failed to load options for field "${e.name}":`,t)})}),()=>r.abort()},[e,n,t,i,a]),(0,r.useEffect)(()=>{if(!e||!t||!n.getOptions)return;let r=i.filter(e=>e.fetchOptionsKey&&e.fetchOptionsParamKey);if(!r.length)return;let s=new AbortController;return r.forEach(e=>{let t=o[e.fetchOptionsParamKey]??a[e.fetchOptionsParamKey],r={[e.fetchOptionsParamKey]:t};Promise.resolve(n.getOptions(e,r,a)).then(t=>{s.signal.aborted||c(n=>({...n,[e.name]:t}))}).catch(t=>{s.signal.aborted||console.error(`[DynamicPopup] Failed to load param-dependent options for "${e.name}":`,t)})}),()=>s.abort()},[e,n,t,i,o,a]),(0,r.useEffect)(()=>{if(!e||!t||!n.loadExtraData)return;let r=new AbortController;return Promise.resolve(n.loadExtraData(a)).then(e=>{r.signal.aborted||u(e)}).catch(e=>{r.signal.aborted||(console.error(`[DynamicPopup] Failed to load extra data:`,e),u(null))}),()=>r.abort()},[e,n,t,a]),{dynamicOptions:s,setDynamicOptions:c,extraData:l}}var Nx=500,Px=3;function Fx({api:e,open:t,fields:n=[],popupContext:i,setDynamicOptions:a}){let[o,s]=(0,r.useState)({}),c=(0,r.useRef)({}),l=(0,r.useRef)({}),u=(0,r.useRef)({}),d=(0,r.useCallback)((t,n)=>{let r=e.searchOptions??e.searchFetcher;if(typeof r!=`function`)return;l.current[t.name]?.abort();let o=new AbortController;return l.current[t.name]=o,Promise.resolve(r(t,n,i)).then(e=>{if(o.signal.aborted)return;let n=Array.isArray(e)?e:e?.items??e?.list??[];a(e=>({...e,[t.name]:n.map(e=>$b(e,t))}))}).catch(e=>{o.signal.aborted||console.error(`[DynamicPopup] Search failed for field "${t.name}":`,e)}),o},[e,i,a]),f=n.filter(e=>(e.searchFetchKey||e.searchFetcher)&&e.preloadOptions!==!1),p=f.map(e=>e.name).join(`|`),m=(0,r.useRef)({runSearch:d,preloadFields:f});(0,r.useEffect)(()=>{m.current={runSearch:d,preloadFields:f}}),(0,r.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??Px;return e=>{clearTimeout(c.current[t.name]);let r=e.length<n?``:e;c.current[t.name]=setTimeout(()=>{d(t,r)},Nx)}}function g(t){let n=e.getMentionOptions??e.mentionFetcher;if(typeof n==`function`)return e=>{u.current[t.name]?.abort();let r=new AbortController;u.current[t.name]=r,Promise.resolve(n(t,e,i)).then(e=>{if(r.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=>{r.signal.aborted||console.error(`[DynamicPopup] Mention search failed for field "${t.name}":`,e)})}}return{mentionOptions:o,getSearchHandler:h,getMentionSearchHandler:g}}function Ix({form:e,config:t,api:n,popupContext:a,resolvedIds:o,dynamicOptions:s,extraData:c,removedIds:l,fields:u,onClose:d,onSubmit:f}){let[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(null);async function _(e){let t={resolvedIds:o,dynamicOptions:s,extraData:c,removedIds:l};if(typeof n.submit==`function`)return n.submit(e,a,t);if(typeof f==`function`)return f(e,a,t)}function v(){if(t){if(!u.length){if(t.mode===`delete`&&typeof n.deleteItems==`function`){m(!0),g(null),Promise.resolve(n.deleteItems(o,a)).then(()=>{i.message.success(t.successMessage||`Deleted successfully`),d({success:!0})}).catch(e=>{let t=e?.message||`Delete failed. Please try again.`;g(t),m(!1),i.message.error(t)});return}if(typeof n.onOk==`function`){m(!0),Promise.resolve(n.onOk(a)).then(()=>d({success:!0})).catch(e=>{let t=e?.message||`Failed. Please try again.`;i.message.error(t),m(!1)});return}if(typeof n.submit==`function`){m(!0),Promise.resolve(_({})).then(e=>{e?.navigated||(i.message.success(t.successMessage||`Saved successfully`),d({success:!0}))}).catch(e=>{i.message.error(e?.message||`Failed. Please try again.`)}).finally(()=>m(!1));return}d();return}e.validateFields().then(async e=>{m(!0);try{if((await _(e))?.navigated)return;i.message.success(t.successMessage||`Saved successfully`),d({success:!0})}catch(e){i.message.error(e?.message||`Failed. Please try again.`)}finally{m(!1)}}).catch(()=>{})}}function y(){m(!1),g(null)}return{handleOk:v,confirming:p,deleteError:h,resetSubmitState:y}}function Lx({open:e=!0,config:t,context:n={},onClose:a,onSubmit:s,api:l={}}){let[u]=i.Form.useForm(),[d,f]=(0,r.useState)({}),[p,m]=(0,r.useState)([]),h=i.Form.useWatch([],u,{preserve:!0})??{},g=(0,r.useMemo)(()=>tx(n),[n]),{selectedIds:_=[],selectedRecords:v=[],moduleName:y=``}=g,b=(0,r.useMemo)(()=>_.map((e,t)=>{let n=v[t];return n?.id??n?._id??e}),[_,v]),x=(0,r.useMemo)(()=>t?typeof t.getFields==`function`?t.getFields(g):t.fields??[]:[],[t,g]),S=(0,r.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,c.default)(n):n)}),e},[x,g]),{dynamicOptions:C,setDynamicOptions:w,extraData:T}=Mx({open:e,config:t,api:l,fields:x,popupContext:g,formValues:d}),{mentionOptions:E,getSearchHandler:D,getMentionSearchHandler:O}=Fx({api:l,open:e,fields:x,popupContext:g,setDynamicOptions:w});function k(e){typeof a==`function`&&a(e)}let{handleOk:A,confirming:j,deleteError:M,resetSubmitState:N}=Ix({form:u,config:t,api:l,popupContext:g,resolvedIds:b,dynamicOptions:C,extraData:T,removedIds:p,fields:x,onClose:k,onSubmit:s});(0,r.useEffect)(()=>{e&&(u.resetFields(),f(S??{}),m(g.removedIds??[]),N())},[e,S]);let P=!!t?.autoSubmitWhenNoFields&&x.length===0;(0,r.useEffect)(()=>{!e||!P||A()},[e,P]);let F=_.length,I=String(y).replace(/s$/i,``),L=F===1?I:y,R=v[0]??{},z=t?.getTitleText?t.getTitleText(F,L,R,g):t?.title,B=F===1?R.jobTitle??R.title??R.name??R.fullName??R.candidateName??null:null,ee=t?.getBodyText?t.getBodyText(F,I,L,B,g):t?.bodyText??null,te=typeof t?.getNote==`function`?t.getNote(g):t?.note,V=x.filter(e=>e.required).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)}),ne=t?.disabledUntilFilled&&!V;if(!t||!e||P)return null;let re=t.component;return re?(0,o.jsx)(i.Modal,{open:e,title:t.title||t.getTitleText?(0,o.jsx)(Gb,{titleText:z,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,o.jsx)(re,{context:g,selectedIds:b,selectedRecords:v,moduleName:y,onClose:k})}):(0,o.jsxs)(i.Modal,{open:e,title:(0,o.jsx)(Gb,{titleText:z,titleIcon:t.titleIcon}),okText:t.okText||`OK`,cancelText:t.cancelText??`Cancel`,onOk:A,onCancel:()=>k(),okButtonProps:{danger:t.okButtonDanger,disabled:ne,loading:j},cancelButtonProps:{disabled:j},closable:!j,maskClosable:!1,width:t.width??480,centered:!0,className:`dynamic-popup${t.className?` ${t.className}`:``}`,children:[(0,o.jsx)(Kb,{note:te,description:t.description,showSelectedCount:t.showSelectedCount,count:F,itemLabel:L,bodyText:ee,deleteError:M}),(0,o.jsx)(qb,{footerNote:t.footerNote}),(0,o.jsx)(kx,{form:u,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 Rx={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:[]},zx={deleteItems:async(e,t)=>{await I(t.moduleName,e)}},Bx={title:`Submit`,okText:`Submit`,width:640,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getNote:e=>e.moduleName===`candidate`?`Note: Select a job to submit this candidate. The 10 most recent jobs are listed — type to search further.`:`Note: Select a candidate to submit for this job. The 10 most recent candidates are listed — type to search further.`,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}`,valueKey:`applicantId`,optionLayout:{id:`{applicantRefrenceId}`,title:`{firstName} {lastName}`,subtitle:`{designation} · {email}`,meta:[{label:`Created`,key:`createdAt`,type:`date`},{label:`Updated`,key:`updatedAt`,type:`relative`}]}}]},Vx=`Already submitted`;function Hx(e){return String(e?.applicantId??e?._id??e?.id??``)}function Ux(e,t,n){return{...e,label:`${e.label} — ${Vx}`,disabled:!0,title:`${Vx}${t?` (submission ${t})`:``}`,alreadySubmitted:!0,existingSubmissionId:t||``,...n?{submittedAt:n}:{}}}var Wx={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 de({searchQuery:t,candidateId:r})}catch{a=!1;let e=await ln({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 Ux(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 fe({applicantId:r,jobIds:o.map(e=>e.value)}).catch(()=>new Map);return o.map(e=>{let t=s.get(String(e.value));return t?Ux(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 J({search:t,jobId:r})}catch{let e=await Ha({isFromSubmission:n.isFromSubmission,jobId:r,submissionId:n.submissionId,search:t});i=Array.isArray(e)?e:[],a=await fe({jobId:r,applicantIds:i.map(Hx)}).catch(()=>new Map)}return i.map(e=>{let t=a.get(Hx(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:Vx,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=>Hx(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.`);let p=f,m=u?._raw?.existingSubmissionId||u?._raw?.jobSubmissionId||d?.existingSubmissionId||d?._raw?.jobSubmissionId||``;try{let e=await q({jobId:c,applicantId:l});p||=!!e?.exists,m=e?.submissionId||m}catch(e){throw Error(`Could not verify existing submissions (${e?.message??`request failed`}). Please try again.`,{cause:e})}if(p)throw Error(`This candidate is already submitted for this job${m?` (submission ${m})`:``}.`);let h=new URLSearchParams;l&&h.set(`candidateId`,l);let g=u?.priorSubmissionId||u?._raw?.submissionId||d?.priorSubmissionId||d?._raw?.submissionId||``;return g?(h.set(`submissionId`,String(g)),h.set(`isFromSubmission`,`true`)):h.set(`isFromSubmission`,`false`),r(`/submission-create/${c}?${h.toString()}`),{navigated:!0}}},Gx={title:`Add Notes & Share`,okText:`Save & Share`,width:480,fields:[{name:`notes`,type:`mention-textarea`,required:!0,rows:5,placeholder:`Add your notes on the job. Use '@' to mention someone.`,mentionFetchKey:`mentionUsers`}]},Kx=e=>e?.data??e;async function qx({relatedId:e,notes:n,title:r,notesFor:i}){return Kx(await Wt(t.b,`/notes`,{method:`POST`,body:JSON.stringify({relatedId:e,notes:n,title:r,notesFor:i})}))}var Jx={getMentionOptions:async(e,t)=>R(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 qx({relatedId:String(n),notes:e.notes,notesFor:t.moduleName})}},Yx={name:`jobId`,label:`Job Title / ID`,type:`search-select`,required:!0,placeholder:`Minimum 3 characters`,searchFetchKey:`tagToJobJobList`,valueKey:`_id`,labelTemplate:`{jobReferenceId} - {jobTitle}`},Xx={name:`hiringStage`,label:`Hiring stage`,type:`select`,required:!0,optionsKey:`hiringStageOptions`,defaultOptions:[{label:`Shortlisted`,value:`shortlisted`},{label:`Pipeline`,value:`pipeline`}],initialValueKey:`hiringStage`},Zx={title:`Tag to Job`,okText:`Tag`,width:480,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getFields:e=>e.jobId&&e.hiringStage?[]:e.jobId?[Xx]:[Yx,Xx]},Qx=e=>e?.data??e;function $x(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 eS(e){return e?Array.isArray(e.data)?e.data.map($x):e.stage&&Array.isArray(e.stage.data)?e.stage.data.map($x):Array.isArray(e)?e.map($x):[]:[]}async function tS(e=1,n=10){let r=await t.a(t.b,`/workflow/list/all?page=${e}&limit=${n}`),i=Qx(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 nS(e=100){let t=await tS(1,e),n=[...t.items],r=t.total,i=2;for(;n.length<r;){let t=await tS(i,e);if(!t.items.length)break;n.push(...t.items),i+=1}return{items:n,total:Math.max(r,n.length)}}async function rS(e,n){let r=Qx(await t.a(t.b,`/workflow/${e}/stage/${n}`));return Array.isArray(r)?{data:r}:r}async function iS(e,n){if(!e||!n)return null;try{let r=Qx(await t.a(t.b,`/module-data-list?${new URLSearchParams({module:e,limit:`1`,offset:`0`,scope:`allJobs`,filters:JSON.stringify([{field:`_id`,op:`in`,values:[String(n)],operator:`and`}])})}`));if(Array.isArray(r))return r[0]??null;if(r?.data&&Array.isArray(r.data))return r.data[0]??null;let i=r?.rows??r?.records??r?.items??r?.list;return Array.isArray(i)?i[0]??null:r??null}catch(t){return console.error(`[getModuleRecordById] failed: ${e}/${n}`,t),null}}async function aS(e){return Qx(await t.a(t.S,`/source/workflow-instance`,{method:`POST`,body:JSON.stringify(e)}))}var oS={pipeline:`pipeline`,goodfited:`goodfited`,contacted:`contacted`,submitted:`submitted`,shortlisted:`shortlisted`,interviewinprogress:`interviewInprogress`,selected:`selected`};function sS(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 cS(e){let t=String(e??``).trim();return t?oS[t.toLowerCase()]??t:``}function lS(e,t){let n=sS(e,`candidateId`,`candidate_id`,`applicantId`,`applicantID`,`applicantReferenceId`,`applicantRefrenceId`,`_id`,`id`)??t;if(!n)return null;let r=(sS(e,`candidateName`,`candidate_name`,`fullName`,`name`)??[sS(e,`firstName`,`first_name`),sS(e,`lastName`,`last_name`)].filter(Boolean).join(` `))||void 0,i={candidateId:String(n),candidateName:r,phone:sS(e,`phone`,`phoneNumber`,`phone_number`,`mobile`,`mobileNumber`,`mobile_number`),source:sS(e,`source`,`sourceType`,`candidateSource`,`profileSource`),submittedAt:sS(e,`submittedAt`,`lastSubmittedAt`,`updatedAt`),remarks:sS(e,`remarks`,`comment`,`comments`,`notes`),assignedRecruiter:sS(e,`assignedRecruiter`,`recruiterName`,`ownerName`,`assignedToName`),screeningStatus:sS(e,`screeningStatus`,`screening.status`,`screeningResult`),screeningScore:sS(e,`screeningScore`,`screening.score`,`score`),assignedDate:sS(e,`assignedDate`,`assignedAt`,`createdAt`)};return Object.fromEntries(Object.entries(i).filter(([,e])=>e!=null&&e!==``))}var uS={searchOptions:async(e,t)=>e.searchFetchKey===`tagToJobJobList`?L(t):[],submit:async(e,t)=>{let n=e.jobId??t.jobId,r=cS(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=lS(a[e]??{},t);await aS({jobId:n,module:`jobs`,currentStage:r,...o?{candidateDetails:o}:{}})}await te({jobId:n,candidateIds:t.selectedIds,hiringStage:r})}},dS={title:`Change Status`,okText:`Apply`,width:420,showSelectedCount:!0,fields:[{name:`status`,label:`New Status`,type:`select`,required:!0,placeholder:`Select a status`,optionsKey:`statusOptions`,initialValueKey:`currentStatus`,defaultOptions:[{label:`Active`,value:`active`},{label:`Inactive`,value:`inactive`},{label:`Pending`,value:`pending`},{label:`Closed`,value:`closed`}]}]},fS={submit:async(e,t)=>{await F(t.moduleName,t.selectedIds,e.status)}},pS={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:[]},mS={onOk:async e=>{await pe({jobId:e.jobId??e.selectedIds[0],candidateIds:e.selectedIds})}},hS={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`}]},gS={getOptions:async e=>e.fetchOptionsKey===`candidateGroups`?V():[],submit:async(e,t,{dynamicOptions:n})=>{let r=(n.groupId??[]).find(t=>String(t.value)===String(e.groupId));await ne({candidateIds:t.selectedIds,groupId:e.groupId,groupName:r?.label??``})}},_S=[{title:`Name`,key:`name`,render:(e,t)=>`${t.first_name??``} ${t.last_name??``}`.trim()||t.user_name||t.name||`-`},{title:`Role`,dataIndex:`role_name`,key:`role`,render:e=>e||`-`},{title:`Reporting`,dataIndex:`reporting_name`,key:`reporting`,render:e=>e||`-`}];function vS({selectedIds:e,onClose:t}){let n=e?.[0],[s,c]=(0,r.useState)(!0),[l,u]=(0,r.useState)(!1),[d,f]=(0,r.useState)({assignedUsers:[],totalSubmissions:0,message:``}),[p,m]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=!1;return c(!0),Promise.all([H(n).catch(t=>(e||i.message.error(t?.message??`Failed to load self-assign details`),{assignedUsers:[],totalSubmissions:0,message:``})),G(n).catch(()=>({recruitersData:[]}))]).then(([t,n])=>{e||(f(t),m(Array.isArray(n?.recruitersData)?n.recruitersData:[]))}).finally(()=>{e||c(!1)}),()=>{e=!0}},[n]);let h=async()=>{u(!0);try{await re({jobIds:[n]}),i.message.success(`Job assigned successfully`),t?.({success:!0})}catch(e){i.message.error(e?.message??`Failed to assign job`)}finally{u(!1)}};if(s)return(0,o.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,o.jsx)(i.Spin,{size:`large`})});let g=(d.assignedUsers?.length??0)>0?d.assignedUsers:p.map(e=>({user_id:e.recruiterId??e.id??e.user_id,first_name:e.name??``,role_name:e.role_name??``,reporting_name:e.reporting_name??``}));return(0,o.jsxs)(`div`,{className:`self-assign-popup-body`,children:[g.length>0?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`div`,{style:{fontWeight:700,marginBottom:8},children:`Team Members Allocated`}),(0,o.jsx)(i.Table,{columns:_S,dataSource:g,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,o.jsxs)(`div`,{className:`warning-card`,style:{display:`flex`,alignItems:`center`,gap:8,marginTop:12},children:[(0,o.jsx)(a.ExclamationCircleFilled,{style:{color:`#faad14`,fontSize:18}}),(0,o.jsx)(`div`,{style:{fontSize:13},children:`These users are already assigned to this job. Do you still want to assign yourself as well?`})]})]}):(0,o.jsx)(`div`,{style:{padding:`8px 0`},children:d.message||`No one is assigned. Be the first to assign!`}),(0,o.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:12,marginTop:24},children:[(0,o.jsx)(i.Button,{size:`small`,onClick:()=>t?.(),disabled:l,children:`No`}),(0,o.jsx)(i.Button,{type:`primary`,size:`small`,onClick:h,loading:l,children:`Yes`})]})]})}vS.propTypes={selectedIds:l.default.array,onClose:l.default.func};var yS={title:`Self Assign`,width:480,className:`self-assign-modal`,component:vS},bS={submit:async()=>{}};function xS(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}function SS(e,t){let n=e??{};if(n.isRange&&n.minAmount!=null&&n.maxAmount!=null&&Number(n.maxAmount)<=Number(n.minAmount))return`To rate must be greater than From rate.`;let r=xS(t?.selectedRecords?.[0]??{}),i=n.isRange?Number(n.maxAmount):Number(n.amount);return r!=null&&Number.isFinite(i)&&i>r?`Candidate rate must not exceed the client rate (${r}).`:``}var CS={getTitleText:(e,t,n)=>{let r=n?.jobTitle||n?.title||``;return r?`Assign - ${r}`:`Assign`},okText:`Assign`,width:520,disabledUntilFilled:!0,showAlreadyAssigned:!0,getFields:e=>[{name:`assignToUserId`,label:`Assign to`,type:`multi-select`,required:!0,placeholder:`Select recruiter(s)`,fetchOptionsKey:`assignToUsers`},{name:`candidateRate`,label:`Candidate Rate`,type:`candidate-rate`,rateCeiling:xS(e?.selectedRecords?.[0]??{}),validator:SS},{name:`priority`,label:`Priority`,type:`priority-checkbox`,checkboxLabel:`Mark as High`}]},wS={getOptions:async e=>e.fetchOptionsKey===`assignToUsers`?W():[],loadExtraData:async e=>G(e.selectedIds[0]),submit:async(e,t,{removedIds:n,extraData:r})=>{await ae({jobIds:t.selectedIds,userId:e.assignToUserId,rate:e.candidateRate,priority:e.priority,removedIds:n,existingRecruiters:r?.recruitersData})}},TS={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`}]},ES={getMentionOptions:async(e,t)=>R(t),submit:async(e,t)=>{let n=e.targetDate?e.targetDate.toISOString():``;t.editingNoteId?await B(t.editingNoteId,{title:e.heading,targetDate:n,notes:e.comments}):await z({relatedIds:t.selectedIds,module:t.moduleName,title:e.heading,targetDate:n,notes:e.comments}),window.dispatchEvent(new Event(`sticky-notes:refresh`))}},DS={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`}]},OS={submit:async(e,t)=>{await oe({submissionId:t.selectedRecords?.[0]?.submissionId,isMail:e.sendOnboardingEmail})}};function kS(e){return Array.isArray(e)?e[e.length-1]??{}:e&&typeof e==`object`?e:{}}var AS={USD:`$`,INR:`₹`,EUR:`€`,GBP:`£`};function jS(e,t,n){let r=kS(e?.[t])[n];if(r!=null&&r!==``)return r;let i=e?.[`${t}.${n}`];return i!=null&&i!==``?i:void 0}function MS(e){let t=e.selectedRecords?.[0]??{},n=jS(t,`candidateRate`,`candidateAcceptedRate`)??jS(t,`candidateBudget`,`candidateBudgetStart`);if(n===void 0||Number(n)===0)return null;let r=jS(t,`candidateRate`,`candidateAcceptedCurrency`)??jS(t,`candidateBudget`,`candidateBudgetCurrency`);return{amount:n,symbol:jS(t,`candidateRate`,`candidateAcceptedCurrencySymbol`)??jS(t,`candidateBudget`,`candidateBudgetCurrencySymbol`)??AS[String(r??``).toUpperCase()]??(r||`$`),unit:jS(t,`candidateRate`,`candidateAcceptedPayUnit`)??jS(t,`candidateBudget`,`candidateBudgetUnit`)??``}}var NS={title:`Approve Rate`,okText:`Approve`,width:520,className:`medium-modal`,successMessage:`Rate approved`,getBodyText:(e,t,n,r,i)=>{let a=MS(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=MS(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`}]}]},PS={submit:async(e,t)=>{let n=t.selectedIds[0];if(await se(n,{candidateProposedRate:e.candidateProposedRate,candidateProposedRateCurrency:e.candidateProposedRateCurrency,candidateProposedRateUnit:e.candidateProposedRateUnit,submitVia:e.submitVia}),e.submitVia===`VMS`)try{await ce(n)}catch{i.message.warning(`Approved. VMS notification could not be sent — use Send Mail to notify the client.`)}else i.message.info(`Approved — use Send Mail to notify the client.`)}};function FS(e,t={}){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:t.employerName??e.supplierName??e.submitSource,submittedBy:t.submittedBy??e.signatureEmail??e.recruiterName,submittedAt:t.createdAt??e.createdAt,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function IS({context:e,selectedIds:t,selectedRecords:n,moduleName:a,onClose:s}){let c=n?.[0]??{},l=t?.[0]??Sp(c),[u,d]=(0,r.useState)(null),[f,p]=(0,r.useState)(!0);(0,r.useEffect)(()=>{let e=!1;return p(!0),Zp(l,c).then(t=>{e||d(t)}).catch(t=>{e||(i.message.error(t?.message??`Unable to load finance details`),d({record:{submission:c},lookups:{},display:{}}))}).finally(()=>{e||p(!1)}),()=>{e=!0}},[l]);let m=(0,r.useMemo)(()=>({submissionApprove:async({computed:e})=>{await se(l,{candidateProposedRate:e.proposedRate,candidateProposedRateCurrency:e.currency,candidateProposedRateUnit:`hr`,submitVia:`Mail`}),i.message.success(`Submission approved`),s?.({success:!0})},submissionReject:async()=>{e?.navigate?.(`/popup/reject`,{replace:!0,state:{background:e?.background??null,selectedIds:t,selectedRecords:n,moduleName:a}})}}),[l,e,t,n,a,s]);return f||!u?(0,o.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,o.jsx)(i.Spin,{size:`large`})}):(0,o.jsx)(Hp,{type:np,record:u.record,lookups:u.lookups,identity:FS(c,u.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:m,onClose:()=>s?.(),variant:`popup`})}IS.propTypes={context:l.default.object,selectedIds:l.default.array,selectedRecords:l.default.array,moduleName:l.default.string,onClose:l.default.func};var LS={title:`Manager Approve`,width:780,className:`fa-modal manager-approve-modal`,component:IS},RS={submit:async()=>{}};function zS(e,t={}){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:t.employerName??e.supplierName??e.submitSource,submittedBy:t.submittedBy??e.signatureEmail??e.recruiterName,submittedAt:t.createdAt??e.createdAt,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function BS(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 VS(e){return String(e??``).toLowerCase().replace(/\b\w/g,e=>e.toUpperCase())}function HS({selectedIds:t,selectedRecords:n,onClose:a}){let s=n?.[0]??{},c=t?.[0]??Sp(s),[l,u]=(0,r.useState)(null),[d,f]=(0,r.useState)(``),[p,m]=(0,r.useState)(!0);(0,r.useEffect)(()=>{let t=!1;return m(!0),Promise.all([Zp(c,s),e.at(`submission`,c).catch(()=>[])]).then(([e,n])=>{if(t)return;let r=BS(n);f(Sp(e?.meta?.workforceEngagementId??s?.onboarding?.workforceEngagementId??s?.workforceEngagementId));let i=e?.meta?.rejectReasonComments||r?.activityComments||``;u({...e,record:{...e.record,submission:{...e.record.submission,cfoRejectionReason:i?VS(i):``,cfoRejectedAt:e?.meta?.rejectedAt??r?.activityTime??null}}})}).catch(e=>{t||(i.message.error(e?.message??`Unable to load finance details`),u({record:{submission:s},lookups:{},display:{}}))}).finally(()=>{t||m(!1)}),()=>{t=!0}},[c]);let h=(0,r.useMemo)(()=>({submissionReapproveSend:async({computed:e})=>{await le(d,{submissionId:c,billRate:e.proposedRate,payRate:e.employerRate,currency:e.currency,referralRate:e.referralRate,vmsPercent:e.clientVmsPercent}),await se(c,{candidateProposedRate:e.proposedRate,candidateProposedRateCurrency:e.currency,candidateProposedRateUnit:`hr`,submitVia:`Mail`}),i.message.success(`Re-approved and sent for CFO approval`),a?.({success:!0})}}),[c,d,a]);return p||!l?(0,o.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,o.jsx)(i.Spin,{size:`large`})}):(0,o.jsx)(Hp,{type:op,record:l.record,lookups:l.lookups,identity:zS(s,l.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:h,onClose:()=>a?.(),variant:`popup`})}HS.propTypes={selectedIds:l.default.array,selectedRecords:l.default.array,onClose:l.default.func};var US={title:`Re-Approve`,width:780,className:`fa-modal manager-approve-modal`,component:HS},WS={submit:async()=>{}},GS=[{id:1,name:`Re-Submission`},{id:2,name:`Candidate doesn't fit into the profile`},{id:3,name:`Incomplete candidate details - (Re-Submission)`}],KS={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:GS.map(e=>({label:e.name,value:e.id}))},{name:`rejectReasonComments`,label:`Comments`,type:`textarea`,required:!0,rows:4}]},qS={submit:async(e,t)=>{let n=GS.find(t=>String(t.id)===String(e.rejectReason));await ue({submissionId:t.selectedIds[0],rejectReasonId:e.rejectReason,rejectReason:n?.name??``,rejectReasonComments:e.rejectReasonComments})}},JS={delete:Rx,"quick-submit":Bx,"add-notes":Gx,"tag-to-job":Zx,"change-status":dS,"remove-from-shortlist":pS,"add-to-groups":hS,"self-assign":yS,"others-assign":CS,"sticky-notes":TS,"move-to-onboarding":DS,"approve-rate":NS,"manager-approve":LS,"manager-reapprove":US,reject:KS},YS={delete:zx,"quick-submit":Wx,"add-notes":Jx,"tag-to-job":uS,"change-status":fS,"remove-from-shortlist":mS,"add-to-groups":gS,"self-assign":bS,"others-assign":wS,"sticky-notes":ES,"move-to-onboarding":OS,"approve-rate":PS,"manager-approve":RS,"manager-reapprove":WS,reject:qS};function XS(e){let t=e?.data??e;return Array.isArray(t)?t:t?.data??t?.rows??t?.records??t?.items??t?.list??[]}function ZS(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 QS(e){let t=String(ZS(e,`isDeleted`,`deleted`)).toLowerCase(),n=String(ZS(e,`assignmentStatus`,`status`)).toLowerCase();return t!==`true`&&t!==`1`&&![`removed`,`inactive`,`deleted`].includes(n)}function $S(e){let t=ZS(e,`candidateName`,`candidate_name`,`fullName`,`name`);return t?String(t):[ZS(e,`firstName`,`first_name`),ZS(e,`lastName`,`last_name`)].filter(Boolean).join(` `)||`Unnamed candidate`}function eC(e){return String(ZS(e,`candidateId`,`candidate_id`,`candidate._id`,`candidate.id`))}function tC(e){return String(ZS(e,`workforceEngagementId`,`engagementId`,`_id`,`id`))}function nC(e){return String(ZS(e,`batchName`,`name`,`title`,`batch_name`))}function rC({open:n=!0,context:a={},onClose:s}){let[c,l]=(0,r.useState)([]),[u,d]=(0,r.useState)([]),[f,p]=(0,r.useState)(``),[m,h]=(0,r.useState)(!0),[g,_]=(0,r.useState)(!1),[v,y]=(0,r.useState)(``),[b,x]=(0,r.useState)(new Map),S=String(a.selectedIds?.[0]??a.selectedRecords?.[0]?._id??a.selectedRecords?.[0]?.id??a.batchId??``);(0,r.useEffect)(()=>{if(!n)return;let t=!1;return Promise.resolve().then(()=>(t||h(!0),Promise.all([e.Wn(`onboarding`,200,0),e.Wn(`batchCandidates`,1e3,0).catch(()=>[])]))).then(([e,n])=>{t||(l(XS(e)),x(new Map(XS(n).filter(QS).map(e=>[String(ZS(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}},[n]);let C=(0,r.useMemo)(()=>{let e=f.trim().toLowerCase();return e?c.filter(t=>[$S(t),ZS(t,`email`,`candidateEmail`,`candidate_email`),ZS(t,`status`,`onboardingStatus`,`onboarding_status`)].some(t=>String(t).toLowerCase().includes(e))):c},[c,f]);async function w(){if(!S){y(`Select a batch before adding candidates`);return}let n=c.filter(e=>u.includes(tC(e)));if(!n.length)return;let r=n.map(e=>({record:e,assignment:b.get(eC(e))})).filter(e=>e.assignment);if(r.length){y(`${r.map(({record:e})=>$S(e)).join(`, `)} ${r.length===1?`is`:`are`} already added to a batch. Each candidate can be added to only one batch.`);return}_(!0),y(``);try{let{userId:r}=t.o(),o=nC(a.selectedRecords?.[0])||nC(a);await Promise.all(n.map(t=>e.bt(`batchCandidates`,{schemaVersion:1,batchId:S,batchName:o,candidateId:eC(t),workforceEngagementId:tC(t),source:`ONBOARDING`,assignmentStatus:`ASSIGNED`,assignedAt:new Date().toISOString(),assignedBy:r??0,isDeleted:!1}))),i.message.success(`${n.length} candidate${n.length===1?``:`s`} added to the batch`),s?.({refresh:!0})}catch(e){y(e.message||`Unable to add candidates to the batch`)}finally{_(!1)}}return(0,o.jsxs)(i.Modal,{open:n,title:`Add Candidate to Batch`,okText:`Add`,onOk:w,onCancel:()=>s?.(),okButtonProps:{disabled:u.length===0||!S,loading:g},cancelButtonProps:{disabled:g},closable:!g,maskClosable:!1,width:760,centered:!0,children:[v&&(0,o.jsx)(i.Alert,{type:`error`,showIcon:!0,message:v,style:{marginBottom:12}}),(0,o.jsx)(i.Input.Search,{allowClear:!0,placeholder:`Search onboarding candidates`,value:f,onChange:e=>p(e.target.value),style:{marginBottom:12}}),(0,o.jsx)(i.Table,{rowKey:e=>tC(e),columns:[{title:`Candidate`,key:`candidate`,render:(e,t)=>$S(t)},{title:`Email`,key:`email`,render:(e,t)=>ZS(t,`email`,`candidateEmail`,`candidate_email`)||`—`},{title:`Onboarding status`,key:`status`,render:(e,t)=>ZS(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(eC(e));return{disabled:!eC(e)||!tC(e)||!!t,title:t?`Candidate is already added to a batch`:void 0}}},locale:{emptyText:m?`Loading candidates…`:`No onboarding candidates found`}})]})}var iC={text:`input`,string:`input`,textarea:`textarea`,date:`date-picker`,datepicker:`date-picker`,multiselect:`multi-select`,lookup:`search-select`};function aC(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:iC[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}))})));return{title:e.label,fields:t}}function oC({apiMap:n={},extraConfigs:i={}}){let a=(0,r.useMemo)(()=>({...YS,...n}),[n]),c=(0,r.useMemo)(()=>{let e={...JS};return Object.entries(i).forEach(([t,n])=>{e[t]={...e[t]??{},...n}}),e},[i]),{popupKey:l}=(0,s.useParams)(),u=(0,s.useNavigate)(),{state:d={}}=(0,s.useLocation)(),[f,p]=(0,r.useState)({key:``,config:null});(0,r.useEffect)(()=>{let t=!1;if(!l||!d.moduleName)return;let n=`${d.moduleName}:${l}`;return e.Gt(d.moduleName,`popup`,l).then(e=>{t||p({key:n,config:aC(e[0])})}).catch(()=>{t||p({key:n,config:null})}),()=>{t=!0}},[l,d.moduleName]);let m=(0,r.useMemo)(()=>{let e=c[l],t=`${d.moduleName}:${l}`,n=f.key===t?f.config:null;return n?{...e,...n}:e},[f,c,l,d.moduleName]),h=(0,r.useMemo)(()=>({selectedIds:d.selectedIds??[],selectedRecords:d.selectedRecords??[],moduleName:d.moduleName??``,navigate:u,background:d.background??null,...d.popupContext??{}}),[u,d.selectedIds,d.selectedRecords,d.moduleName,d.popupContext,d.background]),g=(0,r.useMemo)(()=>{let e=d.popupAction;return e?.apiPath?{submit:(n,r)=>{let i=String(e.apiMethod||`POST`).toUpperCase();return t.a(t.b,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})})}}:{}},[d.popupAction]),_=e=>{let t=d.background;if(e?.success&&m?.successNavigate){u(m.successNavigate,{replace:!0,state:{refreshTimestamp:Date.now()}});return}if(e?.success&&t?.pathname){u(`${t.pathname}${t.search??``}`,{replace:!0,state:{...t.state??{},refreshTimestamp:Date.now()}});return}u(-1)};return l===`add-batch-candidate`?(0,o.jsx)(rC,{open:!0,context:h,onClose:_}):(0,o.jsx)(Lx,{open:!0,config:m,context:h,onClose:_,api:{...a[l]??{},...g}})}var sC={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`}]},cC={getVendorList:({jobId:e,limit:t,offset:n,type:r})=>It({jobId:e,limit:t,offset:n,sortBy:`new`,type:r}),getMailDetails:e=>Lt(e),submit:({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})=>Rt({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})},lC=sC.vendorColumns.map(e=>({...e,render:e=>e||`-`}));function uC(){let e=(0,s.useNavigate)(),t=(0,s.useLocation)(),{selectedIds:n=[],selectedRecords:c=[],recipients:l=[],subject:u=``,onSend:d,moduleName:f=``,popupAction:p={}}=t.state??{},m=n[0]??c[0]?._id??c[0]?.id,[h,g]=(0,r.useState)({to:l.join(`, `),cc:``,bcc:``,subject:u,contents:``,showCc:!1,showBcc:!1}),[_,v]=(0,r.useState)(!m),[y,b]=(0,r.useState)(sC.defaultTab),[x,S]=(0,r.useState)(``),[C,w]=(0,r.useState)([]),[T,E]=(0,r.useState)(0),[D,O]=(0,r.useState)(0),[k,A]=(0,r.useState)(0),[j,M]=(0,r.useState)(1),[N,P]=(0,r.useState)(sC.defaultPageSize),[F,I]=(0,r.useState)(!1),[L,R]=(0,r.useState)([]);(0,r.useEffect)(()=>{if(!m)return;let e=!1;I(!0);let t=x?100:N,n=x?0:(j-1)*N;return cC.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,r.useEffect)(()=>{m&&cC.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,r.useMemo)(()=>L.map(e=>C.find(t=>t.vendorId===e)?.vendorEmail??``).filter(Boolean),[L,C]),B=(0,r.useMemo)(()=>({...h,bcc:[...new Set([...$y(h.bcc),...z])].join(`, `),showBcc:h.showBcc||z.length>0}),[h,z]);function ee(e){let t=new Set(z);g({...e,bcc:$y(e.bcc).filter(e=>!t.has(e)).join(`, `)})}let te=($y(B.to).length||$y(B.bcc).length)&&eb(B.to)&&eb(B.cc)&&eb(B.bcc)&&B.subject.trim(),V=e=>e===`myVendor`?T:D;function ne(){e(-1)}function re(){te&&cC.submit({jobId:m,toMail:$y(B.to),ccMail:$y(B.cc),bccMail:$y(B.bcc),subject:B.subject,contents:B.contents}).then(t=>{t?.status===!0?(i.message.success(t?.data||`Mail sent successfully.`),typeof d==`function`&&d({...B,message:B.contents,selectedIds:n}),e(-1)):i.message.error(t?.message||t?.data||`Failed to send mail. Please try again.`)}).catch(e=>{i.message.error(e?.message||`Failed to send mail. Please try again.`)})}let H=(0,r.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,o.jsx)(i.Drawer,{open:!0,placement:`right`,onClose:ne,closable:!1,rootClassName:`vendor-share`,width:`95%`,footer:(0,o.jsxs)(`div`,{className:`vendor-share__footer`,children:[(0,o.jsx)(i.Button,{onClick:ne,children:`Cancel`}),(0,o.jsx)(i.Button,{type:`primary`,disabled:!te,onClick:re,children:`Send`})]}),children:(0,o.jsxs)(`div`,{className:`vendor-share__body`,children:[(0,o.jsxs)(`div`,{className:`vendor-share__left`,children:[(0,o.jsxs)(`div`,{className:`vendor-share__vendor-header`,children:[(0,o.jsxs)(`div`,{className:`vendor-share__vendor-header-row`,children:[(0,o.jsx)(i.Button,{type:`text`,icon:(0,o.jsx)(a.CloseOutlined,{}),onClick:ne,size:`small`,style:{marginRight:8}}),(0,o.jsx)(`span`,{className:`dynamic-popup__header-icon-box`,children:(0,o.jsx)(a.TeamOutlined,{})}),(0,o.jsx)(`span`,{className:`dynamic-popup__header-label`,children:`Vendor List`}),(0,o.jsxs)(`div`,{className:`vendor-share__vendor-search`,children:[(0,o.jsx)(a.SearchOutlined,{className:`vendor-share__search-icon`}),(0,o.jsx)(i.Input,{variant:`borderless`,placeholder:`Search vendor`,value:x,onChange:e=>{S(e.target.value),M(1)},className:`vendor-share__search-input`})]})]}),(0,o.jsx)(`div`,{className:`vendor-share__vendor-tabs`,children:sC.vendorTabs.map(e=>(0,o.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,` (`,V(e.key),`)`]},e.key))})]}),(0,o.jsx)(`div`,{className:`vendor-share__vendor-table-wrapper`,children:(0,o.jsx)(i.Table,{rowKey:e=>e.vendorId,columns:lC,dataSource:H,loading:F,pagination:!1,size:`small`,rowSelection:{selectedRowKeys:L,onChange:e=>{e.length>sC.maxVendorSelect||R(e)}},scroll:{y:`calc(100vh - 340px)`}})}),(0,o.jsx)(`div`,{className:`vendor-share__vendor-footer`,children:(0,o.jsx)(Se,{current:j,pageSize:N,total:k,onChange:e=>M(e),onPageSizeChange:e=>P(e)})})]}),(0,o.jsx)(`div`,{className:`vendor-share__right`,children:(0,o.jsx)(ab,{value:B,onChange:ee,moduleName:f,defaultTemplateId:p.defaultTemplateId??t.state?.defaultTemplateId??``,ready:_,contextRecords:c,title:`Share`,hint:`Select vendors or add email addresses`,bccHint:`Vendor emails are added automatically`,afterBcc:L.length>0?(0,o.jsxs)(`div`,{className:`vendor-share__selected-count`,children:[L.length,` / `,sC.maxVendorSelect,` Vendors selected`]}):null})})]})})}var dC={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].*$/},fC={SINGLE_FILE_COUNT:1,MULTI_FILE_COUNT:5,MAX_FILE_SIZE:2,ALLOWED_FILE_TYPES:[`image/jpeg`,`image/png`,`application/pdf`]},pC={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 ${fC.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.`},mC={FIRST_NAME_MIN:3,FIRST_NAME_MAX:30},hC={REMARKS_MIN:10,REMARKS_MAX:250},gC={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)}`}},_C={required:(e=`Field`)=>({required:!0,message:pC.REQUIRED(e)}),email:()=>({pattern:dC.EMAIL,message:pC.INVALID_EMAIL}),phone:()=>({pattern:dC.PHONE,message:pC.INVALID_PHONE}),password:()=>({pattern:dC.PASSWORD,message:pC.INVALID_PASSWORD}),alphabets:()=>({pattern:dC.ALPHABETS,message:pC.INVALID_ALPHABETS}),alphanumeric:()=>({pattern:dC.ALPHANUMERIC,message:pC.INVALID_ALPHANUMERIC}),number:()=>({pattern:dC.NUMBER,message:pC.INVALID_NUMBER}),url:()=>({pattern:dC.URL,message:pC.INVALID_URL}),candidateId:(e=`ID`)=>({pattern:dC.CANDIDATE_ID,message:pC.INVALID_CANDIDATE_ID(e)}),remarks:()=>({pattern:dC.REMARKS,message:pC.INVALID_REMARKS,REMARKS_MIN:`Remarks must be at least ${hC.REMARKS_MIN} characters.`,REMARKS_MAX:`Remarks must not exceed ${hC.REMARKS_MAX} characters.`}),designation:()=>({pattern:dC.DESIGNATION,message:pC.INVALID_DESIGNATION}),dob:(e=!0)=>({validator:(t,n)=>{if(!n)return e?Promise.reject(Error(`Date of Birth is required.`)):Promise.resolve();if(!dC.DOB.test(n))return Promise.reject(Error(pC.INVALID_DOB));let r=(0,c.default)(n,`MM/DD/YYYY`,!0);if(!r.isValid())return Promise.reject(Error(pC.INVALID_DOB));let i=(0,c.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:dC.LINKEDIN,message:pC.INVALID_LINKEDIN}),companyName:()=>({pattern:dC.COMPANY_NAME,message:pC.INVALID_COMPANY_NAME}),firstName:()=>({pattern:dC.FIRST_NAME,message:pC.INVALID_FIRST_NAME,FIRST_NAME_MIN:`First Name must be at least ${mC.FIRST_NAME_MIN} characters.`,FIRST_NAME_MAX:`First Name must not exceed ${mC.FIRST_NAME_MAX} characters.`}),firstNameMinLength:()=>({min:mC.FIRST_NAME_MIN,message:pC.FIRST_NAME_MIN}),firstNameMaxLength:()=>({max:mC.FIRST_NAME_MAX,message:pC.FIRST_NAME_MAX}),remarksMinLength:()=>({min:hC.REMARKS_MIN,message:pC.REMARKS_MIN}),remarksMaxLength:()=>({max:hC.REMARKS_MAX,message:pC.REMARKS_MAX}),fullName:()=>({pattern:dC.FULL_NAME,message:pC.INVALID_FULL_NAME}),noSpaces:()=>({pattern:dC.NO_SPACES,message:pC.NO_SPACES_ALLOWED}),startsWithCapital:()=>({pattern:dC.STARTS_WITH_CAPITAL,message:pC.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<=fC.MAX_FILE_SIZE))return i.message.error(pC.INVALID_FILE_SIZE),Promise.reject(Error(pC.INVALID_FILE_SIZE));if(!fC.ALLOWED_FILE_TYPES.includes(t.type))return Promise.reject(Error(pC.INVALID_FILE_TYPE))}return Promise.resolve()}}),singleFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>fC.SINGLE_FILE_COUNT)return Promise.reject(Error(pC.SINGLE_FILE_ONLY));let n=t[0];return n.size/1024/1024<fC.MAX_FILE_SIZE?fC.ALLOWED_FILE_TYPES.includes(n.type)?Promise.resolve():Promise.reject(Error(pC.INVALID_FILE_TYPE)):Promise.reject(Error(pC.INVALID_FILE_SIZE))}}),multiFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>fC.MULTI_FILE_COUNT)return Promise.reject(Error(pC.INVALID_FILE_COUNT));for(let e of t){if(!(e.size/1024/1024<fC.MAX_FILE_SIZE))return Promise.reject(Error(pC.INVALID_FILE_SIZE));if(!fC.ALLOWED_FILE_TYPES.includes(e.type))return Promise.reject(Error(pC.INVALID_FILE_TYPE))}return Promise.resolve()}})},vC={beforeUpload:e=>[`image/jpeg`,`image/png`,`application/pdf`].includes(e.type)?e.size/1024/1024<=2?!1:(i.message.error(`File upload must be 2 MB below.`),i.Upload.LIST_IGNORE):(i.message.error(`Only JPG, PNG and PDF files are allowed.`),i.Upload.LIST_IGNORE)},yC=()=>{let[e]=i.Form.useForm();return(0,o.jsx)(`div`,{style:{padding:24},children:(0,o.jsxs)(i.Form,{form:e,layout:`vertical`,onFinish:e=>{console.log(`Form Values:`,e)},autoComplete:`off`,children:[(0,o.jsxs)(i.Row,{gutter:16,children:[(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Email`,name:`email`,rules:[_C.required(`Email`),_C.email()],children:(0,o.jsx)(i.Input,{})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Phone Number`,name:`phone`,rules:[_C.required(`Phone Number`),_C.phone()],validateTrigger:[`onBlur`,`onChange`],children:(0,o.jsx)(i.Input,{maxLength:10,onChange:t=>{e.setFieldsValue({phone:gC.phoneFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Password`,name:`password`,rules:[_C.required(`Password`),_C.password()],children:(0,o.jsx)(i.Input.Password,{})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Full Name`,name:`fullName`,rules:[_C.required(`Full Name`),_C.alphabets(),_C.firstNameMinLength(),_C.firstNameMaxLength()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({fullName:gC.firstNameFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Username`,name:`username`,rules:[_C.required(`Username`),_C.alphanumeric()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({username:gC.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Website URL`,name:`website`,rules:[_C.required(`Website URL`),_C.url()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({website:gC.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`MSP Req ID`,name:`mspreqID`,rules:[_C.required(`MSP Req ID`),_C.candidateId(`MSP Req ID`)],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({mspreqID:gC.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Candidate ID`,name:`candidateId`,rules:[_C.required(`Candidate ID`),_C.candidateId(`Candidate ID`)],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({candidateId:gC.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:24,children:(0,o.jsx)(i.Form.Item,{label:`Remarks`,name:`remarks`,rules:[_C.required(`Remarks`),_C.remarks(),_C.remarksMinLength(),_C.remarksMaxLength()],children:(0,o.jsx)(i.Input.TextArea,{rows:4})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Designation`,name:`designation`,rules:[_C.required(`Designation`),_C.designation()],children:(0,o.jsx)(i.Input,{})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Date of Birth`,name:`dob`,rules:[_C.dob()],children:(0,o.jsx)(i.Input,{placeholder:`MM/DD/YYYY`,maxLength:10,onChange:t=>{e.setFieldsValue({dob:gC.dobFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Company Name`,name:`companyName`,rules:[_C.required(`Company Name`),_C.companyName()],children:(0,o.jsx)(i.Input,{})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{name:`contractType`,label:`Contract Type`,children:(0,o.jsxs)(i.Select,{showSearch:!0,allowClear:!0,filterOption:(e,t)=>(t?.label??``).toLowerCase().includes(e.toLowerCase()),children:[(0,o.jsx)(i.Select.Option,{value:`C2C`,label:`C2C`,children:`C2C`}),(0,o.jsx)(i.Select.Option,{value:`W2-Contract`,label:`W2-Contract`,children:`W2-Contract`}),(0,o.jsx)(i.Select.Option,{value:`W2-Fulltime`,label:`W2-Fulltime`,children:`W2-Fulltime`}),(0,o.jsx)(i.Select.Option,{value:`1099`,label:`1099`,children:`1099`})]})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{name:`candidateProposedRateCurrency`,label:`Currency`,children:(0,o.jsxs)(i.Select,{showSearch:!0,allowClear:!0,children:[(0,o.jsx)(i.Select.Option,{value:`$`,children:`$`}),(0,o.jsx)(i.Select.Option,{value:`₹`,children:`₹`}),(0,o.jsx)(i.Select.Option,{value:`€`,children:`€`}),(0,o.jsx)(i.Select.Option,{value:`zł`,children:`zł`}),(0,o.jsx)(i.Select.Option,{value:`£`,children:`£`}),(0,o.jsx)(i.Select.Option,{value:`kr`,children:`kr`}),(0,o.jsx)(i.Select.Option,{value:`Fr`,children:`Fr`}),(0,o.jsx)(i.Select.Option,{value:`kr`,children:`kr`})]})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Resume new`,name:`resume`,children:(0,o.jsx)(i.Upload,{beforeUpload:vC.beforeUpload,maxCount:1,children:(0,o.jsx)(i.Button,{children:`Upload Resume`})})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Documents`,name:`documents`,valuePropName:`fileList`,getValueFromEvent:e=>e?.fileList,rules:[_C.multiFileUpload()],children:(0,o.jsx)(i.Upload,{multiple:!0,beforeUpload:vC.beforeUpload,children:(0,o.jsx)(i.Button,{children:`Upload Documents`})})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Upload File`,name:`file`,valuePropName:`fileList`,getValueFromEvent:e=>e?.fileList,rules:[_C.fileUpload()],children:(0,o.jsx)(i.Upload,{beforeUpload:vC.beforeUpload,maxCount:1,children:(0,o.jsx)(i.Button,{children:`Upload`})})})})]}),(0,o.jsx)(i.Row,{children:(0,o.jsx)(i.Form.List,{name:`users`,children:(e,{add:t,remove:n})=>(0,o.jsxs)(o.Fragment,{children:[e.map(({key:e,name:t,...r})=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{required:!0,...r,rules:[{required:!0,message:`First name is requried`}],name:[t,`first`],children:(0,o.jsx)(i.Input,{placeholder:`First Name`})})}),(0,o.jsx)(i.Col,{span:11,children:(0,o.jsx)(i.Form.Item,{...r,required:!0,name:[t,`last`],children:(0,o.jsx)(i.Input,{placeholder:`Last Name`})})}),(0,o.jsx)(i.Col,{span:1,children:(0,o.jsx)(a.MinusCircleOutlined,{onClick:()=>n(t)})})]})),(0,o.jsx)(i.Form.Item,{children:(0,o.jsx)(i.Button,{type:`dashed`,onClick:()=>t(),block:!0,icon:(0,o.jsx)(a.PlusOutlined,{}),children:`Add field`})})]})})}),(0,o.jsxs)(i.Form.Item,{children:[(0,o.jsx)(i.Button,{type:`primary`,htmlType:`submit`,children:`Submit`}),(0,o.jsx)(i.Button,{style:{marginLeft:10},onClick:()=>e.resetFields(),children:`Reset`})]})]})})};function bC(e){return(0,o.jsx)(th,{children:(0,o.jsx)(Jy,{...e})})}var{Text:xC}=i.Typography,SC=[{label:`Total Jobs`,value:1697,icon:`fileText`},{label:`Active Jobs`,value:1685,icon:`checkCircle`},{label:`My Jobs`,value:600,icon:`user`}],CC={fileText:(0,o.jsx)(a.FileTextOutlined,{}),checkCircle:(0,o.jsx)(a.CheckCircleOutlined,{}),user:(0,o.jsx)(a.UserOutlined,{}),filter:(0,o.jsx)(a.FilterOutlined,{})};function wC({stats:e=SC}){return(0,o.jsx)(i.Card,{children:(0,o.jsx)(i.Row,{gutter:[12,12],children:e.map(e=>(0,o.jsx)(i.Col,{xs:24,sm:24,md:8,lg:8,xl:8,children:(0,o.jsxs)(i.Card,{className:`stats-inner-card`,children:[(0,o.jsxs)(i.Space,{align:`center`,children:[CC[e.icon]??CC.fileText,(0,o.jsx)(xC,{children:e.label})]}),(0,o.jsx)(i.Statistic,{value:e.value})]})},e.label))})})}var{Text:TC}=i.Typography;function EC(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 DC(e){return{...e,key:e.USER_ID??e.user_id??e.userId??e.id??e._id,_name:EC(e),_email:e.email??e.EMAIL??e.user_email??``,_role:e.role_name??e.roleName??e.ROLE_NAME??``,_rawRef:e}}function OC(){let[t,n]=(0,r.useState)([]),[s,c]=(0,r.useState)(0),[l,u]=(0,r.useState)(!1),[d,f]=(0,r.useState)(1),[p,m]=(0,r.useState)(10),[h,g]=(0,r.useState)(``),_=(0,r.useCallback)(async({offset:t,limit:r,searchQuery:a}={})=>{u(!0);try{let i=await e.Rt({offset:t,limit:r,searchQuery:a??``}),o=(i.users??[]).map(DC);n(o),c(i.total??o.length)}catch{i.message.error(`Failed to load users`)}finally{u(!1)}},[]);return(0,r.useEffect)(()=>{queueMicrotask(()=>{_({offset:(d-1)*p,limit:p,searchQuery:h})})},[_,d,p,h]),(0,o.jsx)(Z,{icon:(0,o.jsx)(a.TeamOutlined,{}),title:`Users`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,o.jsx)(hf,{listName:`Users`,dataSource:t,fields:[{label:`Name`,value:`_name`,width:220,render:(e,t)=>(0,o.jsxs)(`div`,{children:[(0,o.jsx)(TC,{strong:!0,style:{fontSize:13},children:e}),t._email&&(0,o.jsx)(`div`,{style:{fontSize:11,color:`var(--color-text-muted)`},children:t._email})]})},{label:`Role`,value:`_role`,width:180}],loading:l,total:s,current:d,pageSize:p,onPageChange:e=>f(e),onPageSizeChange:e=>{m(e),f(1)},onSearch:e=>{g(e),f(1)}})})}var{Text:kC}=i.Typography,AC=[{key:`job`,label:`Jobs`},{key:`candidate`,label:`Candidates`},{key:`submissions`,label:`Submissions`}],jC=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`}];function MC({field:e,index:t,onToggle:n,onReorder:s}){let c=(0,r.useRef)(null),[l,u]=(0,r.useState)(!1),[d,f]=(0,r.useState)(!1);function p(e){c.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),c.current!==null&&c.current!==t&&s(c.current,t),c.current=null}return(0,o.jsxs)(`div`,{draggable:!0,onDragStart:p,onDragEnd:m,onDragOver:h,onDragLeave:g,onDrop:_,className:`uss-field-row with-edit${l?` drag-over`:``}${d?` dragging`:``}`,children:[(0,o.jsx)(`span`,{className:`uss-drag-handle`,children:(0,o.jsx)(a.HolderOutlined,{})}),(0,o.jsxs)(`span`,{className:`uss-field-name`,children:[e.fieldName,(0,o.jsx)(`span`,{className:`uss-field-key`,children:e.fieldKey})]}),(0,o.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,o.jsx)(i.Switch,{size:`small`,checked:e.isVisible,onChange:e=>n(t,`isVisible`,e)})}),(0,o.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,o.jsx)(i.Switch,{size:`small`,checked:!!e.isEditable,onChange:e=>n(t,`isEditable`,e)})}),(0,o.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,o.jsx)(i.Switch,{size:`small`,checked:!!e.ismandatory,onChange:e=>n(t,`ismandatory`,e)})})]})}function NC({team:t,configType:n}){let[a,s]=(0,r.useState)({}),[c,l]=(0,r.useState)(!1),[u,d]=(0,r.useState)({}),[f,p]=(0,r.useState)(`job`);(0,r.useEffect)(()=>{t&&(l(!0),e.pn(t,n).then(s).catch(()=>i.message.error(`Failed to load field config`)).finally(()=>l(!1)))},[t,n]);let m=a[f]??[];function h(e,t){s(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 e.Rn(t,r,m,n),i.message.success(`Saved`)}catch{i.message.error(`Save failed`)}finally{d(e=>({...e,[r]:!1}))}}return(0,o.jsxs)(i.Spin,{spinning:c,children:[(0,o.jsx)(i.Tabs,{size:`small`,activeKey:f,onChange:p,items:AC.map(e=>({key:e.key,label:e.label}))}),(0,o.jsxs)(`div`,{className:`uss-field-header with-edit`,children:[(0,o.jsx)(`span`,{}),(0,o.jsx)(`span`,{children:`Field`}),(0,o.jsx)(`span`,{style:{textAlign:`center`},children:`Visible`}),(0,o.jsx)(`span`,{style:{textAlign:`center`},children:`Editable`}),(0,o.jsx)(`span`,{style:{textAlign:`center`},children:`Mandatory`})]}),(0,o.jsxs)(`div`,{className:`uss-field-list`,children:[m.length===0&&!c&&(0,o.jsx)(`div`,{className:`uss-empty`,children:`No fields found.`}),m.map((e,t)=>(0,o.jsx)(MC,{field:e,index:t,onToggle:g,onReorder:_},e.fieldKey??t))]}),(0,o.jsx)(`div`,{className:`uss-modal-footer`,children:(0,o.jsxs)(i.Button,{type:`primary`,size:`small`,loading:u[f],onClick:v,children:[`Save `,AC.find(e=>e.key===f)?.label]})})]})}function PC(){let[t,n]=(0,r.useState)(null),[s,c]=(0,r.useState)(!1),[l,u]=(0,r.useState)(!1),[d,f]=(0,r.useState)(`listView`),[p,m]=(0,r.useState)([]),[h,g]=(0,r.useState)(0),[_,v]=(0,r.useState)(!1),[y,b]=(0,r.useState)(``),[x,S]=(0,r.useState)(!1),C=(0,r.useCallback)(async()=>{v(!0);try{let t=await e.Lt();m(t.teams),g(t.total)}catch{i.message.error(`Failed to load teams`)}finally{v(!1)}},[]);(0,r.useEffect)(()=>{C()},[C]);function w(e){n(e),f(`listView`),c(!0)}function T(e){n(e),b(e.teamName??``),u(!0)}async function E(){if(!y.trim()){i.message.warning(`Team name is required`);return}S(!0);try{await e.Ln(t,{teamName:y.trim(),managerId:t.managerId,memberIds:t.memberIds}),i.message.success(`Team updated`),u(!1),C()}catch{i.message.error(`Failed to update team`)}finally{S(!1)}}return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(Z,{icon:(0,o.jsx)(a.TeamOutlined,{}),title:`Teams`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,o.jsx)(hf,{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,o.jsxs)(`div`,{style:{display:`flex`,gap:4},children:[(0,o.jsx)(i.Button,{size:`small`,type:`link`,onClick:()=>T(t),children:`Edit`}),(0,o.jsx)(i.Button,{size:`small`,type:`link`,onClick:()=>w(t),children:`Configure`})]})}],loading:_,total:h})}),(0,o.jsx)(i.Modal,{open:l,onCancel:()=>u(!1),title:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(a.TeamOutlined,{style:{color:`var(--color-brand)`,marginRight:6}}),`Edit Team`]}),width:420,footer:null,destroyOnClose:!0,children:(0,o.jsxs)(`div`,{className:`uss-edit-team-body`,style:{paddingTop:12},children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`div`,{className:`uss-edit-team-label`,children:`Team Name`}),(0,o.jsx)(i.Input,{value:y,onChange:e=>b(e.target.value),onPressEnter:E,placeholder:`Enter team name`})]}),(0,o.jsxs)(`div`,{className:`uss-modal-footer`,children:[(0,o.jsx)(i.Button,{onClick:()=>u(!1),children:`Cancel`}),(0,o.jsx)(i.Button,{type:`primary`,loading:x,onClick:E,children:`Save`})]})]})}),(0,o.jsxs)(i.Modal,{className:`uss-modal`,open:s,onCancel:()=>c(!1),title:(0,o.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,o.jsx)(a.TeamOutlined,{style:{color:`var(--color-brand)`}}),(0,o.jsxs)(`span`,{children:[`Configure: `,t?.teamName]})]}),width:720,footer:null,destroyOnClose:!0,children:[(0,o.jsx)(`div`,{style:{marginBottom:12},children:(0,o.jsx)(`div`,{className:`uss-config-toggle`,children:jC.map(e=>(0,o.jsx)(`button`,{className:`uss-config-btn${d===e.key?` active`:``}`,onClick:()=>f(e.key),children:e.label},e.key))})}),t&&(0,o.jsx)(NC,{team:t,configType:d},`${t?.teamId}-${d}`)]})]})}var FC=[`view`,`add`,`edit`,`delete`],IC={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`};function LC(e){return IC[e]??e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function RC(e){let t=FC.filter(t=>e.includes(t)),n=e.filter(e=>!FC.includes(e)).sort();return[...t,...n]}function zC(e){let t=new Set;return Object.values(e).forEach(({permissions:e})=>Object.keys(e??{}).forEach(e=>t.add(e))),RC([...t])}function BC(e){let t=0,n=0;return Object.entries(e).forEach(([e,{permissions:r}])=>{Object.entries(r??{}).forEach(([r,{value:i}])=>{dg(e,r)&&(n++,i===`1`&&t++)})}),{enabled:t,total:n}}function VC({value:e,onSave:t,className:n}){let[i,s]=(0,r.useState)(!1),[c,l]=(0,r.useState)(e);(0,r.useEffect)(()=>{l(e)},[e]);function u(){s(!1);let n=c.trim();n&&n!==e?t(n):l(e)}return i?(0,o.jsx)(`input`,{autoFocus:!0,className:`perm-inline-input${n?` ${n}`:``}`,value:c,style:{width:Math.max(48,c.length*8)},onChange:e=>l(e.target.value),onBlur:u,onKeyDown:t=>{t.key===`Enter`&&u(),t.key===`Escape`&&(s(!1),l(e)),t.stopPropagation()},onClick:e=>e.stopPropagation()}):(0,o.jsxs)(`span`,{className:`perm-editable-name${n?` ${n}`:``}`,onDoubleClick:e=>{e.stopPropagation(),s(!0)},children:[e,(0,o.jsx)(a.EditOutlined,{className:`perm-name-edit-icon`})]})}function HC({entry:e,label:t,onToggle:n,onLabelSave:s}){let[c,l]=(0,r.useState)(!1),[u,d]=(0,r.useState)(t),f=e?.value===`1`,p=!!e;(0,r.useEffect)(()=>{d(t)},[t]);function m(){l(!1);let e=u.trim();e&&e!==t?s(e):d(t)}return(0,o.jsx)(i.Tooltip,{title:p?f?`Click to disable`:`Click to enable`:`Not applicable for this module`,children:(0,o.jsxs)(`div`,{className:`perm-action-pill${f?` on`:``}${p?``:` na`}`,onClick:()=>{!c&&p&&n()},children:[(0,o.jsx)(`span`,{className:`perm-action-pill-dot${f?` on`:``}`}),c?(0,o.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`&&(l(!1),d(t)),e.stopPropagation()},onClick:e=>e.stopPropagation()}):(0,o.jsx)(`span`,{className:`perm-action-pill-label`,onDoubleClick:e=>{e.stopPropagation(),l(!0)},children:t}),f&&!c&&(0,o.jsx)(a.CheckOutlined,{className:`perm-action-pill-check`})]})})}function UC({menuName:e,menuData:t,permKeys:n,onChange:r,displayName:i,actionLabels:a,onModuleLabelSave:s,onActionLabelSave:c}){let l=t?.permissions??{},u=n.filter(t=>dg(e,t)),d=u.filter(e=>l[e]?.value===`1`).length,f=u.filter(e=>l[e]).length,p=f>0&&d===f;return(0,o.jsxs)(`div`,{className:`perm-module-card${p?` all-on`:d>0&&!p?` some-on`:``}`,children:[(0,o.jsxs)(`div`,{className:`perm-module-card-header`,children:[(0,o.jsx)(VC,{value:i,onSave:t=>s(e,t),className:`perm-module-card-name`}),f>0&&(0,o.jsxs)(`span`,{className:`perm-module-card-badge${d>0?` active`:``}`,children:[d,`/`,f]})]}),(0,o.jsx)(`div`,{className:`perm-module-card-body`,children:u.map(t=>(0,o.jsx)(HC,{entry:l[t],label:a[t]??LC(t),onToggle:()=>r(e,t),onLabelSave:e=>c(t,e)},t))})]})}function WC({role:t,moduleLabels:n={},actionLabels:s={},onModuleLabelSave:c=()=>{},onActionLabelSave:l=()=>{}}){let[u,d]=(0,r.useState)({}),[f,p]=(0,r.useState)({}),[m,h]=(0,r.useState)(!1),[g,_]=(0,r.useState)(!1),[v,y]=(0,r.useState)(!1),b=e.ln(t);(0,r.useEffect)(()=>{b&&(h(!0),y(!1),e.dn(b).then(e=>{d(e),p(e)}).catch(()=>i.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 e.Fn(b,f),d(f),y(!1),i.message.success(`Permissions saved`)}catch(e){i.message.error(e?.message||`Save failed`)}finally{_(!1)}}let C=(0,r.useMemo)(()=>Object.keys(f).sort(),[f]),w=(0,r.useMemo)(()=>zC(f),[f]),{enabled:T,total:E}=(0,r.useMemo)(()=>BC(f),[f]);return(0,o.jsxs)(i.Spin,{spinning:m,children:[(0,o.jsxs)(`div`,{className:`perm-panel-header`,children:[(0,o.jsxs)(`div`,{className:`perm-panel-title`,children:[(0,o.jsx)(a.LockOutlined,{style:{color:`var(--color-brand)`,marginRight:6}}),(0,o.jsx)(`span`,{children:t?.roleName}),!m&&E>0&&(0,o.jsxs)(i.Tag,{color:`blue`,style:{marginLeft:8,fontSize:11},children:[T,`/`,E,` enabled`]})]}),(0,o.jsx)(i.Button,{type:`primary`,size:`small`,icon:(0,o.jsx)(a.UnlockOutlined,{}),loading:g,disabled:!v,onClick:S,children:`Save Changes`})]}),(0,o.jsxs)(`div`,{className:`perm-hint`,children:[(0,o.jsx)(a.InfoCircleOutlined,{className:`perm-hint-icon`}),(0,o.jsxs)(`span`,{children:[`Click a pill to toggle. `,(0,o.jsx)(`strong`,{children:`Double-click`}),` a module name or action label to rename it — labels are saved locally.`]})]}),C.length===0&&!m?(0,o.jsx)(`div`,{className:`perm-empty`,children:`No permission entries found for this role.`}):(0,o.jsx)(`div`,{className:`perm-cards-grid`,children:C.map(e=>(0,o.jsx)(UC,{menuName:e,menuData:f[e],permKeys:w,onChange:x,displayName:n[e]??e,actionLabels:s,onModuleLabelSave:c,onActionLabelSave:l},e))})]})}var{Text:GC}=i.Typography,KC=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`}];function qC(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function JC(e){return String(e||``).trim().toLowerCase()}function YC(e){return e?.key||e?.collectionName||e?.value||``}function XC(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=YC(e);if(!t)return;let o=JC(e.key||t),s=JC(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||qC(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=JC(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:qC(t),value:t,disabled:!1}))}),n}function ZC(){let[t,n]=(0,r.useState)(null),[s,c]=(0,r.useState)(!1),[l,u]=(0,r.useState)(`listView`),[d,f]=(0,r.useState)([]),[p,m]=(0,r.useState)(0),[h,g]=(0,r.useState)(!1),[_,v]=(0,r.useState)([]),[y,b]=(0,r.useState)([]),[x,S]=(0,r.useState)(!1),[C,w]=(0,r.useState)(!1),T=(0,r.useMemo)(()=>_.filter(e=>!e.disabled),[_]),E=!x&&T.length===0,D=(0,r.useCallback)(async()=>{g(!0);try{let t=await e.It();f(t.roles),m(t.total)}catch{i.message.error(`Failed to load roles`)}finally{g(!1)}},[]),O=(0,r.useCallback)(async()=>{S(!0);try{let[t,n]=await Promise.all([e.Jt(),e.Bt()]),r=XC(t.modules,n),i=new Set(r.filter(e=>!e.disabled).map(e=>e.value));v(r),b(e=>e.filter(e=>i.has(e)))}catch{i.message.error(`Failed to load seed status`)}finally{S(!1)}},[]);(0,r.useEffect)(()=>{D()},[D]),(0,r.useEffect)(()=>{O()},[O]);async function k(){if(y.length===0){i.message.warning(E?`All modules already seeded.`:`Select at least one module to seed.`);return}w(!0);try{await e.En(y),i.message.success(`Role field config seeded`),b([]),await O()}catch(e){i.message.error(e?.message||`Seed failed`)}finally{w(!1)}}function A(e,t=`listView`){n(e),u(t),c(!0)}return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(Z,{icon:(0,o.jsx)(a.AppstoreOutlined,{}),title:`Field Config Seed`,style:{marginBottom:12},children:[(0,o.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[(0,o.jsx)(`div`,{style:{minWidth:320,flex:1},children:(0,o.jsx)(i.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,o.jsx)(i.Button,{type:`primary`,loading:C,disabled:x||y.length===0,onClick:k,children:`Seed Field Config`})]}),(0,o.jsx)(GC,{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,o.jsx)(Z,{icon:(0,o.jsx)(a.SafetyOutlined,{}),title:`Roles`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,o.jsx)(hf,{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,o.jsxs)(i.Space,{size:2,children:[(0,o.jsx)(i.Button,{size:`small`,type:`link`,onClick:()=>A(t),children:`Configure`}),(0,o.jsx)(i.Button,{size:`small`,type:`link`,icon:(0,o.jsx)(a.LockOutlined,{}),onClick:()=>A(t,`permissions`),children:`Permissions`})]})}],loading:h,total:p})}),(0,o.jsxs)(i.Modal,{className:`uss-modal`,open:s,onCancel:()=>c(!1),title:(0,o.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,o.jsx)(a.SafetyOutlined,{style:{color:`var(--color-brand)`}}),(0,o.jsxs)(`span`,{children:[`Configure: `,t?.roleName]})]}),width:720,footer:null,destroyOnClose:!0,children:[(0,o.jsx)(`div`,{style:{marginBottom:12},children:(0,o.jsx)(`div`,{className:`uss-config-toggle`,children:KC.map(e=>(0,o.jsx)(`button`,{className:`uss-config-btn${l===e.key?` active`:``}`,onClick:()=>u(e.key),children:e.label},e.key))})}),t&&(l===`permissions`?(0,o.jsx)(WC,{role:t},t?.roleId):(0,o.jsx)(Og,{role:t,configType:l},`${t?.roleId}-${l}`))]})]})}var QC=`perm-module-labels`,$C=`perm-action-labels`;function ew(e){try{return JSON.parse(localStorage.getItem(e)??`{}`)}catch{return{}}}function tw(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function nw({label:e,onSave:t,onDelete:n,loading:s}){let[c,l]=(0,r.useState)(!1),[u,d]=(0,r.useState)(e);function f(){l(!1);let n=u.trim();n&&n!==e?t(n):d(e)}return(0,o.jsxs)(`div`,{className:`perm-manage-row`,children:[c?(0,o.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`&&(l(!1),d(e))}}):(0,o.jsx)(`span`,{className:`perm-manage-row-label`,children:e}),(0,o.jsxs)(`div`,{className:`perm-manage-row-actions`,children:[(0,o.jsx)(i.Button,{type:`text`,size:`small`,icon:(0,o.jsx)(a.EditOutlined,{}),onClick:()=>{d(e),l(!0)},loading:s}),(0,o.jsx)(i.Popconfirm,{title:`Delete this item?`,onConfirm:n,okText:`Delete`,cancelText:`Cancel`,okType:`danger`,children:(0,o.jsx)(i.Button,{type:`text`,size:`small`,icon:(0,o.jsx)(a.DeleteOutlined,{}),danger:!0})})]})]})}function rw({open:t,onClose:n}){let[s,c]=(0,r.useState)(`modules`),[l,u]=(0,r.useState)([]),[d,f]=(0,r.useState)(!1),[p,m]=(0,r.useState)(``),[h,g]=(0,r.useState)(!1),[_,v]=(0,r.useState)([]),[y,b]=(0,r.useState)(!1),[x,S]=(0,r.useState)(``),[C,w]=(0,r.useState)(``),[T,E]=(0,r.useState)(!1);(0,r.useEffect)(()=>{t&&(D(),O())},[t]);async function D(){f(!0);try{u(await e.tn())}catch{i.message.error(`Failed to load modules`)}finally{f(!1)}}async function O(){b(!0);try{v(await e.en())}catch{i.message.error(`Failed to load actions`)}finally{b(!1)}}async function k(){let t=p.trim();if(!t){i.message.warning(`Enter a module name`);return}g(!0);try{let n=await e.vt({menuName:t});u(e=>[...e,n]),m(``),i.message.success(`Module added`)}catch{i.message.error(`Failed to add module`)}finally{g(!1)}}async function A(t,n){try{await e.jn(t,{menuName:n}),u(e=>e.map(e=>e.MENUID===t?{...e,MENUNAME:n}:e))}catch{i.message.error(`Failed to update module`)}}async function j(t){try{await e.Dt(t),u(e=>e.filter(e=>e.MENUID!==t)),i.message.success(`Module deleted`)}catch{i.message.error(`Failed to delete module`)}}async function M(){let t=x.trim(),n=C.trim().toLowerCase().replace(/\s+/g,`_`);if(!t||!n){i.message.warning(`Enter both name and key`);return}E(!0);try{let r=await e._t({permissionName:t,permissionKey:n});v(e=>[...e,r]),S(``),w(``),i.message.success(`Action added`)}catch(e){i.message.error(e?.message?.includes(`409`)||e?.status===409?`Permission key already exists`:`Failed to add action`)}finally{E(!1)}}async function N(t,n){try{await e.An(t,{permissionName:n}),v(e=>e.map(e=>e.permissionId===t?{...e,permissionName:n}:e))}catch{i.message.error(`Failed to update action`)}}async function P(t){try{await e.Et(t),v(e=>e.filter(e=>e.permissionId!==t)),i.message.success(`Action deleted`)}catch{i.message.error(`Failed to delete action`)}}let F=[{key:`modules`,label:`Modules`,children:(0,o.jsxs)(i.Spin,{spinning:d,children:[(0,o.jsxs)(`div`,{className:`perm-manage-add-row`,children:[(0,o.jsx)(i.Input,{placeholder:`Module name`,value:p,onChange:e=>m(e.target.value),onPressEnter:k,style:{flex:1},size:`small`}),(0,o.jsx)(i.Button,{type:`primary`,size:`small`,icon:(0,o.jsx)(a.PlusOutlined,{}),loading:h,onClick:k,children:`Add`})]}),(0,o.jsxs)(`div`,{className:`perm-manage-list`,children:[l.length===0&&!d&&(0,o.jsx)(`div`,{className:`perm-empty`,style:{paddingTop:24},children:`No modules found`}),l.map(e=>(0,o.jsx)(nw,{label:e.MENUNAME,onSave:t=>A(e.MENUID,t),onDelete:()=>j(e.MENUID)},e.MENUID))]})]})},{key:`actions`,label:`Actions`,children:(0,o.jsxs)(i.Spin,{spinning:y,children:[(0,o.jsxs)(`div`,{className:`perm-manage-add-row`,children:[(0,o.jsx)(i.Input,{placeholder:`Action name (e.g. Approve)`,value:x,onChange:e=>S(e.target.value),style:{flex:1},size:`small`}),(0,o.jsx)(i.Input,{placeholder:`Key (e.g. approve)`,value:C,onChange:e=>w(e.target.value),onPressEnter:M,style:{width:140},size:`small`}),(0,o.jsx)(i.Button,{type:`primary`,size:`small`,icon:(0,o.jsx)(a.PlusOutlined,{}),loading:T,onClick:M,children:`Add`})]}),(0,o.jsxs)(`div`,{className:`perm-manage-list`,children:[_.length===0&&!y&&(0,o.jsx)(`div`,{className:`perm-empty`,style:{paddingTop:24},children:`No actions found`}),_.map(e=>(0,o.jsx)(nw,{label:`${e.permissionName} (${e.permissionKey})`,onSave:t=>N(e.permissionId,t),onDelete:()=>P(e.permissionId)},e.permissionId))]})]})}];return(0,o.jsx)(i.Modal,{open:t,onCancel:n,title:(0,o.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,o.jsx)(a.SettingOutlined,{style:{color:`var(--color-brand)`}}),`Manage Modules & Actions`]}),width:520,footer:null,destroyOnClose:!0,children:(0,o.jsx)(i.Tabs,{activeKey:s,onChange:c,size:`small`,items:F})})}function iw(){let[t,n]=(0,r.useState)([]),[s,c]=(0,r.useState)(!1),[l,u]=(0,r.useState)(null),[d,f]=(0,r.useState)(``),[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(()=>ew(QC)),[_,v]=(0,r.useState)(()=>ew($C)),y=(0,r.useCallback)((e,t)=>{g(n=>{let r={...n,[e]:t};return tw(QC,r),r})},[]),b=(0,r.useCallback)((e,t)=>{v(n=>{let r={...n,[e]:t};return tw($C,r),r})},[]);function x(){g({}),v({}),tw(QC,{}),tw($C,{}),i.message.success(`Labels reset to defaults`)}let S=(0,r.useCallback)(async()=>{c(!0);try{let{roles:t}=await e.It();n(t),t.length>0&&u(t[0])}catch{i.message.error(`Failed to load roles`)}finally{c(!1)}},[]);(0,r.useEffect)(()=>{S()},[S]);let C=(0,r.useMemo)(()=>{let e=d.trim().toLowerCase();return e?t.filter(t=>t.roleName.toLowerCase().includes(e)):t},[t,d]),w=Object.keys(h).length>0||Object.keys(_).length>0;return(0,o.jsxs)(`div`,{className:`perm-page`,children:[(0,o.jsxs)(Z,{className:`perm-left-card`,icon:(0,o.jsx)(a.SafetyOutlined,{}),title:`Roles`,bodyStyle:{padding:0},children:[(0,o.jsx)(`div`,{className:`perm-role-search`,children:(0,o.jsx)(i.Input,{prefix:(0,o.jsx)(a.SearchOutlined,{}),placeholder:`Search roles…`,allowClear:!0,size:`small`,value:d,onChange:e=>f(e.target.value)})}),(0,o.jsx)(i.Spin,{spinning:s,children:(0,o.jsxs)(`div`,{className:`perm-role-list`,children:[C.length===0&&!s&&(0,o.jsx)(`div`,{className:`perm-role-empty`,children:`No roles found`}),C.map(e=>{let t=l?.roleId===e.roleId,n=e.description&&e.description!==`N/A`?e.description:e.roleType===0?`Default role`:`Custom role`;return(0,o.jsxs)(`div`,{className:`perm-role-item${t?` active`:``}`,onClick:()=>u(e),children:[(0,o.jsx)(`div`,{className:`perm-role-item-name`,children:e.roleName}),(0,o.jsx)(`div`,{className:`perm-role-item-desc`,children:n})]},e.roleId)})]})})]}),(0,o.jsx)(Z,{className:`perm-right-card`,icon:(0,o.jsx)(a.LockOutlined,{}),title:`Module Permissions`,extra:(0,o.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[w&&(0,o.jsx)(`button`,{className:`perm-reset-btn`,onClick:x,children:`Reset labels`}),(0,o.jsx)(i.Button,{size:`small`,icon:(0,o.jsx)(a.SettingOutlined,{}),onClick:()=>m(!0),children:`Manage`})]}),bodyStyle:{padding:`12px 16px`},children:l?(0,o.jsx)(WC,{role:l,moduleLabels:h,actionLabels:_,onModuleLabelSave:y,onActionLabelSave:b},l.roleId):(0,o.jsx)(`div`,{className:`perm-empty`,children:`Select a role from the left to manage its permissions.`})}),(0,o.jsx)(rw,{open:p,onClose:()=>m(!1)})]})}var{Title:aw,Text:ow}=i.Typography,sw=[{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 cw({items:e=sw}){return(0,o.jsx)(i.Card,{className:`onboarding-card`,title:(0,o.jsx)(aw,{level:5,children:`Onboarding`}),extra:(0,o.jsx)(i.Button,{type:`link`,children:`View all`}),children:(0,o.jsx)(i.Row,{gutter:[12,12],children:e.map(e=>(0,o.jsx)(i.Col,{xs:12,sm:6,md:6,lg:12,xl:12,children:(0,o.jsxs)(`div`,{className:`onboarding-item ${e.color}`,children:[(0,o.jsx)(ow,{className:`onboarding-item-label`,children:e.label}),(0,o.jsx)(i.Statistic,{value:e.value,className:`onboarding-stat`}),(0,o.jsx)(`div`,{className:`onboarding-item-footer`,children:(0,o.jsx)(ow,{className:`onboarding-item-sub`,children:e.sub})})]})},e.label))})})}var{Text:lw,Title:uw}=i.Typography,dw=[{group:`Dashboard`,items:[{id:`dashboard`,label:`Admin Dashboard`,icon:(0,o.jsx)(a.DashboardOutlined,{})}]},{group:`Settings`,items:[{id:`org`,label:`Organization`,icon:(0,o.jsx)(a.BankOutlined,{}),heading:`Organization Settings`,desc:`Manage your company profile and location details`,cards:[{label:`Company Information`,icon:(0,o.jsx)(a.BankOutlined,{}),desc:`Manage company profile, address and business details.`},{label:`Location`,icon:(0,o.jsx)(a.BuildOutlined,{}),desc:`Manage office locations, branches and regions.`}]},{id:`users`,label:`Users`,icon:(0,o.jsx)(a.UserOutlined,{}),heading:`Users`,desc:`Manage platform users and configure their field views.`,component:`users`},{id:`teams`,label:`Teams`,icon:(0,o.jsx)(a.TeamOutlined,{}),heading:`Teams`,desc:`Organize users into teams and configure field visibility per team.`,component:`teams`},{id:`roles`,label:`Roles`,icon:(0,o.jsx)(a.SafetyOutlined,{}),heading:`Roles`,desc:`Control permissions and configure field visibility per role.`,component:`roles`},{id:`permissions`,label:`Permissions`,icon:(0,o.jsx)(a.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,o.jsx)(a.FileTextOutlined,{}),heading:`Templates`,desc:`Email and signature templates for communications`,component:`templates`},{id:`ai-services`,label:`AI Services`,icon:(0,o.jsx)(a.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,o.jsx)(a.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,o.jsx)(a.BankOutlined,{}),heading:`Clients`,desc:`Manage client accounts and settings`,cards:[{label:`Clients`,icon:(0,o.jsx)(a.BankOutlined,{}),desc:`Manage client companies and account details.`}]}]},{group:`Forms`,items:[{id:`form-groups`,label:`Form Groups`,icon:(0,o.jsx)(a.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,o.jsx)(a.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,o.jsx)(a.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,o.jsx)(a.AppstoreOutlined,{}),heading:`Jobs Master`,desc:`Configure job sources and status types`,cards:[{label:`Sources`,icon:(0,o.jsx)(a.AppstoreOutlined,{}),desc:`Manage job source master values.`},{label:`Job Status`,icon:(0,o.jsx)(a.CheckCircleOutlined,{}),desc:`Configure job workflow status.`}]},{id:`candidates`,label:`Candidates`,icon:(0,o.jsx)(a.UserOutlined,{}),heading:`Candidates Master`,desc:`Skills, sources and work authorization settings`,cards:[{label:`Sources`,icon:(0,o.jsx)(a.AppstoreOutlined,{}),desc:`Manage candidate source values.`},{label:`Skills`,icon:(0,o.jsx)(a.SettingOutlined,{}),desc:`Manage skill master data.`},{label:`Work Authorization`,icon:(0,o.jsx)(a.SafetyOutlined,{}),desc:`Manage visa and authorization types.`}]},{id:`submissions`,label:`Submissions`,icon:(0,o.jsx)(a.FileTextOutlined,{}),heading:`Submissions Master`,desc:`Rejection reasons and submission status configuration`,cards:[{label:`Rejection Reasons`,icon:(0,o.jsx)(a.FileTextOutlined,{}),desc:`Manage common rejection reasons.`},{label:`Client Submission Status`,icon:(0,o.jsx)(a.CheckCircleOutlined,{}),desc:`Manage client submission statuses.`}]},{id:`clientmaster`,label:`Client Master`,icon:(0,o.jsx)(a.BankOutlined,{}),heading:`Client Master`,desc:`Payment terms, client types and contact types`,cards:[{label:`Payment Terms`,icon:(0,o.jsx)(a.FileTextOutlined,{}),desc:`Manage billing and payment terms.`},{label:`Client Type`,icon:(0,o.jsx)(a.AppstoreOutlined,{}),desc:`Classify client business types.`},{label:`Client Contact Type`,icon:(0,o.jsx)(a.TeamOutlined,{}),desc:`Manage client contact categories.`}]}]}],fw=[{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}],pw=[{name:`Tcs`,jobs:14,candidates:86},{name:`Empasis`,jobs:9,candidates:64},{name:`NovaSystems`,jobs:7,candidates:51},{name:`Brightwave`,jobs:5,candidates:38}],mw=[{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 hw(){return(0,o.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:16},children:[(0,o.jsxs)(Z,{icon:(0,o.jsx)(a.DashboardOutlined,{}),title:`Admin Dashboard`,children:[(0,o.jsx)(`div`,{className:`admin-accent-bar`}),(0,o.jsx)(uw,{level:5,children:`Admin Dashboard`}),(0,o.jsx)(lw,{type:`secondary`,children:`Overview of jobs, candidates, onboarding and recent activity`})]}),(0,o.jsx)(`div`,{className:`admin-dashboard-stats`,children:(0,o.jsx)(wC,{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,o.jsxs)(`div`,{className:`admin-dashboard-mid-row`,children:[(0,o.jsx)(cw,{}),(0,o.jsxs)(Z,{icon:(0,o.jsx)(a.AppstoreOutlined,{}),title:`Candidate Pipeline`,children:[(0,o.jsx)(lw,{type:`secondary`,style:{fontSize:12},children:`By stage (892 total)`}),(0,o.jsx)(`div`,{className:`admin-pipeline-bar`,children:fw.map(e=>(0,o.jsx)(`div`,{className:`admin-pipeline-seg`,style:{width:`${e.pct}%`,background:e.color}},e.label))}),(0,o.jsx)(`div`,{className:`admin-pipeline-legend`,children:fw.map(e=>(0,o.jsxs)(`div`,{className:`admin-pipeline-legend-item`,children:[(0,o.jsx)(`span`,{className:`admin-pipeline-dot`,style:{background:e.color}}),e.label,` `,e.count]},e.label))}),(0,o.jsx)(`div`,{className:`admin-divider`}),(0,o.jsx)(lw,{strong:!0,style:{fontSize:12},children:`Submission status`}),(0,o.jsxs)(`div`,{className:`admin-sub-status-list`,style:{marginTop:6},children:[(0,o.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,o.jsx)(lw,{style:{fontSize:13},children:`Pending client review`}),(0,o.jsx)(`span`,{className:`admin-badge warn`,children:`312`})]}),(0,o.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,o.jsx)(lw,{style:{fontSize:13},children:`Client approved`}),(0,o.jsx)(`span`,{className:`admin-badge success`,children:`248`})]}),(0,o.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,o.jsx)(lw,{style:{fontSize:13},children:`Rejected`}),(0,o.jsx)(`span`,{className:`admin-badge danger`,children:`89`})]})]})]})]}),(0,o.jsxs)(`div`,{className:`admin-dashboard-bottom-row`,children:[(0,o.jsx)(Z,{icon:(0,o.jsx)(a.BankOutlined,{}),title:`Top Clients`,extra:(0,o.jsx)(i.Button,{type:`link`,size:`small`,children:`View all`}),children:pw.map(e=>(0,o.jsxs)(`div`,{className:`admin-client-row`,children:[(0,o.jsxs)(`div`,{className:`admin-client-left`,children:[(0,o.jsx)(`div`,{className:`admin-client-icon`,children:(0,o.jsx)(a.BankOutlined,{})}),(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`div`,{className:`admin-client-name`,children:e.name}),(0,o.jsxs)(`div`,{className:`admin-client-sub`,children:[e.jobs,` open jobs`]})]})]}),(0,o.jsxs)(`div`,{className:`admin-client-right`,children:[(0,o.jsx)(`div`,{className:`admin-client-val`,children:e.candidates}),(0,o.jsx)(`div`,{className:`admin-client-sub`,children:`candidates`})]})]},e.name))}),(0,o.jsx)(Z,{icon:(0,o.jsx)(a.BellOutlined,{}),title:`Recent Activity`,children:mw.map((e,t)=>(0,o.jsxs)(`div`,{className:`admin-activity-row`,children:[(0,o.jsx)(`div`,{className:`admin-activity-dot`,style:{background:e.color}}),(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`div`,{className:`admin-activity-text`,children:e.text}),(0,o.jsx)(`div`,{className:`admin-activity-time`,children:e.time})]})]},t))})]}),(0,o.jsx)(Z,{icon:(0,o.jsx)(a.SettingOutlined,{}),title:`Admin Configuration Overview`,extra:(0,o.jsx)(i.Button,{type:`link`,size:`small`,children:`Manage`}),children:(0,o.jsxs)(i.Row,{gutter:[24,0],children:[(0,o.jsxs)(i.Col,{span:8,children:[(0,o.jsx)(lw,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`Settings`}),[[`Organization`,2],[`User Settings`,4],[`Templates`,2]].map(([e,t])=>(0,o.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,o.jsx)(lw,{style:{fontSize:12},children:e}),(0,o.jsxs)(`span`,{className:`admin-badge info`,children:[t,` items`]})]},e))]}),(0,o.jsxs)(i.Col,{span:8,children:[(0,o.jsx)(lw,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`Master`}),[[`Jobs`,2],[`Candidates`,3],[`Submissions`,2]].map(([e,t])=>(0,o.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,o.jsx)(lw,{style:{fontSize:12},children:e}),(0,o.jsxs)(`span`,{className:`admin-badge info`,children:[t,` items`]})]},e))]}),(0,o.jsxs)(i.Col,{span:8,children:[(0,o.jsx)(lw,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`System`}),[[`Total Groups`,4],[`Total Modules`,9],[`Config Items`,19]].map(([e,t])=>(0,o.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,o.jsx)(lw,{style:{fontSize:12},children:e}),(0,o.jsx)(lw,{strong:!0,style:{fontSize:12},children:t})]},e))]})]})})]})}function gw({activeSection:e,activeGroup:t,filteredCards:n,searchText:r,setSearchText:s,allItems:c,handleNav:l}){return(0,o.jsxs)(i.Row,{gutter:[16,16],children:[(0,o.jsx)(i.Col,{span:24,children:(0,o.jsxs)(Z,{icon:e?.icon,title:e?.heading,extra:(0,o.jsx)(i.Input,{className:`admin-search`,prefix:(0,o.jsx)(a.SearchOutlined,{}),placeholder:`Search settings…`,allowClear:!0,value:r,onChange:e=>s(e.target.value)}),children:[(0,o.jsx)(`div`,{className:`admin-accent-bar`}),(0,o.jsx)(uw,{level:5,children:e?.heading}),(0,o.jsx)(lw,{type:`secondary`,children:e?.desc})]})}),(0,o.jsx)(i.Col,{xs:24,xl:16,style:{alignSelf:`flex-start`},children:(0,o.jsx)(Z,{icon:(0,o.jsx)(a.AppstoreOutlined,{}),title:`Configuration Items`,extra:(0,o.jsxs)(lw,{type:`secondary`,children:[n.length,` item`,n.length===1?``:`s`]}),children:(0,o.jsx)(i.Row,{gutter:[14,14],children:n.length>0?n.map(e=>(0,o.jsx)(i.Col,{xs:24,sm:12,xl:8,children:(0,o.jsxs)(`div`,{className:`admin-config-item`,children:[(0,o.jsx)(`div`,{className:`admin-config-top-bar`}),(0,o.jsxs)(`div`,{className:`admin-config-body`,children:[(0,o.jsx)(`div`,{className:`admin-config-icon`,children:e.icon}),(0,o.jsxs)(`div`,{className:`admin-config-text`,children:[(0,o.jsx)(`span`,{className:`admin-config-label`,children:e.label}),(0,o.jsx)(`span`,{className:`admin-config-desc`,children:e.desc})]})]}),(0,o.jsx)(`div`,{className:`admin-config-divider`}),(0,o.jsx)(i.Button,{type:`link`,size:`small`,className:`admin-config-manage`,icon:(0,o.jsx)(a.RightOutlined,{}),iconPosition:`end`,children:`Manage`})]})},e.label)):(0,o.jsx)(i.Col,{span:24,children:(0,o.jsx)(`div`,{className:`admin-config-empty`,children:(0,o.jsx)(i.Empty,{description:`No settings found`,image:i.Empty.PRESENTED_IMAGE_SIMPLE})})})})})}),(0,o.jsx)(i.Col,{xs:24,xl:8,style:{alignSelf:`flex-start`},children:(0,o.jsxs)(Z,{icon:(0,o.jsx)(a.FileTextOutlined,{}),title:`Section Overview`,children:[(0,o.jsx)(`div`,{className:`admin-overview-list`,children:dw.filter(e=>e.group!==`Dashboard`).map(e=>{let n=e.group===t?.group;return(0,o.jsxs)(`div`,{className:`admin-overview-item${n?` active`:``}`,onClick:()=>{let t=e.items[0];t&&l(t.id)},children:[(0,o.jsxs)(`div`,{className:`admin-overview-left`,children:[(0,o.jsx)(`div`,{className:`admin-overview-icon`,children:e.items[0]?.icon}),(0,o.jsxs)(`div`,{className:`admin-overview-text`,children:[(0,o.jsx)(`span`,{className:`admin-overview-name`,children:e.group}),(0,o.jsxs)(`span`,{className:`admin-overview-sub`,children:[e.items.length,` module`,e.items.length===1?``:`s`]})]})]}),(0,o.jsx)(`span`,{className:`admin-overview-count${n?` active`:``}`,children:e.items.length})]},e.group)})}),(0,o.jsxs)(`div`,{className:`admin-overview-footer`,children:[(0,o.jsx)(`span`,{className:`admin-overview-footer-label`,children:`Total configuration items`}),(0,o.jsx)(`span`,{className:`admin-overview-footer-value`,children:c.filter(e=>e.cards).reduce((e,t)=>e+t.cards.length,0)})]})]})})]})}function _w(){let[e,t]=(0,r.useState)(`dashboard`),[n,s]=(0,r.useState)(``),c=(0,r.useMemo)(()=>dw.flatMap(e=>e.items),[]),l=(0,r.useMemo)(()=>c.find(t=>t.id===e),[c,e]),u=(0,r.useMemo)(()=>dw.find(t=>t.items.some(t=>t.id===e)),[e]),d=(0,r.useMemo)(()=>{if(!l?.cards)return[];let e=n.trim().toLowerCase();return e?l.cards.filter(t=>t.label.toLowerCase().includes(e)||t.desc.toLowerCase().includes(e)):l.cards},[l,n]),f=(0,r.useMemo)(()=>dw.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),s(``)};return e===`dashboard`||l?.heading,(0,o.jsxs)(`main`,{className:`admin-page`,children:[(0,o.jsx)(`div`,{className:`admin-breadcrumb`,children:(0,o.jsx)(i.Breadcrumb,{items:[{title:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(a.HomeOutlined,{}),` Home`]})},{title:`Admin`}]})}),(0,o.jsxs)(i.Row,{gutter:[16,16],className:`admin-wrapper`,children:[(0,o.jsx)(i.Col,{xs:24,lg:6,xl:5,children:(0,o.jsxs)(Z,{title:`Admin Console`,icon:(0,o.jsx)(a.SettingOutlined,{}),children:[(0,o.jsxs)(`div`,{className:`admin-sidebar-banner`,children:[(0,o.jsx)(`span`,{className:`admin-sidebar-banner-title`,children:`Admin Panel`}),(0,o.jsx)(`span`,{className:`admin-sidebar-banner-sub`,children:`Configuration Center`}),(0,o.jsxs)(i.Row,{gutter:[8,0],children:[(0,o.jsx)(i.Col,{span:12,children:(0,o.jsxs)(`div`,{className:`admin-sidebar-pill`,children:[(0,o.jsx)(`span`,{className:`admin-sidebar-pill-label`,children:`Groups`}),(0,o.jsx)(`span`,{className:`admin-sidebar-pill-value`,children:dw.length})]})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsxs)(`div`,{className:`admin-sidebar-pill`,children:[(0,o.jsx)(`span`,{className:`admin-sidebar-pill-label`,children:`Modules`}),(0,o.jsx)(`span`,{className:`admin-sidebar-pill-value`,children:c.length})]})})]})]}),(0,o.jsx)(i.Menu,{mode:`inline`,selectedKeys:[e],items:f,onClick:({key:e})=>p(e),className:`admin-sidebar-menu`})]})}),(0,o.jsx)(i.Col,{xs:24,lg:18,xl:19,children:e===`dashboard`?(0,o.jsx)(hw,{}):l?.component===`form-groups`?(0,o.jsx)(x_,{}):l?.component===`detail-groups`?(0,o.jsx)(W_,{}):l?.component===`row-actions`?(0,o.jsx)(Mv,{}):l?.component===`users`?(0,o.jsx)(OC,{}):l?.component===`teams`?(0,o.jsx)(PC,{}):l?.component===`roles`?(0,o.jsx)(ZC,{}):l?.component===`permissions`?(0,o.jsx)(iw,{}):l?.component===`templates`?(0,o.jsx)(Vv,{}):l?.component===`ai-services`?(0,o.jsx)(Gv,{}):l?.component===`bgc-integration`?(0,o.jsx)(Zv,{}):(0,o.jsx)(gw,{activeSection:l,activeGroup:u,filteredCards:d,searchText:n,setSearchText:s,allItems:c,handleNav:p})})]})]})}var{Title:vw}=i.Typography;function yw(){let e=(0,s.useNavigate)(),{state:t}=(0,s.useLocation)(),n=t?.moduleName||`stickyNotes`,r=t?.title||`Sticky Notes`,c={...t?.request,params:{...t?.request?.params,limit:200,offset:0}};return(0,o.jsxs)(`div`,{children:[(0,o.jsx)(i.Button,{type:`text`,icon:(0,o.jsx)(a.ArrowLeftOutlined,{}),onClick:()=>e(-1),style:{marginBottom:12},children:`Back`}),(0,o.jsx)(bt,{moduleName:n,title:r,columns:4,request:c,viewAll:!1})]})}var{Text:bw,Title:xw}=i.Typography,Sw=10*1024*1024,Cw=`/templates/test_cases_flow_template.base64.txt`,ww=`test_cases_flow_template.xlsx`,Tw=`module | subModule | step_order | description | actions | key | value | expected | scenario`,Ew={idle:0,module_set:1,encoding:1,validating:2,preview:3,inserting:3,done:4,error:1},Dw=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Bulk upload`,href:`/bulk-upload`}];function Ow(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 kw(e){return e.filter(e=>e.row_status===`valid`).map(e=>{let t={...e};return delete t.row_status,delete t.errors,t})}function Aw(e){return e.flatMap(e=>(e.errors??[]).map(t=>({id:e.id,...t})))}function jw({errors:e}){return(0,o.jsx)(`div`,{className:`bulk-tooltip-errors`,children:(e??[]).map((e,t)=>(0,o.jsx)(`div`,{children:e.message},`${e.field}-${t}`))})}function Mw({errors:e,expanded:t,onToggle:n,onSummaryClick:r}){return e.length===0?null:(0,o.jsxs)(`div`,{className:`bulk-error-banner`,children:[(0,o.jsxs)(`div`,{className:`bulk-error-summary`,children:[(0,o.jsxs)(`button`,{type:`button`,className:`bulk-error-summary-main`,onClick:r,"aria-label":`Scroll to first invalid row`,children:[(0,o.jsx)(a.ExclamationCircleOutlined,{className:`bulk-error-icon`}),(0,o.jsxs)(`span`,{children:[e.length,` validation error(s) found`]})]}),(0,o.jsx)(i.Button,{type:`link`,onClick:n,"aria-expanded":t,children:t?`Hide Errors`:`View Errors`})]}),t&&(0,o.jsx)(`div`,{className:`bulk-error-list`,role:`region`,"aria-label":`Validation error details`,children:e.map((e,t)=>(0,o.jsxs)(`div`,{className:`bulk-error-line`,children:[(0,o.jsxs)(`span`,{className:`bulk-row-chip`,children:[`Row `,e.id]}),(0,o.jsx)(`span`,{children:e.message})]},`${e.id}-${e.field}-${t}`))})]})}function Nw({rows:e,view:t,onViewChange:n,onConfirm:r,onReset:s,saving:c,firstInvalidRowId:l,firstInvalidRowRef:u}){let d=e.filter(e=>e.row_status===`invalid`),f=t===`errors`?d:e,p=d.length>0||c;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(i.Row,{justify:`space-between`,align:`middle`,gutter:[16,16],className:`bulk-table-toolbar`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsxs)(i.Space.Compact,{children:[(0,o.jsx)(i.Button,{type:t===`all`?`primary`:`default`,onClick:()=>n(`all`),children:`All rows`}),(0,o.jsx)(i.Button,{type:t===`errors`?`primary`:`default`,onClick:()=>n(`errors`),children:`Errors only`})]})}),(0,o.jsx)(i.Col,{children:(0,o.jsxs)(bw,{type:`secondary`,children:[e.length,` row(s)`]})})]}),(0,o.jsx)(`div`,{className:`bulk-table-wrap`,children:(0,o.jsxs)(`table`,{className:`bulk-preview-table`,children:[(0,o.jsx)(`thead`,{children:(0,o.jsxs)(`tr`,{children:[(0,o.jsx)(`th`,{className:`bulk-col-row`,children:`Row`}),(0,o.jsx)(`th`,{className:`bulk-col-flow`,children:`Submodule`}),(0,o.jsx)(`th`,{className:`bulk-col-description`,children:`Description`}),(0,o.jsx)(`th`,{className:`bulk-col-keyword`,children:`Action`}),(0,o.jsx)(`th`,{className:`bulk-col-target`,children:`Key`}),(0,o.jsx)(`th`,{className:`bulk-col-status`,children:`Status`}),(0,o.jsx)(`th`,{className:`bulk-col-error`,children:`Error`})]})}),(0,o.jsx)(`tbody`,{children:f.map(e=>{let t=e.errors??[],n=e.row_status===`invalid`;return(0,o.jsxs)(`tr`,{ref:n&&e.id===l?u:null,className:n?`bulk-row-invalid`:``,children:[(0,o.jsx)(`td`,{children:e.id}),(0,o.jsx)(`td`,{title:e.submodule,children:e.submodule}),(0,o.jsx)(`td`,{title:e.description,children:e.description?e.description:(0,o.jsx)(`span`,{className:`bulk-empty-text`,children:`-empty-`})}),(0,o.jsx)(`td`,{children:(0,o.jsx)(`code`,{className:`bulk-code-chip`,children:e.actions})}),(0,o.jsx)(`td`,{title:e.key,children:e.key}),(0,o.jsx)(`td`,{children:n?(0,o.jsx)(i.Tag,{color:`red`,children:`Error`}):(0,o.jsx)(i.Tag,{color:`green`,children:`Valid`})}),(0,o.jsx)(`td`,{children:n?(0,o.jsx)(i.Tooltip,{title:(0,o.jsx)(jw,{errors:t}),placement:`left`,children:(0,o.jsxs)(`button`,{type:`button`,className:`bulk-error-info`,"aria-label":`View ${t.length} error(s) for row ${e.id}`,children:[(0,o.jsx)(a.InfoCircleOutlined,{}),(0,o.jsx)(i.Badge,{count:t.length,size:`small`})]})}):(0,o.jsx)(`span`,{className:`bulk-error-none`,children:`-`})})]},`${e.id}-${e.step_order}`)})})]})}),(0,o.jsxs)(i.Space,{className:`bulk-actions`,children:[(0,o.jsx)(i.Button,{icon:(0,o.jsx)(a.ReloadOutlined,{}),onClick:s,children:`Reset`}),(0,o.jsx)(i.Button,{type:`primary`,icon:(0,o.jsx)(a.SaveOutlined,{}),loading:c,disabled:p,onClick:r,children:d.length>0?`Fix ${d.length} error(s) to proceed`:`Save to database`})]})]})}function Pw(){let n=(0,s.useNavigate)(),c=(0,r.useMemo)(()=>t.c(),[]),l=(0,r.useRef)(null),u=(0,r.useRef)(null),[d,f]=(0,r.useState)([]),[p,m]=(0,r.useState)(``),[h,g]=(0,r.useState)(`idle`),[_,v]=(0,r.useState)(!1),[y,b]=(0,r.useState)(null),[x,S]=(0,r.useState)([]),[C,w]=(0,r.useState)(`all`),[T,E]=(0,r.useState)(null),[D,O]=(0,r.useState)(null),[k,A]=(0,r.useState)(!1),j=d.map(e=>({value:e.modulename,label:e.modulename})),M=Aw(x),N=h===`encoding`||h===`validating`,P=!!p&&!N,F=Ew[h]??0,I=x.find(e=>e.row_status===`invalid`)?.id,L=(0,r.useCallback)(()=>{m(``),g(`idle`),v(!1),b(null),S([]),w(`all`),E(null),O(null),l.current&&(l.current.value=``)},[]);(0,r.useEffect)(()=>{async function e(){try{f((await vh({project:c?.name??``,activeOnly:!0}))?.items??[])}catch(e){console.error(e),i.message.error(`Unable to load modules.`)}}e()},[c?.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>Sw){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 Ow(e);g(`validating`),S((await ph({filename:e.name,project:c?.name??``,module:p,file_base64:n,file_type:t}))?.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(Cw);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 a=new Blob([r],{type:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`}),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=ww,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o),i.message.success(`Sample template downloaded.`)}catch(e){console.error(e),i.message.error(`Unable to download sample template.`)}},ee=async()=>{g(`inserting`),E(null);try{O(await mh({project:c?.name??``,module:p,uploaded_by:localStorage.getItem(`user_Email`)??``,rows:kw(x)})),g(`done`),i.message.success(`Bulk upload saved. Redirecting to view test cases...`),window.setTimeout(()=>n(`/viewTestCase`),900)}catch(e){console.error(e),E(e.payload??{code:`NETWORK_ERROR`,message:e.message||`Could not reach the server.`}),g(`preview`)}},te=(0,r.useCallback)(()=>{u.current?.scrollIntoView({behavior:`smooth`,block:`center`})},[]),V=[`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,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:Dw})}),c?.name&&(0,o.jsx)(i.Col,{children:(0,o.jsx)(bw,{strong:!0,children:c.name})})]}),(0,o.jsxs)(`div`,{className:`zt-page zt-page-wide bulk-page`,children:[(0,o.jsxs)(`div`,{className:`bulk-header`,children:[(0,o.jsx)(xw,{level:3,children:`Bulk upload test cases`}),(0,o.jsxs)(i.Space,{direction:`vertical`,size:4,children:[(0,o.jsx)(bw,{type:`secondary`,children:Tw}),(0,o.jsx)(bw,{type:`secondary`,children:`Use the sample template for the required columns. Uploaded rows are saved as Active by default.`})]})]}),(0,o.jsx)(`div`,{className:`bulk-stepbar`,children:[`Select`,`Upload`,`Validate`,`Save`].map((e,t)=>(0,o.jsxs)(`span`,{className:t<F?`bulk-step-active`:``,children:[t+1,` `,e]},e))}),(0,o.jsx)(i.Card,{className:`v1-card zt-fall`,title:`1. Module selector`,children:(0,o.jsx)(i.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,o.jsxs)(i.Card,{className:`v1-card zt-fall`,title:`2. File upload`,extra:(0,o.jsx)(i.Button,{icon:(0,o.jsx)(a.DownloadOutlined,{}),onClick:B,children:`Download Sample Template`}),children:[(0,o.jsx)(i.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,o.jsxs)(`button`,{type:`button`,className:V,disabled:!P,onClick:()=>l.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,o.jsx)(a.CloudUploadOutlined,{className:`bulk-upload-icon`}),y?(0,o.jsxs)(`span`,{className:`bulk-file-chip`,children:[y.name,` - `,Math.ceil(y.size/1024),` KB`]}):(0,o.jsx)(`span`,{children:`Drag & drop here, or click to browse`})]}),(0,o.jsx)(`input`,{ref:l,hidden:!0,type:`file`,accept:`.xlsx,.csv`,onChange:e=>z(e.target.files?.[0])}),N&&(0,o.jsx)(i.Progress,{percent:h===`encoding`?45:82,showInfo:!1,size:`small`}),T&&h!==`preview`&&(0,o.jsx)(i.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`})]}),x.length>0&&(0,o.jsxs)(i.Card,{className:`v1-card zt-fall`,title:`3. Validation result`,children:[(0,o.jsx)(Mw,{errors:M,expanded:k,onToggle:()=>A(e=>!e),onSummaryClick:te}),T&&h===`preview`&&(0,o.jsx)(i.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`}),(0,o.jsx)(Nw,{rows:x,view:C,onViewChange:w,onConfirm:ee,onReset:L,saving:h===`inserting`,firstInvalidRowId:I,firstInvalidRowRef:u})]}),D&&h===`done`&&(0,o.jsxs)(i.Card,{className:`v1-card zt-fall`,title:`4. Upload complete`,children:[(0,o.jsxs)(i.Row,{gutter:[16,16],className:`bulk-metrics`,children:[(0,o.jsx)(i.Col,{xs:24,md:8,children:(0,o.jsxs)(`div`,{children:[(0,o.jsx)(bw,{children:`Total`}),(0,o.jsx)(`strong`,{children:x.length})]})}),(0,o.jsx)(i.Col,{xs:24,md:8,children:(0,o.jsxs)(`div`,{children:[(0,o.jsx)(bw,{children:`Inserted`}),(0,o.jsx)(`strong`,{children:D.inserted??0})]})}),(0,o.jsx)(i.Col,{xs:24,md:8,children:(0,o.jsxs)(`div`,{children:[(0,o.jsx)(bw,{children:`Failed`}),(0,o.jsx)(`strong`,{children:D.failed??0})]})})]}),(0,o.jsx)(i.Alert,{type:`success`,showIcon:!0,icon:(0,o.jsx)(a.CheckCircleOutlined,{}),message:`${D.inserted??0} test cases saved to database - module: ${p}`,className:`bulk-inline-alert`}),(0,o.jsx)(i.Button,{icon:(0,o.jsx)(a.ReloadOutlined,{}),onClick:L,children:`Upload another file`})]})]})]})}var Fw=[{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:Iw}=i.Typography,Lw=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}],Rw={tags:`regression`,active:1},zw={module:{dbName:`Modules`,formField:`module`,label:`Module`}};function Bw(e=[]){return e.map(e=>({value:e,label:e}))}function Vw(e=``){return String(e??``).trim()}function Hw(e=``){return Vw(e).toLowerCase()}function Uw(e=[]){let t=new Map;return e.forEach(e=>{let n=Vw(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function Ww(e=[],t,n){let r=Vw(t).toLowerCase(),i=Vw(n).toLowerCase();return e.reduce((e,t)=>{let n=Vw(t?.module).toLowerCase(),a=Vw(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 Gw({icon:e,title:t}){return(0,o.jsxs)(i.Space,{size:10,align:`center`,children:[(0,o.jsx)(`div`,{className:`v1-section-icon-box`,children:e}),(0,o.jsx)(Iw,{strong:!0,className:`v1-section-label`,children:t})]})}function Kw(){let[t]=i.Form.useForm(),[n]=i.Form.useForm(),[c,l]=(0,r.useState)([]),[u,d]=(0,r.useState)([]),[f,p]=(0,r.useState)([]),[m,h]=(0,r.useState)(!1),[g,_]=(0,r.useState)(!1),[v,y]=(0,r.useState)({open:!1,typeKey:`module`}),[b,x]=(0,r.useState)(!1),[S,C]=(0,r.useState)(!1),[w,T]=(0,r.useState)(!1),E=(0,s.useNavigate)(),D=zw[v.typeKey],O=(0,r.useMemo)(()=>Bw(c),[c]),k=i.Form.useWatch(`module`,t),A=i.Form.useWatch(`flow`,t),j=!!Vw(k),M=!!Vw(A),N=!j,P=!j||!M,F=(e,t=[])=>{e===`module`&&l(t)},I=async()=>{h(!0);try{l((await ch(zw.module.dbName))?.items??[])}catch(e){console.error(`Unable to load testing options:`,e),i.message.error(`Unable to load testing options.`)}finally{h(!1)}},L=(0,r.useCallback)(async e=>{let n=Vw(e);if(d([]),p([]),t.setFieldsValue({step_order:void 0}),n){_(!0);try{let e=await fh({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];d(t),p(Uw(t))}catch(e){console.error(`Unable to load flows:`,e),i.message.error(`Unable to load flows.`)}finally{_(!1)}}},[t]),R=(0,r.useCallback)(async(e,n,r)=>{let a=Vw(e),o=Vw(n);if(!a||!o){t.setFieldsValue({step_order:void 0});return}C(!0);try{t.setFieldsValue({step_order:Ww(r,a,o)})}catch(e){console.error(`Unable to load step order:`,e),i.message.error(`Unable to load step order.`)}finally{C(!1)}},[t]);(0,r.useEffect)(()=>{Promise.resolve().then(I)},[]),(0,r.useEffect)(()=>{Promise.resolve().then(()=>L(k))},[L,k]),(0,r.useEffect)(()=>{Promise.resolve().then(()=>R(k,A,u))},[u,R,A,k]);let z=async e=>{let n={module:Vw(e.module),flow:Vw(e.flow),step_order:Number(e.step_order),description:Vw(e.description),keyword:Hw(e.keyword),target:Vw(e.target),value:Vw(e.value),expected:Vw(e.expected),tags:e.tags?Vw(e.tags):Rw.tags,active:Number(e.active)};T(!0);try{await dh(n),i.message.success(`Test case details saved successfully.`),t.resetFields(),d([]),p([])}catch(e){console.error(`Unable to save test case:`,e),i.message.error(`Unable to save test case.`)}finally{T(!1)}},B=(e,n)=>{t.setFieldsValue({[e]:Vw(n)})},ee=e=>{t.setFieldsValue({module:Vw(e),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:Rw.tags,value:void 0,expected:void 0})},te=e=>{t.setFieldsValue({flow:Vw(e),step_order:void 0})},V=e=>{let t=zw[e];y({open:!0,typeKey:e}),n.setFieldsValue({name:``,type:t.label})},ne=()=>{y(e=>({...e,open:!1})),n.resetFields()},re=async()=>{try{let e=Vw((await n.validateFields()).name),r=await lh({name:e,type:D.dbName});F(v.typeKey,r?.items??[]),t.setFieldsValue({[D.formField]:e}),i.message.success(`${D.label} added successfully.`),ne()}catch(e){if(e?.errorFields)return;console.error(`Unable to save testing option:`,e),i.message.error(`Unable to add ${D.label.toLowerCase()}.`)}finally{x(!1)}};return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:Lw})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`link`,onClick:()=>E(`/zinnext-home`),children:`View Table`})})]}),(0,o.jsx)(`div`,{className:`v1-page`,children:(0,o.jsxs)(`div`,{className:`v1-page-inner`,children:[(0,o.jsx)(`div`,{className:`v1-page-header`,children:(0,o.jsxs)(i.Space,{align:`center`,size:10,children:[(0,o.jsx)(a.ProfileOutlined,{className:`v1-outer-icon`}),(0,o.jsx)(`div`,{children:(0,o.jsx)(Iw,{strong:!0,style:{fontSize:16},children:`Add Test Case`})})]})}),(0,o.jsx)(Z,{children:(0,o.jsxs)(i.Form,{form:t,className:`v1-form`,layout:`vertical`,colon:!1,requiredMark:(e,{required:t})=>(0,o.jsxs)(o.Fragment,{children:[e,t&&(0,o.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),initialValues:Rw,onFinish:z,autoComplete:`off`,children:[(0,o.jsx)(i.Card,{className:`v1-card`,title:(0,o.jsx)(Gw,{icon:(0,o.jsx)(a.FileTextOutlined,{}),title:`Test Case Details`}),extra:(0,o.jsx)(Iw,{type:`secondary`,className:`v1-card-subtitle`,children:`Module, flow, step order and execution data`}),children:(0,o.jsxs)(i.Row,{gutter:[24,0],children:[(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsxs)(i.Space.Compact,{style:{width:`100%`},children:[(0,o.jsx)(i.Form.Item,{label:`Module`,name:`module`,style:{flex:1},children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,loading:m,optionFilterProp:`label`,placeholder:`Select module`,options:O,onChange:ee})}),(0,o.jsx)(i.Button,{"aria-label":`Add module`,icon:(0,o.jsx)(a.PlusOutlined,{}),style:{marginTop:30},onClick:()=>V(`module`)})]})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Flow`,name:`flow`,children:(0,o.jsx)(i.AutoComplete,{maxLength:100,allowClear:!0,disabled:N,options:f,placeholder:g?`Loading flows`:`Enter flow`,onChange:te,filterOption:(e,t)=>t?.value?.toLowerCase().includes(e.toLowerCase())})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Step Order`,name:`step_order`,validateTrigger:[`onBlur`,`onChange`],children:(0,o.jsx)(i.Input,{maxLength:10,disabled:!0,placeholder:S?`Loading step order`:`Step order`})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Action`,name:`keyword`,children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,disabled:P,optionFilterProp:`label`,placeholder:`Select action`,options:Fw,onChange:e=>t.setFieldsValue({keyword:Hw(e)})})})}),(0,o.jsx)(i.Col,{xs:24,children:(0,o.jsx)(i.Form.Item,{label:`Description`,name:`description`,children:(0,o.jsx)(i.Input.TextArea,{rows:3,maxLength:255,disabled:P,placeholder:`Enter description`,showCount:!0,onBlur:e=>B(`description`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Key`,name:`target`,children:(0,o.jsx)(i.Input,{maxLength:255,disabled:P,placeholder:`Enter target`,onBlur:e=>B(`target`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Tags`,name:`tags`,children:(0,o.jsx)(i.Input,{maxLength:200,disabled:P,placeholder:`Enter tags`,prefix:(0,o.jsx)(a.TagsOutlined,{className:`v1-input-icon`}),onBlur:e=>B(`tags`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Value`,name:`value`,children:(0,o.jsx)(i.Input.TextArea,{rows:4,disabled:P,placeholder:`Enter value`,onBlur:e=>B(`value`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Expected`,name:`expected`,children:(0,o.jsx)(i.Input.TextArea,{rows:4,disabled:P,placeholder:`Enter expected result`,onBlur:e=>B(`expected`,e.target.value)})})})]})}),(0,o.jsx)(`div`,{className:`v1-form-actions`,children:(0,o.jsx)(i.Form.Item,{children:(0,o.jsxs)(i.Space,{children:[(0,o.jsx)(i.Button,{type:`primary`,htmlType:`submit`,loading:w,disabled:P,children:`Submit`}),(0,o.jsx)(i.Button,{onClick:()=>{t.resetFields(),d([]),p([])},children:`Reset`})]})})})]})}),(0,o.jsx)(i.Modal,{title:`Add ${D.label}`,open:v.open,confirmLoading:b,okText:`Add`,onCancel:ne,onOk:()=>{x(!0),re()},destroyOnHidden:!0,children:(0,o.jsxs)(i.Form,{form:n,layout:`vertical`,colon:!1,className:`v1-form`,requiredMark:(e,{required:t})=>(0,o.jsxs)(o.Fragment,{children:[e,t&&(0,o.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),children:[(0,o.jsx)(i.Form.Item,{label:`Name`,name:`name`,children:(0,o.jsx)(i.Input,{maxLength:100,placeholder:`Enter ${D.label.toLowerCase()} name`,onBlur:e=>{n.setFieldsValue({name:Vw(e.target.value)})}})}),(0,o.jsx)(i.Form.Item,{label:`Type`,name:`type`,children:(0,o.jsx)(i.Input,{disabled:!0})})]})})]})})]})}var{Text:qw}=i.Typography,Jw=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`}];function Yw(e=``){return String(e??``).trim()}function Xw(e=[],t){return e.map(e=>({value:e.id,label:e[t]}))}var Zw=[{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,o.jsx)(i.Tag,{color:`green`,children:`Positive`}):(0,o.jsx)(i.Tag,{color:`red`,children:`Negative`})}],Qw={key:!1,value:!1,expected:!1};function $w(e,t){return t?e[t]??Qw:Qw}function eT(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function tT(){let[n]=i.Form.useForm(),c=(0,s.useNavigate)(),[l]=(0,s.useSearchParams)(),u=l.get(`edit`),d=!!u,f=(0,r.useMemo)(()=>t.c(),[]),[p,m]=(0,r.useState)([]),[h,g]=(0,r.useState)([]),[_,v]=(0,r.useState)([]),[y,b]=(0,r.useState)(Fw),[x,S]=(0,r.useState)({}),[C,w]=(0,r.useState)(!1),[T,E]=(0,r.useState)(!1),[D,O]=(0,r.useState)(!1),[k,A]=(0,r.useState)(!1),[j,M]=(0,r.useState)(!1),N=i.Form.useWatch(`module`,n),P=i.Form.useWatch(`submodule`,n),F=i.Form.useWatch(`actions`,n),I=!!N,L=!!P,R=(0,r.useMemo)(()=>$w(x,F),[x,F]),z=(0,r.useMemo)(()=>Xw(p,`modulename`),[p]),B=(0,r.useMemo)(()=>Xw(h,`submodulename`),[h]),ee=(0,r.useMemo)(()=>p.find(e=>e.id===N)?.modulename??``,[p,N]),te=(0,r.useMemo)(()=>h.find(e=>e.id===P)?.submodulename??``,[P,h]),V=(0,r.useCallback)(async()=>{try{let e=await uh();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),i.message.error(`Unable to load action validation rules.`)}},[]),ne=(0,r.useCallback)(async e=>{if(!e){m([]);return}w(!0);try{m((await vh({project:e,activeOnly:!0}))?.items??[])}catch(e){console.error(`Unable to load modules:`,e),i.message.error(`Unable to load modules.`)}finally{w(!1)}},[]),re=(0,r.useCallback)(async(e,t)=>{if(!e||!t){g([]);return}E(!0);try{g((await xh({project:e,module:t,activeOnly:!0}))?.items??[])}catch(e){console.error(`Unable to load submodules:`,e),i.message.error(`Unable to load submodules.`)}finally{E(!1)}},[]),H=(0,r.useCallback)(async(e,t,r,a=``)=>{if(!e||!t||!r){v([]),n.setFieldsValue({step_order:void 0});return}O(!0);try{let[i,o]=await Promise.all([wh({product_parent_ID:e,module_parent_ID:t,submodule_parent_ID:r,actions:a,limit:1e3}),Dh({product_parent_ID:e,module_parent_ID:t,submodule_parent_ID:r})]);v(i?.items??[]),n.setFieldsValue({step_order:o?.step_order??1})}catch(e){console.error(`Unable to load flows:`,e),i.message.error(`Unable to load flows.`)}finally{O(!1)}},[n]),U=(0,r.useCallback)(async(e=``)=>{if(!(!f?.id||!N||!P)){O(!0);try{v((await wh({product_parent_ID:f.id,module_parent_ID:N,submodule_parent_ID:P,actions:e,limit:1e3}))?.items??[])}catch(e){console.error(`Unable to load action flows:`,e),i.message.error(`Unable to load action steps.`)}finally{O(!1)}}},[f?.id,N,P]),W=(0,r.useCallback)(async()=>{if(!(!u||!f?.name)){M(!0);try{let e=await Eh(u);await re(f.name,e.module),v((await wh({product_parent_ID:e.product_parent_ID,module_parent_ID:e.module_parent_ID,submodule_parent_ID:e.submodule_parent_ID,limit:1e3}))?.items??[]),n.setFieldsValue({module:e.module_parent_ID,submodule:e.submodule_parent_ID,step_order:e.step_order,actions:e.actions,key:e.key,value:e.value,expected:e.expected,description:e.description,scenario:e.scenario===1,active:Number(e.active)!==0})}catch(e){console.error(`Unable to load test flow:`,e),i.message.error(`Unable to load test flow for edit.`),c(`/viewTestCase`)}finally{M(!1)}}},[u,n,re,c,f?.name]);return(0,r.useEffect)(()=>{if(!f){c(`/select-project`,{replace:!0});return}Promise.resolve().then(async()=>{await V(),await ne(f.name),u&&await W()})},[f,c,V,ne,u,W]),f?(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:Jw})}),(0,o.jsx)(i.Col,{children:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.ProjectOutlined,{}),(0,o.jsx)(qw,{strong:!0,children:f.name})]})})]}),(0,o.jsx)(`div`,{className:`zt-page`,children:(0,o.jsxs)(i.Form,{form:n,layout:`vertical`,colon:!1,className:`v1-form`,initialValues:{scenario:!0,active:!0},onFinish:async e=>{let t={product_parent_ID:Number(f?.id),module_parent_ID:Number(e.module),submodule_parent_ID:Number(e.submodule),description:Yw(e.description),actions:Yw(e.actions),key:Yw(e.key),value:Yw(e.value),expected:Yw(e.expected),scenario:+!!e.scenario,active:+!!e.active};A(!0);try{if(d){await Oh(u,{...t,step_order:Number(e.step_order)}),i.message.success(`Test case updated successfully.`),c(`/viewTestCase`);return}await Th(t),i.message.success(`Step saved (#${e.step_order}).`),n.setFieldsValue({actions:void 0,key:void 0,value:void 0,expected:void 0,description:void 0}),await H(t.product_parent_ID,t.module_parent_ID,t.submodule_parent_ID)}catch(e){console.error(`Unable to save test case:`,e),i.message.error(d?`Unable to update test case.`:`Unable to save step.`)}finally{A(!1)}},autoComplete:`off`,disabled:j,children:[(0,o.jsx)(i.Card,{className:`v1-card zt-fall`,title:(0,o.jsxs)(i.Space,{size:8,className:`zt-section-title`,children:[(0,o.jsx)(`span`,{className:`zt-step-tag`,children:`1`}),(0,o.jsx)(`span`,{children:`Module & Submodule`})]}),children:(0,o.jsxs)(i.Row,{gutter:[24,0],align:`bottom`,children:[(0,o.jsx)(i.Col,{xs:24,md:6,children:(0,o.jsx)(i.Form.Item,{label:`Module`,name:`module`,children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,loading:C,placeholder:`Select module`,options:z,onChange:e=>{let t=p.find(t=>t.id===e)?.modulename??``;n.setFieldsValue({module:e,submodule:void 0,step_order:void 0,actions:void 0,key:void 0,value:void 0,expected:void 0}),eT(n,[`actions`,`key`,`value`,`expected`]),g([]),v([]),re(f?.name,t)}})})}),(0,o.jsx)(i.Col,{xs:24,md:6,children:(0,o.jsx)(i.Form.Item,{label:`Submodule`,name:`submodule`,children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,disabled:!I,loading:T,placeholder:I?`Select submodule`:`Select module first`,options:B,onChange:e=>{n.setFieldsValue({submodule:e,actions:void 0,key:void 0,value:void 0,expected:void 0}),eT(n,[`actions`,`key`,`value`,`expected`]),H(f?.id,N,e)}})})}),(0,o.jsx)(i.Col,{xs:24,md:6,children:(0,o.jsx)(i.Form.Item,{label:`Scenario`,name:`scenario`,valuePropName:`checked`,children:(0,o.jsx)(i.Switch,{disabled:!L,checkedChildren:`Positive`,unCheckedChildren:`Negative`})})}),(0,o.jsx)(i.Col,{xs:24,md:6,children:(0,o.jsx)(i.Form.Item,{label:`Active`,name:`active`,valuePropName:`checked`,children:(0,o.jsx)(i.Switch,{checkedChildren:`Active`,unCheckedChildren:`Inactive`})})})]})}),L&&(0,o.jsxs)(i.Card,{className:`v1-card zt-fall`,title:(0,o.jsxs)(i.Space,{size:8,className:`zt-section-title`,children:[(0,o.jsx)(`span`,{className:`zt-step-tag`,children:`2`}),(0,o.jsx)(a.FileTextOutlined,{}),(0,o.jsx)(`span`,{children:`Step Details`})]}),extra:(0,o.jsxs)(qw,{type:`secondary`,children:[ee,` / `,te]}),children:[(0,o.jsxs)(i.Row,{gutter:[24,0],children:[(0,o.jsx)(i.Col,{xs:24,md:6,children:(0,o.jsx)(i.Form.Item,{label:`Step Order`,name:`step_order`,children:(0,o.jsx)(i.Input,{disabled:!0,placeholder:D?`Loading…`:`Auto`})})}),(0,o.jsx)(i.Col,{xs:24,md:18,children:(0,o.jsx)(i.Form.Item,{label:`Action`,name:`actions`,rules:[{required:!0,message:`Mandatory Field`}],children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,placeholder:`Select action`,options:y,onChange:e=>{let t=$w(x,e);n.setFieldsValue({actions:e,key:t.key?n.getFieldValue(`key`):void 0,value:t.value?n.getFieldValue(`value`):void 0,expected:t.expected?n.getFieldValue(`expected`):void 0}),eT(n,[`key`,`value`,`expected`]),U(e||``)}})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Key`,name:`key`,rules:[{required:R.key,message:`Key is required for this action`}],children:(0,o.jsx)(i.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,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Value`,name:`value`,rules:[{required:R.value,message:`Value is required for this action`}],children:(0,o.jsx)(i.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,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Expected`,name:`expected`,rules:[{required:R.expected,message:`Expected result is required for this action`}],children:(0,o.jsx)(i.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,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Description`,name:`description`,children:(0,o.jsx)(i.Input.TextArea,{rows:2,maxLength:255,showCount:!0,placeholder:`Enter description`})})})]}),(0,o.jsxs)(i.Space,{className:`zt-actions`,children:[(0,o.jsx)(i.Button,{onClick:()=>{if(d){c(`/viewTestCase`);return}n.resetFields(),g([]),v([]),E(!1),O(!1)},children:`Cancel`}),(0,o.jsx)(i.Button,{type:`primary`,htmlType:`submit`,loading:k||j,children:d?`Update Test Case`:`Save & Continue`})]})]},`${N}-${P}`),L&&(0,o.jsx)(i.Card,{className:`v1-card zt-fall`,title:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.TableOutlined,{}),(0,o.jsx)(`span`,{children:`Added Steps`})]}),extra:(0,o.jsx)(i.Tag,{children:F?`${_.length} ${F} step(s)`:`${_.length} step(s)`}),children:(0,o.jsx)(hf,{listName:`Added Steps`,loading:D,fields:Zw,dataSource:_,current:1,pageSize:Math.max(_.length,1),total:_.length,rowSelection:!1,className:`zt-list-plain zt-list-static`})})]})})]}):null}var{Text:nT}=i.Typography,rT=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`}];function iT(){let n=(0,s.useNavigate)(),c=(0,r.useMemo)(()=>t.c(),[]),[l,u]=(0,r.useState)([]),[d,f]=(0,r.useState)({}),[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(!1),[_,v]=(0,r.useState)(``),[y,b]=(0,r.useState)(!1),[x,S]=(0,r.useState)(1),[C,w]=(0,r.useState)(10),T=(0,r.useCallback)(async e=>{if(!e){u([]);return}m(!0);try{let[t,n]=await Promise.all([vh({project:e}),xh({project:e})]);u(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),i.message.error(`Unable to load modules.`)}finally{m(!1)}},[]);(0,r.useEffect)(()=>{if(!c){n(`/select-project`,{replace:!0});return}Promise.resolve().then(()=>T(c.name))},[c,n,T]);let E=async(e,t)=>{try{await bh(e.id,+!!t),u(n=>n.map(n=>n.id===e.id?{...n,active:+!!t}:n)),i.message.success(`Module ${t?`activated`:`deactivated`}.`)}catch(e){console.error(e),i.message.error(`Unable to update module status.`)}},D=async()=>{let e=_.trim();if(!e){i.message.warning(`Enter a module name.`);return}b(!0);try{await yh({project:c.name,modulename:e}),i.message.success(`Module added.`),g(!1),v(``),S(1),T(c.name)}catch(e){console.error(e),i.message.error(`Unable to add module (maybe it already exists).`)}finally{b(!1)}},O=e=>{n(`/test-cases/zinnext/submodules?module=${encodeURIComponent(e.modulename)}`)};return c?(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:rT})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`link`,onClick:()=>n(`/addTestCase`),children:`Back to Form`})})]}),(0,o.jsxs)(`div`,{className:`zt-page`,children:[(0,o.jsx)(i.Card,{className:`v1-card zt-bar`,children:(0,o.jsxs)(i.Row,{gutter:[16,16],align:`middle`,justify:`space-between`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.ProjectOutlined,{}),(0,o.jsx)(`span`,{children:`Project:`}),(0,o.jsx)(nT,{strong:!0,children:c.name})]})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`primary`,icon:(0,o.jsx)(a.PlusOutlined,{}),onClick:()=>g(!0),children:`Add Module`})})]})}),(0,o.jsx)(i.Card,{className:`v1-card zt-fall`,title:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.AppstoreOutlined,{}),(0,o.jsx)(`span`,{children:`Modules`})]}),children:(0,o.jsx)(hf,{listName:`Modules`,loading:p,fields:[{label:`Module`,value:`modulename`},{label:`Submodules`,value:`submoduleCount`,width:140,render:(e,t)=>(0,o.jsxs)(i.Button,{type:`link`,className:`zt-count-link`,onClick:()=>O(t),children:[d[t.modulename]??0,` submodule(s)`]})},{label:`Active`,value:`active`,width:120,render:(e,t)=>(0,o.jsx)(i.Switch,{checked:e===1,checkedChildren:`On`,unCheckedChildren:`Off`,onChange:e=>E(t,e)})}],dataSource:l,current:x,pageSize:C,total:l.length,onPageChange:S,onPageSizeChange:e=>{S(1),w(e)},rowSelection:!1,className:`zt-list-plain`})})]}),(0,o.jsx)(i.Modal,{title:`Add Module`,open:h,confirmLoading:y,okText:`Add`,onOk:D,onCancel:()=>{g(!1),v(``)},destroyOnHidden:!0,children:(0,o.jsxs)(i.Space,{direction:`vertical`,className:`zt-modal-stack`,children:[(0,o.jsxs)(nT,{type:`secondary`,children:[`Project: `,(0,o.jsx)(`b`,{children:c.name})]}),(0,o.jsx)(i.Input,{placeholder:`Enter module name`,maxLength:100,value:_,onChange:e=>v(e.target.value),onPressEnter:D})]})})]}):null}var{Text:aT}=i.Typography,oT=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`},{label:`Manage Submodules`,href:`/test-cases/zinnext/submodules`}];function sT(){let n=(0,s.useNavigate)(),[c]=(0,s.useSearchParams)(),l=(0,r.useMemo)(()=>t.c(),[]),u=c.get(`module`)??``,[d,f]=(0,r.useState)([]),[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(!1),[_,v]=(0,r.useState)(``),[y,b]=(0,r.useState)(!1),[x,S]=(0,r.useState)(1),[C,w]=(0,r.useState)(10),T=(0,r.useCallback)(async(e,t)=>{if(!e||!t){f([]);return}m(!0);try{f((await xh({project:e,module:t}))?.items??[])}catch(e){console.error(e),i.message.error(`Unable to load submodules.`)}finally{m(!1)}},[]);(0,r.useEffect)(()=>{if(!l){n(`/select-project`,{replace:!0});return}if(!u){n(`/manageModules`,{replace:!0});return}Promise.resolve().then(()=>T(l.name,u))},[l,u,n,T]);let E=async(e,t)=>{try{await Ch(e.id,+!!t),f(n=>n.map(n=>n.id===e.id?{...n,active:+!!t}:n)),i.message.success(`Submodule ${t?`activated`:`deactivated`}.`)}catch(e){console.error(e),i.message.error(`Unable to update submodule status.`)}},D=async()=>{let e=_.trim();if(!e){i.message.warning(`Enter a submodule name.`);return}b(!0);try{await Sh({project:l.name,modulename:u,submodulename:e}),i.message.success(`Submodule added.`),g(!1),v(``),S(1),T(l.name,u)}catch(e){console.error(e),i.message.error(`Unable to add submodule (maybe it already exists).`)}finally{b(!1)}};return!l||!u?null:(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:oT})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`link`,onClick:()=>n(`/manageModules`),children:`Back to Modules`})})]}),(0,o.jsxs)(`div`,{className:`zt-page`,children:[(0,o.jsx)(i.Card,{className:`v1-card zt-bar`,children:(0,o.jsxs)(i.Row,{gutter:[16,16],align:`middle`,justify:`space-between`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsxs)(i.Space,{size:16,wrap:!0,className:`zt-section-title`,children:[(0,o.jsxs)(i.Space,{size:6,children:[(0,o.jsx)(a.ProjectOutlined,{}),(0,o.jsx)(`span`,{children:`Project:`}),(0,o.jsx)(aT,{strong:!0,children:l.name})]}),(0,o.jsxs)(i.Space,{size:6,children:[(0,o.jsx)(a.AppstoreOutlined,{}),(0,o.jsx)(`span`,{children:`Module:`}),(0,o.jsx)(aT,{strong:!0,children:u})]})]})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`primary`,icon:(0,o.jsx)(a.PlusOutlined,{}),onClick:()=>g(!0),children:`Add Submodule`})})]})}),(0,o.jsx)(i.Card,{className:`v1-card zt-fall`,title:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.AppstoreOutlined,{}),(0,o.jsx)(`span`,{children:`Submodules`})]}),children:(0,o.jsx)(hf,{listName:`Submodules`,loading:p,fields:[{label:`Submodule`,value:`submodulename`},{label:`Active`,value:`active`,width:120,render:(e,t)=>(0,o.jsx)(i.Switch,{checked:e===1,checkedChildren:`On`,unCheckedChildren:`Off`,onChange:e=>E(t,e)})}],dataSource:d,current:x,pageSize:C,total:d.length,onPageChange:S,onPageSizeChange:e=>{S(1),w(e)},rowSelection:!1,className:`zt-list-plain`})})]}),(0,o.jsx)(i.Modal,{title:`Add Submodule`,open:h,confirmLoading:y,okText:`Add`,onOk:D,onCancel:()=>{g(!1),v(``)},destroyOnHidden:!0,children:(0,o.jsxs)(i.Space,{direction:`vertical`,className:`zt-modal-stack`,children:[(0,o.jsxs)(aT,{type:`secondary`,children:[`Project: `,(0,o.jsx)(`b`,{children:l.name}),` \xA0|\xA0 Module: `,(0,o.jsx)(`b`,{children:u})]}),(0,o.jsx)(i.Input,{placeholder:`Enter submodule name`,maxLength:100,value:_,onChange:e=>v(e.target.value),onPressEnter:D})]})})]})}var{Text:cT}=i.Typography,lT=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Table`,href:`/viewTestCase`}];function uT(){let n=(0,s.useNavigate)(),[c,l]=(0,r.useState)([]),[u,d]=(0,r.useState)(0),[f,p]=(0,r.useState)(!1),m=(0,r.useMemo)(()=>t.c(),[]),[h,g]=(0,r.useState)(``),[_,v]=(0,r.useState)(1),[y,b]=(0,r.useState)(20),[x,S]=(0,r.useState)(null),C=(0,r.useCallback)(async(e={})=>{p(!0);try{let t=await wh({product_parent_ID:e.project??m?.id??``,search:e.search??h??``,limit:e.pageSize??y,offset:((e.page??_)-1)*(e.pageSize??y)});l(t?.items??[]),d(t?.total??0)}catch(e){console.error(e),i.message.error(`Unable to load test flows.`)}finally{p(!1)}},[m?.id,h,_,y]),w=e=>{i.Modal.confirm({title:`Delete Test Case`,icon:(0,o.jsx)(a.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 kh(e.id),i.message.success(`Test case deleted successfully.`);let t=c.length===1&&_>1?_-1:_;v(t),await C({page:t})}catch(e){throw console.error(`Unable to delete test flow:`,e),i.message.error(`Unable to delete test case.`),e}finally{S(null)}}})};return(0,r.useEffect)(()=>{Promise.resolve().then(()=>{if(!m?.id){n(`/select-project`,{replace:!0});return}C({page:1})})},[]),(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:lT})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`link`,onClick:()=>n(`/addTestCase`),children:`Back to Form`})})]}),(0,o.jsx)(`div`,{className:`zt-page zt-page-wide`,children:(0,o.jsxs)(i.Card,{className:`v1-card`,title:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.TableOutlined,{}),(0,o.jsx)(`span`,{children:`Test Flows`})]}),extra:(0,o.jsxs)(cT,{type:`secondary`,children:[u,` row(s)`]}),children:[(0,o.jsxs)(i.Space,{wrap:!0,className:`zt-toolbar`,children:[(0,o.jsx)(i.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,o.jsx)(i.Button,{icon:(0,o.jsx)(a.ReloadOutlined,{}),onClick:()=>C(),children:`Refresh`})]}),(0,o.jsx)(hf,{listName:`Test Flows`,loading:f,fields:[{label:`Actions`,value:`rowActions`,width:112,fixed:`left`,sorter:!1,render:(e,t)=>(0,o.jsxs)(i.Space,{size:4,className:`zt-row-actions`,children:[(0,o.jsx)(i.Tooltip,{title:`Edit`,children:(0,o.jsx)(i.Button,{type:`text`,size:`small`,icon:(0,o.jsx)(a.EditOutlined,{}),onClick:()=>n(`/addTestCase?edit=${t.id}`)})}),(0,o.jsx)(i.Tooltip,{title:`Delete`,children:(0,o.jsx)(i.Button,{danger:!0,type:`text`,size:`small`,icon:(0,o.jsx)(a.DeleteOutlined,{}),loading:x===t.id,onClick:()=>w(t)})})]})},{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,o.jsx)(i.Tag,{color:`green`,children:`Positive`}):(0,o.jsx)(i.Tag,{color:`red`,children:`Negative`})},{label:`Active`,value:`active`,width:90,render:e=>e===1?(0,o.jsx)(i.Tag,{color:`blue`,children:`Active`}):(0,o.jsx)(i.Tag,{children:`Inactive`})}],dataSource:c,current:_,pageSize:y,total:u,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 dT=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}];function fT(){return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsx)(e.t,{items:dT}),(0,o.jsx)(Va,{moduleName:`test-flows`,rowKey:`id`})]})}var{Text:pT}=i.Typography,mT=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}],hT={tags:`regression`,active:1},gT={module:{dbName:`Modules`,formField:`module`,label:`Module`}},_T={key:!1,value:!1,expected:!1};function vT(e,t){return t?e[t]??_T:_T}function yT(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function bT(e=[]){return e.map(e=>({value:e,label:e}))}function xT(e=``){return String(e??``).trim()}function ST(e=[]){let t=new Map;return e.forEach(e=>{let n=xT(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function CT(e=[],t,n){let r=xT(t).toLowerCase(),i=xT(n).toLowerCase();return e.reduce((e,t)=>{let n=xT(t?.module).toLowerCase(),a=xT(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 wT({icon:e,title:t}){return(0,o.jsxs)(i.Space,{size:10,align:`center`,children:[(0,o.jsx)(`div`,{className:`v1-section-icon-box`,children:e}),(0,o.jsx)(pT,{strong:!0,className:`v1-section-label`,children:t})]})}function TT(){let[t]=i.Form.useForm(),[n]=i.Form.useForm(),[c,l]=(0,r.useState)([]),[u,d]=(0,r.useState)([]),[f,p]=(0,r.useState)([]),[m,h]=(0,r.useState)(Fw),[g,_]=(0,r.useState)({}),[v,y]=(0,r.useState)(!1),[b,x]=(0,r.useState)(!1),[S,C]=(0,r.useState)({open:!1,typeKey:`module`}),[w,T]=(0,r.useState)(!1),[E,D]=(0,r.useState)(!1),[O,k]=(0,r.useState)(!1),A=(0,s.useNavigate)(),j=gT[S.typeKey],M=(0,r.useMemo)(()=>bT(c),[c]),N=i.Form.useWatch(`module`,t),P=i.Form.useWatch(`flow`,t),F=i.Form.useWatch(`keyword`,t),I=!!xT(N),L=!!xT(P),R=!I,z=!I||!L,B=(0,r.useMemo)(()=>vT(g,F),[g,F]),ee=(e,t=[])=>{e===`module`&&l(t)},te=async()=>{y(!0);try{l((await ch(gT.module.dbName))?.items??[])}catch(e){console.error(`Unable to load testing options:`,e),i.message.error(`Unable to load testing options.`)}finally{y(!1)}},V=async()=>{try{let e=await uh();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),i.message.error(`Unable to load action validation rules.`)}},ne=(0,r.useCallback)(async e=>{let n=xT(e);if(d([]),p([]),t.setFieldsValue({step_order:void 0}),n){x(!0);try{let e=await gh({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];d(t),p(ST(t))}catch(e){console.error(`Unable to load flows:`,e),i.message.error(`Unable to load flows.`)}finally{x(!1)}}},[t]),re=(0,r.useCallback)(async(e,n,r)=>{let a=xT(e),o=xT(n);if(!a||!o){t.setFieldsValue({step_order:void 0});return}D(!0);try{t.setFieldsValue({step_order:CT(r,a,o)})}catch(e){console.error(`Unable to load step order:`,e),i.message.error(`Unable to load step order.`)}finally{D(!1)}},[t]);(0,r.useEffect)(()=>{Promise.resolve().then(async()=>{await Promise.all([te(),V()])})},[]),(0,r.useEffect)(()=>{Promise.resolve().then(()=>ne(N))},[ne,N]),(0,r.useEffect)(()=>{Promise.resolve().then(()=>re(N,P,u))},[u,re,P,N]);let H=async e=>{let n={module:xT(e.module),flow:xT(e.flow),step_order:Number(e.step_order),description:xT(e.description),keyword:xT(e.keyword),target:xT(e.target),value:xT(e.value),expected:xT(e.expected),tags:e.tags?xT(e.tags):hT.tags,active:Number(e.active)};k(!0);try{await hh(n),i.message.success(`LMS case details saved successfully.`),t.resetFields(),d([]),p([])}catch(e){console.error(`Unable to save LMS case:`,e),i.message.error(`Unable to save LMS case.`)}finally{k(!1)}},U=(e,n)=>{t.setFieldsValue({[e]:xT(n)})},W=e=>{t.setFieldsValue({module:xT(e),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:hT.tags,value:void 0,expected:void 0}),yT(t,[`keyword`,`target`,`value`,`expected`])},G=e=>{t.setFieldsValue({flow:xT(e),step_order:void 0,keyword:void 0,target:void 0,value:void 0,expected:void 0}),yT(t,[`keyword`,`target`,`value`,`expected`])},ie=e=>{let n=vT(g,e);t.setFieldsValue({keyword:xT(e),target:n.key?t.getFieldValue(`target`):void 0,value:n.value?t.getFieldValue(`value`):void 0,expected:n.expected?t.getFieldValue(`expected`):void 0}),yT(t,[`target`,`value`,`expected`])},K=e=>{let t=gT[e];C({open:!0,typeKey:e}),n.setFieldsValue({name:``,type:t.label})},ae=()=>{C(e=>({...e,open:!1})),n.resetFields()},oe=async()=>{try{let e=xT((await n.validateFields()).name),r=await lh({name:e,type:j.dbName});ee(S.typeKey,r?.items??[]),t.setFieldsValue({[j.formField]:e}),i.message.success(`${j.label} added successfully.`),ae()}catch(e){if(e?.errorFields)return;console.error(`Unable to save testing option:`,e),i.message.error(`Unable to add ${j.label.toLowerCase()}.`)}finally{T(!1)}};return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:mT})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`link`,onClick:()=>A(`/lms-home`),children:`View Table`})})]}),(0,o.jsx)(`div`,{className:`v1-page`,children:(0,o.jsxs)(`div`,{className:`v1-page-inner`,children:[(0,o.jsx)(`div`,{className:`v1-page-header`,children:(0,o.jsxs)(i.Space,{align:`center`,size:10,children:[(0,o.jsx)(a.ProfileOutlined,{className:`v1-outer-icon`}),(0,o.jsx)(`div`,{children:(0,o.jsx)(pT,{strong:!0,style:{fontSize:16},children:`Add LMS Case`})})]})}),(0,o.jsx)(Z,{children:(0,o.jsxs)(i.Form,{form:t,className:`v1-form`,layout:`vertical`,colon:!1,requiredMark:(e,{required:t})=>(0,o.jsxs)(o.Fragment,{children:[e,t&&(0,o.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),initialValues:hT,onFinish:H,autoComplete:`off`,children:[(0,o.jsx)(i.Card,{className:`v1-card`,title:(0,o.jsx)(wT,{icon:(0,o.jsx)(a.FileTextOutlined,{}),title:`LMS Case Details`}),extra:(0,o.jsx)(pT,{type:`secondary`,className:`v1-card-subtitle`,children:`Module, flow, step order and execution data`}),children:(0,o.jsxs)(i.Row,{gutter:[24,0],children:[(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsxs)(i.Space.Compact,{style:{width:`100%`},children:[(0,o.jsx)(i.Form.Item,{label:`Module`,name:`module`,style:{flex:1},children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,loading:v,optionFilterProp:`label`,placeholder:`Select module`,options:M,onChange:W})}),(0,o.jsx)(i.Button,{"aria-label":`Add module`,icon:(0,o.jsx)(a.PlusOutlined,{}),style:{marginTop:30},onClick:()=>K(`module`)})]})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Flow`,name:`flow`,children:(0,o.jsx)(i.AutoComplete,{maxLength:100,allowClear:!0,disabled:R,options:f,placeholder:b?`Loading flows`:`Enter flow`,onChange:G,filterOption:(e,t)=>t?.value?.toLowerCase().includes(e.toLowerCase())})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Step Order`,name:`step_order`,validateTrigger:[`onBlur`,`onChange`],children:(0,o.jsx)(i.Input,{maxLength:10,disabled:!0,placeholder:E?`Loading step order`:`Step order`})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Action`,name:`keyword`,children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,disabled:z,optionFilterProp:`label`,placeholder:`Select action`,options:m,onChange:ie})})}),(0,o.jsx)(i.Col,{xs:24,children:(0,o.jsx)(i.Form.Item,{label:`Description`,name:`description`,children:(0,o.jsx)(i.Input.TextArea,{rows:3,maxLength:255,disabled:z,placeholder:`Enter description`,showCount:!0,onBlur:e=>U(`description`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Key`,name:`target`,rules:[{required:B.key,message:`Key is required for this action`}],children:(0,o.jsx)(i.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=>U(`target`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Tags`,name:`tags`,children:(0,o.jsx)(i.Input,{maxLength:200,disabled:z,placeholder:`Enter tags`,prefix:(0,o.jsx)(a.TagsOutlined,{className:`v1-input-icon`}),onBlur:e=>U(`tags`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Value`,name:`value`,rules:[{required:B.value,message:`Value is required for this action`}],children:(0,o.jsx)(i.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=>U(`value`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Expected`,name:`expected`,rules:[{required:B.expected,message:`Expected result is required for this action`}],children:(0,o.jsx)(i.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=>U(`expected`,e.target.value)})})})]})}),(0,o.jsx)(`div`,{className:`v1-form-actions`,children:(0,o.jsx)(i.Form.Item,{children:(0,o.jsxs)(i.Space,{children:[(0,o.jsx)(i.Button,{type:`primary`,htmlType:`submit`,loading:O,disabled:z,children:`Submit`}),(0,o.jsx)(i.Button,{onClick:()=>{t.resetFields(),d([]),p([])},children:`Reset`})]})})})]})}),(0,o.jsx)(i.Modal,{title:`Add ${j.label}`,open:S.open,confirmLoading:w,okText:`Add`,onCancel:ae,onOk:()=>{T(!0),oe()},destroyOnHidden:!0,children:(0,o.jsxs)(i.Form,{form:n,layout:`vertical`,colon:!1,className:`v1-form`,requiredMark:(e,{required:t})=>(0,o.jsxs)(o.Fragment,{children:[e,t&&(0,o.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),children:[(0,o.jsx)(i.Form.Item,{label:`Name`,name:`name`,children:(0,o.jsx)(i.Input,{maxLength:100,placeholder:`Enter ${j.label.toLowerCase()} name`,onBlur:e=>{n.setFieldsValue({name:xT(e.target.value)})}})}),(0,o.jsx)(i.Form.Item,{label:`Type`,name:`type`,children:(0,o.jsx)(i.Input,{disabled:!0})})]})})]})})]})}var ET=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}];function DT(){return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsx)(e.t,{items:ET}),(0,o.jsx)(Va,{moduleName:`lms-flows`,rowKey:`id`})]})}var OT=[`referenceId`,`ReferenceId`,`candidateId`,`CandidateId`,`entityId`,`EntityId`,`id`,`Id`,`_id`];function kT(e=OT){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 AT(e,t=OT){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 jT=kT();function MT(e){return typeof e==`function`?e:typeof e==`string`?kT([e]):Array.isArray(e)?kT(e):jT}function NT(e,t,n){return!t||typeof t!=`object`?e:{...t,...e,id:t.id??e.id??n}}function PT(e,t,n={}){return{status:`success`,total:t,data:{data:e,...n}}}var FT=[`fields`,`fieldConfig`,`tabs`,`tabField`,`actionRules`,`actions`,`columnActions`];function IT(e){let t=e?.data??e,n={};for(let r of FT){let i=e?.[r]??t?.[r];i==null||Array.isArray(i)&&i.length===0||(n[r]=i)}return n}var LT=e=>String(e??``).replace(/[^a-zA-Z0-9]/g,``).toLowerCase();function RT(e,t,n){let r=(Array.isArray(n)?n:[n]).map(LT).filter(Boolean),i=r.length?e.findIndex(e=>r.includes(LT(e?.value))||r.includes(LT(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 zT=(e,t)=>br(e,t).rows,BT=(e,t)=>{let{rows:n,total:r}=br(e,t);return{rows:n,total:r}};function VT({fetchPrimaryPage:e,extractPrimaryPage:t=BT,fetchSecondaryByKeys:n,fetchPrimary:r,extractPrimaryRows:i=zT,fetchSecondary:a,extractSecondaryRows:o=zT,fetchSecondaryById:s,primaryKey:c,secondaryKey:l,mergeRow:u=NT,secondaryFetchLimit:d=200,extraFields:f=[],extraFieldsAfter:p}){let m=MT(c),h=typeof l==`function`?e=>{let t=l(e);return t?[String(t)]:[]}:e=>AT(e,typeof l==`string`?[l]:Array.isArray(l)?l:OT),g=0;function _(e){let t=new Map;return e.forEach(e=>{for(let n of h(e))t.has(n)||t.set(n,e)}),t}async function v(e,t){if(!s||!t)return null;try{let n=await s(e,t);return n&&h(n).includes(String(t))?n:null}catch(e){return console.error(`[mergedListApi] per-id secondary lookup failed for "${t}"`,e),null}}async function y(e,t,n,r){return Promise.all(e.map(async e=>{let i=m(e);return u(e,t.get(i)??(r()?null:await v(n,i)),i)}))}function b(e,t,n){let r={};for(let e of n){if(!e)continue;let t=IT(e);for(let e of Object.keys(t))r[e]??(r[e]=t[e])}return f.length&&(r.fields=RT(r.fields??[],f,p)),PT(e,t,r)}async function x(r,i,a,s,c){let l=await e(r,i,a,s),u=t(l,r)??{},d=Array.isArray(u.rows)?u.rows:[],f=Number.isFinite(Number(u.total))?Number(u.total):d.length,p=[...new Set(d.map(m).filter(Boolean))],h=null,g=[];if(p.length&&n)try{h=await n(r,p,s),g=o(h,r)??[]}catch(e){console.error(`[mergedListApi] secondary fetch failed — rendering unenriched page`,e),h=null}return b(await y(d,_(g),r,c),f,[l,h])}async function S(e,t,n,s,c){let[l,u]=await Promise.allSettled([r(e,t,n,s),a?a(e,d,0,s):Promise.resolve(null)]);if(l.status===`rejected`)throw l.reason;let f=u.status===`fulfilled`?u.value:null;u.status===`rejected`&&console.error(`[mergedListApi] secondary fetch failed — rendering unenriched page`,u.reason);let p=i(l.value,e)??[],m=_(f?o(f,e)??[]:[]),h=p.length;return b(await y(p.slice(n,n+t),m,e,c),h,[l.value,f])}return async function(t,n=10,r=0,i={}){let a=++g,o=()=>a!==g;return e?x(t,n,r,i,o):S(t,n,r,i,o)}}function HT(e,t,n={}){return VT({fetchPrimary:()=>rS(e,t),extractPrimaryRows:eS,fetchSecondary:Qt,fetchSecondaryById:iS,secondaryFetchLimit:n.moduleFetchLimit??200})}function UT(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 WT(e){let t=Array.isArray(e?.stages)?e.stages:[];if(!t.length)return e;let n={};for(let e of t){let t=UT(e?.stageName);t&&(n[t]=Number(e?.count)||0)}return{...n,...e}}var GT=e=>{let t=Number(e?.targetSubmission??e?.targetSubmissions);return Number.isFinite(t)&&t>0?t:null};function KT({submittedCountField:e=`submittedCount`,progressField:t=`targetSubmissionProgress`}={}){return function(n,r,i){let a=NT(n,r,i),o=GT(a);return o!=null&&(console.log(`mergeJobWorkflowRow`,i,a?.[e],o),a[t]=`${Number(a?.[e])||0} of ${o}`),a}}function qT(e={}){let t=KT(),n=VT({primaryKey:`_id`,secondaryKey:`entityId`,extraFields:e.extraFields,extraFieldsAfter:e.extraFieldsAfter,fetchPrimaryPage:Qt,fetchSecondaryByKeys:()=>nS(),extractSecondaryRows:e=>(e?.items??[]).map(WT),mergeRow:(e,n,r)=>{let i=t(e,n,r);return n?._id&&(i.workflowId=n._id),i}});return async function(e,t,r,i){return await n(e,t,r,i)}}async function JT(e,t=10,n=0,r={},i={}){return br(await qT(i)(e,t,n,r),e)}async function YT(e,t,n,r=10,i=0,a={}){return br(await HT(e,t)(n,r,i,a),n)}var XT=bC,ZT=Mh(_w),QT=Mh(yw),$T=Mh(Pw),eE=Mh(Kw),tE=Mh(tT),nE=Mh(iT),rE=Mh(sT),iE=Mh(uT),aE=Mh(fT),oE=Mh(TT),sE=Mh(DT);exports.ADMIN_API_URL=t._,exports.ADMIN_APP_ID=t.v,exports.APP_ID=t.y,exports.AUTH_URL=t.b,exports.ActivityTab=Cs,exports.AddBatchCandidatePopup=rC,exports.AddFormV1=ss,exports.AdminDashboard=bC,exports.AdminDashboardContent=Jy,exports.AdminPage=XT,exports.AppAlert=cs,exports.AppButton=qr,exports.AppShell=th,exports.ApprovalActionBar=Xf,exports.AssigneeAvatars=ws,exports.AuthGuard=$m,exports.BILLING_STATUS_FLOW=Ul,exports.BULK_UPLOAD_DEFAULT_ACCEPT=Ts,exports.BULK_UPLOAD_DEFAULT_MAX_SIZE_MB=Es,exports.Breadcrumb=e.t,exports.BulkUploadPage=$T,exports.BulkUploadPanel=Ps,exports.CANDIDATES_URL=t.x,exports.CONTRACT_C2C=hp,exports.CONTRACT_W2=mp,exports.CalendarCard=D,exports.CoreThemeAdminApp=Qy,exports.CoreThemeAdminRoutes=Zy,exports.CustomPagination=Se,exports.DayLogModal=Wf,exports.DescriptionBlock=qs,exports.DetailHeaderCard=Gu,exports.DetailViewPage=Qu,exports.DetailViewV1=qc,exports.DocumentViewer=e.Jn,exports.DynamicCards=bt,exports.DynamicPopup=Lx,exports.DynamicPopupRoute=oC,exports.DynamicTabs=j,exports.EditFormV1=Kd,exports.FINANCE_APPROVAL_CONFIG=lp,exports.FINANCE_TYPE_CFO=ip,exports.FINANCE_TYPE_ONBOARDING_MANAGER=rp,exports.FINANCE_TYPE_ONBOARDING_MANAGER_REAPPROVE=sp,exports.FINANCE_TYPE_ONLY_FINANCE=ap,exports.FINANCE_TYPE_SUBMISSION_MANAGER=np,exports.FINANCE_TYPE_SUBMISSION_MANAGER_REAPPROVE=op,exports.FileListCard=Qp,exports.FinanceApprovalPanel=Hp,exports.FinanceAvatar=wu,exports.FinanceBadge=Ou,exports.FinanceDayCell=Qf,exports.FinanceDivider=gu,exports.FinanceEmployeeCell=Tu,exports.FinanceEmptyState=pu,exports.FinanceEquation=_u,exports.FinanceHistoryTimeline=xu,exports.FinanceHoursGrid=fu,exports.FinanceKpiRow=du,exports.FinanceLine=hu,exports.FinanceListToolbar=Df,exports.FinanceMarginBadge=ku,exports.FinanceMoneyCell=Du,exports.FinanceRecordsTable=Mu,exports.FinanceRowChevron=Au,exports.FinanceSection=mu,exports.FinanceStatusPill=uu,exports.FinanceTextCell=Eu,exports.FinanceTimesheetAnalysis=ep,exports.FinanceWorkflowSteps=vu,exports.Header=Dm,exports.HierarchyUserFilter=Tt,exports.JOBS_URL=t.S,exports.LegacyAdminPage=ZT,exports.ListView=Va,exports.LmsHomePage=sE,exports.LmsTestForm=oE,exports.Login=nh,exports.MailPopup=ob,exports.ManageModules=nE,exports.ManageSubmodules=rE,exports.ModuleRowActions=tf,exports.NotesPanel=Yf,exports.PAYROLL_STATUS_FLOW=Wl,exports.POPUP_CONFIGS=JS,exports.ParamCardView=lf,exports.ParamListView=hf,exports.PreviewPopup=Rb,exports.ProjectSelect=jh,exports.ProofUploadPreview=Jf,exports.QuickLogBar=qf,exports.QuickLogSelectionBar=Gf,exports.RejectionReasonModal=Kf,exports.SUBMISSIONS_URL=t.C,exports.Sidebar=Ym,exports.StatusBadge=_f,exports.StatusBadgeTag=Af,exports.StickyNotesFullPage=QT,exports.StylishDynamicTabs=yf,exports.TemplateEditor=wf,exports.TestForm=eE,exports.TestingHomePage=aE,exports.TimelineGroups=hs,exports.TimesheetDayCell=zf,exports.TipTapEditor=e.Yn,exports.UserForm=yC,exports.VendorShareDrawer=uC,exports.ViewSummaryWidget=Kr,exports.WizardPopup=Wb,exports.ZinnextTableView=iE,exports.ZinnextTestForm=tE,exports.applyIntegrationStatus=e.mt,exports.approveSubmission=se,exports.buildAcceptAttr=js,exports.buildCsv=iu,exports.buildDailyRows=Ql,exports.buildDayGradient=Lf,exports.buildRateHistoryEntries=Np,exports.buildWeeklyRollup=tu,exports.clearSelectedProject=t.r,exports.colors=e.Qn,exports.computeFinance=jp,exports.computeMarginBand=nu,exports.configureCoreTheme=t.w,exports.createAllWorkflowsListFetcher=qT,exports.createWorkflowStageListFetcher=HT,exports.deleteIntegrationConfig=e.Tt,exports.deriveDayStats=Zl,exports.downloadCsv=cu,exports.findEmployerRow=Tp,exports.flattenGroups=Cp,exports.formatFileSize=As,exports.formatFinanceMoney=Pp,exports.formatHours=Pl,exports.formatMoney=Nl,exports.formatPercent=Il,exports.formatRate=Fl,exports.getActivity=e.at,exports.getAllWorkflowsModuleList=JT,exports.getApprovalDate=Bl,exports.getBgcIntegrationConfig=e.Ht,exports.getBgcIntegrationSummary=e.Ut,exports.getBillingActionStates=Gl,exports.getCurrentRoleName=t.s,exports.getFieldLabel=ou,exports.getFileExtension=ks,exports.getFinanceApprovalConfig=dp,exports.getFormGroupsRaw=Xp,exports.getIntegrationConfig=e.Yt,exports.getIntegrationConfigs=e.Xt,exports.getIntegrationSummary=e.Zt,exports.getModuleConfig=xe,exports.getModuleDataDetail=e.st,exports.getPayrollActionStates=Kl,exports.getSelectedProject=t.c,exports.getStoredToken=t.l,exports.getStoredUser=t.u,exports.getUserRoles=t.d,exports.getVMSApprove=ce,exports.getValueStyle=su,exports.getWorkflowStageModuleList=YT,exports.getWorkflowSteps=ql,exports.humanizeEvent=zl,Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return ao}}),exports.indexFieldConfig=au,exports.initialsOf=Ll,exports.isTester=t.f,exports.logout=t.m,exports.marginIncludesReferral=pp,exports.matchLocationTax=Ap,Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return td}}),exports.normalizeContract=Dp,Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Fs}}),exports.rejectSubmission=ue,exports.resolveActivityMeta=bs,exports.resolveAndCompute=Mp,exports.resolveFinanceInputs=kp,exports.resolveMergeKey=jT,exports.resolveRejectionReason=fp,exports.resolveSubmissionFinance=Zp,exports.saveBgcIntegrationConfig=e.vn,exports.saveIntegrationConfig=e.xn,exports.setSelectedProject=t.g,exports.stageCountKey=UT,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return rh}}),exports.testIntegrationConnection=e.Dn,exports.useDropdownFields=hn,exports.useDropdownValues=Jr,exports.useEditForm=$p,exports.useFieldConfig=gn,exports.useFilterFields=_n,exports.useMenuPermission=Cn,exports.useModuleActions=Jd,exports.useRecordRefresh=Yu,exports.validateBulkFile=Ms,exports.withAdminAppId=t.T,exports.withAppId=t.E,exports.withAuthGuard=Mh;
|
|
9
|
+
`))}function yb(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:mb(n),value:r}}function bb(e){let t=e.toLowerCase().replace(/[\s:.\-–—]+$/,``).trim();return ub.has(t)?db.test(t)?`education`:fb.test(t)?`keySkills`:`overview`:null}function xb(e){let t=[],n={overview:[],keySkills:[],education:[]},r=`overview`;return e.forEach(e=>{let i=bb(e);if(i){r=i;return}if(r===`overview`){let n=yb(e);if(n){t.push(n);return}}n[r].push(e)}),{meta:t,overview:hb(n.overview),keySkills:hb(n.keySkills),education:hb(n.education)}}function Sb(e){let t=[...lb].sort((e,t)=>t.length-e.length),n=RegExp(`\\b(${t.map(pb).join(`|`)})\\b\\s*:?`,`gi`),r=[...e.matchAll(n)];if(!r.length)return{meta:[],overview:hb(vb(e)),keySkills:[],education:[]};let i={overview:[],keySkills:[],education:[]},a=e.slice(0,r[0].index).trim();return a&&i.overview.push(...vb(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=vb(e.slice(o,s).trim());c.length&&i[db.test(a)?`education`:fb.test(a)?`keySkills`:`overview`].push(...c)}),{meta:[],overview:hb(i.overview),keySkills:hb(i.keySkills),education:hb(i.education)}}function Cb(e){let t=gb(e);if(!t)return{meta:[],overview:[],keySkills:[],education:[]};let n=_b(t);return n.length>=4?xb(n):Sb(t)}function wb({items:e}){return(0,o.jsx)(`ul`,{className:`jdv-ats-bullets`,children:e.map((e,t)=>(0,o.jsx)(`li`,{className:`jdv-ats-bullet-item`,children:e},t))})}function Tb({raw:e=``,meta:t=[]}){let[n,i]=(0,r.useState)(!1),a=(0,r.useMemo)(()=>Cb(e),[e]),s=t.length?t:a.meta,c=[];if(a.overview.length&&c.push({key:`overview`,title:`Overview`,items:a.overview}),a.keySkills.length&&c.push({key:`keySkills`,title:`Key Skills`,items:a.keySkills,card:!0,icon:`🛠️`}),a.education.length&&c.push({key:`education`,title:`Education`,items:a.education,card:!0,icon:`🎓`}),!s.length&&!c.length)return(0,o.jsx)(sb,{type:`secondary`,children:`No description available.`});let l=n?c:c.slice(0,cb),u=c.length-cb;return(0,o.jsxs)(`div`,{className:`jdv-ats-desc`,children:[s.length>0&&(0,o.jsx)(`div`,{className:`jdv-ats-meta-grid`,children:s.map(({fieldKey:e,fieldLabel:t,value:n})=>(0,o.jsxs)(`div`,{className:`jdv-ats-meta-row`,children:[(0,o.jsx)(`span`,{className:`jdv-ats-meta-key`,children:t}),(0,o.jsx)(`span`,{className:`jdv-ats-meta-val`,children:n})]},e??t))}),(0,o.jsx)(`div`,{className:`jdv-ats-sections`,children:l.map(e=>e.card?(0,o.jsxs)(`div`,{className:`education-block`,children:[(0,o.jsxs)(`div`,{className:`education-header`,children:[(0,o.jsx)(`span`,{children:e.icon}),(0,o.jsx)(`span`,{children:e.title})]}),(0,o.jsx)(`ul`,{className:`education-list`,children:e.items.map((e,t)=>(0,o.jsx)(`li`,{className:`education-list-item`,children:e},t))})]},e.key):(0,o.jsxs)(`div`,{className:`jdv-ats-section`,children:[(0,o.jsx)(`div`,{className:`jdv-ats-section-hd`,children:(0,o.jsx)(`span`,{children:e.title})}),(0,o.jsx)(wb,{items:e.items})]},e.key))}),u>0&&(0,o.jsx)(`span`,{className:`jdv-desc-toggle`,onClick:()=>i(e=>!e),children:n?`Show less`:`Show more (${u} more section${u>1?`s`:``})`})]})}var{Text:Eb}=i.Typography;function Db(e){return e?e.trim().split(/\s+/).slice(0,2).map(e=>e[0].toUpperCase()).join(``):`?`}function Ob(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 kb(e){return e?e.email??e.emailId??e.emailAddress??``:``}function Ab(e){return e?e.status?e.status:e.stage?e.stage:typeof e.isActive==`boolean`?e.isActive?`Active`:`Inactive`:``:``}function jb(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 Mb=[`jobDescription`,`description`,`rawDescription`,`jobDescriptionText`];function Nb(e){return String(e??``).toLowerCase()===`job`}function Pb(e){let t=Mb.includes(e.field),n=/description/i.test(e.label??``);return t||n}function Fb({steps:e,current:t,onStepClick:n}){return(0,o.jsx)(`div`,{className:`preview-stepper`,children:e.map((i,s)=>{let c=s<t,l=s===t,u=s===e.length-1;return(0,o.jsxs)(r.Fragment,{children:[(0,o.jsxs)(`button`,{type:`button`,className:`preview-stepper__item${l?` preview-stepper__item--active`:``}`,onClick:()=>n(s),"aria-label":`Go to step ${s+1}: ${i.title}`,"aria-current":l?`step`:void 0,children:[(0,o.jsx)(`div`,{className:[`preview-stepper__circle`,c?`preview-stepper__circle--done`:``,l?`preview-stepper__circle--active`:``].filter(Boolean).join(` `),children:c?(0,o.jsx)(a.CheckOutlined,{}):s+1}),(0,o.jsx)(`span`,{className:`preview-stepper__label${l?` preview-stepper__label--active`:``}`,children:i.title})]}),!u&&(0,o.jsx)(`div`,{className:`preview-stepper__line${c?` preview-stepper__line--done`:``}`})]},i.title??s)})})}function Ib({record:e}){let t=Ob(e),n=kb(e),r=Ab(e);return!t&&!n?null:(0,o.jsxs)(`div`,{className:`preview-profile-card`,children:[(0,o.jsxs)(`div`,{className:`preview-profile-card__info`,children:[(0,o.jsx)(i.Avatar,{className:`preview-profile-card__avatar`,children:Db(t)}),(0,o.jsxs)(`div`,{className:`preview-profile-card__text`,children:[t&&(0,o.jsx)(`span`,{className:`preview-profile-card__name`,children:t}),n&&(0,o.jsx)(`span`,{className:`preview-profile-card__email`,children:n})]})]}),r&&(0,o.jsx)(i.Tag,{className:`preview-profile-card__status`,children:r})]})}function Lb({fields:e,moduleName:t}){return e?.length?(0,o.jsx)(`div`,{className:`preview-field-grid`,children:e.map(e=>{let n=e.value,r=Array.isArray(n)&&n.length>0,i=Nb(t)&&Pb(e)&&typeof n==`string`&&n.trim();return r?n.map((t,r)=>(0,o.jsxs)(`div`,{className:`preview-field-card`,children:[(0,o.jsxs)(`span`,{className:`preview-field-card__label`,children:[e.label,n.length>1?` (${r+1})`:``]}),(0,o.jsx)(`span`,{className:`preview-field-card__value`,children:jb(t)})]},`${e.field??e.label}-${r}`)):i?(0,o.jsxs)(`div`,{className:`preview-field-card preview-field-card--description`,children:[(0,o.jsx)(`span`,{className:`preview-field-card__label`,children:e.label}),(0,o.jsx)(`div`,{className:`preview-field-card__description`,children:(0,o.jsx)(Tb,{raw:n})})]},e.field??e.label):(0,o.jsxs)(`div`,{className:`preview-field-card`,children:[(0,o.jsx)(`span`,{className:`preview-field-card__label`,children:e.label}),(0,o.jsx)(`span`,{className:`preview-field-card__value`,children:jb(n)})]},e.field??e.label)})}):null}function Rb(){let t=(0,s.useNavigate)(),{moduleName:n=``,record:c=null}=(0,s.useLocation)().state??{},l=c?.id??c?._id,[u,d]=(0,r.useState)([]),[f,p]=(0,r.useState)(!!(n&&l)),[m,h]=(0,r.useState)(null),[g,_]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(!n||!l)return;let t=!1;return e.Hn({module:n,id:l}).then(e=>{t||(d(Array.isArray(e)?e:[]),p(!1))}).catch(e=>{t||(h(e.message||`Failed to load preview`),p(!1))}),()=>{t=!0}},[n,l]);function v(){t(-1)}let y=u.length,b=y>1,x=u[g],S=y>4?`min(${y*105+80}px, min(95vw, 1200px))`:`min(680px, calc(100vw - 32px))`,C=u.map((e,t)=>({title:e.label??e.name??`Step ${t+1}`})),w=(0,o.jsxs)(`div`,{className:`preview-modal-header`,children:[(0,o.jsx)(`span`,{className:`preview-modal-module`,children:n.toUpperCase()}),(0,o.jsx)(`span`,{className:`preview-modal-title`,children:x?.label??(n?`Preview - ${n}`:`Preview`)})]}),T=(0,o.jsxs)(`div`,{className:`wizard-footer`,children:[b&&(0,o.jsxs)(Eb,{className:`preview-footer-step-count`,children:[`Step `,g+1,` of `,y]}),(0,o.jsxs)(`div`,{className:`wizard-footer-nav`,children:[(0,o.jsx)(i.Button,{onClick:v,children:`Close`}),b&&g>0&&(0,o.jsx)(i.Button,{onClick:()=>_(e=>e-1),children:`Back`}),b&&(g<y-1?(0,o.jsx)(i.Button,{type:`primary`,icon:(0,o.jsx)(a.RightOutlined,{}),iconPosition:`end`,onClick:()=>_(e=>e+1),children:`Next`}):(0,o.jsx)(i.Button,{type:`primary`,onClick:v,children:`Done`}))]})]});function E(){return!n||!l?(0,o.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:`Preview id is missing.`}):f?(0,o.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:(0,o.jsx)(i.Spin,{size:`small`})}):m?(0,o.jsx)(`div`,{className:`job-preview-content job-preview-status job-preview-error`,children:m}):u.length?u.map((e,t)=>(0,o.jsx)(`div`,{style:{display:t===g?`block`:`none`},children:e.fields?.length>0?(0,o.jsx)(Lb,{fields:e.fields,moduleName:n}):(0,o.jsx)(Eb,{type:`secondary`,children:`No fields in this group.`})},e.name??e.id??t)):(0,o.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:`No form groups found.`})}return(0,o.jsxs)(i.Modal,{centered:!0,className:`wizard-modal preview-modal`,footer:T,open:!0,title:w,width:S,onCancel:v,maskClosable:!1,children:[b&&(0,o.jsx)(`div`,{className:`wizard-steps-container`,children:(0,o.jsx)(Fb,{steps:C,current:g,onStepClick:_})}),(0,o.jsxs)(`div`,{className:`wizard-body`,children:[c&&(0,o.jsx)(Ib,{record:c}),E()]})]})}var{Text:zb}=i.Typography,{TextArea:Bb}=i.Input,Vb=[{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 Hb(e){switch(e.type){case`select`:return(0,o.jsx)(i.Select,{placeholder:e.placeholder,options:e.options,style:{width:`100%`}});case`textarea`:return(0,o.jsx)(Bb,{rows:3,placeholder:e.placeholder});case`number`:return(0,o.jsx)(i.InputNumber,{placeholder:e.placeholder,style:{width:`100%`}});default:return(0,o.jsx)(i.Input,{type:e.inputType||`text`,placeholder:e.placeholder})}}function Ub({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,o.jsxs)(`div`,{className:`wizard-review-content`,children:[r.map(e=>(0,o.jsxs)(`div`,{className:`wizard-review-section`,children:[(0,o.jsx)(zb,{className:`wizard-review-section-title`,children:e.title}),(0,o.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,o.jsxs)(`div`,{className:`wizard-review-row`,children:[(0,o.jsx)(`span`,{className:`wizard-review-label`,children:e.label}),(0,o.jsx)(`span`,{className:`wizard-review-separator`,children:`:`}),(0,o.jsx)(`span`,{className:`wizard-review-value`,children:r})]},e.name)})})]},e.key)),(0,o.jsxs)(`div`,{className:`wizard-review-confirm-note`,children:[(0,o.jsx)(a.CheckCircleOutlined,{className:`wizard-review-confirm-icon`}),(0,o.jsx)(zb,{type:`secondary`,children:`Please review the information above before submitting.`})]})]}):(0,o.jsx)(`div`,{className:`wizard-review-empty`,children:(0,o.jsx)(zb,{type:`secondary`,children:`No data entered yet.`})})}function Wb(){let[e]=i.Form.useForm(),t=(0,s.useNavigate)(),{title:n=`Wizard`,moduleName:a=``,steps:c=Vb,onSubmit:l}=(0,s.useLocation)().state??{},[u,d]=(0,r.useState)(0),f=c[u],p=u===c.length-1,m=u===0;function h(){t(-1)}function g(){let t=(f.fields||[]).map(e=>e.name);e.validateFields(t.length>0?t:void 0).then(()=>{d(e=>e+1)})}function _(){d(e=>e-1)}function v(){let n=e.getFieldsValue();typeof l==`function`&&l(n),t(-1)}let y=c.map((e,t)=>({title:e.title,description:e.description,status:t<u?`finish`:t===u?`process`:`wait`}));return(0,o.jsxs)(i.Modal,{open:!0,title:a?`${n} — ${a}`:n,footer:(0,o.jsxs)(`div`,{className:`wizard-footer`,children:[(0,o.jsx)(i.Button,{onClick:h,children:`Cancel`}),(0,o.jsxs)(`div`,{className:`wizard-footer-nav`,children:[!m&&(0,o.jsx)(i.Button,{onClick:_,children:`Back`}),p?(0,o.jsx)(i.Button,{type:`primary`,onClick:v,children:`Submit`}):(0,o.jsx)(i.Button,{type:`primary`,onClick:g,children:`Next`})]})]}),onCancel:h,width:`min(680px, calc(100vw - 32px))`,centered:!0,className:`wizard-modal`,children:[(0,o.jsx)(`div`,{className:`wizard-steps-container`,children:(0,o.jsx)(i.Steps,{current:u,items:y,size:`small`,className:`wizard-steps`})}),(0,o.jsx)(`div`,{className:`wizard-body`,children:(0,o.jsxs)(i.Form,{form:e,layout:`vertical`,children:[c.filter(e=>!e.isReview).map((e,t)=>(0,o.jsx)(`div`,{style:{display:t===u?`block`:`none`},children:(0,o.jsx)(i.Row,{gutter:16,children:(e.fields||[]).map(e=>(0,o.jsx)(i.Col,{span:e.span||24,children:(0,o.jsx)(i.Form.Item,{name:e.name,label:e.label,rules:[...e.required?[{required:!0,message:`${e.label} is required`}]:[],...e.rules||[]],children:Hb(e)})},e.name))})},e.key)),f.isReview&&(0,o.jsx)(Ub,{steps:c,form:e})]})})]})}function Gb({titleText:e,titleIcon:t}){let n=t===`delete`;return(0,o.jsxs)(`span`,{className:`dynamic-popup__header`,children:[(0,o.jsx)(`span`,{className:`dynamic-popup__header-icon-box${n?` dynamic-popup__header-icon-box--danger`:``}`,children:n?(0,o.jsx)(a.DeleteOutlined,{}):(0,o.jsx)(a.AppstoreOutlined,{})}),(0,o.jsx)(`span`,{className:`dynamic-popup__header-label`,children:e})]})}function Kb({note:t,description:n,showSelectedCount:r,count:i,itemLabel:a,bodyText:s,deleteError:c}){return(0,o.jsxs)(o.Fragment,{children:[t&&(0,o.jsx)(e.Xn,{variant:`body`,color:`secondary`,className:`dynamic-popup__note`,children:t}),n&&(0,o.jsx)(e.Xn,{variant:`body`,className:`dynamic-popup__description`,children:n}),r&&i>0&&(0,o.jsxs)(e.Xn,{variant:`body`,className:`dynamic-popup__selected-count`,children:[`Changing status for `,(0,o.jsx)(`strong`,{children:i}),` selected `,a,`.`]}),s&&(0,o.jsx)(e.Xn,{variant:`body`,children:s}),c&&(0,o.jsx)(e.Xn,{variant:`caption`,color:`danger`,className:`dynamic-popup__error`,children:c})]})}function qb({footerNote:t}){return t?(0,o.jsx)(e.Xn,{variant:`caption`,color:`secondary`,className:`dynamic-popup__footer-note`,children:t}):null}function Jb(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t?.[n]??``).trim()}function Yb(e){return String(e).replace(/\(\s*\)/g,``).replace(/\s+/g,` `).replace(/(^|\s)([-–—·|])(?=\s*\2)/g,``).replace(/^[\s\-–—·|]+/,``).replace(/[\s\-–—·|]+$/,``).trim()}function Xb(e){if(!e)return``;let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=Math.round((n(new Date)-n(t))/864e5);return r<=0?`Today`:r===1?`Yesterday`:`${r} days ago`}function Zb(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 Qb(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 $b(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:Xb(Zb(e))}:e,o=(i?Yb(Jb(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||Qb(e);t&&(u.submittedAt=t)}if(e?.isFromSubmission===!0&&e?.submissionId){u.isFromSubmission=!0,u.priorSubmissionId=String(e.submissionId);let t=e?.lastSubmittedAt||Qb(e);t&&(u.priorSubmittedAt=t)}return u}function ex(e,t){return(t?.[e.optionsKey]??e.defaultOptions??[]).map(t=>$b(t,e))}function tx(e={}){return{selectedIds:[],selectedRecords:[],moduleName:``,removedIds:[],...e}}var nx=`DD MMM YYYY`,rx=`DD MMM YYYY, h:mm A`;function ix(e,t){if(e==null||e===``)return``;let n=(0,c.default)(e);return n.isValid()?t===`relative`&&Xb(e)||n.format(nx):String(e)}function ax(e,t){return e?String(e).includes(`{`)?Yb(Jb(e,t)):String(t?.[e]??e).trim():``}function ox(e){if(e?.alreadySubmitted){let t=e?.submittedAt?(0,c.default)(e.submittedAt):null;return{tone:`blocked`,tooltip:t?.isValid()?`Already submitted to this job on ${t.format(rx)}`:`Already submitted to this job — a candidate can only be submitted once per job`}}if(e?.isFromSubmission){let t=e?.priorSubmittedAt?(0,c.default)(e.priorSubmittedAt):null;return{tone:`history`,tooltip:t?.isValid()?`Previously submitted on ${t.format(rx)} — this form will prefill from it`:`Submitted to another job before — this form will prefill from it`}}return null}function sx(e,t){return e?.alreadySubmitted||!e?.disabled?``:String(t?.message??e?.title??``).trim()}function cx({meta:e}){return(0,o.jsx)(`div`,{className:`dynamic-popup__option-dates`,children:e.map(e=>(0,o.jsxs)(r.Fragment,{children:[(0,o.jsx)(`span`,{className:`dynamic-popup__option-date-label`,children:e.label}),(0,o.jsx)(`span`,{className:`dynamic-popup__option-date-value`,children:e.text})]},e.label))})}function lx({option:e,layout:t}){let n=e?._raw??e??{},r=ax(t.id,n),s=ax(t.title,n)||String(e?.label??``),c=ax(t.subtitle,n),l=ax(t.titleAccent?.key,n),u=ax(t.titleAccent?.toneKey,n),d=t.titleAccent?.prefix??``,f=(t.meta??[]).map(e=>({label:e.label,text:ix(n?.[e.key],e.type)})).filter(e=>e.text),p=sx(e,n),m=ox(e);return(0,o.jsxs)(`div`,{className:`dynamic-popup__option`,children:[(0,o.jsx)(`span`,{className:`dynamic-popup__option-tick${m?` dynamic-popup__option-tick--${m.tone}`:``}`,children:m&&(0,o.jsx)(i.Tooltip,{title:m.tooltip,placement:`topLeft`,children:(0,o.jsx)(a.CheckCircleFilled,{"aria-label":m.tooltip})})}),(0,o.jsxs)(`div`,{className:`dynamic-popup__option-main`,children:[(0,o.jsxs)(`div`,{className:`dynamic-popup__option-head`,children:[r&&(0,o.jsx)(`span`,{className:`dynamic-popup__option-id`,children:r}),(0,o.jsxs)(`span`,{className:`dynamic-popup__option-title`,children:[(0,o.jsx)(`span`,{className:`dynamic-popup__option-title-text`,children:s}),l&&(0,o.jsx)(`span`,{className:`dynamic-popup__option-title-accent${u?` dynamic-popup__option-title-accent--${u}`:``}`,children:`${d}${l}`})]}),p&&(0,o.jsx)(`span`,{className:`dynamic-popup__option-flag`,children:p})]}),c&&(0,o.jsx)(`div`,{className:`dynamic-popup__option-sub`,children:c})]}),e?.alreadySubmitted?(0,o.jsx)(`span`,{className:`dynamic-popup__option-onjob`,children:`On this job`}):f.length>0&&(0,o.jsx)(cx,{meta:f})]})}var{Text:ux}=i.Typography,{TextArea:dx}=i.Input,fx=[{label:`$`,value:`$`},{label:`EUR`,value:`EUR`},{label:`GBP`,value:`GBP`},{label:`INR`,value:`INR`}],px=[{label:`Hourly`,value:`Hourly`},{label:`Daily`,value:`Daily`},{label:`Weekly`,value:`Weekly`},{label:`Monthly`,value:`Monthly`},{label:`Yearly`,value:`Yearly`}];function mx(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 hx({field:e,value:t,onChange:n}){return(0,o.jsx)(i.Input,{value:t,onChange:n,placeholder:e.placeholder,maxLength:e.maxLength,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function gx({field:e,value:t,onChange:n}){return(0,o.jsx)(dx,{value:t,onChange:n,rows:e.rows??5,placeholder:e.placeholder})}function _x({field:e,options:t,value:n,onChange:r}){return(0,o.jsx)(i.Select,{value:n,onChange:r,options:mx(t),placeholder:e.placeholder,className:`dynamic-popup__field-select`,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function vx({field:e,options:t,value:n,onChange:r}){return(0,o.jsx)(i.Select,{mode:`multiple`,value:n,onChange:r,options:mx(t),placeholder:e.placeholder,className:`dynamic-popup__field-select`,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function yx({field:e,options:t,onSearch:n,value:r,onChange:s,popupContext:c}){let l=mx(t),u=e.optionLayout,d=new Map(l.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:c,confirm:i.Modal.confirm})===!1||s?.(t)}return(0,o.jsx)(i.Select,{showSearch:!0,filterOption:!1,notFoundContent:e.notFoundContent??null,value:r,onChange:f,options:l,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,o.jsx)(lx,{option:e?.data??e,layout:u}):void 0,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function bx({field:e,mentionOpts:t,onMentionSearch:n,value:r,onChange:a}){return(0,o.jsx)(i.Mentions,{value:r,onChange:a,rows:e.rows??5,placeholder:e.placeholder,prefix:`@`,options:t,onSearch:n,className:`dynamic-popup__mention-textarea`})}function xx({field:e={},value:t={},onChange:n}){let a=t.period??`Hourly`,s=t.isRange??!1;function c(e){n?.({...t,...e})}(0,r.useEffect)(()=>{let e={};t.currency??(e.currency=`$`),t.period??(e.period=`Hourly`),Object.keys(e).length&&n?.({...t,...e})},[]);let l=Number(s?t.maxAmount:t.amount),u=s&&t.minAmount!=null&&t.maxAmount!=null&&Number(t.maxAmount)<=Number(t.minAmount),d=e.rateCeiling!=null&&Number.isFinite(l)&&l>Number(e.rateCeiling);return(0,o.jsxs)(`div`,{children:[(0,o.jsxs)(i.Space.Compact,{style:{width:`100%`},children:[s?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.InputNumber,{controls:!1,placeholder:`From`,value:t.minAmount,onChange:e=>c({minAmount:e}),style:{flex:1}}),(0,o.jsx)(i.InputNumber,{controls:!1,placeholder:`To`,value:t.maxAmount,onChange:e=>c({maxAmount:e}),style:{flex:1}})]}):(0,o.jsx)(i.InputNumber,{controls:!1,placeholder:`0`,value:t.amount,onChange:e=>c({amount:e}),style:{flex:2}}),(0,o.jsx)(i.Select,{value:t.currency??`$`,options:fx,onChange:e=>c({currency:e}),style:{width:80}}),(0,o.jsx)(i.Select,{value:a,options:px,onChange:e=>c({period:e}),style:{width:110}})]}),(u||d)&&(0,o.jsxs)(`div`,{style:{marginTop:4},children:[u&&(0,o.jsx)(ux,{type:`danger`,style:{fontSize:12,display:`block`},children:`To rate must be greater than From rate.`}),d&&(0,o.jsxs)(ux,{type:`danger`,style:{fontSize:12,display:`block`},children:[`Rate must not exceed the client rate (`,e.rateCeiling,`).`]})]}),(0,o.jsxs)(i.Space,{size:`small`,style:{marginTop:8},children:[(0,o.jsx)(i.Switch,{checked:s,onChange:e=>c({isRange:e})}),(0,o.jsx)(`span`,{children:`Range`})]})]})}function Sx({field:e,value:t,onChange:n}){return(0,o.jsx)(i.DatePicker,{value:t,onChange:n,placeholder:e.placeholder??`Select date`,style:{width:`100%`},format:`YYYY-MM-DD`})}function Cx({field:e,checked:t,onChange:n}){return(0,o.jsx)(i.Checkbox,{checked:t,onChange:n,children:e.checkboxLabel})}function wx({field:e,value:t,onChange:n}){return(0,o.jsx)(i.InputNumber,{value:t,onChange:n,min:e.min,max:e.max,placeholder:e.placeholder,style:{width:`100%`}})}function Tx({options:e,value:t,onChange:n}){return(0,o.jsx)(i.Radio.Group,{value:t,onChange:n,options:e})}var Ex={input:hx,text:hx,textarea:gx,select:_x,"multi-select":vx,"search-select":yx,"mention-textarea":bx,"candidate-rate":xx,"priority-checkbox":Cx,"date-picker":Sx,number:wx,radio:Tx};function Dx(e){return e===`priority-checkbox`?{valuePropName:`checked`}:{}}var Ox=new Set([`input`,`text`,`textarea`,`mention-textarea`]);function kx({form:t,fields:n,initialValues:r,dynamicOptions:a,popupContext:s,extraData:c,removedIds:l,setRemovedIds:u,showAlreadyAssigned:d,onValuesChange:f,getSearchHandler:p,getMentionSearchHandler:m,mentionOptions:h}){let g=d&&c;return!n.length&&!g?null:(0,o.jsxs)(o.Fragment,{children:[g&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`dynamic-popup__already-assigned`,children:[(0,o.jsx)(e.Xn,{variant:`caption`,color:`secondary`,children:`Already Assigned People`}),(0,o.jsx)(`div`,{style:{marginTop:6,display:`flex`,flexWrap:`wrap`,gap:6},children:(c?.recruitersData??[]).filter(e=>{let t=String(e?.user_id??e?.id??e?.userId??``);return t&&!l.includes(t)}).map(e=>{let t=String(e?.user_id??e?.id??e?.userId??``),n=e?.name??e?.user_name??e?.userName??e?.email??t;return(0,o.jsx)(i.Tag,{closable:!0,onClose:()=>{t&&u(e=>Array.from(new Set([...e,t])))},children:n},t||n)})})]}),(0,o.jsx)(i.Divider,{style:{margin:`12px 0`}})]}),n.length>0&&(0,o.jsx)(i.Form,{form:t,layout:`vertical`,initialValues:r,onValuesChange:(e,t)=>f(t),children:Ax(n).map(t=>jx(t,t=>{let n=a[t.name]??ex(t,s),r=p(t),c=m(t),l=h[t.name]??[],u=Dx(t.type),d=Ex[t.type],f=[];return t.required&&f.push({required:!0,message:`${t.label||`This field`} is required`}),typeof t.validator==`function`&&f.push({validator:(e,n)=>{let r=t.validator(n,s);return r?Promise.reject(Error(r)):Promise.resolve()}}),Ox.has(t.type)&&f.push(e.q({label:t.label,field:t.name,type:t.type})),(0,o.jsx)(i.Form.Item,{name:t.name,label:t.label,rules:f,...u,children:d?(0,o.jsx)(d,{field:t,options:n,onSearch:r,mentionOpts:l,onMentionSearch:c,popupContext:s}):null},t.name)}))})]})}function Ax(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 jx(e,t){return e.length===1?t(e[0]):(0,o.jsx)(`div`,{style:{display:`flex`,gap:8,alignItems:`flex-start`},children:e.map((e,n)=>(0,o.jsx)(`div`,{style:{flex:n===0?2:1,minWidth:0},children:t(e)},e.name))},`row-${e.map(e=>e.name).join(`-`)}`)}function Mx({open:e,config:t,api:n,fields:i,popupContext:a,formValues:o}){let[s,c]=(0,r.useState)({}),[l,u]=(0,r.useState)(null);return(0,r.useEffect)(()=>{e||(c({}),u(null))},[e]),(0,r.useEffect)(()=>{if(!e||!t||!n.getOptions)return;let r=new AbortController;return i.forEach(e=>{!e.fetchOptionsKey||e.fetchOptionsParamKey||Promise.resolve(n.getOptions(e,void 0,a)).then(t=>{r.signal.aborted||c(n=>({...n,[e.name]:t}))}).catch(t=>{r.signal.aborted||console.error(`[DynamicPopup] Failed to load options for field "${e.name}":`,t)})}),()=>r.abort()},[e,n,t,i,a]),(0,r.useEffect)(()=>{if(!e||!t||!n.getOptions)return;let r=i.filter(e=>e.fetchOptionsKey&&e.fetchOptionsParamKey);if(!r.length)return;let s=new AbortController;return r.forEach(e=>{let t=o[e.fetchOptionsParamKey]??a[e.fetchOptionsParamKey],r={[e.fetchOptionsParamKey]:t};Promise.resolve(n.getOptions(e,r,a)).then(t=>{s.signal.aborted||c(n=>({...n,[e.name]:t}))}).catch(t=>{s.signal.aborted||console.error(`[DynamicPopup] Failed to load param-dependent options for "${e.name}":`,t)})}),()=>s.abort()},[e,n,t,i,o,a]),(0,r.useEffect)(()=>{if(!e||!t||!n.loadExtraData)return;let r=new AbortController;return Promise.resolve(n.loadExtraData(a)).then(e=>{r.signal.aborted||u(e)}).catch(e=>{r.signal.aborted||(console.error(`[DynamicPopup] Failed to load extra data:`,e),u(null))}),()=>r.abort()},[e,n,t,a]),{dynamicOptions:s,setDynamicOptions:c,extraData:l}}var Nx=500,Px=3;function Fx({api:e,open:t,fields:n=[],popupContext:i,setDynamicOptions:a}){let[o,s]=(0,r.useState)({}),c=(0,r.useRef)({}),l=(0,r.useRef)({}),u=(0,r.useRef)({}),d=(0,r.useCallback)((t,n)=>{let r=e.searchOptions??e.searchFetcher;if(typeof r!=`function`)return;l.current[t.name]?.abort();let o=new AbortController;return l.current[t.name]=o,Promise.resolve(r(t,n,i)).then(e=>{if(o.signal.aborted)return;let n=Array.isArray(e)?e:e?.items??e?.list??[];a(e=>({...e,[t.name]:n.map(e=>$b(e,t))}))}).catch(e=>{o.signal.aborted||console.error(`[DynamicPopup] Search failed for field "${t.name}":`,e)}),o},[e,i,a]),f=n.filter(e=>(e.searchFetchKey||e.searchFetcher)&&e.preloadOptions!==!1),p=f.map(e=>e.name).join(`|`),m=(0,r.useRef)({runSearch:d,preloadFields:f});(0,r.useEffect)(()=>{m.current={runSearch:d,preloadFields:f}}),(0,r.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??Px;return e=>{clearTimeout(c.current[t.name]);let r=e.length<n?``:e;c.current[t.name]=setTimeout(()=>{d(t,r)},Nx)}}function g(t){let n=e.getMentionOptions??e.mentionFetcher;if(typeof n==`function`)return e=>{u.current[t.name]?.abort();let r=new AbortController;u.current[t.name]=r,Promise.resolve(n(t,e,i)).then(e=>{if(r.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=>{r.signal.aborted||console.error(`[DynamicPopup] Mention search failed for field "${t.name}":`,e)})}}return{mentionOptions:o,getSearchHandler:h,getMentionSearchHandler:g}}function Ix({form:e,config:t,api:n,popupContext:a,resolvedIds:o,dynamicOptions:s,extraData:c,removedIds:l,fields:u,onClose:d,onSubmit:f}){let[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(null);async function _(e){let t={resolvedIds:o,dynamicOptions:s,extraData:c,removedIds:l};if(typeof n.submit==`function`)return n.submit(e,a,t);if(typeof f==`function`)return f(e,a,t)}function v(){if(t){if(!u.length){if(t.mode===`delete`&&typeof n.deleteItems==`function`){m(!0),g(null),Promise.resolve(n.deleteItems(o,a)).then(()=>{i.message.success(t.successMessage||`Deleted successfully`),d({success:!0})}).catch(e=>{let t=e?.message||`Delete failed. Please try again.`;g(t),m(!1),i.message.error(t)});return}if(typeof n.onOk==`function`){m(!0),Promise.resolve(n.onOk(a)).then(()=>d({success:!0})).catch(e=>{let t=e?.message||`Failed. Please try again.`;i.message.error(t),m(!1)});return}if(typeof n.submit==`function`){m(!0),Promise.resolve(_({})).then(e=>{e?.navigated||(i.message.success(t.successMessage||`Saved successfully`),d({success:!0}))}).catch(e=>{i.message.error(e?.message||`Failed. Please try again.`)}).finally(()=>m(!1));return}d();return}e.validateFields().then(async e=>{m(!0);try{if((await _(e))?.navigated)return;i.message.success(t.successMessage||`Saved successfully`),d({success:!0})}catch(e){i.message.error(e?.message||`Failed. Please try again.`)}finally{m(!1)}}).catch(()=>{})}}function y(){m(!1),g(null)}return{handleOk:v,confirming:p,deleteError:h,resetSubmitState:y}}function Lx({open:e=!0,config:t,context:n={},onClose:a,onSubmit:s,api:l={}}){let[u]=i.Form.useForm(),[d,f]=(0,r.useState)({}),[p,m]=(0,r.useState)([]),h=i.Form.useWatch([],u,{preserve:!0})??{},g=(0,r.useMemo)(()=>tx(n),[n]),{selectedIds:_=[],selectedRecords:v=[],moduleName:y=``}=g,b=(0,r.useMemo)(()=>_.map((e,t)=>{let n=v[t];return n?.id??n?._id??e}),[_,v]),x=(0,r.useMemo)(()=>t?typeof t.getFields==`function`?t.getFields(g):t.fields??[]:[],[t,g]),S=(0,r.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,c.default)(n):n)}),e},[x,g]),{dynamicOptions:C,setDynamicOptions:w,extraData:T}=Mx({open:e,config:t,api:l,fields:x,popupContext:g,formValues:d}),{mentionOptions:E,getSearchHandler:D,getMentionSearchHandler:O}=Fx({api:l,open:e,fields:x,popupContext:g,setDynamicOptions:w});function k(e){typeof a==`function`&&a(e)}let{handleOk:A,confirming:j,deleteError:M,resetSubmitState:N}=Ix({form:u,config:t,api:l,popupContext:g,resolvedIds:b,dynamicOptions:C,extraData:T,removedIds:p,fields:x,onClose:k,onSubmit:s});(0,r.useEffect)(()=>{e&&(u.resetFields(),f(S??{}),m(g.removedIds??[]),N())},[e,S]);let P=!!t?.autoSubmitWhenNoFields&&x.length===0;(0,r.useEffect)(()=>{!e||!P||A()},[e,P]);let F=_.length,I=String(y).replace(/s$/i,``),L=F===1?I:y,R=v[0]??{},z=t?.getTitleText?t.getTitleText(F,L,R,g):t?.title,B=F===1?R.jobTitle??R.title??R.name??R.fullName??R.candidateName??null:null,ee=t?.getBodyText?t.getBodyText(F,I,L,B,g):t?.bodyText??null,te=typeof t?.getNote==`function`?t.getNote(g):t?.note,V=x.filter(e=>e.required).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)}),ne=t?.disabledUntilFilled&&!V;if(!t||!e||P)return null;let re=t.component;return re?(0,o.jsx)(i.Modal,{open:e,title:t.title||t.getTitleText?(0,o.jsx)(Gb,{titleText:z,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,o.jsx)(re,{context:g,selectedIds:b,selectedRecords:v,moduleName:y,onClose:k})}):(0,o.jsxs)(i.Modal,{open:e,title:(0,o.jsx)(Gb,{titleText:z,titleIcon:t.titleIcon}),okText:t.okText||`OK`,cancelText:t.cancelText??`Cancel`,onOk:A,onCancel:()=>k(),okButtonProps:{danger:t.okButtonDanger,disabled:ne,loading:j},cancelButtonProps:{disabled:j},closable:!j,maskClosable:!1,width:t.width??480,centered:!0,className:`dynamic-popup${t.className?` ${t.className}`:``}`,children:[(0,o.jsx)(Kb,{note:te,description:t.description,showSelectedCount:t.showSelectedCount,count:F,itemLabel:L,bodyText:ee,deleteError:M}),(0,o.jsx)(qb,{footerNote:t.footerNote}),(0,o.jsx)(kx,{form:u,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 Rx={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:[]},zx={deleteItems:async(e,t)=>{await I(t.moduleName,e)}},Bx=`Already submitted`,Vx=1440*60*1e3,Hx=90,Ux=`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.`,Wx=[`createdAt`,`createdDate`,`dateCreated`,`created_on`,`createdOn`],Gx=[`updatedAt`,`updatedDate`,`lastUpdatedAt`,`lastUpdatedDate`,`modifiedAt`,`modifiedDate`];function Kx(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 qx(e){return Kx(e,Wx)}function Jx(e){return Kx(e,Gx)}function Yx(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))/Vx))}function Xx(e){if(!(e instanceof Date)||Number.isNaN(e.getTime()))return null;let t=new Date,n=(t.getFullYear()-e.getFullYear())*12+(t.getMonth()-e.getMonth());return t.getDate()<e.getDate()&&--n,Math.max(0,n)}function Zx(e){if(!(e instanceof Date)||Number.isNaN(e.getTime()))return null;let t=new Date,n=t.getFullYear()-e.getFullYear();return(t.getMonth()<e.getMonth()||t.getMonth()===e.getMonth()&&t.getDate()<e.getDate())&&--n,Math.max(0,n)}function Qx(e){return e===null?``:e<=14?`green`:e<=89?`yellow`:`red`}function $x(e,t=Hx){if(!e)return!1;let n=Date.now()-t*Vx,r=qx(e),i=Jx(e),a=r&&r.getTime()>=n,o=i&&i.getTime()>=n;return!a&&!o}function eS(e){let t=Jx(e);if(!t)return{createdAgo:``,createdAgoTone:``};let n=Yx(t),r=Xx(t),i=Zx(t);return i>=1?{createdAgo:`${i} year${i===1?``:`s`} ago`,createdAgoTone:Qx(n)}:r>=1?{createdAgo:`${r} month${r===1?``:`s`} ago`,createdAgoTone:Qx(n)}:{createdAgo:Xb(t),createdAgoTone:Qx(n)}}function tS(e){return{...e,...eS(e),isStaleCandidate:$x(e)}}function nS(e){return String(e?.applicantId??e?._id??e?.id??``)}function rS(e){let t=nS(e);return`/candidates/edit/${encodeURIComponent(t)}`}async function iS({option:e,popupContext:t,confirm:n}){let r=e?._raw??e??{};if(!$x(r))return!0;let i=t?.navigate,a=nS(r);return!i||!a?!1:new Promise(e=>{n({title:`Candidate update required`,content:Ux,okText:`OK`,cancelText:`Cancel`,onOk:()=>{i(rS(r)),e(!1)},onCancel:()=>e(!1)})})}function aS(e,t,n){return{...e,label:`${e.label} - ${Bx}`,disabled:!0,title:`${Bx}${t?` (submission ${t})`:``}`,alreadySubmitted:!0,existingSubmissionId:t||``,...n?{submittedAt:n}:{}}}var oS={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 de({searchQuery:t,candidateId:r})}catch{a=!1;let e=await ln({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 aS(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 fe({applicantId:r,jobIds:o.map(e=>e.value)}).catch(()=>new Map);return o.map(e=>{let t=s.get(String(e.value));return t?aS(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 J({search:t,jobId:r})}catch{let e=await Ha({isFromSubmission:n.isFromSubmission,jobId:r,submissionId:n.submissionId,search:t});i=Array.isArray(e)?e:[],a=await fe({jobId:r,applicantIds:i.map(nS)}).catch(()=>new Map)}return i.map(e=>tS(e)).map(e=>{let t=a.get(nS(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:Bx,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=>nS(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($x(u?._raw))throw Error(Ux);let p=f,m=u?._raw?.existingSubmissionId||u?._raw?.jobSubmissionId||d?.existingSubmissionId||d?._raw?.jobSubmissionId||``;try{let e=await q({jobId:c,applicantId:l});p||=!!e?.exists,m=e?.submissionId||m}catch(e){throw Error(`Could not verify existing submissions (${e?.message??`request failed`}). Please try again.`,{cause:e})}if(p)throw Error(`This candidate is already submitted for this job${m?` (submission ${m})`:``}.`);let h=new URLSearchParams;l&&h.set(`candidateId`,l);let g=u?.priorSubmissionId||u?._raw?.submissionId||d?.priorSubmissionId||d?._raw?.submissionId||``;return g?(h.set(`submissionId`,String(g)),h.set(`isFromSubmission`,`true`)):h.set(`isFromSubmission`,`false`),r(`/submission-create/${c}?${h.toString()}`),{navigated:!0}}},sS={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:iS}]},cS={title:`Add Notes & Share`,okText:`Save & Share`,width:480,fields:[{name:`notes`,type:`mention-textarea`,required:!0,rows:5,placeholder:`Add your notes on the job. Use '@' to mention someone.`,mentionFetchKey:`mentionUsers`}]},lS=e=>e?.data??e;async function uS({relatedId:e,notes:n,title:r,notesFor:i}){return lS(await Wt(t.b,`/notes`,{method:`POST`,body:JSON.stringify({relatedId:e,notes:n,title:r,notesFor:i})}))}var dS={getMentionOptions:async(e,t)=>R(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 uS({relatedId:String(n),notes:e.notes,notesFor:t.moduleName})}},fS={name:`jobId`,label:`Job Title / ID`,type:`search-select`,required:!0,placeholder:`Minimum 3 characters`,searchFetchKey:`tagToJobJobList`,valueKey:`_id`,labelTemplate:`{jobReferenceId} - {jobTitle}`},pS={name:`hiringStage`,label:`Hiring stage`,type:`select`,required:!0,optionsKey:`hiringStageOptions`,defaultOptions:[{label:`Shortlisted`,value:`shortlisted`},{label:`Pipeline`,value:`pipeline`}],initialValueKey:`hiringStage`},mS={title:`Tag to Job`,okText:`Tag`,width:480,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getFields:e=>e.jobId&&e.hiringStage?[]:e.jobId?[pS]:[fS,pS]},hS=e=>e?.data??e;function gS(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 _S(e){return e?Array.isArray(e.data)?e.data.map(gS):e.stage&&Array.isArray(e.stage.data)?e.stage.data.map(gS):Array.isArray(e)?e.map(gS):[]:[]}async function vS(e=1,n=10){let r=await t.a(t.b,`/workflow/list/all?page=${e}&limit=${n}`),i=hS(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 yS(e=100){let t=await vS(1,e),n=[...t.items],r=t.total,i=2;for(;n.length<r;){let t=await vS(i,e);if(!t.items.length)break;n.push(...t.items),i+=1}return{items:n,total:Math.max(r,n.length)}}async function bS(e,n){let r=hS(await t.a(t.b,`/workflow/${e}/stage/${n}`));return Array.isArray(r)?{data:r}:r}async function xS(e,n){if(!e||!n)return null;try{let r=hS(await t.a(t.b,`/module-data-list?${new URLSearchParams({module:e,limit:`1`,offset:`0`,scope:`allJobs`,filters:JSON.stringify([{field:`_id`,op:`in`,values:[String(n)],operator:`and`}])})}`));if(Array.isArray(r))return r[0]??null;if(r?.data&&Array.isArray(r.data))return r.data[0]??null;let i=r?.rows??r?.records??r?.items??r?.list;return Array.isArray(i)?i[0]??null:r??null}catch(t){return console.error(`[getModuleRecordById] failed: ${e}/${n}`,t),null}}async function SS(e){return hS(await t.a(t.S,`/source/workflow-instance`,{method:`POST`,body:JSON.stringify(e)}))}var CS={pipeline:`pipeline`,goodfited:`goodfited`,contacted:`contacted`,submitted:`submitted`,shortlisted:`shortlisted`,interviewinprogress:`interviewInprogress`,selected:`selected`};function wS(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 TS(e){let t=String(e??``).trim();return t?CS[t.toLowerCase()]??t:``}function ES(e,t){let n=wS(e,`candidateId`,`candidate_id`,`applicantId`,`applicantID`,`applicantReferenceId`,`applicantRefrenceId`,`_id`,`id`)??t;if(!n)return null;let r=(wS(e,`candidateName`,`candidate_name`,`fullName`,`name`)??[wS(e,`firstName`,`first_name`),wS(e,`lastName`,`last_name`)].filter(Boolean).join(` `))||void 0,i={candidateId:String(n),candidateName:r,phone:wS(e,`phone`,`phoneNumber`,`phone_number`,`mobile`,`mobileNumber`,`mobile_number`),source:wS(e,`source`,`sourceType`,`candidateSource`,`profileSource`),submittedAt:wS(e,`submittedAt`,`lastSubmittedAt`,`updatedAt`),remarks:wS(e,`remarks`,`comment`,`comments`,`notes`),assignedRecruiter:wS(e,`assignedRecruiter`,`recruiterName`,`ownerName`,`assignedToName`),screeningStatus:wS(e,`screeningStatus`,`screening.status`,`screeningResult`),screeningScore:wS(e,`screeningScore`,`screening.score`,`score`),assignedDate:wS(e,`assignedDate`,`assignedAt`,`createdAt`)};return Object.fromEntries(Object.entries(i).filter(([,e])=>e!=null&&e!==``))}var DS={searchOptions:async(e,t)=>e.searchFetchKey===`tagToJobJobList`?L(t):[],submit:async(e,t)=>{let n=e.jobId??t.jobId,r=TS(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=ES(a[e]??{},t);await SS({jobId:n,module:`jobs`,currentStage:r,...o?{candidateDetails:o}:{}})}await te({jobId:n,candidateIds:t.selectedIds,hiringStage:r})}},OS={title:`Change Status`,okText:`Apply`,width:420,showSelectedCount:!0,fields:[{name:`status`,label:`New Status`,type:`select`,required:!0,placeholder:`Select a status`,optionsKey:`statusOptions`,initialValueKey:`currentStatus`,defaultOptions:[{label:`Active`,value:`active`},{label:`Inactive`,value:`inactive`},{label:`Pending`,value:`pending`},{label:`Closed`,value:`closed`}]}]},kS={submit:async(e,t)=>{await F(t.moduleName,t.selectedIds,e.status)}},AS={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:[]},jS={onOk:async e=>{await pe({jobId:e.jobId??e.selectedIds[0],candidateIds:e.selectedIds})}},MS={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`}]},NS={getOptions:async e=>e.fetchOptionsKey===`candidateGroups`?V():[],submit:async(e,t,{dynamicOptions:n})=>{let r=(n.groupId??[]).find(t=>String(t.value)===String(e.groupId));await ne({candidateIds:t.selectedIds,groupId:e.groupId,groupName:r?.label??``})}},PS=[{title:`Name`,key:`name`,render:(e,t)=>`${t.first_name??``} ${t.last_name??``}`.trim()||t.user_name||t.name||`-`},{title:`Role`,dataIndex:`role_name`,key:`role`,render:e=>e||`-`},{title:`Reporting`,dataIndex:`reporting_name`,key:`reporting`,render:e=>e||`-`}];function FS({selectedIds:e,onClose:t}){let n=e?.[0],[s,c]=(0,r.useState)(!0),[l,u]=(0,r.useState)(!1),[d,f]=(0,r.useState)({assignedUsers:[],totalSubmissions:0,message:``}),[p,m]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=!1;return c(!0),Promise.all([H(n).catch(t=>(e||i.message.error(t?.message??`Failed to load self-assign details`),{assignedUsers:[],totalSubmissions:0,message:``})),G(n).catch(()=>({recruitersData:[]}))]).then(([t,n])=>{e||(f(t),m(Array.isArray(n?.recruitersData)?n.recruitersData:[]))}).finally(()=>{e||c(!1)}),()=>{e=!0}},[n]);let h=async()=>{u(!0);try{await re({jobIds:[n]}),i.message.success(`Job assigned successfully`),t?.({success:!0})}catch(e){i.message.error(e?.message??`Failed to assign job`)}finally{u(!1)}};if(s)return(0,o.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,o.jsx)(i.Spin,{size:`large`})});let g=(d.assignedUsers?.length??0)>0?d.assignedUsers:p.map(e=>({user_id:e.recruiterId??e.id??e.user_id,first_name:e.name??``,role_name:e.role_name??``,reporting_name:e.reporting_name??``}));return(0,o.jsxs)(`div`,{className:`self-assign-popup-body`,children:[g.length>0?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`div`,{style:{fontWeight:700,marginBottom:8},children:`Team Members Allocated`}),(0,o.jsx)(i.Table,{columns:PS,dataSource:g,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,o.jsxs)(`div`,{className:`warning-card`,style:{display:`flex`,alignItems:`center`,gap:8,marginTop:12},children:[(0,o.jsx)(a.ExclamationCircleFilled,{style:{color:`#faad14`,fontSize:18}}),(0,o.jsx)(`div`,{style:{fontSize:13},children:`These users are already assigned to this job. Do you still want to assign yourself as well?`})]})]}):(0,o.jsx)(`div`,{style:{padding:`8px 0`},children:d.message||`No one is assigned. Be the first to assign!`}),(0,o.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:12,marginTop:24},children:[(0,o.jsx)(i.Button,{size:`small`,onClick:()=>t?.(),disabled:l,children:`No`}),(0,o.jsx)(i.Button,{type:`primary`,size:`small`,onClick:h,loading:l,children:`Yes`})]})]})}FS.propTypes={selectedIds:l.default.array,onClose:l.default.func};var IS={title:`Self Assign`,width:480,className:`self-assign-modal`,component:FS},LS={submit:async()=>{}};function RS(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}function zS(e,t){let n=e??{};if(n.isRange&&n.minAmount!=null&&n.maxAmount!=null&&Number(n.maxAmount)<=Number(n.minAmount))return`To rate must be greater than From rate.`;let r=RS(t?.selectedRecords?.[0]??{}),i=n.isRange?Number(n.maxAmount):Number(n.amount);return r!=null&&Number.isFinite(i)&&i>r?`Candidate rate must not exceed the client rate (${r}).`:``}var BS={getTitleText:(e,t,n)=>{let r=n?.jobTitle||n?.title||``;return r?`Assign - ${r}`:`Assign`},okText:`Assign`,width:520,disabledUntilFilled:!0,showAlreadyAssigned:!0,getFields:e=>[{name:`assignToUserId`,label:`Assign to`,type:`multi-select`,required:!0,placeholder:`Select recruiter(s)`,fetchOptionsKey:`assignToUsers`},{name:`candidateRate`,label:`Candidate Rate`,type:`candidate-rate`,rateCeiling:RS(e?.selectedRecords?.[0]??{}),validator:zS},{name:`priority`,label:`Priority`,type:`priority-checkbox`,checkboxLabel:`Mark as High`}]},VS={getOptions:async e=>e.fetchOptionsKey===`assignToUsers`?W():[],loadExtraData:async e=>G(e.selectedIds[0]),submit:async(e,t,{removedIds:n,extraData:r})=>{await ae({jobIds:t.selectedIds,userId:e.assignToUserId,rate:e.candidateRate,priority:e.priority,removedIds:n,existingRecruiters:r?.recruitersData})}},HS={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`}]},US={getMentionOptions:async(e,t)=>R(t),submit:async(e,t)=>{let n=e.targetDate?e.targetDate.toISOString():``;t.editingNoteId?await B(t.editingNoteId,{title:e.heading,targetDate:n,notes:e.comments}):await z({relatedIds:t.selectedIds,module:t.moduleName,title:e.heading,targetDate:n,notes:e.comments}),window.dispatchEvent(new Event(`sticky-notes:refresh`))}},WS={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`}]},GS={submit:async(e,t)=>{await oe({submissionId:t.selectedRecords?.[0]?.submissionId,isMail:e.sendOnboardingEmail})}};function KS(e){return Array.isArray(e)?e[e.length-1]??{}:e&&typeof e==`object`?e:{}}var qS={USD:`$`,INR:`₹`,EUR:`€`,GBP:`£`};function JS(e,t,n){let r=KS(e?.[t])[n];if(r!=null&&r!==``)return r;let i=e?.[`${t}.${n}`];return i!=null&&i!==``?i:void 0}function YS(e){let t=e.selectedRecords?.[0]??{},n=JS(t,`candidateRate`,`candidateAcceptedRate`)??JS(t,`candidateBudget`,`candidateBudgetStart`);if(n===void 0||Number(n)===0)return null;let r=JS(t,`candidateRate`,`candidateAcceptedCurrency`)??JS(t,`candidateBudget`,`candidateBudgetCurrency`);return{amount:n,symbol:JS(t,`candidateRate`,`candidateAcceptedCurrencySymbol`)??JS(t,`candidateBudget`,`candidateBudgetCurrencySymbol`)??qS[String(r??``).toUpperCase()]??(r||`$`),unit:JS(t,`candidateRate`,`candidateAcceptedPayUnit`)??JS(t,`candidateBudget`,`candidateBudgetUnit`)??``}}var XS={title:`Approve Rate`,okText:`Approve`,width:520,className:`medium-modal`,successMessage:`Rate approved`,getBodyText:(e,t,n,r,i)=>{let a=YS(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=YS(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`}]}]},ZS={submit:async(e,t)=>{let n=t.selectedIds[0];if(await se(n,{candidateProposedRate:e.candidateProposedRate,candidateProposedRateCurrency:e.candidateProposedRateCurrency,candidateProposedRateUnit:e.candidateProposedRateUnit,submitVia:e.submitVia}),e.submitVia===`VMS`)try{await ce(n)}catch{i.message.warning(`Approved. VMS notification could not be sent — use Send Mail to notify the client.`)}else i.message.info(`Approved — use Send Mail to notify the client.`)}};function QS(e,t={}){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:t.employerName??e.supplierName??e.submitSource,submittedBy:t.submittedBy??e.signatureEmail??e.recruiterName,submittedAt:t.createdAt??e.createdAt,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function $S({context:e,selectedIds:t,selectedRecords:n,moduleName:a,onClose:s}){let c=n?.[0]??{},l=t?.[0]??Sp(c),[u,d]=(0,r.useState)(null),[f,p]=(0,r.useState)(!0);(0,r.useEffect)(()=>{let e=!1;return p(!0),Zp(l,c).then(t=>{e||d(t)}).catch(t=>{e||(i.message.error(t?.message??`Unable to load finance details`),d({record:{submission:c},lookups:{},display:{}}))}).finally(()=>{e||p(!1)}),()=>{e=!0}},[l]);let m=(0,r.useMemo)(()=>({submissionApprove:async({computed:e})=>{await se(l,{candidateProposedRate:e.proposedRate,candidateProposedRateCurrency:e.currency,candidateProposedRateUnit:`hr`,submitVia:`Mail`}),i.message.success(`Submission approved`),s?.({success:!0})},submissionReject:async()=>{e?.navigate?.(`/popup/reject`,{replace:!0,state:{background:e?.background??null,selectedIds:t,selectedRecords:n,moduleName:a}})}}),[l,e,t,n,a,s]);return f||!u?(0,o.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,o.jsx)(i.Spin,{size:`large`})}):(0,o.jsx)(Hp,{type:np,record:u.record,lookups:u.lookups,identity:QS(c,u.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:m,onClose:()=>s?.(),variant:`popup`})}$S.propTypes={context:l.default.object,selectedIds:l.default.array,selectedRecords:l.default.array,moduleName:l.default.string,onClose:l.default.func};var eC={title:`Manager Approve`,width:780,className:`fa-modal manager-approve-modal`,component:$S},tC={submit:async()=>{}};function nC(e,t={}){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:t.employerName??e.supplierName??e.submitSource,submittedBy:t.submittedBy??e.signatureEmail??e.recruiterName,submittedAt:t.createdAt??e.createdAt,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function rC(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 iC(e){return String(e??``).toLowerCase().replace(/\b\w/g,e=>e.toUpperCase())}function aC({selectedIds:t,selectedRecords:n,onClose:a}){let s=n?.[0]??{},c=t?.[0]??Sp(s),[l,u]=(0,r.useState)(null),[d,f]=(0,r.useState)(``),[p,m]=(0,r.useState)(!0);(0,r.useEffect)(()=>{let t=!1;return m(!0),Promise.all([Zp(c,s),e.at(`submission`,c).catch(()=>[])]).then(([e,n])=>{if(t)return;let r=rC(n);f(Sp(e?.meta?.workforceEngagementId??s?.onboarding?.workforceEngagementId??s?.workforceEngagementId));let i=e?.meta?.rejectReasonComments||r?.activityComments||``;u({...e,record:{...e.record,submission:{...e.record.submission,cfoRejectionReason:i?iC(i):``,cfoRejectedAt:e?.meta?.rejectedAt??r?.activityTime??null}}})}).catch(e=>{t||(i.message.error(e?.message??`Unable to load finance details`),u({record:{submission:s},lookups:{},display:{}}))}).finally(()=>{t||m(!1)}),()=>{t=!0}},[c]);let h=(0,r.useMemo)(()=>({submissionReapproveSend:async({computed:e})=>{await le(d,{submissionId:c,billRate:e.proposedRate,payRate:e.employerRate,currency:e.currency,referralRate:e.referralRate,vmsPercent:e.clientVmsPercent}),await se(c,{candidateProposedRate:e.proposedRate,candidateProposedRateCurrency:e.currency,candidateProposedRateUnit:`hr`,submitVia:`Mail`}),i.message.success(`Re-approved and sent for CFO approval`),a?.({success:!0})}}),[c,d,a]);return p||!l?(0,o.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,o.jsx)(i.Spin,{size:`large`})}):(0,o.jsx)(Hp,{type:op,record:l.record,lookups:l.lookups,identity:nC(s,l.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:h,onClose:()=>a?.(),variant:`popup`})}aC.propTypes={selectedIds:l.default.array,selectedRecords:l.default.array,onClose:l.default.func};var oC={title:`Re-Approve`,width:780,className:`fa-modal manager-approve-modal`,component:aC},sC={submit:async()=>{}},cC=[{id:1,name:`Re-Submission`},{id:2,name:`Candidate doesn't fit into the profile`},{id:3,name:`Incomplete candidate details - (Re-Submission)`}],lC={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:cC.map(e=>({label:e.name,value:e.id}))},{name:`rejectReasonComments`,label:`Comments`,type:`textarea`,required:!0,rows:4}]},uC={submit:async(e,t)=>{let n=cC.find(t=>String(t.id)===String(e.rejectReason));await ue({submissionId:t.selectedIds[0],rejectReasonId:e.rejectReason,rejectReason:n?.name??``,rejectReasonComments:e.rejectReasonComments})}},dC={delete:Rx,"quick-submit":sS,"add-notes":cS,"tag-to-job":mS,"change-status":OS,"remove-from-shortlist":AS,"add-to-groups":MS,"self-assign":IS,"others-assign":BS,"sticky-notes":HS,"move-to-onboarding":WS,"approve-rate":XS,"manager-approve":eC,"manager-reapprove":oC,reject:lC},fC={delete:zx,"quick-submit":oS,"add-notes":dS,"tag-to-job":DS,"change-status":kS,"remove-from-shortlist":jS,"add-to-groups":NS,"self-assign":LS,"others-assign":VS,"sticky-notes":US,"move-to-onboarding":GS,"approve-rate":ZS,"manager-approve":tC,"manager-reapprove":sC,reject:uC};function pC(e){let t=e?.data??e;return Array.isArray(t)?t:t?.data??t?.rows??t?.records??t?.items??t?.list??[]}function mC(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 hC(e){let t=String(mC(e,`isDeleted`,`deleted`)).toLowerCase(),n=String(mC(e,`assignmentStatus`,`status`)).toLowerCase();return t!==`true`&&t!==`1`&&![`removed`,`inactive`,`deleted`].includes(n)}function gC(e){let t=mC(e,`candidateName`,`candidate_name`,`fullName`,`name`);return t?String(t):[mC(e,`firstName`,`first_name`),mC(e,`lastName`,`last_name`)].filter(Boolean).join(` `)||`Unnamed candidate`}function _C(e){return String(mC(e,`candidateId`,`candidate_id`,`candidate._id`,`candidate.id`))}function vC(e){return String(mC(e,`workforceEngagementId`,`engagementId`,`_id`,`id`))}function yC(e){return String(mC(e,`batchName`,`name`,`title`,`batch_name`))}function bC({open:n=!0,context:a={},onClose:s}){let[c,l]=(0,r.useState)([]),[u,d]=(0,r.useState)([]),[f,p]=(0,r.useState)(``),[m,h]=(0,r.useState)(!0),[g,_]=(0,r.useState)(!1),[v,y]=(0,r.useState)(``),[b,x]=(0,r.useState)(new Map),S=String(a.selectedIds?.[0]??a.selectedRecords?.[0]?._id??a.selectedRecords?.[0]?.id??a.batchId??``);(0,r.useEffect)(()=>{if(!n)return;let t=!1;return Promise.resolve().then(()=>(t||h(!0),Promise.all([e.Wn(`onboarding`,200,0),e.Wn(`batchCandidates`,1e3,0).catch(()=>[])]))).then(([e,n])=>{t||(l(pC(e)),x(new Map(pC(n).filter(hC).map(e=>[String(mC(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}},[n]);let C=(0,r.useMemo)(()=>{let e=f.trim().toLowerCase();return e?c.filter(t=>[gC(t),mC(t,`email`,`candidateEmail`,`candidate_email`),mC(t,`status`,`onboardingStatus`,`onboarding_status`)].some(t=>String(t).toLowerCase().includes(e))):c},[c,f]);async function w(){if(!S){y(`Select a batch before adding candidates`);return}let n=c.filter(e=>u.includes(vC(e)));if(!n.length)return;let r=n.map(e=>({record:e,assignment:b.get(_C(e))})).filter(e=>e.assignment);if(r.length){y(`${r.map(({record:e})=>gC(e)).join(`, `)} ${r.length===1?`is`:`are`} already added to a batch. Each candidate can be added to only one batch.`);return}_(!0),y(``);try{let{userId:r}=t.o(),o=yC(a.selectedRecords?.[0])||yC(a);await Promise.all(n.map(t=>e.bt(`batchCandidates`,{schemaVersion:1,batchId:S,batchName:o,candidateId:_C(t),workforceEngagementId:vC(t),source:`ONBOARDING`,assignmentStatus:`ASSIGNED`,assignedAt:new Date().toISOString(),assignedBy:r??0,isDeleted:!1}))),i.message.success(`${n.length} candidate${n.length===1?``:`s`} added to the batch`),s?.({refresh:!0})}catch(e){y(e.message||`Unable to add candidates to the batch`)}finally{_(!1)}}return(0,o.jsxs)(i.Modal,{open:n,title:`Add Candidate to Batch`,okText:`Add`,onOk:w,onCancel:()=>s?.(),okButtonProps:{disabled:u.length===0||!S,loading:g},cancelButtonProps:{disabled:g},closable:!g,maskClosable:!1,width:760,centered:!0,children:[v&&(0,o.jsx)(i.Alert,{type:`error`,showIcon:!0,message:v,style:{marginBottom:12}}),(0,o.jsx)(i.Input.Search,{allowClear:!0,placeholder:`Search onboarding candidates`,value:f,onChange:e=>p(e.target.value),style:{marginBottom:12}}),(0,o.jsx)(i.Table,{rowKey:e=>vC(e),columns:[{title:`Candidate`,key:`candidate`,render:(e,t)=>gC(t)},{title:`Email`,key:`email`,render:(e,t)=>mC(t,`email`,`candidateEmail`,`candidate_email`)||`—`},{title:`Onboarding status`,key:`status`,render:(e,t)=>mC(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(_C(e));return{disabled:!_C(e)||!vC(e)||!!t,title:t?`Candidate is already added to a batch`:void 0}}},locale:{emptyText:m?`Loading candidates…`:`No onboarding candidates found`}})]})}var xC={text:`input`,string:`input`,textarea:`textarea`,date:`date-picker`,datepicker:`date-picker`,multiselect:`multi-select`,lookup:`search-select`};function SC(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:xC[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}))})));return{title:e.label,fields:t}}function CC({apiMap:n={},extraConfigs:i={}}){let a=(0,r.useMemo)(()=>({...fC,...n}),[n]),c=(0,r.useMemo)(()=>{let e={...dC};return Object.entries(i).forEach(([t,n])=>{e[t]={...e[t]??{},...n}}),e},[i]),{popupKey:l}=(0,s.useParams)(),u=(0,s.useNavigate)(),{state:d={}}=(0,s.useLocation)(),[f,p]=(0,r.useState)({key:``,config:null});(0,r.useEffect)(()=>{let t=!1;if(!l||!d.moduleName)return;let n=`${d.moduleName}:${l}`;return e.Gt(d.moduleName,`popup`,l).then(e=>{t||p({key:n,config:SC(e[0])})}).catch(()=>{t||p({key:n,config:null})}),()=>{t=!0}},[l,d.moduleName]);let m=(0,r.useMemo)(()=>{let e=c[l],t=`${d.moduleName}:${l}`,n=f.key===t?f.config:null;return n?{...e,...n}:e},[f,c,l,d.moduleName]),h=(0,r.useMemo)(()=>({selectedIds:d.selectedIds??[],selectedRecords:d.selectedRecords??[],moduleName:d.moduleName??``,navigate:u,background:d.background??null,...d.popupContext??{}}),[u,d.selectedIds,d.selectedRecords,d.moduleName,d.popupContext,d.background]),g=(0,r.useMemo)(()=>{let e=d.popupAction;return e?.apiPath?{submit:(n,r)=>{let i=String(e.apiMethod||`POST`).toUpperCase();return t.a(t.b,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})})}}:{}},[d.popupAction]),_=e=>{let t=d.background;if(e?.success&&m?.successNavigate){u(m.successNavigate,{replace:!0,state:{refreshTimestamp:Date.now()}});return}if(e?.success&&t?.pathname){u(`${t.pathname}${t.search??``}`,{replace:!0,state:{...t.state??{},refreshTimestamp:Date.now()}});return}u(-1)};return l===`add-batch-candidate`?(0,o.jsx)(bC,{open:!0,context:h,onClose:_}):(0,o.jsx)(Lx,{open:!0,config:m,context:h,onClose:_,api:{...a[l]??{},...g}})}var wC={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`}]},TC={getVendorList:({jobId:e,limit:t,offset:n,type:r})=>It({jobId:e,limit:t,offset:n,sortBy:`new`,type:r}),getMailDetails:e=>Lt(e),submit:({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})=>Rt({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})},EC=wC.vendorColumns.map(e=>({...e,render:e=>e||`-`}));function DC(){let e=(0,s.useNavigate)(),t=(0,s.useLocation)(),{selectedIds:n=[],selectedRecords:c=[],recipients:l=[],subject:u=``,onSend:d,moduleName:f=``,popupAction:p={}}=t.state??{},m=n[0]??c[0]?._id??c[0]?.id,[h,g]=(0,r.useState)({to:l.join(`, `),cc:``,bcc:``,subject:u,contents:``,showCc:!1,showBcc:!1}),[_,v]=(0,r.useState)(!m),[y,b]=(0,r.useState)(wC.defaultTab),[x,S]=(0,r.useState)(``),[C,w]=(0,r.useState)([]),[T,E]=(0,r.useState)(0),[D,O]=(0,r.useState)(0),[k,A]=(0,r.useState)(0),[j,M]=(0,r.useState)(1),[N,P]=(0,r.useState)(wC.defaultPageSize),[F,I]=(0,r.useState)(!1),[L,R]=(0,r.useState)([]);(0,r.useEffect)(()=>{if(!m)return;let e=!1;I(!0);let t=x?100:N,n=x?0:(j-1)*N;return TC.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,r.useEffect)(()=>{m&&TC.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,r.useMemo)(()=>L.map(e=>C.find(t=>t.vendorId===e)?.vendorEmail??``).filter(Boolean),[L,C]),B=(0,r.useMemo)(()=>({...h,bcc:[...new Set([...$y(h.bcc),...z])].join(`, `),showBcc:h.showBcc||z.length>0}),[h,z]);function ee(e){let t=new Set(z);g({...e,bcc:$y(e.bcc).filter(e=>!t.has(e)).join(`, `)})}let te=($y(B.to).length||$y(B.bcc).length)&&eb(B.to)&&eb(B.cc)&&eb(B.bcc)&&B.subject.trim(),V=e=>e===`myVendor`?T:D;function ne(){e(-1)}function re(){te&&TC.submit({jobId:m,toMail:$y(B.to),ccMail:$y(B.cc),bccMail:$y(B.bcc),subject:B.subject,contents:B.contents}).then(t=>{t?.status===!0?(i.message.success(t?.data||`Mail sent successfully.`),typeof d==`function`&&d({...B,message:B.contents,selectedIds:n}),e(-1)):i.message.error(t?.message||t?.data||`Failed to send mail. Please try again.`)}).catch(e=>{i.message.error(e?.message||`Failed to send mail. Please try again.`)})}let H=(0,r.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,o.jsx)(i.Drawer,{open:!0,placement:`right`,onClose:ne,closable:!1,rootClassName:`vendor-share`,width:`95%`,footer:(0,o.jsxs)(`div`,{className:`vendor-share__footer`,children:[(0,o.jsx)(i.Button,{onClick:ne,children:`Cancel`}),(0,o.jsx)(i.Button,{type:`primary`,disabled:!te,onClick:re,children:`Send`})]}),children:(0,o.jsxs)(`div`,{className:`vendor-share__body`,children:[(0,o.jsxs)(`div`,{className:`vendor-share__left`,children:[(0,o.jsxs)(`div`,{className:`vendor-share__vendor-header`,children:[(0,o.jsxs)(`div`,{className:`vendor-share__vendor-header-row`,children:[(0,o.jsx)(i.Button,{type:`text`,icon:(0,o.jsx)(a.CloseOutlined,{}),onClick:ne,size:`small`,style:{marginRight:8}}),(0,o.jsx)(`span`,{className:`dynamic-popup__header-icon-box`,children:(0,o.jsx)(a.TeamOutlined,{})}),(0,o.jsx)(`span`,{className:`dynamic-popup__header-label`,children:`Vendor List`}),(0,o.jsxs)(`div`,{className:`vendor-share__vendor-search`,children:[(0,o.jsx)(a.SearchOutlined,{className:`vendor-share__search-icon`}),(0,o.jsx)(i.Input,{variant:`borderless`,placeholder:`Search vendor`,value:x,onChange:e=>{S(e.target.value),M(1)},className:`vendor-share__search-input`})]})]}),(0,o.jsx)(`div`,{className:`vendor-share__vendor-tabs`,children:wC.vendorTabs.map(e=>(0,o.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,` (`,V(e.key),`)`]},e.key))})]}),(0,o.jsx)(`div`,{className:`vendor-share__vendor-table-wrapper`,children:(0,o.jsx)(i.Table,{rowKey:e=>e.vendorId,columns:EC,dataSource:H,loading:F,pagination:!1,size:`small`,rowSelection:{selectedRowKeys:L,onChange:e=>{e.length>wC.maxVendorSelect||R(e)}},scroll:{y:`calc(100vh - 340px)`}})}),(0,o.jsx)(`div`,{className:`vendor-share__vendor-footer`,children:(0,o.jsx)(Se,{current:j,pageSize:N,total:k,onChange:e=>M(e),onPageSizeChange:e=>P(e)})})]}),(0,o.jsx)(`div`,{className:`vendor-share__right`,children:(0,o.jsx)(ab,{value:B,onChange:ee,moduleName:f,defaultTemplateId:p.defaultTemplateId??t.state?.defaultTemplateId??``,ready:_,contextRecords:c,title:`Share`,hint:`Select vendors or add email addresses`,bccHint:`Vendor emails are added automatically`,afterBcc:L.length>0?(0,o.jsxs)(`div`,{className:`vendor-share__selected-count`,children:[L.length,` / `,wC.maxVendorSelect,` Vendors selected`]}):null})})]})})}var OC={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].*$/},kC={SINGLE_FILE_COUNT:1,MULTI_FILE_COUNT:5,MAX_FILE_SIZE:2,ALLOWED_FILE_TYPES:[`image/jpeg`,`image/png`,`application/pdf`]},AC={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 ${kC.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.`},jC={FIRST_NAME_MIN:3,FIRST_NAME_MAX:30},MC={REMARKS_MIN:10,REMARKS_MAX:250},NC={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)}`}},PC={required:(e=`Field`)=>({required:!0,message:AC.REQUIRED(e)}),email:()=>({pattern:OC.EMAIL,message:AC.INVALID_EMAIL}),phone:()=>({pattern:OC.PHONE,message:AC.INVALID_PHONE}),password:()=>({pattern:OC.PASSWORD,message:AC.INVALID_PASSWORD}),alphabets:()=>({pattern:OC.ALPHABETS,message:AC.INVALID_ALPHABETS}),alphanumeric:()=>({pattern:OC.ALPHANUMERIC,message:AC.INVALID_ALPHANUMERIC}),number:()=>({pattern:OC.NUMBER,message:AC.INVALID_NUMBER}),url:()=>({pattern:OC.URL,message:AC.INVALID_URL}),candidateId:(e=`ID`)=>({pattern:OC.CANDIDATE_ID,message:AC.INVALID_CANDIDATE_ID(e)}),remarks:()=>({pattern:OC.REMARKS,message:AC.INVALID_REMARKS,REMARKS_MIN:`Remarks must be at least ${MC.REMARKS_MIN} characters.`,REMARKS_MAX:`Remarks must not exceed ${MC.REMARKS_MAX} characters.`}),designation:()=>({pattern:OC.DESIGNATION,message:AC.INVALID_DESIGNATION}),dob:(e=!0)=>({validator:(t,n)=>{if(!n)return e?Promise.reject(Error(`Date of Birth is required.`)):Promise.resolve();if(!OC.DOB.test(n))return Promise.reject(Error(AC.INVALID_DOB));let r=(0,c.default)(n,`MM/DD/YYYY`,!0);if(!r.isValid())return Promise.reject(Error(AC.INVALID_DOB));let i=(0,c.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:OC.LINKEDIN,message:AC.INVALID_LINKEDIN}),companyName:()=>({pattern:OC.COMPANY_NAME,message:AC.INVALID_COMPANY_NAME}),firstName:()=>({pattern:OC.FIRST_NAME,message:AC.INVALID_FIRST_NAME,FIRST_NAME_MIN:`First Name must be at least ${jC.FIRST_NAME_MIN} characters.`,FIRST_NAME_MAX:`First Name must not exceed ${jC.FIRST_NAME_MAX} characters.`}),firstNameMinLength:()=>({min:jC.FIRST_NAME_MIN,message:AC.FIRST_NAME_MIN}),firstNameMaxLength:()=>({max:jC.FIRST_NAME_MAX,message:AC.FIRST_NAME_MAX}),remarksMinLength:()=>({min:MC.REMARKS_MIN,message:AC.REMARKS_MIN}),remarksMaxLength:()=>({max:MC.REMARKS_MAX,message:AC.REMARKS_MAX}),fullName:()=>({pattern:OC.FULL_NAME,message:AC.INVALID_FULL_NAME}),noSpaces:()=>({pattern:OC.NO_SPACES,message:AC.NO_SPACES_ALLOWED}),startsWithCapital:()=>({pattern:OC.STARTS_WITH_CAPITAL,message:AC.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<=kC.MAX_FILE_SIZE))return i.message.error(AC.INVALID_FILE_SIZE),Promise.reject(Error(AC.INVALID_FILE_SIZE));if(!kC.ALLOWED_FILE_TYPES.includes(t.type))return Promise.reject(Error(AC.INVALID_FILE_TYPE))}return Promise.resolve()}}),singleFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>kC.SINGLE_FILE_COUNT)return Promise.reject(Error(AC.SINGLE_FILE_ONLY));let n=t[0];return n.size/1024/1024<kC.MAX_FILE_SIZE?kC.ALLOWED_FILE_TYPES.includes(n.type)?Promise.resolve():Promise.reject(Error(AC.INVALID_FILE_TYPE)):Promise.reject(Error(AC.INVALID_FILE_SIZE))}}),multiFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>kC.MULTI_FILE_COUNT)return Promise.reject(Error(AC.INVALID_FILE_COUNT));for(let e of t){if(!(e.size/1024/1024<kC.MAX_FILE_SIZE))return Promise.reject(Error(AC.INVALID_FILE_SIZE));if(!kC.ALLOWED_FILE_TYPES.includes(e.type))return Promise.reject(Error(AC.INVALID_FILE_TYPE))}return Promise.resolve()}})},FC={beforeUpload:e=>[`image/jpeg`,`image/png`,`application/pdf`].includes(e.type)?e.size/1024/1024<=2?!1:(i.message.error(`File upload must be 2 MB below.`),i.Upload.LIST_IGNORE):(i.message.error(`Only JPG, PNG and PDF files are allowed.`),i.Upload.LIST_IGNORE)},IC=()=>{let[e]=i.Form.useForm();return(0,o.jsx)(`div`,{style:{padding:24},children:(0,o.jsxs)(i.Form,{form:e,layout:`vertical`,onFinish:e=>{console.log(`Form Values:`,e)},autoComplete:`off`,children:[(0,o.jsxs)(i.Row,{gutter:16,children:[(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Email`,name:`email`,rules:[PC.required(`Email`),PC.email()],children:(0,o.jsx)(i.Input,{})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Phone Number`,name:`phone`,rules:[PC.required(`Phone Number`),PC.phone()],validateTrigger:[`onBlur`,`onChange`],children:(0,o.jsx)(i.Input,{maxLength:10,onChange:t=>{e.setFieldsValue({phone:NC.phoneFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Password`,name:`password`,rules:[PC.required(`Password`),PC.password()],children:(0,o.jsx)(i.Input.Password,{})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Full Name`,name:`fullName`,rules:[PC.required(`Full Name`),PC.alphabets(),PC.firstNameMinLength(),PC.firstNameMaxLength()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({fullName:NC.firstNameFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Username`,name:`username`,rules:[PC.required(`Username`),PC.alphanumeric()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({username:NC.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Website URL`,name:`website`,rules:[PC.required(`Website URL`),PC.url()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({website:NC.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`MSP Req ID`,name:`mspreqID`,rules:[PC.required(`MSP Req ID`),PC.candidateId(`MSP Req ID`)],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({mspreqID:NC.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Candidate ID`,name:`candidateId`,rules:[PC.required(`Candidate ID`),PC.candidateId(`Candidate ID`)],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({candidateId:NC.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:24,children:(0,o.jsx)(i.Form.Item,{label:`Remarks`,name:`remarks`,rules:[PC.required(`Remarks`),PC.remarks(),PC.remarksMinLength(),PC.remarksMaxLength()],children:(0,o.jsx)(i.Input.TextArea,{rows:4})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Designation`,name:`designation`,rules:[PC.required(`Designation`),PC.designation()],children:(0,o.jsx)(i.Input,{})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Date of Birth`,name:`dob`,rules:[PC.dob()],children:(0,o.jsx)(i.Input,{placeholder:`MM/DD/YYYY`,maxLength:10,onChange:t=>{e.setFieldsValue({dob:NC.dobFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Company Name`,name:`companyName`,rules:[PC.required(`Company Name`),PC.companyName()],children:(0,o.jsx)(i.Input,{})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{name:`contractType`,label:`Contract Type`,children:(0,o.jsxs)(i.Select,{showSearch:!0,allowClear:!0,filterOption:(e,t)=>(t?.label??``).toLowerCase().includes(e.toLowerCase()),children:[(0,o.jsx)(i.Select.Option,{value:`C2C`,label:`C2C`,children:`C2C`}),(0,o.jsx)(i.Select.Option,{value:`W2-Contract`,label:`W2-Contract`,children:`W2-Contract`}),(0,o.jsx)(i.Select.Option,{value:`W2-Fulltime`,label:`W2-Fulltime`,children:`W2-Fulltime`}),(0,o.jsx)(i.Select.Option,{value:`1099`,label:`1099`,children:`1099`})]})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{name:`candidateProposedRateCurrency`,label:`Currency`,children:(0,o.jsxs)(i.Select,{showSearch:!0,allowClear:!0,children:[(0,o.jsx)(i.Select.Option,{value:`$`,children:`$`}),(0,o.jsx)(i.Select.Option,{value:`₹`,children:`₹`}),(0,o.jsx)(i.Select.Option,{value:`€`,children:`€`}),(0,o.jsx)(i.Select.Option,{value:`zł`,children:`zł`}),(0,o.jsx)(i.Select.Option,{value:`£`,children:`£`}),(0,o.jsx)(i.Select.Option,{value:`kr`,children:`kr`}),(0,o.jsx)(i.Select.Option,{value:`Fr`,children:`Fr`}),(0,o.jsx)(i.Select.Option,{value:`kr`,children:`kr`})]})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Resume new`,name:`resume`,children:(0,o.jsx)(i.Upload,{beforeUpload:FC.beforeUpload,maxCount:1,children:(0,o.jsx)(i.Button,{children:`Upload Resume`})})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Documents`,name:`documents`,valuePropName:`fileList`,getValueFromEvent:e=>e?.fileList,rules:[PC.multiFileUpload()],children:(0,o.jsx)(i.Upload,{multiple:!0,beforeUpload:FC.beforeUpload,children:(0,o.jsx)(i.Button,{children:`Upload Documents`})})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Upload File`,name:`file`,valuePropName:`fileList`,getValueFromEvent:e=>e?.fileList,rules:[PC.fileUpload()],children:(0,o.jsx)(i.Upload,{beforeUpload:FC.beforeUpload,maxCount:1,children:(0,o.jsx)(i.Button,{children:`Upload`})})})})]}),(0,o.jsx)(i.Row,{children:(0,o.jsx)(i.Form.List,{name:`users`,children:(e,{add:t,remove:n})=>(0,o.jsxs)(o.Fragment,{children:[e.map(({key:e,name:t,...r})=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{required:!0,...r,rules:[{required:!0,message:`First name is requried`}],name:[t,`first`],children:(0,o.jsx)(i.Input,{placeholder:`First Name`})})}),(0,o.jsx)(i.Col,{span:11,children:(0,o.jsx)(i.Form.Item,{...r,required:!0,name:[t,`last`],children:(0,o.jsx)(i.Input,{placeholder:`Last Name`})})}),(0,o.jsx)(i.Col,{span:1,children:(0,o.jsx)(a.MinusCircleOutlined,{onClick:()=>n(t)})})]})),(0,o.jsx)(i.Form.Item,{children:(0,o.jsx)(i.Button,{type:`dashed`,onClick:()=>t(),block:!0,icon:(0,o.jsx)(a.PlusOutlined,{}),children:`Add field`})})]})})}),(0,o.jsxs)(i.Form.Item,{children:[(0,o.jsx)(i.Button,{type:`primary`,htmlType:`submit`,children:`Submit`}),(0,o.jsx)(i.Button,{style:{marginLeft:10},onClick:()=>e.resetFields(),children:`Reset`})]})]})})};function LC(e){return(0,o.jsx)(th,{children:(0,o.jsx)(Jy,{...e})})}var{Text:RC}=i.Typography,zC=[{label:`Total Jobs`,value:1697,icon:`fileText`},{label:`Active Jobs`,value:1685,icon:`checkCircle`},{label:`My Jobs`,value:600,icon:`user`}],BC={fileText:(0,o.jsx)(a.FileTextOutlined,{}),checkCircle:(0,o.jsx)(a.CheckCircleOutlined,{}),user:(0,o.jsx)(a.UserOutlined,{}),filter:(0,o.jsx)(a.FilterOutlined,{})};function VC({stats:e=zC}){return(0,o.jsx)(i.Card,{children:(0,o.jsx)(i.Row,{gutter:[12,12],children:e.map(e=>(0,o.jsx)(i.Col,{xs:24,sm:24,md:8,lg:8,xl:8,children:(0,o.jsxs)(i.Card,{className:`stats-inner-card`,children:[(0,o.jsxs)(i.Space,{align:`center`,children:[BC[e.icon]??BC.fileText,(0,o.jsx)(RC,{children:e.label})]}),(0,o.jsx)(i.Statistic,{value:e.value})]})},e.label))})})}var{Text:HC}=i.Typography;function UC(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 WC(e){return{...e,key:e.USER_ID??e.user_id??e.userId??e.id??e._id,_name:UC(e),_email:e.email??e.EMAIL??e.user_email??``,_role:e.role_name??e.roleName??e.ROLE_NAME??``,_rawRef:e}}function GC(){let[t,n]=(0,r.useState)([]),[s,c]=(0,r.useState)(0),[l,u]=(0,r.useState)(!1),[d,f]=(0,r.useState)(1),[p,m]=(0,r.useState)(10),[h,g]=(0,r.useState)(``),_=(0,r.useCallback)(async({offset:t,limit:r,searchQuery:a}={})=>{u(!0);try{let i=await e.Rt({offset:t,limit:r,searchQuery:a??``}),o=(i.users??[]).map(WC);n(o),c(i.total??o.length)}catch{i.message.error(`Failed to load users`)}finally{u(!1)}},[]);return(0,r.useEffect)(()=>{queueMicrotask(()=>{_({offset:(d-1)*p,limit:p,searchQuery:h})})},[_,d,p,h]),(0,o.jsx)(Z,{icon:(0,o.jsx)(a.TeamOutlined,{}),title:`Users`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,o.jsx)(hf,{listName:`Users`,dataSource:t,fields:[{label:`Name`,value:`_name`,width:220,render:(e,t)=>(0,o.jsxs)(`div`,{children:[(0,o.jsx)(HC,{strong:!0,style:{fontSize:13},children:e}),t._email&&(0,o.jsx)(`div`,{style:{fontSize:11,color:`var(--color-text-muted)`},children:t._email})]})},{label:`Role`,value:`_role`,width:180}],loading:l,total:s,current:d,pageSize:p,onPageChange:e=>f(e),onPageSizeChange:e=>{m(e),f(1)},onSearch:e=>{g(e),f(1)}})})}var{Text:KC}=i.Typography,qC=[{key:`job`,label:`Jobs`},{key:`candidate`,label:`Candidates`},{key:`submissions`,label:`Submissions`}],JC=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`}];function YC({field:e,index:t,onToggle:n,onReorder:s}){let c=(0,r.useRef)(null),[l,u]=(0,r.useState)(!1),[d,f]=(0,r.useState)(!1);function p(e){c.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),c.current!==null&&c.current!==t&&s(c.current,t),c.current=null}return(0,o.jsxs)(`div`,{draggable:!0,onDragStart:p,onDragEnd:m,onDragOver:h,onDragLeave:g,onDrop:_,className:`uss-field-row with-edit${l?` drag-over`:``}${d?` dragging`:``}`,children:[(0,o.jsx)(`span`,{className:`uss-drag-handle`,children:(0,o.jsx)(a.HolderOutlined,{})}),(0,o.jsxs)(`span`,{className:`uss-field-name`,children:[e.fieldName,(0,o.jsx)(`span`,{className:`uss-field-key`,children:e.fieldKey})]}),(0,o.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,o.jsx)(i.Switch,{size:`small`,checked:e.isVisible,onChange:e=>n(t,`isVisible`,e)})}),(0,o.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,o.jsx)(i.Switch,{size:`small`,checked:!!e.isEditable,onChange:e=>n(t,`isEditable`,e)})}),(0,o.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,o.jsx)(i.Switch,{size:`small`,checked:!!e.ismandatory,onChange:e=>n(t,`ismandatory`,e)})})]})}function XC({team:t,configType:n}){let[a,s]=(0,r.useState)({}),[c,l]=(0,r.useState)(!1),[u,d]=(0,r.useState)({}),[f,p]=(0,r.useState)(`job`);(0,r.useEffect)(()=>{t&&(l(!0),e.pn(t,n).then(s).catch(()=>i.message.error(`Failed to load field config`)).finally(()=>l(!1)))},[t,n]);let m=a[f]??[];function h(e,t){s(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 e.Rn(t,r,m,n),i.message.success(`Saved`)}catch{i.message.error(`Save failed`)}finally{d(e=>({...e,[r]:!1}))}}return(0,o.jsxs)(i.Spin,{spinning:c,children:[(0,o.jsx)(i.Tabs,{size:`small`,activeKey:f,onChange:p,items:qC.map(e=>({key:e.key,label:e.label}))}),(0,o.jsxs)(`div`,{className:`uss-field-header with-edit`,children:[(0,o.jsx)(`span`,{}),(0,o.jsx)(`span`,{children:`Field`}),(0,o.jsx)(`span`,{style:{textAlign:`center`},children:`Visible`}),(0,o.jsx)(`span`,{style:{textAlign:`center`},children:`Editable`}),(0,o.jsx)(`span`,{style:{textAlign:`center`},children:`Mandatory`})]}),(0,o.jsxs)(`div`,{className:`uss-field-list`,children:[m.length===0&&!c&&(0,o.jsx)(`div`,{className:`uss-empty`,children:`No fields found.`}),m.map((e,t)=>(0,o.jsx)(YC,{field:e,index:t,onToggle:g,onReorder:_},e.fieldKey??t))]}),(0,o.jsx)(`div`,{className:`uss-modal-footer`,children:(0,o.jsxs)(i.Button,{type:`primary`,size:`small`,loading:u[f],onClick:v,children:[`Save `,qC.find(e=>e.key===f)?.label]})})]})}function ZC(){let[t,n]=(0,r.useState)(null),[s,c]=(0,r.useState)(!1),[l,u]=(0,r.useState)(!1),[d,f]=(0,r.useState)(`listView`),[p,m]=(0,r.useState)([]),[h,g]=(0,r.useState)(0),[_,v]=(0,r.useState)(!1),[y,b]=(0,r.useState)(``),[x,S]=(0,r.useState)(!1),C=(0,r.useCallback)(async()=>{v(!0);try{let t=await e.Lt();m(t.teams),g(t.total)}catch{i.message.error(`Failed to load teams`)}finally{v(!1)}},[]);(0,r.useEffect)(()=>{C()},[C]);function w(e){n(e),f(`listView`),c(!0)}function T(e){n(e),b(e.teamName??``),u(!0)}async function E(){if(!y.trim()){i.message.warning(`Team name is required`);return}S(!0);try{await e.Ln(t,{teamName:y.trim(),managerId:t.managerId,memberIds:t.memberIds}),i.message.success(`Team updated`),u(!1),C()}catch{i.message.error(`Failed to update team`)}finally{S(!1)}}return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(Z,{icon:(0,o.jsx)(a.TeamOutlined,{}),title:`Teams`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,o.jsx)(hf,{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,o.jsxs)(`div`,{style:{display:`flex`,gap:4},children:[(0,o.jsx)(i.Button,{size:`small`,type:`link`,onClick:()=>T(t),children:`Edit`}),(0,o.jsx)(i.Button,{size:`small`,type:`link`,onClick:()=>w(t),children:`Configure`})]})}],loading:_,total:h})}),(0,o.jsx)(i.Modal,{open:l,onCancel:()=>u(!1),title:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(a.TeamOutlined,{style:{color:`var(--color-brand)`,marginRight:6}}),`Edit Team`]}),width:420,footer:null,destroyOnClose:!0,children:(0,o.jsxs)(`div`,{className:`uss-edit-team-body`,style:{paddingTop:12},children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`div`,{className:`uss-edit-team-label`,children:`Team Name`}),(0,o.jsx)(i.Input,{value:y,onChange:e=>b(e.target.value),onPressEnter:E,placeholder:`Enter team name`})]}),(0,o.jsxs)(`div`,{className:`uss-modal-footer`,children:[(0,o.jsx)(i.Button,{onClick:()=>u(!1),children:`Cancel`}),(0,o.jsx)(i.Button,{type:`primary`,loading:x,onClick:E,children:`Save`})]})]})}),(0,o.jsxs)(i.Modal,{className:`uss-modal`,open:s,onCancel:()=>c(!1),title:(0,o.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,o.jsx)(a.TeamOutlined,{style:{color:`var(--color-brand)`}}),(0,o.jsxs)(`span`,{children:[`Configure: `,t?.teamName]})]}),width:720,footer:null,destroyOnClose:!0,children:[(0,o.jsx)(`div`,{style:{marginBottom:12},children:(0,o.jsx)(`div`,{className:`uss-config-toggle`,children:JC.map(e=>(0,o.jsx)(`button`,{className:`uss-config-btn${d===e.key?` active`:``}`,onClick:()=>f(e.key),children:e.label},e.key))})}),t&&(0,o.jsx)(XC,{team:t,configType:d},`${t?.teamId}-${d}`)]})]})}var QC=[`view`,`add`,`edit`,`delete`],$C={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`};function ew(e){return $C[e]??e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function tw(e){let t=QC.filter(t=>e.includes(t)),n=e.filter(e=>!QC.includes(e)).sort();return[...t,...n]}function nw(e){let t=new Set;return Object.values(e).forEach(({permissions:e})=>Object.keys(e??{}).forEach(e=>t.add(e))),tw([...t])}function rw(e){let t=0,n=0;return Object.entries(e).forEach(([e,{permissions:r}])=>{Object.entries(r??{}).forEach(([r,{value:i}])=>{dg(e,r)&&(n++,i===`1`&&t++)})}),{enabled:t,total:n}}function iw({value:e,onSave:t,className:n}){let[i,s]=(0,r.useState)(!1),[c,l]=(0,r.useState)(e);(0,r.useEffect)(()=>{l(e)},[e]);function u(){s(!1);let n=c.trim();n&&n!==e?t(n):l(e)}return i?(0,o.jsx)(`input`,{autoFocus:!0,className:`perm-inline-input${n?` ${n}`:``}`,value:c,style:{width:Math.max(48,c.length*8)},onChange:e=>l(e.target.value),onBlur:u,onKeyDown:t=>{t.key===`Enter`&&u(),t.key===`Escape`&&(s(!1),l(e)),t.stopPropagation()},onClick:e=>e.stopPropagation()}):(0,o.jsxs)(`span`,{className:`perm-editable-name${n?` ${n}`:``}`,onDoubleClick:e=>{e.stopPropagation(),s(!0)},children:[e,(0,o.jsx)(a.EditOutlined,{className:`perm-name-edit-icon`})]})}function aw({entry:e,label:t,onToggle:n,onLabelSave:s}){let[c,l]=(0,r.useState)(!1),[u,d]=(0,r.useState)(t),f=e?.value===`1`,p=!!e;(0,r.useEffect)(()=>{d(t)},[t]);function m(){l(!1);let e=u.trim();e&&e!==t?s(e):d(t)}return(0,o.jsx)(i.Tooltip,{title:p?f?`Click to disable`:`Click to enable`:`Not applicable for this module`,children:(0,o.jsxs)(`div`,{className:`perm-action-pill${f?` on`:``}${p?``:` na`}`,onClick:()=>{!c&&p&&n()},children:[(0,o.jsx)(`span`,{className:`perm-action-pill-dot${f?` on`:``}`}),c?(0,o.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`&&(l(!1),d(t)),e.stopPropagation()},onClick:e=>e.stopPropagation()}):(0,o.jsx)(`span`,{className:`perm-action-pill-label`,onDoubleClick:e=>{e.stopPropagation(),l(!0)},children:t}),f&&!c&&(0,o.jsx)(a.CheckOutlined,{className:`perm-action-pill-check`})]})})}function ow({menuName:e,menuData:t,permKeys:n,onChange:r,displayName:i,actionLabels:a,onModuleLabelSave:s,onActionLabelSave:c}){let l=t?.permissions??{},u=n.filter(t=>dg(e,t)),d=u.filter(e=>l[e]?.value===`1`).length,f=u.filter(e=>l[e]).length,p=f>0&&d===f;return(0,o.jsxs)(`div`,{className:`perm-module-card${p?` all-on`:d>0&&!p?` some-on`:``}`,children:[(0,o.jsxs)(`div`,{className:`perm-module-card-header`,children:[(0,o.jsx)(iw,{value:i,onSave:t=>s(e,t),className:`perm-module-card-name`}),f>0&&(0,o.jsxs)(`span`,{className:`perm-module-card-badge${d>0?` active`:``}`,children:[d,`/`,f]})]}),(0,o.jsx)(`div`,{className:`perm-module-card-body`,children:u.map(t=>(0,o.jsx)(aw,{entry:l[t],label:a[t]??ew(t),onToggle:()=>r(e,t),onLabelSave:e=>c(t,e)},t))})]})}function sw({role:t,moduleLabels:n={},actionLabels:s={},onModuleLabelSave:c=()=>{},onActionLabelSave:l=()=>{}}){let[u,d]=(0,r.useState)({}),[f,p]=(0,r.useState)({}),[m,h]=(0,r.useState)(!1),[g,_]=(0,r.useState)(!1),[v,y]=(0,r.useState)(!1),b=e.ln(t);(0,r.useEffect)(()=>{b&&(h(!0),y(!1),e.dn(b).then(e=>{d(e),p(e)}).catch(()=>i.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 e.Fn(b,f),d(f),y(!1),i.message.success(`Permissions saved`)}catch(e){i.message.error(e?.message||`Save failed`)}finally{_(!1)}}let C=(0,r.useMemo)(()=>Object.keys(f).sort(),[f]),w=(0,r.useMemo)(()=>nw(f),[f]),{enabled:T,total:E}=(0,r.useMemo)(()=>rw(f),[f]);return(0,o.jsxs)(i.Spin,{spinning:m,children:[(0,o.jsxs)(`div`,{className:`perm-panel-header`,children:[(0,o.jsxs)(`div`,{className:`perm-panel-title`,children:[(0,o.jsx)(a.LockOutlined,{style:{color:`var(--color-brand)`,marginRight:6}}),(0,o.jsx)(`span`,{children:t?.roleName}),!m&&E>0&&(0,o.jsxs)(i.Tag,{color:`blue`,style:{marginLeft:8,fontSize:11},children:[T,`/`,E,` enabled`]})]}),(0,o.jsx)(i.Button,{type:`primary`,size:`small`,icon:(0,o.jsx)(a.UnlockOutlined,{}),loading:g,disabled:!v,onClick:S,children:`Save Changes`})]}),(0,o.jsxs)(`div`,{className:`perm-hint`,children:[(0,o.jsx)(a.InfoCircleOutlined,{className:`perm-hint-icon`}),(0,o.jsxs)(`span`,{children:[`Click a pill to toggle. `,(0,o.jsx)(`strong`,{children:`Double-click`}),` a module name or action label to rename it — labels are saved locally.`]})]}),C.length===0&&!m?(0,o.jsx)(`div`,{className:`perm-empty`,children:`No permission entries found for this role.`}):(0,o.jsx)(`div`,{className:`perm-cards-grid`,children:C.map(e=>(0,o.jsx)(ow,{menuName:e,menuData:f[e],permKeys:w,onChange:x,displayName:n[e]??e,actionLabels:s,onModuleLabelSave:c,onActionLabelSave:l},e))})]})}var{Text:cw}=i.Typography,lw=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`}];function uw(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function dw(e){return String(e||``).trim().toLowerCase()}function fw(e){return e?.key||e?.collectionName||e?.value||``}function pw(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=fw(e);if(!t)return;let o=dw(e.key||t),s=dw(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||uw(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=dw(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:uw(t),value:t,disabled:!1}))}),n}function mw(){let[t,n]=(0,r.useState)(null),[s,c]=(0,r.useState)(!1),[l,u]=(0,r.useState)(`listView`),[d,f]=(0,r.useState)([]),[p,m]=(0,r.useState)(0),[h,g]=(0,r.useState)(!1),[_,v]=(0,r.useState)([]),[y,b]=(0,r.useState)([]),[x,S]=(0,r.useState)(!1),[C,w]=(0,r.useState)(!1),T=(0,r.useMemo)(()=>_.filter(e=>!e.disabled),[_]),E=!x&&T.length===0,D=(0,r.useCallback)(async()=>{g(!0);try{let t=await e.It();f(t.roles),m(t.total)}catch{i.message.error(`Failed to load roles`)}finally{g(!1)}},[]),O=(0,r.useCallback)(async()=>{S(!0);try{let[t,n]=await Promise.all([e.Jt(),e.Bt()]),r=pw(t.modules,n),i=new Set(r.filter(e=>!e.disabled).map(e=>e.value));v(r),b(e=>e.filter(e=>i.has(e)))}catch{i.message.error(`Failed to load seed status`)}finally{S(!1)}},[]);(0,r.useEffect)(()=>{D()},[D]),(0,r.useEffect)(()=>{O()},[O]);async function k(){if(y.length===0){i.message.warning(E?`All modules already seeded.`:`Select at least one module to seed.`);return}w(!0);try{await e.En(y),i.message.success(`Role field config seeded`),b([]),await O()}catch(e){i.message.error(e?.message||`Seed failed`)}finally{w(!1)}}function A(e,t=`listView`){n(e),u(t),c(!0)}return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(Z,{icon:(0,o.jsx)(a.AppstoreOutlined,{}),title:`Field Config Seed`,style:{marginBottom:12},children:[(0,o.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[(0,o.jsx)(`div`,{style:{minWidth:320,flex:1},children:(0,o.jsx)(i.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,o.jsx)(i.Button,{type:`primary`,loading:C,disabled:x||y.length===0,onClick:k,children:`Seed Field Config`})]}),(0,o.jsx)(cw,{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,o.jsx)(Z,{icon:(0,o.jsx)(a.SafetyOutlined,{}),title:`Roles`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,o.jsx)(hf,{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,o.jsxs)(i.Space,{size:2,children:[(0,o.jsx)(i.Button,{size:`small`,type:`link`,onClick:()=>A(t),children:`Configure`}),(0,o.jsx)(i.Button,{size:`small`,type:`link`,icon:(0,o.jsx)(a.LockOutlined,{}),onClick:()=>A(t,`permissions`),children:`Permissions`})]})}],loading:h,total:p})}),(0,o.jsxs)(i.Modal,{className:`uss-modal`,open:s,onCancel:()=>c(!1),title:(0,o.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,o.jsx)(a.SafetyOutlined,{style:{color:`var(--color-brand)`}}),(0,o.jsxs)(`span`,{children:[`Configure: `,t?.roleName]})]}),width:720,footer:null,destroyOnClose:!0,children:[(0,o.jsx)(`div`,{style:{marginBottom:12},children:(0,o.jsx)(`div`,{className:`uss-config-toggle`,children:lw.map(e=>(0,o.jsx)(`button`,{className:`uss-config-btn${l===e.key?` active`:``}`,onClick:()=>u(e.key),children:e.label},e.key))})}),t&&(l===`permissions`?(0,o.jsx)(sw,{role:t},t?.roleId):(0,o.jsx)(Og,{role:t,configType:l},`${t?.roleId}-${l}`))]})]})}var hw=`perm-module-labels`,gw=`perm-action-labels`;function _w(e){try{return JSON.parse(localStorage.getItem(e)??`{}`)}catch{return{}}}function vw(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function yw({label:e,onSave:t,onDelete:n,loading:s}){let[c,l]=(0,r.useState)(!1),[u,d]=(0,r.useState)(e);function f(){l(!1);let n=u.trim();n&&n!==e?t(n):d(e)}return(0,o.jsxs)(`div`,{className:`perm-manage-row`,children:[c?(0,o.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`&&(l(!1),d(e))}}):(0,o.jsx)(`span`,{className:`perm-manage-row-label`,children:e}),(0,o.jsxs)(`div`,{className:`perm-manage-row-actions`,children:[(0,o.jsx)(i.Button,{type:`text`,size:`small`,icon:(0,o.jsx)(a.EditOutlined,{}),onClick:()=>{d(e),l(!0)},loading:s}),(0,o.jsx)(i.Popconfirm,{title:`Delete this item?`,onConfirm:n,okText:`Delete`,cancelText:`Cancel`,okType:`danger`,children:(0,o.jsx)(i.Button,{type:`text`,size:`small`,icon:(0,o.jsx)(a.DeleteOutlined,{}),danger:!0})})]})]})}function bw({open:t,onClose:n}){let[s,c]=(0,r.useState)(`modules`),[l,u]=(0,r.useState)([]),[d,f]=(0,r.useState)(!1),[p,m]=(0,r.useState)(``),[h,g]=(0,r.useState)(!1),[_,v]=(0,r.useState)([]),[y,b]=(0,r.useState)(!1),[x,S]=(0,r.useState)(``),[C,w]=(0,r.useState)(``),[T,E]=(0,r.useState)(!1);(0,r.useEffect)(()=>{t&&(D(),O())},[t]);async function D(){f(!0);try{u(await e.tn())}catch{i.message.error(`Failed to load modules`)}finally{f(!1)}}async function O(){b(!0);try{v(await e.en())}catch{i.message.error(`Failed to load actions`)}finally{b(!1)}}async function k(){let t=p.trim();if(!t){i.message.warning(`Enter a module name`);return}g(!0);try{let n=await e.vt({menuName:t});u(e=>[...e,n]),m(``),i.message.success(`Module added`)}catch{i.message.error(`Failed to add module`)}finally{g(!1)}}async function A(t,n){try{await e.jn(t,{menuName:n}),u(e=>e.map(e=>e.MENUID===t?{...e,MENUNAME:n}:e))}catch{i.message.error(`Failed to update module`)}}async function j(t){try{await e.Dt(t),u(e=>e.filter(e=>e.MENUID!==t)),i.message.success(`Module deleted`)}catch{i.message.error(`Failed to delete module`)}}async function M(){let t=x.trim(),n=C.trim().toLowerCase().replace(/\s+/g,`_`);if(!t||!n){i.message.warning(`Enter both name and key`);return}E(!0);try{let r=await e._t({permissionName:t,permissionKey:n});v(e=>[...e,r]),S(``),w(``),i.message.success(`Action added`)}catch(e){i.message.error(e?.message?.includes(`409`)||e?.status===409?`Permission key already exists`:`Failed to add action`)}finally{E(!1)}}async function N(t,n){try{await e.An(t,{permissionName:n}),v(e=>e.map(e=>e.permissionId===t?{...e,permissionName:n}:e))}catch{i.message.error(`Failed to update action`)}}async function P(t){try{await e.Et(t),v(e=>e.filter(e=>e.permissionId!==t)),i.message.success(`Action deleted`)}catch{i.message.error(`Failed to delete action`)}}let F=[{key:`modules`,label:`Modules`,children:(0,o.jsxs)(i.Spin,{spinning:d,children:[(0,o.jsxs)(`div`,{className:`perm-manage-add-row`,children:[(0,o.jsx)(i.Input,{placeholder:`Module name`,value:p,onChange:e=>m(e.target.value),onPressEnter:k,style:{flex:1},size:`small`}),(0,o.jsx)(i.Button,{type:`primary`,size:`small`,icon:(0,o.jsx)(a.PlusOutlined,{}),loading:h,onClick:k,children:`Add`})]}),(0,o.jsxs)(`div`,{className:`perm-manage-list`,children:[l.length===0&&!d&&(0,o.jsx)(`div`,{className:`perm-empty`,style:{paddingTop:24},children:`No modules found`}),l.map(e=>(0,o.jsx)(yw,{label:e.MENUNAME,onSave:t=>A(e.MENUID,t),onDelete:()=>j(e.MENUID)},e.MENUID))]})]})},{key:`actions`,label:`Actions`,children:(0,o.jsxs)(i.Spin,{spinning:y,children:[(0,o.jsxs)(`div`,{className:`perm-manage-add-row`,children:[(0,o.jsx)(i.Input,{placeholder:`Action name (e.g. Approve)`,value:x,onChange:e=>S(e.target.value),style:{flex:1},size:`small`}),(0,o.jsx)(i.Input,{placeholder:`Key (e.g. approve)`,value:C,onChange:e=>w(e.target.value),onPressEnter:M,style:{width:140},size:`small`}),(0,o.jsx)(i.Button,{type:`primary`,size:`small`,icon:(0,o.jsx)(a.PlusOutlined,{}),loading:T,onClick:M,children:`Add`})]}),(0,o.jsxs)(`div`,{className:`perm-manage-list`,children:[_.length===0&&!y&&(0,o.jsx)(`div`,{className:`perm-empty`,style:{paddingTop:24},children:`No actions found`}),_.map(e=>(0,o.jsx)(yw,{label:`${e.permissionName} (${e.permissionKey})`,onSave:t=>N(e.permissionId,t),onDelete:()=>P(e.permissionId)},e.permissionId))]})]})}];return(0,o.jsx)(i.Modal,{open:t,onCancel:n,title:(0,o.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,o.jsx)(a.SettingOutlined,{style:{color:`var(--color-brand)`}}),`Manage Modules & Actions`]}),width:520,footer:null,destroyOnClose:!0,children:(0,o.jsx)(i.Tabs,{activeKey:s,onChange:c,size:`small`,items:F})})}function xw(){let[t,n]=(0,r.useState)([]),[s,c]=(0,r.useState)(!1),[l,u]=(0,r.useState)(null),[d,f]=(0,r.useState)(``),[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(()=>_w(hw)),[_,v]=(0,r.useState)(()=>_w(gw)),y=(0,r.useCallback)((e,t)=>{g(n=>{let r={...n,[e]:t};return vw(hw,r),r})},[]),b=(0,r.useCallback)((e,t)=>{v(n=>{let r={...n,[e]:t};return vw(gw,r),r})},[]);function x(){g({}),v({}),vw(hw,{}),vw(gw,{}),i.message.success(`Labels reset to defaults`)}let S=(0,r.useCallback)(async()=>{c(!0);try{let{roles:t}=await e.It();n(t),t.length>0&&u(t[0])}catch{i.message.error(`Failed to load roles`)}finally{c(!1)}},[]);(0,r.useEffect)(()=>{S()},[S]);let C=(0,r.useMemo)(()=>{let e=d.trim().toLowerCase();return e?t.filter(t=>t.roleName.toLowerCase().includes(e)):t},[t,d]),w=Object.keys(h).length>0||Object.keys(_).length>0;return(0,o.jsxs)(`div`,{className:`perm-page`,children:[(0,o.jsxs)(Z,{className:`perm-left-card`,icon:(0,o.jsx)(a.SafetyOutlined,{}),title:`Roles`,bodyStyle:{padding:0},children:[(0,o.jsx)(`div`,{className:`perm-role-search`,children:(0,o.jsx)(i.Input,{prefix:(0,o.jsx)(a.SearchOutlined,{}),placeholder:`Search roles…`,allowClear:!0,size:`small`,value:d,onChange:e=>f(e.target.value)})}),(0,o.jsx)(i.Spin,{spinning:s,children:(0,o.jsxs)(`div`,{className:`perm-role-list`,children:[C.length===0&&!s&&(0,o.jsx)(`div`,{className:`perm-role-empty`,children:`No roles found`}),C.map(e=>{let t=l?.roleId===e.roleId,n=e.description&&e.description!==`N/A`?e.description:e.roleType===0?`Default role`:`Custom role`;return(0,o.jsxs)(`div`,{className:`perm-role-item${t?` active`:``}`,onClick:()=>u(e),children:[(0,o.jsx)(`div`,{className:`perm-role-item-name`,children:e.roleName}),(0,o.jsx)(`div`,{className:`perm-role-item-desc`,children:n})]},e.roleId)})]})})]}),(0,o.jsx)(Z,{className:`perm-right-card`,icon:(0,o.jsx)(a.LockOutlined,{}),title:`Module Permissions`,extra:(0,o.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[w&&(0,o.jsx)(`button`,{className:`perm-reset-btn`,onClick:x,children:`Reset labels`}),(0,o.jsx)(i.Button,{size:`small`,icon:(0,o.jsx)(a.SettingOutlined,{}),onClick:()=>m(!0),children:`Manage`})]}),bodyStyle:{padding:`12px 16px`},children:l?(0,o.jsx)(sw,{role:l,moduleLabels:h,actionLabels:_,onModuleLabelSave:y,onActionLabelSave:b},l.roleId):(0,o.jsx)(`div`,{className:`perm-empty`,children:`Select a role from the left to manage its permissions.`})}),(0,o.jsx)(bw,{open:p,onClose:()=>m(!1)})]})}var{Title:Sw,Text:Cw}=i.Typography,ww=[{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 Tw({items:e=ww}){return(0,o.jsx)(i.Card,{className:`onboarding-card`,title:(0,o.jsx)(Sw,{level:5,children:`Onboarding`}),extra:(0,o.jsx)(i.Button,{type:`link`,children:`View all`}),children:(0,o.jsx)(i.Row,{gutter:[12,12],children:e.map(e=>(0,o.jsx)(i.Col,{xs:12,sm:6,md:6,lg:12,xl:12,children:(0,o.jsxs)(`div`,{className:`onboarding-item ${e.color}`,children:[(0,o.jsx)(Cw,{className:`onboarding-item-label`,children:e.label}),(0,o.jsx)(i.Statistic,{value:e.value,className:`onboarding-stat`}),(0,o.jsx)(`div`,{className:`onboarding-item-footer`,children:(0,o.jsx)(Cw,{className:`onboarding-item-sub`,children:e.sub})})]})},e.label))})})}var{Text:Ew,Title:Dw}=i.Typography,Ow=[{group:`Dashboard`,items:[{id:`dashboard`,label:`Admin Dashboard`,icon:(0,o.jsx)(a.DashboardOutlined,{})}]},{group:`Settings`,items:[{id:`org`,label:`Organization`,icon:(0,o.jsx)(a.BankOutlined,{}),heading:`Organization Settings`,desc:`Manage your company profile and location details`,cards:[{label:`Company Information`,icon:(0,o.jsx)(a.BankOutlined,{}),desc:`Manage company profile, address and business details.`},{label:`Location`,icon:(0,o.jsx)(a.BuildOutlined,{}),desc:`Manage office locations, branches and regions.`}]},{id:`users`,label:`Users`,icon:(0,o.jsx)(a.UserOutlined,{}),heading:`Users`,desc:`Manage platform users and configure their field views.`,component:`users`},{id:`teams`,label:`Teams`,icon:(0,o.jsx)(a.TeamOutlined,{}),heading:`Teams`,desc:`Organize users into teams and configure field visibility per team.`,component:`teams`},{id:`roles`,label:`Roles`,icon:(0,o.jsx)(a.SafetyOutlined,{}),heading:`Roles`,desc:`Control permissions and configure field visibility per role.`,component:`roles`},{id:`permissions`,label:`Permissions`,icon:(0,o.jsx)(a.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,o.jsx)(a.FileTextOutlined,{}),heading:`Templates`,desc:`Email and signature templates for communications`,component:`templates`},{id:`ai-services`,label:`AI Services`,icon:(0,o.jsx)(a.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,o.jsx)(a.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,o.jsx)(a.BankOutlined,{}),heading:`Clients`,desc:`Manage client accounts and settings`,cards:[{label:`Clients`,icon:(0,o.jsx)(a.BankOutlined,{}),desc:`Manage client companies and account details.`}]}]},{group:`Forms`,items:[{id:`form-groups`,label:`Form Groups`,icon:(0,o.jsx)(a.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,o.jsx)(a.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,o.jsx)(a.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,o.jsx)(a.AppstoreOutlined,{}),heading:`Jobs Master`,desc:`Configure job sources and status types`,cards:[{label:`Sources`,icon:(0,o.jsx)(a.AppstoreOutlined,{}),desc:`Manage job source master values.`},{label:`Job Status`,icon:(0,o.jsx)(a.CheckCircleOutlined,{}),desc:`Configure job workflow status.`}]},{id:`candidates`,label:`Candidates`,icon:(0,o.jsx)(a.UserOutlined,{}),heading:`Candidates Master`,desc:`Skills, sources and work authorization settings`,cards:[{label:`Sources`,icon:(0,o.jsx)(a.AppstoreOutlined,{}),desc:`Manage candidate source values.`},{label:`Skills`,icon:(0,o.jsx)(a.SettingOutlined,{}),desc:`Manage skill master data.`},{label:`Work Authorization`,icon:(0,o.jsx)(a.SafetyOutlined,{}),desc:`Manage visa and authorization types.`}]},{id:`submissions`,label:`Submissions`,icon:(0,o.jsx)(a.FileTextOutlined,{}),heading:`Submissions Master`,desc:`Rejection reasons and submission status configuration`,cards:[{label:`Rejection Reasons`,icon:(0,o.jsx)(a.FileTextOutlined,{}),desc:`Manage common rejection reasons.`},{label:`Client Submission Status`,icon:(0,o.jsx)(a.CheckCircleOutlined,{}),desc:`Manage client submission statuses.`}]},{id:`clientmaster`,label:`Client Master`,icon:(0,o.jsx)(a.BankOutlined,{}),heading:`Client Master`,desc:`Payment terms, client types and contact types`,cards:[{label:`Payment Terms`,icon:(0,o.jsx)(a.FileTextOutlined,{}),desc:`Manage billing and payment terms.`},{label:`Client Type`,icon:(0,o.jsx)(a.AppstoreOutlined,{}),desc:`Classify client business types.`},{label:`Client Contact Type`,icon:(0,o.jsx)(a.TeamOutlined,{}),desc:`Manage client contact categories.`}]}]}],kw=[{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}],Aw=[{name:`Tcs`,jobs:14,candidates:86},{name:`Empasis`,jobs:9,candidates:64},{name:`NovaSystems`,jobs:7,candidates:51},{name:`Brightwave`,jobs:5,candidates:38}],jw=[{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 Mw(){return(0,o.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:16},children:[(0,o.jsxs)(Z,{icon:(0,o.jsx)(a.DashboardOutlined,{}),title:`Admin Dashboard`,children:[(0,o.jsx)(`div`,{className:`admin-accent-bar`}),(0,o.jsx)(Dw,{level:5,children:`Admin Dashboard`}),(0,o.jsx)(Ew,{type:`secondary`,children:`Overview of jobs, candidates, onboarding and recent activity`})]}),(0,o.jsx)(`div`,{className:`admin-dashboard-stats`,children:(0,o.jsx)(VC,{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,o.jsxs)(`div`,{className:`admin-dashboard-mid-row`,children:[(0,o.jsx)(Tw,{}),(0,o.jsxs)(Z,{icon:(0,o.jsx)(a.AppstoreOutlined,{}),title:`Candidate Pipeline`,children:[(0,o.jsx)(Ew,{type:`secondary`,style:{fontSize:12},children:`By stage (892 total)`}),(0,o.jsx)(`div`,{className:`admin-pipeline-bar`,children:kw.map(e=>(0,o.jsx)(`div`,{className:`admin-pipeline-seg`,style:{width:`${e.pct}%`,background:e.color}},e.label))}),(0,o.jsx)(`div`,{className:`admin-pipeline-legend`,children:kw.map(e=>(0,o.jsxs)(`div`,{className:`admin-pipeline-legend-item`,children:[(0,o.jsx)(`span`,{className:`admin-pipeline-dot`,style:{background:e.color}}),e.label,` `,e.count]},e.label))}),(0,o.jsx)(`div`,{className:`admin-divider`}),(0,o.jsx)(Ew,{strong:!0,style:{fontSize:12},children:`Submission status`}),(0,o.jsxs)(`div`,{className:`admin-sub-status-list`,style:{marginTop:6},children:[(0,o.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,o.jsx)(Ew,{style:{fontSize:13},children:`Pending client review`}),(0,o.jsx)(`span`,{className:`admin-badge warn`,children:`312`})]}),(0,o.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,o.jsx)(Ew,{style:{fontSize:13},children:`Client approved`}),(0,o.jsx)(`span`,{className:`admin-badge success`,children:`248`})]}),(0,o.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,o.jsx)(Ew,{style:{fontSize:13},children:`Rejected`}),(0,o.jsx)(`span`,{className:`admin-badge danger`,children:`89`})]})]})]})]}),(0,o.jsxs)(`div`,{className:`admin-dashboard-bottom-row`,children:[(0,o.jsx)(Z,{icon:(0,o.jsx)(a.BankOutlined,{}),title:`Top Clients`,extra:(0,o.jsx)(i.Button,{type:`link`,size:`small`,children:`View all`}),children:Aw.map(e=>(0,o.jsxs)(`div`,{className:`admin-client-row`,children:[(0,o.jsxs)(`div`,{className:`admin-client-left`,children:[(0,o.jsx)(`div`,{className:`admin-client-icon`,children:(0,o.jsx)(a.BankOutlined,{})}),(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`div`,{className:`admin-client-name`,children:e.name}),(0,o.jsxs)(`div`,{className:`admin-client-sub`,children:[e.jobs,` open jobs`]})]})]}),(0,o.jsxs)(`div`,{className:`admin-client-right`,children:[(0,o.jsx)(`div`,{className:`admin-client-val`,children:e.candidates}),(0,o.jsx)(`div`,{className:`admin-client-sub`,children:`candidates`})]})]},e.name))}),(0,o.jsx)(Z,{icon:(0,o.jsx)(a.BellOutlined,{}),title:`Recent Activity`,children:jw.map((e,t)=>(0,o.jsxs)(`div`,{className:`admin-activity-row`,children:[(0,o.jsx)(`div`,{className:`admin-activity-dot`,style:{background:e.color}}),(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`div`,{className:`admin-activity-text`,children:e.text}),(0,o.jsx)(`div`,{className:`admin-activity-time`,children:e.time})]})]},t))})]}),(0,o.jsx)(Z,{icon:(0,o.jsx)(a.SettingOutlined,{}),title:`Admin Configuration Overview`,extra:(0,o.jsx)(i.Button,{type:`link`,size:`small`,children:`Manage`}),children:(0,o.jsxs)(i.Row,{gutter:[24,0],children:[(0,o.jsxs)(i.Col,{span:8,children:[(0,o.jsx)(Ew,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`Settings`}),[[`Organization`,2],[`User Settings`,4],[`Templates`,2]].map(([e,t])=>(0,o.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,o.jsx)(Ew,{style:{fontSize:12},children:e}),(0,o.jsxs)(`span`,{className:`admin-badge info`,children:[t,` items`]})]},e))]}),(0,o.jsxs)(i.Col,{span:8,children:[(0,o.jsx)(Ew,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`Master`}),[[`Jobs`,2],[`Candidates`,3],[`Submissions`,2]].map(([e,t])=>(0,o.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,o.jsx)(Ew,{style:{fontSize:12},children:e}),(0,o.jsxs)(`span`,{className:`admin-badge info`,children:[t,` items`]})]},e))]}),(0,o.jsxs)(i.Col,{span:8,children:[(0,o.jsx)(Ew,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`System`}),[[`Total Groups`,4],[`Total Modules`,9],[`Config Items`,19]].map(([e,t])=>(0,o.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,o.jsx)(Ew,{style:{fontSize:12},children:e}),(0,o.jsx)(Ew,{strong:!0,style:{fontSize:12},children:t})]},e))]})]})})]})}function Nw({activeSection:e,activeGroup:t,filteredCards:n,searchText:r,setSearchText:s,allItems:c,handleNav:l}){return(0,o.jsxs)(i.Row,{gutter:[16,16],children:[(0,o.jsx)(i.Col,{span:24,children:(0,o.jsxs)(Z,{icon:e?.icon,title:e?.heading,extra:(0,o.jsx)(i.Input,{className:`admin-search`,prefix:(0,o.jsx)(a.SearchOutlined,{}),placeholder:`Search settings…`,allowClear:!0,value:r,onChange:e=>s(e.target.value)}),children:[(0,o.jsx)(`div`,{className:`admin-accent-bar`}),(0,o.jsx)(Dw,{level:5,children:e?.heading}),(0,o.jsx)(Ew,{type:`secondary`,children:e?.desc})]})}),(0,o.jsx)(i.Col,{xs:24,xl:16,style:{alignSelf:`flex-start`},children:(0,o.jsx)(Z,{icon:(0,o.jsx)(a.AppstoreOutlined,{}),title:`Configuration Items`,extra:(0,o.jsxs)(Ew,{type:`secondary`,children:[n.length,` item`,n.length===1?``:`s`]}),children:(0,o.jsx)(i.Row,{gutter:[14,14],children:n.length>0?n.map(e=>(0,o.jsx)(i.Col,{xs:24,sm:12,xl:8,children:(0,o.jsxs)(`div`,{className:`admin-config-item`,children:[(0,o.jsx)(`div`,{className:`admin-config-top-bar`}),(0,o.jsxs)(`div`,{className:`admin-config-body`,children:[(0,o.jsx)(`div`,{className:`admin-config-icon`,children:e.icon}),(0,o.jsxs)(`div`,{className:`admin-config-text`,children:[(0,o.jsx)(`span`,{className:`admin-config-label`,children:e.label}),(0,o.jsx)(`span`,{className:`admin-config-desc`,children:e.desc})]})]}),(0,o.jsx)(`div`,{className:`admin-config-divider`}),(0,o.jsx)(i.Button,{type:`link`,size:`small`,className:`admin-config-manage`,icon:(0,o.jsx)(a.RightOutlined,{}),iconPosition:`end`,children:`Manage`})]})},e.label)):(0,o.jsx)(i.Col,{span:24,children:(0,o.jsx)(`div`,{className:`admin-config-empty`,children:(0,o.jsx)(i.Empty,{description:`No settings found`,image:i.Empty.PRESENTED_IMAGE_SIMPLE})})})})})}),(0,o.jsx)(i.Col,{xs:24,xl:8,style:{alignSelf:`flex-start`},children:(0,o.jsxs)(Z,{icon:(0,o.jsx)(a.FileTextOutlined,{}),title:`Section Overview`,children:[(0,o.jsx)(`div`,{className:`admin-overview-list`,children:Ow.filter(e=>e.group!==`Dashboard`).map(e=>{let n=e.group===t?.group;return(0,o.jsxs)(`div`,{className:`admin-overview-item${n?` active`:``}`,onClick:()=>{let t=e.items[0];t&&l(t.id)},children:[(0,o.jsxs)(`div`,{className:`admin-overview-left`,children:[(0,o.jsx)(`div`,{className:`admin-overview-icon`,children:e.items[0]?.icon}),(0,o.jsxs)(`div`,{className:`admin-overview-text`,children:[(0,o.jsx)(`span`,{className:`admin-overview-name`,children:e.group}),(0,o.jsxs)(`span`,{className:`admin-overview-sub`,children:[e.items.length,` module`,e.items.length===1?``:`s`]})]})]}),(0,o.jsx)(`span`,{className:`admin-overview-count${n?` active`:``}`,children:e.items.length})]},e.group)})}),(0,o.jsxs)(`div`,{className:`admin-overview-footer`,children:[(0,o.jsx)(`span`,{className:`admin-overview-footer-label`,children:`Total configuration items`}),(0,o.jsx)(`span`,{className:`admin-overview-footer-value`,children:c.filter(e=>e.cards).reduce((e,t)=>e+t.cards.length,0)})]})]})})]})}function Pw(){let[e,t]=(0,r.useState)(`dashboard`),[n,s]=(0,r.useState)(``),c=(0,r.useMemo)(()=>Ow.flatMap(e=>e.items),[]),l=(0,r.useMemo)(()=>c.find(t=>t.id===e),[c,e]),u=(0,r.useMemo)(()=>Ow.find(t=>t.items.some(t=>t.id===e)),[e]),d=(0,r.useMemo)(()=>{if(!l?.cards)return[];let e=n.trim().toLowerCase();return e?l.cards.filter(t=>t.label.toLowerCase().includes(e)||t.desc.toLowerCase().includes(e)):l.cards},[l,n]),f=(0,r.useMemo)(()=>Ow.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),s(``)};return e===`dashboard`||l?.heading,(0,o.jsxs)(`main`,{className:`admin-page`,children:[(0,o.jsx)(`div`,{className:`admin-breadcrumb`,children:(0,o.jsx)(i.Breadcrumb,{items:[{title:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(a.HomeOutlined,{}),` Home`]})},{title:`Admin`}]})}),(0,o.jsxs)(i.Row,{gutter:[16,16],className:`admin-wrapper`,children:[(0,o.jsx)(i.Col,{xs:24,lg:6,xl:5,children:(0,o.jsxs)(Z,{title:`Admin Console`,icon:(0,o.jsx)(a.SettingOutlined,{}),children:[(0,o.jsxs)(`div`,{className:`admin-sidebar-banner`,children:[(0,o.jsx)(`span`,{className:`admin-sidebar-banner-title`,children:`Admin Panel`}),(0,o.jsx)(`span`,{className:`admin-sidebar-banner-sub`,children:`Configuration Center`}),(0,o.jsxs)(i.Row,{gutter:[8,0],children:[(0,o.jsx)(i.Col,{span:12,children:(0,o.jsxs)(`div`,{className:`admin-sidebar-pill`,children:[(0,o.jsx)(`span`,{className:`admin-sidebar-pill-label`,children:`Groups`}),(0,o.jsx)(`span`,{className:`admin-sidebar-pill-value`,children:Ow.length})]})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsxs)(`div`,{className:`admin-sidebar-pill`,children:[(0,o.jsx)(`span`,{className:`admin-sidebar-pill-label`,children:`Modules`}),(0,o.jsx)(`span`,{className:`admin-sidebar-pill-value`,children:c.length})]})})]})]}),(0,o.jsx)(i.Menu,{mode:`inline`,selectedKeys:[e],items:f,onClick:({key:e})=>p(e),className:`admin-sidebar-menu`})]})}),(0,o.jsx)(i.Col,{xs:24,lg:18,xl:19,children:e===`dashboard`?(0,o.jsx)(Mw,{}):l?.component===`form-groups`?(0,o.jsx)(x_,{}):l?.component===`detail-groups`?(0,o.jsx)(W_,{}):l?.component===`row-actions`?(0,o.jsx)(Mv,{}):l?.component===`users`?(0,o.jsx)(GC,{}):l?.component===`teams`?(0,o.jsx)(ZC,{}):l?.component===`roles`?(0,o.jsx)(mw,{}):l?.component===`permissions`?(0,o.jsx)(xw,{}):l?.component===`templates`?(0,o.jsx)(Vv,{}):l?.component===`ai-services`?(0,o.jsx)(Gv,{}):l?.component===`bgc-integration`?(0,o.jsx)(Zv,{}):(0,o.jsx)(Nw,{activeSection:l,activeGroup:u,filteredCards:d,searchText:n,setSearchText:s,allItems:c,handleNav:p})})]})]})}var{Title:Fw}=i.Typography;function Iw(){let e=(0,s.useNavigate)(),{state:t}=(0,s.useLocation)(),n=t?.moduleName||`stickyNotes`,r=t?.title||`Sticky Notes`,c={...t?.request,params:{...t?.request?.params,limit:200,offset:0}};return(0,o.jsxs)(`div`,{children:[(0,o.jsx)(i.Button,{type:`text`,icon:(0,o.jsx)(a.ArrowLeftOutlined,{}),onClick:()=>e(-1),style:{marginBottom:12},children:`Back`}),(0,o.jsx)(bt,{moduleName:n,title:r,columns:4,request:c,viewAll:!1})]})}var{Text:Lw,Title:Rw}=i.Typography,zw=10*1024*1024,Bw=`/templates/test_cases_flow_template.base64.txt`,Vw=`test_cases_flow_template.xlsx`,Hw=`module | subModule | step_order | description | actions | key | value | expected | scenario`,Uw={idle:0,module_set:1,encoding:1,validating:2,preview:3,inserting:3,done:4,error:1},Ww=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Bulk upload`,href:`/bulk-upload`}];function Gw(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 Kw(e){return e.filter(e=>e.row_status===`valid`).map(e=>{let t={...e};return delete t.row_status,delete t.errors,t})}function qw(e){return e.flatMap(e=>(e.errors??[]).map(t=>({id:e.id,...t})))}function Jw({errors:e}){return(0,o.jsx)(`div`,{className:`bulk-tooltip-errors`,children:(e??[]).map((e,t)=>(0,o.jsx)(`div`,{children:e.message},`${e.field}-${t}`))})}function Yw({errors:e,expanded:t,onToggle:n,onSummaryClick:r}){return e.length===0?null:(0,o.jsxs)(`div`,{className:`bulk-error-banner`,children:[(0,o.jsxs)(`div`,{className:`bulk-error-summary`,children:[(0,o.jsxs)(`button`,{type:`button`,className:`bulk-error-summary-main`,onClick:r,"aria-label":`Scroll to first invalid row`,children:[(0,o.jsx)(a.ExclamationCircleOutlined,{className:`bulk-error-icon`}),(0,o.jsxs)(`span`,{children:[e.length,` validation error(s) found`]})]}),(0,o.jsx)(i.Button,{type:`link`,onClick:n,"aria-expanded":t,children:t?`Hide Errors`:`View Errors`})]}),t&&(0,o.jsx)(`div`,{className:`bulk-error-list`,role:`region`,"aria-label":`Validation error details`,children:e.map((e,t)=>(0,o.jsxs)(`div`,{className:`bulk-error-line`,children:[(0,o.jsxs)(`span`,{className:`bulk-row-chip`,children:[`Row `,e.id]}),(0,o.jsx)(`span`,{children:e.message})]},`${e.id}-${e.field}-${t}`))})]})}function Xw({rows:e,view:t,onViewChange:n,onConfirm:r,onReset:s,saving:c,firstInvalidRowId:l,firstInvalidRowRef:u}){let d=e.filter(e=>e.row_status===`invalid`),f=t===`errors`?d:e,p=d.length>0||c;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(i.Row,{justify:`space-between`,align:`middle`,gutter:[16,16],className:`bulk-table-toolbar`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsxs)(i.Space.Compact,{children:[(0,o.jsx)(i.Button,{type:t===`all`?`primary`:`default`,onClick:()=>n(`all`),children:`All rows`}),(0,o.jsx)(i.Button,{type:t===`errors`?`primary`:`default`,onClick:()=>n(`errors`),children:`Errors only`})]})}),(0,o.jsx)(i.Col,{children:(0,o.jsxs)(Lw,{type:`secondary`,children:[e.length,` row(s)`]})})]}),(0,o.jsx)(`div`,{className:`bulk-table-wrap`,children:(0,o.jsxs)(`table`,{className:`bulk-preview-table`,children:[(0,o.jsx)(`thead`,{children:(0,o.jsxs)(`tr`,{children:[(0,o.jsx)(`th`,{className:`bulk-col-row`,children:`Row`}),(0,o.jsx)(`th`,{className:`bulk-col-flow`,children:`Submodule`}),(0,o.jsx)(`th`,{className:`bulk-col-description`,children:`Description`}),(0,o.jsx)(`th`,{className:`bulk-col-keyword`,children:`Action`}),(0,o.jsx)(`th`,{className:`bulk-col-target`,children:`Key`}),(0,o.jsx)(`th`,{className:`bulk-col-status`,children:`Status`}),(0,o.jsx)(`th`,{className:`bulk-col-error`,children:`Error`})]})}),(0,o.jsx)(`tbody`,{children:f.map(e=>{let t=e.errors??[],n=e.row_status===`invalid`;return(0,o.jsxs)(`tr`,{ref:n&&e.id===l?u:null,className:n?`bulk-row-invalid`:``,children:[(0,o.jsx)(`td`,{children:e.id}),(0,o.jsx)(`td`,{title:e.submodule,children:e.submodule}),(0,o.jsx)(`td`,{title:e.description,children:e.description?e.description:(0,o.jsx)(`span`,{className:`bulk-empty-text`,children:`-empty-`})}),(0,o.jsx)(`td`,{children:(0,o.jsx)(`code`,{className:`bulk-code-chip`,children:e.actions})}),(0,o.jsx)(`td`,{title:e.key,children:e.key}),(0,o.jsx)(`td`,{children:n?(0,o.jsx)(i.Tag,{color:`red`,children:`Error`}):(0,o.jsx)(i.Tag,{color:`green`,children:`Valid`})}),(0,o.jsx)(`td`,{children:n?(0,o.jsx)(i.Tooltip,{title:(0,o.jsx)(Jw,{errors:t}),placement:`left`,children:(0,o.jsxs)(`button`,{type:`button`,className:`bulk-error-info`,"aria-label":`View ${t.length} error(s) for row ${e.id}`,children:[(0,o.jsx)(a.InfoCircleOutlined,{}),(0,o.jsx)(i.Badge,{count:t.length,size:`small`})]})}):(0,o.jsx)(`span`,{className:`bulk-error-none`,children:`-`})})]},`${e.id}-${e.step_order}`)})})]})}),(0,o.jsxs)(i.Space,{className:`bulk-actions`,children:[(0,o.jsx)(i.Button,{icon:(0,o.jsx)(a.ReloadOutlined,{}),onClick:s,children:`Reset`}),(0,o.jsx)(i.Button,{type:`primary`,icon:(0,o.jsx)(a.SaveOutlined,{}),loading:c,disabled:p,onClick:r,children:d.length>0?`Fix ${d.length} error(s) to proceed`:`Save to database`})]})]})}function Zw(){let n=(0,s.useNavigate)(),c=(0,r.useMemo)(()=>t.c(),[]),l=(0,r.useRef)(null),u=(0,r.useRef)(null),[d,f]=(0,r.useState)([]),[p,m]=(0,r.useState)(``),[h,g]=(0,r.useState)(`idle`),[_,v]=(0,r.useState)(!1),[y,b]=(0,r.useState)(null),[x,S]=(0,r.useState)([]),[C,w]=(0,r.useState)(`all`),[T,E]=(0,r.useState)(null),[D,O]=(0,r.useState)(null),[k,A]=(0,r.useState)(!1),j=d.map(e=>({value:e.modulename,label:e.modulename})),M=qw(x),N=h===`encoding`||h===`validating`,P=!!p&&!N,F=Uw[h]??0,I=x.find(e=>e.row_status===`invalid`)?.id,L=(0,r.useCallback)(()=>{m(``),g(`idle`),v(!1),b(null),S([]),w(`all`),E(null),O(null),l.current&&(l.current.value=``)},[]);(0,r.useEffect)(()=>{async function e(){try{f((await vh({project:c?.name??``,activeOnly:!0}))?.items??[])}catch(e){console.error(e),i.message.error(`Unable to load modules.`)}}e()},[c?.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>zw){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 Gw(e);g(`validating`),S((await ph({filename:e.name,project:c?.name??``,module:p,file_base64:n,file_type:t}))?.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(Bw);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 a=new Blob([r],{type:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`}),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=Vw,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o),i.message.success(`Sample template downloaded.`)}catch(e){console.error(e),i.message.error(`Unable to download sample template.`)}},ee=async()=>{g(`inserting`),E(null);try{O(await mh({project:c?.name??``,module:p,uploaded_by:localStorage.getItem(`user_Email`)??``,rows:Kw(x)})),g(`done`),i.message.success(`Bulk upload saved. Redirecting to view test cases...`),window.setTimeout(()=>n(`/viewTestCase`),900)}catch(e){console.error(e),E(e.payload??{code:`NETWORK_ERROR`,message:e.message||`Could not reach the server.`}),g(`preview`)}},te=(0,r.useCallback)(()=>{u.current?.scrollIntoView({behavior:`smooth`,block:`center`})},[]),V=[`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,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:Ww})}),c?.name&&(0,o.jsx)(i.Col,{children:(0,o.jsx)(Lw,{strong:!0,children:c.name})})]}),(0,o.jsxs)(`div`,{className:`zt-page zt-page-wide bulk-page`,children:[(0,o.jsxs)(`div`,{className:`bulk-header`,children:[(0,o.jsx)(Rw,{level:3,children:`Bulk upload test cases`}),(0,o.jsxs)(i.Space,{direction:`vertical`,size:4,children:[(0,o.jsx)(Lw,{type:`secondary`,children:Hw}),(0,o.jsx)(Lw,{type:`secondary`,children:`Use the sample template for the required columns. Uploaded rows are saved as Active by default.`})]})]}),(0,o.jsx)(`div`,{className:`bulk-stepbar`,children:[`Select`,`Upload`,`Validate`,`Save`].map((e,t)=>(0,o.jsxs)(`span`,{className:t<F?`bulk-step-active`:``,children:[t+1,` `,e]},e))}),(0,o.jsx)(i.Card,{className:`v1-card zt-fall`,title:`1. Module selector`,children:(0,o.jsx)(i.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,o.jsxs)(i.Card,{className:`v1-card zt-fall`,title:`2. File upload`,extra:(0,o.jsx)(i.Button,{icon:(0,o.jsx)(a.DownloadOutlined,{}),onClick:B,children:`Download Sample Template`}),children:[(0,o.jsx)(i.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,o.jsxs)(`button`,{type:`button`,className:V,disabled:!P,onClick:()=>l.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,o.jsx)(a.CloudUploadOutlined,{className:`bulk-upload-icon`}),y?(0,o.jsxs)(`span`,{className:`bulk-file-chip`,children:[y.name,` - `,Math.ceil(y.size/1024),` KB`]}):(0,o.jsx)(`span`,{children:`Drag & drop here, or click to browse`})]}),(0,o.jsx)(`input`,{ref:l,hidden:!0,type:`file`,accept:`.xlsx,.csv`,onChange:e=>z(e.target.files?.[0])}),N&&(0,o.jsx)(i.Progress,{percent:h===`encoding`?45:82,showInfo:!1,size:`small`}),T&&h!==`preview`&&(0,o.jsx)(i.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`})]}),x.length>0&&(0,o.jsxs)(i.Card,{className:`v1-card zt-fall`,title:`3. Validation result`,children:[(0,o.jsx)(Yw,{errors:M,expanded:k,onToggle:()=>A(e=>!e),onSummaryClick:te}),T&&h===`preview`&&(0,o.jsx)(i.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`}),(0,o.jsx)(Xw,{rows:x,view:C,onViewChange:w,onConfirm:ee,onReset:L,saving:h===`inserting`,firstInvalidRowId:I,firstInvalidRowRef:u})]}),D&&h===`done`&&(0,o.jsxs)(i.Card,{className:`v1-card zt-fall`,title:`4. Upload complete`,children:[(0,o.jsxs)(i.Row,{gutter:[16,16],className:`bulk-metrics`,children:[(0,o.jsx)(i.Col,{xs:24,md:8,children:(0,o.jsxs)(`div`,{children:[(0,o.jsx)(Lw,{children:`Total`}),(0,o.jsx)(`strong`,{children:x.length})]})}),(0,o.jsx)(i.Col,{xs:24,md:8,children:(0,o.jsxs)(`div`,{children:[(0,o.jsx)(Lw,{children:`Inserted`}),(0,o.jsx)(`strong`,{children:D.inserted??0})]})}),(0,o.jsx)(i.Col,{xs:24,md:8,children:(0,o.jsxs)(`div`,{children:[(0,o.jsx)(Lw,{children:`Failed`}),(0,o.jsx)(`strong`,{children:D.failed??0})]})})]}),(0,o.jsx)(i.Alert,{type:`success`,showIcon:!0,icon:(0,o.jsx)(a.CheckCircleOutlined,{}),message:`${D.inserted??0} test cases saved to database - module: ${p}`,className:`bulk-inline-alert`}),(0,o.jsx)(i.Button,{icon:(0,o.jsx)(a.ReloadOutlined,{}),onClick:L,children:`Upload another file`})]})]})]})}var Qw=[{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:$w}=i.Typography,eT=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}],tT={tags:`regression`,active:1},nT={module:{dbName:`Modules`,formField:`module`,label:`Module`}};function rT(e=[]){return e.map(e=>({value:e,label:e}))}function iT(e=``){return String(e??``).trim()}function aT(e=``){return iT(e).toLowerCase()}function oT(e=[]){let t=new Map;return e.forEach(e=>{let n=iT(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function sT(e=[],t,n){let r=iT(t).toLowerCase(),i=iT(n).toLowerCase();return e.reduce((e,t)=>{let n=iT(t?.module).toLowerCase(),a=iT(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 cT({icon:e,title:t}){return(0,o.jsxs)(i.Space,{size:10,align:`center`,children:[(0,o.jsx)(`div`,{className:`v1-section-icon-box`,children:e}),(0,o.jsx)($w,{strong:!0,className:`v1-section-label`,children:t})]})}function lT(){let[t]=i.Form.useForm(),[n]=i.Form.useForm(),[c,l]=(0,r.useState)([]),[u,d]=(0,r.useState)([]),[f,p]=(0,r.useState)([]),[m,h]=(0,r.useState)(!1),[g,_]=(0,r.useState)(!1),[v,y]=(0,r.useState)({open:!1,typeKey:`module`}),[b,x]=(0,r.useState)(!1),[S,C]=(0,r.useState)(!1),[w,T]=(0,r.useState)(!1),E=(0,s.useNavigate)(),D=nT[v.typeKey],O=(0,r.useMemo)(()=>rT(c),[c]),k=i.Form.useWatch(`module`,t),A=i.Form.useWatch(`flow`,t),j=!!iT(k),M=!!iT(A),N=!j,P=!j||!M,F=(e,t=[])=>{e===`module`&&l(t)},I=async()=>{h(!0);try{l((await ch(nT.module.dbName))?.items??[])}catch(e){console.error(`Unable to load testing options:`,e),i.message.error(`Unable to load testing options.`)}finally{h(!1)}},L=(0,r.useCallback)(async e=>{let n=iT(e);if(d([]),p([]),t.setFieldsValue({step_order:void 0}),n){_(!0);try{let e=await fh({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];d(t),p(oT(t))}catch(e){console.error(`Unable to load flows:`,e),i.message.error(`Unable to load flows.`)}finally{_(!1)}}},[t]),R=(0,r.useCallback)(async(e,n,r)=>{let a=iT(e),o=iT(n);if(!a||!o){t.setFieldsValue({step_order:void 0});return}C(!0);try{t.setFieldsValue({step_order:sT(r,a,o)})}catch(e){console.error(`Unable to load step order:`,e),i.message.error(`Unable to load step order.`)}finally{C(!1)}},[t]);(0,r.useEffect)(()=>{Promise.resolve().then(I)},[]),(0,r.useEffect)(()=>{Promise.resolve().then(()=>L(k))},[L,k]),(0,r.useEffect)(()=>{Promise.resolve().then(()=>R(k,A,u))},[u,R,A,k]);let z=async e=>{let n={module:iT(e.module),flow:iT(e.flow),step_order:Number(e.step_order),description:iT(e.description),keyword:aT(e.keyword),target:iT(e.target),value:iT(e.value),expected:iT(e.expected),tags:e.tags?iT(e.tags):tT.tags,active:Number(e.active)};T(!0);try{await dh(n),i.message.success(`Test case details saved successfully.`),t.resetFields(),d([]),p([])}catch(e){console.error(`Unable to save test case:`,e),i.message.error(`Unable to save test case.`)}finally{T(!1)}},B=(e,n)=>{t.setFieldsValue({[e]:iT(n)})},ee=e=>{t.setFieldsValue({module:iT(e),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:tT.tags,value:void 0,expected:void 0})},te=e=>{t.setFieldsValue({flow:iT(e),step_order:void 0})},V=e=>{let t=nT[e];y({open:!0,typeKey:e}),n.setFieldsValue({name:``,type:t.label})},ne=()=>{y(e=>({...e,open:!1})),n.resetFields()},re=async()=>{try{let e=iT((await n.validateFields()).name),r=await lh({name:e,type:D.dbName});F(v.typeKey,r?.items??[]),t.setFieldsValue({[D.formField]:e}),i.message.success(`${D.label} added successfully.`),ne()}catch(e){if(e?.errorFields)return;console.error(`Unable to save testing option:`,e),i.message.error(`Unable to add ${D.label.toLowerCase()}.`)}finally{x(!1)}};return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:eT})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`link`,onClick:()=>E(`/zinnext-home`),children:`View Table`})})]}),(0,o.jsx)(`div`,{className:`v1-page`,children:(0,o.jsxs)(`div`,{className:`v1-page-inner`,children:[(0,o.jsx)(`div`,{className:`v1-page-header`,children:(0,o.jsxs)(i.Space,{align:`center`,size:10,children:[(0,o.jsx)(a.ProfileOutlined,{className:`v1-outer-icon`}),(0,o.jsx)(`div`,{children:(0,o.jsx)($w,{strong:!0,style:{fontSize:16},children:`Add Test Case`})})]})}),(0,o.jsx)(Z,{children:(0,o.jsxs)(i.Form,{form:t,className:`v1-form`,layout:`vertical`,colon:!1,requiredMark:(e,{required:t})=>(0,o.jsxs)(o.Fragment,{children:[e,t&&(0,o.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),initialValues:tT,onFinish:z,autoComplete:`off`,children:[(0,o.jsx)(i.Card,{className:`v1-card`,title:(0,o.jsx)(cT,{icon:(0,o.jsx)(a.FileTextOutlined,{}),title:`Test Case Details`}),extra:(0,o.jsx)($w,{type:`secondary`,className:`v1-card-subtitle`,children:`Module, flow, step order and execution data`}),children:(0,o.jsxs)(i.Row,{gutter:[24,0],children:[(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsxs)(i.Space.Compact,{style:{width:`100%`},children:[(0,o.jsx)(i.Form.Item,{label:`Module`,name:`module`,style:{flex:1},children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,loading:m,optionFilterProp:`label`,placeholder:`Select module`,options:O,onChange:ee})}),(0,o.jsx)(i.Button,{"aria-label":`Add module`,icon:(0,o.jsx)(a.PlusOutlined,{}),style:{marginTop:30},onClick:()=>V(`module`)})]})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Flow`,name:`flow`,children:(0,o.jsx)(i.AutoComplete,{maxLength:100,allowClear:!0,disabled:N,options:f,placeholder:g?`Loading flows`:`Enter flow`,onChange:te,filterOption:(e,t)=>t?.value?.toLowerCase().includes(e.toLowerCase())})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Step Order`,name:`step_order`,validateTrigger:[`onBlur`,`onChange`],children:(0,o.jsx)(i.Input,{maxLength:10,disabled:!0,placeholder:S?`Loading step order`:`Step order`})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Action`,name:`keyword`,children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,disabled:P,optionFilterProp:`label`,placeholder:`Select action`,options:Qw,onChange:e=>t.setFieldsValue({keyword:aT(e)})})})}),(0,o.jsx)(i.Col,{xs:24,children:(0,o.jsx)(i.Form.Item,{label:`Description`,name:`description`,children:(0,o.jsx)(i.Input.TextArea,{rows:3,maxLength:255,disabled:P,placeholder:`Enter description`,showCount:!0,onBlur:e=>B(`description`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Key`,name:`target`,children:(0,o.jsx)(i.Input,{maxLength:255,disabled:P,placeholder:`Enter target`,onBlur:e=>B(`target`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Tags`,name:`tags`,children:(0,o.jsx)(i.Input,{maxLength:200,disabled:P,placeholder:`Enter tags`,prefix:(0,o.jsx)(a.TagsOutlined,{className:`v1-input-icon`}),onBlur:e=>B(`tags`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Value`,name:`value`,children:(0,o.jsx)(i.Input.TextArea,{rows:4,disabled:P,placeholder:`Enter value`,onBlur:e=>B(`value`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Expected`,name:`expected`,children:(0,o.jsx)(i.Input.TextArea,{rows:4,disabled:P,placeholder:`Enter expected result`,onBlur:e=>B(`expected`,e.target.value)})})})]})}),(0,o.jsx)(`div`,{className:`v1-form-actions`,children:(0,o.jsx)(i.Form.Item,{children:(0,o.jsxs)(i.Space,{children:[(0,o.jsx)(i.Button,{type:`primary`,htmlType:`submit`,loading:w,disabled:P,children:`Submit`}),(0,o.jsx)(i.Button,{onClick:()=>{t.resetFields(),d([]),p([])},children:`Reset`})]})})})]})}),(0,o.jsx)(i.Modal,{title:`Add ${D.label}`,open:v.open,confirmLoading:b,okText:`Add`,onCancel:ne,onOk:()=>{x(!0),re()},destroyOnHidden:!0,children:(0,o.jsxs)(i.Form,{form:n,layout:`vertical`,colon:!1,className:`v1-form`,requiredMark:(e,{required:t})=>(0,o.jsxs)(o.Fragment,{children:[e,t&&(0,o.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),children:[(0,o.jsx)(i.Form.Item,{label:`Name`,name:`name`,children:(0,o.jsx)(i.Input,{maxLength:100,placeholder:`Enter ${D.label.toLowerCase()} name`,onBlur:e=>{n.setFieldsValue({name:iT(e.target.value)})}})}),(0,o.jsx)(i.Form.Item,{label:`Type`,name:`type`,children:(0,o.jsx)(i.Input,{disabled:!0})})]})})]})})]})}var{Text:uT}=i.Typography,dT=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`}];function fT(e=``){return String(e??``).trim()}function pT(e=[],t){return e.map(e=>({value:e.id,label:e[t]}))}var mT=[{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,o.jsx)(i.Tag,{color:`green`,children:`Positive`}):(0,o.jsx)(i.Tag,{color:`red`,children:`Negative`})}],hT={key:!1,value:!1,expected:!1};function gT(e,t){return t?e[t]??hT:hT}function _T(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function vT(){let[n]=i.Form.useForm(),c=(0,s.useNavigate)(),[l]=(0,s.useSearchParams)(),u=l.get(`edit`),d=!!u,f=(0,r.useMemo)(()=>t.c(),[]),[p,m]=(0,r.useState)([]),[h,g]=(0,r.useState)([]),[_,v]=(0,r.useState)([]),[y,b]=(0,r.useState)(Qw),[x,S]=(0,r.useState)({}),[C,w]=(0,r.useState)(!1),[T,E]=(0,r.useState)(!1),[D,O]=(0,r.useState)(!1),[k,A]=(0,r.useState)(!1),[j,M]=(0,r.useState)(!1),N=i.Form.useWatch(`module`,n),P=i.Form.useWatch(`submodule`,n),F=i.Form.useWatch(`actions`,n),I=!!N,L=!!P,R=(0,r.useMemo)(()=>gT(x,F),[x,F]),z=(0,r.useMemo)(()=>pT(p,`modulename`),[p]),B=(0,r.useMemo)(()=>pT(h,`submodulename`),[h]),ee=(0,r.useMemo)(()=>p.find(e=>e.id===N)?.modulename??``,[p,N]),te=(0,r.useMemo)(()=>h.find(e=>e.id===P)?.submodulename??``,[P,h]),V=(0,r.useCallback)(async()=>{try{let e=await uh();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),i.message.error(`Unable to load action validation rules.`)}},[]),ne=(0,r.useCallback)(async e=>{if(!e){m([]);return}w(!0);try{m((await vh({project:e,activeOnly:!0}))?.items??[])}catch(e){console.error(`Unable to load modules:`,e),i.message.error(`Unable to load modules.`)}finally{w(!1)}},[]),re=(0,r.useCallback)(async(e,t)=>{if(!e||!t){g([]);return}E(!0);try{g((await xh({project:e,module:t,activeOnly:!0}))?.items??[])}catch(e){console.error(`Unable to load submodules:`,e),i.message.error(`Unable to load submodules.`)}finally{E(!1)}},[]),H=(0,r.useCallback)(async(e,t,r,a=``)=>{if(!e||!t||!r){v([]),n.setFieldsValue({step_order:void 0});return}O(!0);try{let[i,o]=await Promise.all([wh({product_parent_ID:e,module_parent_ID:t,submodule_parent_ID:r,actions:a,limit:1e3}),Dh({product_parent_ID:e,module_parent_ID:t,submodule_parent_ID:r})]);v(i?.items??[]),n.setFieldsValue({step_order:o?.step_order??1})}catch(e){console.error(`Unable to load flows:`,e),i.message.error(`Unable to load flows.`)}finally{O(!1)}},[n]),U=(0,r.useCallback)(async(e=``)=>{if(!(!f?.id||!N||!P)){O(!0);try{v((await wh({product_parent_ID:f.id,module_parent_ID:N,submodule_parent_ID:P,actions:e,limit:1e3}))?.items??[])}catch(e){console.error(`Unable to load action flows:`,e),i.message.error(`Unable to load action steps.`)}finally{O(!1)}}},[f?.id,N,P]),W=(0,r.useCallback)(async()=>{if(!(!u||!f?.name)){M(!0);try{let e=await Eh(u);await re(f.name,e.module),v((await wh({product_parent_ID:e.product_parent_ID,module_parent_ID:e.module_parent_ID,submodule_parent_ID:e.submodule_parent_ID,limit:1e3}))?.items??[]),n.setFieldsValue({module:e.module_parent_ID,submodule:e.submodule_parent_ID,step_order:e.step_order,actions:e.actions,key:e.key,value:e.value,expected:e.expected,description:e.description,scenario:e.scenario===1,active:Number(e.active)!==0})}catch(e){console.error(`Unable to load test flow:`,e),i.message.error(`Unable to load test flow for edit.`),c(`/viewTestCase`)}finally{M(!1)}}},[u,n,re,c,f?.name]);return(0,r.useEffect)(()=>{if(!f){c(`/select-project`,{replace:!0});return}Promise.resolve().then(async()=>{await V(),await ne(f.name),u&&await W()})},[f,c,V,ne,u,W]),f?(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:dT})}),(0,o.jsx)(i.Col,{children:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.ProjectOutlined,{}),(0,o.jsx)(uT,{strong:!0,children:f.name})]})})]}),(0,o.jsx)(`div`,{className:`zt-page`,children:(0,o.jsxs)(i.Form,{form:n,layout:`vertical`,colon:!1,className:`v1-form`,initialValues:{scenario:!0,active:!0},onFinish:async e=>{let t={product_parent_ID:Number(f?.id),module_parent_ID:Number(e.module),submodule_parent_ID:Number(e.submodule),description:fT(e.description),actions:fT(e.actions),key:fT(e.key),value:fT(e.value),expected:fT(e.expected),scenario:+!!e.scenario,active:+!!e.active};A(!0);try{if(d){await Oh(u,{...t,step_order:Number(e.step_order)}),i.message.success(`Test case updated successfully.`),c(`/viewTestCase`);return}await Th(t),i.message.success(`Step saved (#${e.step_order}).`),n.setFieldsValue({actions:void 0,key:void 0,value:void 0,expected:void 0,description:void 0}),await H(t.product_parent_ID,t.module_parent_ID,t.submodule_parent_ID)}catch(e){console.error(`Unable to save test case:`,e),i.message.error(d?`Unable to update test case.`:`Unable to save step.`)}finally{A(!1)}},autoComplete:`off`,disabled:j,children:[(0,o.jsx)(i.Card,{className:`v1-card zt-fall`,title:(0,o.jsxs)(i.Space,{size:8,className:`zt-section-title`,children:[(0,o.jsx)(`span`,{className:`zt-step-tag`,children:`1`}),(0,o.jsx)(`span`,{children:`Module & Submodule`})]}),children:(0,o.jsxs)(i.Row,{gutter:[24,0],align:`bottom`,children:[(0,o.jsx)(i.Col,{xs:24,md:6,children:(0,o.jsx)(i.Form.Item,{label:`Module`,name:`module`,children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,loading:C,placeholder:`Select module`,options:z,onChange:e=>{let t=p.find(t=>t.id===e)?.modulename??``;n.setFieldsValue({module:e,submodule:void 0,step_order:void 0,actions:void 0,key:void 0,value:void 0,expected:void 0}),_T(n,[`actions`,`key`,`value`,`expected`]),g([]),v([]),re(f?.name,t)}})})}),(0,o.jsx)(i.Col,{xs:24,md:6,children:(0,o.jsx)(i.Form.Item,{label:`Submodule`,name:`submodule`,children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,disabled:!I,loading:T,placeholder:I?`Select submodule`:`Select module first`,options:B,onChange:e=>{n.setFieldsValue({submodule:e,actions:void 0,key:void 0,value:void 0,expected:void 0}),_T(n,[`actions`,`key`,`value`,`expected`]),H(f?.id,N,e)}})})}),(0,o.jsx)(i.Col,{xs:24,md:6,children:(0,o.jsx)(i.Form.Item,{label:`Scenario`,name:`scenario`,valuePropName:`checked`,children:(0,o.jsx)(i.Switch,{disabled:!L,checkedChildren:`Positive`,unCheckedChildren:`Negative`})})}),(0,o.jsx)(i.Col,{xs:24,md:6,children:(0,o.jsx)(i.Form.Item,{label:`Active`,name:`active`,valuePropName:`checked`,children:(0,o.jsx)(i.Switch,{checkedChildren:`Active`,unCheckedChildren:`Inactive`})})})]})}),L&&(0,o.jsxs)(i.Card,{className:`v1-card zt-fall`,title:(0,o.jsxs)(i.Space,{size:8,className:`zt-section-title`,children:[(0,o.jsx)(`span`,{className:`zt-step-tag`,children:`2`}),(0,o.jsx)(a.FileTextOutlined,{}),(0,o.jsx)(`span`,{children:`Step Details`})]}),extra:(0,o.jsxs)(uT,{type:`secondary`,children:[ee,` / `,te]}),children:[(0,o.jsxs)(i.Row,{gutter:[24,0],children:[(0,o.jsx)(i.Col,{xs:24,md:6,children:(0,o.jsx)(i.Form.Item,{label:`Step Order`,name:`step_order`,children:(0,o.jsx)(i.Input,{disabled:!0,placeholder:D?`Loading…`:`Auto`})})}),(0,o.jsx)(i.Col,{xs:24,md:18,children:(0,o.jsx)(i.Form.Item,{label:`Action`,name:`actions`,rules:[{required:!0,message:`Mandatory Field`}],children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,placeholder:`Select action`,options:y,onChange:e=>{let t=gT(x,e);n.setFieldsValue({actions:e,key:t.key?n.getFieldValue(`key`):void 0,value:t.value?n.getFieldValue(`value`):void 0,expected:t.expected?n.getFieldValue(`expected`):void 0}),_T(n,[`key`,`value`,`expected`]),U(e||``)}})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Key`,name:`key`,rules:[{required:R.key,message:`Key is required for this action`}],children:(0,o.jsx)(i.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,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Value`,name:`value`,rules:[{required:R.value,message:`Value is required for this action`}],children:(0,o.jsx)(i.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,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Expected`,name:`expected`,rules:[{required:R.expected,message:`Expected result is required for this action`}],children:(0,o.jsx)(i.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,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Description`,name:`description`,children:(0,o.jsx)(i.Input.TextArea,{rows:2,maxLength:255,showCount:!0,placeholder:`Enter description`})})})]}),(0,o.jsxs)(i.Space,{className:`zt-actions`,children:[(0,o.jsx)(i.Button,{onClick:()=>{if(d){c(`/viewTestCase`);return}n.resetFields(),g([]),v([]),E(!1),O(!1)},children:`Cancel`}),(0,o.jsx)(i.Button,{type:`primary`,htmlType:`submit`,loading:k||j,children:d?`Update Test Case`:`Save & Continue`})]})]},`${N}-${P}`),L&&(0,o.jsx)(i.Card,{className:`v1-card zt-fall`,title:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.TableOutlined,{}),(0,o.jsx)(`span`,{children:`Added Steps`})]}),extra:(0,o.jsx)(i.Tag,{children:F?`${_.length} ${F} step(s)`:`${_.length} step(s)`}),children:(0,o.jsx)(hf,{listName:`Added Steps`,loading:D,fields:mT,dataSource:_,current:1,pageSize:Math.max(_.length,1),total:_.length,rowSelection:!1,className:`zt-list-plain zt-list-static`})})]})})]}):null}var{Text:yT}=i.Typography,bT=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`}];function xT(){let n=(0,s.useNavigate)(),c=(0,r.useMemo)(()=>t.c(),[]),[l,u]=(0,r.useState)([]),[d,f]=(0,r.useState)({}),[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(!1),[_,v]=(0,r.useState)(``),[y,b]=(0,r.useState)(!1),[x,S]=(0,r.useState)(1),[C,w]=(0,r.useState)(10),T=(0,r.useCallback)(async e=>{if(!e){u([]);return}m(!0);try{let[t,n]=await Promise.all([vh({project:e}),xh({project:e})]);u(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),i.message.error(`Unable to load modules.`)}finally{m(!1)}},[]);(0,r.useEffect)(()=>{if(!c){n(`/select-project`,{replace:!0});return}Promise.resolve().then(()=>T(c.name))},[c,n,T]);let E=async(e,t)=>{try{await bh(e.id,+!!t),u(n=>n.map(n=>n.id===e.id?{...n,active:+!!t}:n)),i.message.success(`Module ${t?`activated`:`deactivated`}.`)}catch(e){console.error(e),i.message.error(`Unable to update module status.`)}},D=async()=>{let e=_.trim();if(!e){i.message.warning(`Enter a module name.`);return}b(!0);try{await yh({project:c.name,modulename:e}),i.message.success(`Module added.`),g(!1),v(``),S(1),T(c.name)}catch(e){console.error(e),i.message.error(`Unable to add module (maybe it already exists).`)}finally{b(!1)}},O=e=>{n(`/test-cases/zinnext/submodules?module=${encodeURIComponent(e.modulename)}`)};return c?(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:bT})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`link`,onClick:()=>n(`/addTestCase`),children:`Back to Form`})})]}),(0,o.jsxs)(`div`,{className:`zt-page`,children:[(0,o.jsx)(i.Card,{className:`v1-card zt-bar`,children:(0,o.jsxs)(i.Row,{gutter:[16,16],align:`middle`,justify:`space-between`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.ProjectOutlined,{}),(0,o.jsx)(`span`,{children:`Project:`}),(0,o.jsx)(yT,{strong:!0,children:c.name})]})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`primary`,icon:(0,o.jsx)(a.PlusOutlined,{}),onClick:()=>g(!0),children:`Add Module`})})]})}),(0,o.jsx)(i.Card,{className:`v1-card zt-fall`,title:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.AppstoreOutlined,{}),(0,o.jsx)(`span`,{children:`Modules`})]}),children:(0,o.jsx)(hf,{listName:`Modules`,loading:p,fields:[{label:`Module`,value:`modulename`},{label:`Submodules`,value:`submoduleCount`,width:140,render:(e,t)=>(0,o.jsxs)(i.Button,{type:`link`,className:`zt-count-link`,onClick:()=>O(t),children:[d[t.modulename]??0,` submodule(s)`]})},{label:`Active`,value:`active`,width:120,render:(e,t)=>(0,o.jsx)(i.Switch,{checked:e===1,checkedChildren:`On`,unCheckedChildren:`Off`,onChange:e=>E(t,e)})}],dataSource:l,current:x,pageSize:C,total:l.length,onPageChange:S,onPageSizeChange:e=>{S(1),w(e)},rowSelection:!1,className:`zt-list-plain`})})]}),(0,o.jsx)(i.Modal,{title:`Add Module`,open:h,confirmLoading:y,okText:`Add`,onOk:D,onCancel:()=>{g(!1),v(``)},destroyOnHidden:!0,children:(0,o.jsxs)(i.Space,{direction:`vertical`,className:`zt-modal-stack`,children:[(0,o.jsxs)(yT,{type:`secondary`,children:[`Project: `,(0,o.jsx)(`b`,{children:c.name})]}),(0,o.jsx)(i.Input,{placeholder:`Enter module name`,maxLength:100,value:_,onChange:e=>v(e.target.value),onPressEnter:D})]})})]}):null}var{Text:ST}=i.Typography,CT=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`},{label:`Manage Submodules`,href:`/test-cases/zinnext/submodules`}];function wT(){let n=(0,s.useNavigate)(),[c]=(0,s.useSearchParams)(),l=(0,r.useMemo)(()=>t.c(),[]),u=c.get(`module`)??``,[d,f]=(0,r.useState)([]),[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(!1),[_,v]=(0,r.useState)(``),[y,b]=(0,r.useState)(!1),[x,S]=(0,r.useState)(1),[C,w]=(0,r.useState)(10),T=(0,r.useCallback)(async(e,t)=>{if(!e||!t){f([]);return}m(!0);try{f((await xh({project:e,module:t}))?.items??[])}catch(e){console.error(e),i.message.error(`Unable to load submodules.`)}finally{m(!1)}},[]);(0,r.useEffect)(()=>{if(!l){n(`/select-project`,{replace:!0});return}if(!u){n(`/manageModules`,{replace:!0});return}Promise.resolve().then(()=>T(l.name,u))},[l,u,n,T]);let E=async(e,t)=>{try{await Ch(e.id,+!!t),f(n=>n.map(n=>n.id===e.id?{...n,active:+!!t}:n)),i.message.success(`Submodule ${t?`activated`:`deactivated`}.`)}catch(e){console.error(e),i.message.error(`Unable to update submodule status.`)}},D=async()=>{let e=_.trim();if(!e){i.message.warning(`Enter a submodule name.`);return}b(!0);try{await Sh({project:l.name,modulename:u,submodulename:e}),i.message.success(`Submodule added.`),g(!1),v(``),S(1),T(l.name,u)}catch(e){console.error(e),i.message.error(`Unable to add submodule (maybe it already exists).`)}finally{b(!1)}};return!l||!u?null:(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:CT})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`link`,onClick:()=>n(`/manageModules`),children:`Back to Modules`})})]}),(0,o.jsxs)(`div`,{className:`zt-page`,children:[(0,o.jsx)(i.Card,{className:`v1-card zt-bar`,children:(0,o.jsxs)(i.Row,{gutter:[16,16],align:`middle`,justify:`space-between`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsxs)(i.Space,{size:16,wrap:!0,className:`zt-section-title`,children:[(0,o.jsxs)(i.Space,{size:6,children:[(0,o.jsx)(a.ProjectOutlined,{}),(0,o.jsx)(`span`,{children:`Project:`}),(0,o.jsx)(ST,{strong:!0,children:l.name})]}),(0,o.jsxs)(i.Space,{size:6,children:[(0,o.jsx)(a.AppstoreOutlined,{}),(0,o.jsx)(`span`,{children:`Module:`}),(0,o.jsx)(ST,{strong:!0,children:u})]})]})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`primary`,icon:(0,o.jsx)(a.PlusOutlined,{}),onClick:()=>g(!0),children:`Add Submodule`})})]})}),(0,o.jsx)(i.Card,{className:`v1-card zt-fall`,title:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.AppstoreOutlined,{}),(0,o.jsx)(`span`,{children:`Submodules`})]}),children:(0,o.jsx)(hf,{listName:`Submodules`,loading:p,fields:[{label:`Submodule`,value:`submodulename`},{label:`Active`,value:`active`,width:120,render:(e,t)=>(0,o.jsx)(i.Switch,{checked:e===1,checkedChildren:`On`,unCheckedChildren:`Off`,onChange:e=>E(t,e)})}],dataSource:d,current:x,pageSize:C,total:d.length,onPageChange:S,onPageSizeChange:e=>{S(1),w(e)},rowSelection:!1,className:`zt-list-plain`})})]}),(0,o.jsx)(i.Modal,{title:`Add Submodule`,open:h,confirmLoading:y,okText:`Add`,onOk:D,onCancel:()=>{g(!1),v(``)},destroyOnHidden:!0,children:(0,o.jsxs)(i.Space,{direction:`vertical`,className:`zt-modal-stack`,children:[(0,o.jsxs)(ST,{type:`secondary`,children:[`Project: `,(0,o.jsx)(`b`,{children:l.name}),` \xA0|\xA0 Module: `,(0,o.jsx)(`b`,{children:u})]}),(0,o.jsx)(i.Input,{placeholder:`Enter submodule name`,maxLength:100,value:_,onChange:e=>v(e.target.value),onPressEnter:D})]})})]})}var{Text:TT}=i.Typography,ET=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Table`,href:`/viewTestCase`}];function DT(){let n=(0,s.useNavigate)(),[c,l]=(0,r.useState)([]),[u,d]=(0,r.useState)(0),[f,p]=(0,r.useState)(!1),m=(0,r.useMemo)(()=>t.c(),[]),[h,g]=(0,r.useState)(``),[_,v]=(0,r.useState)(1),[y,b]=(0,r.useState)(20),[x,S]=(0,r.useState)(null),C=(0,r.useCallback)(async(e={})=>{p(!0);try{let t=await wh({product_parent_ID:e.project??m?.id??``,search:e.search??h??``,limit:e.pageSize??y,offset:((e.page??_)-1)*(e.pageSize??y)});l(t?.items??[]),d(t?.total??0)}catch(e){console.error(e),i.message.error(`Unable to load test flows.`)}finally{p(!1)}},[m?.id,h,_,y]),w=e=>{i.Modal.confirm({title:`Delete Test Case`,icon:(0,o.jsx)(a.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 kh(e.id),i.message.success(`Test case deleted successfully.`);let t=c.length===1&&_>1?_-1:_;v(t),await C({page:t})}catch(e){throw console.error(`Unable to delete test flow:`,e),i.message.error(`Unable to delete test case.`),e}finally{S(null)}}})};return(0,r.useEffect)(()=>{Promise.resolve().then(()=>{if(!m?.id){n(`/select-project`,{replace:!0});return}C({page:1})})},[]),(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:ET})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`link`,onClick:()=>n(`/addTestCase`),children:`Back to Form`})})]}),(0,o.jsx)(`div`,{className:`zt-page zt-page-wide`,children:(0,o.jsxs)(i.Card,{className:`v1-card`,title:(0,o.jsxs)(i.Space,{size:6,className:`zt-section-title`,children:[(0,o.jsx)(a.TableOutlined,{}),(0,o.jsx)(`span`,{children:`Test Flows`})]}),extra:(0,o.jsxs)(TT,{type:`secondary`,children:[u,` row(s)`]}),children:[(0,o.jsxs)(i.Space,{wrap:!0,className:`zt-toolbar`,children:[(0,o.jsx)(i.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,o.jsx)(i.Button,{icon:(0,o.jsx)(a.ReloadOutlined,{}),onClick:()=>C(),children:`Refresh`})]}),(0,o.jsx)(hf,{listName:`Test Flows`,loading:f,fields:[{label:`Actions`,value:`rowActions`,width:112,fixed:`left`,sorter:!1,render:(e,t)=>(0,o.jsxs)(i.Space,{size:4,className:`zt-row-actions`,children:[(0,o.jsx)(i.Tooltip,{title:`Edit`,children:(0,o.jsx)(i.Button,{type:`text`,size:`small`,icon:(0,o.jsx)(a.EditOutlined,{}),onClick:()=>n(`/addTestCase?edit=${t.id}`)})}),(0,o.jsx)(i.Tooltip,{title:`Delete`,children:(0,o.jsx)(i.Button,{danger:!0,type:`text`,size:`small`,icon:(0,o.jsx)(a.DeleteOutlined,{}),loading:x===t.id,onClick:()=>w(t)})})]})},{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,o.jsx)(i.Tag,{color:`green`,children:`Positive`}):(0,o.jsx)(i.Tag,{color:`red`,children:`Negative`})},{label:`Active`,value:`active`,width:90,render:e=>e===1?(0,o.jsx)(i.Tag,{color:`blue`,children:`Active`}):(0,o.jsx)(i.Tag,{children:`Inactive`})}],dataSource:c,current:_,pageSize:y,total:u,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 OT=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}];function kT(){return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsx)(e.t,{items:OT}),(0,o.jsx)(Va,{moduleName:`test-flows`,rowKey:`id`})]})}var{Text:AT}=i.Typography,jT=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}],MT={tags:`regression`,active:1},NT={module:{dbName:`Modules`,formField:`module`,label:`Module`}},PT={key:!1,value:!1,expected:!1};function FT(e,t){return t?e[t]??PT:PT}function IT(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function LT(e=[]){return e.map(e=>({value:e,label:e}))}function RT(e=``){return String(e??``).trim()}function zT(e=[]){let t=new Map;return e.forEach(e=>{let n=RT(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function BT(e=[],t,n){let r=RT(t).toLowerCase(),i=RT(n).toLowerCase();return e.reduce((e,t)=>{let n=RT(t?.module).toLowerCase(),a=RT(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 VT({icon:e,title:t}){return(0,o.jsxs)(i.Space,{size:10,align:`center`,children:[(0,o.jsx)(`div`,{className:`v1-section-icon-box`,children:e}),(0,o.jsx)(AT,{strong:!0,className:`v1-section-label`,children:t})]})}function HT(){let[t]=i.Form.useForm(),[n]=i.Form.useForm(),[c,l]=(0,r.useState)([]),[u,d]=(0,r.useState)([]),[f,p]=(0,r.useState)([]),[m,h]=(0,r.useState)(Qw),[g,_]=(0,r.useState)({}),[v,y]=(0,r.useState)(!1),[b,x]=(0,r.useState)(!1),[S,C]=(0,r.useState)({open:!1,typeKey:`module`}),[w,T]=(0,r.useState)(!1),[E,D]=(0,r.useState)(!1),[O,k]=(0,r.useState)(!1),A=(0,s.useNavigate)(),j=NT[S.typeKey],M=(0,r.useMemo)(()=>LT(c),[c]),N=i.Form.useWatch(`module`,t),P=i.Form.useWatch(`flow`,t),F=i.Form.useWatch(`keyword`,t),I=!!RT(N),L=!!RT(P),R=!I,z=!I||!L,B=(0,r.useMemo)(()=>FT(g,F),[g,F]),ee=(e,t=[])=>{e===`module`&&l(t)},te=async()=>{y(!0);try{l((await ch(NT.module.dbName))?.items??[])}catch(e){console.error(`Unable to load testing options:`,e),i.message.error(`Unable to load testing options.`)}finally{y(!1)}},V=async()=>{try{let e=await uh();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),i.message.error(`Unable to load action validation rules.`)}},ne=(0,r.useCallback)(async e=>{let n=RT(e);if(d([]),p([]),t.setFieldsValue({step_order:void 0}),n){x(!0);try{let e=await gh({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];d(t),p(zT(t))}catch(e){console.error(`Unable to load flows:`,e),i.message.error(`Unable to load flows.`)}finally{x(!1)}}},[t]),re=(0,r.useCallback)(async(e,n,r)=>{let a=RT(e),o=RT(n);if(!a||!o){t.setFieldsValue({step_order:void 0});return}D(!0);try{t.setFieldsValue({step_order:BT(r,a,o)})}catch(e){console.error(`Unable to load step order:`,e),i.message.error(`Unable to load step order.`)}finally{D(!1)}},[t]);(0,r.useEffect)(()=>{Promise.resolve().then(async()=>{await Promise.all([te(),V()])})},[]),(0,r.useEffect)(()=>{Promise.resolve().then(()=>ne(N))},[ne,N]),(0,r.useEffect)(()=>{Promise.resolve().then(()=>re(N,P,u))},[u,re,P,N]);let H=async e=>{let n={module:RT(e.module),flow:RT(e.flow),step_order:Number(e.step_order),description:RT(e.description),keyword:RT(e.keyword),target:RT(e.target),value:RT(e.value),expected:RT(e.expected),tags:e.tags?RT(e.tags):MT.tags,active:Number(e.active)};k(!0);try{await hh(n),i.message.success(`LMS case details saved successfully.`),t.resetFields(),d([]),p([])}catch(e){console.error(`Unable to save LMS case:`,e),i.message.error(`Unable to save LMS case.`)}finally{k(!1)}},U=(e,n)=>{t.setFieldsValue({[e]:RT(n)})},W=e=>{t.setFieldsValue({module:RT(e),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:MT.tags,value:void 0,expected:void 0}),IT(t,[`keyword`,`target`,`value`,`expected`])},G=e=>{t.setFieldsValue({flow:RT(e),step_order:void 0,keyword:void 0,target:void 0,value:void 0,expected:void 0}),IT(t,[`keyword`,`target`,`value`,`expected`])},ie=e=>{let n=FT(g,e);t.setFieldsValue({keyword:RT(e),target:n.key?t.getFieldValue(`target`):void 0,value:n.value?t.getFieldValue(`value`):void 0,expected:n.expected?t.getFieldValue(`expected`):void 0}),IT(t,[`target`,`value`,`expected`])},K=e=>{let t=NT[e];C({open:!0,typeKey:e}),n.setFieldsValue({name:``,type:t.label})},ae=()=>{C(e=>({...e,open:!1})),n.resetFields()},oe=async()=>{try{let e=RT((await n.validateFields()).name),r=await lh({name:e,type:j.dbName});ee(S.typeKey,r?.items??[]),t.setFieldsValue({[j.formField]:e}),i.message.success(`${j.label} added successfully.`),ae()}catch(e){if(e?.errorFields)return;console.error(`Unable to save testing option:`,e),i.message.error(`Unable to add ${j.label.toLowerCase()}.`)}finally{T(!1)}};return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsxs)(i.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,o.jsx)(i.Col,{children:(0,o.jsx)(e.t,{items:jT})}),(0,o.jsx)(i.Col,{children:(0,o.jsx)(i.Button,{type:`link`,onClick:()=>A(`/lms-home`),children:`View Table`})})]}),(0,o.jsx)(`div`,{className:`v1-page`,children:(0,o.jsxs)(`div`,{className:`v1-page-inner`,children:[(0,o.jsx)(`div`,{className:`v1-page-header`,children:(0,o.jsxs)(i.Space,{align:`center`,size:10,children:[(0,o.jsx)(a.ProfileOutlined,{className:`v1-outer-icon`}),(0,o.jsx)(`div`,{children:(0,o.jsx)(AT,{strong:!0,style:{fontSize:16},children:`Add LMS Case`})})]})}),(0,o.jsx)(Z,{children:(0,o.jsxs)(i.Form,{form:t,className:`v1-form`,layout:`vertical`,colon:!1,requiredMark:(e,{required:t})=>(0,o.jsxs)(o.Fragment,{children:[e,t&&(0,o.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),initialValues:MT,onFinish:H,autoComplete:`off`,children:[(0,o.jsx)(i.Card,{className:`v1-card`,title:(0,o.jsx)(VT,{icon:(0,o.jsx)(a.FileTextOutlined,{}),title:`LMS Case Details`}),extra:(0,o.jsx)(AT,{type:`secondary`,className:`v1-card-subtitle`,children:`Module, flow, step order and execution data`}),children:(0,o.jsxs)(i.Row,{gutter:[24,0],children:[(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsxs)(i.Space.Compact,{style:{width:`100%`},children:[(0,o.jsx)(i.Form.Item,{label:`Module`,name:`module`,style:{flex:1},children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,loading:v,optionFilterProp:`label`,placeholder:`Select module`,options:M,onChange:W})}),(0,o.jsx)(i.Button,{"aria-label":`Add module`,icon:(0,o.jsx)(a.PlusOutlined,{}),style:{marginTop:30},onClick:()=>K(`module`)})]})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Flow`,name:`flow`,children:(0,o.jsx)(i.AutoComplete,{maxLength:100,allowClear:!0,disabled:R,options:f,placeholder:b?`Loading flows`:`Enter flow`,onChange:G,filterOption:(e,t)=>t?.value?.toLowerCase().includes(e.toLowerCase())})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Step Order`,name:`step_order`,validateTrigger:[`onBlur`,`onChange`],children:(0,o.jsx)(i.Input,{maxLength:10,disabled:!0,placeholder:E?`Loading step order`:`Step order`})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Action`,name:`keyword`,children:(0,o.jsx)(i.Select,{allowClear:!0,showSearch:!0,disabled:z,optionFilterProp:`label`,placeholder:`Select action`,options:m,onChange:ie})})}),(0,o.jsx)(i.Col,{xs:24,children:(0,o.jsx)(i.Form.Item,{label:`Description`,name:`description`,children:(0,o.jsx)(i.Input.TextArea,{rows:3,maxLength:255,disabled:z,placeholder:`Enter description`,showCount:!0,onBlur:e=>U(`description`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Key`,name:`target`,rules:[{required:B.key,message:`Key is required for this action`}],children:(0,o.jsx)(i.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=>U(`target`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Tags`,name:`tags`,children:(0,o.jsx)(i.Input,{maxLength:200,disabled:z,placeholder:`Enter tags`,prefix:(0,o.jsx)(a.TagsOutlined,{className:`v1-input-icon`}),onBlur:e=>U(`tags`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Value`,name:`value`,rules:[{required:B.value,message:`Value is required for this action`}],children:(0,o.jsx)(i.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=>U(`value`,e.target.value)})})}),(0,o.jsx)(i.Col,{xs:24,md:12,children:(0,o.jsx)(i.Form.Item,{label:`Expected`,name:`expected`,rules:[{required:B.expected,message:`Expected result is required for this action`}],children:(0,o.jsx)(i.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=>U(`expected`,e.target.value)})})})]})}),(0,o.jsx)(`div`,{className:`v1-form-actions`,children:(0,o.jsx)(i.Form.Item,{children:(0,o.jsxs)(i.Space,{children:[(0,o.jsx)(i.Button,{type:`primary`,htmlType:`submit`,loading:O,disabled:z,children:`Submit`}),(0,o.jsx)(i.Button,{onClick:()=>{t.resetFields(),d([]),p([])},children:`Reset`})]})})})]})}),(0,o.jsx)(i.Modal,{title:`Add ${j.label}`,open:S.open,confirmLoading:w,okText:`Add`,onCancel:ae,onOk:()=>{T(!0),oe()},destroyOnHidden:!0,children:(0,o.jsxs)(i.Form,{form:n,layout:`vertical`,colon:!1,className:`v1-form`,requiredMark:(e,{required:t})=>(0,o.jsxs)(o.Fragment,{children:[e,t&&(0,o.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),children:[(0,o.jsx)(i.Form.Item,{label:`Name`,name:`name`,children:(0,o.jsx)(i.Input,{maxLength:100,placeholder:`Enter ${j.label.toLowerCase()} name`,onBlur:e=>{n.setFieldsValue({name:RT(e.target.value)})}})}),(0,o.jsx)(i.Form.Item,{label:`Type`,name:`type`,children:(0,o.jsx)(i.Input,{disabled:!0})})]})})]})})]})}var UT=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}];function WT(){return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsx)(e.t,{items:UT}),(0,o.jsx)(Va,{moduleName:`lms-flows`,rowKey:`id`})]})}var GT=[`referenceId`,`ReferenceId`,`candidateId`,`CandidateId`,`entityId`,`EntityId`,`id`,`Id`,`_id`];function KT(e=GT){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 qT(e,t=GT){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 JT=KT();function YT(e){return typeof e==`function`?e:typeof e==`string`?KT([e]):Array.isArray(e)?KT(e):JT}function XT(e,t,n){return!t||typeof t!=`object`?e:{...t,...e,id:t.id??e.id??n}}function ZT(e,t,n={}){return{status:`success`,total:t,data:{data:e,...n}}}var QT=[`fields`,`fieldConfig`,`tabs`,`tabField`,`actionRules`,`actions`,`columnActions`];function $T(e){let t=e?.data??e,n={};for(let r of QT){let i=e?.[r]??t?.[r];i==null||Array.isArray(i)&&i.length===0||(n[r]=i)}return n}var eE=e=>String(e??``).replace(/[^a-zA-Z0-9]/g,``).toLowerCase();function tE(e,t,n){let r=(Array.isArray(n)?n:[n]).map(eE).filter(Boolean),i=r.length?e.findIndex(e=>r.includes(eE(e?.value))||r.includes(eE(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 nE=(e,t)=>br(e,t).rows,rE=(e,t)=>{let{rows:n,total:r}=br(e,t);return{rows:n,total:r}};function iE({fetchPrimaryPage:e,extractPrimaryPage:t=rE,fetchSecondaryByKeys:n,fetchPrimary:r,extractPrimaryRows:i=nE,fetchSecondary:a,extractSecondaryRows:o=nE,fetchSecondaryById:s,primaryKey:c,secondaryKey:l,mergeRow:u=XT,secondaryFetchLimit:d=200,extraFields:f=[],extraFieldsAfter:p}){let m=YT(c),h=typeof l==`function`?e=>{let t=l(e);return t?[String(t)]:[]}:e=>qT(e,typeof l==`string`?[l]:Array.isArray(l)?l:GT),g=0;function _(e){let t=new Map;return e.forEach(e=>{for(let n of h(e))t.has(n)||t.set(n,e)}),t}async function v(e,t){if(!s||!t)return null;try{let n=await s(e,t);return n&&h(n).includes(String(t))?n:null}catch(e){return console.error(`[mergedListApi] per-id secondary lookup failed for "${t}"`,e),null}}async function y(e,t,n,r){return Promise.all(e.map(async e=>{let i=m(e);return u(e,t.get(i)??(r()?null:await v(n,i)),i)}))}function b(e,t,n){let r={};for(let e of n){if(!e)continue;let t=$T(e);for(let e of Object.keys(t))r[e]??(r[e]=t[e])}return f.length&&(r.fields=tE(r.fields??[],f,p)),ZT(e,t,r)}async function x(r,i,a,s,c){let l=await e(r,i,a,s),u=t(l,r)??{},d=Array.isArray(u.rows)?u.rows:[],f=Number.isFinite(Number(u.total))?Number(u.total):d.length,p=[...new Set(d.map(m).filter(Boolean))],h=null,g=[];if(p.length&&n)try{h=await n(r,p,s),g=o(h,r)??[]}catch(e){console.error(`[mergedListApi] secondary fetch failed — rendering unenriched page`,e),h=null}return b(await y(d,_(g),r,c),f,[l,h])}async function S(e,t,n,s,c){let[l,u]=await Promise.allSettled([r(e,t,n,s),a?a(e,d,0,s):Promise.resolve(null)]);if(l.status===`rejected`)throw l.reason;let f=u.status===`fulfilled`?u.value:null;u.status===`rejected`&&console.error(`[mergedListApi] secondary fetch failed — rendering unenriched page`,u.reason);let p=i(l.value,e)??[],m=_(f?o(f,e)??[]:[]),h=p.length;return b(await y(p.slice(n,n+t),m,e,c),h,[l.value,f])}return async function(t,n=10,r=0,i={}){let a=++g,o=()=>a!==g;return e?x(t,n,r,i,o):S(t,n,r,i,o)}}function aE(e,t,n={}){return iE({fetchPrimary:()=>bS(e,t),extractPrimaryRows:_S,fetchSecondary:Qt,fetchSecondaryById:xS,secondaryFetchLimit:n.moduleFetchLimit??200})}function oE(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 sE(e){let t=Array.isArray(e?.stages)?e.stages:[];if(!t.length)return e;let n={};for(let e of t){let t=oE(e?.stageName);t&&(n[t]=Number(e?.count)||0)}return{...n,...e}}var cE=e=>{let t=Number(e?.targetSubmission??e?.targetSubmissions);return Number.isFinite(t)&&t>0?t:null};function lE({submittedCountField:e=`submittedCount`,progressField:t=`targetSubmissionProgress`}={}){return function(n,r,i){let a=XT(n,r,i),o=cE(a);return o!=null&&(console.log(`mergeJobWorkflowRow`,i,a?.[e],o),a[t]=`${Number(a?.[e])||0} of ${o}`),a}}function uE(e={}){let t=lE(),n=iE({primaryKey:`_id`,secondaryKey:`entityId`,extraFields:e.extraFields,extraFieldsAfter:e.extraFieldsAfter,fetchPrimaryPage:Qt,fetchSecondaryByKeys:()=>yS(),extractSecondaryRows:e=>(e?.items??[]).map(sE),mergeRow:(e,n,r)=>{let i=t(e,n,r);return n?._id&&(i.workflowId=n._id),i}});return async function(e,t,r,i){return await n(e,t,r,i)}}async function dE(e,t=10,n=0,r={},i={}){return br(await uE(i)(e,t,n,r),e)}async function fE(e,t,n,r=10,i=0,a={}){return br(await aE(e,t)(n,r,i,a),n)}var pE=LC,mE=Mh(Pw),hE=Mh(Iw),gE=Mh(Zw),_E=Mh(lT),vE=Mh(vT),yE=Mh(xT),bE=Mh(wT),xE=Mh(DT),SE=Mh(kT),CE=Mh(HT),wE=Mh(WT);exports.ADMIN_API_URL=t._,exports.ADMIN_APP_ID=t.v,exports.APP_ID=t.y,exports.AUTH_URL=t.b,exports.ActivityTab=Cs,exports.AddBatchCandidatePopup=bC,exports.AddFormV1=ss,exports.AdminDashboard=LC,exports.AdminDashboardContent=Jy,exports.AdminPage=pE,exports.AppAlert=cs,exports.AppButton=qr,exports.AppShell=th,exports.ApprovalActionBar=Xf,exports.AssigneeAvatars=ws,exports.AuthGuard=$m,exports.BILLING_STATUS_FLOW=Ul,exports.BULK_UPLOAD_DEFAULT_ACCEPT=Ts,exports.BULK_UPLOAD_DEFAULT_MAX_SIZE_MB=Es,exports.Breadcrumb=e.t,exports.BulkUploadPage=gE,exports.BulkUploadPanel=Ps,exports.CANDIDATES_URL=t.x,exports.CONTRACT_C2C=hp,exports.CONTRACT_W2=mp,exports.CalendarCard=D,exports.CoreThemeAdminApp=Qy,exports.CoreThemeAdminRoutes=Zy,exports.CustomPagination=Se,exports.DayLogModal=Wf,exports.DescriptionBlock=qs,exports.DetailHeaderCard=Gu,exports.DetailViewPage=Qu,exports.DetailViewV1=qc,exports.DocumentViewer=e.Jn,exports.DynamicCards=bt,exports.DynamicPopup=Lx,exports.DynamicPopupRoute=CC,exports.DynamicTabs=j,exports.EditFormV1=Kd,exports.FINANCE_APPROVAL_CONFIG=lp,exports.FINANCE_TYPE_CFO=ip,exports.FINANCE_TYPE_ONBOARDING_MANAGER=rp,exports.FINANCE_TYPE_ONBOARDING_MANAGER_REAPPROVE=sp,exports.FINANCE_TYPE_ONLY_FINANCE=ap,exports.FINANCE_TYPE_SUBMISSION_MANAGER=np,exports.FINANCE_TYPE_SUBMISSION_MANAGER_REAPPROVE=op,exports.FileListCard=Qp,exports.FinanceApprovalPanel=Hp,exports.FinanceAvatar=wu,exports.FinanceBadge=Ou,exports.FinanceDayCell=Qf,exports.FinanceDivider=gu,exports.FinanceEmployeeCell=Tu,exports.FinanceEmptyState=pu,exports.FinanceEquation=_u,exports.FinanceHistoryTimeline=xu,exports.FinanceHoursGrid=fu,exports.FinanceKpiRow=du,exports.FinanceLine=hu,exports.FinanceListToolbar=Df,exports.FinanceMarginBadge=ku,exports.FinanceMoneyCell=Du,exports.FinanceRecordsTable=Mu,exports.FinanceRowChevron=Au,exports.FinanceSection=mu,exports.FinanceStatusPill=uu,exports.FinanceTextCell=Eu,exports.FinanceTimesheetAnalysis=ep,exports.FinanceWorkflowSteps=vu,exports.Header=Dm,exports.HierarchyUserFilter=Tt,exports.JOBS_URL=t.S,exports.LegacyAdminPage=mE,exports.ListView=Va,exports.LmsHomePage=wE,exports.LmsTestForm=CE,exports.Login=nh,exports.MailPopup=ob,exports.ManageModules=yE,exports.ManageSubmodules=bE,exports.ModuleRowActions=tf,exports.NotesPanel=Yf,exports.PAYROLL_STATUS_FLOW=Wl,exports.POPUP_CONFIGS=dC,exports.ParamCardView=lf,exports.ParamListView=hf,exports.PreviewPopup=Rb,exports.ProjectSelect=jh,exports.ProofUploadPreview=Jf,exports.QuickLogBar=qf,exports.QuickLogSelectionBar=Gf,exports.RejectionReasonModal=Kf,exports.SUBMISSIONS_URL=t.C,exports.Sidebar=Ym,exports.StatusBadge=_f,exports.StatusBadgeTag=Af,exports.StickyNotesFullPage=hE,exports.StylishDynamicTabs=yf,exports.TemplateEditor=wf,exports.TestForm=_E,exports.TestingHomePage=SE,exports.TimelineGroups=hs,exports.TimesheetDayCell=zf,exports.TipTapEditor=e.Yn,exports.UserForm=IC,exports.VendorShareDrawer=DC,exports.ViewSummaryWidget=Kr,exports.WizardPopup=Wb,exports.ZinnextTableView=xE,exports.ZinnextTestForm=vE,exports.applyIntegrationStatus=e.mt,exports.approveSubmission=se,exports.buildAcceptAttr=js,exports.buildCsv=iu,exports.buildDailyRows=Ql,exports.buildDayGradient=Lf,exports.buildRateHistoryEntries=Np,exports.buildWeeklyRollup=tu,exports.clearSelectedProject=t.r,exports.colors=e.Qn,exports.computeFinance=jp,exports.computeMarginBand=nu,exports.configureCoreTheme=t.w,exports.createAllWorkflowsListFetcher=uE,exports.createWorkflowStageListFetcher=aE,exports.deleteIntegrationConfig=e.Tt,exports.deriveDayStats=Zl,exports.downloadCsv=cu,exports.findEmployerRow=Tp,exports.flattenGroups=Cp,exports.formatFileSize=As,exports.formatFinanceMoney=Pp,exports.formatHours=Pl,exports.formatMoney=Nl,exports.formatPercent=Il,exports.formatRate=Fl,exports.getActivity=e.at,exports.getAllWorkflowsModuleList=dE,exports.getApprovalDate=Bl,exports.getBgcIntegrationConfig=e.Ht,exports.getBgcIntegrationSummary=e.Ut,exports.getBillingActionStates=Gl,exports.getCurrentRoleName=t.s,exports.getFieldLabel=ou,exports.getFileExtension=ks,exports.getFinanceApprovalConfig=dp,exports.getFormGroupsRaw=Xp,exports.getIntegrationConfig=e.Yt,exports.getIntegrationConfigs=e.Xt,exports.getIntegrationSummary=e.Zt,exports.getModuleConfig=xe,exports.getModuleDataDetail=e.st,exports.getPayrollActionStates=Kl,exports.getSelectedProject=t.c,exports.getStoredToken=t.l,exports.getStoredUser=t.u,exports.getUserRoles=t.d,exports.getVMSApprove=ce,exports.getValueStyle=su,exports.getWorkflowStageModuleList=fE,exports.getWorkflowSteps=ql,exports.humanizeEvent=zl,Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return ao}}),exports.indexFieldConfig=au,exports.initialsOf=Ll,exports.isTester=t.f,exports.logout=t.m,exports.marginIncludesReferral=pp,exports.matchLocationTax=Ap,Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return td}}),exports.normalizeContract=Dp,Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Fs}}),exports.rejectSubmission=ue,exports.resolveActivityMeta=bs,exports.resolveAndCompute=Mp,exports.resolveFinanceInputs=kp,exports.resolveMergeKey=JT,exports.resolveRejectionReason=fp,exports.resolveSubmissionFinance=Zp,exports.saveBgcIntegrationConfig=e.vn,exports.saveIntegrationConfig=e.xn,exports.setSelectedProject=t.g,exports.stageCountKey=oE,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return rh}}),exports.testIntegrationConnection=e.Dn,exports.useDropdownFields=hn,exports.useDropdownValues=Jr,exports.useEditForm=$p,exports.useFieldConfig=gn,exports.useFilterFields=_n,exports.useMenuPermission=Cn,exports.useModuleActions=Jd,exports.useRecordRefresh=Yu,exports.validateBulkFile=Ms,exports.withAdminAppId=t.T,exports.withAppId=t.E,exports.withAuthGuard=Mh;
|
|
10
10
|
//# sourceMappingURL=index.cjs.map
|