@realtek/core-theme 0.0.201 → 0.0.202
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 +1 -1
- package/dist-lib/index.js.map +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 ab(e){return e.replace(/•/g,`
|
|
8
8
|
`).split(/\n+/).map(e=>e.trim().replace(/^[-–—•]\s*/,``).trim()).filter(Boolean)}function ob(e){return ab(e.replace(/(?:^|\s)[-–—]\s+/g,`
|
|
9
|
-
`))}function sb(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:nb(n),value:r}}function cb(e){let t=e.toLowerCase().replace(/[\s:.\-–—]+$/,``).trim();return Qy.has(t)?$y.test(t)?`education`:eb.test(t)?`keySkills`:`overview`:null}function lb(e){let t=[],n={overview:[],keySkills:[],education:[]},r=`overview`;return e.forEach(e=>{let i=cb(e);if(i){r=i;return}if(r===`overview`){let n=sb(e);if(n){t.push(n);return}}n[r].push(e)}),{meta:t,overview:rb(n.overview),keySkills:rb(n.keySkills),education:rb(n.education)}}function ub(e){let t=[...Zy].sort((e,t)=>t.length-e.length),n=RegExp(`\\b(${t.map(tb).join(`|`)})\\b\\s*:?`,`gi`),r=[...e.matchAll(n)];if(!r.length)return{meta:[],overview:rb(ob(e)),keySkills:[],education:[]};let i={overview:[],keySkills:[],education:[]},a=e.slice(0,r[0].index).trim();return a&&i.overview.push(...ob(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=ob(e.slice(o,s).trim());c.length&&i[$y.test(a)?`education`:eb.test(a)?`keySkills`:`overview`].push(...c)}),{meta:[],overview:rb(i.overview),keySkills:rb(i.keySkills),education:rb(i.education)}}function db(e){let t=ib(e);if(!t)return{meta:[],overview:[],keySkills:[],education:[]};let n=ab(t);return n.length>=4?lb(n):ub(t)}function fb({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 pb({raw:e=``,meta:t=[]}){let[n,i]=(0,r.useState)(!1),a=(0,r.useMemo)(()=>db(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)(Yy,{type:`secondary`,children:`No description available.`});let l=n?c:c.slice(0,Xy),u=c.length-Xy;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)(fb,{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:mb}=i.Typography;function hb(e){return e?e.trim().split(/\s+/).slice(0,2).map(e=>e[0].toUpperCase()).join(``):`?`}function gb(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 _b(e){return e?e.email??e.emailId??e.emailAddress??``:``}function vb(e){return e?e.status?e.status:e.stage?e.stage:typeof e.isActive==`boolean`?e.isActive?`Active`:`Inactive`:``:``}function yb(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 bb=[`jobDescription`,`description`,`rawDescription`,`jobDescriptionText`];function xb(e){return String(e??``).toLowerCase()===`job`}function Sb(e){let t=bb.includes(e.field),n=/description/i.test(e.label??``);return t||n}function Cb({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 wb({record:e}){let t=gb(e),n=_b(e),r=vb(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:hb(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 Tb({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=xb(t)&&Sb(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:yb(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)(pb,{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:yb(n)})]},e.field??e.label)})}):null}function Eb(){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.In({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)(mb,{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)(Tb,{fields:e.fields,moduleName:n}):(0,o.jsx)(mb,{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)(Cb,{steps:C,current:g,onStepClick:_})}),(0,o.jsxs)(`div`,{className:`wizard-body`,children:[c&&(0,o.jsx)(wb,{record:c}),E()]})]})}var{Text:Db}=i.Typography,{TextArea:Ob}=i.Input,kb=[{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 Ab(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)(Ob,{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 jb({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)(Db,{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)(Db,{type:`secondary`,children:`Please review the information above before submitting.`})]})]}):(0,o.jsx)(`div`,{className:`wizard-review-empty`,children:(0,o.jsx)(Db,{type:`secondary`,children:`No data entered yet.`})})}function Mb(){let[e]=i.Form.useForm(),t=(0,s.useNavigate)(),{title:n=`Wizard`,moduleName:a=``,steps:c=kb,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:Ab(e)})},e.name))})},e.key)),f.isReview&&(0,o.jsx)(jb,{steps:c,form:e})]})})]})}function Nb({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 Pb({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.Wn,{variant:`body`,color:`secondary`,className:`dynamic-popup__note`,children:t}),n&&(0,o.jsx)(e.Wn,{variant:`body`,className:`dynamic-popup__description`,children:n}),r&&i>0&&(0,o.jsxs)(e.Wn,{variant:`body`,className:`dynamic-popup__selected-count`,children:[`Changing status for `,(0,o.jsx)(`strong`,{children:i}),` selected `,a,`.`]}),s&&(0,o.jsx)(e.Wn,{variant:`body`,children:s}),c&&(0,o.jsx)(e.Wn,{variant:`caption`,color:`danger`,className:`dynamic-popup__error`,children:c})]})}function Fb({footerNote:t}){return t?(0,o.jsx)(e.Wn,{variant:`caption`,color:`secondary`,className:`dynamic-popup__footer-note`,children:t}):null}var{Text:Ib}=i.Typography,{TextArea:Lb}=i.Input,Rb=[{label:`$`,value:`$`},{label:`EUR`,value:`EUR`},{label:`GBP`,value:`GBP`},{label:`INR`,value:`INR`}],zb=[{label:`Hourly`,value:`Hourly`},{label:`Daily`,value:`Daily`},{label:`Weekly`,value:`Weekly`},{label:`Monthly`,value:`Monthly`},{label:`Yearly`,value:`Yearly`}];function Bb(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 Vb({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 Hb({field:e,value:t,onChange:n}){return(0,o.jsx)(Lb,{value:t,onChange:n,rows:e.rows??5,placeholder:e.placeholder})}function Ub({field:e,options:t,value:n,onChange:r}){return(0,o.jsx)(i.Select,{value:n,onChange:r,options:Bb(t),placeholder:e.placeholder,className:`dynamic-popup__field-select`,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function Wb({field:e,options:t,value:n,onChange:r}){return(0,o.jsx)(i.Select,{mode:`multiple`,value:n,onChange:r,options:Bb(t),placeholder:e.placeholder,className:`dynamic-popup__field-select`,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function Gb({field:e,options:t,onSearch:n,value:r,onChange:s}){return(0,o.jsx)(i.Select,{showSearch:!0,filterOption:!1,notFoundContent:null,value:r,onChange:s,options:Bb(t),placeholder:e.placeholder,onSearch:n,className:`dynamic-popup__field-select`,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function Kb({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 qb({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:Rb,onChange:e=>c({currency:e}),style:{width:80}}),(0,o.jsx)(i.Select,{value:a,options:zb,onChange:e=>c({period:e}),style:{width:110}})]}),(u||d)&&(0,o.jsxs)(`div`,{style:{marginTop:4},children:[u&&(0,o.jsx)(Ib,{type:`danger`,style:{fontSize:12,display:`block`},children:`To rate must be greater than From rate.`}),d&&(0,o.jsxs)(Ib,{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 Jb({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 Yb({field:e,checked:t,onChange:n}){return(0,o.jsx)(i.Checkbox,{checked:t,onChange:n,children:e.checkboxLabel})}function Xb({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 Zb({options:e,value:t,onChange:n}){return(0,o.jsx)(i.Radio.Group,{value:t,onChange:n,options:e})}var Qb={input:Vb,text:Vb,textarea:Hb,select:Ub,"multi-select":Wb,"search-select":Gb,"mention-textarea":Kb,"candidate-rate":qb,"priority-checkbox":Yb,"date-picker":Jb,number:Xb,radio:Zb};function $b(e){return e===`priority-checkbox`?{valuePropName:`checked`}:{}}function ex(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t?.[n]??``).trim()}function tx(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 nx(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 rx(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:tx(nx(e))}:e,o=(i?ex(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};return c&&(u.disabled=!0),l&&(u.title=l),u}function ix(e,t){return(t?.[e.optionsKey]??e.defaultOptions??[]).map(t=>rx(t,e))}function ax(e={}){return{selectedIds:[],selectedRecords:[],moduleName:``,removedIds:[],...e}}var ox=new Set([`input`,`text`,`textarea`,`mention-textarea`]);function sx({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.Wn,{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:cx(n).map(t=>lx(t,t=>{let n=a[t.name]??ix(t,s),r=p(t),c=m(t),l=h[t.name]??[],u=$b(t.type),d=Qb[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.U({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 cx(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 lx(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 ux({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 dx=500,fx=3;function px({api:e,popupContext:t,setDynamicOptions:n}){let[i,a]=(0,r.useState)({}),o=(0,r.useRef)({}),s=(0,r.useRef)({}),c=(0,r.useRef)({});function l(r){if(!r.searchFetchKey&&!r.searchFetcher)return;let i=e.searchOptions??e.searchFetcher;if(typeof i==`function`)return e=>{if(clearTimeout(o.current[r.name]),e.length<fx){n(e=>({...e,[r.name]:[]}));return}o.current[r.name]=setTimeout(()=>{s.current[r.name]?.abort();let a=new AbortController;s.current[r.name]=a,Promise.resolve(i(r,e,t)).then(e=>{if(a.signal.aborted)return;let t=Array.isArray(e)?e:e?.items??e?.list??[];n(e=>({...e,[r.name]:t.map(e=>rx(e,r))}))}).catch(e=>{a.signal.aborted||console.error(`[DynamicPopup] Search failed for field "${r.name}":`,e)})},dx)}}function u(n){let r=e.getMentionOptions??e.mentionFetcher;if(typeof r==`function`)return e=>{c.current[n.name]?.abort();let i=new AbortController;c.current[n.name]=i,Promise.resolve(r(n,e,t)).then(e=>{if(i.signal.aborted)return;let t=Array.isArray(e)?e:e?.items??e?.list??[];a(e=>({...e,[n.name]:t.map(e=>({value:e.user_name??e.userName??e.username??String(e),label:e.user_name??e.userName??e.username??String(e)}))}))}).catch(e=>{i.signal.aborted||console.error(`[DynamicPopup] Mention search failed for field "${n.name}":`,e)})}}return{mentionOptions:i,getSearchHandler:l,getMentionSearchHandler:u}}function mx({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 hx({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)(()=>ax(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}=ux({open:e,config:t,api:l,fields:x,popupContext:g,formValues:d}),{mentionOptions:E,getSearchHandler:D,getMentionSearchHandler:O}=px({api:l,open:e,popupContext:g,setDynamicOptions:w});function k(e){typeof a==`function`&&a(e)}let{handleOk:A,confirming:j,deleteError:M,resetSubmitState:N}=mx({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,V=typeof t?.getNote==`function`?t.getNote(g):t?.note,H=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)}),te=t?.disabledUntilFilled&&!H;if(!t||!e||P)return null;let ne=t.component;return ne?(0,o.jsx)(i.Modal,{open:e,title:t.title||t.getTitleText?(0,o.jsx)(Nb,{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)(ne,{context:g,selectedIds:b,selectedRecords:v,moduleName:y,onClose:k})}):(0,o.jsxs)(i.Modal,{open:e,title:(0,o.jsx)(Nb,{titleText:z,titleIcon:t.titleIcon}),okText:t.okText||`OK`,cancelText:t.cancelText??`Cancel`,onOk:A,onCancel:()=>k(),okButtonProps:{danger:t.okButtonDanger,disabled:te,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)(Pb,{note:V,description:t.description,showSelectedCount:t.showSelectedCount,count:F,itemLabel:L,bodyText:ee,deleteError:M}),(0,o.jsx)(Fb,{footerNote:t.footerNote}),(0,o.jsx)(sx,{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 gx={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:[]},_x={deleteItems:async(e,t)=>{await I(t.moduleName,e)}},vx={title:`Quick Submit`,okText:`Submit`,width:480,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 (minimum 3 characters)`,searchFetchKey:`quickSubmitJobList`}]:[{name:`candidate`,label:`Candidate`,type:`search-select`,required:!0,placeholder:`Search candidate name (minimum 3 character)`,optionsKey:`candidateOptions`,searchFetchKey:`quickSubmitCandidates`,labelTemplate:`{applicantRefrenceId} - {firstName} {lastName} - ({lastdate})`,valueKey:`applicantId`}]},yx=`Already submitted`;function bx(e){return String(e?.applicantId??e?._id??e?.id??``)}function xx(e,t){return{...e,label:`${e.label} — ${yx}`,disabled:!0,title:`${yx}${t?` (submission ${t})`:``}`,alreadySubmitted:!0,existingSubmissionId:t||``}}var Sx={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 ue({searchQuery:t,candidateId:r})}catch{a=!1;let e=await fn({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?.alreadySubmitted)return xx(e,e._raw?.submissionId||``);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?xx(e,t.submissionId):e})}if(e.searchFetchKey===`quickSubmitCandidates`){let e=n.selectedRecords?.[0]??{},r=n.jobId??e.jobId??e.id??e._id??n.selectedIds?.[0],i,a=new Map;try{i=await de({search:t,jobId:r})}catch{let e=await Ga({isFromSubmission:n.isFromSubmission,jobId:r,submissionId:n.submissionId,search:t});i=Array.isArray(e)?e:[],a=await fe({jobId:r,applicantIds:i.map(bx)}).catch(()=>new Map)}return i.map(e=>{let t=a.get(bx(e));if(!t&&!e?.isFromSubmission&&!e?.alreadySubmitted)return e;let n=t?.submissionId||e?.submissionId||``;return{...e,disabled:!0,optionNote:yx,alreadySubmitted:!0,existingSubmissionId:n}})}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=>bx(e?._raw)===String(l)),d=n?.dynamicOptions?.jobId?.find(e=>String(e?.value)===String(c)),f=u?._raw?.alreadySubmitted||u?._raw?.isFromSubmission||d?.alreadySubmitted||d?._raw?.alreadySubmitted;if(!c||!l)throw Error(`Select both a job and a candidate to quick submit.`);let p=f,m=t.submissionId||u?._raw?.existingSubmissionId||u?._raw?.submissionId||d?.existingSubmissionId||s.submissionId||``;try{let e=await le({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;return l&&h.set(`candidateId`,l),h.set(`isFromSubmission`,`false`),r(`/submission-create/${c}?${h.toString()}`),{navigated:!0}}},Cx={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`}]},wx=e=>e?.data??e;async function Tx({relatedId:e,notes:n,title:r,notesFor:i}){return wx(await qt(t.b,`/notes`,{method:`POST`,body:JSON.stringify({relatedId:e,notes:n,title:r,notesFor:i})}))}var Ex={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 Tx({relatedId:String(n),notes:e.notes,notesFor:t.moduleName})}},Dx={name:`jobId`,label:`Job Title / ID`,type:`search-select`,required:!0,placeholder:`Minimum 3 characters`,searchFetchKey:`tagToJobJobList`,valueKey:`_id`,labelTemplate:`{jobReferenceId} - {jobTitle}`},Ox={name:`hiringStage`,label:`Hiring stage`,type:`select`,required:!0,optionsKey:`hiringStageOptions`,defaultOptions:[{label:`Shortlisted`,value:`shortlisted`},{label:`Pipeline`,value:`pipeline`}],initialValueKey:`hiringStage`},kx={title:`Tag to Job`,okText:`Tag`,width:480,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getFields:e=>e.jobId&&e.hiringStage?[]:e.jobId?[Ox]:[Dx,Ox]},Ax=e=>e?.data??e;function jx(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 Mx(e){return e?Array.isArray(e.data)?e.data.map(jx):e.stage&&Array.isArray(e.stage.data)?e.stage.data.map(jx):Array.isArray(e)?e.map(jx):[]:[]}async function Nx(e=1,n=10){let r=await t.a(t.b,`/workflow/list/all?page=${e}&limit=${n}`),i=Ax(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 Px(e=100){let t=await Nx(1,e),n=[...t.items],r=t.total,i=2;for(;n.length<r;){let t=await Nx(i,e);if(!t.items.length)break;n.push(...t.items),i+=1}return{items:n,total:Math.max(r,n.length)}}async function Fx(e,n){let r=Ax(await t.a(t.b,`/workflow/${e}/stage/${n}`));return Array.isArray(r)?{data:r}:r}async function Ix(e,n){if(!e||!n)return null;try{let r=Ax(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 Lx(e){return Ax(await t.a(t.S,`/source/workflow-instance`,{method:`POST`,body:JSON.stringify(e)}))}var Rx={pipeline:`pipeline`,goodfited:`goodfited`,contacted:`contacted`,submitted:`submitted`,shortlisted:`shortlisted`,interviewinprogress:`interviewInprogress`,selected:`selected`};function zx(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 Bx(e){let t=String(e??``).trim();return t?Rx[t.toLowerCase()]??t:``}function Vx(e,t){let n=zx(e,`candidateId`,`candidate_id`,`applicantId`,`applicantID`,`applicantReferenceId`,`applicantRefrenceId`,`_id`,`id`)??t;if(!n)return null;let r=(zx(e,`candidateName`,`candidate_name`,`fullName`,`name`)??[zx(e,`firstName`,`first_name`),zx(e,`lastName`,`last_name`)].filter(Boolean).join(` `))||void 0,i={candidateId:String(n),candidateName:r,phone:zx(e,`phone`,`phoneNumber`,`phone_number`,`mobile`,`mobileNumber`,`mobile_number`),source:zx(e,`source`,`sourceType`,`candidateSource`,`profileSource`),submittedAt:zx(e,`submittedAt`,`lastSubmittedAt`,`updatedAt`),remarks:zx(e,`remarks`,`comment`,`comments`,`notes`),assignedRecruiter:zx(e,`assignedRecruiter`,`recruiterName`,`ownerName`,`assignedToName`),screeningStatus:zx(e,`screeningStatus`,`screening.status`,`screeningResult`),screeningScore:zx(e,`screeningScore`,`screening.score`,`score`),assignedDate:zx(e,`assignedDate`,`assignedAt`,`createdAt`)};return Object.fromEntries(Object.entries(i).filter(([,e])=>e!=null&&e!==``))}var Hx={searchOptions:async(e,t)=>e.searchFetchKey===`tagToJobJobList`?L(t):[],submit:async(e,t)=>{let n=e.jobId??t.jobId,r=Bx(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=Vx(a[e]??{},t);await Lx({jobId:n,module:`jobs`,currentStage:r,...o?{candidateDetails:o}:{}})}await V({jobId:n,candidateIds:t.selectedIds,hiringStage:r})}},Ux={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`}]}]},Wx={submit:async(e,t)=>{await F(t.moduleName,t.selectedIds,e.status)}},Gx={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:[]},Kx={onOk:async e=>{await pe({jobId:e.jobId??e.selectedIds[0],candidateIds:e.selectedIds})}},qx={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`}]},Jx={getOptions:async e=>e.fetchOptionsKey===`candidateGroups`?H():[],submit:async(e,t,{dynamicOptions:n})=>{let r=(n.groupId??[]).find(t=>String(t.value)===String(e.groupId));await te({candidateIds:t.selectedIds,groupId:e.groupId,groupName:r?.label??``})}},Yx=[{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 Xx({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([U(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 ne({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:Yx,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`})]})]})}Xx.propTypes={selectedIds:l.default.array,onClose:l.default.func};var Zx={title:`Self Assign`,width:480,className:`self-assign-modal`,component:Xx},Qx={submit:async()=>{}};function $x(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 eS(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=$x(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 tS={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:$x(e?.selectedRecords?.[0]??{}),validator:eS},{name:`priority`,label:`Priority`,type:`priority-checkbox`,checkboxLabel:`Mark as High`}]},nS={getOptions:async e=>e.fetchOptionsKey===`assignToUsers`?re():[],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})}},rS={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`}]},iS={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`))}},aS={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`,fields:[{name:`sendOnboardingEmail`,type:`priority-checkbox`,checkboxLabel:`Send Onboarding Email`}]},oS={submit:async(e,t)=>{await q({submissionId:t.selectedRecords?.[0]?.submissionId,isMail:e.sendOnboardingEmail})}};function sS(e){return Array.isArray(e)?e[e.length-1]??{}:e&&typeof e==`object`?e:{}}var cS={USD:`$`,INR:`₹`,EUR:`€`,GBP:`£`};function lS(e,t,n){let r=sS(e?.[t])[n];if(r!=null&&r!==``)return r;let i=e?.[`${t}.${n}`];return i!=null&&i!==``?i:void 0}function uS(e){let t=e.selectedRecords?.[0]??{},n=lS(t,`candidateRate`,`candidateAcceptedRate`)??lS(t,`candidateBudget`,`candidateBudgetStart`);if(n===void 0||Number(n)===0)return null;let r=lS(t,`candidateRate`,`candidateAcceptedCurrency`)??lS(t,`candidateBudget`,`candidateBudgetCurrency`);return{amount:n,symbol:lS(t,`candidateRate`,`candidateAcceptedCurrencySymbol`)??lS(t,`candidateBudget`,`candidateBudgetCurrencySymbol`)??cS[String(r??``).toUpperCase()]??(r||`$`),unit:lS(t,`candidateRate`,`candidateAcceptedPayUnit`)??lS(t,`candidateBudget`,`candidateBudgetUnit`)??``}}var dS={title:`Approve Rate`,okText:`Approve`,width:520,className:`medium-modal`,successMessage:`Rate approved`,getBodyText:(e,t,n,r,i)=>{let a=uS(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=uS(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`}]}]},fS={submit:async(e,t)=>{let n=t.selectedIds[0];if(await oe(n,{candidateProposedRate:e.candidateProposedRate,candidateProposedRateCurrency:e.candidateProposedRateCurrency,candidateProposedRateUnit:e.candidateProposedRateUnit,submitVia:e.submitVia}),e.submitVia===`VMS`)try{await se(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 pS(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,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function mS({context:e,selectedIds:t,selectedRecords:n,moduleName:a,onClose:s}){let c=n?.[0]??{},l=t?.[0]??pp(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 oe(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)(Mp,{type:Jf,record:u.record,lookups:u.lookups,identity:pS(c,u.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:m,onClose:()=>s?.(),variant:`popup`})}mS.propTypes={context:l.default.object,selectedIds:l.default.array,selectedRecords:l.default.array,moduleName:l.default.string,onClose:l.default.func};var hS={title:`Manager Approve`,width:780,className:`fa-modal manager-approve-modal`,component:mS},gS={submit:async()=>{}};function _S(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,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function vS(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 yS(e){return String(e??``).toLowerCase().replace(/\b\w/g,e=>e.toUpperCase())}function bS({selectedIds:t,selectedRecords:n,onClose:a}){let s=n?.[0]??{},c=t?.[0]??pp(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.tt(`submission`,c).catch(()=>[])]).then(([e,n])=>{if(t)return;let r=vS(n);f(pp(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?yS(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 ce(d,{billRate:e.proposedRate,payRate:e.employerRate,currency:e.currency,referralRate:e.referralRate,vmsPercent:e.clientVmsPercent}),await oe(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)(Mp,{type:Zf,record:l.record,lookups:l.lookups,identity:_S(s,l.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:h,onClose:()=>a?.(),variant:`popup`})}bS.propTypes={selectedIds:l.default.array,selectedRecords:l.default.array,onClose:l.default.func};var xS={title:`Re-Approve`,width:780,className:`fa-modal manager-approve-modal`,component:bS},SS={submit:async()=>{}},CS=[{id:1,name:`Re-Submission`},{id:2,name:`Candidate doesn't fit into the profile`},{id:3,name:`Incomplete candidate details - (Re-Submission)`}],wS={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:CS.map(e=>({label:e.name,value:e.id}))},{name:`rejectReasonComments`,label:`Comments`,type:`textarea`,required:!0,rows:4}]},TS={submit:async(e,t)=>{let n=CS.find(t=>String(t.id)===String(e.rejectReason));await J({submissionId:t.selectedIds[0],rejectReasonId:e.rejectReason,rejectReason:n?.name??``,rejectReasonComments:e.rejectReasonComments})}},ES={delete:gx,"quick-submit":vx,"add-notes":Cx,"tag-to-job":kx,"change-status":Ux,"remove-from-shortlist":Gx,"add-to-groups":qx,"self-assign":Zx,"others-assign":tS,"sticky-notes":rS,"move-to-onboarding":aS,"approve-rate":dS,"manager-approve":hS,"manager-reapprove":xS,reject:wS},DS={delete:_x,"quick-submit":Sx,"add-notes":Ex,"tag-to-job":Hx,"change-status":Wx,"remove-from-shortlist":Kx,"add-to-groups":Jx,"self-assign":Qx,"others-assign":nS,"sticky-notes":iS,"move-to-onboarding":oS,"approve-rate":fS,"manager-approve":gS,"manager-reapprove":SS,reject:TS};function OS(e){let t=e?.data??e;return Array.isArray(t)?t:t?.data??t?.rows??t?.records??t?.items??t?.list??[]}function kS(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 AS(e){let t=kS(e,`candidateName`,`candidate_name`,`fullName`,`name`);return t?String(t):[kS(e,`firstName`,`first_name`),kS(e,`lastName`,`last_name`)].filter(Boolean).join(` `)||`Unnamed candidate`}function jS(e){return String(kS(e,`candidateId`,`candidate_id`,`candidate._id`,`candidate.id`))}function MS(e){return String(kS(e,`workforceEngagementId`,`engagementId`,`_id`,`id`))}function NS({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=String(a.selectedIds?.[0]??a.selectedRecords?.[0]?._id??a.selectedRecords?.[0]?.id??a.batchId??``);(0,r.useEffect)(()=>{if(!n)return;let t=!1;return e.Rn(`onboarding`,200,0).then(e=>{t||l(OS(e))}).catch(e=>{t||y(e.message||`Unable to load onboarding candidates`)}).finally(()=>{t||h(!1)}),()=>{t=!0}},[n]);let x=(0,r.useMemo)(()=>{let e=f.trim().toLowerCase();return e?c.filter(t=>[AS(t),kS(t,`email`,`candidateEmail`,`candidate_email`),kS(t,`status`,`onboardingStatus`,`onboarding_status`)].some(t=>String(t).toLowerCase().includes(e))):c},[c,f]);async function S(){if(!b){y(`Select a batch before adding candidates`);return}let n=c.filter(e=>u.includes(MS(e)));if(n.length){_(!0),y(``);try{let{userId:r}=t.o();await Promise.all(n.map(t=>e.mt(`batchCandidates`,{schemaVersion:1,batchId:b,candidateId:jS(t),workforceEngagementId:MS(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:S,onCancel:()=>s?.(),okButtonProps:{disabled:u.length===0||!b,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=>MS(e),columns:[{title:`Candidate`,key:`candidate`,render:(e,t)=>AS(t)},{title:`Email`,key:`email`,render:(e,t)=>kS(t,`email`,`candidateEmail`,`candidate_email`)||`—`},{title:`Onboarding status`,key:`status`,render:(e,t)=>kS(t,`status`,`onboardingStatus`,`onboarding_status`)||`—`}],dataSource:x,loading:m,size:`small`,pagination:{pageSize:10,showSizeChanger:!1},rowSelection:{selectedRowKeys:u,onChange:d,getCheckboxProps:e=>({disabled:!jS(e)||!MS(e)})},locale:{emptyText:m?`Loading candidates…`:`No onboarding candidates found`}})]})}var PS={text:`input`,string:`input`,textarea:`textarea`,date:`date-picker`,datepicker:`date-picker`,multiselect:`multi-select`,lookup:`search-select`};function FS(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:PS[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 IS({apiMap:n={},extraConfigs:i={}}){let a=(0,r.useMemo)(()=>({...DS,...n}),[n]),c=(0,r.useMemo)(()=>({...ES,...i}),[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.zt(d.moduleName,`popup`,l).then(e=>{t||p({key:n,config:FS(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&&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)(NS,{open:!0,context:h,onClose:_}):(0,o.jsx)(hx,{open:!0,config:m,context:h,onClose:_,api:{...a[l]??{},...g}})}var LS={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`}]},RS={getVendorList:({jobId:e,limit:t,offset:n,type:r})=>zt({jobId:e,limit:t,offset:n,sortBy:`new`,type:r}),getMailDetails:e=>Bt(e),submit:({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})=>Vt({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})},zS=LS.vendorColumns.map(e=>({...e,render:e=>e||`-`}));function BS(){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)(LS.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)(LS.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 RS.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&&RS.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([...Vy(h.bcc),...z])].join(`, `),showBcc:h.showBcc||z.length>0}),[h,z]);function ee(e){let t=new Set(z);g({...e,bcc:Vy(e.bcc).filter(e=>!t.has(e)).join(`, `)})}let V=(Vy(B.to).length||Vy(B.bcc).length)&&Hy(B.to)&&Hy(B.cc)&&Hy(B.bcc)&&B.subject.trim(),H=e=>e===`myVendor`?T:D;function te(){e(-1)}function ne(){V&&RS.submit({jobId:m,toMail:Vy(B.to),ccMail:Vy(B.cc),bccMail:Vy(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 U=(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:te,closable:!1,rootClassName:`vendor-share`,width:`95%`,footer:(0,o.jsxs)(`div`,{className:`vendor-share__footer`,children:[(0,o.jsx)(i.Button,{onClick:te,children:`Cancel`}),(0,o.jsx)(i.Button,{type:`primary`,disabled:!V,onClick:ne,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:te,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:LS.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,` (`,H(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:zS,dataSource:U,loading:F,pagination:!1,size:`small`,rowSelection:{selectedRowKeys:L,onChange:e=>{e.length>LS.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)(qy,{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,` / `,LS.maxVendorSelect,` Vendors selected`]}):null})})]})})}var VS={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].*$/},HS={SINGLE_FILE_COUNT:1,MULTI_FILE_COUNT:5,MAX_FILE_SIZE:2,ALLOWED_FILE_TYPES:[`image/jpeg`,`image/png`,`application/pdf`]},US={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 ${HS.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.`},WS={FIRST_NAME_MIN:3,FIRST_NAME_MAX:30},GS={REMARKS_MIN:10,REMARKS_MAX:250},KS={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)}`}},qS={required:(e=`Field`)=>({required:!0,message:US.REQUIRED(e)}),email:()=>({pattern:VS.EMAIL,message:US.INVALID_EMAIL}),phone:()=>({pattern:VS.PHONE,message:US.INVALID_PHONE}),password:()=>({pattern:VS.PASSWORD,message:US.INVALID_PASSWORD}),alphabets:()=>({pattern:VS.ALPHABETS,message:US.INVALID_ALPHABETS}),alphanumeric:()=>({pattern:VS.ALPHANUMERIC,message:US.INVALID_ALPHANUMERIC}),number:()=>({pattern:VS.NUMBER,message:US.INVALID_NUMBER}),url:()=>({pattern:VS.URL,message:US.INVALID_URL}),candidateId:(e=`ID`)=>({pattern:VS.CANDIDATE_ID,message:US.INVALID_CANDIDATE_ID(e)}),remarks:()=>({pattern:VS.REMARKS,message:US.INVALID_REMARKS,REMARKS_MIN:`Remarks must be at least ${GS.REMARKS_MIN} characters.`,REMARKS_MAX:`Remarks must not exceed ${GS.REMARKS_MAX} characters.`}),designation:()=>({pattern:VS.DESIGNATION,message:US.INVALID_DESIGNATION}),dob:(e=!0)=>({validator:(t,n)=>{if(!n)return e?Promise.reject(Error(`Date of Birth is required.`)):Promise.resolve();if(!VS.DOB.test(n))return Promise.reject(Error(US.INVALID_DOB));let r=(0,c.default)(n,`MM/DD/YYYY`,!0);if(!r.isValid())return Promise.reject(Error(US.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:VS.LINKEDIN,message:US.INVALID_LINKEDIN}),companyName:()=>({pattern:VS.COMPANY_NAME,message:US.INVALID_COMPANY_NAME}),firstName:()=>({pattern:VS.FIRST_NAME,message:US.INVALID_FIRST_NAME,FIRST_NAME_MIN:`First Name must be at least ${WS.FIRST_NAME_MIN} characters.`,FIRST_NAME_MAX:`First Name must not exceed ${WS.FIRST_NAME_MAX} characters.`}),firstNameMinLength:()=>({min:WS.FIRST_NAME_MIN,message:US.FIRST_NAME_MIN}),firstNameMaxLength:()=>({max:WS.FIRST_NAME_MAX,message:US.FIRST_NAME_MAX}),remarksMinLength:()=>({min:GS.REMARKS_MIN,message:US.REMARKS_MIN}),remarksMaxLength:()=>({max:GS.REMARKS_MAX,message:US.REMARKS_MAX}),fullName:()=>({pattern:VS.FULL_NAME,message:US.INVALID_FULL_NAME}),noSpaces:()=>({pattern:VS.NO_SPACES,message:US.NO_SPACES_ALLOWED}),startsWithCapital:()=>({pattern:VS.STARTS_WITH_CAPITAL,message:US.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<=HS.MAX_FILE_SIZE))return i.message.error(US.INVALID_FILE_SIZE),Promise.reject(Error(US.INVALID_FILE_SIZE));if(!HS.ALLOWED_FILE_TYPES.includes(t.type))return Promise.reject(Error(US.INVALID_FILE_TYPE))}return Promise.resolve()}}),singleFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>HS.SINGLE_FILE_COUNT)return Promise.reject(Error(US.SINGLE_FILE_ONLY));let n=t[0];return n.size/1024/1024<HS.MAX_FILE_SIZE?HS.ALLOWED_FILE_TYPES.includes(n.type)?Promise.resolve():Promise.reject(Error(US.INVALID_FILE_TYPE)):Promise.reject(Error(US.INVALID_FILE_SIZE))}}),multiFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>HS.MULTI_FILE_COUNT)return Promise.reject(Error(US.INVALID_FILE_COUNT));for(let e of t){if(!(e.size/1024/1024<HS.MAX_FILE_SIZE))return Promise.reject(Error(US.INVALID_FILE_SIZE));if(!HS.ALLOWED_FILE_TYPES.includes(e.type))return Promise.reject(Error(US.INVALID_FILE_TYPE))}return Promise.resolve()}})},JS={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)},YS=()=>{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:[qS.required(`Email`),qS.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:[qS.required(`Phone Number`),qS.phone()],validateTrigger:[`onBlur`,`onChange`],children:(0,o.jsx)(i.Input,{maxLength:10,onChange:t=>{e.setFieldsValue({phone:KS.phoneFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Password`,name:`password`,rules:[qS.required(`Password`),qS.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:[qS.required(`Full Name`),qS.alphabets(),qS.firstNameMinLength(),qS.firstNameMaxLength()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({fullName:KS.firstNameFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Username`,name:`username`,rules:[qS.required(`Username`),qS.alphanumeric()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({username:KS.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Website URL`,name:`website`,rules:[qS.required(`Website URL`),qS.url()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({website:KS.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:[qS.required(`MSP Req ID`),qS.candidateId(`MSP Req ID`)],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({mspreqID:KS.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Candidate ID`,name:`candidateId`,rules:[qS.required(`Candidate ID`),qS.candidateId(`Candidate ID`)],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({candidateId:KS.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:24,children:(0,o.jsx)(i.Form.Item,{label:`Remarks`,name:`remarks`,rules:[qS.required(`Remarks`),qS.remarks(),qS.remarksMinLength(),qS.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:[qS.required(`Designation`),qS.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:[qS.dob()],children:(0,o.jsx)(i.Input,{placeholder:`MM/DD/YYYY`,maxLength:10,onChange:t=>{e.setFieldsValue({dob:KS.dobFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Company Name`,name:`companyName`,rules:[qS.required(`Company Name`),qS.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:JS.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:[qS.multiFileUpload()],children:(0,o.jsx)(i.Upload,{multiple:!0,beforeUpload:JS.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:[qS.fileUpload()],children:(0,o.jsx)(i.Upload,{beforeUpload:JS.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 XS(e){return(0,o.jsx)(Um,{children:(0,o.jsx)(Iy,{...e})})}var{Text:ZS}=i.Typography,QS=[{label:`Total Jobs`,value:1697,icon:`fileText`},{label:`Active Jobs`,value:1685,icon:`checkCircle`},{label:`My Jobs`,value:600,icon:`user`}],$S={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 eC({stats:e=QS}){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:[$S[e.icon]??$S.fileText,(0,o.jsx)(ZS,{children:e.label})]}),(0,o.jsx)(i.Statistic,{value:e.value})]})},e.label))})})}var{Text:tC}=i.Typography;function nC(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 rC(e){return{...e,key:e.USER_ID??e.user_id??e.userId??e.id??e._id,_name:nC(e),_email:e.email??e.EMAIL??e.user_email??``,_role:e.role_name??e.roleName??e.ROLE_NAME??``,_rawRef:e}}function iC(){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.Mt({offset:t,limit:r,searchQuery:a??``}),o=(i.users??[]).map(rC);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)(cf,{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:aC}=i.Typography,oC=[{key:`job`,label:`Jobs`},{key:`candidate`,label:`Candidates`},{key:`submissions`,label:`Submissions`}],sC=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`}];function cC({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 lC({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.sn(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.Mn(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:oC.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)(cC,{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 `,oC.find(e=>e.key===f)?.label]})})]})}function uC(){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.jt();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.jn(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)(cf,{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:sC.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)(lC,{team:t,configType:d},`${t?.teamId}-${d}`)]})]})}var dC=[`view`,`add`,`edit`,`delete`],fC={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`};function pC(e){return fC[e]??e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function mC(e){let t=dC.filter(t=>e.includes(t)),n=e.filter(e=>!dC.includes(e)).sort();return[...t,...n]}function hC(e){let t=new Set;return Object.values(e).forEach(({permissions:e})=>Object.keys(e??{}).forEach(e=>t.add(e))),mC([...t])}function gC(e){let t=0,n=0;return Object.entries(e).forEach(([e,{permissions:r}])=>{Object.entries(r??{}).forEach(([r,{value:i}])=>{$h(e,r)&&(n++,i===`1`&&t++)})}),{enabled:t,total:n}}function _C({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 vC({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 yC({menuName:e,menuData:t,permKeys:n,onChange:r,displayName:i,actionLabels:a,onModuleLabelSave:s,onActionLabelSave:c}){let l=t?.permissions??{},u=n.filter(t=>$h(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)(_C,{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)(vC,{entry:l[t],label:a[t]??pC(t),onToggle:()=>r(e,t),onLabelSave:e=>c(t,e)},t))})]})}function bC({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.rn(t);(0,r.useEffect)(()=>{b&&(h(!0),y(!1),e.an(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.kn(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)(()=>hC(f),[f]),{enabled:T,total:E}=(0,r.useMemo)(()=>gC(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)(yC,{menuName:e,menuData:f[e],permKeys:w,onChange:x,displayName:n[e]??e,actionLabels:s,onModuleLabelSave:c,onActionLabelSave:l},e))})]})}var{Text:xC}=i.Typography,SC=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`}];function CC(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function wC(e){return String(e||``).trim().toLowerCase()}function TC(e){return e?.key||e?.collectionName||e?.value||``}function EC(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=TC(e);if(!t)return;let o=wC(e.key||t),s=wC(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||CC(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=wC(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:CC(t),value:t,disabled:!1}))}),n}function DC(){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.At();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.Ht(),e.Pt()]),r=EC(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.bn(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)(xC,{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)(cf,{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:SC.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)(bC,{role:t},t?.roleId):(0,o.jsx)(gg,{role:t,configType:l},`${t?.roleId}-${l}`))]})]})}var OC=`perm-module-labels`,kC=`perm-action-labels`;function AC(e){try{return JSON.parse(localStorage.getItem(e)??`{}`)}catch{return{}}}function jC(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function MC({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 NC({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.Yt())}catch{i.message.error(`Failed to load modules`)}finally{f(!1)}}async function O(){b(!0);try{v(await e.Jt())}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.ft({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.Tn(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.xt(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.dt({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.wn(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.bt(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)(MC,{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)(MC,{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 PC(){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)(()=>AC(OC)),[_,v]=(0,r.useState)(()=>AC(kC)),y=(0,r.useCallback)((e,t)=>{g(n=>{let r={...n,[e]:t};return jC(OC,r),r})},[]),b=(0,r.useCallback)((e,t)=>{v(n=>{let r={...n,[e]:t};return jC(kC,r),r})},[]);function x(){g({}),v({}),jC(OC,{}),jC(kC,{}),i.message.success(`Labels reset to defaults`)}let S=(0,r.useCallback)(async()=>{c(!0);try{let{roles:t}=await e.At();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)(bC,{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)(NC,{open:p,onClose:()=>m(!1)})]})}var{Title:FC,Text:IC}=i.Typography,LC=[{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 RC({items:e=LC}){return(0,o.jsx)(i.Card,{className:`onboarding-card`,title:(0,o.jsx)(FC,{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)(IC,{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)(IC,{className:`onboarding-item-sub`,children:e.sub})})]})},e.label))})})}var{Text:zC,Title:BC}=i.Typography,VC=[{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.`}]}]}],HC=[{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}],UC=[{name:`Tcs`,jobs:14,candidates:86},{name:`Empasis`,jobs:9,candidates:64},{name:`NovaSystems`,jobs:7,candidates:51},{name:`Brightwave`,jobs:5,candidates:38}],WC=[{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 GC(){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)(BC,{level:5,children:`Admin Dashboard`}),(0,o.jsx)(zC,{type:`secondary`,children:`Overview of jobs, candidates, onboarding and recent activity`})]}),(0,o.jsx)(`div`,{className:`admin-dashboard-stats`,children:(0,o.jsx)(eC,{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)(RC,{}),(0,o.jsxs)(Z,{icon:(0,o.jsx)(a.AppstoreOutlined,{}),title:`Candidate Pipeline`,children:[(0,o.jsx)(zC,{type:`secondary`,style:{fontSize:12},children:`By stage (892 total)`}),(0,o.jsx)(`div`,{className:`admin-pipeline-bar`,children:HC.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:HC.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)(zC,{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)(zC,{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)(zC,{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)(zC,{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:UC.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:WC.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)(zC,{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)(zC,{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)(zC,{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)(zC,{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)(zC,{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)(zC,{style:{fontSize:12},children:e}),(0,o.jsx)(zC,{strong:!0,style:{fontSize:12},children:t})]},e))]})]})})]})}function KC({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)(BC,{level:5,children:e?.heading}),(0,o.jsx)(zC,{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)(zC,{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:VC.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 qC(){let[e,t]=(0,r.useState)(`dashboard`),[n,s]=(0,r.useState)(``),c=(0,r.useMemo)(()=>VC.flatMap(e=>e.items),[]),l=(0,r.useMemo)(()=>c.find(t=>t.id===e),[c,e]),u=(0,r.useMemo)(()=>VC.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)(()=>VC.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:VC.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)(GC,{}):l?.component===`form-groups`?(0,o.jsx)(l_,{}):l?.component===`detail-groups`?(0,o.jsx)(M_,{}):l?.component===`row-actions`?(0,o.jsx)(bv,{}):l?.component===`users`?(0,o.jsx)(iC,{}):l?.component===`teams`?(0,o.jsx)(uC,{}):l?.component===`roles`?(0,o.jsx)(DC,{}):l?.component===`permissions`?(0,o.jsx)(PC,{}):l?.component===`templates`?(0,o.jsx)(kv,{}):l?.component===`ai-services`?(0,o.jsx)(Nv,{}):l?.component===`bgc-integration`?(0,o.jsx)(zv,{}):(0,o.jsx)(KC,{activeSection:l,activeGroup:u,filteredCards:d,searchText:n,setSearchText:s,allItems:c,handleNav:p})})]})]})}var{Title:JC}=i.Typography;function YC(){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:XC,Title:ZC}=i.Typography,QC=10*1024*1024,$C=`/templates/test_cases_flow_template.base64.txt`,ew=`test_cases_flow_template.xlsx`,tw=`module | subModule | step_order | description | actions | key | value | expected | scenario`,nw={idle:0,module_set:1,encoding:1,validating:2,preview:3,inserting:3,done:4,error:1},rw=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Bulk upload`,href:`/bulk-upload`}];function iw(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 aw(e){return e.filter(e=>e.row_status===`valid`).map(e=>{let t={...e};return delete t.row_status,delete t.errors,t})}function ow(e){return e.flatMap(e=>(e.errors??[]).map(t=>({id:e.id,...t})))}function sw({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 cw({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 lw({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)(XC,{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)(sw,{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 uw(){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=ow(x),N=h===`encoding`||h===`validating`,P=!!p&&!N,F=nw[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 oh({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>QC){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 iw(e);g(`validating`),S((await th({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($C);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=ew,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 nh({project:c?.name??``,module:p,uploaded_by:localStorage.getItem(`user_Email`)??``,rows:aw(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`)}},V=(0,r.useCallback)(()=>{u.current?.scrollIntoView({behavior:`smooth`,block:`center`})},[]),H=[`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:rw})}),c?.name&&(0,o.jsx)(i.Col,{children:(0,o.jsx)(XC,{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)(ZC,{level:3,children:`Bulk upload test cases`}),(0,o.jsxs)(i.Space,{direction:`vertical`,size:4,children:[(0,o.jsx)(XC,{type:`secondary`,children:tw}),(0,o.jsx)(XC,{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:H,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)(cw,{errors:M,expanded:k,onToggle:()=>A(e=>!e),onSummaryClick:V}),T&&h===`preview`&&(0,o.jsx)(i.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`}),(0,o.jsx)(lw,{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)(XC,{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)(XC,{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)(XC,{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 dw=[{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:fw}=i.Typography,pw=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}],mw={tags:`regression`,active:1},hw={module:{dbName:`Modules`,formField:`module`,label:`Module`}};function gw(e=[]){return e.map(e=>({value:e,label:e}))}function _w(e=``){return String(e??``).trim()}function vw(e=``){return _w(e).toLowerCase()}function yw(e=[]){let t=new Map;return e.forEach(e=>{let n=_w(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function bw(e=[],t,n){let r=_w(t).toLowerCase(),i=_w(n).toLowerCase();return e.reduce((e,t)=>{let n=_w(t?.module).toLowerCase(),a=_w(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 xw({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)(fw,{strong:!0,className:`v1-section-label`,children:t})]})}function Sw(){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=hw[v.typeKey],O=(0,r.useMemo)(()=>gw(c),[c]),k=i.Form.useWatch(`module`,t),A=i.Form.useWatch(`flow`,t),j=!!_w(k),M=!!_w(A),N=!j,P=!j||!M,F=(e,t=[])=>{e===`module`&&l(t)},I=async()=>{h(!0);try{l((await Xm(hw.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=_w(e);if(d([]),p([]),t.setFieldsValue({step_order:void 0}),n){_(!0);try{let e=await eh({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];d(t),p(yw(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=_w(e),o=_w(n);if(!a||!o){t.setFieldsValue({step_order:void 0});return}C(!0);try{t.setFieldsValue({step_order:bw(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:_w(e.module),flow:_w(e.flow),step_order:Number(e.step_order),description:_w(e.description),keyword:vw(e.keyword),target:_w(e.target),value:_w(e.value),expected:_w(e.expected),tags:e.tags?_w(e.tags):mw.tags,active:Number(e.active)};T(!0);try{await $m(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]:_w(n)})},ee=e=>{t.setFieldsValue({module:_w(e),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:mw.tags,value:void 0,expected:void 0})},V=e=>{t.setFieldsValue({flow:_w(e),step_order:void 0})},H=e=>{let t=hw[e];y({open:!0,typeKey:e}),n.setFieldsValue({name:``,type:t.label})},te=()=>{y(e=>({...e,open:!1})),n.resetFields()},ne=async()=>{try{let e=_w((await n.validateFields()).name),r=await Zm({name:e,type:D.dbName});F(v.typeKey,r?.items??[]),t.setFieldsValue({[D.formField]:e}),i.message.success(`${D.label} added successfully.`),te()}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:pw})}),(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)(fw,{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:mw,onFinish:z,autoComplete:`off`,children:[(0,o.jsx)(i.Card,{className:`v1-card`,title:(0,o.jsx)(xw,{icon:(0,o.jsx)(a.FileTextOutlined,{}),title:`Test Case Details`}),extra:(0,o.jsx)(fw,{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:()=>H(`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:V,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:dw,onChange:e=>t.setFieldsValue({keyword:vw(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:te,onOk:()=>{x(!0),ne()},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:_w(e.target.value)})}})}),(0,o.jsx)(i.Form.Item,{label:`Type`,name:`type`,children:(0,o.jsx)(i.Input,{disabled:!0})})]})})]})})]})}var{Text:Cw}=i.Typography,ww=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`}];function Tw(e=``){return String(e??``).trim()}function Ew(e=[],t){return e.map(e=>({value:e.id,label:e[t]}))}var Dw=[{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`})}],Ow={key:!1,value:!1,expected:!1};function kw(e,t){return t?e[t]??Ow:Ow}function Aw(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function jw(){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)(dw),[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)(()=>kw(x,F),[x,F]),z=(0,r.useMemo)(()=>Ew(p,`modulename`),[p]),B=(0,r.useMemo)(()=>Ew(h,`submodulename`),[h]),ee=(0,r.useMemo)(()=>p.find(e=>e.id===N)?.modulename??``,[p,N]),V=(0,r.useMemo)(()=>h.find(e=>e.id===P)?.submodulename??``,[P,h]),H=(0,r.useCallback)(async()=>{try{let e=await Qm();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.`)}},[]),te=(0,r.useCallback)(async e=>{if(!e){m([]);return}w(!0);try{m((await oh({project:e,activeOnly:!0}))?.items??[])}catch(e){console.error(`Unable to load modules:`,e),i.message.error(`Unable to load modules.`)}finally{w(!1)}},[]),ne=(0,r.useCallback)(async(e,t)=>{if(!e||!t){g([]);return}E(!0);try{g((await lh({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)}},[]),U=(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([fh({product_parent_ID:e,module_parent_ID:t,submodule_parent_ID:r,actions:a,limit:1e3}),hh({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]),W=(0,r.useCallback)(async(e=``)=>{if(!(!f?.id||!N||!P)){O(!0);try{v((await fh({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]),re=(0,r.useCallback)(async()=>{if(!(!u||!f?.name)){M(!0);try{let e=await mh(u);await ne(f.name,e.module),v((await fh({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,ne,c,f?.name]);return(0,r.useEffect)(()=>{if(!f){c(`/select-project`,{replace:!0});return}Promise.resolve().then(async()=>{await H(),await te(f.name),u&&await re()})},[f,c,H,te,u,re]),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:ww})}),(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)(Cw,{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:Tw(e.description),actions:Tw(e.actions),key:Tw(e.key),value:Tw(e.value),expected:Tw(e.expected),scenario:+!!e.scenario,active:+!!e.active};A(!0);try{if(d){await gh(u,{...t,step_order:Number(e.step_order)}),i.message.success(`Test case updated successfully.`),c(`/viewTestCase`);return}await ph(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 U(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}),Aw(n,[`actions`,`key`,`value`,`expected`]),g([]),v([]),ne(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}),Aw(n,[`actions`,`key`,`value`,`expected`]),U(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)(Cw,{type:`secondary`,children:[ee,` / `,V]}),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=kw(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}),Aw(n,[`key`,`value`,`expected`]),W(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)(cf,{listName:`Added Steps`,loading:D,fields:Dw,dataSource:_,current:1,pageSize:Math.max(_.length,1),total:_.length,rowSelection:!1,className:`zt-list-plain zt-list-static`})})]})})]}):null}var{Text:Mw}=i.Typography,Nw=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`}];function Pw(){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([oh({project:e}),lh({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 ch(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 sh({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:Nw})}),(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)(Mw,{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)(cf,{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)(Mw,{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:Fw}=i.Typography,Iw=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`},{label:`Manage Submodules`,href:`/test-cases/zinnext/submodules`}];function Lw(){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 lh({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 dh(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 uh({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:Iw})}),(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)(Fw,{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)(Fw,{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)(cf,{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)(Fw,{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:Rw}=i.Typography,zw=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Table`,href:`/viewTestCase`}];function Bw(){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 fh({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 _h(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:zw})}),(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)(Rw,{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)(cf,{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 Vw=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}];function Hw(){return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsx)(e.t,{items:Vw}),(0,o.jsx)(Wa,{moduleName:`test-flows`,rowKey:`id`})]})}var{Text:Uw}=i.Typography,Ww=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}],Gw={tags:`regression`,active:1},Kw={module:{dbName:`Modules`,formField:`module`,label:`Module`}},qw={key:!1,value:!1,expected:!1};function Jw(e,t){return t?e[t]??qw:qw}function Yw(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function Xw(e=[]){return e.map(e=>({value:e,label:e}))}function Zw(e=``){return String(e??``).trim()}function Qw(e=[]){let t=new Map;return e.forEach(e=>{let n=Zw(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function $w(e=[],t,n){let r=Zw(t).toLowerCase(),i=Zw(n).toLowerCase();return e.reduce((e,t)=>{let n=Zw(t?.module).toLowerCase(),a=Zw(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 eT({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)(Uw,{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)(dw),[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=Kw[S.typeKey],M=(0,r.useMemo)(()=>Xw(c),[c]),N=i.Form.useWatch(`module`,t),P=i.Form.useWatch(`flow`,t),F=i.Form.useWatch(`keyword`,t),I=!!Zw(N),L=!!Zw(P),R=!I,z=!I||!L,B=(0,r.useMemo)(()=>Jw(g,F),[g,F]),ee=(e,t=[])=>{e===`module`&&l(t)},V=async()=>{y(!0);try{l((await Xm(Kw.module.dbName))?.items??[])}catch(e){console.error(`Unable to load testing options:`,e),i.message.error(`Unable to load testing options.`)}finally{y(!1)}},H=async()=>{try{let e=await Qm();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.`)}},te=(0,r.useCallback)(async e=>{let n=Zw(e);if(d([]),p([]),t.setFieldsValue({step_order:void 0}),n){x(!0);try{let e=await ih({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];d(t),p(Qw(t))}catch(e){console.error(`Unable to load flows:`,e),i.message.error(`Unable to load flows.`)}finally{x(!1)}}},[t]),ne=(0,r.useCallback)(async(e,n,r)=>{let a=Zw(e),o=Zw(n);if(!a||!o){t.setFieldsValue({step_order:void 0});return}D(!0);try{t.setFieldsValue({step_order:$w(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([V(),H()])})},[]),(0,r.useEffect)(()=>{Promise.resolve().then(()=>te(N))},[te,N]),(0,r.useEffect)(()=>{Promise.resolve().then(()=>ne(N,P,u))},[u,ne,P,N]);let U=async e=>{let n={module:Zw(e.module),flow:Zw(e.flow),step_order:Number(e.step_order),description:Zw(e.description),keyword:Zw(e.keyword),target:Zw(e.target),value:Zw(e.value),expected:Zw(e.expected),tags:e.tags?Zw(e.tags):Gw.tags,active:Number(e.active)};k(!0);try{await rh(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)}},W=(e,n)=>{t.setFieldsValue({[e]:Zw(n)})},re=e=>{t.setFieldsValue({module:Zw(e),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:Gw.tags,value:void 0,expected:void 0}),Yw(t,[`keyword`,`target`,`value`,`expected`])},G=e=>{t.setFieldsValue({flow:Zw(e),step_order:void 0,keyword:void 0,target:void 0,value:void 0,expected:void 0}),Yw(t,[`keyword`,`target`,`value`,`expected`])},ie=e=>{let n=Jw(g,e);t.setFieldsValue({keyword:Zw(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}),Yw(t,[`target`,`value`,`expected`])},K=e=>{let t=Kw[e];C({open:!0,typeKey:e}),n.setFieldsValue({name:``,type:t.label})},ae=()=>{C(e=>({...e,open:!1})),n.resetFields()},q=async()=>{try{let e=Zw((await n.validateFields()).name),r=await Zm({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:Ww})}),(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)(Uw,{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:Gw,onFinish:U,autoComplete:`off`,children:[(0,o.jsx)(i.Card,{className:`v1-card`,title:(0,o.jsx)(eT,{icon:(0,o.jsx)(a.FileTextOutlined,{}),title:`LMS Case Details`}),extra:(0,o.jsx)(Uw,{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:re})}),(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=>W(`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=>W(`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=>W(`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=>W(`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=>W(`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),q()},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:Zw(e.target.value)})}})}),(0,o.jsx)(i.Form.Item,{label:`Type`,name:`type`,children:(0,o.jsx)(i.Input,{disabled:!0})})]})})]})})]})}var nT=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}];function rT(){return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsx)(e.t,{items:nT}),(0,o.jsx)(Wa,{moduleName:`lms-flows`,rowKey:`id`})]})}var iT=[`referenceId`,`ReferenceId`,`candidateId`,`CandidateId`,`entityId`,`EntityId`,`id`,`Id`,`_id`];function aT(e=iT){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 oT(e,t=iT){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 sT=aT();function cT(e){return typeof e==`function`?e:typeof e==`string`?aT([e]):Array.isArray(e)?aT(e):sT}function lT(e,t,n){return!t||typeof t!=`object`?e:{...t,...e,id:t.id??e.id??n}}function uT(e,t,n={}){return{status:`success`,total:t,data:{data:e,...n}}}var dT=[`fields`,`fieldConfig`,`tabs`,`tabField`,`actionRules`,`actions`,`columnActions`];function fT(e){let t=e?.data??e,n={};for(let r of dT){let i=e?.[r]??t?.[r];i==null||Array.isArray(i)&&i.length===0||(n[r]=i)}return n}var pT=e=>String(e??``).replace(/[^a-zA-Z0-9]/g,``).toLowerCase();function mT(e,t,n){let r=(Array.isArray(n)?n:[n]).map(pT).filter(Boolean),i=r.length?e.findIndex(e=>r.includes(pT(e?.value))||r.includes(pT(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 hT=(e,t)=>Cr(e,t).rows,gT=(e,t)=>{let{rows:n,total:r}=Cr(e,t);return{rows:n,total:r}};function _T({fetchPrimaryPage:e,extractPrimaryPage:t=gT,fetchSecondaryByKeys:n,fetchPrimary:r,extractPrimaryRows:i=hT,fetchSecondary:a,extractSecondaryRows:o=hT,fetchSecondaryById:s,primaryKey:c,secondaryKey:l,mergeRow:u=lT,secondaryFetchLimit:d=200,extraFields:f=[],extraFieldsAfter:p}){let m=cT(c),h=typeof l==`function`?e=>{let t=l(e);return t?[String(t)]:[]}:e=>oT(e,typeof l==`string`?[l]:Array.isArray(l)?l:iT),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=fT(e);for(let e of Object.keys(t))r[e]??(r[e]=t[e])}return f.length&&(r.fields=mT(r.fields??[],f,p)),uT(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 vT(e,t,n={}){return _T({fetchPrimary:()=>Fx(e,t),extractPrimaryRows:Mx,fetchSecondary:tn,fetchSecondaryById:Ix,secondaryFetchLimit:n.moduleFetchLimit??200})}function yT(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 bT(e){let t=Array.isArray(e?.stages)?e.stages:[];if(!t.length)return e;let n={};for(let e of t){let t=yT(e?.stageName);t&&(n[t]=Number(e?.count)||0)}return{...n,...e}}var xT=e=>{let t=Number(e?.targetSubmission??e?.targetSubmissions);return Number.isFinite(t)&&t>0?t:null};function ST({submittedCountField:e=`submittedCount`,progressField:t=`targetSubmissionProgress`}={}){return function(n,r,i){let a=lT(n,r,i),o=xT(a);return o!=null&&(console.log(`mergeJobWorkflowRow`,i,a?.[e],o),a[t]=`${Number(a?.[e])||0} of ${o}`),a}}function CT(e={}){let t=ST(),n=_T({primaryKey:`_id`,secondaryKey:`entityId`,extraFields:e.extraFields,extraFieldsAfter:e.extraFieldsAfter,fetchPrimaryPage:tn,fetchSecondaryByKeys:()=>Px(),extractSecondaryRows:e=>(e?.items??[]).map(bT),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 wT(e,t=10,n=0,r={},i={}){return Cr(await CT(i)(e,t,n,r),e)}async function TT(e,t,n,r=10,i=0,a={}){return Cr(await vT(e,t)(n,r,i,a),n)}var ET=XS,DT=bh(qC),OT=bh(YC),kT=bh(uw),AT=bh(Sw),jT=bh(jw),MT=bh(Pw),NT=bh(Lw),PT=bh(Bw),FT=bh(Hw),IT=bh(tT),LT=bh(rT);exports.ADMIN_API_URL=t._,exports.ADMIN_APP_ID=t.v,exports.APP_ID=t.y,exports.AUTH_URL=t.b,exports.ActivityTab=Es,exports.AddBatchCandidatePopup=NS,exports.AddFormV1=us,exports.AdminDashboard=XS,exports.AdminDashboardContent=Iy,exports.AdminPage=ET,exports.AppAlert=ds,exports.AppButton=Xr,exports.AppShell=Um,exports.ApprovalActionBar=Hf,exports.AssigneeAvatars=Ds,exports.AuthGuard=Vm,exports.BILLING_STATUS_FLOW=Il,exports.BULK_UPLOAD_DEFAULT_ACCEPT=Os,exports.BULK_UPLOAD_DEFAULT_MAX_SIZE_MB=ks,exports.Breadcrumb=e.t,exports.BulkUploadPage=kT,exports.BulkUploadPanel=Ls,exports.CANDIDATES_URL=t.x,exports.CONTRACT_C2C=op,exports.CONTRACT_W2=ap,exports.CalendarCard=D,exports.CoreThemeAdminApp=By,exports.CoreThemeAdminRoutes=zy,exports.CustomPagination=Se,exports.DayLogModal=If,exports.DescriptionBlock=Xs,exports.DetailHeaderCard=Ru,exports.DetailViewPage=Gu,exports.DetailViewV1=Bc,exports.DocumentViewer=e.Hn,exports.DynamicCards=bt,exports.DynamicPopup=hx,exports.DynamicPopupRoute=IS,exports.DynamicTabs=j,exports.EditFormV1=zd,exports.FINANCE_APPROVAL_CONFIG=ep,exports.FINANCE_TYPE_CFO=Xf,exports.FINANCE_TYPE_ONBOARDING_MANAGER=Yf,exports.FINANCE_TYPE_ONBOARDING_MANAGER_REAPPROVE=Qf,exports.FINANCE_TYPE_SUBMISSION_MANAGER=Jf,exports.FINANCE_TYPE_SUBMISSION_MANAGER_REAPPROVE=Zf,exports.FileListCard=Bp,exports.FinanceApprovalPanel=Mp,exports.FinanceAvatar=_u,exports.FinanceBadge=xu,exports.FinanceDayCell=Wf,exports.FinanceDivider=lu,exports.FinanceEmployeeCell=vu,exports.FinanceEmptyState=ou,exports.FinanceEquation=uu,exports.FinanceHistoryTimeline=mu,exports.FinanceHoursGrid=au,exports.FinanceKpiRow=iu,exports.FinanceLine=cu,exports.FinanceListToolbar=yf,exports.FinanceMarginBadge=Su,exports.FinanceMoneyCell=bu,exports.FinanceRecordsTable=Tu,exports.FinanceRowChevron=Cu,exports.FinanceSection=su,exports.FinanceStatusPill=ru,exports.FinanceTextCell=yu,exports.FinanceTimesheetAnalysis=Kf,exports.FinanceWorkflowSteps=du,exports.Header=hm,exports.HierarchyUserFilter=Tt,exports.JOBS_URL=t.S,exports.LegacyAdminPage=DT,exports.ListView=Wa,exports.LmsHomePage=LT,exports.LmsTestForm=IT,exports.Login=Wm,exports.MailPopup=Jy,exports.ManageModules=MT,exports.ManageSubmodules=NT,exports.ModuleRowActions=Jd,exports.NotesPanel=Vf,exports.PAYROLL_STATUS_FLOW=Ll,exports.POPUP_CONFIGS=ES,exports.ParamCardView=tf,exports.ParamListView=cf,exports.PreviewPopup=Eb,exports.ProjectSelect=yh,exports.ProofUploadPreview=Bf,exports.QuickLogBar=zf,exports.QuickLogSelectionBar=Lf,exports.RejectionReasonModal=Rf,exports.SUBMISSIONS_URL=t.C,exports.Sidebar=Lm,exports.StatusBadge=uf,exports.StatusBadgeTag=Sf,exports.StickyNotesFullPage=OT,exports.StylishDynamicTabs=ff,exports.TemplateEditor=_f,exports.TestForm=AT,exports.TestingHomePage=FT,exports.TimelineGroups=vs,exports.TimesheetDayCell=jf,exports.TipTapEditor=e.Un,exports.UserForm=YS,exports.VendorShareDrawer=BS,exports.ViewSummaryWidget=Yr,exports.WizardPopup=Mb,exports.ZinnextTableView=PT,exports.ZinnextTestForm=jT,exports.applyIntegrationStatus=e.ct,exports.approveSubmission=oe,exports.buildAcceptAttr=Ps,exports.buildCsv=Zl,exports.buildDailyRows=Gl,exports.buildDayGradient=kf,exports.buildRateHistoryEntries=wp,exports.buildWeeklyRollup=Jl,exports.clearSelectedProject=t.r,exports.colors=e.Kn,exports.computeFinance=Sp,exports.computeMarginBand=Yl,exports.configureCoreTheme=t.w,exports.createAllWorkflowsListFetcher=CT,exports.createWorkflowStageListFetcher=vT,exports.deleteIntegrationConfig=e.yt,exports.deriveDayStats=Wl,exports.downloadCsv=tu,exports.findEmployerRow=gp,exports.flattenGroups=mp,exports.formatFileSize=Ns,exports.formatFinanceMoney=Tp,exports.formatHours=Dl,exports.formatMoney=El,exports.formatPercent=kl,exports.formatRate=Ol,exports.getActivity=e.tt,exports.getAllWorkflowsModuleList=wT,exports.getApprovalDate=Nl,exports.getBgcIntegrationConfig=e.It,exports.getBgcIntegrationSummary=e.Lt,exports.getBillingActionStates=Rl,exports.getCurrentRoleName=t.s,exports.getFieldLabel=$l,exports.getFileExtension=Ms,exports.getFinanceApprovalConfig=np,exports.getFormGroupsRaw=Rp,exports.getIntegrationConfig=e.Ut,exports.getIntegrationConfigs=e.Wt,exports.getIntegrationSummary=e.Gt,exports.getModuleConfig=xe,exports.getModuleDataDetail=e.rt,exports.getPayrollActionStates=zl,exports.getSelectedProject=t.c,exports.getStoredToken=t.l,exports.getStoredUser=t.u,exports.getUserRoles=t.d,exports.getVMSApprove=se,exports.getValueStyle=eu,exports.getWorkflowStageModuleList=TT,exports.getWorkflowSteps=Bl,exports.humanizeEvent=Ml,Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return co}}),exports.indexFieldConfig=Ql,exports.initialsOf=Al,exports.isTester=t.f,exports.logout=t.m,exports.marginIncludesReferral=ip,exports.matchLocationTax=xp,Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Ju}}),exports.normalizeContract=vp,Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Rs}}),exports.rejectSubmission=J,exports.resolveActivityMeta=Cs,exports.resolveAndCompute=Cp,exports.resolveFinanceInputs=bp,exports.resolveMergeKey=sT,exports.resolveRejectionReason=rp,exports.resolveSubmissionFinance=zp,exports.saveBgcIntegrationConfig=e.fn,exports.saveIntegrationConfig=e.hn,exports.setSelectedProject=t.g,exports.stageCountKey=yT,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Gm}}),exports.testIntegrationConnection=e.xn,exports.useDropdownFields=vn,exports.useDropdownValues=Zr,exports.useEditForm=Vp,exports.useFieldConfig=yn,exports.useFilterFields=bn,exports.useMenuPermission=En,exports.useModuleActions=Vd,exports.useRecordRefresh=Hu,exports.validateBulkFile=Fs,exports.withAdminAppId=t.T,exports.withAppId=t.E,exports.withAuthGuard=bh;
|
|
9
|
+
`))}function sb(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:nb(n),value:r}}function cb(e){let t=e.toLowerCase().replace(/[\s:.\-–—]+$/,``).trim();return Qy.has(t)?$y.test(t)?`education`:eb.test(t)?`keySkills`:`overview`:null}function lb(e){let t=[],n={overview:[],keySkills:[],education:[]},r=`overview`;return e.forEach(e=>{let i=cb(e);if(i){r=i;return}if(r===`overview`){let n=sb(e);if(n){t.push(n);return}}n[r].push(e)}),{meta:t,overview:rb(n.overview),keySkills:rb(n.keySkills),education:rb(n.education)}}function ub(e){let t=[...Zy].sort((e,t)=>t.length-e.length),n=RegExp(`\\b(${t.map(tb).join(`|`)})\\b\\s*:?`,`gi`),r=[...e.matchAll(n)];if(!r.length)return{meta:[],overview:rb(ob(e)),keySkills:[],education:[]};let i={overview:[],keySkills:[],education:[]},a=e.slice(0,r[0].index).trim();return a&&i.overview.push(...ob(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=ob(e.slice(o,s).trim());c.length&&i[$y.test(a)?`education`:eb.test(a)?`keySkills`:`overview`].push(...c)}),{meta:[],overview:rb(i.overview),keySkills:rb(i.keySkills),education:rb(i.education)}}function db(e){let t=ib(e);if(!t)return{meta:[],overview:[],keySkills:[],education:[]};let n=ab(t);return n.length>=4?lb(n):ub(t)}function fb({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 pb({raw:e=``,meta:t=[]}){let[n,i]=(0,r.useState)(!1),a=(0,r.useMemo)(()=>db(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)(Yy,{type:`secondary`,children:`No description available.`});let l=n?c:c.slice(0,Xy),u=c.length-Xy;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)(fb,{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:mb}=i.Typography;function hb(e){return e?e.trim().split(/\s+/).slice(0,2).map(e=>e[0].toUpperCase()).join(``):`?`}function gb(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 _b(e){return e?e.email??e.emailId??e.emailAddress??``:``}function vb(e){return e?e.status?e.status:e.stage?e.stage:typeof e.isActive==`boolean`?e.isActive?`Active`:`Inactive`:``:``}function yb(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 bb=[`jobDescription`,`description`,`rawDescription`,`jobDescriptionText`];function xb(e){return String(e??``).toLowerCase()===`job`}function Sb(e){let t=bb.includes(e.field),n=/description/i.test(e.label??``);return t||n}function Cb({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 wb({record:e}){let t=gb(e),n=_b(e),r=vb(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:hb(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 Tb({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=xb(t)&&Sb(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:yb(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)(pb,{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:yb(n)})]},e.field??e.label)})}):null}function Eb(){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.In({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)(mb,{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)(Tb,{fields:e.fields,moduleName:n}):(0,o.jsx)(mb,{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)(Cb,{steps:C,current:g,onStepClick:_})}),(0,o.jsxs)(`div`,{className:`wizard-body`,children:[c&&(0,o.jsx)(wb,{record:c}),E()]})]})}var{Text:Db}=i.Typography,{TextArea:Ob}=i.Input,kb=[{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 Ab(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)(Ob,{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 jb({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)(Db,{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)(Db,{type:`secondary`,children:`Please review the information above before submitting.`})]})]}):(0,o.jsx)(`div`,{className:`wizard-review-empty`,children:(0,o.jsx)(Db,{type:`secondary`,children:`No data entered yet.`})})}function Mb(){let[e]=i.Form.useForm(),t=(0,s.useNavigate)(),{title:n=`Wizard`,moduleName:a=``,steps:c=kb,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:Ab(e)})},e.name))})},e.key)),f.isReview&&(0,o.jsx)(jb,{steps:c,form:e})]})})]})}function Nb({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 Pb({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.Wn,{variant:`body`,color:`secondary`,className:`dynamic-popup__note`,children:t}),n&&(0,o.jsx)(e.Wn,{variant:`body`,className:`dynamic-popup__description`,children:n}),r&&i>0&&(0,o.jsxs)(e.Wn,{variant:`body`,className:`dynamic-popup__selected-count`,children:[`Changing status for `,(0,o.jsx)(`strong`,{children:i}),` selected `,a,`.`]}),s&&(0,o.jsx)(e.Wn,{variant:`body`,children:s}),c&&(0,o.jsx)(e.Wn,{variant:`caption`,color:`danger`,className:`dynamic-popup__error`,children:c})]})}function Fb({footerNote:t}){return t?(0,o.jsx)(e.Wn,{variant:`caption`,color:`secondary`,className:`dynamic-popup__footer-note`,children:t}):null}var{Text:Ib}=i.Typography,{TextArea:Lb}=i.Input,Rb=[{label:`$`,value:`$`},{label:`EUR`,value:`EUR`},{label:`GBP`,value:`GBP`},{label:`INR`,value:`INR`}],zb=[{label:`Hourly`,value:`Hourly`},{label:`Daily`,value:`Daily`},{label:`Weekly`,value:`Weekly`},{label:`Monthly`,value:`Monthly`},{label:`Yearly`,value:`Yearly`}];function Bb(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 Vb({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 Hb({field:e,value:t,onChange:n}){return(0,o.jsx)(Lb,{value:t,onChange:n,rows:e.rows??5,placeholder:e.placeholder})}function Ub({field:e,options:t,value:n,onChange:r}){return(0,o.jsx)(i.Select,{value:n,onChange:r,options:Bb(t),placeholder:e.placeholder,className:`dynamic-popup__field-select`,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function Wb({field:e,options:t,value:n,onChange:r}){return(0,o.jsx)(i.Select,{mode:`multiple`,value:n,onChange:r,options:Bb(t),placeholder:e.placeholder,className:`dynamic-popup__field-select`,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function Gb({field:e,options:t,onSearch:n,value:r,onChange:s}){return(0,o.jsx)(i.Select,{showSearch:!0,filterOption:!1,notFoundContent:null,value:r,onChange:s,options:Bb(t),placeholder:e.placeholder,onSearch:n,className:`dynamic-popup__field-select`,prefix:(0,o.jsx)(a.CrownOutlined,{})})}function Kb({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 qb({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:Rb,onChange:e=>c({currency:e}),style:{width:80}}),(0,o.jsx)(i.Select,{value:a,options:zb,onChange:e=>c({period:e}),style:{width:110}})]}),(u||d)&&(0,o.jsxs)(`div`,{style:{marginTop:4},children:[u&&(0,o.jsx)(Ib,{type:`danger`,style:{fontSize:12,display:`block`},children:`To rate must be greater than From rate.`}),d&&(0,o.jsxs)(Ib,{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 Jb({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 Yb({field:e,checked:t,onChange:n}){return(0,o.jsx)(i.Checkbox,{checked:t,onChange:n,children:e.checkboxLabel})}function Xb({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 Zb({options:e,value:t,onChange:n}){return(0,o.jsx)(i.Radio.Group,{value:t,onChange:n,options:e})}var Qb={input:Vb,text:Vb,textarea:Hb,select:Ub,"multi-select":Wb,"search-select":Gb,"mention-textarea":Kb,"candidate-rate":qb,"priority-checkbox":Yb,"date-picker":Jb,number:Xb,radio:Zb};function $b(e){return e===`priority-checkbox`?{valuePropName:`checked`}:{}}function ex(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t?.[n]??``).trim()}function tx(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 nx(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 rx(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:tx(nx(e))}:e,o=(i?ex(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};return c&&(u.disabled=!0),l&&(u.title=l),u}function ix(e,t){return(t?.[e.optionsKey]??e.defaultOptions??[]).map(t=>rx(t,e))}function ax(e={}){return{selectedIds:[],selectedRecords:[],moduleName:``,removedIds:[],...e}}var ox=new Set([`input`,`text`,`textarea`,`mention-textarea`]);function sx({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.Wn,{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:cx(n).map(t=>lx(t,t=>{let n=a[t.name]??ix(t,s),r=p(t),c=m(t),l=h[t.name]??[],u=$b(t.type),d=Qb[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.U({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 cx(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 lx(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 ux({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 dx=500,fx=3;function px({api:e,popupContext:t,setDynamicOptions:n}){let[i,a]=(0,r.useState)({}),o=(0,r.useRef)({}),s=(0,r.useRef)({}),c=(0,r.useRef)({});function l(r){if(!r.searchFetchKey&&!r.searchFetcher)return;let i=e.searchOptions??e.searchFetcher;if(typeof i==`function`)return e=>{if(clearTimeout(o.current[r.name]),e.length<fx){n(e=>({...e,[r.name]:[]}));return}o.current[r.name]=setTimeout(()=>{s.current[r.name]?.abort();let a=new AbortController;s.current[r.name]=a,Promise.resolve(i(r,e,t)).then(e=>{if(a.signal.aborted)return;let t=Array.isArray(e)?e:e?.items??e?.list??[];n(e=>({...e,[r.name]:t.map(e=>rx(e,r))}))}).catch(e=>{a.signal.aborted||console.error(`[DynamicPopup] Search failed for field "${r.name}":`,e)})},dx)}}function u(n){let r=e.getMentionOptions??e.mentionFetcher;if(typeof r==`function`)return e=>{c.current[n.name]?.abort();let i=new AbortController;c.current[n.name]=i,Promise.resolve(r(n,e,t)).then(e=>{if(i.signal.aborted)return;let t=Array.isArray(e)?e:e?.items??e?.list??[];a(e=>({...e,[n.name]:t.map(e=>({value:e.user_name??e.userName??e.username??String(e),label:e.user_name??e.userName??e.username??String(e)}))}))}).catch(e=>{i.signal.aborted||console.error(`[DynamicPopup] Mention search failed for field "${n.name}":`,e)})}}return{mentionOptions:i,getSearchHandler:l,getMentionSearchHandler:u}}function mx({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 hx({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)(()=>ax(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}=ux({open:e,config:t,api:l,fields:x,popupContext:g,formValues:d}),{mentionOptions:E,getSearchHandler:D,getMentionSearchHandler:O}=px({api:l,open:e,popupContext:g,setDynamicOptions:w});function k(e){typeof a==`function`&&a(e)}let{handleOk:A,confirming:j,deleteError:M,resetSubmitState:N}=mx({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,V=typeof t?.getNote==`function`?t.getNote(g):t?.note,H=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)}),te=t?.disabledUntilFilled&&!H;if(!t||!e||P)return null;let ne=t.component;return ne?(0,o.jsx)(i.Modal,{open:e,title:t.title||t.getTitleText?(0,o.jsx)(Nb,{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)(ne,{context:g,selectedIds:b,selectedRecords:v,moduleName:y,onClose:k})}):(0,o.jsxs)(i.Modal,{open:e,title:(0,o.jsx)(Nb,{titleText:z,titleIcon:t.titleIcon}),okText:t.okText||`OK`,cancelText:t.cancelText??`Cancel`,onOk:A,onCancel:()=>k(),okButtonProps:{danger:t.okButtonDanger,disabled:te,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)(Pb,{note:V,description:t.description,showSelectedCount:t.showSelectedCount,count:F,itemLabel:L,bodyText:ee,deleteError:M}),(0,o.jsx)(Fb,{footerNote:t.footerNote}),(0,o.jsx)(sx,{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 gx={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:[]},_x={deleteItems:async(e,t)=>{await I(t.moduleName,e)}},vx={title:`Submit`,okText:`Submit`,width:480,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 (minimum 3 characters)`,searchFetchKey:`quickSubmitJobList`}]:[{name:`candidate`,label:`Candidate`,type:`search-select`,required:!0,placeholder:`Search candidate name (minimum 3 character)`,optionsKey:`candidateOptions`,searchFetchKey:`quickSubmitCandidates`,labelTemplate:`{applicantRefrenceId} - {firstName} {lastName} - ({lastdate})`,valueKey:`applicantId`}]},yx=`Already submitted`;function bx(e){return String(e?.applicantId??e?._id??e?.id??``)}function xx(e,t){return{...e,label:`${e.label} — ${yx}`,disabled:!0,title:`${yx}${t?` (submission ${t})`:``}`,alreadySubmitted:!0,existingSubmissionId:t||``}}var Sx={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 ue({searchQuery:t,candidateId:r})}catch{a=!1;let e=await fn({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?.alreadySubmitted)return xx(e,e._raw?.submissionId||``);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?xx(e,t.submissionId):e})}if(e.searchFetchKey===`quickSubmitCandidates`){let e=n.selectedRecords?.[0]??{},r=n.jobId??e.jobId??e.id??e._id??n.selectedIds?.[0],i,a=new Map;try{i=await de({search:t,jobId:r})}catch{let e=await Ga({isFromSubmission:n.isFromSubmission,jobId:r,submissionId:n.submissionId,search:t});i=Array.isArray(e)?e:[],a=await fe({jobId:r,applicantIds:i.map(bx)}).catch(()=>new Map)}return i.map(e=>{let t=a.get(bx(e));if(!t&&!e?.isFromSubmission&&!e?.alreadySubmitted)return e;let n=t?.submissionId||e?.submissionId||``;return{...e,disabled:!0,optionNote:yx,alreadySubmitted:!0,existingSubmissionId:n}})}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=>bx(e?._raw)===String(l)),d=n?.dynamicOptions?.jobId?.find(e=>String(e?.value)===String(c)),f=u?._raw?.alreadySubmitted||u?._raw?.isFromSubmission||d?.alreadySubmitted||d?._raw?.alreadySubmitted;if(!c||!l)throw Error(`Select both a job and a candidate to quick submit.`);let p=f,m=t.submissionId||u?._raw?.existingSubmissionId||u?._raw?.submissionId||d?.existingSubmissionId||s.submissionId||``;try{let e=await le({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;return l&&h.set(`candidateId`,l),h.set(`isFromSubmission`,`false`),r(`/submission-create/${c}?${h.toString()}`),{navigated:!0}}},Cx={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`}]},wx=e=>e?.data??e;async function Tx({relatedId:e,notes:n,title:r,notesFor:i}){return wx(await qt(t.b,`/notes`,{method:`POST`,body:JSON.stringify({relatedId:e,notes:n,title:r,notesFor:i})}))}var Ex={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 Tx({relatedId:String(n),notes:e.notes,notesFor:t.moduleName})}},Dx={name:`jobId`,label:`Job Title / ID`,type:`search-select`,required:!0,placeholder:`Minimum 3 characters`,searchFetchKey:`tagToJobJobList`,valueKey:`_id`,labelTemplate:`{jobReferenceId} - {jobTitle}`},Ox={name:`hiringStage`,label:`Hiring stage`,type:`select`,required:!0,optionsKey:`hiringStageOptions`,defaultOptions:[{label:`Shortlisted`,value:`shortlisted`},{label:`Pipeline`,value:`pipeline`}],initialValueKey:`hiringStage`},kx={title:`Tag to Job`,okText:`Tag`,width:480,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getFields:e=>e.jobId&&e.hiringStage?[]:e.jobId?[Ox]:[Dx,Ox]},Ax=e=>e?.data??e;function jx(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 Mx(e){return e?Array.isArray(e.data)?e.data.map(jx):e.stage&&Array.isArray(e.stage.data)?e.stage.data.map(jx):Array.isArray(e)?e.map(jx):[]:[]}async function Nx(e=1,n=10){let r=await t.a(t.b,`/workflow/list/all?page=${e}&limit=${n}`),i=Ax(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 Px(e=100){let t=await Nx(1,e),n=[...t.items],r=t.total,i=2;for(;n.length<r;){let t=await Nx(i,e);if(!t.items.length)break;n.push(...t.items),i+=1}return{items:n,total:Math.max(r,n.length)}}async function Fx(e,n){let r=Ax(await t.a(t.b,`/workflow/${e}/stage/${n}`));return Array.isArray(r)?{data:r}:r}async function Ix(e,n){if(!e||!n)return null;try{let r=Ax(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 Lx(e){return Ax(await t.a(t.S,`/source/workflow-instance`,{method:`POST`,body:JSON.stringify(e)}))}var Rx={pipeline:`pipeline`,goodfited:`goodfited`,contacted:`contacted`,submitted:`submitted`,shortlisted:`shortlisted`,interviewinprogress:`interviewInprogress`,selected:`selected`};function zx(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 Bx(e){let t=String(e??``).trim();return t?Rx[t.toLowerCase()]??t:``}function Vx(e,t){let n=zx(e,`candidateId`,`candidate_id`,`applicantId`,`applicantID`,`applicantReferenceId`,`applicantRefrenceId`,`_id`,`id`)??t;if(!n)return null;let r=(zx(e,`candidateName`,`candidate_name`,`fullName`,`name`)??[zx(e,`firstName`,`first_name`),zx(e,`lastName`,`last_name`)].filter(Boolean).join(` `))||void 0,i={candidateId:String(n),candidateName:r,phone:zx(e,`phone`,`phoneNumber`,`phone_number`,`mobile`,`mobileNumber`,`mobile_number`),source:zx(e,`source`,`sourceType`,`candidateSource`,`profileSource`),submittedAt:zx(e,`submittedAt`,`lastSubmittedAt`,`updatedAt`),remarks:zx(e,`remarks`,`comment`,`comments`,`notes`),assignedRecruiter:zx(e,`assignedRecruiter`,`recruiterName`,`ownerName`,`assignedToName`),screeningStatus:zx(e,`screeningStatus`,`screening.status`,`screeningResult`),screeningScore:zx(e,`screeningScore`,`screening.score`,`score`),assignedDate:zx(e,`assignedDate`,`assignedAt`,`createdAt`)};return Object.fromEntries(Object.entries(i).filter(([,e])=>e!=null&&e!==``))}var Hx={searchOptions:async(e,t)=>e.searchFetchKey===`tagToJobJobList`?L(t):[],submit:async(e,t)=>{let n=e.jobId??t.jobId,r=Bx(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=Vx(a[e]??{},t);await Lx({jobId:n,module:`jobs`,currentStage:r,...o?{candidateDetails:o}:{}})}await V({jobId:n,candidateIds:t.selectedIds,hiringStage:r})}},Ux={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`}]}]},Wx={submit:async(e,t)=>{await F(t.moduleName,t.selectedIds,e.status)}},Gx={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:[]},Kx={onOk:async e=>{await pe({jobId:e.jobId??e.selectedIds[0],candidateIds:e.selectedIds})}},qx={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`}]},Jx={getOptions:async e=>e.fetchOptionsKey===`candidateGroups`?H():[],submit:async(e,t,{dynamicOptions:n})=>{let r=(n.groupId??[]).find(t=>String(t.value)===String(e.groupId));await te({candidateIds:t.selectedIds,groupId:e.groupId,groupName:r?.label??``})}},Yx=[{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 Xx({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([U(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 ne({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:Yx,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`})]})]})}Xx.propTypes={selectedIds:l.default.array,onClose:l.default.func};var Zx={title:`Self Assign`,width:480,className:`self-assign-modal`,component:Xx},Qx={submit:async()=>{}};function $x(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 eS(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=$x(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 tS={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:$x(e?.selectedRecords?.[0]??{}),validator:eS},{name:`priority`,label:`Priority`,type:`priority-checkbox`,checkboxLabel:`Mark as High`}]},nS={getOptions:async e=>e.fetchOptionsKey===`assignToUsers`?re():[],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})}},rS={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`}]},iS={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`))}},aS={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`,fields:[{name:`sendOnboardingEmail`,type:`priority-checkbox`,checkboxLabel:`Send Onboarding Email`}]},oS={submit:async(e,t)=>{await q({submissionId:t.selectedRecords?.[0]?.submissionId,isMail:e.sendOnboardingEmail})}};function sS(e){return Array.isArray(e)?e[e.length-1]??{}:e&&typeof e==`object`?e:{}}var cS={USD:`$`,INR:`₹`,EUR:`€`,GBP:`£`};function lS(e,t,n){let r=sS(e?.[t])[n];if(r!=null&&r!==``)return r;let i=e?.[`${t}.${n}`];return i!=null&&i!==``?i:void 0}function uS(e){let t=e.selectedRecords?.[0]??{},n=lS(t,`candidateRate`,`candidateAcceptedRate`)??lS(t,`candidateBudget`,`candidateBudgetStart`);if(n===void 0||Number(n)===0)return null;let r=lS(t,`candidateRate`,`candidateAcceptedCurrency`)??lS(t,`candidateBudget`,`candidateBudgetCurrency`);return{amount:n,symbol:lS(t,`candidateRate`,`candidateAcceptedCurrencySymbol`)??lS(t,`candidateBudget`,`candidateBudgetCurrencySymbol`)??cS[String(r??``).toUpperCase()]??(r||`$`),unit:lS(t,`candidateRate`,`candidateAcceptedPayUnit`)??lS(t,`candidateBudget`,`candidateBudgetUnit`)??``}}var dS={title:`Approve Rate`,okText:`Approve`,width:520,className:`medium-modal`,successMessage:`Rate approved`,getBodyText:(e,t,n,r,i)=>{let a=uS(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=uS(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`}]}]},fS={submit:async(e,t)=>{let n=t.selectedIds[0];if(await oe(n,{candidateProposedRate:e.candidateProposedRate,candidateProposedRateCurrency:e.candidateProposedRateCurrency,candidateProposedRateUnit:e.candidateProposedRateUnit,submitVia:e.submitVia}),e.submitVia===`VMS`)try{await se(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 pS(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,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function mS({context:e,selectedIds:t,selectedRecords:n,moduleName:a,onClose:s}){let c=n?.[0]??{},l=t?.[0]??pp(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 oe(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)(Mp,{type:Jf,record:u.record,lookups:u.lookups,identity:pS(c,u.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:m,onClose:()=>s?.(),variant:`popup`})}mS.propTypes={context:l.default.object,selectedIds:l.default.array,selectedRecords:l.default.array,moduleName:l.default.string,onClose:l.default.func};var hS={title:`Manager Approve`,width:780,className:`fa-modal manager-approve-modal`,component:mS},gS={submit:async()=>{}};function _S(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,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function vS(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 yS(e){return String(e??``).toLowerCase().replace(/\b\w/g,e=>e.toUpperCase())}function bS({selectedIds:t,selectedRecords:n,onClose:a}){let s=n?.[0]??{},c=t?.[0]??pp(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.tt(`submission`,c).catch(()=>[])]).then(([e,n])=>{if(t)return;let r=vS(n);f(pp(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?yS(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 ce(d,{billRate:e.proposedRate,payRate:e.employerRate,currency:e.currency,referralRate:e.referralRate,vmsPercent:e.clientVmsPercent}),await oe(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)(Mp,{type:Zf,record:l.record,lookups:l.lookups,identity:_S(s,l.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:h,onClose:()=>a?.(),variant:`popup`})}bS.propTypes={selectedIds:l.default.array,selectedRecords:l.default.array,onClose:l.default.func};var xS={title:`Re-Approve`,width:780,className:`fa-modal manager-approve-modal`,component:bS},SS={submit:async()=>{}},CS=[{id:1,name:`Re-Submission`},{id:2,name:`Candidate doesn't fit into the profile`},{id:3,name:`Incomplete candidate details - (Re-Submission)`}],wS={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:CS.map(e=>({label:e.name,value:e.id}))},{name:`rejectReasonComments`,label:`Comments`,type:`textarea`,required:!0,rows:4}]},TS={submit:async(e,t)=>{let n=CS.find(t=>String(t.id)===String(e.rejectReason));await J({submissionId:t.selectedIds[0],rejectReasonId:e.rejectReason,rejectReason:n?.name??``,rejectReasonComments:e.rejectReasonComments})}},ES={delete:gx,"quick-submit":vx,"add-notes":Cx,"tag-to-job":kx,"change-status":Ux,"remove-from-shortlist":Gx,"add-to-groups":qx,"self-assign":Zx,"others-assign":tS,"sticky-notes":rS,"move-to-onboarding":aS,"approve-rate":dS,"manager-approve":hS,"manager-reapprove":xS,reject:wS},DS={delete:_x,"quick-submit":Sx,"add-notes":Ex,"tag-to-job":Hx,"change-status":Wx,"remove-from-shortlist":Kx,"add-to-groups":Jx,"self-assign":Qx,"others-assign":nS,"sticky-notes":iS,"move-to-onboarding":oS,"approve-rate":fS,"manager-approve":gS,"manager-reapprove":SS,reject:TS};function OS(e){let t=e?.data??e;return Array.isArray(t)?t:t?.data??t?.rows??t?.records??t?.items??t?.list??[]}function kS(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 AS(e){let t=kS(e,`candidateName`,`candidate_name`,`fullName`,`name`);return t?String(t):[kS(e,`firstName`,`first_name`),kS(e,`lastName`,`last_name`)].filter(Boolean).join(` `)||`Unnamed candidate`}function jS(e){return String(kS(e,`candidateId`,`candidate_id`,`candidate._id`,`candidate.id`))}function MS(e){return String(kS(e,`workforceEngagementId`,`engagementId`,`_id`,`id`))}function NS({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=String(a.selectedIds?.[0]??a.selectedRecords?.[0]?._id??a.selectedRecords?.[0]?.id??a.batchId??``);(0,r.useEffect)(()=>{if(!n)return;let t=!1;return e.Rn(`onboarding`,200,0).then(e=>{t||l(OS(e))}).catch(e=>{t||y(e.message||`Unable to load onboarding candidates`)}).finally(()=>{t||h(!1)}),()=>{t=!0}},[n]);let x=(0,r.useMemo)(()=>{let e=f.trim().toLowerCase();return e?c.filter(t=>[AS(t),kS(t,`email`,`candidateEmail`,`candidate_email`),kS(t,`status`,`onboardingStatus`,`onboarding_status`)].some(t=>String(t).toLowerCase().includes(e))):c},[c,f]);async function S(){if(!b){y(`Select a batch before adding candidates`);return}let n=c.filter(e=>u.includes(MS(e)));if(n.length){_(!0),y(``);try{let{userId:r}=t.o();await Promise.all(n.map(t=>e.mt(`batchCandidates`,{schemaVersion:1,batchId:b,candidateId:jS(t),workforceEngagementId:MS(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:S,onCancel:()=>s?.(),okButtonProps:{disabled:u.length===0||!b,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=>MS(e),columns:[{title:`Candidate`,key:`candidate`,render:(e,t)=>AS(t)},{title:`Email`,key:`email`,render:(e,t)=>kS(t,`email`,`candidateEmail`,`candidate_email`)||`—`},{title:`Onboarding status`,key:`status`,render:(e,t)=>kS(t,`status`,`onboardingStatus`,`onboarding_status`)||`—`}],dataSource:x,loading:m,size:`small`,pagination:{pageSize:10,showSizeChanger:!1},rowSelection:{selectedRowKeys:u,onChange:d,getCheckboxProps:e=>({disabled:!jS(e)||!MS(e)})},locale:{emptyText:m?`Loading candidates…`:`No onboarding candidates found`}})]})}var PS={text:`input`,string:`input`,textarea:`textarea`,date:`date-picker`,datepicker:`date-picker`,multiselect:`multi-select`,lookup:`search-select`};function FS(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:PS[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 IS({apiMap:n={},extraConfigs:i={}}){let a=(0,r.useMemo)(()=>({...DS,...n}),[n]),c=(0,r.useMemo)(()=>({...ES,...i}),[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.zt(d.moduleName,`popup`,l).then(e=>{t||p({key:n,config:FS(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&&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)(NS,{open:!0,context:h,onClose:_}):(0,o.jsx)(hx,{open:!0,config:m,context:h,onClose:_,api:{...a[l]??{},...g}})}var LS={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`}]},RS={getVendorList:({jobId:e,limit:t,offset:n,type:r})=>zt({jobId:e,limit:t,offset:n,sortBy:`new`,type:r}),getMailDetails:e=>Bt(e),submit:({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})=>Vt({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})},zS=LS.vendorColumns.map(e=>({...e,render:e=>e||`-`}));function BS(){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)(LS.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)(LS.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 RS.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&&RS.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([...Vy(h.bcc),...z])].join(`, `),showBcc:h.showBcc||z.length>0}),[h,z]);function ee(e){let t=new Set(z);g({...e,bcc:Vy(e.bcc).filter(e=>!t.has(e)).join(`, `)})}let V=(Vy(B.to).length||Vy(B.bcc).length)&&Hy(B.to)&&Hy(B.cc)&&Hy(B.bcc)&&B.subject.trim(),H=e=>e===`myVendor`?T:D;function te(){e(-1)}function ne(){V&&RS.submit({jobId:m,toMail:Vy(B.to),ccMail:Vy(B.cc),bccMail:Vy(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 U=(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:te,closable:!1,rootClassName:`vendor-share`,width:`95%`,footer:(0,o.jsxs)(`div`,{className:`vendor-share__footer`,children:[(0,o.jsx)(i.Button,{onClick:te,children:`Cancel`}),(0,o.jsx)(i.Button,{type:`primary`,disabled:!V,onClick:ne,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:te,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:LS.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,` (`,H(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:zS,dataSource:U,loading:F,pagination:!1,size:`small`,rowSelection:{selectedRowKeys:L,onChange:e=>{e.length>LS.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)(qy,{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,` / `,LS.maxVendorSelect,` Vendors selected`]}):null})})]})})}var VS={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].*$/},HS={SINGLE_FILE_COUNT:1,MULTI_FILE_COUNT:5,MAX_FILE_SIZE:2,ALLOWED_FILE_TYPES:[`image/jpeg`,`image/png`,`application/pdf`]},US={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 ${HS.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.`},WS={FIRST_NAME_MIN:3,FIRST_NAME_MAX:30},GS={REMARKS_MIN:10,REMARKS_MAX:250},KS={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)}`}},qS={required:(e=`Field`)=>({required:!0,message:US.REQUIRED(e)}),email:()=>({pattern:VS.EMAIL,message:US.INVALID_EMAIL}),phone:()=>({pattern:VS.PHONE,message:US.INVALID_PHONE}),password:()=>({pattern:VS.PASSWORD,message:US.INVALID_PASSWORD}),alphabets:()=>({pattern:VS.ALPHABETS,message:US.INVALID_ALPHABETS}),alphanumeric:()=>({pattern:VS.ALPHANUMERIC,message:US.INVALID_ALPHANUMERIC}),number:()=>({pattern:VS.NUMBER,message:US.INVALID_NUMBER}),url:()=>({pattern:VS.URL,message:US.INVALID_URL}),candidateId:(e=`ID`)=>({pattern:VS.CANDIDATE_ID,message:US.INVALID_CANDIDATE_ID(e)}),remarks:()=>({pattern:VS.REMARKS,message:US.INVALID_REMARKS,REMARKS_MIN:`Remarks must be at least ${GS.REMARKS_MIN} characters.`,REMARKS_MAX:`Remarks must not exceed ${GS.REMARKS_MAX} characters.`}),designation:()=>({pattern:VS.DESIGNATION,message:US.INVALID_DESIGNATION}),dob:(e=!0)=>({validator:(t,n)=>{if(!n)return e?Promise.reject(Error(`Date of Birth is required.`)):Promise.resolve();if(!VS.DOB.test(n))return Promise.reject(Error(US.INVALID_DOB));let r=(0,c.default)(n,`MM/DD/YYYY`,!0);if(!r.isValid())return Promise.reject(Error(US.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:VS.LINKEDIN,message:US.INVALID_LINKEDIN}),companyName:()=>({pattern:VS.COMPANY_NAME,message:US.INVALID_COMPANY_NAME}),firstName:()=>({pattern:VS.FIRST_NAME,message:US.INVALID_FIRST_NAME,FIRST_NAME_MIN:`First Name must be at least ${WS.FIRST_NAME_MIN} characters.`,FIRST_NAME_MAX:`First Name must not exceed ${WS.FIRST_NAME_MAX} characters.`}),firstNameMinLength:()=>({min:WS.FIRST_NAME_MIN,message:US.FIRST_NAME_MIN}),firstNameMaxLength:()=>({max:WS.FIRST_NAME_MAX,message:US.FIRST_NAME_MAX}),remarksMinLength:()=>({min:GS.REMARKS_MIN,message:US.REMARKS_MIN}),remarksMaxLength:()=>({max:GS.REMARKS_MAX,message:US.REMARKS_MAX}),fullName:()=>({pattern:VS.FULL_NAME,message:US.INVALID_FULL_NAME}),noSpaces:()=>({pattern:VS.NO_SPACES,message:US.NO_SPACES_ALLOWED}),startsWithCapital:()=>({pattern:VS.STARTS_WITH_CAPITAL,message:US.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<=HS.MAX_FILE_SIZE))return i.message.error(US.INVALID_FILE_SIZE),Promise.reject(Error(US.INVALID_FILE_SIZE));if(!HS.ALLOWED_FILE_TYPES.includes(t.type))return Promise.reject(Error(US.INVALID_FILE_TYPE))}return Promise.resolve()}}),singleFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>HS.SINGLE_FILE_COUNT)return Promise.reject(Error(US.SINGLE_FILE_ONLY));let n=t[0];return n.size/1024/1024<HS.MAX_FILE_SIZE?HS.ALLOWED_FILE_TYPES.includes(n.type)?Promise.resolve():Promise.reject(Error(US.INVALID_FILE_TYPE)):Promise.reject(Error(US.INVALID_FILE_SIZE))}}),multiFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>HS.MULTI_FILE_COUNT)return Promise.reject(Error(US.INVALID_FILE_COUNT));for(let e of t){if(!(e.size/1024/1024<HS.MAX_FILE_SIZE))return Promise.reject(Error(US.INVALID_FILE_SIZE));if(!HS.ALLOWED_FILE_TYPES.includes(e.type))return Promise.reject(Error(US.INVALID_FILE_TYPE))}return Promise.resolve()}})},JS={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)},YS=()=>{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:[qS.required(`Email`),qS.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:[qS.required(`Phone Number`),qS.phone()],validateTrigger:[`onBlur`,`onChange`],children:(0,o.jsx)(i.Input,{maxLength:10,onChange:t=>{e.setFieldsValue({phone:KS.phoneFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Password`,name:`password`,rules:[qS.required(`Password`),qS.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:[qS.required(`Full Name`),qS.alphabets(),qS.firstNameMinLength(),qS.firstNameMaxLength()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({fullName:KS.firstNameFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Username`,name:`username`,rules:[qS.required(`Username`),qS.alphanumeric()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({username:KS.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Website URL`,name:`website`,rules:[qS.required(`Website URL`),qS.url()],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({website:KS.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:[qS.required(`MSP Req ID`),qS.candidateId(`MSP Req ID`)],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({mspreqID:KS.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Candidate ID`,name:`candidateId`,rules:[qS.required(`Candidate ID`),qS.candidateId(`Candidate ID`)],children:(0,o.jsx)(i.Input,{onChange:t=>{e.setFieldsValue({candidateId:KS.removeExtraSpaces(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:24,children:(0,o.jsx)(i.Form.Item,{label:`Remarks`,name:`remarks`,rules:[qS.required(`Remarks`),qS.remarks(),qS.remarksMinLength(),qS.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:[qS.required(`Designation`),qS.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:[qS.dob()],children:(0,o.jsx)(i.Input,{placeholder:`MM/DD/YYYY`,maxLength:10,onChange:t=>{e.setFieldsValue({dob:KS.dobFormatter(t.target.value)})}})})}),(0,o.jsx)(i.Col,{span:12,children:(0,o.jsx)(i.Form.Item,{label:`Company Name`,name:`companyName`,rules:[qS.required(`Company Name`),qS.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:JS.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:[qS.multiFileUpload()],children:(0,o.jsx)(i.Upload,{multiple:!0,beforeUpload:JS.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:[qS.fileUpload()],children:(0,o.jsx)(i.Upload,{beforeUpload:JS.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 XS(e){return(0,o.jsx)(Um,{children:(0,o.jsx)(Iy,{...e})})}var{Text:ZS}=i.Typography,QS=[{label:`Total Jobs`,value:1697,icon:`fileText`},{label:`Active Jobs`,value:1685,icon:`checkCircle`},{label:`My Jobs`,value:600,icon:`user`}],$S={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 eC({stats:e=QS}){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:[$S[e.icon]??$S.fileText,(0,o.jsx)(ZS,{children:e.label})]}),(0,o.jsx)(i.Statistic,{value:e.value})]})},e.label))})})}var{Text:tC}=i.Typography;function nC(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 rC(e){return{...e,key:e.USER_ID??e.user_id??e.userId??e.id??e._id,_name:nC(e),_email:e.email??e.EMAIL??e.user_email??``,_role:e.role_name??e.roleName??e.ROLE_NAME??``,_rawRef:e}}function iC(){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.Mt({offset:t,limit:r,searchQuery:a??``}),o=(i.users??[]).map(rC);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)(cf,{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:aC}=i.Typography,oC=[{key:`job`,label:`Jobs`},{key:`candidate`,label:`Candidates`},{key:`submissions`,label:`Submissions`}],sC=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`}];function cC({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 lC({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.sn(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.Mn(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:oC.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)(cC,{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 `,oC.find(e=>e.key===f)?.label]})})]})}function uC(){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.jt();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.jn(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)(cf,{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:sC.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)(lC,{team:t,configType:d},`${t?.teamId}-${d}`)]})]})}var dC=[`view`,`add`,`edit`,`delete`],fC={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`};function pC(e){return fC[e]??e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function mC(e){let t=dC.filter(t=>e.includes(t)),n=e.filter(e=>!dC.includes(e)).sort();return[...t,...n]}function hC(e){let t=new Set;return Object.values(e).forEach(({permissions:e})=>Object.keys(e??{}).forEach(e=>t.add(e))),mC([...t])}function gC(e){let t=0,n=0;return Object.entries(e).forEach(([e,{permissions:r}])=>{Object.entries(r??{}).forEach(([r,{value:i}])=>{$h(e,r)&&(n++,i===`1`&&t++)})}),{enabled:t,total:n}}function _C({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 vC({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 yC({menuName:e,menuData:t,permKeys:n,onChange:r,displayName:i,actionLabels:a,onModuleLabelSave:s,onActionLabelSave:c}){let l=t?.permissions??{},u=n.filter(t=>$h(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)(_C,{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)(vC,{entry:l[t],label:a[t]??pC(t),onToggle:()=>r(e,t),onLabelSave:e=>c(t,e)},t))})]})}function bC({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.rn(t);(0,r.useEffect)(()=>{b&&(h(!0),y(!1),e.an(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.kn(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)(()=>hC(f),[f]),{enabled:T,total:E}=(0,r.useMemo)(()=>gC(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)(yC,{menuName:e,menuData:f[e],permKeys:w,onChange:x,displayName:n[e]??e,actionLabels:s,onModuleLabelSave:c,onActionLabelSave:l},e))})]})}var{Text:xC}=i.Typography,SC=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`}];function CC(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function wC(e){return String(e||``).trim().toLowerCase()}function TC(e){return e?.key||e?.collectionName||e?.value||``}function EC(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=TC(e);if(!t)return;let o=wC(e.key||t),s=wC(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||CC(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=wC(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:CC(t),value:t,disabled:!1}))}),n}function DC(){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.At();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.Ht(),e.Pt()]),r=EC(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.bn(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)(xC,{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)(cf,{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:SC.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)(bC,{role:t},t?.roleId):(0,o.jsx)(gg,{role:t,configType:l},`${t?.roleId}-${l}`))]})]})}var OC=`perm-module-labels`,kC=`perm-action-labels`;function AC(e){try{return JSON.parse(localStorage.getItem(e)??`{}`)}catch{return{}}}function jC(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function MC({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 NC({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.Yt())}catch{i.message.error(`Failed to load modules`)}finally{f(!1)}}async function O(){b(!0);try{v(await e.Jt())}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.ft({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.Tn(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.xt(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.dt({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.wn(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.bt(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)(MC,{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)(MC,{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 PC(){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)(()=>AC(OC)),[_,v]=(0,r.useState)(()=>AC(kC)),y=(0,r.useCallback)((e,t)=>{g(n=>{let r={...n,[e]:t};return jC(OC,r),r})},[]),b=(0,r.useCallback)((e,t)=>{v(n=>{let r={...n,[e]:t};return jC(kC,r),r})},[]);function x(){g({}),v({}),jC(OC,{}),jC(kC,{}),i.message.success(`Labels reset to defaults`)}let S=(0,r.useCallback)(async()=>{c(!0);try{let{roles:t}=await e.At();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)(bC,{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)(NC,{open:p,onClose:()=>m(!1)})]})}var{Title:FC,Text:IC}=i.Typography,LC=[{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 RC({items:e=LC}){return(0,o.jsx)(i.Card,{className:`onboarding-card`,title:(0,o.jsx)(FC,{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)(IC,{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)(IC,{className:`onboarding-item-sub`,children:e.sub})})]})},e.label))})})}var{Text:zC,Title:BC}=i.Typography,VC=[{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.`}]}]}],HC=[{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}],UC=[{name:`Tcs`,jobs:14,candidates:86},{name:`Empasis`,jobs:9,candidates:64},{name:`NovaSystems`,jobs:7,candidates:51},{name:`Brightwave`,jobs:5,candidates:38}],WC=[{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 GC(){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)(BC,{level:5,children:`Admin Dashboard`}),(0,o.jsx)(zC,{type:`secondary`,children:`Overview of jobs, candidates, onboarding and recent activity`})]}),(0,o.jsx)(`div`,{className:`admin-dashboard-stats`,children:(0,o.jsx)(eC,{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)(RC,{}),(0,o.jsxs)(Z,{icon:(0,o.jsx)(a.AppstoreOutlined,{}),title:`Candidate Pipeline`,children:[(0,o.jsx)(zC,{type:`secondary`,style:{fontSize:12},children:`By stage (892 total)`}),(0,o.jsx)(`div`,{className:`admin-pipeline-bar`,children:HC.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:HC.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)(zC,{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)(zC,{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)(zC,{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)(zC,{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:UC.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:WC.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)(zC,{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)(zC,{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)(zC,{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)(zC,{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)(zC,{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)(zC,{style:{fontSize:12},children:e}),(0,o.jsx)(zC,{strong:!0,style:{fontSize:12},children:t})]},e))]})]})})]})}function KC({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)(BC,{level:5,children:e?.heading}),(0,o.jsx)(zC,{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)(zC,{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:VC.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 qC(){let[e,t]=(0,r.useState)(`dashboard`),[n,s]=(0,r.useState)(``),c=(0,r.useMemo)(()=>VC.flatMap(e=>e.items),[]),l=(0,r.useMemo)(()=>c.find(t=>t.id===e),[c,e]),u=(0,r.useMemo)(()=>VC.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)(()=>VC.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:VC.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)(GC,{}):l?.component===`form-groups`?(0,o.jsx)(l_,{}):l?.component===`detail-groups`?(0,o.jsx)(M_,{}):l?.component===`row-actions`?(0,o.jsx)(bv,{}):l?.component===`users`?(0,o.jsx)(iC,{}):l?.component===`teams`?(0,o.jsx)(uC,{}):l?.component===`roles`?(0,o.jsx)(DC,{}):l?.component===`permissions`?(0,o.jsx)(PC,{}):l?.component===`templates`?(0,o.jsx)(kv,{}):l?.component===`ai-services`?(0,o.jsx)(Nv,{}):l?.component===`bgc-integration`?(0,o.jsx)(zv,{}):(0,o.jsx)(KC,{activeSection:l,activeGroup:u,filteredCards:d,searchText:n,setSearchText:s,allItems:c,handleNav:p})})]})]})}var{Title:JC}=i.Typography;function YC(){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:XC,Title:ZC}=i.Typography,QC=10*1024*1024,$C=`/templates/test_cases_flow_template.base64.txt`,ew=`test_cases_flow_template.xlsx`,tw=`module | subModule | step_order | description | actions | key | value | expected | scenario`,nw={idle:0,module_set:1,encoding:1,validating:2,preview:3,inserting:3,done:4,error:1},rw=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Bulk upload`,href:`/bulk-upload`}];function iw(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 aw(e){return e.filter(e=>e.row_status===`valid`).map(e=>{let t={...e};return delete t.row_status,delete t.errors,t})}function ow(e){return e.flatMap(e=>(e.errors??[]).map(t=>({id:e.id,...t})))}function sw({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 cw({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 lw({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)(XC,{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)(sw,{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 uw(){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=ow(x),N=h===`encoding`||h===`validating`,P=!!p&&!N,F=nw[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 oh({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>QC){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 iw(e);g(`validating`),S((await th({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($C);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=ew,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 nh({project:c?.name??``,module:p,uploaded_by:localStorage.getItem(`user_Email`)??``,rows:aw(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`)}},V=(0,r.useCallback)(()=>{u.current?.scrollIntoView({behavior:`smooth`,block:`center`})},[]),H=[`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:rw})}),c?.name&&(0,o.jsx)(i.Col,{children:(0,o.jsx)(XC,{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)(ZC,{level:3,children:`Bulk upload test cases`}),(0,o.jsxs)(i.Space,{direction:`vertical`,size:4,children:[(0,o.jsx)(XC,{type:`secondary`,children:tw}),(0,o.jsx)(XC,{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:H,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)(cw,{errors:M,expanded:k,onToggle:()=>A(e=>!e),onSummaryClick:V}),T&&h===`preview`&&(0,o.jsx)(i.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`}),(0,o.jsx)(lw,{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)(XC,{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)(XC,{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)(XC,{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 dw=[{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:fw}=i.Typography,pw=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}],mw={tags:`regression`,active:1},hw={module:{dbName:`Modules`,formField:`module`,label:`Module`}};function gw(e=[]){return e.map(e=>({value:e,label:e}))}function _w(e=``){return String(e??``).trim()}function vw(e=``){return _w(e).toLowerCase()}function yw(e=[]){let t=new Map;return e.forEach(e=>{let n=_w(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function bw(e=[],t,n){let r=_w(t).toLowerCase(),i=_w(n).toLowerCase();return e.reduce((e,t)=>{let n=_w(t?.module).toLowerCase(),a=_w(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 xw({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)(fw,{strong:!0,className:`v1-section-label`,children:t})]})}function Sw(){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=hw[v.typeKey],O=(0,r.useMemo)(()=>gw(c),[c]),k=i.Form.useWatch(`module`,t),A=i.Form.useWatch(`flow`,t),j=!!_w(k),M=!!_w(A),N=!j,P=!j||!M,F=(e,t=[])=>{e===`module`&&l(t)},I=async()=>{h(!0);try{l((await Xm(hw.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=_w(e);if(d([]),p([]),t.setFieldsValue({step_order:void 0}),n){_(!0);try{let e=await eh({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];d(t),p(yw(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=_w(e),o=_w(n);if(!a||!o){t.setFieldsValue({step_order:void 0});return}C(!0);try{t.setFieldsValue({step_order:bw(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:_w(e.module),flow:_w(e.flow),step_order:Number(e.step_order),description:_w(e.description),keyword:vw(e.keyword),target:_w(e.target),value:_w(e.value),expected:_w(e.expected),tags:e.tags?_w(e.tags):mw.tags,active:Number(e.active)};T(!0);try{await $m(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]:_w(n)})},ee=e=>{t.setFieldsValue({module:_w(e),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:mw.tags,value:void 0,expected:void 0})},V=e=>{t.setFieldsValue({flow:_w(e),step_order:void 0})},H=e=>{let t=hw[e];y({open:!0,typeKey:e}),n.setFieldsValue({name:``,type:t.label})},te=()=>{y(e=>({...e,open:!1})),n.resetFields()},ne=async()=>{try{let e=_w((await n.validateFields()).name),r=await Zm({name:e,type:D.dbName});F(v.typeKey,r?.items??[]),t.setFieldsValue({[D.formField]:e}),i.message.success(`${D.label} added successfully.`),te()}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:pw})}),(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)(fw,{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:mw,onFinish:z,autoComplete:`off`,children:[(0,o.jsx)(i.Card,{className:`v1-card`,title:(0,o.jsx)(xw,{icon:(0,o.jsx)(a.FileTextOutlined,{}),title:`Test Case Details`}),extra:(0,o.jsx)(fw,{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:()=>H(`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:V,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:dw,onChange:e=>t.setFieldsValue({keyword:vw(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:te,onOk:()=>{x(!0),ne()},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:_w(e.target.value)})}})}),(0,o.jsx)(i.Form.Item,{label:`Type`,name:`type`,children:(0,o.jsx)(i.Input,{disabled:!0})})]})})]})})]})}var{Text:Cw}=i.Typography,ww=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`}];function Tw(e=``){return String(e??``).trim()}function Ew(e=[],t){return e.map(e=>({value:e.id,label:e[t]}))}var Dw=[{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`})}],Ow={key:!1,value:!1,expected:!1};function kw(e,t){return t?e[t]??Ow:Ow}function Aw(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function jw(){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)(dw),[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)(()=>kw(x,F),[x,F]),z=(0,r.useMemo)(()=>Ew(p,`modulename`),[p]),B=(0,r.useMemo)(()=>Ew(h,`submodulename`),[h]),ee=(0,r.useMemo)(()=>p.find(e=>e.id===N)?.modulename??``,[p,N]),V=(0,r.useMemo)(()=>h.find(e=>e.id===P)?.submodulename??``,[P,h]),H=(0,r.useCallback)(async()=>{try{let e=await Qm();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.`)}},[]),te=(0,r.useCallback)(async e=>{if(!e){m([]);return}w(!0);try{m((await oh({project:e,activeOnly:!0}))?.items??[])}catch(e){console.error(`Unable to load modules:`,e),i.message.error(`Unable to load modules.`)}finally{w(!1)}},[]),ne=(0,r.useCallback)(async(e,t)=>{if(!e||!t){g([]);return}E(!0);try{g((await lh({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)}},[]),U=(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([fh({product_parent_ID:e,module_parent_ID:t,submodule_parent_ID:r,actions:a,limit:1e3}),hh({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]),W=(0,r.useCallback)(async(e=``)=>{if(!(!f?.id||!N||!P)){O(!0);try{v((await fh({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]),re=(0,r.useCallback)(async()=>{if(!(!u||!f?.name)){M(!0);try{let e=await mh(u);await ne(f.name,e.module),v((await fh({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,ne,c,f?.name]);return(0,r.useEffect)(()=>{if(!f){c(`/select-project`,{replace:!0});return}Promise.resolve().then(async()=>{await H(),await te(f.name),u&&await re()})},[f,c,H,te,u,re]),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:ww})}),(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)(Cw,{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:Tw(e.description),actions:Tw(e.actions),key:Tw(e.key),value:Tw(e.value),expected:Tw(e.expected),scenario:+!!e.scenario,active:+!!e.active};A(!0);try{if(d){await gh(u,{...t,step_order:Number(e.step_order)}),i.message.success(`Test case updated successfully.`),c(`/viewTestCase`);return}await ph(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 U(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}),Aw(n,[`actions`,`key`,`value`,`expected`]),g([]),v([]),ne(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}),Aw(n,[`actions`,`key`,`value`,`expected`]),U(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)(Cw,{type:`secondary`,children:[ee,` / `,V]}),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=kw(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}),Aw(n,[`key`,`value`,`expected`]),W(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)(cf,{listName:`Added Steps`,loading:D,fields:Dw,dataSource:_,current:1,pageSize:Math.max(_.length,1),total:_.length,rowSelection:!1,className:`zt-list-plain zt-list-static`})})]})})]}):null}var{Text:Mw}=i.Typography,Nw=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`}];function Pw(){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([oh({project:e}),lh({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 ch(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 sh({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:Nw})}),(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)(Mw,{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)(cf,{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)(Mw,{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:Fw}=i.Typography,Iw=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`},{label:`Manage Submodules`,href:`/test-cases/zinnext/submodules`}];function Lw(){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 lh({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 dh(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 uh({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:Iw})}),(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)(Fw,{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)(Fw,{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)(cf,{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)(Fw,{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:Rw}=i.Typography,zw=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Table`,href:`/viewTestCase`}];function Bw(){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 fh({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 _h(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:zw})}),(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)(Rw,{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)(cf,{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 Vw=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}];function Hw(){return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsx)(e.t,{items:Vw}),(0,o.jsx)(Wa,{moduleName:`test-flows`,rowKey:`id`})]})}var{Text:Uw}=i.Typography,Ww=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}],Gw={tags:`regression`,active:1},Kw={module:{dbName:`Modules`,formField:`module`,label:`Module`}},qw={key:!1,value:!1,expected:!1};function Jw(e,t){return t?e[t]??qw:qw}function Yw(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function Xw(e=[]){return e.map(e=>({value:e,label:e}))}function Zw(e=``){return String(e??``).trim()}function Qw(e=[]){let t=new Map;return e.forEach(e=>{let n=Zw(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function $w(e=[],t,n){let r=Zw(t).toLowerCase(),i=Zw(n).toLowerCase();return e.reduce((e,t)=>{let n=Zw(t?.module).toLowerCase(),a=Zw(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 eT({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)(Uw,{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)(dw),[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=Kw[S.typeKey],M=(0,r.useMemo)(()=>Xw(c),[c]),N=i.Form.useWatch(`module`,t),P=i.Form.useWatch(`flow`,t),F=i.Form.useWatch(`keyword`,t),I=!!Zw(N),L=!!Zw(P),R=!I,z=!I||!L,B=(0,r.useMemo)(()=>Jw(g,F),[g,F]),ee=(e,t=[])=>{e===`module`&&l(t)},V=async()=>{y(!0);try{l((await Xm(Kw.module.dbName))?.items??[])}catch(e){console.error(`Unable to load testing options:`,e),i.message.error(`Unable to load testing options.`)}finally{y(!1)}},H=async()=>{try{let e=await Qm();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.`)}},te=(0,r.useCallback)(async e=>{let n=Zw(e);if(d([]),p([]),t.setFieldsValue({step_order:void 0}),n){x(!0);try{let e=await ih({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];d(t),p(Qw(t))}catch(e){console.error(`Unable to load flows:`,e),i.message.error(`Unable to load flows.`)}finally{x(!1)}}},[t]),ne=(0,r.useCallback)(async(e,n,r)=>{let a=Zw(e),o=Zw(n);if(!a||!o){t.setFieldsValue({step_order:void 0});return}D(!0);try{t.setFieldsValue({step_order:$w(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([V(),H()])})},[]),(0,r.useEffect)(()=>{Promise.resolve().then(()=>te(N))},[te,N]),(0,r.useEffect)(()=>{Promise.resolve().then(()=>ne(N,P,u))},[u,ne,P,N]);let U=async e=>{let n={module:Zw(e.module),flow:Zw(e.flow),step_order:Number(e.step_order),description:Zw(e.description),keyword:Zw(e.keyword),target:Zw(e.target),value:Zw(e.value),expected:Zw(e.expected),tags:e.tags?Zw(e.tags):Gw.tags,active:Number(e.active)};k(!0);try{await rh(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)}},W=(e,n)=>{t.setFieldsValue({[e]:Zw(n)})},re=e=>{t.setFieldsValue({module:Zw(e),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:Gw.tags,value:void 0,expected:void 0}),Yw(t,[`keyword`,`target`,`value`,`expected`])},G=e=>{t.setFieldsValue({flow:Zw(e),step_order:void 0,keyword:void 0,target:void 0,value:void 0,expected:void 0}),Yw(t,[`keyword`,`target`,`value`,`expected`])},ie=e=>{let n=Jw(g,e);t.setFieldsValue({keyword:Zw(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}),Yw(t,[`target`,`value`,`expected`])},K=e=>{let t=Kw[e];C({open:!0,typeKey:e}),n.setFieldsValue({name:``,type:t.label})},ae=()=>{C(e=>({...e,open:!1})),n.resetFields()},q=async()=>{try{let e=Zw((await n.validateFields()).name),r=await Zm({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:Ww})}),(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)(Uw,{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:Gw,onFinish:U,autoComplete:`off`,children:[(0,o.jsx)(i.Card,{className:`v1-card`,title:(0,o.jsx)(eT,{icon:(0,o.jsx)(a.FileTextOutlined,{}),title:`LMS Case Details`}),extra:(0,o.jsx)(Uw,{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:re})}),(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=>W(`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=>W(`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=>W(`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=>W(`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=>W(`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),q()},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:Zw(e.target.value)})}})}),(0,o.jsx)(i.Form.Item,{label:`Type`,name:`type`,children:(0,o.jsx)(i.Input,{disabled:!0})})]})})]})})]})}var nT=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}];function rT(){return(0,o.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,o.jsx)(e.t,{items:nT}),(0,o.jsx)(Wa,{moduleName:`lms-flows`,rowKey:`id`})]})}var iT=[`referenceId`,`ReferenceId`,`candidateId`,`CandidateId`,`entityId`,`EntityId`,`id`,`Id`,`_id`];function aT(e=iT){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 oT(e,t=iT){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 sT=aT();function cT(e){return typeof e==`function`?e:typeof e==`string`?aT([e]):Array.isArray(e)?aT(e):sT}function lT(e,t,n){return!t||typeof t!=`object`?e:{...t,...e,id:t.id??e.id??n}}function uT(e,t,n={}){return{status:`success`,total:t,data:{data:e,...n}}}var dT=[`fields`,`fieldConfig`,`tabs`,`tabField`,`actionRules`,`actions`,`columnActions`];function fT(e){let t=e?.data??e,n={};for(let r of dT){let i=e?.[r]??t?.[r];i==null||Array.isArray(i)&&i.length===0||(n[r]=i)}return n}var pT=e=>String(e??``).replace(/[^a-zA-Z0-9]/g,``).toLowerCase();function mT(e,t,n){let r=(Array.isArray(n)?n:[n]).map(pT).filter(Boolean),i=r.length?e.findIndex(e=>r.includes(pT(e?.value))||r.includes(pT(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 hT=(e,t)=>Cr(e,t).rows,gT=(e,t)=>{let{rows:n,total:r}=Cr(e,t);return{rows:n,total:r}};function _T({fetchPrimaryPage:e,extractPrimaryPage:t=gT,fetchSecondaryByKeys:n,fetchPrimary:r,extractPrimaryRows:i=hT,fetchSecondary:a,extractSecondaryRows:o=hT,fetchSecondaryById:s,primaryKey:c,secondaryKey:l,mergeRow:u=lT,secondaryFetchLimit:d=200,extraFields:f=[],extraFieldsAfter:p}){let m=cT(c),h=typeof l==`function`?e=>{let t=l(e);return t?[String(t)]:[]}:e=>oT(e,typeof l==`string`?[l]:Array.isArray(l)?l:iT),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=fT(e);for(let e of Object.keys(t))r[e]??(r[e]=t[e])}return f.length&&(r.fields=mT(r.fields??[],f,p)),uT(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 vT(e,t,n={}){return _T({fetchPrimary:()=>Fx(e,t),extractPrimaryRows:Mx,fetchSecondary:tn,fetchSecondaryById:Ix,secondaryFetchLimit:n.moduleFetchLimit??200})}function yT(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 bT(e){let t=Array.isArray(e?.stages)?e.stages:[];if(!t.length)return e;let n={};for(let e of t){let t=yT(e?.stageName);t&&(n[t]=Number(e?.count)||0)}return{...n,...e}}var xT=e=>{let t=Number(e?.targetSubmission??e?.targetSubmissions);return Number.isFinite(t)&&t>0?t:null};function ST({submittedCountField:e=`submittedCount`,progressField:t=`targetSubmissionProgress`}={}){return function(n,r,i){let a=lT(n,r,i),o=xT(a);return o!=null&&(console.log(`mergeJobWorkflowRow`,i,a?.[e],o),a[t]=`${Number(a?.[e])||0} of ${o}`),a}}function CT(e={}){let t=ST(),n=_T({primaryKey:`_id`,secondaryKey:`entityId`,extraFields:e.extraFields,extraFieldsAfter:e.extraFieldsAfter,fetchPrimaryPage:tn,fetchSecondaryByKeys:()=>Px(),extractSecondaryRows:e=>(e?.items??[]).map(bT),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 wT(e,t=10,n=0,r={},i={}){return Cr(await CT(i)(e,t,n,r),e)}async function TT(e,t,n,r=10,i=0,a={}){return Cr(await vT(e,t)(n,r,i,a),n)}var ET=XS,DT=bh(qC),OT=bh(YC),kT=bh(uw),AT=bh(Sw),jT=bh(jw),MT=bh(Pw),NT=bh(Lw),PT=bh(Bw),FT=bh(Hw),IT=bh(tT),LT=bh(rT);exports.ADMIN_API_URL=t._,exports.ADMIN_APP_ID=t.v,exports.APP_ID=t.y,exports.AUTH_URL=t.b,exports.ActivityTab=Es,exports.AddBatchCandidatePopup=NS,exports.AddFormV1=us,exports.AdminDashboard=XS,exports.AdminDashboardContent=Iy,exports.AdminPage=ET,exports.AppAlert=ds,exports.AppButton=Xr,exports.AppShell=Um,exports.ApprovalActionBar=Hf,exports.AssigneeAvatars=Ds,exports.AuthGuard=Vm,exports.BILLING_STATUS_FLOW=Il,exports.BULK_UPLOAD_DEFAULT_ACCEPT=Os,exports.BULK_UPLOAD_DEFAULT_MAX_SIZE_MB=ks,exports.Breadcrumb=e.t,exports.BulkUploadPage=kT,exports.BulkUploadPanel=Ls,exports.CANDIDATES_URL=t.x,exports.CONTRACT_C2C=op,exports.CONTRACT_W2=ap,exports.CalendarCard=D,exports.CoreThemeAdminApp=By,exports.CoreThemeAdminRoutes=zy,exports.CustomPagination=Se,exports.DayLogModal=If,exports.DescriptionBlock=Xs,exports.DetailHeaderCard=Ru,exports.DetailViewPage=Gu,exports.DetailViewV1=Bc,exports.DocumentViewer=e.Hn,exports.DynamicCards=bt,exports.DynamicPopup=hx,exports.DynamicPopupRoute=IS,exports.DynamicTabs=j,exports.EditFormV1=zd,exports.FINANCE_APPROVAL_CONFIG=ep,exports.FINANCE_TYPE_CFO=Xf,exports.FINANCE_TYPE_ONBOARDING_MANAGER=Yf,exports.FINANCE_TYPE_ONBOARDING_MANAGER_REAPPROVE=Qf,exports.FINANCE_TYPE_SUBMISSION_MANAGER=Jf,exports.FINANCE_TYPE_SUBMISSION_MANAGER_REAPPROVE=Zf,exports.FileListCard=Bp,exports.FinanceApprovalPanel=Mp,exports.FinanceAvatar=_u,exports.FinanceBadge=xu,exports.FinanceDayCell=Wf,exports.FinanceDivider=lu,exports.FinanceEmployeeCell=vu,exports.FinanceEmptyState=ou,exports.FinanceEquation=uu,exports.FinanceHistoryTimeline=mu,exports.FinanceHoursGrid=au,exports.FinanceKpiRow=iu,exports.FinanceLine=cu,exports.FinanceListToolbar=yf,exports.FinanceMarginBadge=Su,exports.FinanceMoneyCell=bu,exports.FinanceRecordsTable=Tu,exports.FinanceRowChevron=Cu,exports.FinanceSection=su,exports.FinanceStatusPill=ru,exports.FinanceTextCell=yu,exports.FinanceTimesheetAnalysis=Kf,exports.FinanceWorkflowSteps=du,exports.Header=hm,exports.HierarchyUserFilter=Tt,exports.JOBS_URL=t.S,exports.LegacyAdminPage=DT,exports.ListView=Wa,exports.LmsHomePage=LT,exports.LmsTestForm=IT,exports.Login=Wm,exports.MailPopup=Jy,exports.ManageModules=MT,exports.ManageSubmodules=NT,exports.ModuleRowActions=Jd,exports.NotesPanel=Vf,exports.PAYROLL_STATUS_FLOW=Ll,exports.POPUP_CONFIGS=ES,exports.ParamCardView=tf,exports.ParamListView=cf,exports.PreviewPopup=Eb,exports.ProjectSelect=yh,exports.ProofUploadPreview=Bf,exports.QuickLogBar=zf,exports.QuickLogSelectionBar=Lf,exports.RejectionReasonModal=Rf,exports.SUBMISSIONS_URL=t.C,exports.Sidebar=Lm,exports.StatusBadge=uf,exports.StatusBadgeTag=Sf,exports.StickyNotesFullPage=OT,exports.StylishDynamicTabs=ff,exports.TemplateEditor=_f,exports.TestForm=AT,exports.TestingHomePage=FT,exports.TimelineGroups=vs,exports.TimesheetDayCell=jf,exports.TipTapEditor=e.Un,exports.UserForm=YS,exports.VendorShareDrawer=BS,exports.ViewSummaryWidget=Yr,exports.WizardPopup=Mb,exports.ZinnextTableView=PT,exports.ZinnextTestForm=jT,exports.applyIntegrationStatus=e.ct,exports.approveSubmission=oe,exports.buildAcceptAttr=Ps,exports.buildCsv=Zl,exports.buildDailyRows=Gl,exports.buildDayGradient=kf,exports.buildRateHistoryEntries=wp,exports.buildWeeklyRollup=Jl,exports.clearSelectedProject=t.r,exports.colors=e.Kn,exports.computeFinance=Sp,exports.computeMarginBand=Yl,exports.configureCoreTheme=t.w,exports.createAllWorkflowsListFetcher=CT,exports.createWorkflowStageListFetcher=vT,exports.deleteIntegrationConfig=e.yt,exports.deriveDayStats=Wl,exports.downloadCsv=tu,exports.findEmployerRow=gp,exports.flattenGroups=mp,exports.formatFileSize=Ns,exports.formatFinanceMoney=Tp,exports.formatHours=Dl,exports.formatMoney=El,exports.formatPercent=kl,exports.formatRate=Ol,exports.getActivity=e.tt,exports.getAllWorkflowsModuleList=wT,exports.getApprovalDate=Nl,exports.getBgcIntegrationConfig=e.It,exports.getBgcIntegrationSummary=e.Lt,exports.getBillingActionStates=Rl,exports.getCurrentRoleName=t.s,exports.getFieldLabel=$l,exports.getFileExtension=Ms,exports.getFinanceApprovalConfig=np,exports.getFormGroupsRaw=Rp,exports.getIntegrationConfig=e.Ut,exports.getIntegrationConfigs=e.Wt,exports.getIntegrationSummary=e.Gt,exports.getModuleConfig=xe,exports.getModuleDataDetail=e.rt,exports.getPayrollActionStates=zl,exports.getSelectedProject=t.c,exports.getStoredToken=t.l,exports.getStoredUser=t.u,exports.getUserRoles=t.d,exports.getVMSApprove=se,exports.getValueStyle=eu,exports.getWorkflowStageModuleList=TT,exports.getWorkflowSteps=Bl,exports.humanizeEvent=Ml,Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return co}}),exports.indexFieldConfig=Ql,exports.initialsOf=Al,exports.isTester=t.f,exports.logout=t.m,exports.marginIncludesReferral=ip,exports.matchLocationTax=xp,Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Ju}}),exports.normalizeContract=vp,Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Rs}}),exports.rejectSubmission=J,exports.resolveActivityMeta=Cs,exports.resolveAndCompute=Cp,exports.resolveFinanceInputs=bp,exports.resolveMergeKey=sT,exports.resolveRejectionReason=rp,exports.resolveSubmissionFinance=zp,exports.saveBgcIntegrationConfig=e.fn,exports.saveIntegrationConfig=e.hn,exports.setSelectedProject=t.g,exports.stageCountKey=yT,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Gm}}),exports.testIntegrationConnection=e.xn,exports.useDropdownFields=vn,exports.useDropdownValues=Zr,exports.useEditForm=Vp,exports.useFieldConfig=yn,exports.useFilterFields=bn,exports.useMenuPermission=En,exports.useModuleActions=Vd,exports.useRecordRefresh=Hu,exports.validateBulkFile=Fs,exports.withAdminAppId=t.T,exports.withAppId=t.E,exports.withAuthGuard=bh;
|
|
10
10
|
//# sourceMappingURL=index.cjs.map
|