@realtek/core-theme-live 0.0.430 → 0.0.431
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 +5951 -7073
- package/dist-lib/index.js.map +1 -1
- package/package.json +1 -1
package/dist-lib/index.cjs
CHANGED
|
@@ -4,5 +4,5 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
4
4
|
`).map(e=>e.trim()).filter(Boolean);if(a.length===1?r.helpText=a[0]:a.length>1&&(r.helpText=a),e.rowHierarchyEnabled&&(r.rowHierarchy=e.rowHierarchy??jw),e.autofillFrom)try{let t=typeof e.autofillFrom==`string`?JSON.parse(e.autofillFrom):e.autofillFrom;Array.isArray(t)&&t.length>0&&(r.autofillFrom=t)}catch{}Array.isArray(e.aiActions)&&e.aiActions.length>0&&(r.aiActions=e.aiActions.filter(e=>e?.key&&e?.label&&e?.serviceKey&&e?.endpointPath).map(e=>({key:e.key,label:e.label,trigger:e.trigger||`click`,serviceKey:e.serviceKey,endpointPath:e.endpointPath,bodyType:e.bodyType||`json`,inputs:(e.inputs||[]).filter(e=>e?.param&&e?.sourceField).map(e=>({param:e.param,sourceField:e.sourceField,kind:e.kind||`text`,...e.transform?{transform:e.transform}:{},...e.group?{group:e.group}:{},...e.required?{required:!0}:{},...Number(e.minWords)>0?{minWords:Number(e.minWords)}:{}})),...String(e.responseDataPath||``).trim()?{responseDataPath:String(e.responseDataPath).trim()}:{},...String(e.position||``).trim()?{position:String(e.position).trim()}:{},...e.confirmWhen&&e.confirmWhen!==`never`?{confirmWhen:e.confirmWhen}:{},...Aw(e.confirmMessages)?{confirmMessages:Aw(e.confirmMessages)}:{}})));let o=e.validator?.type;if(o){r.validator={type:o},e.validator.title&&(r.validator.title=e.validator.title);let t=Number(e.validator.maxLength);!isNaN(t)&&t>0&&(r.validator.maxLength=t);let n=Number(e.validator.maxChars);!isNaN(n)&&n>0&&(r.validator.maxChars=n)}if(e.type===`location`&&(r.multiSelect=e.multiSelect??!1),[`select`,`radio`,`checkbox`].includes(e.type)){let t=e.dataSource??`static`;if(r.dataSource=t,e.type===`select`&&(r.multiSelect=e.multiSelect??!1),e.allowCustomValues&&(r.allowCustomValues=!0,e.tokenSeparators!==void 0&&String(e.tokenSeparators)!==``&&(r.tokenSeparators=String(e.tokenSeparators))),e.optionsFromField&&(r.optionsFromField=String(e.optionsFromField).trim()),t===`master`&&(r.masterName=e.masterName??``),t===`group`&&(r.groupName=e.groupName??``,e.groupRoleContains&&(r.groupRoleContains=String(e.groupRoleContains).trim())),t===`locationMaster`&&(r.locationLevel=e.locationLevel||`country`,(r.locationLevel===`state`||r.locationLevel===`city`)&&e.locationCountryFrom&&(r.locationCountryFrom=String(e.locationCountryFrom).trim()),r.locationLevel===`city`&&e.locationStateFrom&&(r.locationStateFrom=String(e.locationStateFrom).trim())),t===`static`&&(r.options=ZC(e.options)),t===`lookup`){r.lookupCollection=e.lookupCollection??``,r.displayField=e.displayField??``,e.displayField2&&(r.displayField2=e.displayField2),r.valueField=e.valueField??`_id`,e.lookupFilterField&&e.lookupFilterValueFrom&&(r.lookupFilterField=e.lookupFilterField,r.lookupFilterValueFrom=e.lookupFilterValueFrom);let t=Ow(e.lookupFilters);t.length&&(r.lookupFilters=t);let n=String(e.optionsRequireExtraField??``).trim();if(n){r.optionsRequireExtraField=n;let t=String(e.optionsRequireExtraValue??``).trim();t&&(r.optionsRequireExtraValue=t)}let i=String(e.optionsHierarchyParentField??``).trim();if(i&&(r.optionsHierarchyParentField=i,r.optionsHierarchySelfFrom=String(e.optionsHierarchySelfFrom??``).trim()||`currentUserId`),e.quickCreate){r.quickCreate=!0,e.quickCreateModule&&(r.quickCreateModule=e.quickCreateModule),e.quickCreateLabel&&String(e.quickCreateLabel).trim().toLowerCase()!==`add more`&&(r.quickCreateLabel=String(e.quickCreateLabel).trim());let t=e.quickCreateNotice;if(t?.enabled){let e={enabled:!0};[`title`,`message`,`recordNameField`,`recordLabel`,`creatorLabel`].forEach(n=>{let r=String(t[n]??``).trim();r&&(e[n]=r)}),e.showCreator=t.showCreator!==!1,e.showRecordName=t.showRecordName!==!1,r.quickCreateNotice=e}}e.quickEdit&&(r.quickEdit=!0,e.quickEditModule&&(r.quickEditModule=e.quickEditModule),e.quickEditLabel&&String(e.quickEditLabel).trim().toLowerCase()!==`add more`&&(r.quickEditLabel=String(e.quickEditLabel).trim()),e.quickEditIdFrom&&(r.quickEditIdFrom=e.quickEditIdFrom))}}for(let[t,n]of Object.entries(e))n!=null&&n!==``&&(t in r||Lw.has(t)||(r[t]=n));return r})}function Fw({collection:e,displayField:t,valueField:r,value:i,labelValue:a,onChange:o}){let[l,d]=(0,s.useState)([]),[f,p]=(0,s.useState)(!1),m=(0,s.useRef)(``),h=()=>{let i=`${e}|${t}|${r}`;!e||!t||m.current===i||(p(!0),n.ci(e,t,r||`_id`).then(e=>{m.current=i,d(e)}).catch(()=>d([])).finally(()=>p(!1)))},g=i&&!l.some(e=>e.value===i)?[{label:a||i,value:i},...l]:l;return(0,u.jsx)(c.Select,{size:`small`,showSearch:!0,allowClear:!0,loading:f,placeholder:e?`Pick from ${e}`:`Configure a lookup first`,disabled:!e||!t,style:{width:220},optionFilterProp:`label`,options:g,value:i||void 0,onDropdownVisibleChange:e=>{e&&h()},onChange:(e,t)=>o(e??``,t?.label??``),getPopupContainer:()=>document.body})}var Iw=[{value:`eq`,label:`equals`},{value:`neq`,label:`not equals`},{value:`in`,label:`is one of`},{value:`notIn`,label:`is not one of`},{value:`notEmpty`,label:`has a value`},{value:`truthy`,label:`is true`},{value:`falsy`,label:`is false / empty`}],Lw=new Set(`label.field.type.show.req.edit.order.formatter.validations.showOnAdd.addRow.minRows.maxRows.initialRows.addLabel.subFields.placeholder.hidePlaceholder.inputDateFormat.combineKey.combineLabel.combineRole.combineToggleLabel.combineToggleTarget.combineWidth.combineWrap.combineSpan.defaultOnEdit.defaultOnServer.noPrefill.emptyValues.valuePaths.clientScope.clientGateMessage.clientGateResetOnChange.visiblePermission.editablePermission.infoEnabled.infoText.tooltip.helpText.payloadKey.prefillFrom.prefillFromModule.dataType.elementType.prefillAsHint.prefillHintLabel.payloadMode.valueKey.displayKey.defaultValue.richValue.omitEmpty.payloadTemplate.transformRule.multiple.maxCount.fileKey.fileNameKey.fileUrlKey.accept.showIf.labelWhen.colWhen.colWhenField.colWhenOperator.colWhenValue.colWhenCol.verifyAction.verifyResultField.verifyTimestampField.prefillWhen.prefillWhenReset.prefillWhenExclusive.verifyIdleLabel.verifyRetryLabel.verifySuccessLabel.verifyLockedWhenFields.verifyLockedLabel.disabledByField.requiredIfField.linkedClearField.clearGroupOnChange.splitDialCodeInto.requiredWhen.requiredWhenField.requiredWhenOperator.requiredWhenValue.requiredWhenMessage.blockWhileResolving.blockScope.overrideCheckbox.overrideEnabled.overrideLabel.overrideField.overrideSkipValidations.overrideConfirmTitle.overrideConfirmBody.overrideConfirmOkText.overrideConfirmCancelText.overrideStore.checkDuplicateOnBlur.rowHierarchy.exclusiveInGroup.disabledReason.clearWhenDisabled.autofillFrom.aiActions.validator.dataSource.masterName.groupName.groupRoleContains.options.multiSelect.lookupCollection.displayField.displayField2.valueField.lookupFilterField.lookupFilterValueFrom.lookupFilters.locationLevel.locationCountryFrom.locationStateFrom.optionsRequireExtraField.optionsRequireExtraValue.optionsHierarchyParentField.optionsHierarchySelfFrom.allowCustomValues.tokenSeparators.optionsFromField.quickCreate.quickCreateModule.quickCreateLabel.quickCreateNotice.quickEdit.quickEditModule.quickEditLabel.quickEditIdFrom.value.documentPreview.displayAs.renderType.renderOptions`.split(`.`)),Rw=new Set(`module.name.label.addRow.order.fields.hideGroup.hideGroupInForm.moduleName.linkField.linkTypeField.parentRefField.hierarchyLevel.hierarchyParent.hierarchyLinkField.writeRefs.dependsOn.optionalWrite.appendHistory.allowCollapse.defaultCollapsed.collapseWhenEmpty.historyField.historyFields.historyTimestampField.historyLabels.historyLabelFrom.historyAfterGroup.historyAmountFields.historyCurrencyFields.historyUnitFields.historyShowIf.minRows.maxRows.initialRows.requireOne.requireValidatedField.requireValidatedFieldMessage.submitDisabledMessage.requireAnyOf.requireAnyOfMessage.allowInProgress.inProgressMessage.orderBy.orderByEnabled.levelRule.levelRuleEnabled.regionRules.duplicateCheck.linkGroup.mergeInto.mergePosition.infoEnabled.infoText.toggleEnabled.toggleLabel.toggleField.afterSubmit.showIf.showIfField.showIfOperator.showIfValue.disabled.disabledIf.disabledIfField.disabledIfOperator.disabledIfValue.formActions.afterSubmitMode.afterSubmitTarget.submitMessages.submitMsgAddSuccess.submitMsgEditSuccess.submitMsgAddError.submitMsgEditError.submitMsgSuppress.id._id.rows.toggleValue`.split(`.`));function zw(e){return{...e,show:e.show===1,req:e.req===1,edit:e.edit===1,showOnAdd:e.showOnAdd!==!1,addRow:e.addRow??!1,minRows:e.minRows??``,maxRows:e.maxRows??``,initialRows:e.initialRows??``,addLabel:e.addLabel??``,subFields:Array.isArray(e.subFields)?e.subFields.map(e=>({field:e.field??``,label:e.label??``,type:e.type??`text`,req:e.req===1||e.req===!0,col:e.col??``,payloadKey:e.payloadKey??``,dataSource:e.dataSource??`static`,multiSelect:e.multiSelect??!1,masterName:e.masterName??``,groupName:e.groupName??``,options:Array.isArray(e.options)?e.options:[],lookupCollection:e.lookupCollection??``,displayField:e.displayField??``,displayField2:e.displayField2??``,valueField:e.valueField??`_id`,lookupFilterField:e.lookupFilterField??``,lookupFilterValueFrom:e.lookupFilterValueFrom??``})):[],placeholder:e.placeholder??``,hidePlaceholder:e.hidePlaceholder??!1,inputDateFormat:e.inputDateFormat??``,clientScope:e.clientScope??!1,clientGateMessage:e.clientGateMessage??``,clientGateResetOnChange:e.clientGateResetOnChange??!1,visiblePermission:e.visiblePermission??``,editablePermission:e.editablePermission??``,infoEnabled:e.infoEnabled??!1,infoText:e.infoText??``,tooltip:e.tooltip??``,helpText:Array.isArray(e.helpText)?e.helpText.join(`
|
|
5
5
|
`):e.helpText??``,formatter:e.formatter??``,combineKey:e.combineKey??``,combineLabel:e.combineLabel??``,combineRole:e.combineRole??``,combineToggleLabel:e.combineToggleLabel??``,combineToggleTarget:e.combineToggleTarget??``,combineWidth:e.combineWidth??``,combineWrap:e.combineWrap??!1,combineSpan:e.combineSpan??``,defaultOnEdit:e.defaultOnEdit??!1,defaultOnServer:e.defaultOnServer??!1,noPrefill:e.noPrefill??!1,emptyValues:Array.isArray(e.emptyValues)?e.emptyValues.join(`, `):e.emptyValues??``,valuePaths:Array.isArray(e.valuePaths)?e.valuePaths.join(`, `):e.valuePaths??``,booleanCapable:e.booleanCapable??!1,booleanApiKey:Array.isArray(e.booleanApiKey)?e.booleanApiKey.join(`,`):e.booleanApiKey??``,booleanPlaceholder:e.booleanPlaceholder??``,col:e.col??void 0,isPrimaryKeyword:e.isPrimaryKeyword??!1,showMandatoryOption:e.showMandatoryOption??!1,keywordRole:e.keywordRole??`include`,keywordGroup:e.keywordGroup??e.field??``,keywordFields:Array.isArray(e.keywordFields)?e.keywordFields.join(`, `):e.keywordFields??``,maxKeywords:e.maxKeywords??``,hideInBooleanMode:e.hideInBooleanMode??!1,min:e.min??``,max:e.max??``,defaultRange:e.defaultRange??void 0,defaultPreset:e.defaultPreset??void 0,display:e.display??`both`,minLabel:e.minLabel??``,maxLabel:e.maxLabel??``,unit:e.unit??``,rangeKeys:Array.isArray(e.rangeKeys)?e.rangeKeys.join(`,`):e.rangeKeys??``,filterField:e.filterField??``,hideSelectAll:e.hideSelectAll??!1,dataSource:e.dataSource??`static`,masterName:e.masterName??``,groupName:e.groupName??``,groupRoleContains:e.groupRoleContains??``,options:e.options??[],lookupCollection:e.lookupCollection??``,displayField:e.displayField??``,displayField2:e.displayField2??``,valueField:e.valueField??`_id`,lookupFilterField:e.lookupFilterField??``,lookupFilterValueFrom:e.lookupFilterValueFrom??``,locationLevel:e.locationLevel??`country`,locationCountryFrom:e.locationCountryFrom??``,locationStateFrom:e.locationStateFrom??``,lookupFilters:Dw(e.lookupFilters),optionsRequireExtraField:e.optionsRequireExtraField??``,optionsRequireExtraValue:e.optionsRequireExtraValue??``,optionsHierarchyParentField:e.optionsHierarchyParentField??``,optionsHierarchySelfFrom:e.optionsHierarchySelfFrom??``,allowCustomValues:e.allowCustomValues??!1,tokenSeparators:e.tokenSeparators??``,optionsFromField:e.optionsFromField??``,quickCreate:e.quickCreate??!1,quickCreateModule:e.quickCreateModule??``,quickCreateLabel:e.quickCreateLabel??``,quickEdit:e.quickEdit??!1,quickEditModule:e.quickEditModule??``,quickEditLabel:e.quickEditLabel??``,quickEditIdFrom:e.quickEditIdFrom??``,quickCreateNotice:{enabled:e.quickCreateNotice?.enabled??!1,title:e.quickCreateNotice?.title??``,message:e.quickCreateNotice?.message??``,showCreator:e.quickCreateNotice?.showCreator!==!1,showRecordName:e.quickCreateNotice?.showRecordName!==!1,recordNameField:e.quickCreateNotice?.recordNameField??``,recordLabel:e.quickCreateNotice?.recordLabel??``,creatorLabel:e.quickCreateNotice?.creatorLabel??``},multiSelect:e.multiSelect??!1,multiple:e.multiple??!1,maxCount:e.maxCount??5,accept:e.accept??`any`,fileKey:e.fileKey??``,fileNameKey:e.fileNameKey??``,fileUrlKey:e.fileUrlKey??``,payloadKey:e.payloadKey??``,prefillFrom:e.prefillFrom??``,prefillAsHint:!!e.prefillAsHint,prefillHintLabel:e.prefillHintLabel??``,prefillFromModule:e.prefillFromModule??``,prefillWhen:Array.isArray(e.prefillWhen)?e.prefillWhen:[],prefillWhenReset:e.prefillWhenReset!==!1,prefillWhenExclusive:e.prefillWhenExclusive===!0,dataType:e.dataType??`auto`,elementType:e.elementType??``,payloadMode:e.payloadMode??`auto`,valueKey:e.valueKey??``,displayKey:e.displayKey??``,defaultValue:e.defaultValue??``,richValue:e.richValue??!1,omitEmpty:e.omitEmpty??!1,payloadTemplate:Cw(e.payloadTemplate),transformRule:Cw(e.transformRule),showIf:e.showIf?.field||e.showIf?.conditions?.length?{field:e.showIf.field??``,operator:e.showIf.operator??`eq`,value:e.showIf.value??``,logic:e.showIf.logic===`or`?`or`:`and`,conditions:Array.isArray(e.showIf.conditions)?e.showIf.conditions.map(e=>({field:e.field??``,operator:e.operator??`eq`,value:e.value??``})):[]}:{field:``,operator:`eq`,value:``,logic:`and`,conditions:[]},labelWhen:e.labelWhen?.field?{field:e.labelWhen.field,operator:e.labelWhen.operator??`eq`,value:e.labelWhen.value??``,label:e.labelWhen.label??``}:{field:``,operator:`eq`,value:``,label:``},colWhenField:(Array.isArray(e.colWhen)?e.colWhen[0]?.field:e.colWhen?.field)??``,colWhenOperator:(Array.isArray(e.colWhen)?e.colWhen[0]?.operator:e.colWhen?.operator)??`eq`,colWhenValue:(Array.isArray(e.colWhen)?e.colWhen[0]?.value:e.colWhen?.value)??``,colWhenCol:(Array.isArray(e.colWhen)?e.colWhen[0]?.col:e.colWhen?.col)??void 0,verifyAction:e.verifyAction??``,verifyResultField:e.verifyResultField??``,verifyTimestampField:e.verifyTimestampField??``,verifyIdleLabel:e.verifyIdleLabel??``,verifyRetryLabel:e.verifyRetryLabel??``,verifySuccessLabel:e.verifySuccessLabel??``,verifyLockedWhenFields:em(e.verifyLockedWhenFields).join(`, `),verifyLockedLabel:e.verifyLockedLabel??``,validations:(e.validations??[]).map(t=>({type:t.type,value:t.type===`unique`?DC(t.value,e):t.value??``,field:t.field??``,message:t.message??``,strict:!!t.strict,minGap:{value:t.minGap?.value??``,unit:t.minGap?.unit??`month`},minGapFrom:t.minGapFrom??``})),validator:{type:e.validator?.type??``,title:e.validator?.title??``,maxLength:e.validator?.maxLength??``,maxChars:e.validator?.maxChars??``},disabledByField:e.disabledByField??``,requiredIfField:e.requiredIfField??``,blockWhileResolving:e.blockWhileResolving??!1,blockScope:e.blockScope??`form`,requiredWhenField:e.requiredWhen?.field??``,requiredWhenOperator:e.requiredWhen?.operator??`eq`,requiredWhenValue:e.requiredWhen?.value??``,requiredWhenMessage:e.requiredWhen?.message??``,overrideEnabled:!!e.overrideCheckbox,overrideLabel:e.overrideCheckbox?.label??``,overrideField:e.overrideCheckbox?.field??``,overrideSkipValidations:Array.isArray(e.overrideCheckbox?.skipValidations)?e.overrideCheckbox.skipValidations.join(`, `):e.overrideCheckbox?.skipValidations??``,overrideConfirmTitle:e.overrideCheckbox?.confirmTitle??``,overrideConfirmBody:e.overrideCheckbox?.confirmBody??``,overrideConfirmOkText:e.overrideCheckbox?.confirmOkText??``,overrideConfirmCancelText:e.overrideCheckbox?.confirmCancelText??``,overrideStore:e.overrideCheckbox?.store!==!1,linkedClearField:Array.isArray(e.linkedClearField)?e.linkedClearField.join(`, `):e.linkedClearField??``,clearGroupOnChange:!!e.clearGroupOnChange,splitDialCodeInto:e.splitDialCodeInto??``,checkDuplicateOnBlur:!!e.checkDuplicateOnBlur,rowHierarchyEnabled:!!e.rowHierarchy,rowHierarchy:e.rowHierarchy??null,autofillFrom:Array.isArray(e.autofillFrom)?JSON.stringify(e.autofillFrom,null,2):e.autofillFrom??``,aiActions:Array.isArray(e.aiActions)?e.aiActions.map(e=>({...e,inputs:(e.inputs??[]).map(e=>({...e,minWords:e.minWords??``})),responseDataPath:e.responseDataPath??``,confirmWhen:e.confirmWhen??`never`,confirmMessages:{title:e.confirmMessages?.title??``,body:e.confirmMessages?.body??``,ok:e.confirmMessages?.ok??``,cancel:e.confirmMessages?.cancel??``},position:e.position??``})):[]}}function Bw(e,t,n,r,i){if(!t||!n||!String(r??``).trim())return``;let a=new Map;i.forEach(e=>{e.moduleName&&a.set(e.moduleName,e)});let o=[`${t}.${r.trim()}`],s=n,c=new Set([t]),l=0;for(;s&&s!==e&&l<10;){if(c.has(s))return``;c.add(s);let e=a.get(s);if(!e||!e.hierarchyLinkField)return o.unshift(s),o.join(` → `);o.unshift(`${e.moduleName}.${e.hierarchyLinkField}`),s=e.hierarchyParent,l+=1}if(s===e)o.unshift(e);else return``;return o.join(` → `)}function Vw(){let[e,t]=(0,s.useState)({});return(0,s.useEffect)(()=>{let e=!1;return n.pi().then(n=>{e||t(n??{})}).catch(()=>{}),()=>{e=!0}},[]),(0,s.useMemo)(()=>t=>e[String(t??``).trim().toLowerCase()]??``,[e])}function Hw({form:e,fieldItems:t,add:r,remove:i,move:a,absBase:o,moduleFieldOptions:s,dragIndexRef:d,dragOverIndex:f,setDragOverIndex:p,onFieldKeySelect:m,expandedFieldKeys:h,onToggleField:g,defaultFieldRules:_=new Map,uniqueTarget:v={primaryModule:``,getTargetModule:()=>``,collectionForModule:()=>``}}){let y=[...o,`fields`];return(0,u.jsxs)(u.Fragment,{children:[t.map(({key:t,name:r,...o},b)=>{let x=[...y,r],S=e.getFieldValue(x)??{},C=h&&!h.has(b),w=e.getFieldValue(`formType`)===`search`;return(0,u.jsx)(`div`,{draggable:!0,onDragStart:()=>{d.current=b},onDragEnd:()=>{d.current=null,p(null)},onDragOver:e=>{e.preventDefault(),p(b)},onDragLeave:()=>p(null),onDrop:e=>{e.preventDefault();let t=d.current;t!==null&&t!==b&&a(t,b),d.current=null,p(null)},className:`fg-field-card${f===b?` fg-drag-over`:``}`,children:(0,u.jsxs)(`div`,{className:`fg-field-card-inner`,children:[(0,u.jsx)(`span`,{className:`fg-drag-handle`,children:(0,u.jsx)(l.HolderOutlined,{})}),C?(0,u.jsxs)(`div`,{className:`fg-field-summary`,children:[(0,u.jsxs)(`button`,{type:`button`,className:`fg-field-summary-main`,onClick:()=>g(b),children:[(0,u.jsx)(l.RightOutlined,{className:`fg-field-summary-chevron`}),(0,u.jsxs)(`span`,{children:[(0,u.jsx)(`strong`,{children:S.label||S.field||`Field ${b+1}`}),(0,u.jsxs)(`small`,{children:[S.field||`Field key not set`,` · `,S.type||`text`]})]})]}),(0,u.jsxs)(c.Space,{size:4,children:[S.req&&(0,u.jsx)(c.Tag,{color:`red`,children:`Required`}),S.show===!1&&(0,u.jsx)(c.Tag,{children:`Hidden`}),(0,u.jsx)(c.Tooltip,{title:`Edit field settings`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>g(b)})}),(0,u.jsx)(c.Tooltip,{title:`Remove field`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,danger:!0,icon:(0,u.jsx)(l.MinusCircleOutlined,{}),onClick:()=>i(r)})})]})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`fg-field-body`,children:[h&&(0,u.jsxs)(`button`,{type:`button`,className:`fg-field-collapse-btn`,onClick:()=>g(b),children:[(0,u.jsx)(l.DownOutlined,{}),` Collapse field`]}),(0,u.jsx)(c.Form.Item,{...o,name:[r,`field`],label:`Field`,style:{marginBottom:10},rules:[{required:!0,message:`Required`}],children:(0,u.jsx)(c.AutoComplete,{options:s,placeholder:`Search or type field key…`,filterOption:(e,t)=>(t?.searchLabel??``).includes(e.toLowerCase()),onSelect:e=>m(e,r),className:`fg-mono-input`})}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,u.jsx)(c.Form.Item,{...o,name:[r,`label`],label:`Label`,style:{marginBottom:8,flex:2},rules:[{required:!0,message:`Required`}],children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`Display label`})}),(0,u.jsx)(c.Form.Item,{...o,name:[r,`type`],label:`Type`,style:{marginBottom:8,flex:2},initialValue:`text`,children:(0,u.jsx)(c.Select,{size:`small`,options:w?[...rw,...iw]:rw})}),(0,u.jsx)(c.Form.Item,{...o,name:[r,`formatter`],label:`Formatter`,style:{marginBottom:8,flex:2},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`name / phone…`})})]}),(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Layout / Combine`}),(0,u.jsxs)(`div`,{className:`fg-options-controls`,style:{flexWrap:`wrap`},children:[(0,u.jsx)(c.Form.Item,{name:[r,`col`],label:`Width`,style:{marginBottom:0},tooltip:`How much of the row this field takes. Blank uses the form's default (half a row on most forms). Use Full row for controls that need the space, such as a keyword chip box.`,children:(0,u.jsx)(c.Select,{size:`small`,allowClear:!0,style:{width:130},placeholder:`Default`,options:sw})}),(0,u.jsx)(c.Form.Item,{name:[r,`combineKey`],label:`Combine Key`,style:{marginBottom:0},tooltip:`Fields with the same key render together as one visual block. Payload stays unchanged.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. client_rate`,style:{width:150},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`combineLabel`],label:`Combined Label`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. Client Rate`,style:{width:160}})}),(0,u.jsx)(c.Form.Item,{name:[r,`combineRole`],label:`Role`,style:{marginBottom:0},children:(0,u.jsx)(c.Select,{size:`small`,style:{width:120},allowClear:!0,options:[{label:`Primary`,value:`primary`},{label:`From`,value:`from`},{label:`To`,value:`to`},{label:`Currency`,value:`currency`},{label:`Unit`,value:`unit`}]})}),(0,u.jsx)(c.Form.Item,{name:[r,`combineToggleLabel`],label:`Toggle Label`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. Range`,style:{width:130}})}),(0,u.jsx)(c.Form.Item,{name:[r,`combineToggleTarget`],label:`Toggle Target`,style:{marginBottom:0},tooltip:`Field key hidden until the combined-field slider is enabled. Example: clientRateTo.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`target field key`,style:{width:150},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`combineWidth`],label:`Width`,style:{marginBottom:0},tooltip:`Width weight of this box inside the combined block. Set the same key's fields to e.g. 2 & 1 for 2:1, or 1/2/3 for 1:2:3. Blank/0 = equal share.`,children:(0,u.jsx)(c.Input,{size:`small`,type:`number`,min:0,step:.5,placeholder:`1`,style:{width:80}})}),(0,u.jsx)(c.Form.Item,{name:[r,`combineWrap`],label:`Wrap`,valuePropName:`checked`,style:{marginBottom:0},tooltip:`Allow this combined block to wrap to another line. Useful for wider controls such as document upload rows.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Yes`,unCheckedChildren:`No`})}),(0,u.jsx)(c.Form.Item,{name:[r,`combineSpan`],label:`Block Span`,style:{marginBottom:0},tooltip:`How much row width this combined block uses. Blank keeps the existing automatic layout.`,children:(0,u.jsx)(c.Select,{size:`small`,allowClear:!0,placeholder:`Auto`,style:{width:110},options:[{label:`Half`,value:12},{label:`Full`,value:24}]})})]})]}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:8},children:({getFieldValue:e})=>{if(e(`formType`)!==`search`||!e(`booleanSearchEnabled`))return null;let t=e([...x,`type`])??`text`,n=e([...x,`booleanApiKey`]),i=ow.includes(t)&&Wh.includes(n);return(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Boolean Search`}),(0,u.jsxs)(`div`,{className:`fg-options-controls`,children:[(0,u.jsx)(c.Form.Item,{name:[r,`booleanApiKey`],label:`Boolean API key`,style:{marginBottom:0},tooltip:`Which boolean-search request parameter this field fills. Needed by plain fields too — without it the field is not sent in Boolean mode.`,children:(0,u.jsx)(c.Select,{size:`small`,allowClear:!0,style:{width:240},placeholder:`Not sent`,options:aw})}),i?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Form.Item,{name:[r,`booleanCapable`],label:`Boolean capable`,valuePropName:`checked`,style:{marginBottom:0},initialValue:!1,tooltip:`When the user turns the Boolean toggle on, this field becomes an AND/OR/NOT expression box. Fields left off keep their normal control in both modes.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Yes`,unCheckedChildren:`No`})}),e([...x,`booleanCapable`])&&(0,u.jsx)(c.Form.Item,{name:[r,`booleanPlaceholder`],label:`Example expression`,style:{marginBottom:0},tooltip:`Shown inside this field's expression box. Give an example using THIS field's own vocabulary — blank falls back to one generic example shared by every boolean field.`,children:(0,u.jsx)(c.Input,{size:`small`,style:{width:360},placeholder:`e.g., (Java OR J2EE) AND "Spring Boot" NOT PHP`})})]}):ow.includes(t)&&(0,u.jsx)(`span`,{className:`fg-options-hint`,children:`Boolean mode belongs to the common Keywords field. Use a Keywords field mapped to the query API key.`})]})]})}}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:8},children:({getFieldValue:e})=>{if(e(`formType`)!==`search`||e([...x,`type`])!==`keywords`)return null;let t=e([...x,`keywordRole`])===`exclude`;return(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Keyword Search`}),(0,u.jsxs)(`div`,{className:`fg-options-controls`,children:[(0,u.jsx)(c.Form.Item,{name:[r,`keywordRole`],label:`Role`,style:{marginBottom:0},initialValue:`include`,tooltip:`Include fields contribute the keywords to match. An Exclude field contributes keywords that must NOT match — point it at another field's group to attach it.`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:200},options:cw})}),(0,u.jsx)(c.Form.Item,{name:[r,`keywordGroup`],label:`Group`,style:{marginBottom:0},tooltip:`Which keyword group this field feeds. Two fields naming the same group are merged into one — that is how an Exclude box attaches to its Keywords box. Blank uses the field's own key.`,children:(0,u.jsx)(c.Input,{size:`small`,style:{width:200},placeholder:`same as field key`})}),(0,u.jsx)(c.Form.Item,{name:[r,`keywordFields`],label:`Search in fields`,style:{marginBottom:0},tooltip:`Comma-separated database paths this field's keywords match against, e.g. skills or currentLocation, projectLocation. Leave blank to search the entire resume (every configured search field).`,children:(0,u.jsx)(c.Input,{size:`small`,style:{width:320},placeholder:`blank = entire resume`})}),!t&&(0,u.jsx)(c.Form.Item,{name:[r,`showMandatoryOption`],label:`Mandatory star`,valuePropName:`checked`,style:{marginBottom:0},initialValue:!1,tooltip:`Shows a star on every keyword chip and a 'Mark all keywords as mandatory' checkbox below the box. Starred keywords must all match; unstarred ones only need one match between them. Off means plain chips.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Yes`,unCheckedChildren:`No`})}),(0,u.jsx)(c.Form.Item,{name:[r,`isPrimaryKeyword`],label:`Primary (owns Boolean)`,valuePropName:`checked`,style:{marginBottom:0},initialValue:!1,tooltip:`The one field that draws the Boolean toggle and becomes the AND/OR/NOT expression box. Set this on exactly one field per form — without it the form shows no Boolean toggle at all.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Yes`,unCheckedChildren:`No`})}),(0,u.jsx)(c.Form.Item,{name:[r,`maxKeywords`],label:`Max keywords`,style:{marginBottom:0},tooltip:`How many chips this box accepts. Blank means 50.`,children:(0,u.jsx)(c.InputNumber,{size:`small`,min:1,style:{width:110},placeholder:`50`})}),t&&(0,u.jsx)(`span`,{className:`fg-options-hint`,children:`Exclude fields never show stars — a mandatory exclusion has no meaning.`})]})]})}}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:8},children:({getFieldValue:e})=>e(`formType`)!==`search`||!e(`booleanSearchEnabled`)?null:(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Boolean Mode`}),(0,u.jsx)(`div`,{className:`fg-options-controls`,children:(0,u.jsx)(c.Form.Item,{name:[r,`hideInBooleanMode`],label:`Hide when Boolean is on`,valuePropName:`checked`,style:{marginBottom:0},initialValue:!1,tooltip:`Removes this field from the form while the Boolean toggle is on, and stops it being submitted. Use it for controls the expression already covers.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Yes`,unCheckedChildren:`No`})})})]})}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:8},children:({getFieldValue:e})=>e(`formType`)!==`search`||e([...x,`type`])!==`checkbox`?null:(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Select All`}),(0,u.jsx)(`div`,{className:`fg-options-controls`,children:(0,u.jsx)(c.Form.Item,{name:[r,`hideSelectAll`],label:`Show 'All' checkbox`,valuePropName:`checked`,style:{marginBottom:0},initialValue:!1,getValueProps:e=>({checked:!e}),normalize:e=>!e,tooltip:`On by default. Turn off if this field's options should never offer a select-everything shortcut.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Shown`,unCheckedChildren:`Hidden`})})})]})}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:8},children:({getFieldValue:e})=>{let t=e([...x,`type`]);return[`range`,`number`].includes(t)?(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:t===`range`?`Range`:`Bounds`}),(0,u.jsxs)(`div`,{className:`fg-options-controls`,children:[(0,u.jsx)(c.Form.Item,{name:[r,`min`],label:`Min`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,type:`number`,placeholder:`0`,style:{width:90}})}),(0,u.jsx)(c.Form.Item,{name:[r,`max`],label:`Max`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,type:`number`,placeholder:`30`,style:{width:90}})}),t===`range`&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Form.Item,{name:[r,`defaultRange`],label:`Default`,style:{marginBottom:0},tooltip:`Full span means the From/To boxes arrive holding Min and Max, and that range is applied to every search — records with no value for this field will not appear until the user changes it. None starts the field empty and filters nothing.`,children:(0,u.jsx)(c.Select,{size:`small`,allowClear:!0,style:{width:170},placeholder:`None`,options:tw})}),(0,u.jsx)(c.Form.Item,{name:[r,`display`],label:`Show as`,style:{marginBottom:0},initialValue:`both`,tooltip:`Drag bar, plain From/To boxes, or both. Switch to From / To if the horizontal slider is not wanted.`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:170},options:lw})}),(0,u.jsx)(c.Form.Item,{name:[r,`minLabel`],label:`Start label`,style:{marginBottom:0},tooltip:`What the LOW end reads as under the track. Blank shows the Min number itself.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`0`,style:{width:110}})}),(0,u.jsx)(c.Form.Item,{name:[r,`maxLabel`],label:`End label`,style:{marginBottom:0},tooltip:`What the HIGH end reads as under the track. Use it to mark an open ceiling: with Max 30, "30+" reads as "30 or more" where a bare 30 reads as an exact value. Blank shows the Max number itself.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`30+`,style:{width:110}})}),(0,u.jsx)(c.Form.Item,{name:[r,`unit`],label:`Unit`,style:{marginBottom:0},tooltip:`Caption shown after the From / To boxes, e.g. Years. Leave blank when the field label already names the unit.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`Years`,style:{width:110}})}),(0,u.jsx)(c.Form.Item,{name:[r,`rangeKeys`],label:`From / To params`,style:{marginBottom:0},tooltip:`Comma-separated query params this range fills in normal search, e.g. experienceFrom,experienceTo. Blank uses <field>From / <field>To.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`experienceFrom,experienceTo`,style:{width:220},className:`fg-mono-input`})})]})]})]}):null}}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:8},children:({getFieldValue:e})=>e([...x,`type`])===`daterangePreset`?(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Date Filter`}),(0,u.jsxs)(`div`,{className:`fg-options-controls`,children:[(0,u.jsx)(c.Form.Item,{name:[r,`filterField`],label:`Filter Field`,style:{marginBottom:0},tooltip:`Mongo field this range filters on, e.g. createdAt. Blank uses the field's own key. Normal search only — in Boolean mode the range is sent via the Boolean API key instead (createdFrom + createdTo), which the boolean-search API accepts but does not filter on yet.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`createdAt`,style:{width:200},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`defaultPreset`],label:`Default`,style:{marginBottom:0},tooltip:`Which preset the field arrives on. This is a REAL value — it is applied to every search, not just shown, so records outside the window will not appear until the user changes it. Blank means the field starts empty and filters nothing.`,children:(0,u.jsx)(c.Select,{size:`small`,allowClear:!0,style:{width:190},placeholder:`None`,options:ew})})]})]}):null}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:8},children:({getFieldValue:e})=>{if(e([...x,`type`])!==`file`)return null;let t=e([...x,`multiple`]);return(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`File Options`}),(0,u.jsxs)(`div`,{className:`fg-options-controls`,children:[(0,u.jsx)(c.Form.Item,{name:[r,`accept`],label:`Allowed Content`,style:{marginBottom:0},initialValue:`any`,tooltip:`Restrict what this upload accepts. A file outside the selected category is rejected on upload. Overrides the 'File types allowed' validation rule.`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:230},options:n.Mt})}),(0,u.jsx)(c.Form.Item,{name:[r,`multiple`],label:`Upload Mode`,valuePropName:`checked`,style:{marginBottom:0},initialValue:!1,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Multiple`,unCheckedChildren:`Single`})}),t&&(0,u.jsx)(c.Form.Item,{name:[r,`maxCount`],label:`Max files`,style:{marginBottom:0},initialValue:5,rules:[{required:!0,message:`Required`}],children:(0,u.jsx)(c.Input,{size:`small`,type:`number`,min:2,placeholder:`e.g. 5`,style:{width:80}})}),(0,u.jsx)(c.Form.Item,{name:[r,`fileKey`],label:`File Key`,style:{marginBottom:0},tooltip:`Multipart field name sent to the server. Leave blank to use the field key. Set to 'file' for the jobs service.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. file`,style:{width:120},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`fileNameKey`],label:`Name Key`,style:{marginBottom:0},tooltip:`Stored object key that contains the uploaded file name. Leave blank for automatic detection.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. passportUploadName`,style:{width:180},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`fileUrlKey`],label:`URL Key`,style:{marginBottom:0},tooltip:`Stored object key that contains the file location/path. Leave blank for automatic detection.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. passportCopyLocation`,style:{width:190},className:`fg-mono-input`})})]})]})}}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:8},children:({getFieldValue:e})=>{let t=e([...x,`type`]);if(![`select`,`radio`,`checkbox`,`location`].includes(t))return null;let i=t===`location`,a=e([...x,`dataSource`])??`static`;return(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:i?`Location selection`:`Options / Values`}),(0,u.jsxs)(`div`,{className:`fg-options-controls`,children:[!i&&(0,u.jsx)(c.Form.Item,{name:[r,`dataSource`],label:`Source`,style:{marginBottom:0},initialValue:`static`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:190},options:uw})}),(t===`select`||i)&&(0,u.jsx)(c.Form.Item,{name:[r,`multiSelect`],label:`Multi Select`,valuePropName:`checked`,style:{marginBottom:0},initialValue:!1,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Multi`,unCheckedChildren:`Single`})}),a===`master`&&(0,u.jsx)(c.Form.Item,{name:[r,`masterName`],label:`Master Name`,style:{marginBottom:0},rules:[{required:!0,message:`Enter master name`}],children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. tracker`,style:{width:140}})}),a===`group`&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Form.Item,{name:[r,`groupName`],label:`Group Name`,style:{marginBottom:0},rules:[{required:!0,message:`Enter group name`}],children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. users`,style:{width:140}})}),String(e([...x,`groupName`])??``).toLowerCase().trim()===`users`&&(0,u.jsx)(c.Form.Item,{name:[r,`groupRoleContains`],label:`Only roles containing`,style:{marginBottom:0},tooltip:`List only users whose role name CONTAINS this word (case-insensitive) — e.g. 'manager' matches Delivery Manager, Onboarding Manager, Submission Manager, etc. Blank = every user.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. manager`,style:{width:160}})})]}),a===`locationMaster`&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Form.Item,{name:[r,`locationLevel`],label:`Level`,style:{marginBottom:0},initialValue:`country`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:220},options:dw})}),[`state`,`city`].includes(e([...x,`locationLevel`]))&&(0,u.jsx)(c.Form.Item,{name:[r,`locationCountryFrom`],label:`Country field`,style:{marginBottom:0},rules:[{required:!0,message:`Pick the Country field`}],tooltip:`The sibling field on this form that holds the selected country. This field's options are filtered to that country's states/cities and it stays disabled until that field has a value.`,children:(0,u.jsx)(c.AutoComplete,{size:`small`,style:{width:220},placeholder:`e.g. address.country`,options:(e(y)??[]).map((e,t)=>({candidate:e,index:t})).filter(({candidate:e,index:t})=>t!==r&&e?.field).map(({candidate:e})=>({value:e.field,label:`${e.label||e.field} (${e.field})`})),filterOption:(e,t)=>String(t?.label??``).toLowerCase().includes(String(e).toLowerCase()),getPopupContainer:()=>document.body})}),e([...x,`locationLevel`])===`city`&&(0,u.jsx)(c.Form.Item,{name:[r,`locationStateFrom`],label:`State field`,style:{marginBottom:0},rules:[{required:!0,message:`Pick the State field`}],tooltip:`The sibling field on this form that holds the selected state.`,children:(0,u.jsx)(c.AutoComplete,{size:`small`,style:{width:220},placeholder:`e.g. address.state`,options:(e(y)??[]).map((e,t)=>({candidate:e,index:t})).filter(({candidate:e,index:t})=>t!==r&&e?.field).map(({candidate:e})=>({value:e.field,label:`${e.label||e.field} (${e.field})`})),filterOption:(e,t)=>String(t?.label??``).toLowerCase().includes(String(e).toLowerCase()),getPopupContainer:()=>document.body})})]})]}),!i&&(0,u.jsxs)(`div`,{className:`fg-options-controls`,style:{marginTop:8,flexWrap:`wrap`},children:[(0,u.jsx)(c.Form.Item,{name:[r,`allowCustomValues`],label:`Allow typed values`,valuePropName:`checked`,style:{marginBottom:0},initialValue:!1,tooltip:`Let users enter a value that is not in the option list above. The typed text is stored as-is.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Typed OK`,unCheckedChildren:`List only`})}),e([...x,`allowCustomValues`])&&(0,u.jsx)(c.Form.Item,{name:[r,`tokenSeparators`],label:`Token separators`,style:{marginBottom:0},tooltip:`Characters that finish the typed entry and start a new one. Default is a comma, so 'React,Node' becomes two values. Leave blank to require Enter.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`,`,style:{width:90},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`optionsFromField`],label:`Restrict options to field`,style:{marginBottom:0},tooltip:`Show only the options whose value matches the current value of ANOTHER field on this form. Blank = show every option. Example: point a rate-unit picker at the job's unit field so a recruiter cannot switch units.`,children:(0,u.jsx)(c.AutoComplete,{size:`small`,style:{width:230},placeholder:`blank = all options`,options:(e(y)??[]).map((e,t)=>({candidate:e,index:t})).filter(({candidate:e,index:t})=>t!==r&&e?.field).map(({candidate:e})=>({value:e.field,label:`${e.label||e.field} (${e.field})`})),filterOption:(e,t)=>String(t?.label??``).toLowerCase().includes(String(e).toLowerCase()),getPopupContainer:()=>document.body})})]}),!i&&a===`static`&&(0,u.jsxs)(`div`,{className:`fg-static-options`,children:[(0,u.jsx)(`span`,{className:`fg-static-options-hint`,children:`Label / Value pairs`}),[`checkbox`,`radio`].includes(t)&&e(`formType`)===`search`&&(0,u.jsx)(`p`,{className:`fg-source-hint`,style:{marginBottom:6},children:`Locked options are pre-selected and cannot be unchecked by the user. Module lets one option answer from a different module, so its results tab gets that module's own columns and row actions.`}),(0,u.jsx)(c.Form.List,{name:[r,`options`],children:(n,{add:r,remove:i})=>(0,u.jsxs)(u.Fragment,{children:[n.map(({key:n,name:r})=>(0,u.jsxs)(`div`,{className:`fg-option-row`,children:[(0,u.jsx)(c.Form.Item,{name:[r,`label`],style:{marginBottom:0,flex:1},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`Label`})}),(0,u.jsx)(c.Form.Item,{name:[r,`value`],style:{marginBottom:0,flex:1},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`Value`,className:`fg-mono-input`})}),[`checkbox`,`radio`].includes(t)&&e(`formType`)===`search`&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Form.Item,{name:[r,`module`],style:{marginBottom:0,flex:1},tooltip:`Module key this option's results tab is served by, e.g. dice. The tab then gets that module's own columns and row actions instead of the form's. Blank = use the form's module.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`Module (optional)`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`locked`],valuePropName:`checked`,style:{marginBottom:0},tooltip:`Pre-selected on load and cannot be unchecked.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Locked`,unCheckedChildren:`Free`})})]}),(0,u.jsx)(l.MinusCircleOutlined,{onClick:()=>i(r),className:`fg-remove-icon`})]},n)),(0,u.jsx)(c.Button,{size:`small`,type:`dashed`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>r({label:``,value:``}),className:`fg-add-option-btn`,children:`Add Option`})]})})]}),a===`module`&&(0,u.jsx)(`p`,{className:`fg-source-hint`,children:`Options fetched from the module's distinct field values at runtime.`}),a===`group`&&(0,u.jsx)(`p`,{className:`fg-source-hint`,children:`Use "users" to load all users from the MongoDB-backed user collection.`}),a===`lookup`&&(0,u.jsxs)(`div`,{className:`fg-lookup-block`,children:[(0,u.jsx)(`p`,{className:`fg-source-hint`,style:{marginBottom:8},children:`Cross-collection lookup — shows label, stores FK value.`}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,u.jsx)(c.Form.Item,{name:[r,`lookupCollection`],label:`Collection`,style:{marginBottom:0,flex:1},rules:[{required:!0,message:`Required`}],children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. vendors`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`displayField`],label:`Display Field`,style:{marginBottom:0,flex:1},rules:[{required:!0,message:`Required`}],children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. vendorContact.firstName`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`displayField2`],label:`Display Field 2`,style:{marginBottom:0,flex:1},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. vendorContact.lastName`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`valueField`],label:`Value Field (FK)`,style:{marginBottom:0,flex:1},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`_id`,className:`fg-mono-input`})})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:8},children:[(0,u.jsx)(c.Form.Item,{name:[r,`lookupFilterField`],label:`Filter Field`,style:{marginBottom:0,flex:1},tooltip:`Optional DB field to filter lookup rows by. Example: _id or clientId.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. _id`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`lookupFilterValueFrom`],label:`Filter Value From`,style:{marginBottom:0,flex:1},tooltip:`Optional form/scope field that provides the filter value. Example: clientId.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. clientId`,className:`fg-mono-input`})})]}),(0,u.jsxs)(`div`,{className:`fg-lookup-conditions`,style:{marginTop:12},children:[(0,u.jsxs)(`p`,{className:`fg-source-hint`,style:{marginBottom:6},children:[(0,u.jsx)(`b`,{children:`Dropdown conditions`}),` — every condition must match (AND). Evaluated on the server, so they restrict the data, not just the UI.`]}),(0,u.jsx)(c.Form.List,{name:[r,`lookupFilters`],children:(e,{add:t,remove:n})=>(0,u.jsxs)(u.Fragment,{children:[e.map(({key:e,name:t,...i})=>(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginBottom:8,alignItems:`flex-end`,flexWrap:`wrap`},children:[(0,u.jsx)(c.Form.Item,{...i,name:[t,`field`],label:`Field`,style:{marginBottom:0,flex:1,minWidth:140},tooltip:`Field on the lookup collection to test. Example: roleId, legacyUserId.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. roleId`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{...i,name:[t,`op`],label:`Operator`,style:{marginBottom:0,width:130},initialValue:`eq`,children:(0,u.jsx)(c.Select,{size:`small`,options:Tw})}),(0,u.jsx)(c.Form.Item,{...i,name:[t,`valueSource`],label:`Value from`,style:{marginBottom:0,width:160},initialValue:`literal`,tooltip:`Literal = a fixed value. Signed-in user = resolved from the auth token on the server. Another collection = a sub-query supplying the values.`,children:(0,u.jsx)(c.Select,{size:`small`,options:[{label:`Literal value`,value:`literal`},{label:`Signed-in user`,value:`identity`},{label:`Another collection`,value:`collection`}]})}),(0,u.jsx)(c.Form.Item,{noStyle:!0,shouldUpdate:!0,children:({getFieldValue:e})=>{let n=[`fields`,r,`lookupFilters`,t],a=e([...n,`op`])??`eq`;if(a===`notEmpty`||a===`empty`)return(0,u.jsx)(`span`,{className:`fg-source-hint`,style:{flex:1},children:`No value needed.`});let o=e([...n,`valueSource`])??`literal`;return o===`identity`?(0,u.jsx)(c.Form.Item,{...i,name:[t,`valueFrom`],label:`Identity`,style:{marginBottom:0,flex:1,minWidth:170},children:(0,u.jsx)(c.Select,{size:`small`,showSearch:!0,placeholder:`currentUserId`,options:Ew.map(e=>({label:e,value:e}))})}):o===`collection`?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Form.Item,{...i,name:[t,`srcCollection`],label:`Collection`,style:{marginBottom:0,flex:1,minWidth:120},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. roles`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{...i,name:[t,`srcValueField`],label:`Value field`,style:{marginBottom:0,flex:1,minWidth:120},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`_id`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{...i,name:[t,`srcMatchField`],label:`Where field`,style:{marginBottom:0,flex:1,minWidth:120},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. roleName`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{...i,name:[t,`srcMatchValue`],label:`Equals`,style:{marginBottom:0,flex:1,minWidth:120},tooltip:`Fixed value. Comma-separate for a list. Ignored when an Identity is chosen next to it.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. RECRUITER`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{...i,name:[t,`srcMatchValueFrom`],label:`…or identity`,style:{marginBottom:0,flex:1,minWidth:150},tooltip:`Match against the signed-in user instead of a fixed value — resolved on the server.`,children:(0,u.jsx)(c.Select,{size:`small`,allowClear:!0,placeholder:`none`,options:Ew.map(e=>({label:e,value:e}))})}),(0,u.jsx)(c.Form.Item,{...i,name:[t,`srcRecursive`],valuePropName:`checked`,style:{marginBottom:0},tooltip:`Keep following the chain outward — e.g. a reporting tree, so the whole downline is included and not just direct reports.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Chain`,unCheckedChildren:`Direct`})})]}):(0,u.jsx)(c.Form.Item,{...i,name:[t,`value`],label:`Value`,style:{marginBottom:0,flex:1,minWidth:150},tooltip:`Comma-separate for a list.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. Active`,className:`fg-mono-input`})})}}),(0,u.jsx)(c.Button,{size:`small`,danger:!0,type:`text`,onClick:()=>n(t),children:`Remove`})]},e)),(0,u.jsx)(c.Button,{size:`small`,type:`dashed`,onClick:()=>t({op:`eq`,valueSource:`literal`}),children:`+ Add condition`})]})})]}),(0,u.jsxs)(`div`,{className:`fg-lookup-row-filters`,style:{marginTop:12},children:[(0,u.jsxs)(`p`,{className:`fg-source-hint`,style:{marginBottom:6},children:[(0,u.jsx)(`b`,{children:`Option filters (in-browser)`}),` — narrow the returned options by a value on each record, and/or to the signed-in user's reporting line.`]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{alignItems:`flex-end`},children:[(0,u.jsx)(c.Form.Item,{name:[r,`optionsRequireExtraField`],label:`Match Field`,style:{marginBottom:0,flex:1},tooltip:`Field on the looked-up record to test, e.g. roleId. Left empty, no value filter is applied.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. roleId`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`optionsRequireExtraValue`],label:`Match Value(s)`,style:{marginBottom:0,flex:1},tooltip:`Allowed value, or several separated by commas (e.g. 10, 13). Empty means the field must be exactly true.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`empty = must be true`,className:`fg-mono-input`})})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:8,alignItems:`flex-end`},children:[(0,u.jsx)(c.Form.Item,{name:[r,`optionsHierarchyParentField`],label:`Reports-To Field`,style:{marginBottom:0,flex:1},tooltip:`Field holding each record's parent id, in the same id space as the Value Field (e.g. reportingId). Set it to show only people below the signed-in user — directly or through any number of levels. The signed-in user is not listed.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. reportingId`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`optionsHierarchySelfFrom`],label:`Whose Line`,style:{marginBottom:0,flex:1},tooltip:`Whose reporting line to keep. Defaults to the signed-in user.`,children:(0,u.jsx)(c.Select,{size:`small`,allowClear:!0,placeholder:`currentUserId`,options:[{label:`Signed-in user (currentUserId)`,value:`currentUserId`}]})})]})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:8,alignItems:`flex-end`},children:[(0,u.jsx)(c.Form.Item,{name:[r,`quickCreate`],valuePropName:`checked`,style:{marginBottom:0},tooltip:`Adds a button inside this dropdown so someone can create a new record without leaving the form. When they save, it is selected here automatically.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Add button`,unCheckedChildren:`No add`})}),(0,u.jsx)(c.Form.Item,{name:[r,`quickCreateModule`],label:`What it creates`,style:{marginBottom:0,flex:1},tooltip:`Which list the new record is added to. Leave blank to use the Collection set above.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`same as Collection above`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`quickEdit`],valuePropName:`checked`,style:{marginBottom:0},tooltip:`Adds a button so someone can edit the record they have selected, without leaving the form.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Edit button`,unCheckedChildren:`No edit`})}),(0,u.jsx)(c.Form.Item,{name:[r,`quickEditModule`],label:`What it edits`,style:{marginBottom:0,flex:1},tooltip:`Which list the edited record belongs to. Leave blank to use the Collection set above.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`same as Collection above`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`quickEditIdFrom`],label:`Edit which record`,style:{marginBottom:0,flex:1},tooltip:`Normally the record chosen in THIS box. If the thing to edit is chosen in a different box, name that box here — e.g. a recruiter row that should edit its employer names employerId.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. employerId`,className:`fg-mono-input`})})]}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:0},children:({getFieldValue:e})=>{let t=e([...x,`quickCreateModule`])||e([...x,`lookupCollection`])||``,i=e([...x,`quickEditModule`])||e([...x,`lookupCollection`])||``;return(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:8,alignItems:`flex-end`},children:[(0,u.jsx)(c.Form.Item,{name:[r,`quickCreateLabel`],label:`Add button wording`,style:{marginBottom:0,flex:1},tooltip:`Leave blank and the button names what it adds, worked out from the list above. Only type something here if you want different wording.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:n.At({quickCreateModule:t},t)})}),(0,u.jsx)(c.Form.Item,{name:[r,`quickEditLabel`],label:`Edit button wording`,style:{marginBottom:0,flex:1},tooltip:`Leave blank and the button names what it edits. The popup heading matches the button, so the two always agree.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:n.jt({quickEditModule:i},i)})})]})}}),(0,u.jsx)(`p`,{className:`fg-source-hint`,style:{marginTop:4},children:`Leave both blank unless you need different wording. The buttons name the thing they act on — "Add New Employer", "Edit Employer" — instead of a vague "Add More", and the popup heading matches the button that opened it.`}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:8,alignItems:`flex-end`},children:[(0,u.jsx)(c.Form.Item,{name:[r,`quickCreateNotice`,`enabled`],valuePropName:`checked`,style:{marginBottom:0},tooltip:`Show a popup right after a record is created here, warning that it still needs an Organization Admin to configure forms, workflows and permissions.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Notice`,unCheckedChildren:`No Notice`})}),(0,u.jsx)(c.Form.Item,{name:[r,`quickCreateNotice`,`title`],label:`Notice Title`,style:{marginBottom:0,flex:1},tooltip:`Popup title. Default: New record created.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`New record created`})}),(0,u.jsx)(c.Form.Item,{name:[r,`quickCreateNotice`,`recordNameField`],label:`Name Field`,style:{marginBottom:0,flex:1},tooltip:`Key on the created record holding its display name. Empty = the Display Field above, then any name-like key.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`defaults to Display Field`,className:`fg-mono-input`})})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:8,alignItems:`flex-end`},children:[(0,u.jsx)(c.Form.Item,{name:[r,`quickCreateNotice`,`showRecordName`],valuePropName:`checked`,style:{marginBottom:0},tooltip:`Show the created record's name in the popup.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Name`,unCheckedChildren:`No Name`})}),(0,u.jsx)(c.Form.Item,{name:[r,`quickCreateNotice`,`recordLabel`],label:`Name Label`,style:{marginBottom:0,flex:1},tooltip:`Label for the record-name line, e.g. Client name. Default: Record name.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`Record name`})}),(0,u.jsx)(c.Form.Item,{name:[r,`quickCreateNotice`,`showCreator`],valuePropName:`checked`,style:{marginBottom:0},tooltip:`Show who created the record.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Creator`,unCheckedChildren:`No Creator`})}),(0,u.jsx)(c.Form.Item,{name:[r,`quickCreateNotice`,`creatorLabel`],label:`Creator Label`,style:{marginBottom:0,flex:1},tooltip:`Label for the creator line. Default: Created by.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`Created by`})})]}),(0,u.jsx)(c.Form.Item,{name:[r,`quickCreateNotice`,`message`],label:`Notice Message`,style:{marginTop:8,marginBottom:0},tooltip:`Leave empty to use the standard wording asking the recruiter to contact their Organization Admin before proceeding.`,children:(0,u.jsx)(c.Input.TextArea,{size:`small`,rows:3,placeholder:`Leave empty for the standard message`})})]})]})}}),(0,u.jsxs)(`div`,{className:`fg-toggles-row`,children:[(()=>{let e=_.get(S.field),t=e?.locked===!0,n=e?.forceShow===!0,i=e?.forceReq===!0,a=e=>t?`Locked by Default Fields${e?` — always ${e}`:``}`:void 0;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Form.Item,{...o,name:[r,`show`],valuePropName:`checked`,style:{marginBottom:0},initialValue:!0,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Show`,unCheckedChildren:`Hide`,checked:n?!0:void 0,disabled:t,title:a(n?`shown`:``)})}),(0,u.jsx)(c.Form.Item,{...o,name:[r,`req`],valuePropName:`checked`,style:{marginBottom:0},initialValue:!1,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Req`,unCheckedChildren:`Opt`,checked:i?!0:void 0,disabled:t,title:a(i?`required`:``)})})]})})(),(0,u.jsx)(c.Form.Item,{...o,name:[r,`showOnAdd`],valuePropName:`checked`,style:{marginBottom:0},initialValue:!0,tooltip:`Show this field on Add. Turn off for edit-only fields.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Add`,unCheckedChildren:`No Add`})}),(0,u.jsx)(c.Form.Item,{...o,name:[r,`edit`],valuePropName:`checked`,style:{marginBottom:0},initialValue:!0,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Edit`,unCheckedChildren:`Read`})}),(0,u.jsx)(c.Form.Item,{...o,name:[r,`addRow`],valuePropName:`checked`,style:{marginBottom:0},initialValue:!1,tooltip:`Let users repeat this single field (add/remove multiple values). Ignored when this field's group is itself Add Row.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Repeat`,unCheckedChildren:`Single`})}),(0,u.jsx)(c.Form.Item,{...o,name:[r,`clientScope`],valuePropName:`checked`,style:{marginBottom:0},initialValue:!1,tooltip:`Use this field as the client-selector gate. It shows as the top 'Select Client' picker and is hidden from the form body (no duplicate client card).`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Client Gate`,unCheckedChildren:`Client Gate`})}),(0,u.jsx)(c.Form.Item,{...o,name:[r,`infoEnabled`],valuePropName:`checked`,style:{marginBottom:0},initialValue:!1,tooltip:`Show an info icon next to this field label in add/edit forms.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Info`,unCheckedChildren:`Info`})})]}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:8},children:({getFieldValue:e})=>e([...x,`addRow`])?(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Repeat Field Options`}),(0,u.jsxs)(`div`,{className:`fg-options-controls`,style:{flexWrap:`wrap`},children:[(0,u.jsx)(c.Form.Item,{name:[r,`minRows`],label:`Min Values`,style:{marginBottom:0},tooltip:`Minimum values the user must keep. Delete is disabled at this count.`,children:(0,u.jsx)(c.Input,{size:`small`,type:`number`,min:0,placeholder:`0`,style:{width:90}})}),(0,u.jsx)(c.Form.Item,{name:[r,`initialRows`],label:`Initial Values`,style:{marginBottom:0},tooltip:`How many empty inputs to show on a fresh Add (0 = show only the + button).`,children:(0,u.jsx)(c.Input,{size:`small`,type:`number`,min:0,placeholder:`1`,style:{width:90}})}),(0,u.jsx)(c.Form.Item,{name:[r,`maxRows`],label:`Max Values`,style:{marginBottom:0},tooltip:`Maximum values allowed. The + button hides at this count. Blank = unlimited.`,children:(0,u.jsx)(c.Input,{size:`small`,type:`number`,min:0,placeholder:`∞`,style:{width:90}})}),(0,u.jsx)(c.Form.Item,{name:[r,`addLabel`],label:`Add Button Label`,style:{marginBottom:0},tooltip:`Custom text for the add button. Defaults to 'Add <label>'.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. Add Skill`,style:{width:170}})})]}),(0,u.jsxs)(`div`,{className:`fg-subfields-block`,style:{marginTop:10},children:[(0,u.jsxs)(`span`,{className:`fg-options-label`,children:[`Sub-fields (repeat a group together)`,(0,u.jsx)(`span`,{className:`fg-field-key-hint`,style:{marginLeft:6},children:`leave empty to repeat a single value`})]}),(0,u.jsx)(c.Form.List,{name:[r,`subFields`],children:(t,{add:n,remove:r})=>(0,u.jsxs)(`div`,{children:[t.map(({key:t,name:n,...i})=>(0,u.jsxs)(`div`,{className:`fg-subfield-row`,style:{marginBottom:10},children:[(0,u.jsxs)(`div`,{className:`fg-inline-row`,style:{flexWrap:`wrap`,alignItems:`flex-end`},children:[(0,u.jsx)(c.Form.Item,{...i,name:[n,`field`],label:`Key`,rules:[{required:!0,message:`Key`},{pattern:/^[a-zA-Z0-9_]+$/,message:`a-z 0-9 _`}],style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. question`,style:{width:140},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{...i,name:[n,`label`],label:`Label`,rules:[{required:!0,message:`Label`}],style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. Question`,style:{width:150}})}),(0,u.jsx)(c.Form.Item,{...i,name:[n,`type`],label:`Type`,initialValue:`text`,style:{marginBottom:0},children:(0,u.jsx)(c.Select,{size:`small`,options:rw,style:{width:130}})}),(0,u.jsx)(c.Form.Item,{...i,name:[n,`req`],label:`Required`,valuePropName:`checked`,initialValue:!1,style:{marginBottom:0},children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Yes`,unCheckedChildren:`No`})}),(0,u.jsx)(c.Form.Item,{...i,name:[n,`col`],label:`Width`,tooltip:`Grid span: 12 = half row, 24 = full row. Blank = 12.`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,type:`number`,placeholder:`12`,style:{width:70}})}),(0,u.jsx)(c.Tooltip,{title:`Remove sub-field`,children:(0,u.jsx)(`button`,{type:`button`,className:`fg-field-remove-btn`,onClick:()=>r(n),"aria-label":`Remove sub-field`,children:(0,u.jsx)(l.MinusCircleOutlined,{})})})]}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:0},children:()=>{let t=e([...x,`subFields`,n,`type`]);if(![`select`,`radio`,`checkbox`].includes(t))return null;let r=e([...x,`subFields`,n,`dataSource`])??`static`;return(0,u.jsxs)(`div`,{className:`fg-options-block`,style:{marginTop:6},children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Options / Values`}),(0,u.jsxs)(`div`,{className:`fg-options-controls`,children:[(0,u.jsx)(c.Form.Item,{name:[n,`dataSource`],label:`Source`,style:{marginBottom:0},initialValue:`static`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:190},options:uw})}),t===`select`&&(0,u.jsx)(c.Form.Item,{name:[n,`multiSelect`],label:`Multi Select`,valuePropName:`checked`,style:{marginBottom:0},initialValue:!1,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Multi`,unCheckedChildren:`Single`})}),r===`master`&&(0,u.jsx)(c.Form.Item,{name:[n,`masterName`],label:`Master Name`,style:{marginBottom:0},rules:[{required:!0,message:`Enter master name`}],children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. tracker`,style:{width:140}})}),r===`group`&&(0,u.jsx)(c.Form.Item,{name:[n,`groupName`],label:`Group Name`,style:{marginBottom:0},rules:[{required:!0,message:`Enter group name`}],children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. users`,style:{width:140}})})]}),r===`static`&&(0,u.jsxs)(`div`,{className:`fg-static-options`,children:[(0,u.jsx)(`span`,{className:`fg-static-options-hint`,children:`Label / Value pairs`}),(0,u.jsx)(c.Form.List,{name:[n,`options`],children:(e,{add:t,remove:n})=>(0,u.jsxs)(u.Fragment,{children:[e.map(({key:e,name:t})=>(0,u.jsxs)(`div`,{className:`fg-option-row`,children:[(0,u.jsx)(c.Form.Item,{name:[t,`label`],style:{marginBottom:0,flex:1},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`Label`})}),(0,u.jsx)(c.Form.Item,{name:[t,`value`],style:{marginBottom:0,flex:1},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`Value`,className:`fg-mono-input`})}),(0,u.jsx)(l.MinusCircleOutlined,{onClick:()=>n(t),className:`fg-remove-icon`})]},e)),(0,u.jsx)(c.Button,{size:`small`,type:`dashed`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>t({label:``,value:``}),className:`fg-add-option-btn`,children:`Add Option`})]})})]}),r===`group`&&(0,u.jsx)(`p`,{className:`fg-source-hint`,children:`Use "users" to load all users from the MongoDB-backed user collection.`}),r===`lookup`&&(0,u.jsxs)(`div`,{className:`fg-lookup-block`,children:[(0,u.jsx)(`p`,{className:`fg-source-hint`,style:{marginBottom:8},children:`Cross-collection lookup — shows label, stores FK value.`}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,u.jsx)(c.Form.Item,{name:[n,`lookupCollection`],label:`Collection`,style:{marginBottom:0,flex:1},rules:[{required:!0,message:`Required`}],children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. vendors`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[n,`displayField`],label:`Display Field`,style:{marginBottom:0,flex:1},rules:[{required:!0,message:`Required`}],children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. vendorContact.firstName`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[n,`displayField2`],label:`Display Field 2`,style:{marginBottom:0,flex:1},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. vendorContact.lastName`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[n,`valueField`],label:`Value Field (FK)`,style:{marginBottom:0,flex:1},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`_id`,className:`fg-mono-input`})})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:8},children:[(0,u.jsx)(c.Form.Item,{name:[n,`lookupFilterField`],label:`Filter Field`,style:{marginBottom:0,flex:1},tooltip:`Optional DB field to filter lookup rows by. Example: _id or clientId.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. _id`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[n,`lookupFilterValueFrom`],label:`Filter Value From`,style:{marginBottom:0,flex:1},tooltip:`Optional form/scope field that provides the filter value. Example: clientId.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. clientId`,className:`fg-mono-input`})})]})]})]})}})]},t)),(0,u.jsx)(c.Button,{type:`dashed`,size:`small`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>n({type:`text`,req:!1}),children:`Add Sub-field`})]})})]})]}):null}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:8},children:[(0,u.jsx)(c.Form.Item,{name:[r,`placeholder`],label:`Placeholder`,style:{marginBottom:0,flex:1},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`Admin-controlled placeholder`})}),(0,u.jsx)(c.Form.Item,{name:[r,`hidePlaceholder`],label:`Hide Placeholder`,valuePropName:`checked`,style:{marginBottom:0},children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Hidden`,unCheckedChildren:`Shown`})})]}),(0,u.jsx)(`div`,{className:`fg-field-meta-row`,style:{marginTop:8},children:(0,u.jsx)(c.Form.Item,{name:[r,`inputDateFormat`],label:`Input date format (date fields)`,tooltip:`dayjs tokens, e.g. MM/DD/YYYY. Blank = module / tenant default.`,style:{marginBottom:0,flex:1},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`MM/DD/YYYY`,className:`fg-mono-input`,allowClear:!0})})}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:8},children:[(0,u.jsx)(c.Form.Item,{name:[r,`visiblePermission`],label:`Visible permission key`,style:{marginBottom:0,flex:1},tooltip:`Menu-permission key ('<module>.<key>', e.g. submission.viewRate) gating whether this field is rendered at all. Leave blank to show to everyone (subject to the Show toggle above). Add matching keys in Admin → Permissions.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. submission.viewRate`})}),(0,u.jsx)(c.Form.Item,{name:[r,`editablePermission`],label:`Editable permission key`,style:{marginBottom:0,flex:1},tooltip:`Menu-permission key gating whether this field can be edited. Users without it see the field disabled with a tooltip. Leave blank to allow everyone (subject to the Edit toggle above).`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. submission.editRate`})})]}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:8},children:({getFieldValue:e})=>e([...x,`clientScope`])?(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Client Gate Message`}),(0,u.jsx)(c.Form.Item,{name:[r,`clientGateMessage`],style:{marginBottom:0},children:(0,u.jsx)(c.Input.TextArea,{rows:2,placeholder:`Message shown below 'Select Client' in the add form (leave blank for default)`})}),(0,u.jsx)(c.Form.Item,{name:[r,`clientGateResetOnChange`],valuePropName:`checked`,style:{margin:`10px 0 0`},tooltip:`When the selected client changes or is cleared, remove every value already entered in the form before loading the new client configuration.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Reset form on client change`,unCheckedChildren:`Keep form values`})})]}):null}),(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsxs)(`span`,{className:`fg-options-label`,children:[(0,u.jsx)(l.InfoCircleOutlined,{}),` Help Text`]}),(0,u.jsx)(c.Form.Item,{...o,name:[r,`tooltip`],label:`Tooltip`,style:{marginBottom:8},tooltip:`Hover help for this field. Works on every control — including fields rendered without a label, where the info icon below cannot appear. Use this one unless you specifically need the icon.`,children:(0,u.jsx)(c.Input.TextArea,{rows:2,placeholder:`Shown when users hover this field`})}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:0},children:({getFieldValue:e})=>e([...x,`infoEnabled`])?(0,u.jsx)(c.Form.Item,{name:[r,`infoText`],label:`Info icon text`,style:{marginBottom:0},rules:[{required:!0,message:`Enter info message`}],tooltip:`Legacy pair (Info switch above + this text). Renders an icon inside the field label, so it never shows on a label-less field. Ignored when a Tooltip is set.`,children:(0,u.jsx)(c.Input.TextArea,{rows:2,placeholder:`Message shown when users hover the info icon`})}):null})]}),(0,u.jsx)(c.Form.Item,{...o,name:[r,`helpText`],label:`Extra Text`,tooltip:`Small grey text under the field. Put EACH LINE on its own line — they render stacked. Use one line for the rule ("Supports .pdf, .doc, .docx up to 2MB") and another for the reason ("Upload the résumé first — we can read the details out of it"). Run together in one paragraph, the second half gets skipped.`,children:(0,u.jsx)(c.Input.TextArea,{rows:3,placeholder:`Supports: .pdf, .doc, .docx up to 2MB
|
|
6
6
|
Upload the résumé first — we can read the details straight from it`})}),(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Checks against other records and other rows`}),(0,u.jsxs)(`div`,{className:`fg-options-controls`,style:{flexWrap:`wrap`},children:[(0,u.jsx)(c.Form.Item,{name:[r,`checkDuplicateOnBlur`],label:`Check for an existing record`,valuePropName:`checked`,style:{marginBottom:0},tooltip:`Put this on the email (or phone) box. When someone finishes typing it, we look for a record that already matches and offer to open it. Catching it here saves them filling in the whole form first. The fields compared are set in Automations → Check for someone already on file.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`On blur`,unCheckedChildren:`Off`})}),(0,u.jsx)(c.Form.Item,{name:[r,`rowHierarchyEnabled`],label:`Keep rows in date order`,valuePropName:`checked`,style:{marginBottom:0},tooltip:`For a date inside a repeat section that is listed newest-first. Once the first row has dates, the calendar greys out any date that would overlap it in the rows below — you cannot have finished an earlier course after starting a later one. The user sees what is available while choosing, instead of being told afterwards.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Enforced`,unCheckedChildren:`Off`})})]}),(0,u.jsx)(`p`,{className:`fg-source-hint`,children:`These two only make sense in the right place: the duplicate check on the box that identifies a person, and the date order on a start/end date inside a repeat section that lists the most recent first.`})]}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:8},children:({getFieldValue:e})=>{let t=e([...x,`showIf`,`field`]),n=e([...x,`showIf`,`operator`])??`eq`,i=mw.includes(n);return(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Show Condition`}),(0,u.jsxs)(`div`,{className:`fg-options-controls`,style:{flexWrap:`wrap`},children:[(0,u.jsx)(c.Form.Item,{name:[r,`showIf`,`field`],label:`Show only when field`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`field key — blank = always show`,style:{width:210},className:`fg-mono-input`})}),t&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Form.Item,{name:[r,`showIf`,`operator`],label:`Operator`,style:{marginBottom:0},initialValue:`eq`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:130},options:pw,getPopupContainer:()=>document.body})}),i&&(0,u.jsx)(c.Form.Item,{name:[r,`showIf`,`value`],label:`Value`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. yes`,style:{width:100},className:`fg-mono-input`})})]})]}),t&&(0,u.jsx)(c.Form.List,{name:[r,`showIf`,`conditions`],children:(e,{add:t,remove:n})=>(0,u.jsxs)(`div`,{style:{marginTop:8},children:[e.length>0&&(0,u.jsx)(c.Form.Item,{name:[r,`showIf`,`logic`],label:`Combine when`,style:{marginBottom:6},initialValue:`and`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:190},getPopupContainer:()=>document.body,options:[{value:`and`,label:`All must match (AND)`},{value:`or`,label:`Any can match (OR)`}]})}),e.map(e=>(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:6},children:({getFieldValue:t})=>{let r=t([...x,`showIf`,`conditions`,e.name,`operator`])??`eq`,i=mw.includes(r);return(0,u.jsxs)(`div`,{className:`fg-options-controls`,style:{flexWrap:`wrap`,alignItems:`flex-end`},children:[(0,u.jsx)(c.Form.Item,{name:[e.name,`field`],label:`And field`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`field key`,style:{width:180},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[e.name,`operator`],label:`Operator`,style:{marginBottom:0},initialValue:`eq`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:130},options:pw,getPopupContainer:()=>document.body})}),i&&(0,u.jsx)(c.Form.Item,{name:[e.name,`value`],label:`Value`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`comma for list`,style:{width:130},className:`fg-mono-input`})}),(0,u.jsx)(c.Button,{size:`small`,type:`text`,danger:!0,onClick:()=>n(e.name),children:`Remove`})]})}},e.key)),(0,u.jsx)(c.Button,{size:`small`,type:`dashed`,style:{marginTop:4},onClick:()=>t({field:``,operator:`eq`,value:``}),children:`+ Add condition`})]})}),t&&(0,u.jsxs)(`p`,{className:`fg-source-hint`,style:{marginTop:4},children:[`Hidden until “`,t,`”`,i?` ${n===`eq`?`equals`:n===`neq`?`does not equal`:n===`in`?`is one of`:`is not one of`} the value above.`:` ${n===`truthy`?`has any value.`:n===`notEmpty`?`has at least one row.`:`is empty.`}`,` `,`Add more conditions below to require several at once.`]})]})}}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:8},children:({getFieldValue:e})=>{let t=e([...x,`labelWhen`,`field`]),n=e([...x,`labelWhen`,`operator`])??`eq`,i=mw.includes(n);return(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Conditional Label`}),(0,u.jsxs)(`div`,{className:`fg-options-controls`,style:{flexWrap:`wrap`},children:[(0,u.jsx)(c.Form.Item,{name:[r,`labelWhen`,`field`],label:`Watch field`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`blank = use normal label`,style:{width:190},className:`fg-mono-input`})}),t&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Form.Item,{name:[r,`labelWhen`,`operator`],label:`Operator`,style:{marginBottom:0},initialValue:`eq`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:130},options:pw,getPopupContainer:()=>document.body})}),i&&(0,u.jsx)(c.Form.Item,{name:[r,`labelWhen`,`value`],label:`Value`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`comma-separated for one-of`,style:{width:180},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`labelWhen`,`label`],label:`Alternate label`,style:{marginBottom:0},rules:[{required:!0,message:`Enter alternate label`}],children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. Employer Rate`,style:{width:170}})})]})]}),t&&(0,u.jsx)(`p`,{className:`fg-source-hint`,style:{marginTop:4},children:`Only the displayed label changes. The field key and submitted payload stay unchanged.`})]})}}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:8},children:({getFieldValue:e})=>{let t=e([...x,`colWhenField`]),n=e([...x,`colWhenOperator`])??`eq`,i=mw.includes(n);return(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Conditional Width`}),(0,u.jsxs)(`div`,{className:`fg-options-controls`,style:{flexWrap:`wrap`},children:[(0,u.jsx)(c.Form.Item,{name:[r,`colWhenField`],label:`Watch field`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`blank = always use Width`,style:{width:190},className:`fg-mono-input`})}),t&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Form.Item,{name:[r,`colWhenOperator`],label:`Operator`,style:{marginBottom:0},initialValue:`eq`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:130},options:pw,getPopupContainer:()=>document.body})}),i&&(0,u.jsx)(c.Form.Item,{name:[r,`colWhenValue`],label:`Value`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`comma-separated for one-of`,style:{width:180},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`colWhenCol`],label:`Width when matched`,style:{marginBottom:0},rules:[{required:!0,message:`Enter a width (1-24)`}],children:(0,u.jsx)(c.InputNumber,{size:`small`,min:1,max:24,style:{width:150},placeholder:`e.g. 6`})})]})]}),t&&(0,u.jsx)(`p`,{className:`fg-source-hint`,style:{marginTop:4},children:`While the condition holds this field uses the width above (24 = full row); otherwise it falls back to Width. Layout only — the payload is unchanged.`})]})}}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:8},children:({getFieldValue:e})=>{let t=e([...x,`verifyAction`]);return(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Field Verification`}),(0,u.jsxs)(`div`,{className:`fg-options-controls`,style:{flexWrap:`wrap`},children:[(0,u.jsx)(c.Form.Item,{name:[r,`verifyAction`],label:`Action`,style:{marginBottom:0},children:(0,u.jsx)(c.Select,{size:`small`,allowClear:!0,placeholder:`None`,style:{width:130},options:[{label:`Email`,value:`email`}]})}),t&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Form.Item,{name:[r,`verifyResultField`],label:`Result field`,style:{marginBottom:0},rules:[{required:!0,message:`Result field is required`}],children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. isValid`,style:{width:130},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`verifyTimestampField`],label:`Timestamp field`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. validatedAt`,style:{width:150},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`verifyIdleLabel`],label:`Initial text`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`Verify Email`,style:{width:130}})}),(0,u.jsx)(c.Form.Item,{name:[r,`verifyRetryLabel`],label:`Retry text`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`Re Verify`,style:{width:120}})}),(0,u.jsx)(c.Form.Item,{name:[r,`verifySuccessLabel`],label:`Success text`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`Valid`,style:{width:110}})}),(0,u.jsx)(c.Form.Item,{name:[r,`verifyLockedWhenFields`],label:`Locked when fields`,style:{marginBottom:0},tooltip:`Comma-separated sibling field keys on the same row (e.g. isAccountCreate). When ALL of them are true AND the result field is true, the edit form shows a fixed, non-clickable label instead of the Verify button. Blank = never locked.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. isAccountCreate`,style:{width:190},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`verifyLockedLabel`],label:`Locked text`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`Verified`,style:{width:110}})})]})]}),t&&(0,u.jsx)(`p`,{className:`fg-source-hint`,style:{marginTop:4},children:`Changing the verified value resets the result and disables any configured validation gate. \xA0Locked-when fields mark a value that can no longer be re-checked (an account already exists for it) — the edit form then shows the locked text and no button.`})]})}}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:8},children:({getFieldValue:e})=>{let t=e([...x,`type`]),n=e([...x,`dataType`])??`auto`,i=e([...x,`payloadMode`])??`auto`,a=[`select`,`radio`,`checkbox`].includes(t),o=[`label`,`object`,`custom`].includes(i);return(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Payload Mapping`}),(0,u.jsxs)(`div`,{className:`fg-options-controls`,style:{flexWrap:`wrap`},children:[(0,u.jsx)(c.Form.Item,{name:[r,`payloadKey`],label:`Payload Key`,style:{marginBottom:8},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`defaults to field key`,style:{width:180},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`prefillFrom`],label:`Prefill From`,tooltip:`Source path to inherit this field's value from when the record is created by prefilling another module (e.g. submission ← candidate). Dotted paths allowed, e.g. passport.passportNumber.`,style:{marginBottom:8},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`source key (cross-module prefill)`,style:{width:200},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`prefillAsHint`],label:`Show instead of filling`,valuePropName:`checked`,style:{marginBottom:0},tooltip:`On: the prefilled value is shown as a note UNDER the field and the box stays empty. Use it for anything that must be decided fresh each time — a rate carried forward looks helpful, but a number already in the box gets submitted unread.`,children:(0,u.jsx)(c.Switch,{size:`small`})}),(0,u.jsx)(c.Form.Item,{name:[r,`prefillHintLabel`],label:`Note wording`,style:{marginBottom:0},tooltip:`Shown under the field. "{value}" is replaced by the previous value. Blank uses "Last recorded: {value}".`,children:(0,u.jsx)(c.Input,{size:`small`,style:{width:260},placeholder:`Last recorded: {value}`})}),(0,u.jsx)(c.Form.Item,{name:[r,`prefillFromModule`],label:`Prefill From Module`,tooltip:`Prefill this field from ANOTHER module's record linked in the URL instead of the default source — e.g. 'job' makes Quick Submit fill this field from the current job (with Prefill From naming the job's key, e.g. mspreqId). Leave blank for the normal prefill source.`,style:{marginBottom:8},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. job`,style:{width:160},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,noStyle:!0,children:({getFieldValue:e,setFieldValue:t})=>{let n=e([`fields`,r,`prefillWhen`])??[],i=e([`fields`,r,`lookupCollection`]),a=e([`fields`,r,`displayField`]),o=e([`fields`,r,`valueField`])||`_id`,s=(e,i)=>{let a=n.map((t,n)=>n===e?{...t,...i}:t);t([`fields`,r,`prefillWhen`],a)};return(0,u.jsxs)(`div`,{style:{width:`100%`,margin:`4px 0 8px`},children:[(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,flexWrap:`wrap`},children:[(0,u.jsx)(QC,{type:`secondary`,style:{fontSize:12},children:`Conditional Default — when a field matches, set this field to a chosen record (or tick Clear to empty it instead)`}),(0,u.jsx)(c.Button,{size:`small`,type:`dashed`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>t([`fields`,r,`prefillWhen`],[...n,{field:``,value:``,setValue:``}]),children:`Add`})]}),n.length>0&&(0,u.jsx)(c.Form.Item,{name:[r,`prefillWhenReset`],valuePropName:`checked`,initialValue:!0,style:{marginBottom:0,marginTop:6},tooltip:`When the watched field changes to a value with NO matching row above (e.g. Contract Type switches away from W2), clear this field back out — but only if it still holds exactly the default a rule set (a value the admin/user picked themselves is never touched). Off keeps the old default in place.`,children:(0,u.jsx)(c.Checkbox,{children:`Reset this field when the condition no longer matches`})}),n.length>0&&(0,u.jsx)(c.Form.Item,{name:[r,`prefillWhenExclusive`],valuePropName:`checked`,initialValue:!1,style:{marginBottom:0,marginTop:2},tooltip:`Treat each record chosen above as EXCLUSIVE to its condition: it is offered in this dropdown only while its row matches, and is removed from the list entirely the rest of the time (including before the watched field is filled in). Use it when the record is only ever a valid choice under that condition — not merely its default. Off (the default) leaves the dropdown offering everything, as before.`,children:(0,u.jsx)(c.Checkbox,{children:`Offer the chosen record ONLY while its condition matches (hide it otherwise)`})}),n.map((e,d)=>(0,u.jsxs)(`div`,{style:{display:`flex`,gap:6,alignItems:`center`,marginTop:6},children:[(0,u.jsx)(c.Input,{size:`small`,placeholder:`when field (e.g. contractType)`,className:`fg-mono-input`,style:{width:180},value:e.field,onChange:e=>s(d,{field:e.target.value})}),(0,u.jsx)(`span`,{style:{color:`#94a3b8`,fontSize:12},children:`=`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`value (e.g. W2-Fulltime)`,className:`fg-mono-input`,style:{width:150},value:e.value,onChange:e=>s(d,{value:e.target.value})}),(0,u.jsx)(`span`,{style:{color:`#94a3b8`,fontSize:12},children:`→`}),e.clearValue?(0,u.jsx)(QC,{type:`secondary`,style:{fontSize:12,width:220},children:`clear this field`}):(0,u.jsx)(Fw,{collection:i,displayField:a,valueField:o,value:e.setValue,labelValue:e.setValueLabel,onChange:(e,t)=>s(d,{setValue:e,setValueLabel:t})}),(0,u.jsx)(c.Checkbox,{checked:!!e.clearValue,onChange:e=>s(d,{clearValue:e.target.checked}),children:(0,u.jsx)(`span`,{style:{fontSize:12},children:`Clear`})}),(0,u.jsx)(c.Button,{size:`small`,type:`text`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{}),onClick:()=>t([`fields`,r,`prefillWhen`],n.filter((e,t)=>t!==d))})]},d))]})}}),(0,u.jsx)(c.Form.Item,{name:[r,`dataType`],label:`Data Type`,style:{marginBottom:8},initialValue:`auto`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:170},options:hw,getPopupContainer:()=>document.body})}),n===`array`&&(0,u.jsx)(c.Form.Item,{name:[r,`elementType`],label:`Array Element Type`,style:{marginBottom:8},children:(0,u.jsx)(c.Select,{size:`small`,style:{width:130},options:gw,getPopupContainer:()=>document.body})}),(0,u.jsx)(c.Form.Item,{name:[r,`payloadMode`],label:`Payload Mode`,style:{marginBottom:8},initialValue:`auto`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:210},options:_w,getPopupContainer:()=>document.body})}),(0,u.jsx)(c.Form.Item,{name:[r,`defaultValue`],label:`Default Value`,style:{marginBottom:8},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`optional`,style:{width:130}})}),(0,u.jsx)(c.Form.Item,{name:[r,`defaultOnEdit`],label:`Default on Edit`,valuePropName:`checked`,style:{marginBottom:8},tooltip:`When the stored value is empty, show Default Value in edit form. Keep off for fields that should remain blank on edit.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Yes`,unCheckedChildren:`No`})}),(0,u.jsx)(c.Form.Item,{name:[r,`defaultOnServer`],label:`Default on Server`,valuePropName:`checked`,style:{marginBottom:8},tooltip:`On CREATE only, the server writes Default Value when the request carries nothing for this field — covers imports and integrations that never show the form. Updates are never touched.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Yes`,unCheckedChildren:`No`})}),(0,u.jsx)(c.Form.Item,{name:[r,`noPrefill`],label:`No Prefill`,valuePropName:`checked`,style:{marginBottom:8},tooltip:`Always render this field blank on edit instead of showing the stored value. For fields that capture a NEW entry each time rather than the record's current state — e.g. Billing Update's Amount Received, where each save records one more client payment.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Yes`,unCheckedChildren:`No`})}),(0,u.jsx)(c.Form.Item,{name:[r,`emptyValues`],label:`Empty Values`,style:{marginBottom:8},tooltip:`Comma separated stored values that should render as blank in edit form. Example: 0, candidate`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. 0, candidate`,style:{width:170}})}),(0,u.jsx)(c.Form.Item,{name:[r,`valuePaths`],label:`Value Paths`,style:{marginBottom:8},tooltip:`Comma separated read paths for edit/detail prefill. Supports array filters like socialProfiles[type=linkedin].value.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`linkedIn, socialProfiles[type=linkedin].value`,style:{width:300},className:`fg-mono-input`})})]}),(o||a)&&(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,u.jsx)(c.Form.Item,{name:[r,`valueKey`],label:`Value Key (id)`,style:{marginBottom:8,flex:1},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. id`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[r,`displayKey`],label:`Display Key (label)`,style:{marginBottom:8,flex:1},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. name`,className:`fg-mono-input`})}),a&&(0,u.jsx)(c.Form.Item,{name:[r,`richValue`],label:`Keep label`,valuePropName:`checked`,style:{marginBottom:8},initialValue:!1,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Yes`,unCheckedChildren:`No`})})]}),i===`custom`&&(0,u.jsxs)(`div`,{style:{marginBottom:8},children:[(0,u.jsxs)(`span`,{className:`fg-static-options-hint`,children:[`Payload Template (JSON) — tokens: `,`{{value}} {{label}} {{raw.field}}`]}),(0,u.jsx)(c.Form.Item,{name:[r,`payloadTemplate`],style:{marginBottom:0},children:(0,u.jsx)(c.Input.TextArea,{rows:2,className:`fg-mono-input`,placeholder:`{ "countryId": "{{value}}", "countryName": "{{label}}" }`})})]}),(0,u.jsxs)(`details`,{style:{marginTop:4},children:[(0,u.jsx)(`summary`,{className:`fg-source-hint`,style:{cursor:`pointer`},children:`Advanced: transform rule / omit empty`}),(0,u.jsxs)(`div`,{style:{marginTop:6},children:[(0,u.jsxs)(`span`,{className:`fg-static-options-hint`,children:[`Transform Rule (JSON) — e.g. `,`{ "map": { "true": "high", "false": "medium" } }`]}),(0,u.jsx)(c.Form.Item,{name:[r,`transformRule`],style:{marginBottom:6},children:(0,u.jsx)(c.Input.TextArea,{rows:2,className:`fg-mono-input`,placeholder:`{ "map": { "true": "high" }, "default": "medium" }`})}),(0,u.jsx)(c.Form.Item,{name:[r,`omitEmpty`],label:`Omit when empty`,valuePropName:`checked`,style:{marginBottom:0},initialValue:!1,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Omit`,unCheckedChildren:`Send`})})]})]})]})}}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:8},children:({getFieldValue:e})=>{let t=e([...x,`type`]);if([`select`,`radio`,`checkbox`,`date`,`time`,`file`,`location`].includes(t))return null;let i=e([...x,`validator`,`type`]),a=i&&![`email`,`websiteUrl`,`jobDescription`].includes(i),o=i===`jobDescription`;return(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Input Validator`}),(0,u.jsxs)(`div`,{className:`fg-options-controls`,style:{flexWrap:`wrap`},children:[(0,u.jsx)(c.Form.Item,{name:[r,`validator`,`type`],label:`Type`,style:{marginBottom:0},children:(0,u.jsx)(c.Select,{size:`small`,allowClear:!0,placeholder:`None — no char restriction`,style:{width:260},options:n.Vt})}),a&&(0,u.jsx)(c.Form.Item,{name:[r,`validator`,`maxLength`],label:`Max Length`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,type:`number`,min:1,placeholder:`e.g. 55`,style:{width:90}})}),o&&(0,u.jsx)(c.Form.Item,{name:[r,`validator`,`maxChars`],label:`Max Chars`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,type:`number`,min:1,placeholder:`1500`,style:{width:90}})}),i&&(0,u.jsx)(c.Form.Item,{name:[r,`validator`,`title`],label:`Error Title`,style:{marginBottom:0},tooltip:`Used in error messages. Defaults to the field label when blank.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:e([...x,`label`])||`Field`,style:{width:180}})})]})]})}}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:8},children:({getFieldValue:e})=>{let t=e([...x,`type`]),n=t===`checkbox`,i=t===`select`&&e([...x,`dataSource`])===`lookup`;return!n&&!i?(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Grey this out when a tick-box is ticked`}),(0,u.jsx)(c.Form.Item,{name:[r,`disabledByField`],style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`sibling field key (e.g. currentlyPursuing)`,className:`fg-mono-input`,style:{width:260}})}),(0,u.jsx)(`p`,{className:`fg-source-hint`,children:`Name a tick-box in the same section. While it is ticked, this box is greyed out and cannot be typed in. Use it when the answer stops applying — for example an End Date once "still working here" is ticked. To HIDE the box completely instead of greying it out, use Show Condition above with the operator "is empty/false".`}),(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Require this once a sibling field has a value`}),(0,u.jsx)(c.Form.Item,{name:[r,`requiredIfField`],style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`sibling field key (e.g. empSigninAuthAlternatePhone)`,className:`fg-mono-input`,style:{width:260}})}),(0,u.jsx)(`p`,{className:`fg-source-hint`,children:`Name a field in the same section. This field becomes mandatory only once that sibling has a value — e.g. an alternate phone's country code required only after the alternate phone number itself is entered. Works independently of the Required toggle above.`}),(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Freeze the form while this field's dependants reload`}),(0,u.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`,alignItems:`center`},children:[(0,u.jsx)(c.Form.Item,{name:[r,`blockWhileResolving`],valuePropName:`checked`,style:{marginBottom:0},children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Freeze`,unCheckedChildren:`Off`})}),(0,u.jsx)(c.Form.Item,{noStyle:!0,shouldUpdate:(e,t)=>e?.fields?.[r]?.blockWhileResolving!==t?.fields?.[r]?.blockWhileResolving,children:({getFieldValue:e})=>e([`fields`,r,`blockWhileResolving`])?(0,u.jsx)(c.Form.Item,{name:[r,`blockScope`],style:{marginBottom:0},children:(0,u.jsx)(c.Select,{size:`small`,style:{width:260},options:[{value:`form`,label:`Whole form`},{value:`group`,label:`Only the sections that change`}]})}):null})]}),(0,u.jsxs)(`p`,{className:`fg-source-hint`,children:[`Changing this field sets off work on others — an employer lookup refetches, an autofill rewrites a phone number. Those land a moment later, and anything typed in the gap is silently overwritten. Turn this on to lock the fields until they settle.`,(0,u.jsx)(`br`,{}),(0,u.jsx)(`strong`,{children:`Only the sections that change`}),` is usually the better choice: it freezes just the cards holding the dependent fields, so work in progress elsewhere on the form survives. Use`,(0,u.jsx)(`strong`,{children:` Whole form`}),` when the dependants are spread across many sections. Either way the lock lifts on its own — a dependant that fails can never strand it.`]}),(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Require this only when a sibling has a particular value`}),(0,u.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`,alignItems:`flex-start`},children:[(0,u.jsx)(c.Form.Item,{name:[r,`requiredWhenField`],style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`sibling field key (e.g. documentName)`,className:`fg-mono-input`,style:{width:240}})}),(0,u.jsx)(c.Form.Item,{name:[r,`requiredWhenOperator`],style:{marginBottom:0},children:(0,u.jsx)(c.Select,{size:`small`,style:{width:150},options:sC})}),(0,u.jsx)(c.Form.Item,{noStyle:!0,shouldUpdate:(e,t)=>e?.fields?.[r]?.requiredWhenOperator!==t?.fields?.[r]?.requiredWhenOperator,children:({getFieldValue:e})=>lC(e([`fields`,r,`requiredWhenOperator`]))?(0,u.jsx)(c.Form.Item,{name:[r,`requiredWhenValue`],style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`value (e.g. Other)`,style:{width:200}})}):null})]}),(0,u.jsx)(c.Form.Item,{name:[r,`requiredWhenMessage`],style:{marginBottom:0,marginTop:8},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`error message (optional)`,style:{width:400}})}),(0,u.jsxs)(`p`,{className:`fg-source-hint`,children:[`Name a field in the same section and the value that makes this one mandatory — for example Document Name required only when Document Type is "Other". Unlike the rule above, this checks the sibling's `,(0,u.jsx)(`em`,{children:`value`}),`, not merely that it has one.`,(0,u.jsx)(`br`,{}),(0,u.jsx)(`strong`,{children:`Important:`}),` this rule is ignored while the field is already mandatory — that is, while the Required toggle is on or a "required" entry remains in its validations list. Turn those off, or the field stays mandatory in every row and this condition appears to do nothing.`]}),(0,u.jsxs)(`div`,{style:{marginTop:14},children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Put the country code in its own box`}),(0,u.jsx)(c.Form.Item,{name:[r,`splitDialCodeInto`],style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. contactCountryCode`,className:`fg-mono-input`,style:{width:260}})}),(0,u.jsx)(`p`,{className:`fg-source-hint`,children:`For phone-number boxes. When a number arrives with its country code attached — from a parsed résumé, or copied from somewhere else — the code is put into the box you name here and only the number stays in this one. Leave blank to keep the value exactly as it arrives. If a number comes in with no country code, the other box is left alone rather than being filled with a guess.`})]})]}):n?(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Empty another box when this is ticked`}),(0,u.jsx)(c.Form.Item,{name:[r,`linkedClearField`],style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`sibling field key to clear (e.g. endDate)`,className:`fg-mono-input`,style:{width:260}})}),(0,u.jsx)(`p`,{className:`fg-source-hint`,children:`Name the box to empty when someone ticks this. Example: ticking "Currently working here" clears the End Date, so an old date cannot be left behind by accident. You can name more than one box by separating them with commas.`}),(0,u.jsxs)(`div`,{style:{marginTop:10},children:[(0,u.jsx)(c.Form.Item,{name:[r,`exclusiveInGroup`],valuePropName:`checked`,style:{marginBottom:0},children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`One row only`,unCheckedChildren:`Any row`})}),(0,u.jsx)(`p`,{className:`fg-source-hint`,children:`Only one row of a repeatable group may have this checked — e.g. Currently Working Here / Currently Pursuing. Once a row is ticked the box is disabled on every other row; untick it to move the claim. No effect outside a repeatable group.`}),(0,u.jsx)(c.Form.Item,{name:[r,`disabledReason`],style:{marginTop:8,marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`Only one current job allowed`})}),(0,u.jsx)(`p`,{className:`fg-source-hint`,children:`The tooltip shown on the disabled box. A control greyed out with no reason reads as broken, so one is always shown — leave this empty and the form writes a generic sentence from the field's label.`})]})]}):i?(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`When this changes, clear the rest of the group`}),(0,u.jsx)(c.Form.Item,{name:[r,`clearGroupOnChange`],valuePropName:`checked`,style:{marginBottom:0},children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Clear`,unCheckedChildren:`Keep`})}),(0,u.jsx)(`p`,{className:`fg-source-hint`,children:`Turn this on when the other fields in this group describe whatever is picked here. Example: the Employer box. Email, phone and recruiter all belong to the employer that was selected, so if someone picks a different employer those details are now the wrong company's — and because the boxes still look filled in, nobody notices. With this on, they are emptied the moment the selection changes, ready for the new one. Inside a repeat section only that row is cleared.`}),(0,u.jsxs)(`div`,{style:{marginTop:14},children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Autofill Fields (JSON)`}),(0,u.jsx)(c.Form.Item,{name:[r,`autofillFrom`],style:{marginBottom:0},children:(0,u.jsx)(c.Input.TextArea,{rows:3,className:`fg-mono-input`,placeholder:`[{"optionKey":"vendorContact.email","targetField":"vendorEmail"}]`})}),(0,u.jsxs)(`p`,{className:`fg-source-hint`,children:[`Copy details from the record someone picks into other boxes in this group, so they do not have to type them again. Example: choosing a recruiter fills in their email and phone. One entry per box:`,(0,u.jsx)(`b`,{children:` optionKey`}),` is where the value sits on the picked record, and`,(0,u.jsx)(`b`,{children:` targetField`}),` is the box to put it in.`]})]})]}):null}}),(0,u.jsxs)(`div`,{className:`fg-validations-section`,children:[(0,u.jsxs)(`div`,{className:`fg-validations-header`,children:[(0,u.jsx)(l.SafetyCertificateOutlined,{className:`fg-val-icon`}),(0,u.jsx)(`span`,{className:`fg-val-title`,children:`Validations`})]}),(0,u.jsx)(c.Form.List,{name:[r,`validations`],children:(t,{add:n,remove:i})=>(0,u.jsxs)(u.Fragment,{children:[t.map(({key:t,name:n})=>(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:6},children:({getFieldValue:t})=>{let a=t([...y,r,`validations`,n,`type`]),o=yw(a),s=t([...y,r,`type`]),d=a===`dateAfterField`||a===`dateBeforeField`,f=(t(y)??[]).map((e,t)=>({candidate:e,index:t})).filter(({candidate:e,index:t})=>t!==r&&e?.type===`date`&&e?.field).map(({candidate:e})=>({value:e.field,label:`${e.label||e.field} (${e.field})`})),p=(t(y)??[]).map((e,t)=>({candidate:e,index:t})).filter(({candidate:e,index:t})=>t!==r&&e?.field).map(({candidate:e})=>({value:e.field,label:`${e.label||e.field} (${e.field})`})),m=fw.filter(e=>s===`date`?e.dateOnly||e.value===`required`||e.value===`unique`:!e.dateOnly).map(e=>({label:e.label,value:e.value})),h=a===uC,g=t([...y,r])??{},_=xC(g),b=[...y,r,`validations`,n,`value`],x=h?DC(t(b),g):null,S=h?IC({primaryModule:v.primaryModule,groupTargetModule:v.getTargetModule(),field:g,config:x,collectionForModule:v.collectionForModule}):null,C=(t(y)??[]).filter(e=>e?.field).map(e=>{let t=String(e.payloadKey??``).trim()||e.field;return{value:t,label:`${e.label||e.field} (${t})`}});return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`fg-val-row`,children:[(0,u.jsx)(c.Form.Item,{name:[n,`type`],style:{marginBottom:0},rules:[{required:!0,message:`Pick type`},{validator:(e,t)=>t===`unique`&&!_.supported?Promise.reject(Error(_.reason)):Promise.resolve()}],children:(0,u.jsx)(c.Select,{size:`small`,placeholder:s===`date`?`Date condition`:`Type`,style:{width:210},listHeight:400,getPopupContainer:()=>document.body,options:m,onChange:t=>{if(t===`unique`){let t=e.getFieldValue(b);e.setFieldValue(b,DC(t,e.getFieldValue([...y,r])??{}))}else typeof e.getFieldValue(b)==`object`&&e.setFieldValue(b,``)}})}),o.hasValue&&!h&&(0,u.jsx)(c.Form.Item,{name:[n,`value`],style:{marginBottom:0},children:d?(0,u.jsx)(c.Select,{size:`small`,showSearch:!0,allowClear:!0,placeholder:`Related date field`,style:{width:210},options:f,optionFilterProp:`label`,getPopupContainer:()=>document.body}):(0,u.jsx)(c.Input,{size:`small`,type:o.valueType===`number`?`number`:`text`,placeholder:o.placeholder,style:{width:90}})}),o.needsField&&(0,u.jsx)(c.Form.Item,{name:[n,`field`],style:{marginBottom:0},rules:[{required:!0,message:`Pick the capping field`}],children:(0,u.jsx)(c.AutoComplete,{size:`small`,style:{width:210},placeholder:`capped by field, e.g. totalExperience`,options:p,filterOption:(e,t)=>String(t?.label??``).toLowerCase().includes(String(e).toLowerCase()),getPopupContainer:()=>document.body})}),(0,u.jsx)(c.Form.Item,{name:[n,`message`],style:{marginBottom:0,flex:1},rules:o.messageOptional?[]:[{required:!0,whitespace:!0,message:`Message required`}],children:(0,u.jsx)(c.Input,{size:`small`,placeholder:o.messageOptional?`Optional — uses default`:h?`e.g. Email already present`:`Error message shown to user`})}),(0,u.jsx)(l.MinusCircleOutlined,{className:`fg-remove-icon`,style:{marginTop:4},onClick:()=>i(n)})]}),d&&(0,u.jsxs)(`div`,{className:`fg-options-block`,style:{marginTop:6},children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Start and end date rules`}),(0,u.jsxs)(`div`,{className:`fg-options-controls`,style:{flexWrap:`wrap`},children:[(0,u.jsx)(c.Form.Item,{name:[n,`strict`],label:`Must be different days`,valuePropName:`checked`,style:{marginBottom:0},tooltip:`On: the start and end cannot be the same day. Pick 7 July as the start and the calendar greys out 7 July and everything before it on the end date. Off: the same day is allowed on both.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Different days`,unCheckedChildren:`Same day OK`})}),(0,u.jsx)(c.Form.Item,{name:[n,`minGap`,`value`],label:`Smallest gap allowed`,style:{marginBottom:0},tooltip:`How far apart the two dates must be at least. The calendar greys out everything closer than this, so it is clear before anyone picks — not an error afterwards. Leave blank if any gap is fine.`,children:(0,u.jsx)(c.Input,{size:`small`,type:`number`,min:0,placeholder:`e.g. 6`,style:{width:90}})}),(0,u.jsx)(c.Form.Item,{name:[n,`minGap`,`unit`],label:`Unit`,style:{marginBottom:0},initialValue:`month`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:110},getPopupContainer:()=>document.body,options:[{label:`Days`,value:`day`},{label:`Weeks`,value:`week`},{label:`Months`,value:`month`},{label:`Years`,value:`year`}]})}),(0,u.jsx)(c.Form.Item,{name:[n,`minGapFrom`],label:`Let the user choose the gap`,style:{marginBottom:0},tooltip:`Optional. Name a dropdown on the same row that lets the user pick the gap themselves — for example a Duration box offering '6 months'. Whatever they choose is used instead of the fixed gap above; if they leave it empty, the fixed gap applies.`,children:(0,u.jsx)(c.AutoComplete,{size:`small`,style:{width:190},placeholder:`e.g. duration`,options:p,filterOption:(e,t)=>String(t?.label??``).toLowerCase().includes(String(e).toLowerCase()),getPopupContainer:()=>document.body})})]})]}),h&&(0,u.jsxs)(`div`,{className:`fg-options-block`,style:{marginTop:6},children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Uniqueness settings`}),_.supported?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`fg-options-controls`,style:{flexWrap:`wrap`},children:[(0,u.jsx)(c.Form.Item,{name:[n,`value`,`collectionField`],label:`Collection field`,style:{marginBottom:0},tooltip:`The key this value is stored under in the target collection. Dot paths allowed, e.g. passport.passportNumber. Defaults to the field's payload key.`,rules:[{validator:(e,t)=>{let n=CC(t);return n?Promise.reject(Error(n)):Promise.resolve()}}],children:(0,u.jsx)(c.AutoComplete,{size:`small`,style:{width:220},className:`fg-mono-input`,placeholder:S?.storedField||`stored key`,options:C,filterOption:(e,t)=>String(t?.label??``).toLowerCase().includes(String(e).toLowerCase()),getPopupContainer:()=>document.body})}),(0,u.jsx)(c.Form.Item,{name:[n,`value`,`normalizer`],label:`Normalization`,style:{marginBottom:0},tooltip:`How the value is normalised on BOTH sides before comparing. The server applies the same rule.`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:210},options:dC,getPopupContainer:()=>document.body})}),(0,u.jsx)(c.Form.Item,{name:[n,`value`,`validateOn`],label:`Check when`,style:{marginBottom:0},tooltip:`Blur checks as soon as the user leaves the field. Either way the value is re-checked authoritatively on submit.`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:190},options:fC,getPopupContainer:()=>document.body})}),(0,u.jsx)(c.Form.Item,{name:[n,`value`,`skipBlank`],label:`Skip blank`,valuePropName:`checked`,style:{marginBottom:0},tooltip:`On: two records that both left this field empty are not duplicates. Turn off only when a blank must itself be unique.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Skip`,unCheckedChildren:`Check`})}),(0,u.jsx)(c.Form.Item,{name:[n,`value`,`enforcement`],label:`How it is checked`,style:{marginBottom:0},tooltip:`Look at the field: checking email means reading the email of every other record. Nothing extra is stored. Keep a hidden copy: also saves a tidied-up copy of the value on the record and puts a database rule on it — only needed if two people might create the very same value at the exact same moment, and it needs the database rule to be created first.`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:220},options:hC,getPopupContainer:()=>document.body})})]}),(0,u.jsxs)(`p`,{className:`fg-source-hint`,style:{marginTop:6},children:[`Target module: `,(0,u.jsx)(`code`,{children:S?.module||`—`}),` · `,`Target collection: `,(0,u.jsx)(`code`,{children:S?.collection||`resolved on the server`}),` · `,`Form field: `,(0,u.jsx)(`code`,{children:S?.formField||`—`}),` · `,`Stored field: `,(0,u.jsx)(`code`,{children:S?.storedField||`—`})]}),S?.isCrossModule&&(0,u.jsxs)(`p`,{className:`fg-source-hint`,children:[`This group writes to `,(0,u.jsx)(`code`,{children:S.module}),` through its Target Collection, so the value is checked for uniqueness there — not in the module you are editing.`]}),(0,u.jsx)(c.Form.List,{name:[n,`value`,`alsoCheck`],children:(e,{add:t,remove:n})=>(0,u.jsxs)(`div`,{style:{marginTop:8},children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Also check these collections`}),e.map(({key:e,name:t,...r})=>(0,u.jsxs)(`div`,{className:`fg-options-controls`,style:{flexWrap:`wrap`,alignItems:`flex-end`,marginTop:4},children:[(0,u.jsx)(c.Form.Item,{...r,name:[t,`module`],label:`Module`,style:{marginBottom:0},tooltip:`Preferred. Resolved to a collection on the SERVER through the module registry — the browser never names a collection.`,children:(0,u.jsx)(c.Input,{size:`small`,style:{width:150},className:`fg-mono-input`,placeholder:`e.g. users`})}),(0,u.jsx)(c.Form.Item,{...r,name:[t,`collection`],label:`or Collection`,style:{marginBottom:0},tooltip:`Only when the target is not a registered module. A single collection name — never a path.`,children:(0,u.jsx)(c.Input,{size:`small`,style:{width:150},className:`fg-mono-input`,placeholder:`(optional)`})}),(0,u.jsx)(c.Form.Item,{...r,name:[t,`collectionField`],label:`Field there`,style:{marginBottom:0},tooltip:`The stored key in THAT collection. Defaults to this field's own key.`,children:(0,u.jsx)(c.Input,{size:`small`,style:{width:150},className:`fg-mono-input`,placeholder:`e.g. email`})}),(0,u.jsx)(c.Form.Item,{...r,name:[t,`excludeFrom`,`path`],label:`Exclude ids from`,style:{marginBottom:0},tooltip:`Path is read on the record being edited (array paths allowed, e.g. recruiters.accountUserId); Match field is the key those ids are stored under in the other collection (blank = _id). Without it, every record that has already provisioned a value there becomes impossible to edit.`,children:(0,u.jsx)(c.Input,{size:`small`,style:{width:190},className:`fg-mono-input`,placeholder:`e.g. recruiters.accountUserId`})}),(0,u.jsx)(c.Form.Item,{...r,name:[t,`excludeFrom`,`matchField`],label:`matched on`,style:{marginBottom:0},tooltip:`Path is read on the record being edited (array paths allowed, e.g. recruiters.accountUserId); Match field is the key those ids are stored under in the other collection (blank = _id). Without it, every record that has already provisioned a value there becomes impossible to edit.`,children:(0,u.jsx)(c.Input,{size:`small`,style:{width:140},className:`fg-mono-input`,placeholder:`_id`})}),(0,u.jsx)(c.Form.Item,{...r,name:[t,`message`],label:`Message`,style:{marginBottom:0},tooltip:`Optional override. Blank uses the rule's own message — the user is never told which collection matched.`,children:(0,u.jsx)(c.Input,{size:`small`,style:{width:200},placeholder:`(uses rule message)`})}),(0,u.jsx)(l.MinusCircleOutlined,{className:`fg-remove-icon`,style:{marginBottom:6},onClick:()=>n(t)})]},e)),(()=>{let e=(x?.alsoCheck??[]).flatMap((e,t)=>jC(e).map(e=>`#${t+1}: ${e}`));return e.length?(0,u.jsx)(c.Alert,{type:`error`,showIcon:!0,style:{marginTop:6},message:e[0]}):null})(),(0,u.jsx)(c.Button,{size:`small`,type:`dashed`,icon:(0,u.jsx)(l.PlusOutlined,{}),style:{marginTop:6},onClick:()=>t(OC()),children:`Add collection`}),(0,u.jsx)(`p`,{className:`fg-source-hint`,style:{marginTop:4},children:`Path is read on the record being edited (array paths allowed, e.g. recruiters.accountUserId); Match field is the key those ids are stored under in the other collection (blank = _id). Without it, every record that has already provisioned a value there becomes impossible to edit.`})]})})]}):(0,u.jsx)(c.Alert,{type:`warning`,showIcon:!0,style:{marginTop:4},message:`Uniqueness is not available for this field type`,description:_.reason})]})]})}},t)),(0,u.jsx)(c.Button,{size:`small`,type:`dashed`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>n({type:``,value:``,field:``,message:``}),className:`fg-add-val-btn`,children:`Add Validation`})]})})]}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:8},children:({getFieldValue:e})=>{let t=e([...y,r,`overrideEnabled`]),n=(e([...y,r,`validations`])??[]).map(e=>typeof e==`string`?e:e?.type).filter(Boolean);return(0,u.jsxs)(`div`,{className:`fg-validations-section`,children:[(0,u.jsxs)(`div`,{className:`fg-validations-header`,children:[(0,u.jsx)(l.SafetyCertificateOutlined,{className:`fg-val-icon`}),(0,u.jsx)(`span`,{className:`fg-val-title`,children:`Override checkbox`})]}),(0,u.jsxs)(`div`,{className:`fg-options-controls`,style:{flexWrap:`wrap`},children:[(0,u.jsx)(c.Form.Item,{name:[r,`overrideEnabled`],valuePropName:`checked`,style:{marginBottom:0},tooltip:`Adds a checkbox beside this field's label that lifts the validations you name below, after asking the user to confirm. Use it where a rule is right almost always and wrong occasionally — e.g. a rate cap a manager has genuinely agreed to exceed.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`On`,unCheckedChildren:`Off`})}),t&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Form.Item,{name:[r,`overrideSkipValidations`],label:`Lifts validations`,style:{marginBottom:0},rules:[{required:!0,message:`Name at least one validation type`}],tooltip:`Which validation TYPES the checkbox suspends. Everything you do NOT name keeps validating — so an override can lift a rate cap without also switching off 'must be a number'.`,children:(0,u.jsx)(c.Select,{size:`small`,mode:`tags`,style:{minWidth:260},placeholder:`e.g. maxFieldWithFallback`,options:n.map(e=>({label:e,value:e})),tokenSeparators:[`,`],getPopupContainer:()=>document.body})}),(0,u.jsx)(c.Form.Item,{name:[r,`overrideLabel`],label:`Checkbox label`,style:{marginBottom:0},tooltip:`Say what becomes allowed, not 'override'. e.g. 'Rate agreed above the job's client rate'.`,children:(0,u.jsx)(c.Input,{size:`small`,style:{width:280},placeholder:`e.g. Rate agreed above the job rate`})}),(0,u.jsx)(c.Form.Item,{name:[r,`overrideField`],label:`Stored as`,style:{marginBottom:0},tooltip:`The record key the flag is stored under. Leave blank for an automatic, collision-free key derived from this field's own key.`,children:(0,u.jsx)(c.Input,{size:`small`,className:`fg-mono-input`,style:{width:200},placeholder:`blank = automatic`})}),(0,u.jsx)(c.Form.Item,{name:[r,`overrideStore`],label:`Record it`,valuePropName:`checked`,style:{marginBottom:0},initialValue:!0,tooltip:`On (default): the flag is saved on the record, so a value that breaks a documented rule is explained rather than looking like the rule failed. Off: the override applies to this form session only.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Saved`,unCheckedChildren:`Session`})})]})]}),t&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`fg-options-controls`,style:{marginTop:8,flexWrap:`wrap`},children:[(0,u.jsx)(c.Form.Item,{name:[r,`overrideConfirmTitle`],label:`Confirm title`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,style:{width:300},placeholder:`blank = a sensible default`})}),(0,u.jsx)(c.Form.Item,{name:[r,`overrideConfirmOkText`],label:`Confirm button`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,style:{width:200},placeholder:`e.g. Yes, remove the limit`})}),(0,u.jsx)(c.Form.Item,{name:[r,`overrideConfirmCancelText`],label:`Cancel button`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,style:{width:200},placeholder:`e.g. Keep the limit`})})]}),(0,u.jsx)(c.Form.Item,{name:[r,`overrideConfirmBody`],label:`Confirm message`,style:{marginBottom:0,marginTop:8},tooltip:`State plainly what is being given up. Blank uses a default that names this field and says the override is recorded.`,children:(0,u.jsx)(c.Input.TextArea,{size:`small`,rows:2,placeholder:`blank = a sensible default naming this field`})}),(0,u.jsx)(`p`,{className:`fg-source-hint`,children:`Ticking the box asks the user to confirm before the limit comes off; unticking it restores the limit silently. Either way the field re-validates immediately.`})]})]})}}),(0,u.jsxs)(`div`,{className:`fg-validations-section`,children:[(0,u.jsxs)(`div`,{className:`fg-validations-header`,children:[(0,u.jsx)(l.ThunderboltOutlined,{className:`fg-val-icon`}),(0,u.jsx)(`span`,{className:`fg-val-title`,children:`AI Actions`})]}),(0,u.jsx)(c.Form.List,{name:[r,`aiActions`],children:(e,{add:t,remove:n})=>(0,u.jsxs)(u.Fragment,{children:[e.map(({key:e,name:t})=>(0,u.jsxs)(`div`,{className:`fg-ai-action-card`,children:[(0,u.jsxs)(`div`,{className:`fg-val-row`,children:[(0,u.jsx)(c.Form.Item,{name:[t,`key`],style:{marginBottom:0},rules:[{required:!0,message:`Key`}],children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`key (e.g. generateJD)`,style:{width:150}})}),(0,u.jsx)(c.Form.Item,{name:[t,`label`],style:{marginBottom:0},rules:[{required:!0,message:`Label`}],children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`Button label`,style:{width:170}})}),(0,u.jsx)(c.Form.Item,{name:[t,`trigger`],style:{marginBottom:0},initialValue:`click`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:100},options:[{label:`Click`,value:`click`},{label:`Upload`,value:`upload`}]})}),(0,u.jsx)(c.Form.Item,{name:[t,`bodyType`],style:{marginBottom:0},initialValue:`json`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:110},options:[{label:`JSON`,value:`json`},{label:`Multipart`,value:`multipart`}]})}),(0,u.jsx)(c.Form.Item,{name:[t,`position`],style:{marginBottom:0},children:(0,u.jsx)(c.Select,{size:`small`,style:{width:150},placeholder:`Button position`,allowClear:!0,options:[{label:`Top Left`,value:`top-left`},{label:`Top Center`,value:`top-center`},{label:`Top Right`,value:`top-right`},{label:`Bottom Left`,value:`bottom-left`},{label:`Bottom Center`,value:`bottom-center`},{label:`Bottom Right`,value:`bottom-right`}]})}),(0,u.jsx)(l.MinusCircleOutlined,{className:`fg-remove-icon`,style:{marginTop:4},onClick:()=>n(t)})]}),(0,u.jsxs)(`div`,{className:`fg-val-row`,children:[(0,u.jsx)(c.Form.Item,{name:[t,`serviceKey`],style:{marginBottom:0},rules:[{required:!0,message:`Service key`}],children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`Service key (e.g. pyOps)`,style:{width:170}})}),(0,u.jsx)(c.Form.Item,{name:[t,`endpointPath`],style:{marginBottom:0,flex:1},rules:[{required:!0,message:`Endpoint path`}],children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`/v1/promtJD`,className:`fg-mono-input`})})]}),(0,u.jsxs)(`div`,{className:`fg-ai-subsection`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Inputs (form field → request param) — mark an input "Required", or give it a Min Words count, to make the button stay disabled until that field has a value (or enough words). Inputs sharing the same "group" gate as one unit: either one satisfies it (e.g. a JD file OR JD text).`}),(0,u.jsx)(c.Form.List,{name:[t,`inputs`],children:(e,{add:t,remove:n})=>(0,u.jsxs)(u.Fragment,{children:[e.map(({key:e,name:t})=>(0,u.jsxs)(`div`,{className:`fg-val-row`,children:[(0,u.jsx)(c.Form.Item,{name:[t,`param`],style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`param`,style:{width:100}})}),(0,u.jsx)(c.Form.Item,{name:[t,`sourceField`],style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`source field`,className:`fg-mono-input`,style:{width:150}})}),(0,u.jsx)(c.Form.Item,{name:[t,`kind`],style:{marginBottom:0},initialValue:`text`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:90},options:[{label:`Text`,value:`text`},{label:`File`,value:`file`}]})}),(0,u.jsx)(c.Form.Item,{name:[t,`transform`],style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`transform`,style:{width:120}})}),(0,u.jsx)(c.Form.Item,{name:[t,`group`],style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`group (either/or)`,style:{width:130}})}),(0,u.jsx)(c.Form.Item,{name:[t,`minWords`],style:{marginBottom:0},children:(0,u.jsx)(c.InputNumber,{size:`small`,min:0,placeholder:`min words`,style:{width:100}})}),(0,u.jsx)(c.Form.Item,{name:[t,`required`],valuePropName:`checked`,style:{marginBottom:0},children:(0,u.jsx)(c.Checkbox,{children:`Required`})}),(0,u.jsx)(l.MinusCircleOutlined,{className:`fg-remove-icon`,onClick:()=>n(t)})]},e)),(0,u.jsx)(c.Button,{size:`small`,type:`dashed`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>t({kind:`text`}),children:`Add Input`})]})})]}),(0,u.jsxs)(`div`,{className:`fg-ai-subsection`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Where the details sit in the reply (optional)`}),(0,u.jsx)(c.Form.Item,{name:[t,`responseDataPath`],style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. data`,className:`fg-mono-input`,style:{width:200}})}),(0,u.jsx)(`p`,{className:`fg-source-hint`,children:`Most services reply with the details wrapped in something, often called "data". Name that wrapper here. Leave blank if the reply IS the details. Whatever comes back is matched to this form's boxes by name, exactly the way an Edit form fills itself in.`})]}),(0,u.jsxs)(`div`,{className:`fg-ai-subsection`,children:[(0,u.jsx)(`span`,{className:`fg-options-label`,children:`Before filling in the form`}),(0,u.jsx)(c.Form.Item,{name:[t,`confirmWhen`],style:{marginBottom:0},initialValue:`targetsFilled`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:320},getPopupContainer:()=>document.body,options:[{value:`targetsFilled`,label:`Ask only if it would overwrite something (recommended)`},{value:`always`,label:`Always ask first`},{value:`never`,label:`Never ask — just fill it in`}]})}),(0,u.jsx)(`p`,{className:`fg-source-hint`,children:`With the recommended setting, uploading a file to an empty form just fills it in — no interruption. If someone has already typed things in and then uploads a file, they are asked before their work is replaced.`}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:0},children:({getFieldValue:e})=>e([...x,`aiActions`,t,`confirmWhen`])===`never`?null:(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:8,flexWrap:`wrap`},children:[(0,u.jsx)(c.Form.Item,{name:[t,`confirmMessages`,`title`],label:`Question heading`,style:{marginBottom:0,flex:`1 1 220px`},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`Fill the form from this file?`})}),(0,u.jsx)(c.Form.Item,{name:[t,`confirmMessages`,`body`],label:`Explanation`,style:{marginBottom:0,flex:`1 1 320px`},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`We read details from the uploaded file. Applying them will replace what you have already entered.`})}),(0,u.jsx)(c.Form.Item,{name:[t,`confirmMessages`,`ok`],label:`Yes button`,style:{marginBottom:0,flex:`0 1 160px`},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`Parse & fill`})}),(0,u.jsx)(c.Form.Item,{name:[t,`confirmMessages`,`cancel`],label:`No button`,style:{marginBottom:0,flex:`0 1 180px`},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`Keep what I typed`})})]})})]})]},e)),(0,u.jsx)(c.Button,{size:`small`,type:`dashed`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>t({trigger:`click`,bodyType:`json`,inputs:[]}),className:`fg-add-val-btn`,children:`Add AI Action`})]})})]})]}),(0,u.jsx)(c.Tooltip,{title:`Remove field`,children:(0,u.jsx)(`button`,{type:`button`,className:`fg-field-remove-btn`,onClick:()=>i(r),"aria-label":`Remove field`,children:(0,u.jsx)(l.MinusCircleOutlined,{})})})]})]})},t)}),(0,u.jsx)(c.Button,{type:`dashed`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>{r({type:`text`,show:!0,req:!1,edit:!0,dataSource:`static`,masterName:``,options:[]}),g?.(t.length,!0)},block:!0,className:`fg-add-field-btn`,children:`Add Field`})]})}function Uw({open:e,editingGroup:t,defaultModule:r,moduleOptions:i,allGroupsByModule:a,onClose:o,onSaved:d,onSaveGroup:f}){let[p]=c.Form.useForm(),[m,h]=(0,s.useState)(!1),[g,_]=(0,s.useState)(r),[v,y]=(0,s.useState)({}),[b,x]=(0,s.useState)(!1),[S,C]=(0,s.useState)(()=>new Map),[w,T]=(0,s.useState)(null),[E,D]=(0,s.useState)(()=>new Set),[O,k]=(0,s.useState)(`settings`),[A,j]=(0,s.useState)(!1),M=(0,s.useRef)({}),N=(0,s.useRef)(null),P=Vw();(0,s.useEffect)(()=>{if(!e||!g)return;let t=!1;return n.mi(g).then(e=>{t||C(n.Ei(e))}).catch(()=>{t||C(new Map)}),()=>{t=!0}},[e,g]);async function F(e){if(!(!e||M.current[e])){M.current[e]=`loading`,x(!0);try{let t=await n.hi(e);y(n=>({...n,[e]:t})),M.current[e]=`loaded`}catch{delete M.current[e]}finally{x(!1)}}}(0,s.useEffect)(()=>{if(!e)return;let n=t?.module??r;_(n),t?p.setFieldsValue({module:t.module,name:t.name,label:t.label,addRow:t.addRow??!1,hideGroup:t.hideGroup??!1,hideGroupInForm:t.hideGroupInForm??!1,moduleName:t.moduleName??``,linkMode:t.parentRefField?`forward`:`reverse`,linkField:t.linkField??``,linkTypeField:t.linkTypeField??``,parentRefField:t.parentRefField??``,writeRefs:t.writeRefs??[],dependsOn:t.dependsOn??[],optionalWrite:t.optionalWrite??!1,hierarchyLevel:t.hierarchyLevel??void 0,hierarchyParent:t.hierarchyParent??void 0,hierarchyLinkField:t.hierarchyLinkField??``,allowCollapse:t.allowCollapse??!1,defaultCollapsed:t.defaultCollapsed??!1,collapseWhenEmpty:t.collapseWhenEmpty??!1,appendHistory:t.appendHistory??!1,historyField:[t.historyField,...t.historyFields??[]].filter(Boolean).filter((e,t,n)=>n.indexOf(e)===t).join(`, `),historyTimestampField:t.historyTimestampField??``,historyLabels:Object.entries(t.historyLabels??{}).map(([e,t])=>`${e}=${t}`).join(`, `),historyLabelFrom:Object.entries(t.historyLabelFrom??{}).map(([e,t])=>`${e}=${t}`).join(`, `),historyAfterGroup:t.historyAfterGroup??``,historyAmountFields:Object.entries(t.historyAmountFields??{}).map(([e,t])=>`${e}=${t}`).join(`, `),historyCurrencyFields:Object.entries(t.historyCurrencyFields??{}).map(([e,t])=>`${e}=${t}`).join(`, `),historyUnitFields:Object.entries(t.historyUnitFields??{}).map(([e,t])=>`${e}=${t}`).join(`, `),historyShowIf:Object.entries(t.historyShowIf??{}).filter(([,e])=>e&&typeof e==`object`).map(([e,t])=>({container:e,field:t.field??t.conditions?.[0]?.field??``,operator:t.operator??t.conditions?.[0]?.operator??`eq`,value:t.value??t.conditions?.[0]?.value??``})),minRows:t.minRows??``,maxRows:t.maxRows??``,initialRows:t.initialRows??``,requireOne:t.requireOne??!1,allowInProgress:t.allowInProgress!==!1,inProgressMessage:t.inProgressMessage??``,orderByEnabled:!!t.orderBy,levelRuleEnabled:!!t.levelRule,orderBy:t.orderBy??null,levelRule:t.levelRule??null,regionRules:t.regionRules??null,duplicateCheck:t.duplicateCheck??null,requireValidatedField:t.requireValidatedField??``,linkGroup:t.linkGroup??``,mergeInto:t.mergeInto??``,mergePosition:t.mergePosition??`bottom`,showIfField:t.showIf?.field??``,showIfOperator:t.showIf?.operator??`notEmpty`,showIfValue:t.showIf?.value??``,disabledIfField:t.disabledIf?.field??``,disabledIfOperator:t.disabledIf?.operator??`notEmpty`,disabledIfValue:t.disabledIf?.value??``,submitDisabledMessage:t.submitDisabledMessage??``,infoEnabled:t.infoEnabled??!1,infoText:t.infoText??``,toggleEnabled:t.toggleEnabled??!1,toggleLabel:t.toggleLabel??``,toggleField:t.toggleField??``,afterSubmitMode:t.afterSubmit?.mode??void 0,afterSubmitTarget:t.afterSubmit?.target??``,formActions:(t.formActions??[]).map(e=>({label:e.label??``,tone:e.tone===`primary`?`primary`:`default`,afterSubmitMode:e.afterSubmit?.mode??`stay`,afterSubmitTarget:e.afterSubmit?.target??``,enabledWhenField:e.enabledWhen?.field??``,enabledWhenOperator:e.enabledWhen?.operator??`notEmpty`,enabledWhenValue:e.enabledWhen?.value??``})),submitMsgAddSuccess:t.submitMessages?.addSuccess??``,submitMsgEditSuccess:t.submitMessages?.editSuccess??``,submitMsgAddError:t.submitMessages?.addError??``,submitMsgEditError:t.submitMessages?.editError??``,submitMsgSuppress:t.submitMessages?.suppress??!1,order:t.order??0,fields:[...t.fields??[]].sort((e,t)=>Number(e.order??0)-Number(t.order??0)).map(zw)}):(p.resetFields(),p.setFieldsValue({module:n,addRow:!1,hideGroup:!1,hideGroupInForm:!1,moduleName:``,linkMode:`reverse`,linkField:``,linkTypeField:``,parentRefField:``,hierarchyLevel:void 0,hierarchyParent:void 0,hierarchyLinkField:``,allowCollapse:!1,defaultCollapsed:!1,collapseWhenEmpty:!1,appendHistory:!1,historyField:``,historyTimestampField:``,historyLabels:``,historyLabelFrom:``,historyAfterGroup:``,historyAmountFields:``,historyCurrencyFields:``,historyUnitFields:``,minRows:``,requireOne:!1,allowInProgress:!0,inProgressMessage:``,orderByEnabled:!1,levelRuleEnabled:!1,orderBy:null,levelRule:null,regionRules:null,duplicateCheck:null,mergeInto:``,mergePosition:`bottom`,showIfField:``,showIfOperator:`notEmpty`,showIfValue:``,disabledIfField:``,disabledIfOperator:`notEmpty`,disabledIfValue:``,submitDisabledMessage:``,formActions:[],infoEnabled:!1,toggleEnabled:!1,afterSubmitMode:void 0,afterSubmitTarget:``,order:0,fields:[]})),F(n)},[e,t,r,p]);function I(e){_(e),F(e)}function L(){D(new Set),k(`settings`),j(!1),o()}function R(e){k(e),e===`fields`&&j(!0)}function z(e,t=!1){D(n=>{let r=new Set(n);return t?r.add(e):r.has(e)?r.delete(e):r.add(e),r})}function B(e){let n=a[e]??[],r=new Set;return n.forEach(e=>{t&&e.id===t.id||(e.fields??[]).forEach(e=>{e.field&&r.add(e.field)})}),r}function V(e,t){let n=(v[g]??[]).find(t=>t.value===e);if(!n)return;let r=p.getFieldValue([`fields`,t])??{};p.setFieldValue([`fields`,t],{...r,field:n.value,label:n.label,type:n.type??`text`})}function H(e){let t=B(e);return(v[e]??[]).map(e=>({value:e.value,disabled:t.has(e.value),label:(0,u.jsxs)(`span`,{style:{opacity:t.has(e.value)?.4:1},children:[e.label,(0,u.jsx)(`span`,{className:`fg-field-key-hint`,children:e.value}),t.has(e.value)&&(0,u.jsx)(`span`,{className:`fg-field-taken-hint`,children:`(in another group)`})]}),searchLabel:`${e.label} ${e.value}`.toLowerCase()}))}async function ee(){try{let e=await p.validateFields(),r={...p.getFieldsValue(!0),...e,fields:p.getFieldValue(`fields`)??[]},i=kw(r.fields);if(i.length){c.message.error(`Uniqueness rule cannot be saved — ${i[0]}`);return}if(r.moduleName){let e=r.name||r.label||`this group`,n=String(r.hierarchyParent??``).trim(),i=String(r.hierarchyLinkField??``).trim();if(n||i){if(r.linkMode===`forward`){c.message.error(`Group "${e}": Hierarchy cannot be combined with a forward link (parentRefField) — choose one linkage mode.`);return}if(!n||!i){c.message.error(`Group "${e}": set both "Parent collection" and "Store parent id in field" to use Hierarchy.`);return}if(n===r.moduleName){c.message.error(`Group "${e}": Hierarchy parent cannot be this group's own Target Collection.`);return}let o=(a[r.module]??[]).filter(e=>!t||e.id!==t.id),s=new Map;o.forEach(e=>{e.moduleName&&s.set(e.moduleName,e.hierarchyParent??null)}),s.set(r.moduleName,n);let l=n,u=new Set([r.moduleName]),d=!1;for(;l&&l!==r.module;){if(u.has(l)){d=!0;break}u.add(l),l=s.get(l)??null}if(d){c.message.error(`Group "${e}": this Hierarchy parent chain loops back on itself — pick a different Parent collection.`);return}}}h(!0);let o={module:r.module,name:r.name,label:r.label,addRow:r.addRow??!1,order:Number(r.order??0),fields:Pw(r.fields??[])};if(r.hideGroup&&(o.hideGroup=!0),r.hideGroupInForm&&(o.hideGroupInForm=!0),r.moduleName){if(o.moduleName=r.moduleName,r.linkMode===`forward`){let e=String(r.parentRefField??``).trim();e&&(o.parentRefField=e)}else{let e=String(r.linkField??``).trim(),t=String(r.linkTypeField??``).trim();e&&(o.linkField=e),t&&(o.linkTypeField=t)}let e=(r.writeRefs??[]).filter(e=>e?.fromModule&&e?.targetField);e.length&&(o.writeRefs=e.map(e=>({fromModule:e.fromModule.trim(),targetField:e.targetField.trim()})));let t=(r.dependsOn??[]).map(e=>String(e).trim()).filter(Boolean);t.length&&(o.dependsOn=t),r.optionalWrite&&(o.optionalWrite=!0);let n=String(r.hierarchyParent??``).trim(),i=String(r.hierarchyLinkField??``).trim();n&&i&&(o.hierarchyParent=n,o.hierarchyLinkField=i);let a=Number(r.hierarchyLevel);Number.isFinite(a)&&a>0&&(o.hierarchyLevel=a)}let s=String(r.historyField??``).split(`,`).map(e=>e.trim()).filter(Boolean).filter((e,t,n)=>n.indexOf(e)===t);if(r.allowCollapse&&(o.allowCollapse=!0,r.defaultCollapsed&&(o.defaultCollapsed=!0),r.collapseWhenEmpty&&(o.collapseWhenEmpty=!0)),r.appendHistory&&s.length){o.appendHistory=!0,o.historyField=s[0],s.length>1&&(o.historyFields=s.slice(1)),String(r.historyTimestampField??``).trim()&&(o.historyTimestampField=r.historyTimestampField.trim());let e=e=>{let t={};return String(e??``).split(`,`).forEach(e=>{let n=e.indexOf(`=`);if(n<1)return;let r=e.slice(0,n).trim(),i=e.slice(n+1).trim();r&&i&&s.includes(r)&&(t[r]=i)}),t},n=e(r.historyLabels);Object.keys(n).length&&(o.historyLabels=n);let i=e(r.historyLabelFrom);Object.keys(i).length&&(o.historyLabelFrom=i);let a=e(r.historyAmountFields);Object.keys(a).length&&(o.historyAmountFields=a);let c=e(r.historyCurrencyFields);Object.keys(c).length&&(o.historyCurrencyFields=c);let l=e(r.historyUnitFields);Object.keys(l).length&&(o.historyUnitFields=l);let u={};(r.historyShowIf??[]).forEach(e=>{let n=String(e?.container??``).trim(),r=String(e?.field??``).trim(),i=String(e?.operator??``).trim()||`eq`;if(!n||!r||!s.includes(n))return;let a=e?.value===void 0||e?.value===null?``:String(e.value),o=t?.historyShowIf?.[n],c=o?.conditions?.[0],l=!!o?.conditions?.length&&(o.field??c?.field)===r&&(o.operator??c?.operator??`eq`)===i&&String(o.value??c?.value??``)===a;u[n]=l?o:{field:r,operator:i,value:a}}),Object.keys(u).length&&(o.historyShowIf=u),String(r.historyAfterGroup??``).trim()&&(o.historyAfterGroup=r.historyAfterGroup.trim())}if(r.addRow&&r.minRows!==void 0&&r.minRows!==``&&(o.minRows=Number(r.minRows)),r.addRow&&r.initialRows!==void 0&&r.initialRows!==``&&(o.initialRows=Number(r.initialRows)),r.addRow&&r.maxRows!==void 0&&r.maxRows!==``&&(o.maxRows=Number(r.maxRows)),r.addRow&&String(r.requireValidatedField??``).trim()&&(o.requireValidatedField=r.requireValidatedField.trim()),r.addRow&&r.requireOne&&(o.requireOne=!0),r.allowInProgress===!1){o.allowInProgress=!1;let e=String(r.inProgressMessage??``).trim();e&&(o.inProgressMessage=e)}r.orderByEnabled&&(o.orderBy=r.orderBy??Mw),r.levelRuleEnabled&&(o.levelRule=r.levelRule??Nw),r.regionRules&&(o.regionRules=r.regionRules);let l=YC(r.duplicateCheck);if(l&&(o.duplicateCheck=l),r.addRow&&r.linkGroup&&(o.linkGroup=r.linkGroup.trim()),String(r.mergeInto??``).trim()&&(o.mergeInto=r.mergeInto.trim(),r.mergePosition===`top`&&(o.mergePosition=`top`)),String(r.showIfField??``).trim()){let e=r.showIfOperator||`notEmpty`;o.showIf={field:r.showIfField.trim(),operator:e},[`eq`,`neq`,`in`,`notIn`].includes(e)&&String(r.showIfValue??``).trim()&&(o.showIf.value=r.showIfValue.trim())}if(String(r.submitDisabledMessage??``).trim()&&(o.submitDisabledMessage=r.submitDisabledMessage.trim()),String(r.disabledIfField??``).trim()){let e=r.disabledIfOperator||`notEmpty`;o.disabledIf={field:r.disabledIfField.trim(),operator:e},[`eq`,`neq`,`in`,`notIn`].includes(e)&&String(r.disabledIfValue??``).trim()&&(o.disabledIf.value=r.disabledIfValue.trim())}r.infoEnabled&&r.infoText&&(o.infoEnabled=!0,o.infoText=r.infoText),r.toggleEnabled&&r.toggleField&&(o.toggleEnabled=!0,o.toggleLabel=r.toggleLabel||`Toggle`,o.toggleField=r.toggleField),r.afterSubmitMode&&(o.afterSubmit={mode:r.afterSubmitMode},(r.afterSubmitMode===`route`||r.afterSubmitMode===`detail`)&&(o.afterSubmit.target=(r.afterSubmitTarget||``).trim()));let u=(r.formActions??[]).filter(e=>String(e?.label??``).trim());u.length&&(o.formActions=u.map(e=>{let t={label:e.label.trim(),tone:e.tone===`primary`?`primary`:`default`},n=e.afterSubmitMode||`stay`;if(t.afterSubmit={mode:n},(n===`route`||n===`detail`)&&(t.afterSubmit.target=String(e.afterSubmitTarget??``).trim()),String(e.enabledWhenField??``).trim()){let n=e.enabledWhenOperator||`notEmpty`;t.enabledWhen={field:e.enabledWhenField.trim(),operator:n},[`eq`,`neq`,`in`,`notIn`].includes(n)&&String(e.enabledWhenValue??``).trim()&&(t.enabledWhen.value=e.enabledWhenValue.trim())}return t}));let m={};if((r.submitMsgAddSuccess||``).trim()&&(m.addSuccess=r.submitMsgAddSuccess.trim()),(r.submitMsgEditSuccess||``).trim()&&(m.editSuccess=r.submitMsgEditSuccess.trim()),(r.submitMsgAddError||``).trim()&&(m.addError=r.submitMsgAddError.trim()),(r.submitMsgEditError||``).trim()&&(m.editError=r.submitMsgEditError.trim()),r.submitMsgSuppress&&(m.suppress=!0),Object.keys(m).length&&(o.submitMessages=m),t)for(let[e,n]of Object.entries(t))n!=null&&n!==``&&(e in o||Rw.has(e)||(o[e]=n));f?(await f(o,t),c.message.success(t?`Group updated`:`Group created`)):t?(await n.Bi(t.id,o),c.message.success(`Group updated`)):(await n.Cr(o),c.message.success(`Group created`)),D(new Set),k(`settings`),j(!1),d()}catch(e){if(e?.errorFields)return;c.message.error(e.message||`Could not save group`)}finally{h(!1)}}let te=(0,s.useMemo)(()=>H(g||r),[a,r,t,g,v]);return(0,u.jsx)(c.Modal,{open:e,onCancel:L,width:1080,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal fg-group-editor-modal`,title:(0,u.jsxs)(`span`,{className:`fg-drawer-title`,children:[t?(0,u.jsx)(l.EditOutlined,{}):(0,u.jsx)(l.PlusOutlined,{}),t?` Edit Form Group`:` New Form Group`]}),footer:(0,u.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,u.jsx)(c.Button,{onClick:L,children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,loading:m,onClick:ee,icon:t?(0,u.jsx)(l.EditOutlined,{}):(0,u.jsx)(l.PlusOutlined,{}),children:t?`Update Group`:`Create Group`})]}),children:(0,u.jsxs)(c.Form,{form:p,layout:`vertical`,className:`fg-form fg-editor-form fg-group-editor-form`,children:[(0,u.jsxs)(`div`,{className:`fg-group-editor-tabs`,role:`tablist`,"aria-label":`Form group editor sections`,children:[(0,u.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":O===`settings`,className:O===`settings`?`is-active`:``,onClick:()=>R(`settings`),children:[(0,u.jsx)(`span`,{className:`fg-editor-tab-number`,children:`1`}),(0,u.jsxs)(`span`,{children:[(0,u.jsx)(`strong`,{children:`Group settings`}),(0,u.jsx)(`small`,{children:`Name, behaviour and display options`})]})]}),(0,u.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":O===`fields`,className:O===`fields`?`is-active`:``,onClick:()=>R(`fields`),children:[(0,u.jsx)(`span`,{className:`fg-editor-tab-number`,children:`2`}),(0,u.jsxs)(`span`,{children:[(0,u.jsx)(`strong`,{children:`Fields`}),(0,u.jsxs)(`small`,{children:[t?.fields?.length??0,` configured fields`]})]})]})]}),(0,u.jsxs)(`div`,{className:`fg-group-editor-panel${O===`settings`?` is-active`:``}`,children:[(0,u.jsxs)(`div`,{className:`fg-form-section fg-group-settings-card`,children:[(0,u.jsx)(`div`,{className:`fg-form-section-label`,children:`Group Info`}),(0,u.jsx)(c.Form.Item,{name:`module`,label:`Module`,rules:[{required:!0,message:`Select a module`}],children:(0,u.jsx)(c.Select,{options:i,placeholder:`Select module`,onChange:I})}),(0,u.jsx)(c.Form.Item,{name:`label`,label:`Group Label`,rules:[{required:!0,message:`Label is required`}],children:(0,u.jsx)(c.Input,{placeholder:`e.g. Work Experience`})}),(0,u.jsx)(c.Form.Item,{name:`name`,label:`Group Name (key)`,rules:[{required:!0,message:`Name is required`},{pattern:/^[a-z0-9_]+$/,message:`Lowercase letters, numbers, underscores only`}],children:(0,u.jsx)(c.Input,{placeholder:`e.g. work_experience`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:`moduleName`,label:`Target Collection (optional)`,tooltip:`Route THIS group's fields to a different collection instead of the default module record. Groups sharing the same target merge into one linked record. Leave blank for default behaviour.`,children:(0,u.jsx)(c.AutoComplete,{options:i.map(e=>({value:e.value,label:e.label})),placeholder:`Default (this module's own record)`,allowClear:!0,filterOption:(e,t)=>(t?.value??``).toLowerCase().includes(e.toLowerCase()),className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:0},className:`fg-group-conditional`,children:({getFieldValue:e})=>e(`moduleName`)?(0,u.jsxs)(`div`,{className:`fg-options-block`,style:{marginBottom:12},children:[(0,u.jsxs)(`span`,{className:`fg-options-label`,children:[`Linkage`,(0,u.jsx)(`span`,{className:`fg-field-key-hint`,style:{marginLeft:6},children:`how this collection links to the main record (ids stored as ObjectId)`})]}),(0,u.jsx)(c.Form.Item,{name:`linkMode`,style:{marginBottom:8},children:(0,u.jsxs)(c.Radio.Group,{optionType:`button`,buttonStyle:`solid`,size:`small`,children:[(0,u.jsx)(c.Radio.Button,{value:`reverse`,children:`Target stores this record’s id (child→parent)`}),(0,u.jsx)(c.Radio.Button,{value:`forward`,children:`This record stores the target’s id (lookup)`})]})}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:0},children:({getFieldValue:e})=>e(`linkMode`)===`forward`?(0,u.jsx)(c.Form.Item,{name:`parentRefField`,label:`Reference field on THIS record`,tooltip:`A field on the main record that holds the target document's _id (as ObjectId), e.g. employerRef. On edit it selects which target document to load and update.`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{placeholder:`e.g. employerRef`,className:`fg-mono-input`,style:{width:260}})}):(0,u.jsxs)(`div`,{className:`fg-inline-row`,style:{alignItems:`flex-end`},children:[(0,u.jsx)(c.Form.Item,{name:`linkField`,label:`Link field on target (optional)`,tooltip:`Field on the TARGET document that stores this record's _id (as ObjectId), e.g. jobRef. Leave blank to use the default parentId / parentModule linkage.`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{placeholder:`e.g. jobRef`,className:`fg-mono-input`,style:{width:220}})}),(0,u.jsx)(c.Form.Item,{name:`linkTypeField`,label:`Parent-type field (optional)`,tooltip:`Field on the target document recording WHICH module the parent is (e.g. parentType), so one collection can serve several parent modules.`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{placeholder:`e.g. parentType`,className:`fg-mono-input`,style:{width:220}})})]})})]}):null}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:0},className:`fg-group-conditional`,children:({getFieldValue:e})=>e(`moduleName`)?(0,u.jsxs)(`div`,{className:`fg-options-block`,style:{marginBottom:12},children:[(0,u.jsxs)(`span`,{className:`fg-options-label`,children:[`Hierarchy`,(0,u.jsx)(`span`,{className:`fg-field-key-hint`,style:{marginLeft:6},children:`chain this collection under another collection of the same form`})]}),(0,u.jsxs)(`div`,{className:`fg-inline-row`,style:{alignItems:`flex-end`},children:[(0,u.jsx)(c.Form.Item,{name:`hierarchyLevel`,label:`Level`,tooltip:`Explicit ordering when several collections chain together — level 1 is written first.`,style:{marginBottom:0},children:(0,u.jsx)(c.InputNumber,{min:1,max:99,style:{width:120}})}),(0,u.jsx)(c.Form.Item,{name:`hierarchyParent`,label:`Parent collection`,tooltip:`What this collection is chained under: the main record, or another group's Target Collection.`,style:{marginBottom:0,minWidth:260},children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,placeholder:`No hierarchy (default)`,optionFilterProp:`label`,options:(()=>{let t=e(`module`)||g||r,n=e(`moduleName`),i=a[t]??[],o=new Set,s=[];return t&&(s.push({value:t,label:`Main record (${t})`}),o.add(t)),i.forEach(e=>{let t=e.moduleName;!t||t===n||o.has(t)||(o.add(t),s.push({value:t,label:t}))}),s})()})}),(0,u.jsx)(c.Form.Item,{name:`hierarchyLinkField`,label:`Store parent id in field`,tooltip:`Field on THIS collection holding the parent's _id (stored as ObjectId).`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{placeholder:`e.g. trainerId`,className:`fg-mono-input`,style:{width:200}})})]}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,noStyle:!0,children:({getFieldValue:e})=>{let t=e(`module`)||g||r,n=e(`moduleName`),i=a[t]??[],o=Bw(t,n,e(`hierarchyParent`),e(`hierarchyLinkField`),i);return o?(0,u.jsx)(QC,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:6},children:o}):null}})]}):null}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:0},className:`fg-group-conditional`,children:({getFieldValue:e})=>e(`moduleName`)?(0,u.jsxs)(`div`,{className:`fg-options-block`,style:{marginBottom:12},children:[(0,u.jsxs)(`span`,{className:`fg-options-label`,children:[`Linked-write dependencies`,(0,u.jsx)(`span`,{className:`fg-field-key-hint`,style:{marginLeft:6},children:`inject ids created by other writes of this same form submit`})]}),(0,u.jsx)(c.Form.List,{name:`writeRefs`,children:(e,{add:t,remove:n})=>(0,u.jsxs)(`div`,{children:[e.map(({key:e,name:t,...r})=>(0,u.jsxs)(`div`,{className:`fg-inline-row`,style:{alignItems:`flex-end`,marginBottom:6},children:[(0,u.jsx)(c.Form.Item,{...r,name:[t,`fromModule`],label:`Id from (module)`,rules:[{required:!0,message:`Module`}],style:{marginBottom:0},children:(0,u.jsx)(c.AutoComplete,{options:i.map(e=>({value:e.value})),placeholder:`e.g. users (or this module)`,style:{width:220},className:`fg-mono-input`,filterOption:(e,t)=>(t?.value??``).toLowerCase().includes(e.toLowerCase())})}),(0,u.jsx)(c.Form.Item,{...r,name:[t,`targetField`],label:`Store into field`,rules:[{required:!0,message:`Field`}],style:{marginBottom:0},children:(0,u.jsx)(c.Input,{placeholder:`e.g. userId or links.userId`,style:{width:220},className:`fg-mono-input`})}),(0,u.jsx)(c.Tooltip,{title:`Remove dependency`,children:(0,u.jsx)(`button`,{type:`button`,className:`fg-field-remove-btn`,onClick:()=>n(t),"aria-label":`Remove dependency`,children:(0,u.jsx)(l.MinusCircleOutlined,{})})})]},e)),(0,u.jsx)(c.Button,{type:`dashed`,size:`small`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>t({fromModule:``,targetField:``}),children:`Add Dependency`})]})}),(0,u.jsxs)(`div`,{className:`fg-inline-row`,style:{marginTop:10},children:[(0,u.jsx)(c.Form.Item,{name:`dependsOn`,label:`Runs after (ordering only)`,tooltip:`Other Target Collections this write must wait for, without injecting an id.`,style:{marginBottom:0,flex:1},children:(0,u.jsx)(c.Select,{mode:`tags`,placeholder:`e.g. users`,options:i.map(e=>({value:e.value,label:e.value}))})}),(0,u.jsx)(c.Form.Item,{name:`optionalWrite`,label:`Optional write`,valuePropName:`checked`,tooltip:`On: a failure of this write is logged but the submit still succeeds (best-effort). Off (default): a failure rolls back EVERY write of this submit.`,style:{marginBottom:0},children:(0,u.jsx)(c.Switch,{checkedChildren:`Best-effort`,unCheckedChildren:`Required`})})]})]}):null}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:12},className:`fg-group-conditional`,children:({getFieldValue:e})=>{let t=e(`allowCollapse`);return(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsxs)(`span`,{className:`fg-options-label`,children:[`Collapsible section`,(0,u.jsx)(`span`,{className:`fg-field-key-hint`,style:{marginLeft:6},children:`let users fold this section away — useful on long forms`})]}),(0,u.jsxs)(`div`,{className:`fg-options-controls`,children:[(0,u.jsx)(c.Form.Item,{name:`allowCollapse`,valuePropName:`checked`,style:{marginBottom:0},tooltip:`On: the section header shows a chevron that opens and closes it, on both the Add and Edit forms. Off (default): no chevron, the section is always open.`,children:(0,u.jsx)(c.Switch,{checkedChildren:`Collapsible`,unCheckedChildren:`Always open`})}),t&&(0,u.jsx)(c.Form.Item,{name:`defaultCollapsed`,label:`Start closed`,valuePropName:`checked`,style:{marginBottom:0},tooltip:`On: the section is already folded away when the form opens, and the user opens it if they need it. Use it for the parts most records leave alone, so the form opens on the fields that are filled in every time.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Closed`,unCheckedChildren:`Open`})}),t&&(0,u.jsx)(c.Form.Item,{name:`collapseWhenEmpty`,label:`Follow the data`,valuePropName:`checked`,style:{marginBottom:0},tooltip:`On: on the EDIT form the section opens when this record has anything in it and stays closed when it does not — re-checked after every save, so a section the user just emptied closes on its own. A ticked box or a 0 counts as data. Independent of 'Start closed': use this alone for a section that should simply follow whether the record uses it.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Data-driven`,unCheckedChildren:`Fixed`})})]})]})}}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:12},className:`fg-group-conditional`,children:({getFieldValue:e})=>{let t=e(`appendHistory`);return(0,u.jsxs)(`div`,{className:`fg-options-block`,children:[(0,u.jsxs)(`span`,{className:`fg-options-label`,children:[`Append as history`,(0,u.jsx)(`span`,{className:`fg-field-key-hint`,style:{marginLeft:6},children:`keep every past save instead of overwriting (e.g. rate negotiation history)`})]}),(0,u.jsxs)(`div`,{className:`fg-options-controls`,children:[(0,u.jsx)(c.Form.Item,{name:`appendHistory`,valuePropName:`checked`,style:{marginBottom:0},children:(0,u.jsx)(c.Switch,{checkedChildren:`Append`,unCheckedChildren:`Off`})}),t&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Form.Item,{name:`historyField`,label:`Array field`,rules:[{required:!0,message:`Required`}],tooltip:`The record key(s) holding the append-only array(s) — usually the prefix(es) this group's own fields already write through. Comma-separate to keep an independent history per prefix, e.g. candidateBudget, proposedRate, referralRate.`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. proposedRate, candidateBudget`,style:{width:240},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:`historyTimestampField`,label:`Timestamp key`,tooltip:`Key stamped onto each saved entry. Blank defaults to 'timestamp'.`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`timestamp`,style:{width:140},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:`historyLabels`,label:`Detail headings`,tooltip:`Heading shown for each history block in the detail view, as container=Label pairs, comma-separated. Blank derives it from the first field under that container — which also picks up that field's Conditional Label, so the heading can change per record.`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`candidateBudget=Candidate Rate, proposedRate=Proposed Rate`,style:{width:320},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:`historyLabelFrom`,label:`Heading from field`,tooltip:`Take each block's heading from a specific field's label, as container=fieldKey pairs. Use this when the heading must follow a Conditional Label on a field other than the first one.`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`candidateBudget=candidateBudget.candidateBudgetStart`,style:{width:320},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:`historyAmountFields`,label:`Amount key`,tooltip:`Which sub-key of a stored entry holds the amount, as container=subKey pairs, comma-separated. Blank uses the first field this group configures under that container that is not a currency/symbol/unit/type key — correct for almost every group.`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`candidateBudget=candidateBudgetStart`,style:{width:320},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:`historyCurrencyFields`,label:`Currency key`,tooltip:`Which sub-key holds the currency (code or symbol), as container=subKey pairs. Blank prefers a configured symbol field that actually carries a symbol, otherwise the configured currency field.`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`candidateBudget=candidateBudgetCurrency`,style:{width:320},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:`historyUnitFields`,label:`Unit key`,tooltip:`Which sub-key holds the rate unit (Hourly / Daily / …), as container=subKey pairs. Blank uses the configured unit field under that container.`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`candidateBudget=candidateBudgetUnit`,style:{width:320},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:`historyAfterGroup`,label:`Show after group`,tooltip:`Group key the history card is rendered after in the detail view. Blank places it after the employer group, or last when there is none.`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`employer_details`,style:{width:200},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{label:`Show block when`,tooltip:`Per history block: show it in the detail view only when a record field matches — e.g. candidateRate only when contractType equals W2, proposedRate only when internalSubmissionStatusText is one of Approved. Blocks with no row always show. When the record has no value for the field, the block shows.`,style:{marginBottom:0,width:`100%`},children:(0,u.jsx)(c.Form.List,{name:`historyShowIf`,children:(e,{add:t,remove:n})=>(0,u.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6},children:[e.map(e=>(0,u.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:6,alignItems:`flex-start`},children:[(0,u.jsx)(c.Form.Item,{name:[e.name,`container`],style:{marginBottom:0},rules:[{required:!0,message:`Container`},({getFieldValue:e})=>({validator(t,n){let r=String(e(`historyField`)??``).split(`,`).map(e=>e.trim()).filter(Boolean);return!n||r.includes(String(n).trim())?Promise.resolve():Promise.reject(Error(`Must be one of the Array fields above`))}})],children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`proposedRate`,style:{width:150},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[e.name,`field`],style:{marginBottom:0},rules:[{required:!0,message:`Field`}],children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`contractType`,style:{width:210},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[e.name,`operator`],initialValue:`eq`,style:{marginBottom:0},children:(0,u.jsx)(c.Select,{size:`small`,style:{width:130},options:Iw,getPopupContainer:()=>document.body})}),(0,u.jsx)(c.Form.Item,{name:[e.name,`value`],style:{marginBottom:0},children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`W2 (one of: A,B)`,style:{width:170}})}),(0,u.jsx)(c.Button,{size:`small`,type:`text`,danger:!0,onClick:()=>n(e.name),children:`Remove`})]},e.key)),(0,u.jsx)(c.Button,{size:`small`,type:`dashed`,onClick:()=>t({operator:`eq`}),style:{alignSelf:`flex-start`},children:`+ Add block condition`})]})})})]})]}),t&&(0,u.jsx)(`p`,{className:`fg-source-hint`,style:{marginTop:6},children:`Every save adds a new entry to the end of the array — the detail view and edit form always show the latest one, exactly like a normal field.`})]})}}),(0,u.jsxs)(`div`,{className:`fg-inline-row`,children:[(0,u.jsx)(c.Form.Item,{name:`order`,label:`Display Order`,children:(0,u.jsx)(c.Input,{type:`number`,min:0,style:{width:100}})}),(0,u.jsx)(c.Form.Item,{name:`addRow`,label:`Allow Add Row`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{checkedChildren:`Yes`,unCheckedChildren:`No`})}),(0,u.jsx)(c.Form.Item,{name:`hideGroup`,label:`Hide Group`,valuePropName:`checked`,tooltip:`Hide this group entirely from Add/Edit forms — not rendered, not validated, not submitted.`,children:(0,u.jsx)(c.Switch,{checkedChildren:`Hidden`,unCheckedChildren:`Visible`})}),(0,u.jsx)(c.Form.Item,{name:`hideGroupInForm`,label:`Hide in Form only`,valuePropName:`checked`,tooltip:`Hide this group from the Add/Edit forms but KEEP it on the detail view. For groups whose values are filled by the system and should be read, never typed — e.g. a submission's Job Information. (Hide Group above hides it in both places.)`,children:(0,u.jsx)(c.Switch,{checkedChildren:`Form hidden`,unCheckedChildren:`Shown`})}),(0,u.jsx)(c.Form.Item,{label:`Show group when`,tooltip:`Gate the whole group on another field's live value — the group only appears once the condition matches (e.g. the Employer group opens after Contract Type is chosen). Leave the field blank to always show.`,children:(0,u.jsxs)(c.Space.Compact,{block:!0,children:[(0,u.jsx)(c.Form.Item,{name:`showIfField`,noStyle:!0,children:(0,u.jsx)(c.Input,{placeholder:`Field key e.g. contractType`,style:{width:`45%`}})}),(0,u.jsx)(c.Form.Item,{name:`showIfOperator`,noStyle:!0,children:(0,u.jsx)(c.Select,{style:{width:`30%`},options:[{value:`notEmpty`,label:`is set`},{value:`isEmpty`,label:`is empty`},{value:`eq`,label:`equals`},{value:`neq`,label:`not equals`},{value:`in`,label:`in list`},{value:`notIn`,label:`not in list`}]})}),(0,u.jsx)(c.Form.Item,{noStyle:!0,shouldUpdate:(e,t)=>e.showIfOperator!==t.showIfOperator,children:({getFieldValue:e})=>[`eq`,`neq`,`in`,`notIn`].includes(e(`showIfOperator`))?(0,u.jsx)(c.Form.Item,{name:`showIfValue`,noStyle:!0,children:(0,u.jsx)(c.Input,{placeholder:`Value(s), comma for list`,style:{width:`25%`}})}):null})]})}),(0,u.jsx)(c.Form.Item,{name:`disabled`,label:`Disable Group`,valuePropName:`checked`,tooltip:`Make the whole group card read-only — it still renders and submits, but no field can be edited.`,children:(0,u.jsx)(c.Switch,{checkedChildren:`Read-only`,unCheckedChildren:`Editable`})}),(0,u.jsx)(c.Form.Item,{label:`Disable group when`,tooltip:`Make the whole group read-only while another field's live value satisfies this condition (same shape as 'Show group when'). Leave the field blank for no conditional disable.`,children:(0,u.jsxs)(c.Space.Compact,{block:!0,children:[(0,u.jsx)(c.Form.Item,{name:`disabledIfField`,noStyle:!0,children:(0,u.jsx)(c.Input,{placeholder:`Field key e.g. contractType`,style:{width:`45%`}})}),(0,u.jsx)(c.Form.Item,{name:`disabledIfOperator`,noStyle:!0,children:(0,u.jsx)(c.Select,{style:{width:`30%`},options:[{value:`notEmpty`,label:`is set`},{value:`isEmpty`,label:`is empty`},{value:`eq`,label:`equals`},{value:`neq`,label:`not equals`},{value:`in`,label:`in list`},{value:`notIn`,label:`not in list`}]})}),(0,u.jsx)(c.Form.Item,{noStyle:!0,shouldUpdate:(e,t)=>e.disabledIfOperator!==t.disabledIfOperator,children:({getFieldValue:e})=>[`eq`,`neq`,`in`,`notIn`].includes(e(`disabledIfOperator`))?(0,u.jsx)(c.Form.Item,{name:`disabledIfValue`,noStyle:!0,children:(0,u.jsx)(c.Input,{placeholder:`Value(s), comma for list`,style:{width:`25%`}})}):null})]})}),(0,u.jsx)(c.Form.Item,{name:`submitDisabledMessage`,label:`Disabled submit tooltip`,tooltip:`Shown on hover over the form's Create/Update button WHILE it is disabled, so the user knows why they can't submit. Leave blank for the built-in default.`,children:(0,u.jsx)(c.Input,{placeholder:`e.g. Complete all mandatory fields`,allowClear:!0})}),(0,u.jsx)(c.Form.Item,{name:`minRows`,label:`Min Rows`,tooltip:`Minimum rows users must keep. Delete is disabled at this count.`,children:(0,u.jsx)(c.Input,{type:`number`,min:0,style:{width:90}})}),(0,u.jsx)(c.Form.Item,{name:`maxRows`,label:`Max Rows`,tooltip:`Maximum rows users can add. The Add button hides once this count is reached. Blank/0 = unlimited.`,children:(0,u.jsx)(c.Input,{type:`number`,min:0,style:{width:90}})}),(0,u.jsx)(c.Form.Item,{name:`initialRows`,label:`Initial Rows`,tooltip:`How many empty rows to show on load (0 = show only the + button).`,children:(0,u.jsx)(c.Input,{type:`number`,min:0,style:{width:90}})}),(0,u.jsx)(c.Form.Item,{name:`requireOne`,label:`Row Required`,valuePropName:`checked`,tooltip:`When users add a row, at least one field in that row must be filled.`,children:(0,u.jsx)(c.Switch,{checkedChildren:`Yes`,unCheckedChildren:`No`})}),(0,u.jsx)(c.Form.Item,{name:`requireValidatedField`,label:`Require Validated Field`,tooltip:`A boolean field key on every row (e.g. isValid, set by a field's Verify action). The form's Submit button stays disabled until every row has it set to true. Blank = no gate.`,children:(0,u.jsx)(c.Input,{placeholder:`e.g. isValid`,style:{width:130},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:`allowInProgress`,label:`Allow "still ongoing" rows`,valuePropName:`checked`,initialValue:!0,tooltip:`Turn OFF where a person may only submit something they have FINISHED — for example a market where a company will not accept a course that is still being studied. When off, ticking the ongoing box on a row stops the form being submitted and shows the message below.`,children:(0,u.jsx)(c.Switch,{checkedChildren:`Allowed`,unCheckedChildren:`Must be finished`})}),(0,u.jsx)(c.Form.Item,{name:`inProgressMessage`,label:`Message when not allowed`,tooltip:`Shown when someone ticks the ongoing box in a market that does not accept it. Say what they should do, not just that it is wrong.`,style:{flex:`1 1 320px`},children:(0,u.jsx)(c.Input,{placeholder:`A completed qualification is required — an in-progress course cannot be submitted.`})}),(0,u.jsx)(c.Form.Item,{name:`orderByEnabled`,label:`Keep rows newest-first`,valuePropName:`checked`,tooltip:`Keeps this section's rows in date order with the most recent at the top. If someone fills in a row whose dates make it the newest, they are asked whether to move it up — nothing is ever reordered behind their back.`,children:(0,u.jsx)(c.Switch,{checkedChildren:`On`,unCheckedChildren:`Off`})}),(0,u.jsx)(c.Form.Item,{name:`levelRuleEnabled`,label:`Require lower levels too`,valuePropName:`checked`,tooltip:`For qualification lists. When on, entering only a higher qualification (a Master's) asks for the lower one (a Bachelor's) as well. Turn OFF for markets where a higher qualification alone is acceptable. The levels themselves are edited in Masters → Degree Level.`,children:(0,u.jsx)(c.Switch,{checkedChildren:`On`,unCheckedChildren:`Off`})}),(0,u.jsx)(c.Form.Item,{noStyle:!0,shouldUpdate:(e,t)=>e.fields!==t.fields,children:({getFieldValue:e})=>(0,u.jsx)(c.Form.Item,{name:`duplicateCheck`,label:`Duplicate check`,style:{flex:`1 1 100%`},tooltip:`Rules that decide whether a record being created (typed, or read from a résumé) already exists. Applies to the whole form — set it on one group. Overrides Automations → Duplicate check for this form.`,children:(0,u.jsx)(XC,{fieldKeys:(e(`fields`)??[]).map(e=>e?.field)})})}),(0,u.jsx)(c.Form.Item,{name:`linkGroup`,label:`Link Group`,tooltip:`Groups sharing the same value here stay row-synced — adding or removing a row in one adds/removes the matching row in every linked group, while each keeps its own card and its own submitted data. Leave blank for an independent group. Only applies when Allow Add Row is on.`,children:(0,u.jsx)(c.Input,{placeholder:`e.g. workHistory`,style:{width:160},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:`mergeInto`,label:`Show inside another section`,tooltip:`Display these fields inside a different section's card instead of giving them a card of their own — type that section's name. This only changes where they APPEAR: what gets saved, and any rules on this group, stay exactly as they are. Leave blank to keep its own card.`,children:(0,u.jsx)(c.Input,{placeholder:`e.g. submission_current_employer`,style:{width:220},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:`mergePosition`,label:`Merge Position`,initialValue:`bottom`,tooltip:`Whether these fields appear above or below the other card's own fields. Choose Above when this group holds the answer the other fields depend on — for example Contract Type, which decides what the Employer fields show. Below it, people are asked to fill in a section before they reach the box that unlocks it.`,children:(0,u.jsx)(c.Select,{style:{width:140},options:[{label:`Below host fields`,value:`bottom`},{label:`Above host fields`,value:`top`}]})}),(0,u.jsx)(c.Form.Item,{name:`infoEnabled`,label:`Group Info`,valuePropName:`checked`,initialValue:!1,children:(0,u.jsx)(c.Switch,{checkedChildren:`Info`,unCheckedChildren:`Info`})}),(0,u.jsx)(c.Form.Item,{name:`toggleEnabled`,label:`Group Switch`,valuePropName:`checked`,initialValue:!1,children:(0,u.jsx)(c.Switch,{checkedChildren:`On`,unCheckedChildren:`Off`})})]}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:0},className:`fg-group-conditional`,children:({getFieldValue:e})=>e(`infoEnabled`)?(0,u.jsx)(c.Form.Item,{name:`infoText`,label:`Group Info Message`,rules:[{required:!0,message:`Enter group info message`}],children:(0,u.jsx)(c.Input.TextArea,{rows:2,placeholder:`Message shown when users hover the group info icon`})}):null}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:0},className:`fg-group-conditional`,children:({getFieldValue:e})=>e(`toggleEnabled`)?(0,u.jsxs)(`div`,{className:`fg-inline-row`,children:[(0,u.jsx)(c.Form.Item,{name:`toggleLabel`,label:`Switch Label`,rules:[{required:!0,message:`Enter switch label`}],style:{flex:1},children:(0,u.jsx)(c.Input,{placeholder:`e.g. Fresher`})}),(0,u.jsx)(c.Form.Item,{name:`toggleField`,label:`Payload Field`,rules:[{required:!0,message:`Enter payload field`},{pattern:/^[A-Za-z_][\w.]*$/,message:`Use a valid key, dot path allowed`}],style:{flex:1},children:(0,u.jsx)(c.Input,{placeholder:`e.g. isFresher`,className:`fg-mono-input`})})]}):null}),(0,u.jsx)(`div`,{className:`fg-inline-row`,children:(0,u.jsx)(c.Form.Item,{name:`afterSubmitMode`,label:`After Submit`,tooltip:`What happens once this module's Add/Edit form submits successfully. Leave blank to keep the current default navigation.`,children:(0,u.jsx)(c.Select,{allowClear:!0,placeholder:`Default (current behavior)`,style:{width:220},options:[{value:`stay`,label:`Stay on Current Page`},{value:`back`,label:`Go Back`},{value:`route`,label:`Navigate to a Route`},{value:`detail`,label:`Navigate to Record Detail`}]})})}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:0},className:`fg-group-conditional`,children:({getFieldValue:e})=>{let t=e(`afterSubmitMode`);return t!==`route`&&t!==`detail`?null:(0,u.jsx)(c.Form.Item,{name:`afterSubmitTarget`,label:`Navigation Target`,tooltip:`An in-app path. Use :id for the created/updated record's id, or :fieldName for any submitted field value.`,rules:[{required:!0,message:`Enter a navigation target`},{pattern:/^\//,message:`Must be an in-app path starting with /`}],children:(0,u.jsx)(c.Input,{placeholder:`/trainers/:id`,className:`fg-mono-input`})})}}),(0,u.jsx)(c.Form.Item,{label:`Additional submit buttons`,tooltip:`Extra buttons beside Create — each creates the record then navigates per its own After-Submit, optionally enabled only once a field is filled.`,children:(0,u.jsx)(c.Form.List,{name:`formActions`,children:(e,{add:t,remove:n})=>(0,u.jsxs)(`div`,{className:`fg-form-actions-list`,children:[e.map(({key:e,name:t})=>(0,u.jsxs)(`div`,{className:`fg-form-action-row`,style:{border:`1px solid #eee`,borderRadius:8,padding:10,marginBottom:8},children:[(0,u.jsxs)(c.Space,{wrap:!0,align:`start`,children:[(0,u.jsx)(c.Form.Item,{name:[t,`label`],label:`Button Label`,rules:[{required:!0,message:`Label`}],style:{marginBottom:8},children:(0,u.jsx)(c.Input,{placeholder:`e.g. Create and Source Candidate`,style:{width:240}})}),(0,u.jsx)(c.Form.Item,{name:[t,`tone`],label:`Type`,style:{marginBottom:8},children:(0,u.jsx)(c.Select,{style:{width:130},options:[{value:`primary`,label:`Primary`},{value:`default`,label:`Secondary`}]})}),(0,u.jsx)(c.Form.Item,{name:[t,`afterSubmitMode`],label:`After Submit`,style:{marginBottom:8},children:(0,u.jsx)(c.Select,{style:{width:180},options:[{value:`stay`,label:`Stay on page`},{value:`back`,label:`Go back`},{value:`route`,label:`Navigate to a route`},{value:`detail`,label:`Record detail`}]})}),(0,u.jsx)(c.Form.Item,{noStyle:!0,shouldUpdate:!0,children:({getFieldValue:e})=>[`route`,`detail`].includes(e([`formActions`,t,`afterSubmitMode`]))?(0,u.jsx)(c.Form.Item,{name:[t,`afterSubmitTarget`],label:`Target`,style:{marginBottom:8},rules:[{pattern:/^\//,message:`Must start with /`}],children:(0,u.jsx)(c.Input,{placeholder:`/jobs/:id/source`,className:`fg-mono-input`,style:{width:200}})}):null}),(0,u.jsx)(c.Button,{type:`text`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{}),onClick:()=>n(t),style:{marginTop:28}})]}),(0,u.jsxs)(c.Space,{wrap:!0,align:`start`,children:[(0,u.jsx)(c.Form.Item,{name:[t,`enabledWhenField`],label:`Enable when field`,style:{marginBottom:0},tooltip:`Keep the button disabled until this record field satisfies the condition (e.g. Assign To is set). Blank = always enabled.`,children:(0,u.jsx)(c.Input,{placeholder:`e.g. assignedTo`,style:{width:200}})}),(0,u.jsx)(c.Form.Item,{name:[t,`enabledWhenOperator`],label:`Condition`,style:{marginBottom:0},children:(0,u.jsx)(c.Select,{style:{width:130},options:[{value:`notEmpty`,label:`is set`},{value:`isEmpty`,label:`is empty`},{value:`eq`,label:`equals`},{value:`neq`,label:`not equals`},{value:`in`,label:`in list`},{value:`notIn`,label:`not in list`}]})}),(0,u.jsx)(c.Form.Item,{noStyle:!0,shouldUpdate:!0,children:({getFieldValue:e})=>[`eq`,`neq`,`in`,`notIn`].includes(e([`formActions`,t,`enabledWhenOperator`]))?(0,u.jsx)(c.Form.Item,{name:[t,`enabledWhenValue`],label:`Value`,style:{marginBottom:0},children:(0,u.jsx)(c.Input,{placeholder:`Value(s)`,style:{width:160}})}):null})]})]},e)),(0,u.jsx)(c.Button,{type:`dashed`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>t({tone:`primary`,afterSubmitMode:`stay`,enabledWhenOperator:`notEmpty`}),children:`Add submit button`})]})})}),(0,u.jsxs)(`div`,{className:`fg-inline-row`,children:[(0,u.jsx)(c.Form.Item,{name:`submitMsgAddSuccess`,label:`Add Success Message`,tooltip:'Toast shown after a successful Add. ${module} is replaced with the module name. Blank = default "<Module> has added successfully".',children:(0,u.jsx)(c.Input,{placeholder:"${module} has added successfully",style:{width:280}})}),(0,u.jsx)(c.Form.Item,{name:`submitMsgEditSuccess`,label:`Edit Success Message`,tooltip:'Toast shown after a successful Edit. ${module} is replaced with the module name. Blank = default "<Module> has Updated successfully".',children:(0,u.jsx)(c.Input,{placeholder:"${module} has Updated successfully",style:{width:280}})})]}),(0,u.jsxs)(`div`,{className:`fg-inline-row`,children:[(0,u.jsx)(c.Form.Item,{name:`submitMsgAddError`,label:`Add Error Message`,tooltip:`Toast shown when Add fails. Blank = show the server's error.`,children:(0,u.jsx)(c.Input,{placeholder:`Server error (default)`,style:{width:280}})}),(0,u.jsx)(c.Form.Item,{name:`submitMsgEditError`,label:`Edit Error Message`,tooltip:`Toast shown when Edit fails. Blank = show the server's error.`,children:(0,u.jsx)(c.Input,{placeholder:`Server error (default)`,style:{width:280}})}),(0,u.jsx)(c.Form.Item,{name:`submitMsgSuppress`,label:`Hide Success Toast`,valuePropName:`checked`,tooltip:`Prevent the success message for this module's Add/Edit (errors always show).`,children:(0,u.jsx)(c.Switch,{checkedChildren:`Hidden`,unCheckedChildren:`Shown`})})]})]}),(0,u.jsxs)(`div`,{className:`fg-editor-next-row`,children:[(0,u.jsx)(QC,{type:`secondary`,children:`Next, review the fields included in this group.`}),(0,u.jsx)(c.Button,{type:`primary`,onClick:()=>R(`fields`),children:`Continue to Fields`})]})]}),A&&(0,u.jsxs)(`div`,{className:`fg-group-editor-panel${O===`fields`?` is-active`:``}`,children:[(0,u.jsxs)(`div`,{className:`fg-fields-header`,children:[(0,u.jsx)(`span`,{className:`fg-fields-title`,children:`Fields`}),(0,u.jsx)(`span`,{className:`fg-fields-hint`,children:`Open only the field you want to change`}),b&&(0,u.jsx)(c.Spin,{size:`small`}),!b&&te.length>0&&(0,u.jsxs)(`span`,{className:`fg-fields-hint`,children:[te.length,` fields available`]})]}),(0,u.jsx)(c.Form.List,{name:`fields`,children:(e,{add:t,remove:n,move:i})=>Hw({form:p,fieldItems:e,add:t,remove:n,move:i,absBase:[],moduleFieldOptions:te,fieldsLoading:b,dragIndexRef:N,dragOverIndex:w,setDragOverIndex:T,onFieldKeySelect:(e,t)=>V(e,t),expandedFieldKeys:E,onToggleField:z,defaultFieldRules:S,uniqueTarget:{primaryModule:p.getFieldValue(`module`)||r||``,getTargetModule:()=>p.getFieldValue(`moduleName`)||``,collectionForModule:P}})})]})]})})}function Ww({groups:e,onEdit:t,onDelete:n,onCopy:r,onPaste:i,canPaste:a,onReorder:o}){let d=(0,s.useRef)(null),f=[...e].sort((e,t)=>(e.order??0)-(t.order??0)),p=typeof o==`function`&&f.length>1,m=(e,t)=>{let n=[...f],[r]=n.splice(e,1);n.splice(t,0,r),o(n)},h=(0,s.useMemo)(()=>{function e({"data-row-index":e,...t}){return e===void 0?(0,u.jsx)(`tr`,{...t}):(0,u.jsx)(`tr`,{...t,draggable:!0,onDragStart:()=>{d.current=e},onDragOver:e=>{e.preventDefault()},onDrop:t=>{t.preventDefault();let n=d.current;d.current=null,n!==null&&n!==e&&m(n,e)},style:{...t.style||{},cursor:`grab`}})}return e},[f,o]),g=[...p?[{title:``,key:`drag`,width:34,align:`center`,render:()=>(0,u.jsx)(l.HolderOutlined,{className:`fg-drag-handle`,style:{cursor:`grab`,color:`var(--color-text-secondary)`}})}]:[],{title:`Label`,dataIndex:`label`,key:`label`,render:(e,t)=>(0,u.jsxs)(c.Space,{size:6,children:[(0,u.jsx)(QC,{strong:!0,style:{color:`var(--color-text-heading)`},children:e}),t.hideGroup&&(0,u.jsx)(c.Tag,{color:`default`,children:`Hidden`}),!t.hideGroup&&t.hideGroupInForm&&(0,u.jsx)(c.Tag,{color:`default`,children:`Detail only`}),t.moduleName&&(0,u.jsxs)(c.Tag,{color:`purple`,children:[`→ `,t.moduleName]}),t.hierarchyParent&&(0,u.jsxs)(c.Tag,{color:`gold`,children:[`L`,t.hierarchyLevel??`?`,` ← `,t.hierarchyParent]})]})},{title:`Key`,dataIndex:`name`,key:`name`,render:e=>(0,u.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Add Row`,dataIndex:`addRow`,key:`addRow`,align:`center`,width:90,render:e=>e?(0,u.jsx)(c.Tag,{color:`blue`,style:{margin:0},children:`Yes`}):(0,u.jsx)(c.Tag,{color:`default`,style:{margin:0},children:`No`})},{title:`Order`,dataIndex:`order`,key:`order`,align:`center`,width:72,render:e=>(0,u.jsx)(`span`,{className:`fg-order-cell`,children:e??0})},{title:`Fields`,dataIndex:`fields`,key:`fields`,align:`center`,width:76,render:e=>(0,u.jsx)(c.Badge,{count:e?.length??0,showZero:!0,color:`var(--color-brand)`})},{title:``,key:`actions`,align:`right`,width:132,render:(e,o)=>(0,u.jsxs)(c.Space,{size:4,children:[(0,u.jsx)(c.Tooltip,{title:`Copy settings`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,icon:(0,u.jsx)(l.CopyOutlined,{}),onClick:()=>r(o),className:`fg-action-btn`})}),(0,u.jsx)(c.Tooltip,{title:`Paste copied settings into this group`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,icon:(0,u.jsx)(l.SnippetsOutlined,{}),disabled:!a,onClick:()=>i(o),className:`fg-action-btn`})}),(0,u.jsx)(c.Tooltip,{title:`Edit group`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>t(o),className:`fg-action-btn`})}),(0,u.jsx)(c.Popconfirm,{title:`Delete this group?`,description:`All field mappings inside will be removed.`,onConfirm:()=>n(o.id),okText:`Delete`,okButtonProps:{danger:!0},children:(0,u.jsx)(c.Tooltip,{title:`Delete group`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{}),className:`fg-action-btn`})})})]})}];return(0,u.jsx)(c.Table,{rowKey:e=>e.id??e.name,dataSource:f,columns:g,pagination:!1,className:`fg-table`,components:p?{body:{row:h}}:void 0,onRow:p?(e,t)=>({"data-row-index":t,dragCtx:{from:d,onMove:m}}):void 0,locale:{emptyText:(0,u.jsx)(c.Empty,{description:`No groups configured for this module yet.`,image:c.Empty.PRESENTED_IMAGE_SIMPLE,style:{padding:`24px 0`}})},expandable:{expandedRowRender:e=>(e.fields??[]).length===0?(0,u.jsx)(QC,{type:`secondary`,style:{fontSize:12},children:`No fields in this group.`}):(0,u.jsx)(`div`,{className:`fg-expanded-fields`,children:(e.fields??[]).map(e=>{let t={master:`geekblue`,module:`cyan`,lookup:`volcano`,static:`default`},n={master:`master: ${e.masterName||`?`}`,module:`module`,lookup:`lookup: ${e.lookupCollection||`?`} → ${e.displayField||`?`}`,static:`static (${(e.options??[]).length})`};return(0,u.jsxs)(`div`,{className:`fg-field-row`,children:[(0,u.jsxs)(`div`,{className:`fg-field-row-info`,children:[(0,u.jsx)(`span`,{className:`fg-field-row-label`,children:e.label}),(0,u.jsx)(`span`,{className:`fg-field-row-key`,children:e.field}),(0,u.jsxs)(`span`,{className:`fg-field-row-type`,children:[`(`,e.type,`)`]}),[`select`,`radio`,`checkbox`].includes(e.type)&&e.dataSource&&(0,u.jsx)(c.Tag,{color:t[e.dataSource]??`default`,style:{fontSize:10,marginLeft:6},children:n[e.dataSource]??e.dataSource})]}),(0,u.jsxs)(`div`,{className:`fg-field-row-flags`,children:[e.show===1&&(0,u.jsx)(c.Tag,{color:`blue`,style:{marginRight:4},children:`Show`}),e.showOnAdd===!1&&(0,u.jsx)(c.Tag,{color:`orange`,style:{marginRight:4},children:`Edit only`}),e.req===1&&(0,u.jsx)(c.Tag,{color:`red`,style:{marginRight:4},children:`Required`}),e.edit===1&&(0,u.jsx)(c.Tag,{color:`green`,style:{marginRight:4},children:`Editable`}),e.formatter&&(0,u.jsxs)(c.Tag,{color:`purple`,style:{marginRight:4},children:[`fmt: `,e.formatter]})]}),(e.validations??[]).length>0&&(0,u.jsxs)(`div`,{className:`fg-field-row-validations`,children:[(0,u.jsx)(l.CheckCircleOutlined,{style:{color:`var(--color-brand)`,fontSize:11,marginRight:4}}),(e.validations??[]).map((t,n)=>{let r=t.type===`unique`,i=r?String(t.value?.collectionField??e.payloadKey??e.field??``):t.value,a=i!==void 0&&i!==``?i:t.field??``,o=r?`Stored field`:t.field&&(t.value===void 0||t.value===``)?`Field`:`Value`;return(0,u.jsx)(c.Tooltip,{title:`${a===``?``:`${o}: ${a} — `}${t.message}`,children:(0,u.jsxs)(c.Tag,{color:vw[t.type]??`default`,style:{cursor:`default`,fontFamily:`monospace`,fontSize:10},children:[t.type,a===``?``:`(${a})`]})},n)})]})]},e.field)})}),rowExpandable:()=>!0}})}function Gw({open:e,editingForm:t,moduleOptions:r,onClose:i,onSaved:a}){let[o]=c.Form.useForm(),[d,f]=(0,s.useState)(!1),[p,m]=(0,s.useState)(``),[h,g]=(0,s.useState)({}),[_,v]=(0,s.useState)(!1),[y,b]=(0,s.useState)(null),x=(0,s.useRef)({}),S=(0,s.useRef)(null),C=Vw();async function w(e){if(!(!e||x.current[e])){v(!0);try{let t=await n.hi(e);g(n=>({...n,[e]:t})),x.current[e]=!0}catch{}finally{v(!1)}}}(0,s.useEffect)(()=>{if(!e){x.current={},g({});return}if(t){let e=t.module;m(e),o.setFieldsValue({module:e,formType:t.formType||`popup`,action:t.action,label:t.label,booleanSearchEnabled:t.booleanSearchEnabled??!1,booleanSearchEndpoint:t.booleanSearchEndpoint??``,booleanDefaultSourceType:t.booleanDefaultSourceType??``,searchEndpoint:t.searchEndpoint??``,resultsDefaultView:r_(t),detailViewOpenMode:n.yr(t.detailViewOpenMode),resultsSearchPlaceholder:t.resultsSearchPlaceholder??``,actionButtonEnabled:t.actionButtonEnabled??!1,actionButtonLabel:t.actionButtonLabel??``,actionButtonUrl:t.actionButtonUrl??``,actionButtonTarget:t.actionButtonTarget??`_self`,actionButtonOpenAs:Jg({openAs:t.actionButtonOpenAs,target:t.actionButtonTarget}),groups:(t.groups??[]).map(e=>({...e,hideGroup:e.hideGroup??!1,hideGroupInForm:e.hideGroupInForm??!1,moduleName:e.moduleName??``,infoEnabled:e.infoEnabled??!1,infoText:e.infoText??``,minRows:e.minRows??``,initialRows:e.initialRows??``,requireOne:e.requireOne??!1,linkGroup:e.linkGroup??``,toggleEnabled:e.toggleEnabled??!1,toggleLabel:e.toggleLabel??``,toggleField:e.toggleField??``,fields:(e.fields??[]).map(zw)}))}),w(e)}else o.resetFields(),o.setFieldsValue({groups:[],formType:`popup`}),m(``)},[e,t,o]);function T(e){m(e),w(e)}function E(){return(h[p]??[]).map(e=>({value:e.value,label:(0,u.jsxs)(`span`,{children:[e.label,(0,u.jsx)(`span`,{className:`fg-field-key-hint`,children:e.value})]}),searchLabel:`${e.label} ${e.value}`.toLowerCase()}))}async function D(){try{let e=await o.validateFields(),r=(e.groups??[]).flatMap(e=>kw(e?.fields));if(r.length){c.message.error(`Uniqueness rule cannot be saved — ${r[0]}`);return}f(!0);let i={module:e.module,formType:e.formType,action:e.action.trim(),label:e.label,...e.formType===`search`&&e.booleanSearchEnabled?{booleanSearchEnabled:!0,booleanSearchEndpoint:String(e.booleanSearchEndpoint??``).trim(),...e.booleanDefaultSourceType?{booleanDefaultSourceType:e.booleanDefaultSourceType}:{}}:{},searchEndpoint:e.formType===`search`?String(e.searchEndpoint??``).trim():``,...e.formType===`search`?{resultsDefaultView:e.resultsDefaultView||`card`,detailViewOpenMode:e.detailViewOpenMode||`popup`,resultsSearchPlaceholder:String(e.resultsSearchPlaceholder??``).trim()}:{},actionButtonEnabled:!!e.actionButtonEnabled,actionButtonLabel:String(e.actionButtonLabel??``).trim(),actionButtonUrl:String(e.actionButtonUrl??``).trim(),actionButtonOpenAs:e.actionButtonOpenAs||`self`,actionButtonTarget:e.actionButtonOpenAs===`newTab`?`_blank`:`_self`,groups:(e.groups??[]).map(e=>({label:e.label,name:e.name,addRow:e.addRow??!1,...e.hideGroup?{hideGroup:!0}:{},...e.hideGroupInForm?{hideGroupInForm:!0}:{},...e.moduleName?{moduleName:e.moduleName}:{},...e.moduleName&&(e.writeRefs??[]).length?{writeRefs:e.writeRefs}:{},...e.moduleName&&(e.dependsOn??[]).length?{dependsOn:e.dependsOn}:{},...e.moduleName&&e.optionalWrite?{optionalWrite:!0}:{},...e.moduleName&&e.linkField?{linkField:e.linkField}:{},...e.moduleName&&e.linkTypeField?{linkTypeField:e.linkTypeField}:{},...e.moduleName&&e.parentRefField?{parentRefField:e.parentRefField}:{},...e.moduleName&&e.hierarchyParent&&e.hierarchyLinkField?{hierarchyParent:e.hierarchyParent,hierarchyLinkField:e.hierarchyLinkField}:{},...e.moduleName&&Number.isFinite(Number(e.hierarchyLevel))&&Number(e.hierarchyLevel)>0?{hierarchyLevel:Number(e.hierarchyLevel)}:{},...e.appendHistory&&e.historyField?{appendHistory:!0,historyField:e.historyField,...e.historyTimestampField?{historyTimestampField:e.historyTimestampField}:{}}:{},...e.addRow&&e.minRows!==void 0&&e.minRows!==``?{minRows:Number(e.minRows)}:{},...e.addRow&&e.initialRows!==void 0&&e.initialRows!==``?{initialRows:Number(e.initialRows)}:{},...e.addRow&&e.requireOne?{requireOne:!0}:{},...e.addRow&&e.linkGroup?{linkGroup:e.linkGroup.trim()}:{},order:Number(e.order??0),fields:Pw(e.fields??[]),...e.infoEnabled&&e.infoText?{infoEnabled:!0,infoText:e.infoText}:{}}))};t?(await n.Vi(t.id,{...t,...i}),c.message.success(`Custom form updated`)):(await n.wr(i),c.message.success(`Custom form created`)),a()}catch(e){if(e?.errorFields)return;c.message.error(e.message||`Could not save custom form`)}finally{f(!1)}}let O=E();return(0,u.jsx)(c.Modal,{open:e,onCancel:i,width:1120,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,u.jsxs)(`span`,{className:`fg-drawer-title`,children:[t?(0,u.jsx)(l.EditOutlined,{}):(0,u.jsx)(l.PlusOutlined,{}),t?` Edit Custom Form`:` New Custom Form`]}),footer:(0,u.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,u.jsx)(c.Button,{onClick:i,children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,loading:d,onClick:D,icon:t?(0,u.jsx)(l.EditOutlined,{}):(0,u.jsx)(l.PlusOutlined,{}),children:t?`Update`:`Create`})]}),children:(0,u.jsxs)(c.Form,{form:o,layout:`vertical`,className:`fg-form fg-editor-form`,children:[(0,u.jsxs)(`div`,{className:`fg-form-section fg-editor-sticky-section`,children:[(0,u.jsx)(`div`,{className:`fg-form-section-label`,children:`Form Identity`}),(0,u.jsx)(c.Form.Item,{name:`module`,label:`Module`,rules:[{required:!0,message:`Select a module`}],children:(0,u.jsx)(c.Select,{options:r,placeholder:`Select module`,onChange:T})}),(0,u.jsx)(c.Form.Item,{name:`formType`,label:`Form Type`,rules:[{required:!0,message:`Form Type is required`}],initialValue:`popup`,children:(0,u.jsx)(c.Select,{placeholder:`Select form type`,options:[{label:`Search`,value:`search`},{label:`Popup`,value:`popup`}]})}),(0,u.jsx)(c.Form.Item,{name:`action`,label:`Action Key`,extra:`Unique identifier used as ?action= in the URL (e.g. quickAdd, popup)`,rules:[{required:!0,message:`Action is required`},{pattern:/^[a-zA-Z0-9_-]+$/,message:`Letters, numbers, hyphens, underscores only`}],children:(0,u.jsx)(c.Input,{placeholder:`e.g. quickAdd`,className:`fg-mono-input`,disabled:!!t})}),(0,u.jsx)(c.Form.Item,{name:`label`,label:`Display Label`,rules:[{required:!0,message:`Label is required`}],children:(0,u.jsx)(c.Input,{placeholder:`e.g. Quick Add Job`})}),(0,u.jsx)(c.Form.Item,{noStyle:!0,shouldUpdate:!0,children:({getFieldValue:e})=>{if(e(`formType`)!==`search`)return null;let t=e(`booleanSearchEnabled`);return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Form.Item,{name:`searchEndpoint`,label:`Search Endpoint`,extra:`Routes every search on this form — traditional and boolean — through one endpoint. Leave blank to use the common module list API.`,children:(0,u.jsx)(c.Input,{placeholder:`/candidates/boolean-search`,className:`fg-mono-input`,allowClear:!0})}),(0,u.jsx)(c.Form.Item,{name:`resultsDefaultView`,label:`Results Default View`,initialValue:`card`,extra:`How the results arrive. Users can still switch with the view toggle; this is only where they start.`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:180},options:e_})}),(0,u.jsx)(c.Form.Item,{name:`detailViewOpenMode`,label:`Detail View Opens As`,initialValue:`popup`,extra:`How a result row opens the record's detail view. 'Popup' keeps this search — and every typed filter — mounted behind a modal. 'Same page' navigates away.`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:180},options:n.gr})}),(0,u.jsx)(c.Form.Item,{name:`resultsSearchPlaceholder`,label:`Results Search Placeholder`,extra:`Text in the results search box, e.g. what it searches. Leave blank for the built-in default, which spells out that the box needs 3 characters and Enter — worth saying in your own wording too.`,children:(0,u.jsx)(c.Input,{placeholder:`Search by Name, Skill, Designation, Location`,allowClear:!0})}),(0,u.jsx)(c.Form.Item,{name:`booleanSearchEnabled`,label:`Enable Boolean Search`,valuePropName:`checked`,initialValue:!1,extra:`Adds a Boolean toggle to this search form. Off means the form behaves exactly as it does today.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`On`,unCheckedChildren:`Off`})}),t&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Form.Item,{name:`booleanSearchEndpoint`,label:`Boolean Endpoint`,rules:[{required:!0,message:`Required while Boolean Search is enabled`}],extra:`Backend path used in Boolean mode, e.g. /candidates/boolean-search`,children:(0,u.jsx)(c.Input,{placeholder:`/candidates/boolean-search`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:`booleanDefaultSourceType`,label:`Default Source Type`,extra:`Sent as sourceType when the form has no source field. Leave blank for 'internal'.`,children:(0,u.jsx)(c.Input,{placeholder:`internal,dice`,className:`fg-mono-input`})})]})]})}}),(0,u.jsx)(c.Form.Item,{noStyle:!0,shouldUpdate:!0,children:({getFieldValue:e})=>(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Form.Item,{name:`actionButtonEnabled`,label:`Show Link Button`,valuePropName:`checked`,initialValue:!1,extra:`Adds one button beside Reset/Search that navigates to another screen. Off means no button renders at all.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`On`,unCheckedChildren:`Off`})}),e(`actionButtonEnabled`)&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Form.Item,{name:`actionButtonLabel`,label:`Button Label`,rules:[{required:!0,message:`Required while the link button is on`}],extra:`Text shown on the button, e.g. Job Description`,children:(0,u.jsx)(c.Input,{placeholder:`Job Description`})}),(0,u.jsx)(c.Form.Item,{name:`actionButtonUrl`,label:`Destination`,rules:[{required:!0,message:`Required while the link button is on`},{validator:(e,t)=>{let n=String(t??``).trim();return n?!n.startsWith(`/`)||n.startsWith(`//`)?Promise.reject(Error(`Must be an in-app path starting with a single /`)):/^[a-z][a-z0-9+.-]*:/i.test(n)?Promise.reject(Error(`External and scheme: URLs are not allowed`)):Promise.resolve():Promise.resolve()}}],extra:`In-app path. :tokens resolve against the record the search runs for, e.g. /jobs/detailview?id=:jobId&tab=details`,children:(0,u.jsx)(c.Input,{placeholder:`/jobs/detailview?id=:jobId&tab=details`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:`actionButtonOpenAs`,label:`Opens As`,initialValue:`self`,extra:`Popup shows the destination page inside the search screen, so the criteria and the results survive.`,children:(0,u.jsx)(c.Select,{size:`small`,style:{width:180},options:Kg})})]})]})})]}),(0,u.jsxs)(`div`,{className:`fg-fields-header`,children:[(0,u.jsx)(`span`,{className:`fg-fields-title`,children:`Groups`}),(0,u.jsx)(`span`,{className:`fg-fields-hint`,children:`Each group holds a set of form fields`}),_&&(0,u.jsx)(c.Spin,{size:`small`})]}),(0,u.jsx)(c.Form.List,{name:`groups`,children:(e,{add:t,remove:n})=>(0,u.jsxs)(u.Fragment,{children:[e.map(({key:e,name:t})=>(0,u.jsxs)(`div`,{className:`fg-form-section`,style:{marginBottom:16},children:[(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:10},children:[(0,u.jsxs)(`span`,{className:`fg-form-section-label`,style:{marginBottom:0},children:[`Group `,t+1]}),(0,u.jsx)(c.Tooltip,{title:`Remove group`,children:(0,u.jsx)(`button`,{type:`button`,className:`fg-field-remove-btn`,onClick:()=>n(t),"aria-label":`Remove group`,children:(0,u.jsx)(l.MinusCircleOutlined,{})})})]}),(0,u.jsxs)(`div`,{className:`fg-inline-row`,style:{flexWrap:`wrap`,marginBottom:8},children:[(0,u.jsx)(c.Form.Item,{name:[t,`label`],label:`Group Label`,rules:[{required:!0,message:`Required`}],style:{flex:2,marginBottom:8},children:(0,u.jsx)(c.Input,{placeholder:`e.g. Basic Info`})}),(0,u.jsx)(c.Form.Item,{name:[t,`name`],label:`Group Key`,rules:[{required:!0,message:`Required`},{pattern:/^[a-z0-9_]+$/,message:`Lowercase, numbers, underscores`}],style:{flex:2,marginBottom:8},children:(0,u.jsx)(c.Input,{placeholder:`e.g. basicInfo`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[t,`addRow`],label:`Add Row`,valuePropName:`checked`,initialValue:!1,style:{marginBottom:8},children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Yes`,unCheckedChildren:`No`})}),(0,u.jsx)(c.Form.Item,{name:[t,`hideGroup`],label:`Hide Group`,valuePropName:`checked`,initialValue:!1,style:{marginBottom:8},tooltip:`Hide this group entirely from Add/Edit forms — not rendered, not validated, not submitted.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Hidden`,unCheckedChildren:`Visible`})}),(0,u.jsx)(c.Form.Item,{name:[t,`moduleName`],label:`Target Collection`,style:{marginBottom:8,flex:2},tooltip:`Route THIS group's fields to a different collection instead of the default module record. Leave blank for default behaviour.`,children:(0,u.jsx)(c.AutoComplete,{size:`small`,options:r.map(e=>({value:e.value,label:e.label})),placeholder:`Default`,allowClear:!0,filterOption:(e,t)=>(t?.value??``).toLowerCase().includes(e.toLowerCase()),className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[t,`minRows`],label:`Min Rows`,style:{marginBottom:8},tooltip:`Minimum rows users must keep. Delete is disabled at this count.`,children:(0,u.jsx)(c.Input,{type:`number`,min:0,style:{width:80}})}),(0,u.jsx)(c.Form.Item,{name:[t,`initialRows`],label:`Initial Rows`,style:{marginBottom:8},tooltip:`How many empty rows to show on load (0 = show only the + button).`,children:(0,u.jsx)(c.Input,{type:`number`,min:0,style:{width:80}})}),(0,u.jsx)(c.Form.Item,{name:[t,`requireOne`],label:`Row Required`,valuePropName:`checked`,initialValue:!1,style:{marginBottom:8},tooltip:`When users add a row, at least one field in that row must be filled.`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Yes`,unCheckedChildren:`No`})}),(0,u.jsx)(c.Form.Item,{name:[t,`linkGroup`],label:`Link Group`,style:{marginBottom:8},tooltip:`Groups sharing the same value here stay row-synced — adding or removing a row in one adds/removes the matching row in every linked group, while each keeps its own card and its own submitted data. Leave blank for an independent group.`,children:(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. workHistory`,style:{width:130},className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:[t,`infoEnabled`],label:`Group Info`,valuePropName:`checked`,initialValue:!1,style:{marginBottom:8},children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Info`,unCheckedChildren:`Info`})}),(0,u.jsx)(c.Form.Item,{name:[t,`toggleEnabled`],label:`Group Switch`,valuePropName:`checked`,initialValue:!1,style:{marginBottom:8},children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`On`,unCheckedChildren:`Off`})}),(0,u.jsx)(c.Form.Item,{name:[t,`order`],label:`Order`,initialValue:0,style:{marginBottom:8},children:(0,u.jsx)(c.Input,{type:`number`,min:0,style:{width:70}})})]}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:8},children:({getFieldValue:e})=>e([`groups`,t,`infoEnabled`])?(0,u.jsx)(c.Form.Item,{name:[t,`infoText`],label:`Group Info Message`,rules:[{required:!0,message:`Enter group info message`}],children:(0,u.jsx)(c.Input.TextArea,{rows:2,placeholder:`Message shown when users hover the group info icon`})}):null}),(0,u.jsx)(c.Form.Item,{shouldUpdate:!0,style:{marginBottom:8},children:({getFieldValue:e})=>e([`groups`,t,`toggleEnabled`])?(0,u.jsxs)(`div`,{className:`fg-inline-row`,children:[(0,u.jsx)(c.Form.Item,{name:[t,`toggleLabel`],label:`Switch Label`,rules:[{required:!0,message:`Enter switch label`}],style:{flex:1,marginBottom:0},children:(0,u.jsx)(c.Input,{placeholder:`e.g. Fresher`})}),(0,u.jsx)(c.Form.Item,{name:[t,`toggleField`],label:`Payload Field`,rules:[{required:!0,message:`Enter payload field`},{pattern:/^[A-Za-z_][\w.]*$/,message:`Use a valid key, dot path allowed`}],style:{flex:1,marginBottom:0},children:(0,u.jsx)(c.Input,{placeholder:`e.g. isFresher`,className:`fg-mono-input`})})]}):null}),(0,u.jsx)(`div`,{className:`fg-fields-header`,style:{marginTop:4,marginBottom:8},children:(0,u.jsx)(`span`,{className:`fg-fields-title`,style:{fontSize:12},children:`Fields`})}),(0,u.jsx)(c.Form.List,{name:[t,`fields`],children:(e,{add:n,remove:r,move:i})=>Hw({form:o,fieldItems:e,add:n,remove:r,move:i,absBase:[`groups`,t],moduleFieldOptions:O,fieldsLoading:_,dragIndexRef:S,dragOverIndex:y,setDragOverIndex:b,onFieldKeySelect:(e,n)=>{let r=(h[p]??[]).find(t=>t.value===e);if(!r)return;let i=o.getFieldValue([`groups`,t,`fields`,n])??{};o.setFieldValue([`groups`,t,`fields`,n],{...i,field:r.value,label:r.label,type:r.type??`text`})},uniqueTarget:{primaryModule:p||``,getTargetModule:()=>o.getFieldValue([`groups`,t,`moduleName`])||``,collectionForModule:C}})})]},e)),(0,u.jsx)(c.Button,{type:`dashed`,icon:(0,u.jsx)(l.PlusOutlined,{}),block:!0,style:{marginBottom:16},onClick:()=>t({label:``,name:``,addRow:!1,order:e.length,fields:[]}),children:`Add Group`})]})})]})})}function Kw({moduleOptions:e}){let[t,r]=(0,s.useState)([]),[i,a]=(0,s.useState)(!1),[o,d]=(0,s.useState)(!1),[f,p]=(0,s.useState)(null);function m(){a(!0),n.ei().then(e=>r(e)).catch(e=>c.message.error(e.message||`Could not load custom forms`)).finally(()=>a(!1))}(0,s.useEffect)(()=>{m()},[]);async function h(e){try{await n.Mr(e.id),c.message.success(`Custom form deleted`),m()}catch(e){c.message.error(e.message||`Could not delete custom form`)}}return(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`div`,{className:`fg-tab-toolbar`,style:{marginBottom:12},children:(0,u.jsx)(c.Button,{type:`primary`,size:`small`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>{p(null),d(!0)},children:`New Custom Form`})}),(0,u.jsx)(c.Spin,{spinning:i,children:(0,u.jsx)(c.Table,{rowKey:e=>e.id??e.action,dataSource:t,columns:[{title:`Module`,dataIndex:`module`,key:`module`,render:e=>(0,u.jsx)(c.Tag,{color:`blue`,children:e})},{title:`Action Key`,dataIndex:`action`,key:`action`,render:e=>(0,u.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Label`,dataIndex:`label`,key:`label`,render:e=>(0,u.jsx)(QC,{strong:!0,style:{color:`var(--color-text-heading)`},children:e})},{title:`Groups`,dataIndex:`groups`,key:`groups`,align:`center`,width:76,render:e=>(0,u.jsx)(c.Badge,{count:e?.length??0,showZero:!0,color:`var(--color-brand)`})},{title:``,key:`actions`,align:`right`,width:100,render:(e,t)=>(0,u.jsxs)(c.Space,{size:4,children:[(0,u.jsx)(c.Tooltip,{title:`Edit form`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>{p(t),d(!0)},className:`fg-action-btn`})}),(0,u.jsx)(c.Popconfirm,{title:`Delete this custom form?`,description:`All configured groups will be lost.`,onConfirm:()=>h(t),okText:`Delete`,okButtonProps:{danger:!0},children:(0,u.jsx)(c.Tooltip,{title:`Delete form`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{}),className:`fg-action-btn`})})})]})}],pagination:!1,className:`fg-table`,locale:{emptyText:(0,u.jsx)(c.Empty,{description:`No custom forms yet. Click 'New Custom Form' to create one.`,image:c.Empty.PRESENTED_IMAGE_SIMPLE,style:{padding:`24px 0`}})}})}),(0,u.jsx)(Gw,{open:o,editingForm:f,moduleOptions:e,onClose:()=>{d(!1),p(null)},onSaved:()=>{d(!1),p(null),m()}})]})}function qw(){let[e,t]=(0,s.useState)([]),[r,i]=(0,s.useState)(!0),[a,o]=(0,s.useState)({}),[d,f]=(0,s.useState)(`all`),[p,m]=(0,s.useState)(!1),[h,g]=(0,s.useState)(null),[_,v]=(0,s.useState)(null),[y,b]=(0,s.useState)(`module`),[x,S]=(0,s.useState)([]),[C,w]=(0,s.useState)({clientId:``,region:``}),[T,E]=(0,s.useState)(!1),[D,O]=(0,s.useState)(null),k=bw(e),A=e.map(e=>({value:e.key,label:e.label}));(0,s.useEffect)(()=>{n.Xr().then(e=>{let n=qS(e).map(({value:e,label:t})=>({key:e,label:t}));t(n);let r=bw(n);o(xw(r)),F(`all`,r)}).catch(()=>t([])).finally(()=>i(!1))},[]),(0,s.useEffect)(()=>{n.Hr({limit:200}).then(S).catch(()=>S([]))},[]);function j(e,t){o(n=>({...n,[e]:{...n[e],...t}}))}let M=e=>e!==`all`&&!!(C.clientId||C.region),N=e=>M(e)?C:{},P=e=>M(e)?`${C.clientId}|${C.region}`:``;function F(e,t){if(!(t??k).find(t=>t.key===e))return;let r=P(e);j(e,{loading:!0,error:``}),n.Ur(e===`all`?``:e,N(e)).then(t=>j(e,{groups:t,loading:!1,loaded:!0,scopeKey:r})).catch(t=>j(e,{error:t.message||`Could not load groups`,loading:!1}))}function I(e){F(e,null)}function L(e){f(e),(!a[e]?.loaded||a[e]?.scopeKey!==P(e))&&I(e)}function R(){g(null),m(!0)}function z(e){g(e),m(!0)}function B(){m(!1),g(null)}async function V(){B(),I(d),d!==`all`&&I(`all`)}async function H(e){try{await n.Ar(e,re()),c.message.success(`Group deleted`),I(d),d!==`all`&&I(`all`)}catch(e){c.message.error(e.message||`Could not delete group`)}}async function ee(e){let t=e.map((e,t)=>({g:e,index:t})).filter(({g:e,index:t})=>Number(e.order??0)!==t&&e.id);if(t.length)try{await Promise.all(t.map(({g:e,index:t})=>n.Bi(e.id,{...e,order:t},re(e.module||d)))),c.message.success(`Group order updated`),I(d),d!==`all`&&I(`all`)}catch(e){c.message.error(e.message||`Could not reorder groups`),I(d)}}function te(e){v($C[e])}function ne(e){let t={...C,...e};if(w(t),o(e=>{let t={};for(let[n,r]of Object.entries(e))t[n]=n===d?r:{...r,loaded:!1};return t}),d===`all`)return;let r=t.clientId||t.region?t:{};j(d,{loading:!0,error:``}),n.Ur(d,r).then(e=>j(d,{groups:e,loading:!1,loaded:!0,scopeKey:t.clientId||t.region?`${t.clientId}|${t.region}`:``})).catch(e=>j(d,{error:e.message||`Could not load scoped groups`,loading:!1}))}function re(){return N(d)}function ie(e){O(JSON.parse(JSON.stringify(e))),c.message.success(`Copied settings from ${e.label||e.name}`)}async function ae(e){if(D)try{let t={...e,addRow:D.addRow??e.addRow,payloadKey:D.payloadKey??e.payloadKey,fields:JSON.parse(JSON.stringify(D.fields??[]))};await n.Bi(e.id,t,re(e.module||d)),c.message.success(`Pasted settings into ${e.label||e.name}`),I(d),d!==`all`&&I(`all`)}catch(e){c.message.error(e.message||`Could not paste settings`)}}function oe(){v(null),o(xw(k)),I(d),d!==`all`&&I(`all`)}let se=k.map(({key:e,label:t,color:n})=>{let r=a[e]??{groups:[],loading:!1,loaded:!1,error:``},i=[...r.groups].sort((e,t)=>(e.order??0)-(t.order??0));return{key:e,label:(0,u.jsxs)(`span`,{className:`fg-tab-label`,children:[(0,u.jsx)(`span`,{className:`fg-tab-dot`,style:{background:n}}),t,(0,u.jsx)(c.Badge,{count:r.groups.length,showZero:!0,color:n,size:`small`})]}),children:(0,u.jsxs)(`div`,{className:`fg-tab-content`,children:[r.error&&(0,u.jsx)(c.Alert,{type:`error`,showIcon:!0,message:r.error,style:{marginBottom:12}}),(0,u.jsx)(`div`,{className:`fg-tab-toolbar`,children:(0,u.jsx)(c.Button,{type:`primary`,size:`small`,icon:(0,u.jsx)(l.PlusOutlined,{}),disabled:e===`all`,onClick:()=>{f(e),R()},children:`Add Group`})}),(0,u.jsx)(c.Spin,{spinning:r.loading,children:(0,u.jsx)(Ww,{groups:i,onEdit:z,onDelete:H,onCopy:ie,onPaste:ae,canPaste:!!D,onReorder:e===`all`?void 0:ee})})]})}}),ce=d===`all`?A[0]?.value??`jobs`:d,U=k.find(e=>e.key===ce)?.label??ce,W=[{key:`module`,label:`Module Form`,children:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Z,{children:(0,u.jsxs)(`div`,{className:`fg-scope-toolbar`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`div`,{children:(0,u.jsxs)(QC,{type:`secondary`,style:{fontSize:12},children:[`Select a client to edit that client's field list for the module tab you are on — any module, not just Jobs. Leave blank for the default module config. Until the client has a config of its own you are shown the default; the first save copies it into a client-scoped config. A record rendered against a client — a Job, or a Submission through its job — uses that client's list here and falls back to the default when the client has none. The `,(0,u.jsx)(`b`,{children:`All`}),` tab always shows the defaults.`]})}),M(d)&&(0,u.jsx)(`div`,{style:{marginTop:6},children:(0,u.jsx)(c.Tag,{color:`processing`,children:`Editing ${x.find(e=>(e._id??e.id)===C.clientId)?.clientName??`client`} config for ${d}`})})]}),(0,u.jsxs)(c.Space,{wrap:!0,size:8,children:[(0,u.jsx)(c.Select,{size:`small`,allowClear:!0,showSearch:!0,placeholder:`Client`,style:{width:240},value:C.clientId||void 0,optionFilterProp:`label`,options:x.map(e=>({value:e._id??e.id,label:e.clientName??e.name??e.clientRefrenceId??e._id})).filter(e=>e.value),onChange:e=>ne({clientId:e??``})}),(0,u.jsx)(c.Button,{size:`small`,icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:()=>I(d),children:`Reload`}),(0,u.jsx)(c.Button,{size:`small`,icon:(0,u.jsx)(l.EyeOutlined,{}),disabled:d===`all`,onClick:()=>E(!0),children:`Preview`})]})]})}),(0,u.jsx)(Z,{children:(0,u.jsx)(c.Spin,{spinning:r,children:(0,u.jsx)(c.Tabs,{activeKey:d,onChange:L,items:se,size:`middle`,className:`fg-tabs`})})}),(0,u.jsx)(Uw,{open:p,editingGroup:h,defaultModule:d===`all`?A[0]?.value??``:d,moduleOptions:A,allGroupsByModule:Object.fromEntries(Object.entries(a).filter(([e])=>e!==`all`).map(([e,t])=>[e,t.groups??[]])),onClose:B,onSaved:V,onSaveGroup:(e,t)=>t?n.Bi(t.id,e,re(e.module)):n.Cr(e,re(e.module))}),(0,u.jsx)(c.Drawer,{open:T,onClose:()=>E(!1),width:`92vw`,title:(0,u.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,u.jsx)(l.EyeOutlined,{}),` `,U,` Add Form Preview`]}),classNames:{body:`fg-preview-body`},destroyOnClose:!0,children:(0,u.jsx)(Rc,{moduleName:ce,clientId:C.clientId,region:C.region,cancelPath:`/${ce}`,onSubmit:async()=>c.message.info(`Preview only. No record was created.`),breadcrumbItems:[{label:`Admin`},{label:`Form Groups`},{label:`${U} Preview`}]},`${ce}-${C.clientId}-${C.region}`)})]})},{key:`custom`,label:`Custom Form`,children:(0,u.jsx)(Z,{children:(0,u.jsx)(Kw,{moduleOptions:A})})},{key:`defaultFields`,label:`Default Fields`,children:(0,u.jsx)(KC,{moduleOptions:A})}];return(0,u.jsxs)(`div`,{className:`fg-section`,children:[(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.AppstoreAddOutlined,{}),title:`Form Groups`,extra:y===`module`?(0,u.jsxs)(c.Space,{size:8,wrap:!0,children:[(0,u.jsx)(c.Dropdown,{trigger:[`click`],menu:{items:[{key:`save`,label:`Save current as default`,icon:(0,u.jsx)(l.SaveOutlined,{}),onClick:()=>te(`save`)},{key:`restore`,label:`Restore saved default`,icon:(0,u.jsx)(l.CloudDownloadOutlined,{}),onClick:()=>te(`restore`)},{type:`divider`},{key:`reset`,label:`Reset all form groups`,icon:(0,u.jsx)(l.ReloadOutlined,{}),danger:!0,onClick:()=>te(`reset`)}]},children:(0,u.jsx)(c.Button,{size:`small`,icon:(0,u.jsx)(l.MoreOutlined,{}),children:`Workspace defaults`})}),(0,u.jsx)(c.Button,{type:`primary`,size:`small`,icon:(0,u.jsx)(l.AppstoreAddOutlined,{}),onClick:R,children:`New Group`})]}):null,children:[(0,u.jsx)(`div`,{className:`admin-accent-bar`}),(0,u.jsxs)(QC,{type:`secondary`,style:{fontSize:13},children:[(0,u.jsx)(`strong`,{children:`Module Form`}),` — configure the default add/edit form for each module.`,` `,(0,u.jsx)(`strong`,{children:`Custom Form`}),` — create standalone named forms (module + action) for context-specific flows such as quick-add or popup forms.`]})]}),(0,u.jsx)(Z,{styles:{body:{padding:`0 0`}},children:(0,u.jsx)(c.Tabs,{activeKey:y,onChange:b,items:W,size:`middle`,className:`fg-top-tabs`,tabBarStyle:{padding:`0 16px`,margin:0},destroyInactiveTabPane:!1})}),(0,u.jsx)(zC,{open:!!_,scope:`formGroups`,action:_?.action,title:_?.title,description:_?.description,confirmLabel:_?.confirmLabel,danger:_?.danger,onCancel:()=>v(null),onVerified:oe})]})}var Jw=`databaseFields`,Yw=`__detail_database_fields__`;function Xw(e){return e?.detailOnlySource===!0||e?.id===`__detail_database_fields__`}function Zw(e,t){let n=new Set(t),r=[];for(let t of e??[]){let e=String(t?.field??``).trim();!e||n.has(e)||(n.add(e),r.push({field:e,label:String(t?.label??``).trim()||e,type:String(t?.type??``).trim()||`text`,show:1,edit:0,req:0,detailOnlySource:!0}))}return r}function Qw(e,t){let n=Array.isArray(e)?e:[],r=Zw(t,n.flatMap(e=>(e.fields??[]).map(e=>e.field)));if(!r.length)return n;let i=n.reduce((e,t)=>Math.max(e,Number(t.order)||0),0);return[...n,{id:Yw,name:Jw,label:`Database Fields`,order:i+1,hideGroupInForm:!0,detailOnlySource:!0,fields:r}]}function $w(e,t){let n={};return(Array.isArray(t)?t:[]).forEach(e=>{let t=String(e?.name??``).trim(),r=String(e?.label??``).trim();t&&r&&(n[t]=r)}),{groups:(Array.isArray(e)?e:[]).map(e=>{let t=e.inheritedLabel??e.label??e.name;return Object.prototype.hasOwnProperty.call(n,e.name)?{...e,inheritedLabel:t,label:n[e.name]}:{...e,inheritedLabel:t}}),labels:n}}function eT(e){return Object.entries(e??[]).map(([e,t])=>({name:String(e).trim(),label:String(t??``).trim()})).filter(e=>e.name&&e.label)}var tT=`2026-08-06T13:33:00.000Z`,{Text:Q}=c.Typography,nT,rT=new Map;function iT(){return nT||=n.Yr().catch(e=>{throw nT=void 0,e}),nT}function aT(e){return rT.has(e)||rT.set(e,n.$r(e).catch(t=>{throw rT.delete(e),t})),rT.get(e)}var oT={reset:{action:`reset`,title:`Reset all detail config`,confirmLabel:`Reset All`,danger:!0,description:`Clears every detail-view override for all modules in this workspace, so the detail view falls back to the plain form-group fields.`},save:{action:`save`,title:`Save current as default`,confirmLabel:`Save Default`,danger:!1,description:`Snapshots the current detail config for all modules as the saved default you can restore to later.`},restore:{action:`restore`,title:`Restore saved default`,confirmLabel:`Restore Default`,danger:!0,description:`Replaces the current detail config for all modules with the last saved default.`},discoverFields:{action:`discoverFields`,title:`Read fields from database`,confirmLabel:`Read Fields`,danger:!1,description:`Reads field names and types from this module’s registered database collection and imports only that metadata into Detail Groups. Record values are never returned.`}},sT=[{label:`Default`,value:`default`},{label:`Title Case On`,value:`on`},{label:`Off (raw text)`,value:`off`}],cT=e=>e===!0?`on`:e===!1?`off`:`default`,lT=e=>e===`on`||e!==`off`&&void 0,uT=e=>e===!0||e===1||e===`1`;function dT(e){let t=new Set,n=[];for(let r of e??[])for(let e of r.fields??[])!e.field||t.has(e.field)||(t.add(e.field),n.push({key:e.field,label:e.label??e.field,type:e.type??`text`,group:r.label??r.name,validations:Array.isArray(e.validations)?e.validations:[],lookupDefaults:e.lookupCollection?{lookupCollection:e.lookupCollection,displayField:e.displayField??``,displayField2:e.displayField2??``,valueField:e.valueField||`_id`}:{}}));return n}function fT(e,t){if(!t)return null;let n={field:e};t.label&&(n.label=t.label),t.prefix&&(n.prefix=t.prefix),t.suffix&&(n.suffix=t.suffix),t.color&&(n.color=t.color),(t.capitalize===!0||t.capitalize===!1)&&(n.capitalize=t.capitalize),(t.hidden===!0||t.hidden===!1)&&(n.hidden=t.hidden),t.hideInDetail===!0&&(n.hideInDetail=!0),(t.hideWhenEmpty===!0||t.hideWhenEmptyInDetail===!0)&&(n.hideWhenEmpty=!0,t.hideWhenEmptyInDetail===!0&&(n.hideWhenEmptyInDetail=!0)),t.hideWhenZero===!0&&(n.hideWhenZero=!0),t.hidePartLabel===!0&&(n.hidePartLabel=!0),t.ignoreLabelWhenInDetail===!0&&(n.ignoreLabelWhenInDetail=!0);let r=(t.labelWhen??[]).filter(e=>String(e?.field??``).trim()&&String(e?.label??``).trim()).map(e=>{let t={field:String(e.field).trim(),operator:e.operator||`eq`,label:String(e.label).trim()};return lC(t.operator)&&e.value!=null&&e.value!==``&&(t.value=String(e.value)),t});r.length&&(n.labelWhen=r);let i=t.renderType||(t.documentPreview?`document`:t.displayAs===`tag`?`tag`:t.displayAs===`text`?`text`:``);i&&i!==`auto`&&(n.renderType=i);let a={};for(let[e,n]of Object.entries(t.renderOptions??{}))n!==void 0&&n!==``&&n!==!1&&(a[e]=n);return Object.keys(a).length&&(n.renderOptions=a),t.lookupCollection&&(n.lookupCollection=t.lookupCollection,n.displayField=t.displayField||``,t.displayField2&&(n.displayField2=t.displayField2),n.valueField=t.valueField||`_id`),Object.keys(n).length>1?n:null}function pT(e){return(e??[]).filter(e=>e.key&&(e.fields??[]).length).map(e=>{let t={key:e.key,label:e.label||e.key,fields:e.fields};return e.template&&(t.template=e.template),e.valueMaps&&Object.keys(e.valueMaps).length&&(t.valueMaps=e.valueMaps),e.separator&&(t.separator=e.separator),e.prefix&&(t.prefix=e.prefix),e.suffix&&(t.suffix=e.suffix),e.color&&(t.color=e.color),(e.capitalize===!0||e.capitalize===!1)&&(t.capitalize=e.capitalize),e.group&&(t.group=e.group),e.hideSources===!1&&(t.hideSources=!1),t})}function mT(e){return Number(e?.show??1)===0}function hT(e,t){let n=[];return{nextGroups:(e??[]).map(e=>{if(Xw(e))return e;let r=!1,i=(e.fields??[]).map(e=>{let n=t[e.field];if(!n||n.hidden===void 0)return e;let i=+!n.hidden;return Number(e.show??1)===i?e:(r=!0,{...e,show:i})}),a=r?{...e,fields:i}:e;return r&&n.push(a),a}),changed:n}}function gT({value:e,onChange:t}){return(0,u.jsxs)(c.Space.Compact,{style:{width:`100%`},children:[(0,u.jsx)(c.Input,{size:`small`,placeholder:`#0053a5`,value:e??``,onChange:e=>t(e.target.value),className:`fg-mono-input`,prefix:(0,u.jsx)(l.BgColorsOutlined,{style:{color:e||`#bbb`}})}),(0,u.jsx)(`input`,{type:`color`,value:/^#[0-9a-f]{6}$/i.test(e??``)?e:`#0053a5`,onChange:e=>t(e.target.value),style:{width:32,border:`1px solid #d9d9d9`,borderLeft:0,cursor:`pointer`,padding:0},"aria-label":`Pick colour`})]})}function _T({fieldMeta:e,rules:t,ignore:n,fieldOptions:r,onChangeRules:i,onChangeIgnore:a}){let o=Array.isArray(t)?t:[],s=e?.labelWhen,d=o.length===0&&!!(s?.field&&s?.label),f=(e,t)=>i(o.map((n,r)=>r===e?{...n,...t}:n)),p=e=>i(o.filter((t,n)=>n!==e));return(0,u.jsxs)(`div`,{className:`fg-form-section`,style:{marginTop:14,marginBottom:0},children:[(0,u.jsx)(`div`,{className:`fg-form-section-label`,children:`Conditional Label`}),(0,u.jsxs)(Q,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:8},children:[`Show a different label depending on another field's value on the record. The first matching rule wins; if none match, the label above (`,(0,u.jsx)(`b`,{children:e?.label}),`) is used. Detail view only — the add/edit forms are unaffected.`]}),d&&(0,u.jsx)(c.Alert,{type:`info`,showIcon:!0,style:{marginBottom:10},message:`Inheriting from Form Groups: "${s.label}" when ${s.field} ${s.operator??`eq`} ${s.value??``}`,description:(0,u.jsx)(c.Button,{size:`small`,type:`link`,style:{padding:0},onClick:()=>i([{field:s.field,operator:s.operator??`eq`,value:s.value??``,label:s.label}]),children:`Override it here`})}),o.map((e,t)=>{let n=lC(e.operator);return(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginBottom:8,alignItems:`flex-end`},children:[(0,u.jsxs)(`div`,{style:{flex:1.4},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`When field`}),(0,u.jsx)(c.Select,{size:`small`,showSearch:!0,mode:`tags`,maxCount:1,style:{width:`100%`},placeholder:`e.g. contractType`,optionFilterProp:`label`,options:r,value:e.field?[e.field]:[],onChange:e=>f(t,{field:String(e[e.length-1]??``).trim()})})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Is`}),(0,u.jsx)(c.Select,{size:`small`,style:{width:`100%`},options:sC,value:e.operator??`eq`,onChange:e=>f(t,{operator:e})})]}),n&&(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Value`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`C2C`,value:e.value??``,onChange:e=>f(t,{value:e.target.value}),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{flex:1.2},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Show label`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`Employer Rate`,value:e.label??``,onChange:e=>f(t,{label:e.target.value})})]}),(0,u.jsx)(c.Button,{size:`small`,type:`text`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{}),onClick:()=>p(t)})]},t)}),(0,u.jsx)(c.Button,{size:`small`,type:`dashed`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>i([...o,{field:``,operator:`eq`,value:``,label:``}]),children:`Add rule`}),(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:14},children:[(0,u.jsx)(c.Switch,{size:`small`,checked:!n,onChange:e=>a(!e)}),(0,u.jsx)(Q,{style:{fontSize:13},children:`Use conditional labels in the detail view`})]}),(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:11,display:`block`,marginTop:4},children:`Turn off to always show the static label here, ignoring both the rules above and the one from Form Groups.`})]})}function vT({open:e,fieldMeta:t,value:r,moduleFieldOptions:i,onClose:a,onSave:o}){let[d,f]=(0,s.useState)(()=>({...r??{}})),[p,m]=(0,s.useState)([]),[h,g]=(0,s.useState)([]),[_,v]=(0,s.useState)(`display`);(0,s.useEffect)(()=>{if(!e||_!==`lookup`)return;let t=!1;return iT().then(e=>{t||m(e.map(e=>typeof e==`string`?e:e.name??e.value??``).filter(Boolean))}).catch(()=>{}),()=>{t=!0}},[_,e]),(0,s.useEffect)(()=>{if(!e||_!==`lookup`||!d.lookupCollection)return;let t=!1;return aT(d.lookupCollection).then(e=>{t||g(e.map(e=>typeof e==`string`?e:e.value??e.field??e.label??``).filter(Boolean))}).catch(()=>{}),()=>{t=!0}},[_,e,d.lookupCollection]);let y=(e,t)=>f(n=>({...n,[e]:t})),b=e=>{g([]),f(t=>({...t,lookupCollection:e}))},x=p.map(e=>({value:e})),S=h.map(e=>({value:e})),C=d.renderOptions??{},w=(e,t)=>y(`renderOptions`,{...C,[e]:t||void 0}),T=d.renderType||(d.documentPreview?`document`:d.displayAs===`tag`?`tag`:d.displayAs===`text`?`text`:`auto`),E=[`tag`,`tags`,`chip`,`badge`].includes(T),D=[`text`,`tag`,`tags`,`chip`,`badge`,`link`,`email`,`phone`].includes(T);return(0,u.jsxs)(c.Modal,{open:e,onCancel:a,width:760,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal detail-field-editor-modal`,title:(0,u.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,u.jsx)(l.EditOutlined,{}),` `,t?.label,(0,u.jsx)(`code`,{className:`fg-field-key-hint`,style:{marginLeft:8},children:t?.key})]}),footer:(0,u.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,u.jsx)(c.Button,{onClick:a,children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.SaveOutlined,{}),onClick:()=>o(d),children:`Apply`})]}),children:[(0,u.jsxs)(`div`,{className:`detail-editor-nav`,role:`tablist`,"aria-label":`Field settings`,children:[(0,u.jsx)(c.Button,{type:_===`display`?`primary`:`text`,onClick:()=>v(`display`),children:`Display`}),(0,u.jsx)(c.Button,{type:_===`lookup`?`primary`:`text`,onClick:()=>v(`lookup`),children:`Reference lookup`})]}),_===`display`&&(0,u.jsxs)(`div`,{className:`fg-form-section detail-editor-panel`,children:[(0,u.jsx)(`div`,{className:`fg-form-section-label`,children:`Display`}),(0,u.jsxs)(`div`,{style:{marginBottom:12},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Label override`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:t?.label,value:d.label??``,onChange:e=>y(`label`,e.target.value)})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Prefix`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. $`,value:d.prefix??``,onChange:e=>y(`prefix`,e.target.value)})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Suffix`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. yrs`,value:d.suffix??``,onChange:e=>y(`suffix`,e.target.value)})]})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Colour`}),(0,u.jsx)(gT,{value:d.color,onChange:e=>y(`color`,e)})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Capitalize`}),(0,u.jsx)(c.Select,{size:`small`,style:{width:`100%`},options:sT,value:cT(d.capitalize),onChange:e=>y(`capitalize`,lT(e))})]})]}),!t?.detailOnly&&(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:14},children:[(0,u.jsx)(c.Switch,{size:`small`,checked:!!d.hidden,onChange:e=>y(`hidden`,e)}),(0,u.jsx)(Q,{style:{fontSize:13},children:`Hide this field everywhere (detail view and the add/edit form)`})]}),(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:10},children:[(0,u.jsx)(c.Switch,{size:`small`,checked:!!d.hideInDetail,onChange:e=>y(`hideInDetail`,e)}),(0,u.jsx)(Q,{style:{fontSize:13},children:t?.detailOnly?`Hide this database field from the detail view`:`Hide in the detail view only (keep it in the add/edit form)`})]}),(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:10},children:[(0,u.jsx)(c.Switch,{size:`small`,checked:!!d.hideWhenEmpty||!!d.hideWhenEmptyInDetail,onChange:e=>f(t=>({...t,hideWhenEmpty:e,hideWhenEmptyInDetail:e?t.hideWhenEmptyInDetail:!1}))}),(0,u.jsx)(Q,{style:{fontSize:13},children:`Hide when empty — drop this field (and a combined block left with nothing to show) instead of printing a heading over a dash`})]}),(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:10},children:[(0,u.jsx)(c.Switch,{size:`small`,checked:!!d.hidePartLabel,onChange:e=>y(`hidePartLabel`,e)}),(0,u.jsx)(Q,{style:{fontSize:13},children:`Hide this part's label inside a combined block — show just the value (e.g. “12 Days”, not “12 · Unit Days”)`})]}),(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:10},children:[(0,u.jsx)(c.Switch,{size:`small`,checked:!!d.hideWhenZero,onChange:e=>y(`hideWhenZero`,e)}),(0,u.jsx)(Q,{style:{fontSize:13},children:`Treat 0 as empty — hide this field when its value is 0 or blank (e.g. the end of a rate range that was never filled in, so "92 - 0" shows as just "92")`})]}),(0,u.jsx)(_T,{fieldMeta:t,rules:d.labelWhen,ignore:d.ignoreLabelWhenInDetail,fieldOptions:i,onChangeRules:e=>y(`labelWhen`,e),onChangeIgnore:e=>y(`ignoreLabelWhenInDetail`,e)}),(0,u.jsxs)(`div`,{style:{marginTop:14},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Render Type`}),(0,u.jsx)(c.Select,{size:`small`,style:{width:`100%`},value:T,onChange:e=>y(`renderType`,e),options:n.tn}),(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:4},children:`How this field is displayed in the detail view — entirely config-driven.`})]}),(0,u.jsxs)(`div`,{style:{marginTop:12},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Empty text`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:Zu[T]??Zu.default,value:C.emptyText??``,onChange:e=>w(`emptyText`,e.target.value)}),(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:4},children:`What to show when this particular field is empty — for example "No LinkedIn profile added". Leave blank to use the wording set for its type in Display Defaults.`})]}),T===`document`&&(0,u.jsxs)(`div`,{style:{marginTop:12},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Document mode`}),(0,u.jsx)(c.Select,{size:`small`,style:{width:`100%`},value:C.documentMode||`preview`,onChange:e=>w(`documentMode`,e),options:n.en})]}),D&&(0,u.jsxs)(`div`,{style:{marginTop:12},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Text transform`}),(0,u.jsx)(c.Select,{size:`small`,style:{width:`100%`},value:C.textTransform||`none`,onChange:e=>w(`textTransform`,e===`none`?void 0:e),options:n.nn})]}),E&&(0,u.jsxs)(`div`,{style:{marginTop:12},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Tag colour`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`geekblue / #0053a5`,value:C.tagColor??``,onChange:e=>w(`tagColor`,e.target.value),className:`fg-mono-input`})]}),T===`date`&&(0,u.jsxs)(`div`,{style:{marginTop:12},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Date format (dayjs tokens)`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`DD/MM/YYYY`,value:C.dateFormat??``,onChange:e=>w(`dateFormat`,e.target.value),className:`fg-mono-input`})]}),T===`phone`&&(0,u.jsxs)(`div`,{style:{marginTop:12},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Country-code field on the record`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`e.g. countryCode or contact.countryCode`,value:C.countryCodeField??``,onChange:e=>w(`countryCodeField`,e.target.value),className:`fg-mono-input`}),(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:4},children:`Leave blank to auto-detect a sibling code key. Nothing is prefixed when the record carries no code and no global fallback is set.`})]}),(T===`currency`||T===`budget`)&&(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Currency symbol`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`$ / ₹ / £`,value:C.currencySymbol??``,onChange:e=>w(`currencySymbol`,e.target.value)})]}),T===`budget`&&(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Unit (e.g. Monthly)`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`Monthly`,value:C.unit??``,onChange:e=>w(`unit`,e.target.value)})]})]}),(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:14},children:[(0,u.jsx)(c.Switch,{size:`small`,checked:!!C.showEmpty,onChange:e=>w(`showEmpty`,e)}),(0,u.jsx)(Q,{style:{fontSize:13},children:`Show empty values`})]})]}),_===`lookup`&&(0,u.jsxs)(`div`,{className:`fg-form-section detail-editor-panel`,children:[(0,u.jsx)(`div`,{className:`fg-form-section-label`,children:`Reference Lookup (id → name)`}),(0,u.jsxs)(Q,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:8},children:[`For fields that store a foreign-key id. The detail API resolves the name from the target collection and returns `,(0,u.jsx)(`code`,{children:`{ id, value }`}),`.`]}),(0,u.jsxs)(`div`,{style:{marginBottom:10},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Collection`}),(0,u.jsx)(c.AutoComplete,{size:`small`,style:{width:`100%`},options:x,placeholder:`e.g. vendors`,value:d.lookupCollection??``,onChange:b,filterOption:(e,t)=>(t?.value??``).toLowerCase().includes(e.toLowerCase()),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Display Field`}),(0,u.jsx)(c.AutoComplete,{size:`small`,style:{width:`100%`},options:S,placeholder:`e.g. vendorCompanyName`,value:d.displayField??``,onChange:e=>y(`displayField`,e),filterOption:(e,t)=>(t?.value??``).toLowerCase().includes(e.toLowerCase()),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Display Field 2`}),(0,u.jsx)(c.AutoComplete,{size:`small`,style:{width:`100%`},options:S,placeholder:`e.g. lastName`,value:d.displayField2??``,onChange:e=>y(`displayField2`,e),filterOption:(e,t)=>(t?.value??``).toLowerCase().includes(e.toLowerCase()),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Value Field (FK)`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`_id`,value:d.valueField??``,onChange:e=>y(`valueField`,e.target.value),className:`fg-mono-input`})]})]})]})]})}function yT(e){let t=[];return Object.entries(e??{}).forEach(([e,n])=>{Object.entries(n??{}).forEach(([n,r])=>t.push({field:e,from:n,to:r}))}),t}function bT(e){let t={};for(let n of e??[])!n.field||!n.from||(t[n.field]={...t[n.field]??{},[n.from]:n.to??``});return t}function xT({open:e,merge:t,fieldOptions:n,groupOptions:r,onClose:i,onSave:a}){let[o,d]=(0,s.useState)(()=>({key:``,label:``,fields:[],separator:` - `,template:``,prefix:``,suffix:``,color:``,capitalize:void 0,group:``,hideSources:!0,...t??{},mapRows:yT(t?.valueMaps)})),f=(e,t)=>d(n=>({...n,[e]:t})),p=(e,t)=>d(n=>{let r=[...n.mapRows??[]];return r[e]={...r[e],...t},{...n,mapRows:r}}),m=e=>d(t=>({...t,mapRows:(t.mapRows??[]).filter((t,n)=>n!==e)}));return(0,u.jsx)(c.Modal,{open:e,onCancel:i,width:820,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,u.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,u.jsx)(l.MergeCellsOutlined,{}),` `,t?`Edit Merged Field`:`New Merged Field`]}),footer:(0,u.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,u.jsx)(c.Button,{onClick:i,children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.SaveOutlined,{}),onClick:()=>{if(!o.key?.trim())return c.message.error(`A merge key is required`);if(!/^[a-z0-9_]+$/.test(o.key))return c.message.error(`Key: lowercase letters, numbers, underscores only`);if(!(o.fields??[]).length)return c.message.error(`Pick at least one source field`);let{mapRows:e,...t}=o;a({...t,valueMaps:bT(e)})},children:`Apply`})]}),children:(0,u.jsxs)(`div`,{className:`fg-form-section`,children:[(0,u.jsx)(`div`,{className:`fg-form-section-label`,children:`Merged Field`}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Key`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`experience_range`,value:o.key??``,onChange:e=>f(`key`,e.target.value),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Label`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`Experience`,value:o.label??``,onChange:e=>f(`label`,e.target.value)})]})]}),(0,u.jsxs)(`div`,{style:{margin:`12px 0`},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Source fields (combined in order)`}),(0,u.jsx)(c.Select,{mode:`multiple`,size:`small`,style:{width:`100%`},placeholder:`Pick fields to combine`,options:n,value:o.fields??[],onChange:e=>f(`fields`,e),optionFilterProp:`label`})]}),(0,u.jsxs)(`div`,{style:{margin:`12px 0`},children:[(0,u.jsxs)(Q,{type:`secondary`,style:{fontSize:12},children:[`Template `,(0,u.jsx)(`span`,{style:{color:`#94a3b8`},children:`(optional — overrides separator)`})]}),(0,u.jsx)(c.Input.TextArea,{rows:2,value:o.template??``,onChange:e=>f(`template`,e.target.value),placeholder:`{clientBudgetStart} - {clientBudgetEnd} {clientBudgetCurrency}/{clientBudgetUnit}`,className:`fg-mono-input`}),(0,u.jsxs)(Q,{type:`secondary`,style:{fontSize:11,display:`block`,marginTop:4},children:[`A field with no value takes its joining punctuation with it, so a rate with no end shows `,(0,u.jsx)(`code`,{children:`80 $/hour`}),` rather than `,(0,u.jsx)(`code`,{children:`80 - $/hour`}),`. That only applies to pure connectors (`,(0,u.jsx)(`code`,{children:`-`}),` `,(0,u.jsx)(`code`,{children:`/`}),` `,(0,u.jsx)(`code`,{children:`,`}),` `,(0,u.jsx)(`code`,{children:`|`}),` `,(0,u.jsx)(`code`,{children:`:`}),` and spaces) — literal words you type, like `,(0,u.jsx)(`code`,{children:`Rate:`}),`, are always kept. Put spacing in the template itself, never inside a Value Map: a mapped value like `,(0,u.jsx)(`code`,{children:`" hour"`}),` adds a gap the template cannot see, which is how `,(0,u.jsx)(`code`,{children:`$/hour`}),` came out as `,(0,u.jsx)(`code`,{children:`$ / hour`}),`.`]}),(o.fields??[]).length>0&&(0,u.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:4,marginTop:6},children:(o.fields??[]).map(e=>(0,u.jsxs)(c.Tag,{color:`blue`,style:{cursor:`pointer`,margin:0},onClick:()=>f(`template`,`${o.template??``}{${e}}`),children:[`+ `,`{${e}}`]},e))}),(0,u.jsxs)(Q,{type:`secondary`,style:{fontSize:11,display:`block`,marginTop:4},children:[`Click a chip to insert a field. Everything else (spaces, “/”, “-”) is kept literally. Result e.g. `,(0,u.jsx)(`code`,{children:`60 - 80 $/Monthly`}),`.`]})]}),(0,u.jsxs)(`div`,{style:{margin:`12px 0`},children:[(0,u.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Value mappings (raw → display)`}),(0,u.jsx)(c.Button,{size:`small`,type:`dashed`,icon:(0,u.jsx)(l.PlusOutlined,{}),disabled:!(o.fields??[]).length,onClick:()=>d(e=>({...e,mapRows:[...e.mapRows??[],{field:e.fields?.[0]??``,from:``,to:``}]})),children:`Add`})]}),(o.mapRows??[]).map((e,t)=>(0,u.jsxs)(`div`,{style:{display:`flex`,gap:6,marginTop:6,alignItems:`center`},children:[(0,u.jsx)(c.Select,{size:`small`,style:{flex:1.4},placeholder:`field`,value:e.field||void 0,options:(o.fields??[]).map(e=>({value:e,label:e})),onChange:e=>p(t,{field:e})}),(0,u.jsx)(c.Input,{size:`small`,style:{flex:1},placeholder:`Monthly`,value:e.from,onChange:e=>p(t,{from:e.target.value})}),(0,u.jsx)(`span`,{style:{color:`#94a3b8`},children:`→`}),(0,u.jsx)(c.Input,{size:`small`,style:{flex:1},placeholder:`mon`,value:e.to,onChange:e=>p(t,{to:e.target.value})}),(0,u.jsx)(c.Button,{size:`small`,type:`text`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{}),onClick:()=>m(t)})]},t)),!(o.mapRows??[]).length&&(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:11,display:`block`,marginTop:4},children:`e.g. Monthly → mon, Daily → day, Yearly → yr. Unmapped values stay as-is.`})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsxs)(Q,{type:`secondary`,style:{fontSize:12},children:[`Separator `,(0,u.jsx)(`span`,{style:{color:`#94a3b8`},children:`(used when no template)`})]}),(0,u.jsx)(c.Input,{size:`small`,placeholder:` - `,value:o.separator??``,onChange:e=>f(`separator`,e.target.value)})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Place in group`}),(0,u.jsx)(c.Select,{size:`small`,style:{width:`100%`},allowClear:!0,placeholder:`(first source's group)`,options:r,value:o.group||void 0,onChange:e=>f(`group`,e??``)})]})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Prefix`}),(0,u.jsx)(c.Input,{size:`small`,value:o.prefix??``,onChange:e=>f(`prefix`,e.target.value)})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Suffix`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`yrs`,value:o.suffix??``,onChange:e=>f(`suffix`,e.target.value)})]})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Colour`}),(0,u.jsx)(gT,{value:o.color,onChange:e=>f(`color`,e)})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Capitalize`}),(0,u.jsx)(c.Select,{size:`small`,style:{width:`100%`},options:sT,value:cT(o.capitalize),onChange:e=>f(`capitalize`,lT(e))})]})]}),(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:14},children:[(0,u.jsx)(c.Switch,{size:`small`,checked:o.hideSources!==!1,onChange:e=>f(`hideSources`,e)}),(0,u.jsx)(Q,{style:{fontSize:13},children:`Hide the source fields after merging`})]})]})})}function ST({open:e,module:t,onClose:n}){let[r,i]=(0,s.useState)(``),[a,o]=(0,s.useState)(``),d=()=>{let e=r.trim();if(!e)return c.message.warning(`Enter a record _id to preview`);o(e)};return(0,u.jsxs)(c.Drawer,{open:e,onClose:n,width:720,title:(0,u.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,u.jsx)(l.EyeOutlined,{}),` Detail Preview — `,t]}),classNames:{header:`fg-drawer-header`,body:`fg-drawer-body`},children:[(0,u.jsx)(c.Alert,{type:`info`,showIcon:!0,style:{marginBottom:12},message:`Preview renders the live detail view`,description:`This is the real detail component reading saved configuration. Save your changes first to see them here.`}),(0,u.jsxs)(c.Space.Compact,{style:{width:`100%`,marginBottom:14},children:[(0,u.jsx)(c.Input,{placeholder:`Paste a record _id (24-char ObjectId)`,value:r,onChange:e=>i(e.target.value),onPressEnter:d,className:`fg-mono-input`}),(0,u.jsx)(c.Button,{type:`primary`,onClick:d,children:`Load`})]}),a?(0,u.jsx)(Rd,{moduleName:t,id:a},`${t}-${a}`):(0,u.jsx)(c.Empty,{description:`Load a record to preview its detail view.`,image:c.Empty.PRESENTED_IMAGE_SIMPLE})]})}var CT=[{label:`Common (no region profile)`,value:``},{label:`United States (US)`,value:`US`},{label:`United Kingdom (UK)`,value:`UK`},{label:`India (IND)`,value:`IND`}],wT=[{key:`default`,label:`Any value`,placeholder:Zu.default},{key:`group`,label:`Empty group`,placeholder:`No <group name> added`},{key:`document`,label:`Document`,placeholder:Zu.document},{key:`date`,label:`Date`,placeholder:Zu.date},{key:`phone`,label:`Phone`,placeholder:Zu.phone},{key:`email`,label:`Email`,placeholder:Zu.email},{key:`link`,label:`Link`,placeholder:Zu.link},{key:`skills`,label:`Skills/tags`,placeholder:Zu.skills}];function TT(e){let t={};return[`s3BaseUrl`,`dateFormat`,`dateTimeFormat`,`phoneFormat`,`booleanTrueLabel`,`booleanFalseLabel`,`emptyPlaceholder`,`separator`].forEach(n=>{e?.[n]!==void 0&&e?.[n]!==``&&(t[n]=e[n])}),typeof e?.phoneCountryCode==`string`&&(t.phoneCountryCode=e.phoneCountryCode),Array.isArray(e?.documentNameOrder)&&e.documentNameOrder.length&&(t.documentNameOrder=e.documentNameOrder),e?.emptyTexts&&typeof e.emptyTexts==`object`&&(t.emptyTexts={...e.emptyTexts}),typeof e?.timeZone==`string`&&(t.timeZone=e.timeZone),typeof e?.region==`string`&&(t.region=e.region),typeof e?.candidateDetailViewMode==`string`&&e.candidateDetailViewMode&&(t.candidateDetailViewMode=e.candidateDetailViewMode),typeof e?.showTimeZoneLabel==`boolean`&&(t.showTimeZoneLabel=e.showTimeZoneLabel),e?.formDateFormats&&typeof e.formDateFormats==`object`&&!Array.isArray(e.formDateFormats)&&(t.formDateFormats={...e.formDateFormats}),t}function ET(e){let t={};return Object.entries(e??{}).forEach(([e,n])=>{let r=String(e??``).trim(),i=String(n??``).trim();r&&i&&(t[r]=i)}),t}function DT({value:e,onChange:t,labelStyle:n}){let r=Object.entries(e??{}),i=e=>t(Object.fromEntries(e));return(0,u.jsxs)(`div`,{style:{marginBottom:12},children:[(0,u.jsx)(Q,{type:`secondary`,style:n,children:`Form date format per module (Add / Edit form date pickers only)`}),r.map(([e,t],n)=>(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginBottom:4},children:[(0,u.jsx)(c.Input,{size:`small`,placeholder:`candidates`,value:e,onChange:e=>i(r.map((t,r)=>r===n?[e.target.value,t[1]]:t))}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`MM/DD/YYYY`,value:t,className:`fg-mono-input`,onChange:e=>i(r.map((t,r)=>r===n?[t[0],e.target.value]:t))}),(0,u.jsx)(c.Button,{size:`small`,onClick:()=>i(r.filter((e,t)=>t!==n)),children:`Remove`})]},n)),(0,u.jsx)(c.Button,{size:`small`,onClick:()=>i([...r,[``,``]]),children:`Add module`}),(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:4},children:`A module listed here uses its own format in its forms; list and detail views keep the Date format above. Unlisted modules use the Date format everywhere.`})]})}function OT({open:e,onClose:t}){let[r,i]=(0,s.useState)(()=>({...n.fr()})),[a,o]=(0,s.useState)(!1);(0,s.useEffect)(()=>{if(!e)return;let t=!1;return n.ni().then(e=>{t||i(t=>({...t,...TT(e)}))}).catch(()=>{}),()=>{t=!0}},[e]);let d=(e,t)=>i(n=>({...n,[e]:t})),f=(0,s.useMemo)(()=>n.ir(r).map(({value:e,label:t})=>({value:e,label:t})),[r.timeZoneAliases]),p=async()=>{o(!0);try{let e={s3BaseUrl:(r.s3BaseUrl??``).trim(),dateFormat:(r.dateFormat??``).trim(),dateTimeFormat:(r.dateTimeFormat??``).trim(),showTimeZoneLabel:r.showTimeZoneLabel!==!1,phoneFormat:(r.phoneFormat??``).trim(),phoneCountryCode:(r.phoneCountryCode??``).trim(),booleanTrueLabel:r.booleanTrueLabel??``,booleanFalseLabel:r.booleanFalseLabel??``,emptyPlaceholder:r.emptyPlaceholder??``,emptyTexts:r.emptyTexts??{},timeZone:(r.timeZone??``).trim(),region:(r.region??``).trim(),candidateDetailViewMode:r.candidateDetailViewMode||`popup`,separator:r.separator??``,documentNameOrder:Array.isArray(r.documentNameOrder)?r.documentNameOrder:[],...r.formDateFormats?{formDateFormats:ET(r.formDateFormats)}:{}};await n.ji(e),n.lr(e),c.message.success(`Display defaults saved`),t()}catch(e){c.message.error(e?.message||`Could not save defaults`)}finally{o(!1)}},m={fontSize:12,display:`block`,marginBottom:4};return(0,u.jsxs)(c.Drawer,{open:e,onClose:t,width:460,title:(0,u.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,u.jsx)(l.SettingOutlined,{}),` Display Defaults`]}),classNames:{header:`fg-drawer-header`,body:`fg-drawer-body`},footer:(0,u.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,u.jsx)(c.Button,{onClick:()=>i({...n.cr}),children:`Reset to built-in`}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.SaveOutlined,{}),loading:a,onClick:p,children:`Save Defaults`})]}),children:[(0,u.jsxs)(`div`,{className:`fg-form-section`,children:[(0,u.jsx)(`div`,{className:`fg-form-section-label`,children:`Documents / Files`}),(0,u.jsxs)(`div`,{style:{marginBottom:12},children:[(0,u.jsx)(Q,{type:`secondary`,style:m,children:`S3 Base URL`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:n.cr.s3BaseUrl,value:r.s3BaseUrl??``,onChange:e=>d(`s3BaseUrl`,e.target.value),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{children:[(0,u.jsx)(Q,{type:`secondary`,style:m,children:`Document name priority (first match wins)`}),(0,u.jsx)(c.Select,{mode:`tags`,size:`small`,style:{width:`100%`},placeholder:`name, documentName, uploadedFileName…`,value:r.documentNameOrder??[],onChange:e=>d(`documentNameOrder`,e)})]})]}),(0,u.jsxs)(`div`,{className:`fg-form-section`,children:[(0,u.jsx)(`div`,{className:`fg-form-section-label`,children:`Value Formatting`}),(0,u.jsxs)(`div`,{style:{marginBottom:12},children:[(0,u.jsx)(Q,{type:`secondary`,style:m,children:`Date format (dayjs tokens)`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`DD MMM YYYY`,value:r.dateFormat??``,onChange:e=>d(`dateFormat`,e.target.value),className:`fg-mono-input`})]}),(0,u.jsx)(DT,{value:r.formDateFormats,onChange:e=>d(`formDateFormats`,e),labelStyle:m}),(0,u.jsxs)(`div`,{style:{marginBottom:12},children:[(0,u.jsx)(Q,{type:`secondary`,style:m,children:`Phone format (digit groups, e.g. 3-3-4 → 999-878-3413)`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`3-3-4`,value:r.phoneFormat??``,onChange:e=>d(`phoneFormat`,e.target.value),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{marginBottom:12},children:[(0,u.jsx)(Q,{type:`secondary`,style:m,children:`Fallback country code (leave blank — recommended)`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`blank = no code`,value:r.phoneCountryCode??``,onChange:e=>d(`phoneCountryCode`,e.target.value),className:`fg-mono-input`}),(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:4},children:`Used ONLY when a record carries no dial code of its own. It ships empty on purpose: a number that never stated a country is shown without one, rather than being stamped with a code someone assumed. Set it only if this tenant really is single-country.`})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:m,children:`Boolean — true`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`Yes`,value:r.booleanTrueLabel??``,onChange:e=>d(`booleanTrueLabel`,e.target.value)})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:m,children:`Boolean — false`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`No`,value:r.booleanFalseLabel??``,onChange:e=>d(`booleanFalseLabel`,e.target.value)})]})]}),(0,u.jsxs)(`div`,{style:{marginTop:12},children:[(0,u.jsx)(Q,{type:`secondary`,style:m,children:`Region`}),(0,u.jsx)(c.Select,{size:`small`,allowClear:!0,style:{width:`100%`},placeholder:`Common — every group uses its own defaults`,value:r.region||void 0,onChange:e=>d(`region`,e??``),options:CT,getPopupContainer:()=>document.body}),(0,u.jsx)(Q,{type:`secondary`,style:{...m,marginTop:4},children:`Different markets expect different things. Choosing one here switches the rules that have been set up for it — for example whether someone may be put forward while still studying, which is normal in the US and UK but not in India. Leave it on Common if the same rules suit everyone.`})]}),(0,u.jsxs)(`div`,{style:{marginTop:12},children:[(0,u.jsx)(Q,{type:`secondary`,style:m,children:`Application time zone`}),(0,u.jsx)(c.Select,{size:`small`,showSearch:!0,allowClear:!0,style:{width:`100%`},placeholder:`Use each viewer's own browser time zone`,optionFilterProp:`label`,value:r.timeZone||void 0,onChange:e=>d(`timeZone`,e??``),options:f,getPopupContainer:()=>document.body}),(0,u.jsx)(Q,{type:`secondary`,style:{...m,marginTop:4},children:r.timeZone?`Everyone now sees and enters times in ${n.or({...r,timeZone:r.timeZone})}, whichever country they are working from — so an interview slot means the same thing to all of them. Plain dates such as a date of birth are not affected.`:`Not set — everyone sees times in their own computer’s time zone, so the same interview can appear at two different times to two people.`})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:m,children:`Date and time format`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`MMM DD, YYYY | hh:mm A`,value:r.dateTimeFormat??``,onChange:e=>d(`dateTimeFormat`,e.target.value)}),(0,u.jsxs)(Q,{type:`secondary`,style:{...m,marginTop:4},children:[`Used wherever a moment is shown — when a record was created or last changed, activity entries, interview slots. Example:`,(0,u.jsxs)(`b`,{children:[` `,n.nr(tT,{...r,showTimeZoneLabel:r.showTimeZoneLabel!==!1})||`—`]})]})]}),(0,u.jsxs)(`div`,{style:{flex:`0 0 200px`},children:[(0,u.jsx)(Q,{type:`secondary`,style:m,children:`Show the time zone`}),(0,u.jsx)(`div`,{children:(0,u.jsx)(c.Switch,{size:`small`,checked:r.showTimeZoneLabel!==!1,onChange:e=>d(`showTimeZoneLabel`,e),checkedChildren:`Shown`,unCheckedChildren:`Hidden`})}),(0,u.jsxs)(Q,{type:`secondary`,style:{...m,marginTop:4},children:[`Adds a small "`,n.sr(r),`" after every time, so nobody has to guess whose clock it is. Only times get it — plain dates never do.`]})]})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:m,children:`Empty placeholder`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`-`,value:r.emptyPlaceholder??``,onChange:e=>d(`emptyPlaceholder`,e.target.value)})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(Q,{type:`secondary`,style:m,children:`Object / array separator`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:` - `,value:r.separator??``,onChange:e=>d(`separator`,e.target.value)})]})]}),(0,u.jsxs)(`div`,{style:{marginTop:18},children:[(0,u.jsx)(Q,{strong:!0,style:{fontSize:12},children:`Empty-value text by kind`}),(0,u.jsx)(Q,{type:`secondary`,style:{...m,marginTop:2},children:`What people see where there is nothing to show. A dash tells them nothing — "No experience added" tells them the record is fine and that part is simply empty. Leave a box blank to use the built-in wording; a single field or section can still say something different.`}),(0,u.jsx)(`div`,{className:`fg-field-meta-row`,style:{marginTop:8,flexWrap:`wrap`},children:wT.map(({key:e,label:t,placeholder:n})=>(0,u.jsxs)(`div`,{style:{flex:`1 1 190px`},children:[(0,u.jsx)(Q,{type:`secondary`,style:m,children:t}),(0,u.jsx)(c.Input,{size:`small`,placeholder:n,value:r.emptyTexts?.[e]??``,onChange:t=>d(`emptyTexts`,{...r.emptyTexts??{},[e]:t.target.value})})]},e))})]})]}),(0,u.jsxs)(`div`,{className:`fg-form-section`,children:[(0,u.jsx)(`div`,{className:`fg-form-section-label`,children:`Candidate detail view`}),(0,u.jsx)(Q,{type:`secondary`,style:m,children:`How a candidate opens from the Sourcing search results — a per-form setting on the search config overrides this tenant-wide default`}),(0,u.jsx)(c.Select,{size:`small`,style:{width:`100%`},value:r.candidateDetailViewMode||`popup`,onChange:e=>d(`candidateDetailViewMode`,e),options:n.gr,getPopupContainer:()=>document.body}),(0,u.jsx)(Q,{type:`secondary`,style:{...m,marginTop:4},children:`"Same page" opens the full detail page and leaves the search — every typed filter is lost on the way back. "Popup" shows the same detail view in a window over the search, so the filters stay put. "New tab" opens the detail page in a separate browser tab.`})]})]})}function kT(){let[e,t]=(0,s.useState)([]),[r,i]=(0,s.useState)(!0),[a,o]=(0,s.useState)(``),[d,f]=(0,s.useState)([]),[p,m]=(0,s.useState)([]),[h,g]=(0,s.useState)([]),[_,v]=(0,s.useState)({}),[y,b]=(0,s.useState)([]),[x,S]=(0,s.useState)([]),[C,w]=(0,s.useState)({}),[T,E]=(0,s.useState)(!1),[D,O]=(0,s.useState)(``),[k,A]=(0,s.useState)(!1),[j,M]=(0,s.useState)(null),[N,P]=(0,s.useState)(null),[F,I]=(0,s.useState)(!1),[L,R]=(0,s.useState)(!1),[z,B]=(0,s.useState)(null),[V,H]=(0,s.useState)(0),[ee,te]=(0,s.useState)(``),[ne,re]=(0,s.useState)([]),[ie,ae]=(0,s.useState)(``),[oe,se]=(0,s.useState)(``),[ce,U]=(0,s.useState)({});function W(e){B(oT[e])}async function le(e,t,r,i){if(Xw(e))return;let a=d;f(n=>n.map(n=>n.id===e.id?{...n,[t]:r}:n)),U(n=>({...n,[`${e.id}:${t}`]:!0}));try{await n.Bi(e.id,{...e,[t]:r}),c.message.success(r?i.on:i.off)}catch(e){f(a),c.message.error(e?.message||`Could not update group visibility`)}finally{U(n=>{let r={...n};return delete r[`${e.id}:${t}`],r})}}async function ue(e,t,r){if(Xw(e))return;let i=String(r??``).trim();if(i===String(e?.[t]??``).trim())return;let a=d;f(n=>n.map(n=>n.id===e.id?{...n,[t]:i}:n));try{await n.Bi(e.id,{...e,[t]:i}),c.message.success(`Empty text saved`)}catch(e){f(a),c.message.error(e?.message||`Could not save empty text`)}}let de=(e,t)=>le(e,`hideGroup`,t,{on:`Group hidden from add/edit forms and the detail view`,off:`Group is visible again`}),G=(e,t)=>le(e,`hideGroupInDetail`,t,{on:`Group hidden from the detail view only — add/edit forms keep it`,off:`Group is visible in the detail view again`}),fe=(e,t)=>le(e,`ignoreShowIfInDetail`,t,{on:`Group always shows in the detail view, even when its Show Condition fails`,off:`Group follows its Show Condition in the detail view`});function pe(){B(null),H(e=>e+1)}(0,s.useEffect)(()=>{n.Hr({limit:200}).then(re).catch(()=>re([]))},[]),(0,s.useEffect)(()=>{n.Xr().then(e=>{let n=qS(e).map(({value:e,label:t})=>({key:e,label:t}));t(n),n.length&&o(n[0].key)}).catch(()=>t([])).finally(()=>i(!1))},[]),(0,s.useEffect)(()=>{if(!a)return;let e=!1;return(async()=>{E(!0),O(``);try{let[t,r]=await Promise.all([n.Ur(a,{clientId:ie}).catch(e=>{if(e?.status===404)return[];throw e}),n.ti(a,{clientId:ie})]);if(e)return;let i=r.sourceFields??[],o=$w(Qw(t,i),r.groups??[]),s=o.groups;se(r.clientId??``),S(i),w(o.labels),f(s),m(dT(s)),g(s.map(e=>({value:e.name,label:e.label??e.name})));let c={};(r.fields??[]).forEach(e=>{c[e.field]=e}),v(c),b(r.merges??[])}catch(t){e||O(t?.message||`Failed to load configuration`)}finally{e||E(!1)}})(),()=>{e=!0}},[a,V,ie]);let me=(0,s.useMemo)(()=>p.map(e=>({value:e.key,label:`${e.label} (${e.key})`})),[p]);async function he(){A(!0);try{let e=Object.entries(_).map(([e,t])=>fT(e,t)).filter(Boolean),{nextGroups:t,changed:r}=hT(d,_);await n.Ai({module:a,fields:e,merges:pT(y),sourceFields:x,groups:eT(C),clientId:ie}),r.length&&(f(t),m(dT(t)),g(t.map(e=>({value:e.name,label:e.label??e.name})))),se(ie),c.message.success(ie?`Detail view configuration saved for this client`:`Detail view configuration saved`)}catch(e){c.message.error(e?.message||`Could not save configuration`)}finally{A(!1)}}function ge(e,t){let n=e?.name;if(!n)return;let r=String(t??``),i=e.inheritedLabel??e.label??n;w(e=>{let t={...e};return!r.trim()||r.trim()===i?delete t[n]:t[n]=r,t}),f(e=>e.map(e=>e.name===n?{...e,inheritedLabel:i,label:r.trim()||i}:e))}function _e(e){v(t=>({...t,[j.key]:{...e,field:j.key}})),M(null)}function K(e){v(t=>{let n={...t};return delete n[e],n})}function q(e){b(t=>{let n=[...t];return N.index===null?n.push(e):n[N.index]=e,n}),P(null)}function J(e,t,n=!1){v(r=>{let i=r[e]??{field:e};return n?{...r,[e]:{...i,hideInDetail:t,hidden:void 0}}:{...r,[e]:{...i,hidden:t}}})}let ve=e=>{if(!e)return null;let t=[];e.label&&t.push((0,u.jsx)(c.Tag,{color:`blue`,children:`label`},`l`)),(e.prefix||e.suffix)&&t.push((0,u.jsx)(c.Tag,{color:`geekblue`,children:`±fix`},`ps`)),e.color&&t.push((0,u.jsx)(c.Tag,{color:e.color,children:`colour`},`c`)),e.capitalize===!0&&t.push((0,u.jsx)(c.Tag,{color:`purple`,children:`Title`},`cap`)),e.capitalize===!1&&t.push((0,u.jsx)(c.Tag,{color:`default`,children:`raw`},`cap`)),e.lookupCollection&&t.push((0,u.jsxs)(c.Tag,{color:`volcano`,children:[`lookup: `,e.lookupCollection]},`lk`)),e.ignoreLabelWhenInDetail&&t.push((0,u.jsx)(c.Tag,{color:`default`,children:`static label`},`ilw`));let n=e.renderType||(e.documentPreview?`document`:e.displayAs);return n&&n!==`auto`&&t.push((0,u.jsx)(c.Tag,{color:`cyan`,children:n},`rt`)),t.length?t:(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`—`})},ye=[{title:`Group`,dataIndex:`label`,key:`label`,render:(e,t)=>{let n=t.inheritedLabel??e??t.name,r=C[t.name]??``;return(0,u.jsxs)(c.Space,{size:6,direction:`vertical`,style:{width:`100%`},children:[(0,u.jsxs)(c.Space,{size:6,style:{width:`100%`},children:[(0,u.jsx)(c.Input,{size:`small`,value:r||(e??t.name)||``,placeholder:n,onChange:e=>ge(t,e.target.value),style:{fontWeight:600}}),Xw(t)&&(0,u.jsx)(c.Tag,{color:`cyan`,children:`Detail only`})]}),r&&r!==n&&(0,u.jsxs)(c.Space,{size:4,children:[(0,u.jsxs)(Q,{type:`secondary`,style:{fontSize:11},children:[`Detail only · Form Groups shows “`,n,`”`]}),(0,u.jsx)(c.Button,{type:`link`,size:`small`,style:{padding:0,height:`auto`,fontSize:11},onClick:()=>ge(t,``),children:`reset`})]})]})}},{title:`Key`,dataIndex:`name`,key:`name`,render:e=>(0,u.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Order`,dataIndex:`order`,key:`order`,width:72,align:`center`,render:e=>(0,u.jsx)(`span`,{className:`fg-order-cell`,children:e??0})},{title:`Fields`,dataIndex:`fields`,key:`fields`,width:76,align:`center`,render:e=>(0,u.jsx)(c.Badge,{count:e?.length??0,showZero:!0,color:`var(--color-brand)`})},{title:`Customized`,key:`cust`,width:100,align:`center`,render:(e,t)=>{let n=(t.fields??[]).filter(e=>_[e.field]).length;return n?(0,u.jsx)(c.Tag,{color:`blue`,style:{margin:0},children:n}):(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`—`})}},{title:`Hide Group`,key:`hideGroup`,width:110,align:`center`,render:(e,t)=>Xw(t)?(0,u.jsx)(Q,{type:`secondary`,children:`—`}):(0,u.jsx)(c.Tooltip,{title:uT(t.hideGroup)?`Hidden from add/edit forms AND the detail view`:`Visible in both — same flag as Form Groups`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Hide`,unCheckedChildren:`Show`,checked:uT(t.hideGroup),loading:!!ce[`${t.id}:hideGroup`],onChange:e=>de(t,e)})})},{title:`Show Condition`,key:`ignoreShowIfInDetail`,width:130,align:`center`,render:(e,t)=>{if(Xw(t))return(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`—`});let n=t.showIf?.field?`${t.showIf.field} ${t.showIf.operator??`eq`} ${t.showIf.value??``}`.trim():null;return n?(0,u.jsx)(c.Tooltip,{title:uT(t.ignoreShowIfInDetail)?`Always shown, ignoring "${n}"`:`Hidden in the detail view unless "${n}"`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Always`,unCheckedChildren:`Follow`,checked:uT(t.ignoreShowIfInDetail),loading:!!ce[`${t.id}:ignoreShowIfInDetail`],onChange:e=>fe(t,e)})}):(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`—`})}},{title:`Empty Text`,key:`emptyText`,width:220,render:(e,t)=>uT(t.addRow)?(0,u.jsx)(c.Input,{size:`small`,defaultValue:t.emptyText??``,placeholder:`No ${String(t.label??t.name??``).toLowerCase()} added`,onBlur:e=>ue(t,`emptyText`,e.target.value),onPressEnter:e=>e.currentTarget.blur()}):(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`—`})},{title:`Hide in Detail`,key:`hideGroupInDetail`,width:120,align:`center`,render:(e,t)=>Xw(t)?(0,u.jsx)(Q,{type:`secondary`,children:`—`}):(0,u.jsx)(c.Tooltip,{title:uT(t.hideGroupInDetail)?`Hidden from the DETAIL VIEW only — the add/edit forms still show this group`:`Shown in the detail view. Hide here to remove it from the detail view without touching the forms`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Hide`,unCheckedChildren:`Show`,checked:uT(t.hideGroupInDetail),loading:!!ce[`${t.id}:hideGroupInDetail`],onChange:e=>G(t,e)})})}],be=e=>{let t=e.fields??[],n=Xw(e);return t.length?(0,u.jsx)(`div`,{className:`fg-expanded-fields`,children:t.map(t=>{let r=_[t.field],i=n?!!r?.hideInDetail:r?.hidden??mT(t),a={key:t.field,label:t.label??t.field,type:t.type??`text`,group:e.label??e.name,detailOnly:n,labelWhen:t.labelWhen,lookupDefaults:t.lookupCollection?{lookupCollection:t.lookupCollection,displayField:t.displayField??``,displayField2:t.displayField2??``,valueField:t.valueField||`_id`}:{}};return(0,u.jsxs)(`div`,{className:`fg-field-row`,children:[(0,u.jsxs)(`div`,{className:`fg-field-row-info`,children:[(0,u.jsx)(`span`,{className:`fg-field-row-label`,children:r?.label||t.label}),(0,u.jsx)(`span`,{className:`fg-field-row-key`,children:t.field}),(0,u.jsxs)(`span`,{className:`fg-field-row-type`,children:[`(`,t.type,`)`]}),PC(t)&&(0,u.jsx)(c.Tooltip,{title:(()=>{let e=FC(t);return`Configured unique in Form Groups on "${e?.value?.collectionField||t.payloadKey||t.field}"${e?.message?` — "${e.message}"`:``}. Edit it there; this screen is display only.`})(),children:(0,u.jsx)(c.Tag,{color:`magenta`,style:{marginLeft:6},children:`Unique`})}),(()=>{let e=(r?.labelWhen??[]).filter(e=>e?.field&&e?.label),n=e.length?e:t.labelWhen?.field&&t.labelWhen?.label?[t.labelWhen]:[];if(!n.length)return null;let i=r?.ignoreLabelWhenInDetail;return(0,u.jsx)(c.Tooltip,{title:i?`Conditional labels ignored here — the detail view always shows "${t.label}"`:`${e.length?`Set in Detail Groups`:`Inherited from Form Groups`} — ${n.map(e=>`"${e.label}" when ${e.field} ${e.operator??`eq`} ${e.value??``}`.trim()).join(`; `)}`,children:(0,u.jsxs)(c.Tag,{color:i?`default`:e.length?`purple`:`blue`,style:{marginLeft:6},children:[`⇄ `,n[0].label,n.length>1?` +${n.length-1}`:``]})})})()]}),(0,u.jsx)(`div`,{className:`fg-field-row-flags`,children:ve(r)}),(0,u.jsxs)(c.Space,{size:4,style:{marginLeft:`auto`},children:[(0,u.jsx)(c.Tooltip,{title:n?i?`Hidden from the detail view`:`Visible in the detail view`:i?`Hidden in form and detail view`:`Visible`,children:(0,u.jsx)(c.Switch,{size:`small`,checkedChildren:`Hide`,unCheckedChildren:`Show`,checked:i,onChange:e=>J(t.field,e,n)})}),(0,u.jsx)(c.Tooltip,{title:`Customize field`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>M(a)})}),r&&(0,u.jsx)(c.Tooltip,{title:`Reset to default`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,danger:!0,icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:()=>K(t.field)})})]})]},t.field)})}):(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`No fields in this group.`})},xe=(0,s.useMemo)(()=>{let e=ee.trim().toLowerCase();return[...d].filter(t=>!e||[t.label,t.name,...(t.fields??[]).flatMap(e=>[e.label,e.field,e.type])].some(t=>String(t??``).toLowerCase().includes(e))).sort((e,t)=>(e.order??0)-(t.order??0))},[d,ee]),Se=[{title:`Label`,dataIndex:`label`,key:`label`,render:(e,t)=>(0,u.jsxs)(`span`,{children:[(0,u.jsx)(Q,{strong:!0,children:e||t.key}),(0,u.jsx)(`span`,{className:`fg-field-key-hint`,children:t.key})]})},{title:`Fields`,dataIndex:`fields`,key:`fields`,render:e=>(0,u.jsx)(c.Space,{size:4,wrap:!0,children:(e??[]).map(e=>(0,u.jsx)(c.Tag,{children:e},e))})},{title:`Format`,key:`sep`,width:220,render:(e,t)=>(0,u.jsx)(`code`,{className:`fg-table-code`,children:t.template?.trim()?t.template:`join: ${t.separator||` - `}`})},{title:``,key:`actions`,width:90,align:`right`,render:(e,t,n)=>(0,u.jsxs)(c.Space,{size:4,children:[(0,u.jsx)(c.Tooltip,{title:`Edit`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>P({index:n,merge:t})})}),(0,u.jsx)(c.Tooltip,{title:`Delete`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{}),onClick:()=>b(e=>e.filter((e,t)=>t!==n))})})]})}],Ce=e.map(e=>({key:e.key,label:e.label}));return(0,u.jsxs)(`div`,{className:`fg-section`,children:[(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.BgColorsOutlined,{}),title:`Detail Groups`,extra:(0,u.jsxs)(c.Space,{size:8,wrap:!0,children:[(0,u.jsx)(c.Button,{size:`small`,icon:(0,u.jsx)(l.DatabaseOutlined,{}),disabled:!a,onClick:()=>W(`discoverFields`),children:`Read Database Fields`}),(0,u.jsx)(c.Dropdown,{trigger:[`click`],menu:{items:[{key:`save`,label:`Save current as default`,icon:(0,u.jsx)(l.SaveOutlined,{}),onClick:()=>W(`save`)},{key:`restore`,label:`Restore saved default`,icon:(0,u.jsx)(l.CloudDownloadOutlined,{}),onClick:()=>W(`restore`)},{type:`divider`},{key:`reset`,label:`Reset all detail settings`,icon:(0,u.jsx)(l.ReloadOutlined,{}),danger:!0,onClick:()=>W(`reset`)}]},children:(0,u.jsx)(c.Button,{size:`small`,icon:(0,u.jsx)(l.MoreOutlined,{}),children:`Workspace defaults`})}),(0,u.jsx)(c.Button,{size:`small`,icon:(0,u.jsx)(l.SettingOutlined,{}),onClick:()=>R(!0),children:`Display Defaults`}),(0,u.jsx)(c.Button,{size:`small`,icon:(0,u.jsx)(l.EyeOutlined,{}),disabled:!a,onClick:()=>I(!0),children:`Preview`}),(0,u.jsx)(c.Button,{type:`primary`,size:`small`,icon:(0,u.jsx)(l.SaveOutlined,{}),loading:k,disabled:!a,onClick:he,children:`Save Configuration`})]}),children:[(0,u.jsx)(`div`,{className:`admin-accent-bar`}),(0,u.jsxs)(`div`,{className:`fg-scope-toolbar`,style:{marginBottom:12},children:[(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`Select a client to edit a client-scoped detail view for this module. Leave blank for the module default. A record belonging to a client automatically uses that client's detail config, falling back to the default when the client has none.`}),(0,u.jsxs)(c.Space,{wrap:!0,size:8,children:[(0,u.jsx)(c.Select,{size:`small`,allowClear:!0,showSearch:!0,placeholder:`Client (default)`,style:{width:240},value:ie||void 0,optionFilterProp:`label`,options:ne.map(e=>({value:e._id??e.id,label:e.clientName??e.name??e.clientRefrenceId??e._id})).filter(e=>e.value),onChange:e=>ae(e??``)}),(0,u.jsx)(c.Button,{size:`small`,icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:()=>H(e=>e+1),children:`Reload`})]})]}),ie&&!oe&&!T&&(0,u.jsx)(c.Alert,{type:`info`,showIcon:!0,style:{marginBottom:12},message:`This client has no detail config of its own yet`,description:`You are viewing the module default. Saving now creates a config for this client only — the default and every other client are left untouched.`}),!T&&x.length>0&&(0,u.jsx)(c.Alert,{type:`success`,showIcon:!0,style:{marginBottom:12},message:`${x.length} database field${x.length===1?``:`s`} available to this detail view`,description:`These fields are stored only in Detail configuration and do not appear in Add or Edit forms. Read Database Fields again to refresh the list after the collection schema changes.`}),(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:13},children:`Customize how each module's detail view renders: per-field label, prefix/suffix, colour, capitalization, hide, reference lookups (id → name), and merged display fields. These overrides are applied on top of Form Groups and the add/edit forms are unaffected — except "Hide Group", which is the same flag Form Groups uses, so hiding a group here (or there) hides it in both places. "Hide in Detail" hides the group from the detail view only, leaving the forms untouched.`})]}),(0,u.jsx)(Z,{styles:{body:{paddingTop:8}},children:(0,u.jsxs)(c.Spin,{spinning:r,children:[(0,u.jsx)(c.Tabs,{activeKey:a,onChange:o,items:Ce.map(e=>({...e,children:null})),className:`admin-module-tabs`}),D&&(0,u.jsx)(c.Alert,{type:`error`,showIcon:!0,message:D,style:{marginBottom:12}}),(0,u.jsxs)(c.Spin,{spinning:T,children:[(0,u.jsxs)(`div`,{className:`admin-config-table-tools`,children:[(0,u.jsx)(c.Input,{allowClear:!0,prefix:(0,u.jsx)(l.SearchOutlined,{}),placeholder:`Search groups or fields`,value:ee,onChange:e=>te(e.target.value)}),(0,u.jsxs)(Q,{type:`secondary`,style:{fontSize:12},children:[d.length,` groups · `,p.length,` fields`,x.length?` · ${x.length} from database`:``]})]}),(0,u.jsx)(c.Table,{rowKey:e=>e.id??e.name,dataSource:xe,columns:ye,pagination:!1,size:`small`,className:`fg-table`,expandable:{expandedRowRender:be,rowExpandable:()=>!0},locale:{emptyText:(0,u.jsx)(c.Empty,{description:`Select a module to see its groups and fields.`,image:c.Empty.PRESENTED_IMAGE_SIMPLE})}}),(0,u.jsxs)(`div`,{style:{margin:`20px 0 8px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,u.jsxs)(Q,{strong:!0,children:[(0,u.jsx)(l.MergeCellsOutlined,{}),` Merged Fields`]}),(0,u.jsx)(c.Button,{size:`small`,type:`dashed`,icon:(0,u.jsx)(l.PlusOutlined,{}),disabled:!a,onClick:()=>P({index:null,merge:null}),children:`Add Merge`})]}),(0,u.jsx)(c.Table,{rowKey:`key`,dataSource:y,columns:Se,pagination:!1,size:`small`,className:`fg-table`,locale:{emptyText:(0,u.jsx)(c.Empty,{description:`No merged fields. Combine e.g. 'from' + 'to' into one.`,image:c.Empty.PRESENTED_IMAGE_SIMPLE})}})]})]})}),(0,u.jsx)(vT,{open:!!j,fieldMeta:j,value:j?{...j.lookupDefaults,..._[j.key]??{}}:null,moduleFieldOptions:me,onClose:()=>M(null),onSave:_e},j?.key??`field-closed`),(0,u.jsx)(xT,{open:!!N,merge:N?.merge,fieldOptions:me,groupOptions:h,onClose:()=>P(null),onSave:q},N?`merge-${N.index??`new`}`:`merge-closed`),(0,u.jsx)(OT,{open:L,onClose:()=>R(!1)}),(0,u.jsx)(ST,{open:F,module:a,onClose:()=>I(!1)}),(0,u.jsx)(zC,{open:!!z,scope:`detailConfig`,action:z?.action,title:z?.title,description:z?.description,confirmLabel:z?.confirmLabel,danger:z?.danger,onCancel:()=>B(null),onVerified:pe,onConfirm:z?.action===`discoverFields`?e=>n.Br({module:a,clientId:ie,otp:e}):void 0})]})}var AT=`/admin/email-templates`,jT=`/email-templates`;function MT(e){return e?.data??e}async function NT({offset:e=0,limit:n=20,search:r=``,module:i=``,action:a=``,active:o}={}){let s=new URLSearchParams({offset:String(e),limit:String(n)});r&&s.set(`search`,r),i&&s.set(`module`,i),a&&s.set(`action`,a),o!==void 0&&s.set(`active`,String(o));let c=MT(await t.o(t.x,`${AT}?${s}`))??{};return{items:Array.isArray(c.items)?c.items:[],totalCount:Number(c.totalCount??0)}}async function PT(e){return MT(await t.o(t.x,`${AT}/${encodeURIComponent(e)}`))}async function FT(e){return t.o(t.x,AT,{method:`POST`,body:JSON.stringify(e)})}async function IT(e,n){return t.o(t.x,`${AT}/${encodeURIComponent(e)}`,{method:`PUT`,body:JSON.stringify(n)})}async function LT(e){return t.o(t.x,`${AT}/${encodeURIComponent(e)}`,{method:`DELETE`})}async function RT({module:e=``,action:n=``}={}){let r=new URLSearchParams;e&&r.set(`module`,e),n&&r.set(`action`,n);let i=r.toString()?`?${r}`:``,a=MT(await t.o(t.x,`${jT}${i}`));return Array.isArray(a)?a:[]}async function zT(e){return MT(await t.o(t.x,`${jT}/${encodeURIComponent(e)}`))}async function BT(){let e=MT(await t.o(t.x,`/signature/placeHolder?module=userSignature`))??{},n=Array.isArray(e.Keys)?e.Keys:Array.isArray(e.keys)?e.keys:[];return{placeHolderStart:e.placeHolderStart??`{{`,placeHolderEnd:e.placeHolderEnd??`}}`,module:e.module??`userSignature`,keys:n}}async function VT({offset:e=0,limit:n=20,search:r=``}={}){let i=new URLSearchParams({offset:String(e),limit:String(n),sortBy:`new`,searchValue:r}),a=MT(await t.o(t.x,`/signature/homePage?${i}`))??{},o=Array.isArray(a.data)?a.data.map(e=>({...e,isActive:e.isActive??e.status??!1})):[];return{items:o,totalCount:Number(a.totalCount??o.length)}}async function HT(e){return MT(await t.o(t.x,`/signature/editPreview?signatureId=${encodeURIComponent(e)}`))}async function UT(e){return t.o(t.x,`/signature/add`,{method:`POST`,body:JSON.stringify(e)})}async function WT(e){return t.o(t.x,`/signature/edit`,{method:`PUT`,body:JSON.stringify(e)})}async function GT(e){return t.o(t.x,`/signature/delete?signatureId=${encodeURIComponent(e)}`,{method:`DELETE`})}async function KT(e,n){return t.o(t.x,`/signature/statusUpdate?signatureId=${encodeURIComponent(e)}&status=${n}`,{method:`PUT`})}var qT={reset:{action:`reset`,title:`Reset all row actions`,confirmLabel:`Reset All`,danger:!0,description:`This clears every configured row action for every module in this workspace. Actions have no built-in defaults, so this leaves every module with no actions until reconfigured.`},save:{action:`save`,title:`Save current as default`,confirmLabel:`Save Default`,danger:!1,description:`Snapshots the current row actions for all modules and roles as the saved default you can restore to later.`},restore:{action:`restore`,title:`Restore saved default`,confirmLabel:`Restore Default`,danger:!0,description:`Replaces the current row actions for all modules and roles with the last saved default.`}},{Text:JT}=c.Typography,YT=[{value:`delete`,label:`delete (trash)`},{value:`edit`,label:`edit (pencil)`},{value:`mail`,label:`mail (envelope)`},{value:`shareAlt`,label:`shareAlt (share)`},{value:`swap`,label:`swap (arrows)`},{value:`thunderbolt`,label:`thunderbolt (lightning)`},{value:`userAdd`,label:`userAdd (add user)`},{value:`userSwitch`,label:`userSwitch (switch user)`}],XT=[{value:`navigate`,label:`Navigate (open page)`},{value:`modal`,label:`Modal (open popup)`},{value:`api`,label:`API (call endpoint)`},{value:`copy`,label:`Copy (clipboard)`},{value:`document`,label:`Document (open viewer)`},{value:`group`,label:`Group (submenu of child actions)`}],ZT=[`GET`,`POST`,`PUT`,`DELETE`],QT=[`quick-submit`,`add-notes`,`mail`,`change-status`,`tag-to-job`,`add-to-groups`,`self-assign`,`others-assign`,`delete`,`vendor-share`,`sticky-notes`,`move-to-onboarding`,`approve-rate`,`reject`,`add-batch-candidate`],$T={key:``,label:``,icon:``,actionType:`navigate`,routeTemplate:``,linkTarget:`_self`,apiMethod:`POST`,apiPath:``,popupKey:``,popupStateText:``,copyField:``,documentField:``,allowedTabs:[],popupFieldName:``,popupFieldDataSource:``,popupFieldMasterName:``,popupFieldLabelKey:``,popupFieldValueKey:``,permission:``,permissionModule:``,permissionAction:``,permissionKey:``,allowMultiple:!1,danger:!1,showInList:!0,showInDetail:!1,detailPlacement:`more`,requireJobId:!1,doneLabel:``,doneField:``,doneOperator:`notEmpty`,doneValue:``,doneTone:`success`},eE={jobBased:!1,recipientSource:`selectedRecords`,recipientFields:[`email`,`customFields.diceProfileData.email`],recipientMode:`allSelected`,removeDuplicateRecipients:!0,jobIdSource:`context`,jobIdField:`jobId`,jobIdReadOnly:!0,autoFetchJobContent:!0,requiredTo:!0,requiredJobId:!0,requiredSubject:!0,requiredBody:!0},tE=[{value:`notEmpty`,label:`is set (not empty)`},{value:`eq`,label:`equals`},{value:`ne`,label:`not equals`},{value:`isEmpty`,label:`is empty`}];function nE(){return`action_${Date.now()}`}function rE({open:e,initial:t,isChild:n,moduleName:r,popupForms:i,templateOptions:a,permissionModules:o,permissionActions:d,onClose:f,onSave:p}){let[m]=c.Form.useForm(),[h,g]=(0,s.useState)(!1),_=c.Form.useWatch(`actionType`,m)??`navigate`,v=c.Form.useWatch(`showInDetail`,m)??!1,y=c.Form.useWatch(`popupKey`,m)??``,b=c.Form.useWatch(`doneOperator`,m)??`notEmpty`,x=c.Form.useWatch(`mailJobBased`,m)??!1,S=c.Form.useWatch(`mailRecipientSource`,m)??`selectedRecords`,C=c.Form.useWatch(`mailJobIdSource`,m)??`context`;(0,s.useEffect)(()=>{if(e){let[e=``,n=``]=(t?.permission??``).split(`.`),i=String(r??``).trim().toLowerCase().replace(/[^a-z0-9]/g,``).includes(`candidate`),a=t?.requireJobId??i;m.setFieldsValue({...$T,...t,permissionModule:e,permissionAction:n,popupStateText:t?.popupState?JSON.stringify(t.popupState,null,2):``,doneField:t?.doneWhen?.field??``,doneOperator:t?.doneWhen?.operator??`notEmpty`,doneValue:t?.doneWhen?.value??``,doneLabel:t?.doneLabel??``,doneTone:t?.doneTone??`success`,popupFieldName:t?.popupFieldOverrides?.[0]?.name??``,popupFieldDataSource:t?.popupFieldOverrides?.[0]?.dataSource??``,popupFieldMasterName:t?.popupFieldOverrides?.[0]?.masterName??``,popupFieldLabelKey:t?.popupFieldOverrides?.[0]?.labelKey??``,popupFieldValueKey:t?.popupFieldOverrides?.[0]?.valueKey??``,mailJobBased:t?.mailConfig?.jobBased??a,mailRecipientSource:t?.mailConfig?.recipientSource??eE.recipientSource,mailRecipientFields:t?.mailConfig?.recipientFields??eE.recipientFields,mailRecipientMode:t?.mailConfig?.recipientMode??eE.recipientMode,mailRemoveDuplicateRecipients:t?.mailConfig?.removeDuplicateRecipients??eE.removeDuplicateRecipients,mailJobIdSource:t?.mailConfig?.jobIdSource??eE.jobIdSource,mailJobIdField:t?.mailConfig?.jobIdField??eE.jobIdField,mailJobIdReadOnly:t?.mailConfig?.jobIdReadOnly??eE.jobIdReadOnly,mailAutoFetchJobContent:t?.mailConfig?.autoFetchJobContent??eE.autoFetchJobContent,mailRequiredTo:t?.mailConfig?.requiredTo??eE.requiredTo,mailRequiredJobId:t?.mailConfig?.requiredJobId??a,mailRequiredSubject:t?.mailConfig?.requiredSubject??eE.requiredSubject,mailRequiredBody:t?.mailConfig?.requiredBody??eE.requiredBody})}},[e,t,m,r]);let w=async()=>{let e=await m.validateFields(),t;if(e.popupStateText?.trim())try{t=JSON.parse(e.popupStateText)}catch{m.setFields([{name:`popupStateText`,errors:[`Enter valid JSON`]}]);return}let n={...e};delete n.popupStateText;let{permissionModule:r,permissionAction:i}=n;delete n.permissionModule,delete n.permissionAction,n.permission=r&&i?`${r}.${i}`:``;let{doneField:a,doneOperator:o,doneValue:s}=n;if(delete n.doneField,delete n.doneOperator,delete n.doneValue,a?.trim()){let e=o||`notEmpty`,t=e===`eq`||e===`ne`;n.doneWhen={field:a.trim(),operator:e,...t?{value:(s??``).trim()}:{}},n.doneLabel?.trim()||(n.doneLabel=``)}else n.doneWhen=void 0,n.doneLabel=``;(n.actionType!==`modal`||![`mail`,`vendor-share`].includes(n.popupKey))&&delete n.defaultTemplateId,n.actionType===`modal`&&n.popupKey===`mail`?(n.mailConfig={jobBased:!!n.mailJobBased,recipientSource:n.mailRecipientSource||eE.recipientSource,recipientFields:(n.mailRecipientFields??eE.recipientFields).map(e=>String(e??``).trim()).filter(Boolean),recipientMode:n.mailRecipientMode||eE.recipientMode,removeDuplicateRecipients:n.mailRemoveDuplicateRecipients!==!1,jobIdSource:n.mailJobIdSource||eE.jobIdSource,jobIdField:String(n.mailJobIdField??eE.jobIdField).trim()||eE.jobIdField,jobIdReadOnly:!!n.mailJobBased&&!!n.mailJobIdReadOnly,autoFetchJobContent:!!n.mailJobBased&&n.mailAutoFetchJobContent!==!1,requiredTo:n.mailRequiredTo!==!1,requiredJobId:!!n.mailJobBased&&!!n.mailRequiredJobId,requiredSubject:n.mailRequiredSubject!==!1,requiredBody:n.mailRequiredBody!==!1},n.requireJobId=n.mailConfig.requiredJobId):(delete n.requireJobId,delete n.mailConfig),[`mailJobBased`,`mailRecipientSource`,`mailRecipientFields`,`mailRecipientMode`,`mailRemoveDuplicateRecipients`,`mailJobIdSource`,`mailJobIdField`,`mailJobIdReadOnly`,`mailAutoFetchJobContent`,`mailRequiredTo`,`mailRequiredJobId`,`mailRequiredSubject`,`mailRequiredBody`].forEach(e=>delete n[e]);let{popupFieldName:c,popupFieldDataSource:l,popupFieldMasterName:u,popupFieldLabelKey:d,popupFieldValueKey:f}=n;delete n.popupFieldName,delete n.popupFieldDataSource,delete n.popupFieldMasterName,delete n.popupFieldLabelKey,delete n.popupFieldValueKey;let h=c?.trim()||(n.popupKey===`change-status`?`status`:``),_=d?.trim()||(u?.trim()===`clientSubmissions`?`clientSubmissionStatusText`:``),v=f?.trim()||(u?.trim()===`clientSubmissions`?`clientSubmissionStatusText`:``);n.popupFieldOverrides=n.actionType===`modal`&&h&&l?[{name:h,dataSource:l,...l===`master`?{masterName:u?.trim()}:{},..._?{labelKey:_}:{},...v?{valueKey:v}:{}}]:void 0,g(!0);try{await p({...n,...t?{popupState:t}:{popupState:void 0}})}finally{g(!1)}},T=[...QT.map(e=>({value:e,label:`${e} (built-in)`})),...i.map(e=>({value:e.action,label:`${e.label} (${e.action})`}))].filter((e,t,n)=>n.findIndex(t=>t.value===e.value)===t);return(0,u.jsx)(c.Modal,{title:`${t?.key?`Edit`:`Add`}${n?` Child`:``} Action`,width:720,open:e,onCancel:f,onOk:w,confirmLoading:h,okText:`Save Action`,okButtonProps:{icon:(0,u.jsx)(l.SaveOutlined,{})},className:`fg-editor-modal action-editor-modal`,children:(0,u.jsxs)(c.Form,{form:m,layout:`vertical`,initialValues:$T,className:`action-editor-form`,children:[(0,u.jsx)(`div`,{className:`action-editor-intro`,children:`Choose what the action does, then decide where it appears and who can use it.`}),(0,u.jsxs)(`div`,{className:`action-editor-grid`,children:[(0,u.jsx)(c.Form.Item,{name:`key`,label:`Key`,rules:[{required:!0,message:`Key is required`}],children:(0,u.jsx)(c.Input,{placeholder:`e.g. sourceCandidates`})}),(0,u.jsx)(c.Form.Item,{name:`label`,label:`Label`,rules:[{required:!0,message:`Label is required`}],children:(0,u.jsx)(c.Input,{placeholder:`e.g. Source Candidates`})}),(0,u.jsx)(c.Form.Item,{name:`icon`,label:`Icon`,rules:[{required:!1,message:`Icon is required`}],children:(0,u.jsx)(c.Select,{options:YT,placeholder:`Select icon`,allowClear:!0})}),(0,u.jsx)(c.Form.Item,{name:`actionType`,label:`Action Type`,rules:[{required:!0}],children:(0,u.jsx)(c.Select,{options:XT})})]}),_===`group`&&(0,u.jsx)(c.Alert,{type:`info`,showIcon:!0,message:`Group actions don't run anything themselves.`,description:`This action renders as a submenu. Save it, then use "Add Child Action" on its row to configure what appears inside (e.g. Tag To Job, Send Mail, Add Notes).`,style:{marginBottom:16}}),_!==`group`&&(0,u.jsx)(`div`,{className:`action-editor-section-title`,children:`Behaviour`}),_===`navigate`&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Form.Item,{name:`routeTemplate`,label:`Route Template`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{placeholder:`e.g. /app/jobs/edit/:_id`})}),(0,u.jsx)(c.Form.Item,{name:`linkTarget`,label:`Open in`,tooltip:`New tab is useful for a reference page the user shouldn't lose their place to (e.g. Open JD from Quick Submit).`,children:(0,u.jsx)(c.Select,{options:[{value:`_self`,label:`Same tab`},{value:`_blank`,label:`New tab`}]})})]}),_===`modal`&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Form.Item,{name:`popupKey`,label:`Popup`,rules:[{required:!0,message:`Select a popup`}],tooltip:`Admin popup forms and built-in popup integrations are listed together.`,children:(0,u.jsx)(c.Select,{showSearch:!0,optionFilterProp:`label`,options:T,placeholder:`Select popup form`})}),(0,u.jsx)(c.Form.Item,{name:`popupStateText`,label:`Popup Context (JSON, optional)`,tooltip:`Static context passed to the popup, for example {"notesfor":"candidate"}`,children:(0,u.jsx)(c.Input.TextArea,{rows:4,placeholder:`{"notesfor":"candidate"}`})}),(0,u.jsxs)(c.Space.Compact,{block:!0,children:[(0,u.jsx)(c.Form.Item,{name:`apiMethod`,label:`Submit Method`,style:{width:150},children:(0,u.jsx)(c.Select,{options:ZT.map(e=>({value:e,label:e}))})}),(0,u.jsx)(c.Form.Item,{name:`apiPath`,label:`Submit API (optional)`,style:{flex:1},tooltip:`Leave empty to use the built-in handler for the selected popup key.`,children:(0,u.jsx)(c.Input,{placeholder:`e.g. /module-data-update`})})]}),(0,u.jsx)(`div`,{className:`action-editor-section-title`,children:`Popup Dropdown Source`}),(0,u.jsxs)(c.Space.Compact,{block:!0,children:[(0,u.jsx)(c.Form.Item,{name:`popupFieldName`,label:`Field Name`,style:{width:`28%`},tooltip:`The popup field to override. For Change Status, use "status".`,children:(0,u.jsx)(c.Input,{placeholder:`status`})}),(0,u.jsx)(c.Form.Item,{name:`popupFieldDataSource`,label:`Source`,style:{width:`24%`},children:(0,u.jsx)(c.Select,{allowClear:!0,options:[{value:`master`,label:`Master`}],placeholder:`Default`})}),(0,u.jsx)(c.Form.Item,{name:`popupFieldMasterName`,label:`Master Name`,style:{width:`48%`},children:(0,u.jsx)(c.Input,{placeholder:`clientSubmissions`})})]}),(0,u.jsxs)(c.Space.Compact,{block:!0,children:[(0,u.jsx)(c.Form.Item,{name:`popupFieldLabelKey`,label:`Label Key`,style:{width:`50%`},children:(0,u.jsx)(c.Input,{placeholder:`clientSubmissionStatusText`})}),(0,u.jsx)(c.Form.Item,{name:`popupFieldValueKey`,label:`Value Key`,style:{width:`50%`},children:(0,u.jsx)(c.Input,{placeholder:`clientSubmissionStatusText`})})]})]}),_===`modal`&&[`mail`,`vendor-share`].includes(y)&&(0,u.jsx)(c.Form.Item,{name:`defaultTemplateId`,label:`Default Email Template`,tooltip:`This template is selected and loaded automatically whenever this action opens the mail composer.`,children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,options:a,placeholder:`No default — user selects in composer`})}),_===`modal`&&y===`mail`&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`div`,{className:`action-editor-section-title`,children:`Mail Configuration`}),(0,u.jsx)(c.Alert,{type:`info`,showIcon:!0,message:`Configure the shared Send Mail popup without module-specific code.`,description:`For Source Candidate, use Selected Records for recipients and Current Job / Popup Context for Job ID. The search page already passes the opened Job ID into the popup context.`,style:{marginBottom:16}}),(0,u.jsxs)(`div`,{className:`action-toggle-grid`,children:[(0,u.jsx)(c.Form.Item,{name:`mailJobBased`,label:`Job Based Mail`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{})}),(0,u.jsx)(c.Form.Item,{name:`mailRemoveDuplicateRecipients`,label:`Remove Duplicate To Mail`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{})}),(0,u.jsx)(c.Form.Item,{name:`mailAutoFetchJobContent`,label:`Auto Fetch Subject & Body`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{disabled:!x})}),(0,u.jsx)(c.Form.Item,{name:`mailJobIdReadOnly`,label:`Lock Context Job ID`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{disabled:!x||C===`manual`})})]}),(0,u.jsxs)(c.Space.Compact,{block:!0,children:[(0,u.jsx)(c.Form.Item,{name:`mailRecipientSource`,label:`To Mail Source`,style:{width:`45%`},children:(0,u.jsx)(c.Select,{options:[{value:`selectedRecords`,label:`Selected Records`},{value:`manual`,label:`Manual`}]})}),(0,u.jsx)(c.Form.Item,{name:`mailRecipientMode`,label:`Recipient Mode`,style:{width:`55%`},children:(0,u.jsx)(c.Select,{disabled:S!==`selectedRecords`,options:[{value:`allSelected`,label:`All Selected Candidates`},{value:`firstSelected`,label:`First Selected Candidate`}]})})]}),(0,u.jsx)(c.Form.Item,{name:`mailRecipientFields`,label:`Recipient Email Fields`,tooltip:`Field paths are checked in order on selected candidate records. Add provider-specific paths when needed.`,children:(0,u.jsx)(c.Select,{mode:`tags`,tokenSeparators:[`,`],disabled:S!==`selectedRecords`,placeholder:`email, customFields.diceProfileData.email`})}),x&&(0,u.jsxs)(c.Space.Compact,{block:!0,children:[(0,u.jsx)(c.Form.Item,{name:`mailJobIdSource`,label:`Job ID Source`,style:{width:`48%`},children:(0,u.jsx)(c.Select,{options:[{value:`context`,label:`Current Job / Popup Context`},{value:`selectedRecord`,label:`Selected Record`},{value:`manual`,label:`Manual Search`}]})}),(0,u.jsx)(c.Form.Item,{name:`mailJobIdField`,label:`Job ID Field`,style:{width:`52%`},tooltip:`For Source Candidate use jobId. The same field can be read from popup context or the selected record.`,children:(0,u.jsx)(c.Input,{disabled:C===`manual`,placeholder:`jobId`})})]}),(0,u.jsx)(`div`,{className:`action-editor-section-title`,children:`Mail Mandatory Fields`}),(0,u.jsxs)(`div`,{className:`action-toggle-grid`,children:[(0,u.jsx)(c.Form.Item,{name:`mailRequiredTo`,label:`To Mail *`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{})}),(0,u.jsx)(c.Form.Item,{name:`mailRequiredJobId`,label:`Job ID *`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{disabled:!x})}),(0,u.jsx)(c.Form.Item,{name:`mailRequiredSubject`,label:`Subject *`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{})}),(0,u.jsx)(c.Form.Item,{name:`mailRequiredBody`,label:`Body *`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{})})]})]}),_===`api`&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Form.Item,{name:`apiMethod`,label:`API Method`,children:(0,u.jsx)(c.Select,{options:ZT.map(e=>({value:e,label:e}))})}),(0,u.jsx)(c.Form.Item,{name:`apiPath`,label:`API Path`,children:(0,u.jsx)(c.Input,{placeholder:`e.g. /jobs/:_id`})})]}),_===`copy`&&(0,u.jsx)(c.Form.Item,{name:`copyField`,label:`Record Field to Copy`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{placeholder:`e.g. email or applicantRefrenceId`})}),_===`document`&&(0,u.jsx)(c.Form.Item,{name:`documentField`,label:`Document Field`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{placeholder:`e.g. resume or attachment`})}),(0,u.jsx)(`div`,{className:`action-editor-section-title`,children:`Availability and access`}),(0,u.jsx)(c.Form.Item,{name:`allowedTabs`,label:`Allowed Tabs (optional)`,tooltip:`Leave empty to show on every tab.`,children:(0,u.jsx)(c.Select,{mode:`tags`,tokenSeparators:[`,`],placeholder:`e.g. allJobs`})}),(0,u.jsxs)(c.Space.Compact,{block:!0,children:[(0,u.jsx)(c.Form.Item,{name:`permissionModule`,label:`Role Permission — Module (optional)`,style:{width:`50%`},tooltip:`Which module's RBAC permission gates this action. Leave both empty to show for every permitted role.`,children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,placeholder:`e.g. job`,options:o.map(e=>({value:e,label:e}))})}),(0,u.jsx)(c.Form.Item,{name:`permissionAction`,label:`Role Permission — Action`,style:{width:`50%`},children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,placeholder:`e.g. edit`,options:d.map(e=>({value:e,label:e}))})})]}),(0,u.jsx)(c.Form.Item,{name:`permissionKey`,label:`Permission Key (row-level gate)`,tooltip:`Maps to record.actionPermission.<key>. Leave blank to always show.`,children:(0,u.jsx)(c.Input,{placeholder:`e.g. edit, sourceCandidates, sharePermission`})}),(0,u.jsxs)(`div`,{className:`action-toggle-grid`,children:[(0,u.jsx)(c.Form.Item,{name:`allowMultiple`,label:`Multiple Records`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{})}),(0,u.jsx)(c.Form.Item,{name:`danger`,label:`Danger`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{})}),(0,u.jsx)(c.Form.Item,{name:`showInList`,label:`Show in List`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{})}),(0,u.jsx)(c.Form.Item,{name:`showInDetail`,label:`Show in Detail`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{})})]}),v&&(0,u.jsx)(c.Form.Item,{name:`detailPlacement`,label:`Detail Placement`,children:(0,u.jsx)(c.Select,{options:[{value:`primary`,label:`Primary button`},{value:`more`,label:`More actions menu`}]})}),(0,u.jsx)(`div`,{className:`action-editor-section-title`,children:`Done state (optional)`}),(0,u.jsx)(c.Alert,{type:`info`,showIcon:!0,style:{marginBottom:12},message:`Turn this action into a disabled success label once a condition is met.`,description:`Example: when the record field "onboardingStatus" is set, "Move to Onboarding" shows as a disabled "Moved to Onboarded". Leave the field blank to disable.`}),(0,u.jsx)(c.Form.Item,{name:`doneLabel`,label:`Done Label`,tooltip:`Text shown once the done condition is met (e.g. Moved to Onboarded). Falls back to the normal label if blank.`,children:(0,u.jsx)(c.Input,{placeholder:`e.g. Moved to Onboarded`})}),(0,u.jsxs)(c.Space.Compact,{block:!0,children:[(0,u.jsx)(c.Form.Item,{name:`doneField`,label:`When Record Field`,style:{width:`40%`},tooltip:`A field on the record to test (dotted paths allowed, e.g. onboardingStatus).`,children:(0,u.jsx)(c.Input,{placeholder:`e.g. onboardingStatus`})}),(0,u.jsx)(c.Form.Item,{name:`doneOperator`,label:`Condition`,style:{width:`30%`},children:(0,u.jsx)(c.Select,{options:tE})}),(0,u.jsx)(c.Form.Item,{name:`doneValue`,label:`Value`,style:{width:`30%`},hidden:b!==`eq`&&b!==`ne`,children:(0,u.jsx)(c.Input,{placeholder:`e.g. In Progress`})})]}),(0,u.jsx)(c.Form.Item,{name:`doneTone`,label:`Done Colour`,children:(0,u.jsx)(c.Select,{options:[{value:`success`,label:`Success (green)`},{value:`primary`,label:`Primary (blue)`},{value:`danger`,label:`Danger (red)`}]})})]})})}function iE(){let[e,t]=(0,s.useState)([]),[r,i]=(0,s.useState)(``),[a,o]=(0,s.useState)([]),[d,f]=(0,s.useState)(null),[p,m]=(0,s.useState)([]),[h,g]=(0,s.useState)(!1),[_,v]=(0,s.useState)(!1),[y,b]=(0,s.useState)(!1),[x,S]=(0,s.useState)(null),[C,w]=(0,s.useState)(!1),[T,E]=(0,s.useState)(null),[D,O]=(0,s.useState)([]),[k,A]=(0,s.useState)([]),[j,M]=(0,s.useState)(null),[N,P]=(0,s.useState)(``),[F,I]=(0,s.useState)([]),[L,R]=(0,s.useState)([]);(0,s.useEffect)(()=>{n.ui().then(e=>{let n=qS(e);t(n),i(e=>e||n[0]?.value||``)}).catch(()=>{t([])})},[]),(0,s.useEffect)(()=>{Promise.all([n.ui().catch(()=>[]),n.li().catch(()=>[])]).then(([e,t])=>{I([...new Set(e.map(e=>e.MENUNAME??e.menuName).filter(Boolean))]),R([...new Set(t.map(e=>e.permissionKey??e.PERMISSIONKEY).filter(Boolean))])})},[]);let z=(0,s.useCallback)(async()=>{if(r){v(!0),S(null),o([]);try{let e=await n.xi(r);o(e)}catch(e){S(e.message)}finally{v(!1)}}},[r]);(0,s.useEffect)(()=>{queueMicrotask(()=>{z()})},[z]),(0,s.useEffect)(()=>{Promise.all([n.ei(r,`popup`).catch(()=>[]),RT({module:r}).catch(()=>[])]).then(([e,t])=>{O(e),A(t.map(e=>({value:e._id??e.id,label:`${e.name} · ${e.action}`})))})},[r]),(0,s.useEffect)(()=>{queueMicrotask(()=>{let e=a.filter(e=>e.roleId===0),t=e.find(e=>e.module===r)??e[0];f(t??null),m(t?t.rowActions??[]:[]),g(!1)})},[r,a]);let B=async()=>{b(!0);try{if(d)await n.Ji(d.id??d._id,p),o(e=>e.map(e=>(e.id??e._id)===(d.id??d._id)?{...e,rowActions:p}:e)),c.message.success(`Config saved`);else{let e=await n.kr({module:r,roleId:0,rowActions:p}),t=e?.data??e;f(t),o(e=>[...e,t]),c.message.success(`Config created`)}g(!1)}catch(e){c.message.error(e.message),String(e.message??``).toLowerCase().includes(`already exists`)&&z()}finally{b(!1)}},V=async()=>{if(d)try{await n.zr(d.id??d._id),c.message.success(`Config deleted`),await z()}catch(e){c.message.error(e.message)}},[H,ee]=(0,s.useState)(null),te=(e=null)=>{ee(typeof e==`string`?e:null),E(null),w(!0)},ne=(e,t=null)=>{ee(t),E(e),w(!0)},re=async e=>{let t;t=H?p.map(t=>{if(t.key!==H)return t;let n=t.children??[],r=T?n.map(t=>t.key===T.key?{...t,...e}:t):[...n,{...$T,...e,_localKey:nE()}];return{...t,children:r}}):T?p.map(t=>t.key===T.key?{...t,...e}:t):[...p,{...$T,...e,_localKey:nE()}];try{if(d)await n.Ji(d.id??d._id,t),o(e=>e.map(e=>(e.id??e._id)===(d.id??d._id)?{...e,rowActions:t}:e)),c.message.success(`Config saved`);else{let e=await n.kr({module:r,roleId:0,rowActions:t}),i=e?.data??e;f(i),o(e=>[...e,i]),c.message.success(`Config created`)}m(t),g(!1),w(!1)}catch(e){c.message.error(e.message),String(e.message??``).toLowerCase().includes(`already exists`)&&z()}},ie=(e,t=null)=>{m(t?n=>n.map(n=>n.key===t?{...n,children:(n.children??[]).filter(t=>t.key!==e)}:n):t=>t.filter(t=>t.key!==e)),g(!0)},ae=(e,t)=>{m(n=>{let r=[...n],i=e+t;return i<0||i>=r.length?n:([r[e],r[i]]=[r[i],r[e]],r)}),g(!0)};function oe(e){M(qT[e])}function se(){M(null),z()}let ce=(0,s.useMemo)(()=>{let e=N.trim().toLowerCase();return e?p.filter(t=>[t.label,t.key,t.actionType,t.popupKey,t.routeTemplate,t.apiPath,t.permissionKey].some(t=>String(t??``).toLowerCase().includes(e))):p},[p,N]),U=[{title:`Order`,key:`order`,width:76,render:(e,t)=>(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(c.Button,{size:`small`,type:`text`,disabled:t._actionIndex===0,onClick:()=>ae(t._actionIndex,-1),children:`↑`}),(0,u.jsx)(c.Button,{size:`small`,type:`text`,disabled:t._actionIndex===p.length-1,onClick:()=>ae(t._actionIndex,1),children:`↓`})]})},{title:`Action`,key:`identity`,width:210,render:(e,t)=>(0,u.jsxs)(`div`,{className:`admin-config-primary-cell`,children:[(0,u.jsx)(JT,{strong:!0,children:t.label||t.key}),(0,u.jsx)(JT,{type:`secondary`,code:!0,children:t.key})]})},{title:`Behaviour`,key:`destination`,render:(e,t)=>(0,u.jsxs)(`div`,{className:`admin-config-primary-cell`,children:[(0,u.jsx)(c.Tag,{color:`blue`,children:t.actionType}),(0,u.jsx)(JT,{type:`secondary`,ellipsis:{tooltip:!0},children:t.actionType===`group`?`${(t.children??[]).length} child action${(t.children??[]).length===1?``:`s`}`:t.popupKey||t.routeTemplate||t.apiPath||t.copyField||t.documentField||`No destination`})]})},{title:`Visible in`,key:`visibility`,width:210,render:(e,t)=>(0,u.jsxs)(c.Space,{size:[4,4],wrap:!0,children:[t.showInList&&(0,u.jsx)(c.Tag,{color:`green`,children:`List`}),(t.showInDetail??t.showInList)&&(0,u.jsxs)(c.Tag,{color:`purple`,children:[`Detail · `,t.detailPlacement||`more`]}),t.allowMultiple&&(0,u.jsx)(c.Tag,{children:`Multi-select`}),t.danger&&(0,u.jsx)(c.Tag,{color:`red`,children:`Destructive`}),!t.showInList&&!(t.showInDetail??t.showInList)&&(0,u.jsx)(JT,{type:`secondary`,children:`Nowhere`})]})},{title:`Access`,key:`access`,width:170,render:(e,t)=>(0,u.jsxs)(`div`,{className:`admin-config-primary-cell`,children:[(0,u.jsx)(JT,{type:`secondary`,children:t.permission||`All permitted roles`}),t.permissionKey&&(0,u.jsx)(JT,{type:`secondary`,code:!0,children:t.permissionKey})]})},{title:``,key:`actions`,width:110,fixed:`right`,render:(e,t)=>(0,u.jsxs)(c.Space,{children:[t.actionType===`group`&&(0,u.jsx)(c.Tooltip,{title:`Add child action`,children:(0,u.jsx)(c.Button,{size:`small`,type:`text`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>te(t.key)})}),(0,u.jsx)(c.Tooltip,{title:`Edit`,children:(0,u.jsx)(c.Button,{size:`small`,type:`text`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>ne(t)})}),(0,u.jsx)(c.Popconfirm,{title:`Remove this action?`,onConfirm:()=>ie(t.key),okText:`Remove`,okType:`danger`,children:(0,u.jsx)(c.Tooltip,{title:`Remove`,children:(0,u.jsx)(c.Button,{size:`small`,type:`text`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{})})})})]})}],W=e=>[{title:`Action`,key:`identity`,width:210,render:(e,t)=>(0,u.jsxs)(`div`,{className:`admin-config-primary-cell`,children:[(0,u.jsx)(JT,{strong:!0,children:t.label||t.key}),(0,u.jsx)(JT,{type:`secondary`,code:!0,children:t.key})]})},{title:`Behaviour`,key:`destination`,render:(e,t)=>(0,u.jsxs)(`div`,{className:`admin-config-primary-cell`,children:[(0,u.jsx)(c.Tag,{color:`blue`,children:t.actionType}),(0,u.jsx)(JT,{type:`secondary`,ellipsis:{tooltip:!0},children:t.popupKey||t.routeTemplate||t.apiPath||t.copyField||t.documentField||`No destination`})]})},{title:`Access`,key:`access`,width:170,render:(e,t)=>(0,u.jsxs)(`div`,{className:`admin-config-primary-cell`,children:[(0,u.jsx)(JT,{type:`secondary`,children:t.permission||`All permitted roles`}),t.permissionKey&&(0,u.jsx)(JT,{type:`secondary`,code:!0,children:t.permissionKey})]})},{title:``,key:`actions`,width:80,fixed:`right`,render:(t,n)=>(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(c.Tooltip,{title:`Edit`,children:(0,u.jsx)(c.Button,{size:`small`,type:`text`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>ne(n,e)})}),(0,u.jsx)(c.Popconfirm,{title:`Remove this child action?`,onConfirm:()=>ie(n.key,e),okText:`Remove`,okType:`danger`,children:(0,u.jsx)(c.Tooltip,{title:`Remove`,children:(0,u.jsx)(c.Button,{size:`small`,type:`text`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{})})})})]})}];return(0,u.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.ToolOutlined,{}),title:`Actions`,extra:(0,u.jsx)(c.Dropdown,{trigger:[`click`],menu:{items:[{key:`save`,label:`Save current as default`,icon:(0,u.jsx)(l.SaveOutlined,{}),onClick:()=>oe(`save`)},{key:`restore`,label:`Restore saved default`,icon:(0,u.jsx)(l.CloudDownloadOutlined,{}),onClick:()=>oe(`restore`)},{type:`divider`},{key:`reset`,label:`Reset all actions`,icon:(0,u.jsx)(l.ReloadOutlined,{}),danger:!0,onClick:()=>oe(`reset`)}]},children:(0,u.jsx)(c.Button,{size:`small`,icon:(0,u.jsx)(l.MoreOutlined,{}),children:`Workspace defaults`})}),children:[(0,u.jsx)(`div`,{className:`admin-accent-bar`}),(0,u.jsx)(JT,{type:`secondary`,children:`Build one action once, then control its List and Detail placement, permissions, tabs, and multi-select behaviour.`})]}),(0,u.jsx)(Z,{styles:{body:{padding:`14px 18px`}},children:(0,u.jsxs)(`div`,{className:`admin-config-context`,children:[(0,u.jsxs)(`div`,{className:`admin-config-context-copy`,children:[(0,u.jsx)(JT,{strong:!0,children:`Configuration context`}),(0,u.jsx)(JT,{type:`secondary`,children:`Choose a module. This is the default action library for all roles — per-role overrides are set in User Types → Config → Actions.`})]}),(0,u.jsxs)(`div`,{className:`admin-config-context-controls`,children:[(0,u.jsxs)(`label`,{className:`admin-config-control`,children:[(0,u.jsx)(JT,{type:`secondary`,style:{display:`block`,marginBottom:4,fontSize:12},children:`Module`}),(0,u.jsx)(c.Select,{showSearch:!0,optionFilterProp:`label`,style:{width:220},mode:`tags`,maxCount:1,placeholder:`Pick or type a module key`,value:r?[r]:[],onChange:e=>i(String(e[e.length-1]??``).trim()),options:e.map(e=>({value:e.value,label:e.label===e.value?e.value:`${e.label} (${e.value})`}))})]}),(0,u.jsx)(`div`,{className:`admin-config-reload`,children:(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:z,loading:_,children:`Reload`})})]})]})}),x&&(0,u.jsx)(c.Alert,{type:`error`,message:x,showIcon:!0}),(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.ToolOutlined,{}),title:(0,u.jsxs)(c.Space,{wrap:!0,children:[(0,u.jsxs)(`span`,{children:[p.length,` configured action`,p.length===1?``:`s`]}),d?(0,u.jsx)(c.Tag,{color:`green`,children:`Default config loaded (All Roles)`}):(0,u.jsx)(c.Tag,{color:`orange`,children:`No config — will create on Save`})]}),extra:(0,u.jsxs)(c.Space,{wrap:!0,children:[d&&(0,u.jsx)(c.Popconfirm,{title:`Delete this entire config?`,onConfirm:V,okText:`Delete`,okType:`danger`,children:(0,u.jsx)(c.Button,{danger:!0,size:`small`,icon:(0,u.jsx)(l.DeleteOutlined,{}),children:`Delete Config`})}),(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>te(),children:`New action`}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.SaveOutlined,{}),loading:y,disabled:!h,onClick:B,children:`Save Config`})]}),children:[(0,u.jsxs)(`div`,{className:`admin-config-table-tools`,children:[(0,u.jsx)(c.Input,{allowClear:!0,prefix:(0,u.jsx)(l.SearchOutlined,{}),placeholder:`Search actions`,value:N,onChange:e=>P(e.target.value)}),h&&(0,u.jsx)(JT,{type:`warning`,children:`Unsaved changes`})]}),(0,u.jsx)(c.Spin,{spinning:_,children:(0,u.jsx)(c.Table,{dataSource:ce.map((e,t)=>({...e,_actionIndex:p.indexOf(e),_rowKey:e.key||e._localKey||t})),rowKey:`_rowKey`,columns:U,pagination:!1,size:`small`,className:`fg-table admin-config-table`,scroll:{x:820},locale:{emptyText:`No actions configured. Click "Add Action" to start.`},expandable:{rowExpandable:e=>e.actionType===`group`,expandedRowRender:e=>(0,u.jsx)(c.Table,{dataSource:(e.children??[]).map((e,t)=>({...e,_rowKey:e.key||e._localKey||t})),rowKey:`_rowKey`,columns:W(e.key),pagination:!1,size:`small`,className:`fg-table admin-config-table`,locale:{emptyText:`No child actions yet. Use the + button on this row to add one (e.g. Tag To Job, Send Mail, Add Notes).`}})}})})]}),(0,u.jsx)(rE,{open:C,initial:T,isChild:!!H,moduleName:r,popupForms:D,templateOptions:k,permissionModules:F,permissionActions:L,onClose:()=>w(!1),onSave:re}),(0,u.jsx)(zC,{open:!!j,scope:`rowActions`,action:j?.action,title:j?.title,description:j?.description,confirmLabel:j?.confirmLabel,danger:j?.danger,onCancel:()=>M(null),onVerified:se})]})}var{Text:aE,Title:oE}=c.Typography,sE=[{value:`eq`,label:`equals`},{value:`ne`,label:`not equals`},{value:`isEmpty`,label:`is empty`},{value:`notEmpty`,label:`is not empty`},{value:`contains`,label:`contains`},{value:`includes`,label:`list includes (exact)`},{value:`notIncludes`,label:`list does not include (exact)`},{value:`fieldEq`,label:`field = field`},{value:`scope`,label:`view scope`}],cE=[{value:`{currentUserId}`,label:`{currentUserId} — the signed-in user`}],lE=[{value:`myJobs`,label:`My Jobs`},{value:`allJobs`,label:`All Jobs`}],uE=[`eq`,`ne`,`contains`,`includes`,`notIncludes`],dE=`scope`,fE=`fieldEq`,pE=[{name:`Fulfilled jobs — block sourcing`,description:`When a job is fulfilled, hide source, quick-submit and send-mail.`,conditions:[{field:`jobRecruitmentStatus`,operator:`eq`,value:`fulfilled`,compareField:``}],blockedActions:[`sourceCandidate`,`quickSubmit`,`sendMail`],isActive:!0},{name:`Inactive jobs — Edit and Delete only`,description:`An inactive or on-hold job cannot be worked. Only Edit and Delete remain.`,conditions:[{field:`jobRecruitmentStatus`,operator:`eq`,value:`inactive`,compareField:``}],allowedActions:[`edit`,`delete`],isActive:!0},{name:`On Hold jobs — Edit and Delete only`,description:`A paused job cannot be worked. Only Edit and Delete remain.`,conditions:[{field:`jobRecruitmentStatus`,operator:`eq`,value:`on hold`,compareField:``}],allowedActions:[`edit`,`delete`],isActive:!0},{name:`All Jobs scope — restrict actions`,description:`When viewing All Jobs, hide sourcing, quick-submit, change-status and send-mail.`,conditions:[{field:``,operator:`scope`,value:`allJobs`,compareField:``}],blockedActions:[`sourceCandidate`,`quickSubmit`,`changeStatus`,`sendMail`],isActive:!0},{name:`Target submission reached — block sourcing`,description:`When a job has reached its submission target, sourcing and submitting are done. Guarded so a job with no target set (0, or the field absent) does not match.`,conditions:[{field:`targetSubmission`,operator:`notEmpty`,value:``,compareField:``},{field:`targetSubmission`,operator:`ne`,value:`0`,compareField:``},{field:`targetSubmission`,operator:`fieldEq`,value:``,compareField:`submittedCount`}],blockedActions:[`sourceCandidate`,`quickSubmit`,`sendMail`],isActive:!0}],mE=()=>({field:``,operator:`eq`,value:``,compareField:``}),hE=()=>({name:``,description:``,conditions:[mE()],blockedActions:[],disabledActions:[],allowedActions:[],isActive:!0});function gE(e){return sE.find(t=>t.value===e)?.label??e}function _E(e){return e.operator===dE?`scope = ${e.value}`:e.operator===fE?`${e.field} = field:${e.compareField}`:[`isEmpty`,`notEmpty`].includes(e.operator)?`${e.field} ${gE(e.operator)}`:`${e.field} ${gE(e.operator)} "${e.value}"`}function vE(){let[e,t]=(0,s.useState)([]),[r,i]=(0,s.useState)(!1),[a,o]=(0,s.useState)(``),[d,f]=(0,s.useState)([]),[p,m]=(0,s.useState)(!1),[h,g]=(0,s.useState)(!1),[_,v]=(0,s.useState)(null),[y,b]=(0,s.useState)(hE()),[x,S]=(0,s.useState)(!1),[C,w]=(0,s.useState)(!1),[T,E]=(0,s.useState)([]),[D,O]=(0,s.useState)([]);(0,s.useEffect)(()=>{let e=!1;return queueMicrotask(()=>{i(!0),n.Vr().then(n=>{if(e)return;let r=qS(n);t(r),o(e=>r.some(t=>t.value===e)?e:r[0]?.value??``)}).catch(()=>{e||(t([]),o(``))}).finally(()=>{e||i(!1)})}),()=>{e=!0}},[]);function k(e){m(!0),n.di(e).then(e=>f(Array.isArray(e)?e:[])).catch(()=>f([])).finally(()=>m(!1))}function A(e){n.hi(e).then(e=>{let t=(Array.isArray(e)?e:[]).map(e=>({value:e.field??e.fieldKey??e.key??e.name,label:`${e.label??e.fieldName??e.name} (${e.field??e.fieldKey??e.key??e.name})`})).filter(e=>e.value);E(t)}).catch(()=>E([]))}function j(e){n.xi(e).then(e=>{let t=new Set;(Array.isArray(e)?e:[]).forEach(e=>{(e.rowActions??[]).forEach(e=>{e.key&&t.add(e.key)})}),O([...t].map(e=>({value:e,label:e})))}).catch(()=>O([]))}(0,s.useEffect)(()=>{queueMicrotask(()=>{if(!a){f([]),E([]),O([]);return}k(a),A(a),j(a)})},[a]);function M(){v(null),b(hE()),g(!0)}function N(e){v(e),b({name:e.name??``,description:e.description??``,conditions:e.conditions?.length?e.conditions.map(e=>({...e})):[mE()],blockedActions:e.blockedActions??[],disabledActions:e.disabledActions??[],allowedActions:e.allowedActions??[],isActive:e.isActive??!0}),g(!0)}async function P(){if(y.name.trim()){S(!0);try{_?(await n.Wi(_.id,y),c.message.success(`Rule updated`)):(await n.Dr({...y,module:a}),c.message.success(`Rule created`)),g(!1),k(a)}catch(e){c.message.error(e.message)}finally{S(!1)}}}async function F(e){try{await n.Ir(e.id),c.message.success(`Rule deleted`)}catch(e){c.message.error(e.message)}k(a)}async function I(){w(!0);try{for(let e of pE)await n.Dr({...e,module:a});c.message.success(`Default job rules created`),k(a)}catch(e){c.message.error(e.message)}finally{w(!1)}}function L(e,t){b(n=>({...n,conditions:n.conditions.map((n,r)=>r===e?{...n,...t}:n)}))}function R(){b(e=>({...e,conditions:[...e.conditions,mE()]}))}function z(e){b(t=>({...t,conditions:t.conditions.filter((t,n)=>n!==e)}))}return(0,u.jsxs)(`div`,{style:{padding:`24px 0`},children:[(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,marginBottom:8,flexWrap:`wrap`},children:[(0,u.jsx)(oE,{level:5,style:{margin:0},children:`Action Rules`}),(0,u.jsx)(c.Select,{options:e,value:a,loading:r,placeholder:`Select module`,onChange:o,style:{width:200}}),(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.PlusOutlined,{}),type:`primary`,disabled:!a,onClick:M,children:`Add Rule`}),(a===`job`||a===`jobs`)&&(0,u.jsx)(c.Tooltip,{title:`Create the 3 standard job rules that replace the hardcoded backend logic`,children:(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.ThunderboltOutlined,{}),loading:C,onClick:I,children:`Seed Job Defaults`})})]}),(0,u.jsx)(c.Alert,{type:`info`,showIcon:!0,style:{marginBottom:16,fontSize:12},message:(0,u.jsxs)(`span`,{children:[`Rules are evaluated `,(0,u.jsx)(`b`,{children:`per row`}),` in the list view using the record's own field values. When `,(0,u.jsx)(`b`,{children:`all conditions`}),` of a rule match, the listed action buttons are hidden for that row. The `,(0,u.jsx)(`b`,{children:`key`}),` of each blocked action must match what is set in `,(0,u.jsx)(`b`,{children:`Row Actions`}),` config.`]})}),(0,u.jsx)(c.Table,{columns:[{title:`Rule Name`,dataIndex:`name`,key:`name`,width:200,render:(e,t)=>(0,u.jsxs)(`div`,{children:[(0,u.jsx)(aE,{strong:!0,children:e}),t.description?(0,u.jsx)(`div`,{children:(0,u.jsx)(aE,{type:`secondary`,style:{fontSize:11},children:t.description})}):null]})},{title:`Conditions (ALL must match)`,key:`conditions`,render:(e,t)=>(0,u.jsx)(c.Space,{size:4,direction:`vertical`,children:(t.conditions??[]).map((e,t)=>(0,u.jsx)(c.Tag,{style:{fontFamily:`monospace`,fontSize:11,margin:0},children:_E(e)},t))})},{title:`Blocked Row Actions`,key:`blockedActions`,render:(e,t)=>(0,u.jsx)(c.Space,{size:4,wrap:!0,children:(t.blockedActions??[]).map(e=>(0,u.jsx)(c.Tag,{color:`volcano`,children:e},e))})},{title:`Disabled Row Actions`,key:`disabledActions`,render:(e,t)=>(0,u.jsx)(c.Space,{size:4,wrap:!0,children:(t.disabledActions??[]).map(e=>(0,u.jsx)(c.Tag,{color:`gold`,children:e},e))})},{title:`Only These Allowed`,key:`allowedActions`,render:(e,t)=>(0,u.jsx)(c.Space,{size:4,wrap:!0,children:(t.allowedActions??[]).map(e=>(0,u.jsx)(c.Tag,{color:`green`,children:e},e))})},{title:`Active`,dataIndex:`isActive`,key:`isActive`,width:70,render:e=>(0,u.jsx)(c.Tag,{color:e?`green`:`default`,children:e?`On`:`Off`})},{title:``,key:`act`,width:80,render:(e,t)=>(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(c.Tooltip,{title:`Edit`,children:(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.EditOutlined,{}),size:`small`,type:`text`,onClick:()=>N(t)})}),(0,u.jsx)(c.Popconfirm,{title:`Delete this rule?`,onConfirm:()=>F(t),children:(0,u.jsx)(c.Tooltip,{title:`Delete`,children:(0,u.jsx)(c.Button,{danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{}),size:`small`,type:`text`})})})]})}],dataSource:d,loading:p,rowKey:`id`,size:`small`,pagination:!1,locale:{emptyText:a?`No rules yet. Click "Add Rule" to get started.`:`No modules found. Configure modules first.`}}),(0,u.jsx)(c.Drawer,{open:h,title:_?`Edit: ${_.name}`:`Add Action Rule`,width:620,onClose:()=>g(!1),footer:(0,u.jsxs)(c.Space,{style:{float:`right`},children:[(0,u.jsx)(c.Button,{onClick:()=>g(!1),children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,loading:x,onClick:P,children:`Save Rule`})]}),children:(0,u.jsxs)(c.Form,{layout:`vertical`,children:[(0,u.jsx)(c.Form.Item,{label:`Rule Name`,required:!0,children:(0,u.jsx)(c.Input,{value:y.name,placeholder:`e.g. Fulfilled jobs — block sourcing`,onChange:e=>b(t=>({...t,name:e.target.value}))})}),(0,u.jsx)(c.Form.Item,{label:`Description`,children:(0,u.jsx)(c.Input.TextArea,{rows:2,value:y.description,placeholder:`Explain when this rule applies`,onChange:e=>b(t=>({...t,description:e.target.value}))})}),(0,u.jsx)(c.Form.Item,{label:`Active`,children:(0,u.jsx)(c.Switch,{checked:y.isActive,onChange:e=>b(t=>({...t,isActive:e}))})}),(0,u.jsxs)(c.Divider,{orientation:`left`,orientationMargin:0,style:{fontSize:13},children:[`Conditions `,(0,u.jsx)(aE,{type:`secondary`,style:{fontSize:12},children:`(ALL must match for the rule to fire)`})]}),y.conditions.map((e,t)=>(0,u.jsxs)(`div`,{style:{background:`#fafafa`,border:`1px solid #f0f0f0`,borderRadius:6,padding:`10px 12px`,marginBottom:8},children:[(0,u.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`flex-start`,flexWrap:`wrap`},children:[(0,u.jsx)(c.Form.Item,{label:`Operator`,style:{marginBottom:0,minWidth:140},children:(0,u.jsx)(c.Select,{options:sE,value:e.operator,style:{width:140},onChange:e=>L(t,{operator:e,value:``,compareField:``})})}),e.operator!==dE&&(0,u.jsxs)(c.Form.Item,{label:`Record Field`,style:{marginBottom:0,flex:1,minWidth:180},children:[(0,u.jsx)(c.Select,{showSearch:!0,allowClear:!0,mode:`tags`,maxCount:1,value:e.field?[e.field]:[],options:T,style:{width:`100%`},placeholder:`Select or type field name`,onChange:e=>L(t,{field:e[e.length-1]??``}),filterOption:(e,t)=>(t?.label??t?.value??``).toLowerCase().includes(e.toLowerCase())}),(0,u.jsxs)(aE,{type:`secondary`,style:{fontSize:11},children:[`Field from the record (e.g. `,(0,u.jsx)(`code`,{children:`jobRecruitmentStatus`}),`, `,(0,u.jsx)(`code`,{children:`recruiters`}),`)`]})]}),uE.includes(e.operator)&&(0,u.jsxs)(c.Form.Item,{label:`Value`,style:{marginBottom:0,minWidth:180},children:[(0,u.jsx)(c.Select,{showSearch:!0,allowClear:!0,mode:`tags`,maxCount:1,value:e.value?[e.value]:[],options:cE,style:{width:200},placeholder:`e.g. "fulfilled"`,onChange:e=>L(t,{value:e[e.length-1]??``}),filterOption:(e,t)=>(t?.label??t?.value??``).toLowerCase().includes(e.toLowerCase())}),(0,u.jsxs)(aE,{type:`secondary`,style:{fontSize:11},children:[`Type a literal, or pick `,(0,u.jsx)(`code`,{children:`{currentUserId}`}),` for the signed-in user.`]})]}),e.operator===dE&&(0,u.jsxs)(c.Form.Item,{label:`Scope Value`,style:{marginBottom:0,minWidth:140},children:[(0,u.jsx)(c.Select,{options:lE,value:e.value||void 0,style:{width:150},placeholder:`Select scope`,onChange:e=>L(t,{value:e})}),(0,u.jsx)(aE,{type:`secondary`,style:{fontSize:11},children:`Current view tab (myJobs / allJobs)`})]}),e.operator===fE&&(0,u.jsxs)(c.Form.Item,{label:`Compare To Field`,style:{marginBottom:0,minWidth:160},children:[(0,u.jsx)(c.Select,{showSearch:!0,allowClear:!0,mode:`tags`,maxCount:1,value:e.compareField?[e.compareField]:[],options:T,style:{width:170},placeholder:`Select or type field`,onChange:e=>L(t,{compareField:e[e.length-1]??``}),filterOption:(e,t)=>(t?.label??t?.value??``).toLowerCase().includes(e.toLowerCase())}),(0,u.jsxs)(aE,{type:`secondary`,style:{fontSize:11},children:[`e.g. `,(0,u.jsx)(`code`,{children:`submissionCount`})]})]}),(0,u.jsx)(`div`,{style:{paddingTop:22},children:(0,u.jsx)(c.Button,{danger:!0,disabled:y.conditions.length<=1,icon:(0,u.jsx)(l.DeleteOutlined,{}),size:`small`,type:`text`,onClick:()=>z(t)})})]}),(0,u.jsx)(`div`,{style:{marginTop:6},children:(0,u.jsxs)(aE,{type:`secondary`,style:{fontSize:11},children:[`Preview: `,(0,u.jsx)(`code`,{style:{color:`#1677ff`},children:_E(e)})]})})]},t)),(0,u.jsx)(c.Button,{size:`small`,style:{marginBottom:16},onClick:R,children:`+ Add Condition`}),(0,u.jsxs)(c.Divider,{orientation:`left`,orientationMargin:0,style:{fontSize:13},children:[`Blocked Row Actions`,(0,u.jsx)(aE,{type:`secondary`,style:{fontSize:12,marginLeft:8},children:`(hidden when this rule fires)`})]}),(0,u.jsxs)(c.Form.Item,{children:[(0,u.jsx)(c.Select,{mode:`tags`,style:{width:`100%`},value:y.blockedActions,options:D,placeholder:`Select or type action key (e.g. sourceCandidates, quickSubmit)`,onChange:e=>b(t=>({...t,blockedActions:e})),filterOption:(e,t)=>(t?.value??``).toLowerCase().includes(e.toLowerCase())}),(0,u.jsxs)(aE,{type:`secondary`,style:{fontSize:11},children:[`Must match the `,(0,u.jsx)(`b`,{children:`key`}),` of a Row Action (configured in Admin → Row Actions). Common job keys: `,(0,u.jsx)(`code`,{children:`sourceCandidates`}),`, `,(0,u.jsx)(`code`,{children:`quickSubmit`}),`,`,` `,(0,u.jsx)(`code`,{children:`changeStatus`}),`, `,(0,u.jsx)(`code`,{children:`share`}),`, `,(0,u.jsx)(`code`,{children:`addNotes`}),`, `,(0,u.jsx)(`code`,{children:`assign`}),`.`]})]}),(0,u.jsxs)(c.Divider,{orientation:`left`,orientationMargin:0,style:{fontSize:13},children:[`Disabled Row Actions`,(0,u.jsx)(aE,{type:`secondary`,style:{fontSize:12,marginLeft:8},children:`(stay visible, greyed out, when this rule fires)`})]}),(0,u.jsxs)(c.Form.Item,{children:[(0,u.jsx)(c.Select,{mode:`tags`,style:{width:`100%`},value:y.disabledActions,options:D,placeholder:`Select or type action key (e.g. approveSubmission, rejectSubmission)`,onChange:e=>b(t=>({...t,disabledActions:e})),filterOption:(e,t)=>(t?.value??``).toLowerCase().includes(e.toLowerCase())}),(0,u.jsxs)(aE,{type:`secondary`,style:{fontSize:11},children:[`Unlike Blocked, a disabled action keeps its normal spot and label — it's just unclickable, with this rule's `,(0,u.jsx)(`b`,{children:`Description`}),` shown as the reason on hover. Use this when the user should still see the action exists (e.g. Approve/Reject while awaiting a resubmission) instead of it disappearing.`]})]}),(0,u.jsxs)(c.Divider,{orientation:`left`,orientationMargin:0,style:{fontSize:13},children:[`Only These Actions Allowed`,(0,u.jsx)(aE,{type:`secondary`,style:{fontSize:12,marginLeft:8},children:`(everything else is hidden when this rule fires)`})]}),(0,u.jsxs)(c.Form.Item,{children:[(0,u.jsx)(c.Select,{mode:`tags`,style:{width:`100%`},value:y.allowedActions,options:D,placeholder:`Leave empty unless you want an allow-list (e.g. delete)`,onChange:e=>b(t=>({...t,allowedActions:e})),filterOption:(e,t)=>(t?.value??``).toLowerCase().includes(e.toLowerCase())}),(0,u.jsxs)(aE,{type:`secondary`,style:{fontSize:11},children:[`The `,(0,u.jsx)(`b`,{children:`inverse`}),` of Blocked. Use it for "when this happens, only these remain" — e.g. an inactive job where only `,(0,u.jsx)(`code`,{children:`delete`}),`should show. Prefer it over listing every other action in Blocked: an allow-list keeps working when a new action is added later, whereas a blocked list silently lets the new one through on exactly the records the rule exists to lock down.`,(0,u.jsx)(`br`,{}),`Leave it `,(0,u.jsx)(`b`,{children:`empty`}),` for any normal rule — an allow-list that names nothing would hide everything.`]})]})]})})]})}function yE(){return(0,u.jsx)(c.Tabs,{defaultActiveKey:`actions`,className:`admin-config-tabs`,destroyOnHidden:!1,items:[{key:`actions`,label:`Action library`,icon:(0,u.jsx)(l.ThunderboltOutlined,{}),children:(0,u.jsx)(iE,{})},{key:`rules`,label:`Visibility rules`,icon:(0,u.jsx)(l.ApartmentOutlined,{}),children:(0,u.jsx)(vE,{})}]})}var{Text:bE}=c.Typography,xE={name:``,module:``,action:``,clientId:``,description:``,toMail:[],ccMail:[],bccMail:[],subject:``,body:``,isActive:!0},SE=e=>e?._id??e?.id;function CE(e){return String(e??``).trim().replace(/^{{\s*/,``).replace(/\s*}}$/,``).trim().replace(/^\./,``).trim()}function wE(...e){let t=new Set;return e.forEach(e=>{let n=/{{\.?([\w.]+)}}/g,r;for(;(r=n.exec(String(e??``)))!==null;)t.add(r[1])}),t}var TE=[{key:`proposedRate`,value:`proposedRate.candidateProposedRate`,label:`Proposed Rate (Latest)`,type:`number`,arrayMode:`last`},{key:`jobBillRate`,value:`clientBudget.clientBudgetStart`,label:`Job Bill Rate`,type:`number`}];function EE(e){return String(e??``).trim().toLowerCase().replace(/[^a-z0-9]/g,``).replace(/s$/,``)===`submission`}function DE({open:e,templateId:t,modules:r,clients:i,onClose:a,onSaved:o}){let[l]=c.Form.useForm(),[d,f]=(0,s.useState)(``),[p,m]=(0,s.useState)(!1),[h,g]=(0,s.useState)(!1),[_,v]=(0,s.useState)([]),[y,b]=(0,s.useState)([]),[x,S]=(0,s.useState)({});async function C(e){if(!e){v([]);return}let t=await n.xi(e).catch(()=>[]),r=new Map;t.forEach(e=>(e.rowActions??[]).forEach(e=>{e.key&&r.set(e.key,e.label||e.key)})),v([...r].map(([e,t])=>({value:e,label:t})))}async function w(){let e=await Promise.all((r??[]).map(async e=>{let t=e.value,r=(await n.hi(t).catch(()=>[])).map(n=>{let r=n.value??n.field??n.fieldKey??n.key??n.name,i=n.path??n.value??n.field??n.fieldKey??n.key??n.name;return{key:CE(r),value:CE(i),label:n.label??n.fieldName??n.name??n.value,moduleName:t,moduleLabel:e.label??t,type:String(n.type??``).trim().toLowerCase(),arrayMode:n.arrayMode??n.placeholderArrayMode??``}}).filter(e=>e.key&&e.value);if(!EE(t))return r;let i=new Set(TE.map(e=>e.key)),a=TE.map(n=>({...n,moduleName:t,moduleLabel:e.label??t}));return[...r.filter(e=>!i.has(e.key)),...a]}));b(e.flat())}(0,s.useEffect)(()=>{if(!e)return;let n=!1;return queueMicrotask(()=>{g(!0),w().catch(()=>{}),(t?PT(t):Promise.resolve(xE)).then(e=>{if(n)return;let t={...xE,...e,action:e?.action?[e.action]:[],clientId:e?.clientIdStr||(typeof e?.clientId==`string`?e.clientId:``)};l.setFieldsValue(t),f(t.body||``);let r={};(e?.placeholders??e?.placeHolder??[]).forEach(e=>{(e?.holders??[]).forEach(t=>{if(t?.key){let n=CE(t.key);r[n]={moduleName:e.moduleName,value:CE(t.value),type:t.type??``,arrayMode:t.arrayMode??``}}})}),S(r),C(t.module)}).catch(e=>c.message.error(e?.message||`Could not load template`)).finally(()=>{n||g(!1)})}),()=>{n=!0}},[l,e,t,r]);function T(e){let t=`{{.${e.key}}}`;S(t=>({...t,[e.key]:{moduleName:e.moduleName,value:e.value,type:e.type,arrayMode:e.arrayMode??``}})),f(e=>`${e}${e?` `:``}${t}`),c.message.success(`Inserted ${t} from ${e.moduleLabel||e.moduleName}`)}function E(e,t){let n=x[e];if(n?.moduleName&&n?.value)return n;let r=y.filter(t=>t.key===e),i=r.find(e=>e.moduleName===t)??r[0];return i?{moduleName:i.moduleName,value:i.value,type:i.type,arrayMode:i.arrayMode??``}:null}async function D(){try{let e=await l.validateFields();if(!d.trim()){c.message.error(`Message body is required`);return}m(!0);let n=wE(e.subject,d),r=new Map;n.forEach(t=>{let n=E(t,e.module);n&&(r.has(n.moduleName)||r.set(n.moduleName,[]),r.get(n.moduleName).push({key:t,value:n.value,...n.type?{type:n.type}:{},...n.arrayMode?{arrayMode:n.arrayMode}:{}}))});let i=[...r].map(([e,t])=>({moduleName:e,holders:t})),a={...e,action:Array.isArray(e.action)?e.action.at(-1):e.action,body:d,placeholders:i};a.clientId||delete a.clientId,t?await IT(t,a):await FT(a),c.message.success(t?`Template updated`:`Template created`),o()}catch(e){e?.errorFields||c.message.error(e?.message||`Could not save template`)}finally{m(!1)}}let O=(0,s.useMemo)(()=>{let e=new Map;return y.forEach(t=>{e.has(t.moduleName)||e.set(t.moduleName,{label:t.moduleLabel,fields:[]}),e.get(t.moduleName).fields.push(t)}),[...e].map(([e,t])=>({moduleName:e,...t}))},[y]);return(0,u.jsx)(c.Drawer,{open:e,onClose:a,width:`min(920px, 96vw)`,title:t?`Edit email template`:`New email template`,destroyOnClose:!0,extra:(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(c.Button,{onClick:a,children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,loading:p,onClick:D,children:t?`Update`:`Create`})]}),children:(0,u.jsxs)(c.Form,{form:l,layout:`vertical`,initialValues:xE,disabled:h,className:`template-editor-form`,children:[(0,u.jsxs)(`div`,{className:`template-editor-grid`,children:[(0,u.jsx)(c.Form.Item,{name:`name`,label:`Template name`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{placeholder:`Candidate introduction`})}),(0,u.jsx)(c.Form.Item,{name:`module`,label:`Module`,rules:[{required:!0}],children:(0,u.jsx)(c.Select,{showSearch:!0,optionFilterProp:`label`,options:r,onChange:e=>{l.setFieldValue(`action`,``),C(e)}})}),(0,u.jsx)(c.Form.Item,{name:`action`,label:`Action`,rules:[{required:!0}],tooltip:`Pick a Row Action, or TYPE a system action key. Not every email comes from a row action — the credentials mail sent when an employer's recruiters are provisioned uses "accountCreated", which is raised by a workflow and so never appears in this list.`,children:(0,u.jsx)(c.Select,{showSearch:!0,mode:`tags`,maxCount:1,optionFilterProp:`label`,options:_,placeholder:`Select a row action, or type a system key (e.g. accountCreated)`})}),(0,u.jsx)(c.Form.Item,{name:`clientId`,label:`Client scope (optional)`,children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,options:i,placeholder:`Available to every client`})})]}),(0,u.jsx)(c.Form.Item,{name:`description`,label:`Description`,children:(0,u.jsx)(c.Input.TextArea,{rows:2})}),(0,u.jsxs)(`div`,{className:`template-editor-grid template-editor-grid--three`,children:[(0,u.jsx)(c.Form.Item,{name:`toMail`,label:`Default To`,children:(0,u.jsx)(c.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`]})}),(0,u.jsx)(c.Form.Item,{name:`ccMail`,label:`Default Cc`,children:(0,u.jsx)(c.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`]})}),(0,u.jsx)(c.Form.Item,{name:`bccMail`,label:`Default Bcc`,children:(0,u.jsx)(c.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`]})})]}),(0,u.jsx)(c.Form.Item,{name:`subject`,label:`Subject`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{placeholder:`Email subject`})}),(0,u.jsx)(c.Form.Item,{label:`Message`,required:!0,children:(0,u.jsx)(n.Xn,{value:d,onChange:f,placeholder:`Write the reusable email body…`})}),(0,u.jsxs)(`div`,{className:`template-placeholder-panel`,children:[(0,u.jsx)(bE,{strong:!0,children:`All module placeholders`}),(0,u.jsx)(bE,{type:`secondary`,children:`Placeholders from every configured module are available. Click or drag one into the message. Document placeholders (📎) are attached to the outgoing email automatically.`}),O.map(e=>(0,u.jsxs)(`div`,{style:{marginTop:10},children:[(0,u.jsx)(bE,{type:`secondary`,strong:!0,children:e.label||e.moduleName}),(0,u.jsx)(`div`,{className:`template-placeholder-list`,children:e.fields.map(t=>(0,u.jsx)(c.Tooltip,{title:`${t.label||t.key} · ${t.value}${t.arrayMode===`last`?` · uses last array item`:``}${[`file`,`document`,`attachment`].includes(t.type)?` · attaches document to email`:``}`,children:(0,u.jsx)(c.Tag,{color:[`file`,`document`,`attachment`].includes(t.type)?`purple`:`blue`,draggable:!0,style:{cursor:`grab`},onDragStart:e=>{let n=`{{.${t.key}}}`;e.dataTransfer.setData(`text/plain`,n),e.dataTransfer.setData(`text/html`,n),e.dataTransfer.effectAllowed=`copy`,S(e=>({...e,[t.key]:{moduleName:t.moduleName,value:t.value,type:t.type,arrayMode:t.arrayMode??``}}))},onClick:()=>T(t),children:[`file`,`document`,`attachment`].includes(t.type)?`📎 {{.${t.key}}}`:`${t.arrayMode===`last`?`↧ `:``}{{.${t.key}}}`})},`${e.moduleName}:${t.key}:${t.value}`))})]},e.moduleName)),!O.length&&(0,u.jsx)(c.Empty,{image:c.Empty.PRESENTED_IMAGE_SIMPLE,description:`No module fields available`})]}),(0,u.jsx)(c.Form.Item,{name:`isActive`,label:`Available in mail composer`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{})})]})})}function OE(){let[e,t]=(0,s.useState)([]),[r,i]=(0,s.useState)(0),[a,o]=(0,s.useState)(!1),[d,f]=(0,s.useState)(``),[p,m]=(0,s.useState)(1),[h,g]=(0,s.useState)(20),[_,v]=(0,s.useState)([]),[y,b]=(0,s.useState)([]),[x,S]=(0,s.useState)(null),[C,w]=(0,s.useState)(!1),T=(0,s.useMemo)(()=>_.map(e=>({value:e.key??e.module??e.value,label:e.label??e.name??e.key??e.module??e.value})).filter(e=>e.value),[_]);function E(e=p,n=h,r=d){o(!0),NT({offset:(e-1)*n,limit:n,search:r}).then(({items:e,totalCount:n})=>{t(e),i(n)}).catch(e=>c.message.error(e?.message||`Could not load templates`)).finally(()=>o(!1))}(0,s.useEffect)(()=>{queueMicrotask(()=>{E(1,h,``)})},[]),(0,s.useEffect)(()=>{Promise.all([n.Xr(),n.Hr({limit:200})]).then(([e,t])=>{v(qS(e).map(({value:e,label:t})=>({key:e,label:t}))),b(t)}).catch(()=>{})},[]);async function D(e,n){let r=SE(e);try{await IT(r,{...e,isActive:n}),t(e=>e.map(e=>SE(e)===r?{...e,isActive:n}:e))}catch(e){c.message.error(e?.message||`Could not update status`)}}async function O(e){try{await LT(e),c.message.success(`Template deleted`),E(1),m(1)}catch(e){c.message.error(e?.message||`Could not delete template`)}}let k=[{title:`Template`,key:`template`,width:300,ellipsis:!0,render:(e,t)=>(0,u.jsxs)(`div`,{className:`admin-config-primary-cell templates-primary-cell`,children:[(0,u.jsx)(bE,{strong:!0,ellipsis:{tooltip:t.name},children:t.name}),(0,u.jsx)(bE,{type:`secondary`,ellipsis:{tooltip:t.description||t.subject},children:t.description||t.subject||`No description`})]})},{title:`Module`,dataIndex:`module`,key:`module`,width:140,ellipsis:!0,responsive:[`sm`],render:e=>e?(0,u.jsx)(c.Tag,{color:`blue`,children:e}):`—`},{title:`Action`,dataIndex:`action`,key:`action`,width:180,ellipsis:!0,responsive:[`md`],render:e=>e?(0,u.jsx)(bE,{code:!0,ellipsis:{tooltip:e},children:e}):`—`},{title:`Recipients`,key:`recipients`,width:130,responsive:[`lg`],render:(e,t)=>`${(t.toMail?.length??0)+(t.ccMail?.length??0)+(t.bccMail?.length??0)} defaults`},{title:`Active`,dataIndex:`isActive`,key:`active`,width:80,render:(e,t)=>(0,u.jsx)(c.Switch,{size:`small`,checked:e,onChange:e=>D(t,e)})},{title:``,key:`actions`,width:84,fixed:`right`,render:(e,t)=>(0,u.jsxs)(c.Space,{size:2,children:[(0,u.jsx)(c.Tooltip,{title:`Edit`,children:(0,u.jsx)(c.Button,{type:`text`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>{S(SE(t)),w(!0)}})}),(0,u.jsx)(c.Popconfirm,{title:`Delete this template?`,onConfirm:()=>O(SE(t)),children:(0,u.jsx)(c.Button,{type:`text`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{})})})]})}],A=y.map(e=>({value:e._id??e.id,label:e.clientName??e.name??e._id})).filter(e=>e.value);return(0,u.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.MailOutlined,{}),title:`Email templates`,extra:(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>{S(null),w(!0)},children:`New template`}),children:[(0,u.jsx)(`div`,{className:`admin-accent-bar`}),(0,u.jsx)(bE,{type:`secondary`,children:`Create reusable, module-aware email content. Modules, actions and placeholders are read from DB configuration.`})]}),(0,u.jsxs)(Z,{title:`${r} template${r===1?``:`s`}`,extra:(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:()=>E(),children:`Reload`}),children:[(0,u.jsx)(`div`,{className:`admin-config-table-tools`,children:(0,u.jsx)(c.Input,{allowClear:!0,prefix:(0,u.jsx)(l.SearchOutlined,{}),placeholder:`Search templates`,value:d,onChange:e=>{let t=e.target.value;f(t),m(1),E(1,h,t)}})}),(0,u.jsx)(`div`,{className:`templates-table-viewport`,children:(0,u.jsx)(c.Table,{rowKey:SE,columns:k,dataSource:e,loading:a,className:`fg-table`,size:`small`,tableLayout:`fixed`,sticky:!0,scroll:{x:914,y:`calc(100vh - 410px)`},pagination:{current:p,pageSize:h,total:r,showSizeChanger:!0,responsive:!0,onChange:(e,t)=>{m(e),g(t),E(e,t)}}})})]}),(0,u.jsx)(DE,{open:C,templateId:x,modules:T,clients:A,onClose:()=>w(!1),onSaved:()=>{w(!1),E()}})]})}function kE({open:e,signatureId:t,onClose:r,onSaved:i}){let[a,o]=(0,s.useState)(``),[l,d]=(0,s.useState)(``),[f,p]=(0,s.useState)({module:`userSignature`,keys:[]}),[m,h]=(0,s.useState)(!1),[g,_]=(0,s.useState)(!1);(0,s.useEffect)(()=>{if(!e)return;let n=!1;return queueMicrotask(()=>{_(!0),Promise.all([t?HT(t):Promise.resolve(null),BT()]).then(([e,t])=>{n||(o(e?.signatureName??``),d(e?.signature??``),p(t??{module:`userSignature`,keys:[]}))}).catch(()=>{n||c.message.error(`Could not load signature details`)}).finally(()=>{n||_(!1)})}),()=>{n=!0}},[e,t]);function v(e){let t=`{{.${e.key}}}`;d(e=>`${e}${e?` `:``}${t}`)}async function y(){if(!a.trim())return c.message.error(`Signature name is required`);if(!l.trim())return c.message.error(`Signature content is required`);h(!0);try{let e=wE(l),n=(f.keys??[]).filter(t=>e.has(t.key)).map(e=>({key:e.key,value:e.value})),r={signatureId:t,signatureName:a,signature:l,signatureLogoPath:``,placeHolder:n.length?[{moduleName:f.module||`userSignature`,holders:n}]:[]};t?await WT(r):await UT(r),c.message.success(t?`Signature updated`:`Signature created`),i()}catch(e){c.message.error(e?.message||`Could not save signature`)}finally{h(!1)}}let b=e=>{let t=String(e?.key??``).trim().toLowerCase(),n=String(e?.value??``).trim().toLowerCase();return[`role_id`,`role_name`,`user_role`,`reporting_manager`].includes(t)||[`role`,`role_name`,`role id`,`role_id`,`reporting_manager`,`reporting manager`].includes(n)},x=(f.keys??[]).filter(e=>!b(e)),S=(f.keys??[]).filter(b),C=e=>(0,u.jsx)(`div`,{className:`template-placeholder-list`,children:e.map(e=>(0,u.jsx)(c.Tooltip,{title:`Mongo field: ${e.value}`,children:(0,u.jsx)(c.Tag,{color:`blue`,style:{cursor:`pointer`},onClick:()=>v(e),children:`{{.${e.key}}}`})},e.key))});return(0,u.jsx)(c.Drawer,{open:e,onClose:r,width:`min(820px, 96vw)`,title:t?`Edit signature`:`New signature`,destroyOnClose:!0,extra:(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(c.Button,{onClick:r,children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,loading:m,onClick:y,children:t?`Update`:`Create`})]}),children:(0,u.jsxs)(c.Form,{layout:`vertical`,children:[(0,u.jsx)(c.Form.Item,{label:`Signature name`,required:!0,children:(0,u.jsx)(c.Input,{value:a,onChange:e=>o(e.target.value)})}),(0,u.jsx)(c.Form.Item,{label:`Signature content`,required:!0,children:(0,u.jsx)(n.Xn,{value:l,onChange:d,placeholder:`Create the reusable signature…`})}),(0,u.jsxs)(`div`,{className:`template-placeholder-panel`,children:[(0,u.jsx)(bE,{strong:!0,children:`Signature placeholders`}),(0,u.jsx)(bE,{type:`secondary`,children:`Click a placeholder to add it to the signature. Values resolve from MongoDB users and roles when mail is generated.`}),g?(0,u.jsx)(bE,{type:`secondary`,children:`Loading placeholders…`}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{style:{marginTop:10},children:[(0,u.jsx)(bE,{strong:!0,children:`User details`}),C(x)]}),(0,u.jsxs)(`div`,{style:{marginTop:10},children:[(0,u.jsx)(bE,{strong:!0,children:`Role details`}),C(S)]}),!f.keys?.length&&(0,u.jsx)(c.Empty,{image:c.Empty.PRESENTED_IMAGE_SIMPLE,description:`No signature placeholders available`})]})]})]})})}function AE(){let[e,t]=(0,s.useState)([]),[n,r]=(0,s.useState)(0),[i,a]=(0,s.useState)(!1),[o,d]=(0,s.useState)(``),[f,p]=(0,s.useState)(1),[m,h]=(0,s.useState)(20),[g,_]=(0,s.useState)(!1),[v,y]=(0,s.useState)(null);function b(e=f,n=m,i=o){a(!0),VT({offset:(e-1)*n,limit:n,search:i}).then(({items:e,totalCount:n})=>{t(e),r(n)}).catch(()=>c.message.error(`Could not load signatures`)).finally(()=>a(!1))}(0,s.useEffect)(()=>{queueMicrotask(()=>{b(1,m,``)})},[]);async function x(e,n){try{await KT(e.signatureId,n),t(t=>t.map(t=>t.signatureId===e.signatureId?{...t,isActive:n}:t))}catch{c.message.error(`Could not update status`)}}async function S(e){try{await GT(e),c.message.success(`Signature deleted`),p(1),b(1)}catch{c.message.error(`Could not delete signature`)}}return(0,u.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,u.jsx)(Z,{icon:(0,u.jsx)(l.MailOutlined,{}),title:`Signature templates`,extra:(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>{y(null),_(!0)},children:`New signature`}),children:(0,u.jsx)(bE,{type:`secondary`,children:`Existing company and user signatures from the shared DB.`})}),(0,u.jsxs)(Z,{title:`${n} signature${n===1?``:`s`}`,children:[(0,u.jsx)(`div`,{className:`admin-config-table-tools`,children:(0,u.jsx)(c.Input,{allowClear:!0,prefix:(0,u.jsx)(l.SearchOutlined,{}),value:o,placeholder:`Search signatures`,onChange:e=>{d(e.target.value),p(1),b(1,m,e.target.value)}})}),(0,u.jsx)(`div`,{className:`templates-table-viewport`,children:(0,u.jsx)(c.Table,{rowKey:`signatureId`,dataSource:e,columns:[{title:`Signature`,dataIndex:`templateName`,key:`name`,width:300,ellipsis:!0,render:e=>(0,u.jsx)(bE,{strong:!0,ellipsis:{tooltip:e},children:e||`Untitled signature`})},{title:`Created`,dataIndex:`createdDt`,key:`created`,width:150,responsive:[`md`],render:e=>e?new Date(e).toLocaleDateString():`—`},{title:`Active`,dataIndex:`isActive`,key:`active`,width:80,render:(e,t)=>(0,u.jsx)(c.Switch,{size:`small`,checked:e,onChange:e=>x(t,e)})},{title:``,key:`actions`,width:84,fixed:`right`,render:(e,t)=>(0,u.jsxs)(c.Space,{size:2,children:[(0,u.jsx)(c.Button,{type:`text`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>{y(t.signatureId),_(!0)}}),(0,u.jsx)(c.Popconfirm,{title:`Delete this signature?`,onConfirm:()=>S(t.signatureId),children:(0,u.jsx)(c.Button,{type:`text`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{})})})]})}],loading:i,className:`fg-table`,size:`small`,tableLayout:`fixed`,sticky:!0,scroll:{x:614,y:`calc(100vh - 410px)`},pagination:{current:f,pageSize:m,total:n,responsive:!0,onChange:(e,t)=>{p(e),h(t),b(e,t)}}})})]}),(0,u.jsx)(kE,{open:g,signatureId:v,onClose:()=>_(!1),onSaved:()=>{_(!1),b()}})]})}function jE(){return(0,u.jsx)(c.Tabs,{defaultActiveKey:`email`,className:`admin-config-tabs`,items:[{key:`email`,label:`Email templates`,children:(0,u.jsx)(OE,{})},{key:`signature`,label:`Signatures`,children:(0,u.jsx)(AE,{})}]})}var ME=new Set([`169.254.169.254`,`169.254.170.2`,`metadata.google.internal`,`100.100.100.200`,`192.0.0.192`]);function NE(e){let t=String(e??``).trim();if(!t)return`Base URL is required`;let n;try{n=new URL(t)}catch{return`Enter a full URL including http:// or https://`}if(n.protocol!==`http:`&&n.protocol!==`https:`)return`Base URL must start with http:// or https://`;if(!n.hostname)return`Base URL has no host`;if(ME.has(n.hostname))return`${n.hostname} is a cloud metadata address and cannot be used`;if(!n.hostname.includes(`.`)&&n.hostname!==`localhost`&&!n.port)return`"${n.hostname}" looks incomplete — did you mean "${n.hostname}.com", or is a port missing?`;if(n.port){let e=Number(n.port);if(!Number.isInteger(e)||e<1||e>65535)return`Port "${n.port}" is not valid`}return null}function PE(e){let t=String(e??``).trim();if(!t)return null;let n;try{n=new URL(t)}catch{return null}return n.pathname.includes(`/pyOps`)?`Path contains "/pyOps" (capital O). On zinnext.com that route serves the web app, not the AI service — the AI service is at lowercase "/pyops".`:n.pathname.replace(/\/+$/,``).endsWith(`/v1`)?`Base URL ends with "/v1". The action's endpoint path already includes it (e.g. /v1/parse), so this would produce "/v1/v1/parse".`:null}var{Text:FE}=c.Typography,IE={serviceKey:``,label:``,baseUrl:``,authHeader:``,authValue:``,providerApiKey:``,enabled:!0};function LE({open:e,service:t,onClose:r,onSaved:i}){let[a]=c.Form.useForm(),[o,d]=(0,s.useState)(!1),[f,p]=(0,s.useState)(!1),[m,h]=(0,s.useState)(null),g=c.Form.useWatch(`baseUrl`,a);(0,s.useEffect)(()=>{e&&a.setFieldsValue({...IE,...t,authValue:``,providerApiKey:``})},[e,t,a]);let _=m&&m.forUrl===g?m:null,v=PE(g);async function y(){let e=a.getFieldsValue(),t=NE(e.baseUrl);if(t){h({reachable:!1,detail:t,forUrl:e.baseUrl});return}p(!0);try{h({...await n.Ri(e),forUrl:e.baseUrl})}catch(t){h({reachable:!1,detail:t?.message||`Test failed`,forUrl:e.baseUrl})}finally{p(!1)}}async function b(){try{let e=await a.validateFields();d(!0),await n.Oi(e),c.message.success(`AI service saved`),i()}catch(e){e?.errorFields||c.message.error(e?.message||`Could not save AI service`)}finally{d(!1)}}return(0,u.jsx)(c.Drawer,{open:e,onClose:r,width:`min(560px, 96vw)`,title:t?`Edit AI service`:`New AI service`,destroyOnClose:!0,extra:(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(c.Button,{onClick:r,children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,loading:o,onClick:b,children:`Save`})]}),children:(0,u.jsxs)(c.Form,{form:a,layout:`vertical`,initialValues:IE,children:[(0,u.jsx)(c.Form.Item,{name:`serviceKey`,label:`Service Key`,rules:[{required:!0,message:`Service key is required`}],tooltip:`Referenced by an AI Action's Service Key on any form field (e.g. pyOps).`,children:(0,u.jsx)(c.Input,{placeholder:`pyOps`,disabled:!!t,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:`label`,label:`Label`,children:(0,u.jsx)(c.Input,{placeholder:`Resume/JD Parsing Service`})}),(0,u.jsx)(c.Form.Item,{name:`baseUrl`,label:`Base URL`,rules:[{required:!0,message:`Base URL is required`,validator:(e,t)=>{let n=NE(t);return n?Promise.reject(Error(n)):Promise.resolve()}}],extra:v?(0,u.jsx)(FE,{type:`warning`,children:v}):null,children:(0,u.jsx)(c.Input,{placeholder:`https://zinnext.com/pyops`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{label:`Connection`,children:(0,u.jsxs)(c.Space,{direction:`vertical`,style:{width:`100%`},children:[(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.ApiOutlined,{}),loading:f,onClick:y,disabled:!g,children:`Test connection`}),_?(0,u.jsx)(c.Alert,{type:_.reachable&&!_.looksLikeWebApp?`success`:`error`,showIcon:!0,message:_.looksLikeWebApp?`This is not the AI service`:_.reachable?`Reachable`:`Not reachable`,description:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`div`,{children:_.detail}),_.latencyMs==null?null:(0,u.jsxs)(FE,{type:`secondary`,children:[`Checked from the server in `,_.latencyMs,`ms`]})]})}):(0,u.jsx)(FE,{type:`secondary`,children:`Checked from the backend server, not your browser — that is the machine that actually calls this service.`})]})}),(0,u.jsx)(c.Form.Item,{name:`authHeader`,label:`Auth Header (optional)`,children:(0,u.jsx)(c.Input,{placeholder:`x-api-key`,className:`fg-mono-input`})}),(0,u.jsx)(c.Form.Item,{name:`providerApiKey`,label:`Provider API Key`,tooltip:`The key the AI service uses to call its own provider (e.g. OpenAI). Write-only — leave blank to keep the saved value.`,extra:(0,u.jsx)(FE,{type:`secondary`,children:t?.hasProviderApiKey?`A key is stored. Leave blank to keep it, or type a new one to replace it.`:`No key stored here. Preferred: set OPENAI_API_KEY on the service instead — this is for environments that cannot be redeployed.`}),children:(0,u.jsx)(c.Input.Password,{placeholder:t?.hasProviderApiKey?`Unchanged`:`sk-…`,autoComplete:`new-password`})}),(0,u.jsx)(c.Form.Item,{name:`authValue`,label:`Auth Value`,tooltip:`Write-only — leave blank to keep the currently saved value.`,children:(0,u.jsx)(c.Input.Password,{placeholder:t?`Unchanged`:``})}),(0,u.jsx)(c.Form.Item,{name:`enabled`,label:`Enabled`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{})})]})})}function RE(){let[e,t]=(0,s.useState)([]),[r,i]=(0,s.useState)(!1),[a,o]=(0,s.useState)(!1),[d,f]=(0,s.useState)(null);function p(){i(!0),n.Wr().then(e=>t(Array.isArray(e)?e:[])).catch(e=>c.message.error(e?.message||`Could not load AI services`)).finally(()=>i(!1))}(0,s.useEffect)(()=>{queueMicrotask(()=>{p()})},[]);async function m(e,r){try{await n.Oi({...e,enabled:r}),t(t=>t.map(t=>t.serviceKey===e.serviceKey?{...t,enabled:r}:t))}catch(e){c.message.error(e?.message||`Could not update AI service`)}}async function h(e){try{await n.jr(e),c.message.success(`AI service deleted`),p()}catch(e){c.message.error(e?.message||`Could not delete AI service`)}}return(0,u.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.ThunderboltOutlined,{}),title:`AI Services`,extra:(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>{f(null),o(!0)},children:`New service`}),children:[(0,u.jsx)(`div`,{className:`admin-accent-bar`}),(0,u.jsx)(FE,{type:`secondary`,children:`Register the AI/automation backends that admin-configured "AI Actions" (Generate/Parse-style buttons on any form field) call. A field's AI Action names a Service Key here — no URL is ever hardcoded in the app.`})]}),(0,u.jsx)(Z,{title:`${e.length} service${e.length===1?``:`s`}`,extra:(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:p,children:`Reload`}),children:(0,u.jsx)(c.Table,{rowKey:`serviceKey`,columns:[{title:`Service`,key:`service`,render:(e,t)=>(0,u.jsxs)(`div`,{className:`admin-config-primary-cell`,children:[(0,u.jsx)(FE,{strong:!0,children:t.label||t.serviceKey}),(0,u.jsx)(FE,{type:`secondary`,code:!0,children:t.serviceKey})]})},{title:`Base URL`,dataIndex:`baseUrl`,key:`baseUrl`,ellipsis:!0,render:e=>(0,u.jsx)(FE,{code:!0,ellipsis:{tooltip:e},children:e})},{title:`Auth Header`,dataIndex:`authHeader`,key:`authHeader`,width:140,render:e=>e||`—`},{title:`Provider Key`,dataIndex:`hasProviderApiKey`,key:`hasProviderApiKey`,width:120,render:e=>e?(0,u.jsx)(FE,{type:`success`,children:`Configured`}):(0,u.jsx)(FE,{type:`secondary`,children:`Not set`})},{title:`Enabled`,dataIndex:`enabled`,key:`enabled`,width:90,render:(e,t)=>(0,u.jsx)(c.Switch,{size:`small`,checked:e,onChange:e=>m(t,e)})},{title:``,key:`actions`,width:84,fixed:`right`,render:(e,t)=>(0,u.jsxs)(c.Space,{size:2,children:[(0,u.jsx)(c.Tooltip,{title:`Edit`,children:(0,u.jsx)(c.Button,{type:`text`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>{f(t),o(!0)}})}),(0,u.jsx)(c.Popconfirm,{title:`Delete this AI service?`,onConfirm:()=>h(t.serviceKey),children:(0,u.jsx)(c.Button,{type:`text`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{})})})]})}],dataSource:e,loading:r,className:`fg-table`,size:`small`})}),(0,u.jsx)(LE,{open:a,service:d,onClose:()=>o(!1),onSaved:()=>{o(!1),p()}})]})}var{Text:zE}=c.Typography,BE={integrationKey:``,label:``,category:`GENERAL`,updateMethod:`MANUAL`,enabled:!0,provider:``,baseUrl:``,authType:`API_KEY`,authHeader:`x-api-key`,authValue:``,clientId:``,clientSecret:``,tokenUrl:``,createPath:``,statusPath:``,testPath:``,webhookSecret:``,targetModule:``,targetField:``,stageMatchField:``,stageMatchValue:``,stageStatusField:``,providerStatusPath:``,providerReferencePath:``,statusMappings:[{providerStatus:``,applicationStatus:``}]},VE=[{label:`API Key`,value:`API_KEY`},{label:`Bearer Token`,value:`BEARER_TOKEN`},{label:`Basic Authentication`,value:`BASIC_AUTH`},{label:`OAuth 2.0 Client Credentials`,value:`OAUTH2_CLIENT_CREDENTIALS`}];function HE(e){let t=Object.fromEntries((e.statusMappings??[]).filter(e=>e?.providerStatus&&e?.applicationStatus).map(e=>[e.providerStatus.trim(),e.applicationStatus.trim()])),n={...e,statusMapping:e.updateMethod===`API`?{targetModule:e.targetModule,targetField:e.targetField,stageMatchField:e.stageMatchField,stageMatchValue:e.stageMatchValue,stageStatusField:e.stageStatusField,providerStatusPath:e.providerStatusPath,providerReferencePath:e.providerReferencePath,values:t}:void 0};return[`statusMappings`,`targetModule`,`targetField`,`stageMatchField`,`stageMatchValue`,`stageStatusField`,`providerStatusPath`,`providerReferencePath`].forEach(e=>delete n[e]),n}function UE({open:e,integration:t,onClose:r,onSaved:i}){let[a]=c.Form.useForm(),[o,d]=(0,s.useState)(!1),[f,p]=(0,s.useState)(!1),m=c.Form.useWatch(`updateMethod`,a),h=c.Form.useWatch(`authType`,a),g=m===`API`,_=h===`OAUTH2_CLIENT_CREDENTIALS`;(0,s.useEffect)(()=>{if(!e)return;let n=t?.statusMapping??{};a.setFieldsValue({...BE,...t,authValue:``,clientSecret:``,webhookSecret:``,targetModule:n.targetModule??``,targetField:n.targetField??``,stageMatchField:n.stageMatchField??``,stageMatchValue:n.stageMatchValue??``,stageStatusField:n.stageStatusField??``,providerStatusPath:n.providerStatusPath??``,providerReferencePath:n.providerReferencePath??``,statusMappings:Object.entries(n.values??{}).map(([e,t])=>({providerStatus:e,applicationStatus:t})).concat(Object.keys(n.values??{}).length?[]:[{providerStatus:``,applicationStatus:``}])})},[a,t,e]);async function v(){try{let e=HE(await a.validateFields());d(!0),await n.Mi(e),c.message.success(`Integration saved`),i()}catch(e){e?.errorFields||c.message.error(e?.message||`Could not save integration`)}finally{d(!1)}}async function y(){try{let e=await a.validateFields([`integrationKey`,`baseUrl`,`testPath`,`authType`,`authHeader`,`authValue`,`clientId`,`clientSecret`,`tokenUrl`]);p(!0);let t=await n.zi(HE({...a.getFieldsValue(!0),...e}));c.message.success(t?.message||`Connection successful${t?.statusCode?` (${t.statusCode})`:``}`)}catch(e){e?.errorFields||c.message.error(e?.message||`Connection test failed`)}finally{p(!1)}}return(0,u.jsx)(c.Drawer,{open:e,onClose:r,width:`min(680px, 96vw)`,title:t?`Edit ${t.label}`:`Add Integration`,destroyOnClose:!0,extra:(0,u.jsxs)(c.Space,{children:[g&&(0,u.jsx)(c.Button,{loading:f,onClick:y,children:`Test Connection`}),(0,u.jsx)(c.Button,{onClick:r,children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,loading:o,onClick:v,children:`Save`})]}),children:(0,u.jsxs)(c.Form,{form:a,layout:`vertical`,initialValues:BE,children:[(0,u.jsxs)(c.Row,{gutter:16,children:[(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{name:`label`,label:`Integration Name`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{placeholder:`Background Check`})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{name:`integrationKey`,label:`Integration Key`,rules:[{required:!0},{pattern:/^[a-z][a-z0-9_-]{1,63}$/,message:`Use lowercase letters, numbers, _ or -`}],children:(0,u.jsx)(c.Input,{placeholder:`bgc`,disabled:!!t})})})]}),(0,u.jsxs)(c.Row,{gutter:16,children:[(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{name:`category`,label:`Category`,children:(0,u.jsx)(c.Select,{options:[{value:`ONBOARDING`,label:`Onboarding`},{value:`HRMS`,label:`HRMS`},{value:`PAYROLL`,label:`Payroll`},{value:`ESIGNATURE`,label:`E-Signature`},{value:`VMS`,label:`VMS`},{value:`GENERAL`,label:`General / Custom`}]})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{name:`enabled`,label:`Enabled`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{})})})]}),(0,u.jsx)(c.Form.Item,{name:`updateMethod`,label:`Update Method`,rules:[{required:!0}],children:(0,u.jsx)(c.Radio.Group,{optionType:`button`,buttonStyle:`solid`,options:[{label:`Manual Update`,value:`MANUAL`},{label:`API Integration`,value:`API`}]})}),!g&&(0,u.jsx)(c.Alert,{type:`info`,showIcon:!0,message:`This integration will use manual updates.`}),g&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Alert,{type:t?.credentialsConfigured?`success`:`warning`,showIcon:!0,message:t?.credentialsConfigured?`Credentials configured`:`Credentials required`,description:`Secrets are write-only. Leave a secret blank while editing to keep its current value.`,style:{marginBottom:16}}),(0,u.jsxs)(c.Row,{gutter:16,children:[(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{name:`provider`,label:`Provider`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{placeholder:`Provider name`})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{name:`baseUrl`,label:`API Base URL`,rules:[{required:!0,type:`url`}],children:(0,u.jsx)(c.Input,{placeholder:`https://api.provider.com`})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{name:`createPath`,label:`Create/Submit Path`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{placeholder:`/v1/requests`})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{name:`statusPath`,label:`Status Path`,rules:[{required:!0}],tooltip:`Use {referenceId} as a placeholder.`,children:(0,u.jsx)(c.Input,{placeholder:`/v1/requests/{referenceId}`})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{name:`testPath`,label:`Test Connection Path`,rules:[{required:!0}],tooltip:`A safe GET endpoint used only to validate URL and credentials.`,children:(0,u.jsx)(c.Input,{placeholder:`/v1/health`})})})]}),(0,u.jsx)(c.Form.Item,{name:`authType`,label:`Authentication Type`,rules:[{required:!0}],children:(0,u.jsx)(c.Select,{options:VE})}),_?(0,u.jsxs)(c.Row,{gutter:16,children:[(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{name:`clientId`,label:`Client ID`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{name:`clientSecret`,label:`Client Secret`,children:(0,u.jsx)(c.Input.Password,{placeholder:t?.credentialsConfigured?`Unchanged`:`Required`})})}),(0,u.jsx)(c.Col,{xs:24,children:(0,u.jsx)(c.Form.Item,{name:`tokenUrl`,label:`Token URL`,rules:[{required:!0,type:`url`}],children:(0,u.jsx)(c.Input,{})})})]}):(0,u.jsxs)(c.Row,{gutter:16,children:[(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{name:`authHeader`,label:`Authentication Header`,children:(0,u.jsx)(c.Input,{placeholder:`x-api-key`})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{name:`authValue`,label:`API Credential`,children:(0,u.jsx)(c.Input.Password,{placeholder:t?.credentialsConfigured?`Unchanged`:`Required`})})})]}),(0,u.jsx)(c.Form.Item,{name:`webhookSecret`,label:`Webhook Signing Secret (optional)`,children:(0,u.jsx)(c.Input.Password,{placeholder:t?.webhookConfigured?`Unchanged`:``})}),(0,u.jsxs)(Z,{title:`Status Mapping`,children:[(0,u.jsx)(zE,{type:`secondary`,children:`Map a status from the provider response into a module field or a matching workflow stage.`}),(0,u.jsxs)(c.Row,{gutter:16,style:{marginTop:16},children:[(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{name:`targetModule`,label:`Target Module`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{placeholder:`onboarding`})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{name:`targetField`,label:`Target Field`,rules:[{required:!0}],tooltip:`Use stages for a stage-array update, or a direct field name.`,children:(0,u.jsx)(c.Input,{placeholder:`stages`})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{name:`providerStatusPath`,label:`Provider Status JSON Path`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{placeholder:`data.status`})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{name:`providerReferencePath`,label:`Provider Reference JSON Path`,children:(0,u.jsx)(c.Input,{placeholder:`data.id`})})}),(0,u.jsx)(c.Col,{xs:24,md:8,children:(0,u.jsx)(c.Form.Item,{name:`stageMatchField`,label:`Stage Match Field`,children:(0,u.jsx)(c.Input,{placeholder:`stageCode`})})}),(0,u.jsx)(c.Col,{xs:24,md:8,children:(0,u.jsx)(c.Form.Item,{name:`stageMatchValue`,label:`Stage Match Value`,children:(0,u.jsx)(c.Input,{placeholder:`BGC`})})}),(0,u.jsx)(c.Col,{xs:24,md:8,children:(0,u.jsx)(c.Form.Item,{name:`stageStatusField`,label:`Stage Status Field`,children:(0,u.jsx)(c.Input,{placeholder:`status`})})})]}),(0,u.jsx)(zE,{strong:!0,children:`Status Values`}),(0,u.jsx)(c.Form.List,{name:`statusMappings`,children:(e,{add:t,remove:n})=>(0,u.jsxs)(c.Space,{direction:`vertical`,style:{width:`100%`,marginTop:8},children:[e.map(e=>(0,u.jsxs)(c.Row,{gutter:12,children:[(0,u.jsx)(c.Col,{flex:`1 1 220px`,children:(0,u.jsx)(c.Form.Item,{...e,name:[e.name,`providerStatus`],rules:[{required:!0,message:`Provider status is required`}],children:(0,u.jsx)(c.Input,{placeholder:`Provider status, e.g. completed`})})}),(0,u.jsx)(c.Col,{flex:`1 1 220px`,children:(0,u.jsx)(c.Form.Item,{...e,name:[e.name,`applicationStatus`],rules:[{required:!0,message:`Application status is required`}],children:(0,u.jsx)(c.Input,{placeholder:`Zinnext status, e.g. CLEARED`})})}),(0,u.jsx)(c.Col,{children:(0,u.jsx)(c.Button,{danger:!0,onClick:()=>n(e.name),children:`Remove`})})]},e.key)),(0,u.jsx)(c.Button,{type:`dashed`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>t({providerStatus:``,applicationStatus:``}),children:`Add Status Mapping`})]})})]})]})]})})}function WE(){let[e,t]=(0,s.useState)([]),[r,i]=(0,s.useState)(!1),[a,o]=(0,s.useState)(!1),[d,f]=(0,s.useState)(null),p=(0,s.useCallback)(()=>{i(!0),n.ai().then(e=>t(Array.isArray(e)?e:[])).catch(e=>c.message.error(e?.message||`Could not load integrations`)).finally(()=>i(!1))},[]);(0,s.useEffect)(()=>{queueMicrotask(p)},[p]);async function m(e){try{await n.Nr(e),c.message.success(`Integration deleted`),p()}catch(e){c.message.error(e?.message||`Could not delete integration`)}}return(0,u.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.ApiOutlined,{}),title:`Integrations`,extra:(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:p,children:`Reload`}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>{f(null),o(!0)},children:`Add Integration`})]}),children:[(0,u.jsx)(`div`,{className:`admin-accent-bar`}),(0,u.jsx)(zE,{type:`secondary`,children:`Configure reusable manual or API integrations for onboarding, payroll, e-signature, VMS, HRMS, and custom workflows.`})]}),(0,u.jsx)(Z,{title:`${e.length} integration${e.length===1?``:`s`}`,children:(0,u.jsx)(c.Table,{rowKey:`integrationKey`,columns:[{title:`Integration`,key:`name`,render:(e,t)=>(0,u.jsxs)(`div`,{className:`admin-config-primary-cell`,children:[(0,u.jsx)(zE,{strong:!0,children:t.label}),(0,u.jsx)(zE,{type:`secondary`,code:!0,children:t.integrationKey})]})},{title:`Category`,dataIndex:`category`,width:130,render:e=>e||`GENERAL`},{title:`Method`,dataIndex:`updateMethod`,width:110,render:e=>(0,u.jsx)(c.Tag,{color:e===`API`?`blue`:`default`,children:e})},{title:`Provider`,dataIndex:`provider`,render:e=>e||`—`},{title:`Enabled`,dataIndex:`enabled`,width:90,render:e=>(0,u.jsx)(c.Tag,{color:e?`green`:`default`,children:e?`Yes`:`No`})},{title:``,key:`actions`,width:90,render:(e,t)=>(0,u.jsxs)(c.Space,{size:2,children:[(0,u.jsx)(c.Button,{type:`text`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>{f(t),o(!0)}}),(0,u.jsx)(c.Popconfirm,{title:`Delete this integration?`,onConfirm:()=>m(t.integrationKey),children:(0,u.jsx)(c.Button,{type:`text`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{})})})]})}],dataSource:e,loading:r,size:`small`,className:`fg-table`})}),(0,u.jsx)(UE,{open:a,integration:d,onClose:()=>o(!1),onSaved:()=>{o(!1),p()}})]})}var{Text:$}=c.Typography;function GE({rows:e,onChange:t,keyPlaceholder:n,valuePlaceholder:r}){let i=(n,r)=>t(e.map((e,t)=>t===n?{...e,...r}:e)),a=n=>t(e.filter((e,t)=>t!==n));return(0,u.jsxs)(`div`,{children:[e.map((e,t)=>(0,u.jsxs)(`div`,{style:{display:`flex`,gap:6,marginTop:6},children:[(0,u.jsx)(c.Input,{size:`small`,style:{flex:1},placeholder:n,value:e.key,onChange:e=>i(t,{key:e.target.value}),className:`fg-mono-input`}),(0,u.jsx)(`span`,{style:{color:`#94a3b8`,alignSelf:`center`},children:`→`}),(0,u.jsx)(c.Input,{size:`small`,style:{flex:1},placeholder:r,value:e.value,onChange:e=>i(t,{value:e.target.value}),className:`fg-mono-input`}),(0,u.jsx)(c.Button,{size:`small`,type:`text`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{}),onClick:()=>a(t)})]},t)),(0,u.jsx)(c.Button,{size:`small`,type:`dashed`,icon:(0,u.jsx)(l.PlusOutlined,{}),style:{marginTop:6},onClick:()=>t([...e,{key:``,value:``}]),children:`Add`})]})}function KE({rows:e,onChange:t,keyPlaceholder:n=`field`,valuePlaceholder:r=`literal or {{field.path}}`}){let i=(n,r)=>t(e.map((e,t)=>t===n?{...e,...r}:e)),a=n=>t(e.filter((e,t)=>t!==n));return(0,u.jsxs)(`div`,{children:[e.map((e,t)=>(0,u.jsxs)(`div`,{style:{display:`flex`,gap:6,marginTop:6},children:[(0,u.jsx)(c.Input,{size:`small`,style:{flex:1},placeholder:n,value:e.key,onChange:e=>i(t,{key:e.target.value}),className:`fg-mono-input`}),(0,u.jsx)(c.Input,{size:`small`,style:{flex:1.6},placeholder:r,value:e.value,onChange:e=>i(t,{value:e.target.value}),className:`fg-mono-input`}),(0,u.jsx)(c.Button,{size:`small`,type:`text`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{}),onClick:()=>a(t)})]},t)),(0,u.jsx)(c.Button,{size:`small`,type:`dashed`,icon:(0,u.jsx)(l.PlusOutlined,{}),style:{marginTop:6},onClick:()=>t([...e,{key:``,value:``}]),children:`Add`}),(0,u.jsxs)($,{type:`secondary`,style:{fontSize:11,display:`block`,marginTop:4},children:[`Values are read as JSON when possible (true, 123, ["a","b"]) — otherwise kept as literal text. Use `,(0,u.jsx)(`code`,{children:`{{field.path}}`}),` to reference a payload field, or `,(0,u.jsx)(`code`,{children:`{{now}}`}),` for the current time.`]})]})}function qE(e){return Object.entries(e??{}).map(([e,t])=>({key:e,value:String(t??``)}))}function JE(e){let t={};for(let n of e??[])n.key?.trim()&&(t[n.key.trim()]=n.value??``);return t}function YE(e){return Object.entries(e??{}).map(([e,t])=>({key:e,value:typeof t==`string`?t:JSON.stringify(t)}))}function XE(e){let t={};for(let n of e??[]){if(!n.key?.trim())continue;let e=n.value;if(typeof e==`string`){let t=e.trim();if(t!==``)try{e=JSON.parse(t)}catch{}}t[n.key.trim()]=e}return t}function ZE({open:e,rule:t,onClose:n,onSave:r}){let[i,a]=(0,s.useState)(()=>({sourceModule:``,sourceIdField:``,required:!1,...t??{},fieldMapRows:qE(t?.fieldMap)})),o=(e,t)=>a(n=>({...n,[e]:t}));return(0,u.jsx)(c.Modal,{open:e,onCancel:n,width:640,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,u.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,u.jsx)(l.DatabaseOutlined,{}),` `,t?`Edit Denormalize Rule`:`New Denormalize Rule`]}),footer:(0,u.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,u.jsx)(c.Button,{onClick:n,children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.SaveOutlined,{}),onClick:()=>{if(!i.sourceModule?.trim())return c.message.error(`Source module is required`);if(!i.sourceIdField?.trim())return c.message.error(`Source id field is required`);let{fieldMapRows:e,...t}=i;r({...t,fieldMap:JE(e)})},children:`Apply`})]}),children:(0,u.jsxs)(`div`,{className:`fg-form-section`,children:[(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Source module`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`job`,value:i.sourceModule??``,onChange:e=>o(`sourceModule`,e.target.value),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Source id field (on THIS payload)`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`jobId`,value:i.sourceIdField??``,onChange:e=>o(`sourceIdField`,e.target.value),className:`fg-mono-input`})]})]}),(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:14},children:[(0,u.jsx)(c.Switch,{size:`small`,checked:!!i.required,onChange:e=>o(`required`,e)}),(0,u.jsx)($,{style:{fontSize:13},children:`Required — block the write if the source record can't be found`})]}),(0,u.jsxs)(`div`,{style:{marginTop:16},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Field map (source field → this payload's field)`}),(0,u.jsx)(GE,{rows:i.fieldMapRows??[],onChange:e=>o(`fieldMapRows`,e),keyPlaceholder:`jobTitle`,valuePlaceholder:`jobTitle`})]})]})})}function QE({open:e,rule:t,onClose:n,onSave:r}){let[i,a]=(0,s.useState)(()=>({sourceField:``,targetField:``,sourceCollection:``,idField:``,idOutputKey:``,stampNow:``,...t??{},fieldMapRows:qE(t?.fieldMap)})),o=(e,t)=>a(n=>({...n,[e]:t}));return(0,u.jsx)(c.Modal,{open:e,onCancel:n,width:640,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,u.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,u.jsx)(l.ApartmentOutlined,{}),` `,t?`Edit Array Enrichment`:`New Array Enrichment`]}),footer:(0,u.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,u.jsx)(c.Button,{onClick:n,children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.SaveOutlined,{}),onClick:()=>{if(!i.sourceField?.trim())return c.message.error(`Source field is required`);if(!i.targetField?.trim())return c.message.error(`Target field is required`);let{fieldMapRows:e,...t}=i;r({...t,fieldMap:JE(e)})},children:`Apply`})]}),children:(0,u.jsxs)(`div`,{className:`fg-form-section`,children:[(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Source field (array of ids on this payload)`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`recruitersData`,value:i.sourceField??``,onChange:e=>o(`sourceField`,e.target.value),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Target field (enriched array written here)`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`recruiters`,value:i.targetField??``,onChange:e=>o(`targetField`,e.target.value),className:`fg-mono-input`})]})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Source collection`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`users (default)`,value:i.sourceCollection??``,onChange:e=>o(`sourceCollection`,e.target.value),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Id field on that collection`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`legacyUserId (default)`,value:i.idField??``,onChange:e=>o(`idField`,e.target.value),className:`fg-mono-input`})]})]}),(0,u.jsxs)(`div`,{style:{marginTop:16},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Field map (source collection field → output key)`}),(0,u.jsx)(GE,{rows:i.fieldMapRows??[],onChange:e=>o(`fieldMapRows`,e),keyPlaceholder:`firstName`,valuePlaceholder:`recruiterName`})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Also write the matched id as`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`recruiterId`,value:i.idOutputKey??``,onChange:e=>o(`idOutputKey`,e.target.value),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Also stamp the current time as`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`assignedDateTime`,value:i.stampNow??``,onChange:e=>o(`stampNow`,e.target.value),className:`fg-mono-input`})]})]})]})})}function $E({open:e,rule:t,onClose:n,onSave:r}){let[i,a]=(0,s.useState)(()=>({sourceField:``,targetField:``,uploadedFileNameField:``,uniqueNameField:``,uploadedAtField:``,uploadedByField:``,arrayMode:!1,nameFromField:``,nameOutputField:``,historyField:``,historySnapshotKey:``,historyReason:``,...t??{},staticFieldRows:qE(t?.staticFields),arrayFieldNameRows:qE(t?.arrayFieldNames)})),o=(e,t)=>a(n=>({...n,[e]:t}));return(0,u.jsx)(c.Modal,{open:e,onCancel:n,width:760,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,u.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,u.jsx)(l.DatabaseOutlined,{}),` `,t?`Edit File Field Map`:`New File Field Map`]}),footer:(0,u.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,u.jsx)(c.Button,{onClick:n,children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.SaveOutlined,{}),onClick:()=>{if(!i.sourceField?.trim())return c.message.error(`Source field (the multipart upload key) is required`);if(!i.targetField?.trim())return c.message.error(`Target field is required`);let{staticFieldRows:e,arrayFieldNameRows:t,...n}=i;r({...n,staticFields:JE(e),arrayFieldNames:JE(t)})},children:`Apply`})]}),children:(0,u.jsxs)(`div`,{className:`fg-form-section`,children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:10},children:`Turns one uploaded file field into a nested object (or array of objects) instead of a flat S3 path string — for schemas like a candidate's resume/passport/visa that store location + filename + who/when as sub-fields.`}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Source field (multipart upload key)`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`resume`,value:i.sourceField??``,onChange:e=>o(`sourceField`,e.target.value),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsxs)($,{type:`secondary`,style:{fontSize:12},children:[`Target field `,i.arrayMode?`(array)`:`(location sub-field)`]}),(0,u.jsx)(c.Input,{size:`small`,placeholder:i.arrayMode?`documents`:`resume.location`,value:i.targetField??``,onChange:e=>o(`targetField`,e.target.value),className:`fg-mono-input`})]})]}),(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:14},children:[(0,u.jsx)(c.Switch,{size:`small`,checked:!!i.arrayMode,onChange:e=>o(`arrayMode`,e)}),(0,u.jsx)($,{style:{fontSize:13},children:`Array mode — every uploaded file becomes one element (e.g. "documents")`})]}),i.arrayMode?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{style:{marginTop:12},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Sub-field names (location / uploadedFileName / uniqueName → this schema's names)`}),(0,u.jsx)(GE,{rows:i.arrayFieldNameRows??[],onChange:e=>o(`arrayFieldNameRows`,e),keyPlaceholder:`location`,valuePlaceholder:`documentCopyLocation`})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Take each element's display name from (payload array field)`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`documents`,value:i.nameFromField??``,onChange:e=>o(`nameFromField`,e.target.value),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`...reading its field`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`documentName`,value:i.nameOutputField??``,onChange:e=>o(`nameOutputField`,e.target.value),className:`fg-mono-input`})]})]})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Original filename field`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`resume.uploadedFileName`,value:i.uploadedFileNameField??``,onChange:e=>o(`uploadedFileNameField`,e.target.value),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Unique name field`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`resume.uniqueName`,value:i.uniqueNameField??``,onChange:e=>o(`uniqueNameField`,e.target.value),className:`fg-mono-input`})]})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Uploaded-at field`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`resume.uploadedAt`,value:i.uploadedAtField??``,onChange:e=>o(`uploadedAtField`,e.target.value),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Uploaded-by field`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`resume.uploadedBy`,value:i.uploadedByField??``,onChange:e=>o(`uploadedByField`,e.target.value),className:`fg-mono-input`})]})]}),(0,u.jsxs)(`div`,{style:{marginTop:12},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Static fields (literal value written alongside the upload)`}),(0,u.jsx)(GE,{rows:i.staticFieldRows??[],onChange:e=>o(`staticFieldRows`,e),keyPlaceholder:`resume.source`,valuePlaceholder:`candidate`})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Append a snapshot to (history array field)`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`resumeHistory`,value:i.historyField??``,onChange:e=>o(`historyField`,e.target.value),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`...under snapshot key`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`resume`,value:i.historySnapshotKey??``,onChange:e=>o(`historySnapshotKey`,e.target.value),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`...with reason`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`Initial resume upload`,value:i.historyReason??``,onChange:e=>o(`historyReason`,e.target.value),className:`fg-mono-input`})]})]})]})]})})}function eD({open:e,rule:t,onClose:n,onSave:r}){let[i,a]=(0,s.useState)(()=>({name:``,seedField:``,direction:`up`,stopRole:0,includeSeed:!0,...t??{}})),o=(e,t)=>a(n=>({...n,[e]:t}));return(0,u.jsx)(c.Modal,{open:e,onCancel:n,width:620,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,u.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,u.jsx)(l.ApartmentOutlined,{}),` `,t?`Edit Hierarchy Expansion`:`New Hierarchy Expansion`]}),footer:(0,u.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,u.jsx)(c.Button,{onClick:n,children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.SaveOutlined,{}),onClick:()=>{if(!i.name?.trim())return c.message.error(`Name is required — this is how RelatedUpdates/Notify reference the result`);if(!/^[a-zA-Z0-9_]+$/.test(i.name))return c.message.error(`Name: letters, numbers, underscores only`);r(i)},children:`Apply`})]}),children:(0,u.jsxs)(`div`,{className:`fg-form-section`,children:[(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Name`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`chain`,value:i.name??``,onChange:e=>o(`name`,e.target.value),className:`fg-mono-input`}),(0,u.jsxs)($,{type:`secondary`,style:{fontSize:11},children:[`Referenced as `,(0,u.jsx)(`code`,{children:`{{hierarchy.`+(i.name||`name`)+`}}`})]})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Seed field (blank = the caller)`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`recruitersData`,value:i.seedField??``,onChange:e=>o(`seedField`,e.target.value),className:`fg-mono-input`})]})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Direction`}),(0,u.jsx)(c.Select,{size:`small`,style:{width:`100%`},value:i.direction||`up`,onChange:e=>o(`direction`,e),options:[{value:`up`,label:`Up — toward admin (reporting chain)`},{value:`down`,label:`Down — toward subordinates (team)`}]})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Stop at role id (up only, 0 = walk to the top)`}),(0,u.jsx)(c.InputNumber,{size:`small`,style:{width:`100%`},min:0,value:i.stopRole??0,onChange:e=>o(`stopRole`,e??0),disabled:i.direction!==`up`})]})]}),(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:14},children:[(0,u.jsx)(c.Switch,{size:`small`,checked:i.includeSeed!==!1,onChange:e=>o(`includeSeed`,e)}),(0,u.jsx)($,{style:{fontSize:13},children:`Include the seed user(s) themselves in the result`})]})]})})}function tD({open:e,rule:t,hierarchyNames:n,onClose:r,onSave:i}){let[a,o]=(0,s.useState)(()=>({collectionName:``,targetModule:``,matchField:``,scopeTenant:!1,forEach:``,insertMode:!!(t?.insertIfMissing&&Object.keys(t.insertIfMissing).length),...t??{},extraFilterRows:YE(t?.extraFilter),pullRows:YE(t?.pull),pushRows:YE(t?.push),setRows:YE(t?.set),setIfNonBlankRows:YE(t?.setIfNonBlank),insertIfMissingRows:YE(t?.insertIfMissing)})),d=(e,t)=>o(n=>({...n,[e]:t})),f=()=>{if(!a.collectionName?.trim()&&!a.targetModule?.trim())return c.message.error(`Set either a collection name or a target module`);let{extraFilterRows:e,pullRows:t,pushRows:n,setRows:r,setIfNonBlankRows:o,insertIfMissingRows:s,insertMode:l,...u}=a;i({...u,extraFilter:XE(e),pull:l?{}:XE(t),push:l?{}:XE(n),set:l?{}:XE(r),setIfNonBlank:l?{}:XE(o),insertIfMissing:l?XE(s):{}})},p=(n??[]).map(e=>({value:`hierarchy.${e}`,label:`{{hierarchy.${e}}}`}));return(0,u.jsx)(c.Modal,{open:e,onCancel:r,width:820,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,u.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,u.jsx)(l.ThunderboltOutlined,{}),` `,t?`Edit Related Update`:`New Related Update`]}),footer:(0,u.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,u.jsx)(c.Button,{onClick:r,children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.SaveOutlined,{}),onClick:f,children:`Apply`})]}),children:(0,u.jsxs)(`div`,{className:`fg-form-section`,children:[(0,u.jsx)(`div`,{className:`fg-form-section-label`,children:`Target`}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Collection name (used verbatim)`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`hiringProgress`,value:a.collectionName??``,onChange:e=>d(`collectionName`,e.target.value),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`— or — target module`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`job`,value:a.targetModule??``,onChange:e=>d(`targetModule`,e.target.value),className:`fg-mono-input`})]})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Match field (this payload's field holding the target _id)`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`jobId (blank for a tenant-scoped board)`,value:a.matchField??``,onChange:e=>d(`matchField`,e.target.value),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Repeat once per element of (ForEach)`}),(0,u.jsx)(c.Select,{size:`small`,style:{width:`100%`},allowClear:!0,showSearch:!0,placeholder:`e.g. {{hierarchy.chain}}`,value:a.forEach||void 0,onChange:e=>d(`forEach`,e??``),options:p})]})]}),(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:14},children:[(0,u.jsx)(c.Switch,{size:`small`,checked:!!a.scopeTenant,onChange:e=>d(`scopeTenant`,e)}),(0,u.jsx)($,{style:{fontSize:13},children:`Scope filter to the caller's tenant/business/businessUnit`})]}),(0,u.jsxs)(`div`,{style:{marginTop:14},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Extra filter (merged into the match filter)`}),(0,u.jsx)(KE,{rows:a.extraFilterRows??[],onChange:e=>d(`extraFilterRows`,e),keyPlaceholder:`recruiterId`,valuePlaceholder:`{"$in":"{{hierarchy.chain}}"}`})]}),(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:18},children:[(0,u.jsx)(c.Switch,{size:`small`,checked:!!a.insertMode,onChange:e=>d(`insertMode`,e)}),(0,u.jsx)($,{style:{fontSize:13},children:`Insert-only-if-missing (seed a new document instead of updating an existing one)`})]}),a.insertMode?(0,u.jsxs)(`div`,{style:{marginTop:10},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Document to insert when the filter matches nothing`}),(0,u.jsx)(KE,{rows:a.insertIfMissingRows??[],onChange:e=>d(`insertIfMissingRows`,e),keyPlaceholder:`hiringProgressJobStatus`,valuePlaceholder:`"unread"`})]}):(0,u.jsx)(c.Tabs,{size:`small`,style:{marginTop:10},items:[{key:`pull`,label:`Pull`,children:(0,u.jsx)(KE,{rows:a.pullRows??[],onChange:e=>d(`pullRows`,e),keyPlaceholder:`submitted`,valuePlaceholder:`{"candidateId":"{{applicantId}}"}`})},{key:`push`,label:`Push`,children:(0,u.jsx)(KE,{rows:a.pushRows??[],onChange:e=>d(`pushRows`,e),keyPlaceholder:`submitted`,valuePlaceholder:`{"status":"{{submissionStatus}}"}`})},{key:`set`,label:`Set`,children:(0,u.jsx)(KE,{rows:a.setRows??[],onChange:e=>d(`setRows`,e),keyPlaceholder:`hiringProgressJobStatus`,valuePlaceholder:`"unread"`})},{key:`setIfNonBlank`,label:`Set if non-blank`,children:(0,u.jsx)(KE,{rows:a.setIfNonBlankRows??[],onChange:e=>d(`setIfNonBlankRows`,e),keyPlaceholder:`resume.location`,valuePlaceholder:`{{resume.location}}`})}]})]})})}function nD({icon:e,title:t,description:n,rules:r,columns:i,onAdd:a,onEdit:o,onDelete:s}){return(0,u.jsxs)(Z,{title:(0,u.jsxs)(`span`,{children:[e,` `,t]}),extra:(0,u.jsx)(c.Button,{size:`small`,type:`dashed`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:a,children:`Add`}),styles:{body:{paddingTop:8}},children:[n&&(0,u.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:10},children:n}),(0,u.jsx)(c.Table,{rowKey:(e,t)=>t,dataSource:r,columns:[...i,{title:``,key:`actions`,width:80,align:`right`,render:(e,t,n)=>(0,u.jsxs)(c.Space,{size:4,children:[(0,u.jsx)(c.Tooltip,{title:`Edit`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>o(n,t)})}),(0,u.jsx)(c.Tooltip,{title:`Delete`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{}),onClick:()=>s(n)})})]})}],pagination:!1,size:`small`,className:`fg-table`,locale:{emptyText:(0,u.jsx)(c.Empty,{image:c.Empty.PRESENTED_IMAGE_SIMPLE,description:`Not configured`})}})]})}var rD={assignmentSource:null,sequence:null,duplicateCheck:null,fileVersioning:null,denormalizations:[],arrayEnrichments:[],fileFieldMaps:[],sanitizeFields:[],defaults:{},hierarchyExpands:[],relatedUpdates:[],notify:null,cacheInvalidate:[]};function iD(){let[e,t]=(0,s.useState)([]),[r,i]=(0,s.useState)(!0),[a,o]=(0,s.useState)(``),[d,f]=(0,s.useState)({storage:`mongo`}),[p,m]=(0,s.useState)(`mongo`),[h,g]=(0,s.useState)(rD),[_,v]=(0,s.useState)(!1),[y,b]=(0,s.useState)(!1),[x,S]=(0,s.useState)(``),[C,w]=(0,s.useState)(null),[T,E]=(0,s.useState)(null),[D,O]=(0,s.useState)(null),[k,A]=(0,s.useState)(null),[j,M]=(0,s.useState)(null);(0,s.useEffect)(()=>{n.Xr().then(e=>{let n=qS(e).map(({value:e,label:t})=>({key:e,label:t}));t(n),n.length&&o(n[0].key)}).catch(()=>t([])).finally(()=>i(!1))},[]),(0,s.useEffect)(()=>{if(!a)return;let e=!1;return(async()=>{v(!0),S(``);try{let t=await n.fi(a);if(e)return;let r=t.gateway??{storage:`mongo`};f(r),m(r.storage||`mongo`),g({...rD,...t.strategies??{}})}catch(t){e||S(t?.message||`Failed to load automations`)}finally{e||v(!1)}})(),()=>{e=!0}},[a]);let N=(0,s.useMemo)(()=>(h.hierarchyExpands??[]).map(e=>e.name).filter(Boolean),[h.hierarchyExpands]);function P(e,t){g(n=>({...n,[e]:t}))}function F(e,t){g(n=>{let r=n.duplicateCheck??{},i=[...r.stages??[]];return i[e]=t,{...n,duplicateCheck:{...r,stages:i}}})}function I(e,t){g(n=>{let r={...n.assignmentSource??{},[e]:t};return e===`stampAs`&&!String(t).trim()?{...n,assignmentSource:null}:{...n,assignmentSource:r}})}function L(){b(!0);let e={...h,denormalizations:h.denormalizations?.length?h.denormalizations:void 0,arrayEnrichments:h.arrayEnrichments?.length?h.arrayEnrichments:void 0,fileFieldMaps:h.fileFieldMaps?.length?h.fileFieldMaps:void 0,sanitizeFields:h.sanitizeFields?.length?h.sanitizeFields:void 0,hierarchyExpands:h.hierarchyExpands?.length?h.hierarchyExpands:void 0,relatedUpdates:h.relatedUpdates?.length?h.relatedUpdates:void 0,cacheInvalidate:h.cacheInvalidate?.length?h.cacheInvalidate:void 0,defaults:Object.keys(h.defaults??{}).length?h.defaults:void 0,assignmentSource:h.assignmentSource?.stampAs?.trim()?h.assignmentSource:void 0};n.Ni(a,{gateway:d,strategies:e}).then(()=>{m(d.storage||`mongo`),c.message.success(`Automations saved`)}).catch(e=>c.message.error(e?.message||`Could not save automations`)).finally(()=>b(!1))}function R(){if((d.storage||`mongo`)!==p){c.Modal.confirm({title:`Change how this module persists writes?`,content:`You're switching ${a} from "${p}" to "${d.storage}". `+(d.storage===`mongo`?`This module will stop calling its downstream service and this gateway will own the write + every Strategy below.`:`This module will stop using the Strategies below and go back to calling its downstream service.`)+` Make sure the downstream service / e2e checks are ready before confirming.`,okText:`Confirm cutover`,okButtonProps:{danger:!0},onOk:L});return}L()}let z=[{title:`Source module`,dataIndex:`sourceModule`,key:`sourceModule`,render:e=>(0,u.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Source id field`,dataIndex:`sourceIdField`,key:`sourceIdField`},{title:`Fields`,key:`fields`,render:(e,t)=>(0,u.jsx)(c.Badge,{count:Object.keys(t.fieldMap??{}).length,showZero:!0,color:`var(--color-brand)`})},{title:`Required`,dataIndex:`required`,key:`required`,width:90,render:e=>e?(0,u.jsx)(c.Tag,{color:`volcano`,children:`Required`}):(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`optional`})}],B=[{title:`Source field`,dataIndex:`sourceField`,key:`sourceField`,render:e=>(0,u.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Target field`,dataIndex:`targetField`,key:`targetField`,render:e=>(0,u.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`From collection`,key:`coll`,render:(e,t)=>t.sourceCollection||`users`},{title:`Fields`,key:`fields`,render:(e,t)=>(0,u.jsx)(c.Badge,{count:Object.keys(t.fieldMap??{}).length,showZero:!0,color:`var(--color-brand)`})}],V=[{title:`Source field`,dataIndex:`sourceField`,key:`sourceField`,render:e=>(0,u.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Target field`,dataIndex:`targetField`,key:`targetField`,render:e=>(0,u.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Mode`,dataIndex:`arrayMode`,key:`arrayMode`,width:100,render:e=>e?(0,u.jsx)(c.Tag,{color:`blue`,children:`Array`}):(0,u.jsx)(c.Tag,{children:`Single`})},{title:`History`,dataIndex:`historyField`,key:`historyField`,render:e=>e||(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`—`})}],H=[{title:`Name`,dataIndex:`name`,key:`name`,render:e=>(0,u.jsx)(`code`,{className:`fg-table-code`,children:`{{hierarchy.`+e+`}}`})},{title:`Seed field`,dataIndex:`seedField`,key:`seedField`,render:e=>e||(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`caller`})},{title:`Direction`,dataIndex:`direction`,key:`direction`,render:e=>(0,u.jsx)(c.Tag,{color:e===`down`?`blue`:`purple`,children:e===`down`?`Down — team`:`Up — chain`})},{title:`Stop role`,dataIndex:`stopRole`,key:`stopRole`,width:90,render:e=>e||(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`top`})}],ee=[{title:`Target`,key:`target`,render:(e,t)=>(0,u.jsx)(`code`,{className:`fg-table-code`,children:t.collectionName||t.targetModule})},{title:`Match`,key:`match`,render:(e,t)=>t.matchField||(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`tenant-scoped`})},{title:`For each`,key:`forEach`,render:(e,t)=>t.forEach?(0,u.jsx)(c.Tag,{color:`geekblue`,children:`{{${t.forEach}}}`}):(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`once`})},{title:`Mode`,key:`mode`,render:(e,t)=>Object.keys(t.insertIfMissing??{}).length?(0,u.jsx)(c.Tag,{color:`green`,children:`Insert if missing`}):(0,u.jsx)(c.Tag,{children:`Update`})}],te=e.map(e=>({key:e.key,label:e.label}));return(0,u.jsxs)(`div`,{className:`fg-section`,children:[(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.ThunderboltOutlined,{}),title:`Automations`,extra:(0,u.jsx)(c.Button,{type:`primary`,size:`small`,icon:(0,u.jsx)(l.SaveOutlined,{}),loading:y,disabled:!a,onClick:R,children:`Save Automations`}),children:[(0,u.jsx)(`div`,{className:`admin-accent-bar`}),(0,u.jsx)($,{type:`secondary`,style:{fontSize:13},children:`Config-driven side-effects the common CRUD gateway runs around a create — reference ids, duplicate checks, cross-module field snapshots, reporting-chain hierarchy expansion, board updates, notifications, cache invalidation. Nothing here is module-specific: the same engine serves every module.`})]}),(0,u.jsx)(Z,{styles:{body:{paddingTop:8}},children:(0,u.jsxs)(c.Spin,{spinning:r,children:[(0,u.jsx)(c.Tabs,{activeKey:a,onChange:o,items:te.map(e=>({...e,children:null})),className:`admin-module-tabs`}),x&&(0,u.jsx)(c.Alert,{type:`error`,showIcon:!0,message:x,style:{marginBottom:12}}),(0,u.jsxs)(c.Spin,{spinning:_,children:[(0,u.jsxs)(Z,{title:`Gateway`,styles:{body:{paddingTop:8}},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:10},children:`Selects how a write to this module persists. "Proxy" forwards to a downstream microservice (which owns every side-effect below itself). "Mongo" makes THIS gateway own the write and run every Strategy configured below.`}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Storage`}),(0,u.jsx)(c.Select,{size:`small`,style:{width:`100%`},value:d.storage||`mongo`,onChange:e=>f(t=>({...t,storage:e})),options:[{value:`mongo`,label:`Mongo — this gateway owns the write`},{value:`proxy`,label:`Proxy — forward to a downstream service`}]})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`File field key`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`file`,value:d.fileKey??``,onChange:e=>f(t=>({...t,fileKey:e.target.value})),className:`fg-mono-input`})]})]}),d.storage===`proxy`&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Base URL env var`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`JOBS_SERVICE_URL`,value:d.baseUrlEnv??``,onChange:e=>f(t=>({...t,baseUrlEnv:e.target.value})),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Base URL (fallback)`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`http://...`,value:d.baseUrl??``,onChange:e=>f(t=>({...t,baseUrl:e.target.value})),className:`fg-mono-input`})]})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginTop:12},children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Create path`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`/v1/jobs`,value:d.createPath??``,onChange:e=>f(t=>({...t,createPath:e.target.value})),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Update path (%s = id)`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`/v1/edit/%s`,value:d.updatePath??``,onChange:e=>f(t=>({...t,updatePath:e.target.value})),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Update method`}),(0,u.jsx)(c.Select,{size:`small`,style:{width:`100%`},value:d.updateMethod||`PUT`,onChange:e=>f(t=>({...t,updateMethod:e})),options:[`PUT`,`POST`,`PATCH`].map(e=>({value:e,label:e}))})]})]})]})]}),(0,u.jsxs)(Z,{title:`Reference ID (Sequence)`,styles:{body:{paddingTop:8}},children:[(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:10},children:[(0,u.jsx)(c.Switch,{size:`small`,checked:!!h.sequence,onChange:e=>P(`sequence`,e?{field:``,prefix:``,counterKey:``}:null)}),(0,u.jsxs)($,{style:{fontSize:13},children:[`Generate a "`,`{prefix}{n}`,`" reference id on create`]})]}),h.sequence&&(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Payload field`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`submissionId`,value:h.sequence.field??``,onChange:e=>P(`sequence`,{...h.sequence,field:e.target.value}),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Prefix`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`sub`,value:h.sequence.prefix??``,onChange:e=>P(`sequence`,{...h.sequence,prefix:e.target.value}),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Counter key`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`submissions`,value:h.sequence.counterKey??``,onChange:e=>P(`sequence`,{...h.sequence,counterKey:e.target.value}),className:`fg-mono-input`})]})]})]}),(0,u.jsxs)(Z,{title:`Check for someone already on file`,styles:{body:{paddingTop:8}},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:10},children:`Before a new record is saved, look for one that already matches. This is what stops the same person being added twice under slightly different details.`}),(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:10},children:[(0,u.jsx)(c.Switch,{size:`small`,checked:!!h.duplicateCheck,onChange:e=>P(`duplicateCheck`,e?{stages:[],policy:`prompt`,displayFields:[],message:``}:null)}),(0,u.jsx)($,{style:{fontSize:13},children:`Check before saving a new record`})]}),h.duplicateCheck&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:6},children:[(0,u.jsx)(`b`,{children:`Checks run in order, top first, and stop at the first match.`}),` Put your most certain check first — matching an email or a phone number is near proof; matching a name alone is only a maybe, so it belongs lower down.`]}),(h.duplicateCheck.stages??[]).map((e,t)=>(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginBottom:8,alignItems:`flex-end`},children:[(0,u.jsxs)(`div`,{style:{flex:1.6},children:[(0,u.jsxs)($,{type:`secondary`,style:{fontSize:12},children:[`Check `,t+1,` — compare these`]}),(0,u.jsx)(c.Select,{mode:`tags`,size:`small`,style:{width:`100%`},placeholder:`email, contactNumber`,value:e.fields??[],onChange:n=>F(t,{...e,fields:n})})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Counts as a match when`}),(0,u.jsx)(c.Select,{size:`small`,style:{width:`100%`},value:e.match??`all`,onChange:n=>F(t,{...e,match:n}),options:[{value:`any`,label:`Any one of them matches`},{value:`all`,label:`All of them match`}]})]}),(0,u.jsxs)(`div`,{style:{flex:.8},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`How sure is it?`}),(0,u.jsx)(c.Select,{size:`small`,style:{width:`100%`},value:e.weight??`strong`,onChange:n=>F(t,{...e,weight:n}),options:[{value:`strong`,label:`Almost certainly the same`},{value:`weak`,label:`Possibly the same`}]})]}),(0,u.jsxs)(`div`,{style:{flex:2},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`What to tell the user`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`A candidate with this email already exists — {name}, last updated {age}.`,value:e.message??``,onChange:n=>F(t,{...e,message:n.target.value})})]}),(0,u.jsx)(c.Button,{size:`small`,danger:!0,type:`text`,onClick:()=>P(`duplicateCheck`,{...h.duplicateCheck,stages:(h.duplicateCheck.stages??[]).filter((e,n)=>n!==t)}),children:`Remove`})]},t)),(0,u.jsx)(c.Button,{size:`small`,type:`dashed`,style:{marginBottom:12},onClick:()=>P(`duplicateCheck`,{...h.duplicateCheck,stages:[...h.duplicateCheck.stages??[],{fields:[],match:`any`,weight:`strong`}]}),children:`Add another check`}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`When a match is found`}),(0,u.jsx)(c.Select,{size:`small`,style:{width:`100%`},value:h.duplicateCheck.policy??`prompt`,onChange:e=>P(`duplicateCheck`,{...h.duplicateCheck,policy:e}),options:[{value:`prompt`,label:`Ask, and offer to update the existing one`},{value:`block`,label:`Refuse to save, and name the existing one`}]})]}),(0,u.jsxs)(`div`,{style:{flex:1.2},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Which details identify the record`}),(0,u.jsx)(c.Select,{mode:`tags`,size:`small`,style:{width:`100%`},placeholder:`firstName, lastName, email`,value:h.duplicateCheck.displayFields??[],onChange:e=>P(`duplicateCheck`,{...h.duplicateCheck,displayFields:e})})]})]}),(0,u.jsx)(`div`,{className:`fg-field-meta-row`,style:{marginTop:10},children:(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Where to open the existing record`}),(0,u.jsx)(c.Input,{size:`small`,className:`fg-mono-input`,placeholder:`/candidate/edit/:id`,value:h.duplicateCheck.editRoute??``,onChange:e=>P(`duplicateCheck`,{...h.duplicateCheck,editRoute:e.target.value})})]})}),(0,u.jsxs)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:6},children:[`The page that opens when someone chooses to update the record you already have. Use `,(0,u.jsx)(`b`,{children:`:id`}),` where the record's id goes. This has to be filled in — it cannot be worked out, because addresses follow no single pattern (this app uses `,(0,u.jsx)(`code`,{children:`/candidate/edit/:id`}),` but `,(0,u.jsx)(`code`,{children:`/clients/edit/:id`}),`). Left blank, the dialog still appears and simply does not navigate, rather than sending anyone to a page that does not exist.`]}),(0,u.jsxs)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:8},children:[`In any message you can use `,(0,u.jsx)(`b`,{children:`{name}`}),` for the matched record and`,(0,u.jsxs)(`b`,{children:[` `,`{age}`]}),` for how long ago it was last touched ("about 2 months ago"). `,(0,u.jsx)(`b`,{children:`{updatedOn}`}),` gives the date instead. Only the details listed above are shown — nothing else about the record is revealed.`]})]})]}),(0,u.jsxs)(Z,{title:`Keep previous versions of an uploaded file`,styles:{body:{paddingTop:8}},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:10},children:`Normally a new upload replaces the old one and it is gone. Turn this on and the last few are kept instead — useful when someone sends an updated CV and you may want to look back at the earlier one. Everywhere in the app still shows the newest; the older ones sit behind it.`}),(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:10},children:[(0,u.jsx)(c.Switch,{size:`small`,checked:!!h.fileVersioning,onChange:e=>P(`fileVersioning`,e?{fields:[],keep:2,historyKey:``,s3Prefix:``,deleteEvicted:!1}:null)}),(0,u.jsx)($,{style:{fontSize:13},children:`Keep previous uploads`})]}),h.fileVersioning&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{style:{marginBottom:10},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`},children:`Where the older versions are kept`}),(0,u.jsxs)(c.Radio.Group,{size:`small`,value:h.fileVersioning.store===`documents`?`documents`:`record`,onChange:e=>{let t=e.target.value,n={...h.fileVersioning,store:t===`documents`?`documents`:``};t===`documents`&&(n.linkField=n.linkField||`documentIds`,n.clearRecordKeys=n.clearRecordKeys?.length?n.clearRecordKeys:(n.fields??[]).flatMap(e=>[`${e}History`,`${e}Versions`])),P(`fileVersioning`,n)},children:[(0,u.jsx)(c.Radio,{value:`documents`,children:`In Documents (recommended)`}),(0,u.jsx)(c.Radio,{value:`record`,children:`On the record itself`})]}),(0,u.jsxs)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:6},children:[(0,u.jsx)(`b`,{children:`In Documents`}),` keeps the file and all its earlier versions in one place, the same place every other document lives. The record just points at it — so when a candidate is submitted for a job, the submission shows the very same file, and replacing it updates both at once. `,(0,u.jsx)(`b`,{children:`On the record itself`}),` is the older way: each record keeps its own copy of the history, which is why the same résumé could end up recorded several times over and the copies could disagree.`]})]}),h.fileVersioning.store===`documents`&&(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,style:{marginBottom:10},children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`List of attached documents is kept in`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`documentIds`,value:h.fileVersioning.linkField??``,onChange:e=>P(`fileVersioning`,{...h.fileVersioning,linkField:e.target.value})})]}),(0,u.jsxs)(`div`,{style:{flex:1.6},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Old history fields to clear off the record`}),(0,u.jsx)(c.Select,{mode:`tags`,size:`small`,style:{width:`100%`},placeholder:`resumeHistory`,value:h.fileVersioning.clearRecordKeys??[],onChange:e=>P(`fileVersioning`,{...h.fileVersioning,clearRecordKeys:e})})]})]}),(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,u.jsxs)(`div`,{style:{flex:1.4},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Which uploads`}),(0,u.jsx)(c.Select,{mode:`tags`,size:`small`,style:{width:`100%`},placeholder:`resume`,value:h.fileVersioning.fields??[],onChange:e=>P(`fileVersioning`,{...h.fileVersioning,fields:e})})]}),(0,u.jsxs)(`div`,{style:{flex:.7},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`How many to keep`}),(0,u.jsx)(c.Input,{size:`small`,type:`number`,min:1,value:h.fileVersioning.keep??2,onChange:e=>P(`fileVersioning`,{...h.fileVersioning,keep:Number(e.target.value)||1})})]}),(0,u.jsxs)(`div`,{style:{flex:1.4},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Where the files are grouped`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`candidates/{recordId}/resume`,value:h.fileVersioning.s3Prefix??``,onChange:e=>P(`fileVersioning`,{...h.fileVersioning,s3Prefix:e.target.value})})]})]}),(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:10},children:[(0,u.jsx)(c.Switch,{size:`small`,checked:!!h.fileVersioning.deleteEvicted,onChange:e=>P(`fileVersioning`,{...h.fileVersioning,deleteEvicted:e})}),(0,u.jsx)($,{style:{fontSize:13},children:`Also delete the file once it drops off the end`})]}),(0,u.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:6},children:`Leave that switch OFF unless you are sure. With it off, an older file simply stops being shown and can still be recovered. With it on, it is deleted from storage permanently and cannot be brought back. Keeping 2 means a third upload pushes the first one off the end.`})]})]}),(0,u.jsx)(nD,{icon:(0,u.jsx)(l.DatabaseOutlined,{}),title:`Denormalizations`,description:`Copy fields from ANOTHER module's record onto this payload before insert (e.g. a submission snapshotting job title/client).`,rules:h.denormalizations??[],columns:z,onAdd:()=>w({index:null,rule:null}),onEdit:(e,t)=>w({index:e,rule:t}),onDelete:e=>P(`denormalizations`,(h.denormalizations??[]).filter((t,n)=>n!==e))}),(0,u.jsx)(nD,{icon:(0,u.jsx)(l.ApartmentOutlined,{}),title:`Array Enrichments`,description:`Enrich a payload array of ids (e.g. recruitersData) into objects carrying looked-up fields (name, email) before insert.`,rules:h.arrayEnrichments??[],columns:B,onAdd:()=>E({index:null,rule:null}),onEdit:(e,t)=>E({index:e,rule:t}),onDelete:e=>P(`arrayEnrichments`,(h.arrayEnrichments??[]).filter((t,n)=>n!==e))}),(0,u.jsx)(nD,{icon:(0,u.jsx)(l.DatabaseOutlined,{}),title:`File Field Maps`,description:`Turn an uploaded file field into a nested object (location + filename + who/when) or an array of such objects, instead of a flat S3 path string — needed for schemas like resume/passport/visa.`,rules:h.fileFieldMaps??[],columns:V,onAdd:()=>O({index:null,rule:null}),onEdit:(e,t)=>O({index:e,rule:t}),onDelete:e=>P(`fileFieldMaps`,(h.fileFieldMaps??[]).filter((t,n)=>n!==e))}),(0,u.jsxs)(Z,{title:`Sanitize Fields`,styles:{body:{paddingTop:8}},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:8},children:`Trim and HTML-escape these payload fields before anything else runs — basic XSS-safety for free-text fields (e.g. firstName/lastName) that might later be embedded in an HTML activity comment or email.`}),(0,u.jsx)(c.Select,{mode:`tags`,style:{width:`100%`},placeholder:`firstName, lastName, email`,value:h.sanitizeFields??[],onChange:e=>P(`sanitizeFields`,e)})]}),(0,u.jsxs)(Z,{title:`Who is assigned to this record`,styles:{body:{paddingTop:8}},children:[(0,u.jsxs)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:8},children:[`Marks every row of this module's list with whether the signed-in user is assigned to it, by looking in another collection. The result is written onto each row as the field named below, so an `,(0,u.jsx)(`b`,{children:`Action Rule`}),` can test it like any other field — e.g.`,` `,(0,u.jsx)(`code`,{children:`assignedToMe equals false`}),` to restrict what an unassigned user can do.`,(0,u.jsx)(`br`,{}),`Leave `,(0,u.jsx)(`b`,{children:`Stamp as`}),` empty to turn this off.`]}),(0,u.jsxs)(c.Space,{direction:`vertical`,style:{width:`100%`},size:8,children:[(0,u.jsxs)(c.Space,{wrap:!0,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)($,{style:{fontSize:12},children:`Collection`}),(0,u.jsx)(c.Input,{style:{width:220},placeholder:`workflow_instances`,value:h.assignmentSource?.collection??``,onChange:e=>I(`collection`,e.target.value)})]}),(0,u.jsxs)(`div`,{children:[(0,u.jsx)($,{style:{fontSize:12},children:`Record id field`}),(0,u.jsx)(c.Input,{style:{width:180},placeholder:`entityId`,value:h.assignmentSource?.entityIdField??``,onChange:e=>I(`entityIdField`,e.target.value)})]}),(0,u.jsxs)(`div`,{children:[(0,u.jsx)($,{style:{fontSize:12},children:`Stamp as`}),(0,u.jsx)(c.Input,{style:{width:180},placeholder:`assignedToMe`,value:h.assignmentSource?.stampAs??``,onChange:e=>I(`stampAs`,e.target.value)})]})]}),(0,u.jsxs)(`div`,{children:[(0,u.jsx)($,{style:{fontSize:12},children:`User fields — assigned if ANY holds the signed-in user`}),(0,u.jsx)(c.Select,{mode:`tags`,style:{width:`100%`},placeholder:`recruiterId, reportingId`,value:h.assignmentSource?.userMatchFields??[],onChange:e=>I(`userMatchFields`,e)})]}),(0,u.jsxs)(c.Space,{wrap:!0,align:`start`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)($,{style:{fontSize:12},children:`Entity type field / values`}),(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(c.Input,{style:{width:140},placeholder:`entityType`,value:h.assignmentSource?.entityTypeField??``,onChange:e=>I(`entityTypeField`,e.target.value)}),(0,u.jsx)(c.Select,{mode:`tags`,style:{width:200},placeholder:`Job`,value:h.assignmentSource?.entityTypeValues??[],onChange:e=>I(`entityTypeValues`,e)})]})]}),(0,u.jsxs)(`div`,{children:[(0,u.jsx)($,{style:{fontSize:12},children:`Module field / values`}),(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(c.Input,{style:{width:140},placeholder:`module`,value:h.assignmentSource?.moduleField??``,onChange:e=>I(`moduleField`,e.target.value)}),(0,u.jsx)(c.Select,{mode:`tags`,style:{width:200},placeholder:`Jobs, jobs`,value:h.assignmentSource?.moduleValues??[],onChange:e=>I(`moduleValues`,e)})]})]})]}),(0,u.jsx)(c.Alert,{type:`warning`,showIcon:!0,style:{fontSize:12},message:`List every spelling that exists in the data`,description:(0,u.jsxs)(`span`,{children:[`These are exact matches. The same value is stored with different casing in places (`,(0,u.jsx)(`code`,{children:`Jobs`}),` and `,(0,u.jsx)(`code`,{children:`jobs`}),`), so listing only one reads as correct while silently missing every row written with the other — and those rows would show as "not assigned". Add each spelling as its own tag.`]})})]})]}),(0,u.jsxs)(Z,{title:`Defaults`,styles:{body:{paddingTop:8}},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:8},children:`Set a field only when the payload doesn't already carry a non-blank value — status defaults, empty arrays.`}),(0,u.jsx)(KE,{rows:YE(h.defaults),onChange:e=>P(`defaults`,XE(e)),keyPlaceholder:`internalSubmissionStatus.internalSubmissionStatusText`,valuePlaceholder:`"Under Evaluation"`})]}),(0,u.jsx)(nD,{icon:(0,u.jsx)(l.ApartmentOutlined,{}),title:`Hierarchy Expansions`,description:`Walk the reporting chain up (toward admin) or down (toward a team) from a seed user, publishing the result as {{hierarchy.<name>}} for Related Updates / Notify to use.`,rules:h.hierarchyExpands??[],columns:H,onAdd:()=>A({index:null,rule:null}),onEdit:(e,t)=>A({index:e,rule:t}),onDelete:e=>P(`hierarchyExpands`,(h.hierarchyExpands??[]).filter((t,n)=>n!==e))}),(0,u.jsx)(nD,{icon:(0,u.jsx)(l.ThunderboltOutlined,{}),title:`Related Updates`,description:`Best-effort side-effect writes to other collections after a successful insert — board state, activity logs. Combine with ForEach + a Hierarchy Expansion to seed one document per user in a chain.`,rules:h.relatedUpdates??[],columns:ee,onAdd:()=>M({index:null,rule:null}),onEdit:(e,t)=>M({index:e,rule:t}),onDelete:e=>P(`relatedUpdates`,(h.relatedUpdates??[]).filter((t,n)=>n!==e))}),(0,u.jsxs)(Z,{title:`Notify`,styles:{body:{paddingTop:8}},children:[(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:10},children:[(0,u.jsx)(c.Switch,{size:`small`,checked:!!h.notify,onChange:e=>P(`notify`,e?{action:``,subjectDefault:``,bodyDefault:``,toReportingManager:!1,toHierarchy:``}:null)}),(0,u.jsx)($,{style:{fontSize:13},children:`Send a best-effort email after a successful insert`})]}),h.notify&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Action (matched against an EmailTemplates doc)`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`internalSubmit`,value:h.notify.action??``,onChange:e=>P(`notify`,{...h.notify,action:e.target.value}),className:`fg-mono-input`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Notify entire hierarchy chain`}),(0,u.jsx)(c.Select,{size:`small`,style:{width:`100%`},allowClear:!0,placeholder:`pick a Hierarchy Expansion`,value:h.notify.toHierarchy||void 0,onChange:e=>P(`notify`,{...h.notify,toHierarchy:e??``}),options:N.map(e=>({value:e,label:e}))})]})]}),(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:12},children:[(0,u.jsx)(c.Switch,{size:`small`,checked:!!h.notify.toReportingManager,onChange:e=>P(`notify`,{...h.notify,toReportingManager:e})}),(0,u.jsx)($,{style:{fontSize:13},children:`Also notify the caller's direct reporting manager`})]}),(0,u.jsxs)(`div`,{style:{marginTop:12},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Default subject`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`New submission`,value:h.notify.subjectDefault??``,onChange:e=>P(`notify`,{...h.notify,subjectDefault:e.target.value})})]}),(0,u.jsxs)(`div`,{style:{marginTop:12},children:[(0,u.jsx)($,{type:`secondary`,style:{fontSize:12},children:`Default body (used when no EmailTemplates doc matches)`}),(0,u.jsx)(c.Input.TextArea,{rows:4,value:h.notify.bodyDefault??``,onChange:e=>P(`notify`,{...h.notify,bodyDefault:e.target.value}),className:`fg-mono-input`})]})]})]}),(0,u.jsxs)(Z,{title:`Cache Invalidate`,styles:{body:{paddingTop:8}},children:[(0,u.jsxs)($,{type:`secondary`,style:{fontSize:12,display:`block`,marginBottom:8},children:[`Redis key patterns (with `,`{{field}}`,` tokens) to SCAN+DEL after a successful insert.`]}),(0,u.jsx)(c.Select,{mode:`tags`,style:{width:`100%`},placeholder:`jobs:{{tenantId}}:{{businessId}}:{{businessUnitId}}:*`,value:h.cacheInvalidate??[],onChange:e=>P(`cacheInvalidate`,e)})]})]})]})}),(0,u.jsx)(ZE,{open:!!C,rule:C?.rule,onClose:()=>w(null),onSave:e=>{P(`denormalizations`,C.index===null?[...h.denormalizations??[],e]:(h.denormalizations??[]).map((t,n)=>n===C.index?e:t)),w(null)}},C?`denorm-${C.index??`new`}`:`denorm-closed`),(0,u.jsx)(QE,{open:!!T,rule:T?.rule,onClose:()=>E(null),onSave:e=>{P(`arrayEnrichments`,T.index===null?[...h.arrayEnrichments??[],e]:(h.arrayEnrichments??[]).map((t,n)=>n===T.index?e:t)),E(null)}},T?`enrich-${T.index??`new`}`:`enrich-closed`),(0,u.jsx)($E,{open:!!D,rule:D?.rule,onClose:()=>O(null),onSave:e=>{P(`fileFieldMaps`,D.index===null?[...h.fileFieldMaps??[],e]:(h.fileFieldMaps??[]).map((t,n)=>n===D.index?e:t)),O(null)}},D?`filemap-${D.index??`new`}`:`filemap-closed`),(0,u.jsx)(eD,{open:!!k,rule:k?.rule,onClose:()=>A(null),onSave:e=>{P(`hierarchyExpands`,k.index===null?[...h.hierarchyExpands??[],e]:(h.hierarchyExpands??[]).map((t,n)=>n===k.index?e:t)),A(null)}},k?`hier-${k.index??`new`}`:`hier-closed`),(0,u.jsx)(tD,{open:!!j,rule:j?.rule,hierarchyNames:N,onClose:()=>M(null),onSave:e=>{P(`relatedUpdates`,j.index===null?[...h.relatedUpdates??[],e]:(h.relatedUpdates??[]).map((t,n)=>n===j.index?e:t)),M(null)}},j?`ru-${j.index??`new`}`:`ru-closed`)]})}var{Text:aD}=c.Typography,oD=[`beforeCreate`,`afterCreate`,`beforeUpdate`,`afterUpdate`,`beforeDelete`,`afterDelete`],sD=[`sanitizeFields`,`generateSequence`,`duplicateCheck`,`copyFields`,`arrayEnrich`,`setDefaults`,`resolve`,`updateRelated`,`notify`,`invalidateCache`,`webhook`,`linkDocuments`,`captureFileUrls`,`normalizeStatus`,`recomputeFulfilment`,`syncAssignmentRows`],cD={linkDocuments:{text:`Share one record’s uploaded files with another, without making a second copy. Used so a submission shows the candidate’s résumé and paperwork, and anything uploaded during the submission appears on the candidate too. Both records get the list of document ids written onto them.`,sample:{sourceModule:`candidates`,sourceIdField:`applicantId`,targetModule:`submissions`,linkField:`documentIds`,fieldNames:[],backLink:!0}},captureFileUrls:{text:`File a document that was generated elsewhere and handed to us as a link — a formatted résumé or an attestation PDF — so it sits with every other attachment instead of being a loose field on the record.`,sample:{linkField:`documentIds`,files:[{urlField:`resumeUrl`,nameField:`resumeFileName`,fieldName:`formattedResume`,defaultName:`Formatted Resume.pdf`},{urlField:`attestationUrl`,nameField:`attestationFileName`,fieldName:`attestation`,defaultName:`Attestation.pdf`}]}},normalizeStatus:{text:`Keep a status field inside an agreed list. Use on Before Create / Before Update. Any spelling is folded onto the list (“in-active” becomes “In Active”), old values can be mapped with aliases, and anything else is refused with a message. Values outside “userSelectable” are set by the system and cannot be chosen by a person.`,sample:{field:`jobRecruitmentStatus`,allowed:[`Active`,`In Active`,`Partially Fulfilled`,`On Hold`,`Fulfilled`],userSelectable:[`Active`,`In Active`,`On Hold`],aliases:{unread:`Active`,unassigned:`Active`,cancelled:`In Active`,paused:`On Hold`},derive:{field:`jobStatus`,inactiveValues:[`In Active`,`On Hold`],activeValue:`active`,inactiveValue:`inactive`,keepValues:[`drafts`]}}},recomputeFulfilment:{text:`Recount a job’s submissions against its target and set its status: none → Active, some → Partially Fulfilled, target reached → Fulfilled. In Active and On Hold jobs are left alone. Use on After events of the job itself (jobIdFrom “_id”) or of a record that links to a job (jobIdFrom “jobId”).`,sample:{jobIdFrom:`jobId`,overrides:{}}},syncAssignmentRows:{text:`Keep one row per person for everyone in the assignees’ reporting chain. Assigning someone adds rows for them and their managers; removing someone removes only the rows no remaining assignee still needs, so a shared manager stays. Removing everyone removes every per-person row. Rows that already hold candidates can be protected. The Jobs Assign popup uses this same configuration.`,sample:{seedField:`recruitersData`,storedSeedField:`recruiters.recruiterId`,chain:{direction:`up`,stopRole:5,includeSeed:!0},membershipField:`assignedUserIds`,rows:[{collection:`workflow_instances`,entityField:`entityId`,userField:`recruiterId`,match:{entityType:`Job`,workflowType:`HiringPipeline`,module:`jobs`},keepUserValues:[0],identityKey:`{{tenantId}}|{{businessId}}|{{businessUnitId}}|jobs|hiringpipeline|job|{{entityId}}|{{userId}}`,deleteMode:`soft`,insert:{module:`jobs`,entityType:`Job`,workflowType:`HiringPipeline`,currentStage:`pipeline`,reportingId:`{{reportingId}}`,teamId:`{{teamId}}`,createdDt:`{{now}}`,updatedDt:`{{now}}`}}]}}};function lD(e){return JSON.stringify(e??{},null,2)}function uD({action:e,onChange:t,onRemove:n}){let[r,i]=(0,s.useState)(()=>lD(e.config)),[a,o]=(0,s.useState)(!1);return(0,u.jsxs)(`div`,{style:{border:`1px solid #e2e8f0`,borderRadius:8,padding:10,marginTop:8},children:[(0,u.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`},children:[(0,u.jsx)(c.Select,{size:`small`,style:{width:200},showSearch:!0,value:e.type||void 0,placeholder:`action type`,options:sD.map(e=>({value:e})),onChange:n=>{let r=e.config&&Object.keys(e.config).length>0,i=cD[n]?.sample;t(r||!i?{...e,type:n}:{...e,type:n,config:i})}}),a&&(0,u.jsx)(c.Tag,{color:`red`,children:`invalid JSON`}),(0,u.jsx)(c.Button,{size:`small`,type:`text`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{}),style:{marginLeft:`auto`},onClick:n})]}),cD[e.type]&&(0,u.jsx)(`p`,{style:{margin:`8px 0 0`,fontSize:12,color:`#64748b`,lineHeight:1.5},children:cD[e.type].text}),(0,u.jsx)(c.Input.TextArea,{rows:Math.min(14,Math.max(3,r.split(`
|
|
7
|
-
`).length)),value:r,className:`fg-mono-input`,style:{marginTop:8,fontSize:12},onChange:n=>{i(n.target.value);try{t({...e,config:JSON.parse(n.target.value||`{}`)}),o(!1)}catch{o(!0)}}})]})}function dD({open:e,doc:t,moduleOptions:n,onClose:r,onSave:i}){let[a,o]=(0,s.useState)(()=>({key:``,module:``,event:`afterCreate`,order:10,isActive:!0,condition:{},actions:[],...t??{}})),[d,f]=(0,s.useState)(()=>lD(t?.condition)),[p,m]=(0,s.useState)(!1),h=(e,t)=>o(n=>({...n,[e]:t}));return(0,u.jsx)(c.Modal,{open:e,onCancel:r,width:840,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,u.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,u.jsx)(l.ApartmentOutlined,{}),` `,t?`Edit Workflow`:`New Workflow`]}),footer:(0,u.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,u.jsx)(c.Button,{onClick:r,children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.SaveOutlined,{}),onClick:()=>{if(!a.key?.trim())return c.message.error(`Key is required`);if(!a.module?.trim())return c.message.error(`Module is required`);if(p)return c.message.error(`Condition JSON is invalid`);if(!(a.actions??[]).length)return c.message.error(`At least one action is required`);if((a.actions??[]).some(e=>!e.type))return c.message.error(`Every action needs a type`);let e={...a};delete e.id,delete e._id,i(e)},children:`Save Workflow`})]}),children:(0,u.jsxs)(`div`,{className:`fg-form-section`,children:[(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(aD,{type:`secondary`,style:{fontSize:12},children:`Key`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`jobs-create-after`,value:a.key??``,onChange:e=>h(`key`,e.target.value),className:`fg-mono-input`,disabled:!!t})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(aD,{type:`secondary`,style:{fontSize:12},children:`Module`}),(0,u.jsx)(c.Select,{size:`small`,style:{width:`100%`},showSearch:!0,value:a.module||void 0,options:n,onChange:e=>h(`module`,e),placeholder:`jobs`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(aD,{type:`secondary`,style:{fontSize:12},children:`Event`}),(0,u.jsx)(c.Select,{size:`small`,style:{width:`100%`},value:a.event,options:oD.map(e=>({value:e})),onChange:e=>h(`event`,e)})]}),(0,u.jsxs)(`div`,{style:{width:90},children:[(0,u.jsx)(aD,{type:`secondary`,style:{fontSize:12},children:`Order`}),(0,u.jsx)(c.InputNumber,{size:`small`,style:{width:`100%`},value:a.order??10,onChange:e=>h(`order`,e??10)})]})]}),(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:12},children:[(0,u.jsx)(c.Switch,{size:`small`,checked:a.isActive!==!1,onChange:e=>h(`isActive`,e)}),(0,u.jsx)(aD,{style:{fontSize:13},children:`Active`})]}),(0,u.jsxs)(`div`,{style:{marginTop:12},children:[(0,u.jsxs)(aD,{type:`secondary`,style:{fontSize:12},children:[`Condition (all must match the payload; empty = always run) `,p&&(0,u.jsx)(c.Tag,{color:`red`,children:`invalid JSON`})]}),(0,u.jsx)(c.Input.TextArea,{rows:2,value:d,className:`fg-mono-input`,style:{fontSize:12},onChange:e=>{f(e.target.value);try{h(`condition`,JSON.parse(e.target.value||`{}`)),m(!1)}catch{m(!0)}}})]}),(0,u.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginTop:14},children:[(0,u.jsx)(aD,{strong:!0,style:{fontSize:13},children:`Actions (run in order)`}),(0,u.jsx)(c.Button,{size:`small`,type:`dashed`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>h(`actions`,[...a.actions??[],{type:``,config:{}}]),children:`Add Action`})]}),(a.actions??[]).map((e,t)=>(0,u.jsx)(uD,{action:e,onChange:e=>h(`actions`,a.actions.map((n,r)=>r===t?e:n)),onRemove:()=>h(`actions`,a.actions.filter((e,n)=>n!==t))},t)),(0,u.jsxs)(aD,{type:`secondary`,style:{fontSize:11,display:`block`,marginTop:8},children:[`Config supports `,(0,u.jsx)(`code`,{children:`{{field.path}}`}),`, `,(0,u.jsx)(`code`,{children:`{{now}}`}),`, `,(0,u.jsx)(`code`,{children:`{{__userId}}`}),`,`,` `,(0,u.jsx)(`code`,{children:`{{__userName}}`}),`, and `,(0,u.jsx)(`code`,{children:`{{hierarchy.<name>}}`}),` from a `,(0,u.jsx)(`code`,{children:`resolve`}),` action.`]})]})})}function fD(){let[e,t]=(0,s.useState)([]),[r,i]=(0,s.useState)([]),[a,o]=(0,s.useState)(!0),[d,f]=(0,s.useState)(``),[p,m]=(0,s.useState)(null),[h,g]=(0,s.useState)(``),[_,v]=(0,s.useState)(0);(0,s.useEffect)(()=>{let e=!1;return n.wi(`workflows`).then(n=>{e||t(n)}).catch(t=>{e||f(t?.message||`Failed to load workflows`)}).finally(()=>{e||o(!1)}),()=>{e=!0}},[_]),(0,s.useEffect)(()=>{n.Xr().then(e=>i(qS(e).map(({value:e,label:t})=>({value:e,label:t})))).catch(()=>i([]))},[]);let y=()=>{o(!0),f(``),v(e=>e+1)};async function b(e){try{await n.Fi(`workflows`,e),c.message.success(`Workflow "${e.key}" saved`),m(null),y()}catch(e){c.message.error(e?.message||`Could not save workflow`)}}async function x(e){try{await n.Rr(`workflows`,e),c.message.success(`Workflow "${e}" deleted`),y()}catch(e){c.message.error(e?.message||`Could not delete workflow`)}}async function S(e,t){let r={...e};delete r.id,delete r._id;try{await n.Fi(`workflows`,{...r,isActive:t}),y()}catch(e){c.message.error(e?.message||`Could not update workflow`)}}let C=(0,s.useMemo)(()=>e.filter(e=>!h||e.module===h),[e,h]);return(0,u.jsxs)(`div`,{className:`fg-section`,children:[(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.ApartmentOutlined,{}),title:`Workflows`,extra:(0,u.jsxs)(c.Space,{size:8,children:[(0,u.jsx)(c.Select,{size:`small`,style:{minWidth:160},allowClear:!0,placeholder:`Filter by module`,options:r,value:h||void 0,onChange:e=>g(e??``)}),(0,u.jsx)(c.Button,{size:`small`,icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:y,children:`Reload`}),(0,u.jsx)(c.Button,{type:`primary`,size:`small`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>m({doc:null}),children:`New Workflow`})]}),children:[(0,u.jsx)(`div`,{className:`admin-accent-bar`}),(0,u.jsxs)(aD,{type:`secondary`,style:{fontSize:13},children:[`Event-driven behavior per module — reference ids, duplicate checks, snapshots, hierarchy fan-outs, board updates, notifications, cache — executed by the platform Workflow Engine on every create/update/delete.`,(0,u.jsx)(c.Tag,{style:{marginLeft:8},children:`before*`}),` actions can block the write; `,(0,u.jsx)(c.Tag,{children:`after*`}),` actions are best-effort.`]})]}),(0,u.jsxs)(Z,{styles:{body:{paddingTop:8}},children:[d&&(0,u.jsx)(c.Alert,{type:`error`,showIcon:!0,message:d,style:{marginBottom:12}}),(0,u.jsxs)(c.Spin,{spinning:a,children:[(0,u.jsxs)(`div`,{style:{marginBottom:8},children:[(0,u.jsx)(c.Badge,{count:C.length,showZero:!0,color:`var(--color-brand)`}),` `,(0,u.jsx)(aD,{type:`secondary`,style:{fontSize:12},children:`workflows`})]}),(0,u.jsx)(c.Table,{rowKey:`key`,dataSource:C,columns:[{title:`Key`,dataIndex:`key`,key:`key`,render:e=>(0,u.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Module`,dataIndex:`module`,key:`module`,width:130,render:e=>(0,u.jsx)(c.Tag,{color:`geekblue`,children:e})},{title:`Event`,dataIndex:`event`,key:`event`,width:130,render:e=>(0,u.jsx)(c.Tag,{color:String(e).startsWith(`before`)?`purple`:`green`,children:e})},{title:`Actions`,key:`acts`,render:(e,t)=>(0,u.jsx)(c.Space,{size:4,wrap:!0,children:(t.actions??[]).map((e,t)=>(0,u.jsx)(c.Tag,{style:{margin:0},children:e.type},t))})},{title:`Order`,dataIndex:`order`,key:`order`,width:70,align:`center`},{title:`Active`,key:`active`,width:80,align:`center`,render:(e,t)=>(0,u.jsx)(c.Switch,{size:`small`,checked:t.isActive!==!1,onChange:e=>S(t,e)})},{title:``,key:`ops`,width:90,align:`right`,render:(e,t)=>(0,u.jsxs)(c.Space,{size:4,children:[(0,u.jsx)(c.Tooltip,{title:`Edit`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>m({doc:t})})}),(0,u.jsx)(c.Popconfirm,{title:`Delete workflow "${t.key}"?`,onConfirm:()=>x(t.key),children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{})})})]})}],pagination:!1,size:`small`,className:`fg-table`,locale:{emptyText:(0,u.jsx)(c.Empty,{description:`No workflows configured.`,image:c.Empty.PRESENTED_IMAGE_SIMPLE})}})]})]}),(0,u.jsx)(dD,{open:!!p,doc:p?.doc,moduleOptions:r,onClose:()=>m(null),onSave:b},p?p.doc?.key??`new`:`closed`)]})}var{Text:pD}=c.Typography,mD=e=>e?._id??e?.id,hD=`masters`;function gD(){return{tenantId:localStorage.getItem(`tenantId`)||``,businessId:localStorage.getItem(`businessId`)||``,businessUnitId:localStorage.getItem(`businessUnitId`)||``}}function _D(e){return e&&typeof e==`object`?e.$oid??e.oid??e.id??``:e??``}function vD(e,t){return t.map(t=>_D(e?.[t])).find(e=>e!=null&&e!==``)??``}function yD(e,t){return[[t.tenantId,[`tid`,`tenantId`]],[t.businessId,[`bid`,`businessId`]],[t.businessUnitId,[`buid`,`businessUnitId`]]].every(([t,n])=>{if(!t)return!0;let r=String(vD(e,n));return!r||r===String(t)})}function bD(e){return Array.isArray(e?.masterFeeds)?e.masterFeeds:[]}function xD(e){return e.reduce((e,t)=>Math.max(e,Number(t?.uniqueId)||0),0)+1}function SD(e){return Array.isArray(e?.taxHistory)?e.taxHistory:[]}function CD(e){let t=e?.taxValue;if(t!=null&&t!==``)return Number(t);let n=SD(e).at(-1),r=n?.taxValue??n?.value;return r!=null&&r!==``?Number(r):void 0}function wD(e){if(!e)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(t)}function TD(e){let t=SD(e).at(-1);return t?.updatedAt??t?.timestamp??e?.updatedAt}function ED({open:e,record:t,onClose:r,onSaved:i}){let[a]=c.Form.useForm(),[o,l]=(0,s.useState)(!1),[d,f]=(0,s.useState)([]),[p,m]=(0,s.useState)(!1),h=(0,s.useRef)(null),g=!!t;(0,s.useEffect)(()=>{e&&queueMicrotask(()=>{a.resetFields(),a.setFieldsValue({name:t?.name??void 0,taxValue:CD(t)}),f(t?.name?[{label:t.name,value:t.name}]:[])})},[e,t,a]);function _(e){if(h.current&&clearTimeout(h.current),!e||e.trim().length<2){f([]);return}m(!0),h.current=setTimeout(()=>{n.si(e.trim()).then(f).catch(()=>f([])).finally(()=>m(!1))},350)}async function v(){let e=await a.validateFields(),r=Number(e.taxValue),o={name:e.name,taxValue:r,taxHistory:{taxValue:r}};l(!0);try{g?await n.Gi(`locations`,mD(t),o):await n.Or(`locations`,o),c.message.success(g?`Tax updated`:`Location and tax created`),i()}catch(e){c.message.error(e?.message||`Could not save location and tax`)}finally{l(!1)}}return(0,u.jsx)(c.Modal,{open:e,onCancel:r,onOk:v,confirmLoading:o,destroyOnHidden:!0,title:g?`Edit Tax — ${t?.name??``}`:`New Location`,children:(0,u.jsxs)(c.Form,{form:a,layout:`vertical`,children:[(0,u.jsx)(c.Form.Item,{name:`name`,label:`Location`,rules:[{required:!0,message:`Location is required`}],tooltip:g?`Location cannot be changed once created — only the tax is editable.`:`Search and pick from the location master.`,children:(0,u.jsx)(c.Select,{showSearch:!0,disabled:g,placeholder:`Type at least 2 characters to search…`,filterOption:!1,onSearch:_,notFoundContent:p?`Searching…`:null,options:d})}),(0,u.jsx)(c.Form.Item,{name:`taxValue`,label:`Tax`,rules:[{required:!0,message:`Tax is required`},{type:`number`,min:0,max:100,message:`Tax must be between 0 and 100`}],children:(0,u.jsx)(c.InputNumber,{style:{width:`100%`},min:0,max:100,step:.01,suffix:`%`,placeholder:`8.875`,autoFocus:g})})]})})}function DD({record:e}){let t=[...SD(e)].reverse();return t.length?(0,u.jsx)(c.Space,{direction:`vertical`,size:4,style:{padding:`4px 8px`},children:t.map((e,t)=>(0,u.jsxs)(c.Space,{size:10,children:[(0,u.jsxs)(c.Tag,{color:t===0?`green`:`default`,style:{margin:0},children:[e.taxValue??e.value,`%`]}),(0,u.jsx)(pD,{type:`secondary`,style:{fontSize:12},children:wD(e.updatedAt??e.timestamp)}),t===0&&(0,u.jsx)(pD,{type:`secondary`,style:{fontSize:12},children:`(current)`})]},t))}):(0,u.jsx)(c.Empty,{image:c.Empty.PRESENTED_IMAGE_SIMPLE,description:`No tax history yet`})}function OD(){let[e,t]=(0,s.useState)([]),[r,i]=(0,s.useState)(!1),[a,o]=(0,s.useState)(!1),[d,f]=(0,s.useState)(null);function p(){i(!0),n.Ci(`locations`).then(({items:e})=>t(e)).catch(e=>c.message.error(e?.message||`Could not load locations`)).finally(()=>i(!1))}(0,s.useEffect)(()=>{queueMicrotask(p)},[]);async function m(e){try{await n.Lr(`locations`,e),c.message.success(`Location deleted`),p()}catch(e){c.message.error(e?.message||`Could not delete location`)}}return(0,u.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,u.jsx)(Z,{title:`${e.length} location${e.length===1?``:`s`}`,extra:(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:p,children:`Reload`}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>{f(null),o(!0)},children:`New location`})]}),children:(0,u.jsx)(c.Table,{rowKey:mD,columns:[{title:`Location`,dataIndex:`name`,key:`name`},{title:`Tax`,key:`taxValue`,width:100,render:(e,t)=>{let n=CD(t);return Number.isFinite(n)?(0,u.jsxs)(c.Tag,{color:`blue`,children:[n,`%`]}):`—`}},{title:`Tax updated`,key:`taxUpdatedAt`,render:(e,t)=>wD(TD(t))},{title:`Created`,key:`createdAt`,responsive:[`lg`],render:(e,t)=>wD(t?.createdAt)},{title:``,key:`actions`,width:90,render:(e,t)=>(0,u.jsxs)(c.Space,{size:4,children:[(0,u.jsx)(c.Tooltip,{title:`Edit tax`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>{f(t),o(!0)}})}),(0,u.jsx)(c.Popconfirm,{title:`Delete this location?`,onConfirm:()=>m(mD(t)),children:(0,u.jsx)(c.Tooltip,{title:`Delete`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{})})})})]})}],dataSource:e,loading:r,size:`small`,pagination:!1,className:`fg-table`,expandable:{expandedRowRender:e=>(0,u.jsx)(DD,{record:e}),rowExpandable:e=>SD(e).length>0},locale:{emptyText:`No locations yet. Click "New location" to add one.`}})}),(0,u.jsx)(ED,{open:a,record:d,onClose:()=>o(!1),onSaved:()=>{o(!1),p()}})]})}function kD({open:e,record:t,onClose:r,onSaved:i}){let[a]=c.Form.useForm(),[o,d]=(0,s.useState)(!1),f=!!t,p=c.Form.useWatch(`masterName`,a),m=c.Form.useWatch(`masterFeeds`,a)??[],h=[`clientsubmissionstatus`,`clientsubmission`,`clientsubmissions`].includes(String(p??t?.masterName??``).trim().toLowerCase()),g=m.map(e=>({label:String(e?.name??``).trim()||`Status ${e?.uniqueId??``}`,value:Number(e?.uniqueId)})).filter(e=>Number.isInteger(e.value)&&e.value>0);function _(e,t){if(!t){a.setFieldValue([`masterFeeds`,e,`isInitialStatus`],!1);return}(a.getFieldValue(`masterFeeds`)??[]).forEach((t,n)=>{a.setFieldValue([`masterFeeds`,n,`isInitialStatus`],n===e)})}function v(e,t){a.setFieldValue([`masterFeeds`,e,`isTerminalStatus`],t),t&&a.setFieldValue([`masterFeeds`,e,`allowedNextStatusIds`],[])}(0,s.useEffect)(()=>{e&&queueMicrotask(()=>{a.resetFields();let e=t?.masterName??``,n=[`clientsubmissionstatus`,`clientsubmission`,`clientsubmissions`].includes(String(e).trim().toLowerCase()),r=bD(t),i=r.length?r.map(e=>({...e})):[{uniqueId:1,name:``,type:`neutral`,status:!0,isdeleted:!1}];if(n&&!i.some(e=>e?.status!==!1&&e?.isdeleted!==!0&&e?.isInitialStatus===!0)){let e=i.findIndex(e=>e?.status!==!1&&e?.isdeleted!==!0);e>=0&&(i=i.map((t,n)=>({...t,isInitialStatus:n===e,isTerminalStatus:t?.isTerminalStatus===!0,allowedNextStatusIds:Array.isArray(t?.allowedNextStatusIds)?t.allowedNextStatusIds:[]})))}a.setFieldsValue({masterName:e,schemaVersion:t?.schemaVersion??1,masterFeeds:i})})},[e,t,a]),(0,s.useEffect)(()=>{!e||!h||(Number(a.getFieldValue(`schemaVersion`))||1)<2&&a.setFieldValue(`schemaVersion`,2)},[e,h,a]);async function y(){let e=await a.validateFields(),r=gD(),o=[`clientsubmissionstatus`,`clientsubmission`,`clientsubmissions`].includes(String(e.masterName??``).trim().toLowerCase()),s=(e.masterFeeds??[]).map((e,t)=>{let n=Number(e.uniqueId)||t+1,r=o&&e.isTerminalStatus===!0,i=o&&!r?[...new Set((e.allowedNextStatusIds??[]).map(Number).filter(e=>Number.isInteger(e)&&e>0&&e!==n))]:[];return{uniqueId:n,name:String(e.name??``).trim(),type:String(e.type??``).trim(),status:e.status!==!1,...o?{isInitialStatus:e.isInitialStatus===!0,isTerminalStatus:r,allowedNextStatusIds:i}:{},isdeleted:e.isdeleted===!0}}).filter(e=>e.name);if(o){let e=s.filter(e=>e.status&&!e.isdeleted&&e.isInitialStatus);if(e.length===0){let t=s.findIndex(e=>e.status&&!e.isdeleted);t>=0&&(s[t]={...s[t],isInitialStatus:!0},e=[s[t]],a.setFieldValue([`masterFeeds`,t,`isInitialStatus`],!0))}if(e.length!==1){c.message.error(`Client Submission Status must have exactly one active Initial Status.`);return}}let l={...r,tid:r.tenantId,bid:r.businessId,buid:r.businessUnitId,schemaVersion:o?Math.max(2,Number(e.schemaVersion)||2):Number(e.schemaVersion)||1,masterName:e.masterName.trim(),masterFeeds:s};d(!0);try{f?await n.Gi(hD,mD(t),l):await n.Or(hD,l),c.message.success(f?`Master value updated`:`Master value created`),i()}catch(e){c.message.error(e?.message||`Could not save master value`)}finally{d(!1)}}return(0,u.jsx)(c.Modal,{open:e,onCancel:r,onOk:y,confirmLoading:o,destroyOnHidden:!0,title:f?`Edit Master Feed`:`New Master Feed`,width:1040,children:(0,u.jsxs)(c.Form,{form:a,layout:`vertical`,children:[(0,u.jsx)(c.Form.Item,{name:`masterName`,label:`Master Name`,rules:[{required:!0,message:`Master name is required`}],children:(0,u.jsx)(c.Input,{placeholder:`blacklistType`,autoFocus:!f,disabled:f})}),(0,u.jsx)(c.Form.Item,{name:`schemaVersion`,label:`Schema Version`,children:(0,u.jsx)(c.InputNumber,{min:1,style:{width:`100%`}})}),(0,u.jsx)(c.Form.List,{name:`masterFeeds`,children:(e,{add:t,remove:n})=>(0,u.jsxs)(c.Space,{direction:`vertical`,style:{width:`100%`},size:10,children:[e.map(({key:e,name:t})=>(0,u.jsxs)(c.Space,{align:`baseline`,wrap:!0,children:[(0,u.jsx)(c.Form.Item,{name:[t,`uniqueId`],label:`ID`,rules:[{required:!0,message:`ID required`}],children:(0,u.jsx)(c.InputNumber,{min:1,style:{width:90}})}),(0,u.jsx)(c.Form.Item,{name:[t,`name`],label:`Name`,rules:[{required:!0,message:`Name required`}],children:(0,u.jsx)(c.Input,{placeholder:`Dropdown label`,style:{width:280}})}),(0,u.jsx)(c.Form.Item,{name:[t,`type`],label:`Type`,children:(0,u.jsx)(c.Select,{allowClear:!0,placeholder:`Select type`,style:{width:120},options:[{label:`Positive`,value:`positive`},{label:`Neutral`,value:`neutral`},{label:`Negative`,value:`negative`}]})}),(0,u.jsx)(c.Form.Item,{name:[t,`status`],label:`Status`,initialValue:!0,children:(0,u.jsx)(c.Select,{style:{width:110},options:[{label:`Active`,value:!0},{label:`Inactive`,value:!1}]})}),(0,u.jsx)(c.Form.Item,{name:[t,`isdeleted`],label:`Deleted`,initialValue:!1,children:(0,u.jsx)(c.Select,{style:{width:110},options:[{label:`No`,value:!1},{label:`Yes`,value:!0}]})}),h&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Form.Item,{name:[t,`isInitialStatus`],label:`Initial`,initialValue:!1,tooltip:`The initial status is the only option shown before a candidate has a client submission status. Only one active initial status is allowed.`,children:(0,u.jsx)(c.Select,{style:{width:100},onChange:e=>_(t,e===!0),options:[{label:`Yes`,value:!0},{label:`No`,value:!1}]})}),(0,u.jsx)(c.Form.Item,{name:[t,`isTerminalStatus`],label:`End Status`,initialValue:!1,tooltip:`End Status stops the configured client submission flow. Once reached, Change Status is hidden and no next statuses are allowed.`,children:(0,u.jsx)(c.Select,{style:{width:105},onChange:e=>v(t,e===!0),options:[{label:`Yes`,value:!0},{label:`No`,value:!1}]})}),(0,u.jsx)(c.Form.Item,{noStyle:!0,shouldUpdate:(e,n)=>e?.masterFeeds?.[t]?.isTerminalStatus!==n?.masterFeeds?.[t]?.isTerminalStatus||e?.masterFeeds?.[t]?.uniqueId!==n?.masterFeeds?.[t]?.uniqueId||e?.masterFeeds!==n?.masterFeeds,children:({getFieldValue:e})=>{let n=e([`masterFeeds`,t,`isTerminalStatus`])===!0,r=Number(e([`masterFeeds`,t,`uniqueId`]));return(0,u.jsx)(c.Form.Item,{name:[t,`allowedNextStatusIds`],label:`Allowed Next Statuses`,tooltip:n?`End Status cannot move to another status.`:`Only these statuses will appear after the current status is saved.`,children:(0,u.jsx)(c.Select,{mode:`multiple`,allowClear:!0,disabled:n,placeholder:n?`End status`:`Select next statuses`,style:{minWidth:280},options:g.filter(e=>e.value!==r)})})}})]}),(0,u.jsx)(c.Tooltip,{title:`Remove row`,children:(0,u.jsx)(c.Button,{type:`text`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{}),onClick:()=>n(t)})})]},e)),(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>t({uniqueId:xD(a.getFieldValue(`masterFeeds`)??[]),name:``,type:`neutral`,status:!0,isdeleted:!1,...h?{isInitialStatus:!1,isTerminalStatus:!1,allowedNextStatusIds:[]}:{}}),children:`Add feed value`})]})})]})})}function AD(){let[e,t]=(0,s.useState)([]),[r,i]=(0,s.useState)(!1),[a,o]=(0,s.useState)(!1),[d,f]=(0,s.useState)(null),[p,m]=(0,s.useState)(``);function h(){let e=gD();i(!0),n.Ci(hD,{limit:500}).then(({items:n})=>{let r=n.filter(t=>yD(t,e));t(r)}).catch(e=>c.message.error(e?.message||`Could not load master values`)).finally(()=>i(!1))}(0,s.useEffect)(()=>{queueMicrotask(h)},[]);async function g(e){try{await n.Lr(hD,e),c.message.success(`Master value deleted`),h()}catch(e){c.message.error(e?.message||`Could not delete master value`)}}let _=p?e.filter(e=>String(e?.masterName??``).toLowerCase()===p.toLowerCase()):e,v=[...new Set(e.map(e=>e?.masterName).filter(Boolean))].sort((e,t)=>String(e).localeCompare(String(t))).map(e=>({label:e,value:e}));return(0,u.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,u.jsx)(Z,{title:`${_.length} master${_.length===1?``:`s`}`,extra:(0,u.jsxs)(c.Space,{wrap:!0,children:[(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,placeholder:`Filter master name`,value:p||void 0,options:v,onChange:e=>m(e??``),style:{minWidth:220}}),(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:h,children:`Reload`}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>{f(null),o(!0)},children:`New master`})]}),children:(0,u.jsx)(c.Table,{rowKey:mD,columns:[{title:`Master Name`,dataIndex:`masterName`,key:`masterName`,width:180},{title:`Feed Values`,key:`masterFeeds`,render:(e,t)=>(0,u.jsx)(c.Space,{wrap:!0,children:bD(t).filter(e=>!e.isdeleted).map(e=>(0,u.jsx)(c.Tag,{color:e.status===!1?`default`:`blue`,children:e.name},e.uniqueId??e.name))})},{title:`Count`,key:`count`,width:90,render:(e,t)=>bD(t).filter(e=>!e.isdeleted).length},{title:`Updated`,key:`updatedAt`,responsive:[`lg`],render:(e,t)=>wD(t?.updatedAt)},{title:``,key:`actions`,width:90,render:(e,t)=>(0,u.jsxs)(c.Space,{size:4,children:[(0,u.jsx)(c.Tooltip,{title:`Edit`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>{f(t),o(!0)}})}),(0,u.jsx)(c.Popconfirm,{title:`Delete this master?`,onConfirm:()=>g(mD(t)),children:(0,u.jsx)(c.Tooltip,{title:`Delete`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{})})})})]})}],dataSource:_,loading:r,size:`small`,pagination:{pageSize:10,showSizeChanger:!0},className:`fg-table`,locale:{emptyText:`No masters yet. Click "New master" to add one.`}})}),(0,u.jsx)(kD,{open:a,record:d,onClose:()=>o(!1),onSaved:()=>{o(!1),h()}})]})}function jD(){return(0,u.jsxs)(`div`,{className:`fg-section`,children:[(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.DatabaseOutlined,{}),title:`Master Collections`,children:[(0,u.jsx)(`div`,{className:`admin-accent-bar`}),(0,u.jsx)(pD,{type:`secondary`,style:{fontSize:13},children:`Create, update, and delete master documents, then customize multiple dropdown values inside masterFeeds. Records are saved with the current tenant, business, business unit, and master name.`})]}),(0,u.jsx)(AD,{}),(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.DatabaseOutlined,{}),title:`Location Tax Master`,children:[(0,u.jsx)(`div`,{className:`admin-accent-bar`}),(0,u.jsx)(pD,{type:`secondary`,style:{fontSize:13},children:`Pick a location from the master list and set its tax. Once added, only the tax can be changed — every change is kept in a timeline with its timestamp. Expand a row to see the full tax history.`})]}),(0,u.jsx)(OD,{})]})}var{Text:MD,Title:ND}=c.Typography;function PD(){let[e]=c.Form.useForm(),[t,n]=(0,s.useState)([]),[r,i]=(0,s.useState)(!0),[a,o]=(0,s.useState)(!1),[d,f]=(0,s.useState)(null),[p,m]=(0,s.useState)(!1);async function h(){i(!0);try{n(await gS())}catch(e){c.message.error(e.message||`Unable to load menus`)}finally{i(!1)}}(0,s.useEffect)(()=>{h()},[]);let g=(0,s.useMemo)(()=>t.filter(e=>!d||e.menu_id!==d.menu_id).map(e=>({label:e.menu_name,value:e.menu_id})),[d,t]);function _(){f(null),e.resetFields(),e.setFieldsValue({menu_type:`MENU`,display_order:t.length+1,status:`ACTIVE`}),m(!0)}function v(t){f(t),e.setFieldsValue(t),m(!0)}async function y(e){o(!0);try{d?await vS(d.menu_id,e):await _S(e),c.message.success(d?`Menu updated`:`Menu created`),m(!1),await h()}catch(e){c.message.error(e.message||`Unable to save menu`)}finally{o(!1)}}async function b(e){try{await yS(e),c.message.success(`Menu deleted`),await h()}catch(e){c.message.error(e.message||`Unable to delete menu`)}}return(0,u.jsxs)(`section`,{className:`admin-section`,children:[(0,u.jsxs)(`div`,{className:`admin-section-head`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(ND,{level:4,children:`Menus`}),(0,u.jsx)(MD,{type:`secondary`,children:`Manage records in the MongoDB menus collection.`})]}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:_,children:`Add Menu`})]}),(0,u.jsx)(c.Table,{rowKey:`menu_id`,loading:r,columns:[{title:`Name`,dataIndex:`menu_name`},{title:`Key`,dataIndex:`menu_key`,render:e=>(0,u.jsx)(c.Tag,{children:e})},{title:`Route / API`,dataIndex:`api_url`},{title:`Type`,dataIndex:`menu_type`,width:110},{title:`Order`,dataIndex:`display_order`,width:80},{title:`Status`,dataIndex:`status`,width:100,render:e=>(0,u.jsx)(c.Tag,{color:e===`ACTIVE`?`green`:`default`,children:e})},{title:``,key:`actions`,width:90,render:(e,t)=>(0,u.jsxs)(c.Space,{size:4,children:[(0,u.jsx)(c.Button,{"aria-label":`Edit menu`,size:`small`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>v(t)}),(0,u.jsx)(c.Popconfirm,{title:`Delete menu?`,onConfirm:()=>b(t.menu_id),children:(0,u.jsx)(c.Button,{"aria-label":`Delete menu`,danger:!0,size:`small`,icon:(0,u.jsx)(l.DeleteOutlined,{})})})]})}],dataSource:t,size:`small`,pagination:{pageSize:10}}),(0,u.jsx)(c.Modal,{title:d?`Edit Menu`:`Add Menu`,open:p,onCancel:()=>m(!1),onOk:()=>e.submit(),confirmLoading:a,destroyOnHidden:!0,children:(0,u.jsxs)(c.Form,{form:e,layout:`vertical`,onFinish:y,children:[(0,u.jsx)(c.Form.Item,{name:`menu_name`,label:`Menu name`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{})}),(0,u.jsx)(c.Form.Item,{name:`menu_key`,label:`Menu key`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{placeholder:`jobs`})}),(0,u.jsx)(c.Form.Item,{name:`api_url`,label:`Route / API URL`,children:(0,u.jsx)(c.Input,{placeholder:`/jobs`})}),(0,u.jsx)(c.Form.Item,{name:`component_name`,label:`Component`,children:(0,u.jsx)(c.Input,{placeholder:`Jobs`})}),(0,u.jsxs)(`div`,{className:`admin-form-row`,children:[(0,u.jsx)(c.Form.Item,{name:`menu_type`,label:`Type`,children:(0,u.jsx)(c.Select,{options:[{value:`MENU`},{value:`FOOTER`},{value:`CHILD`}]})}),(0,u.jsx)(c.Form.Item,{name:`parent_menu_id`,label:`Parent`,children:(0,u.jsx)(c.Select,{allowClear:!0,options:g})})]}),(0,u.jsxs)(`div`,{className:`admin-form-row`,children:[(0,u.jsx)(c.Form.Item,{name:`display_order`,label:`Display order`,children:(0,u.jsx)(c.InputNumber,{min:0})}),(0,u.jsx)(c.Form.Item,{name:`status`,label:`Status`,children:(0,u.jsx)(c.Select,{options:[{value:`ACTIVE`},{value:`INACTIVE`}]})})]}),(0,u.jsx)(c.Form.Item,{name:`icon`,label:`Icon`,children:(0,u.jsx)(c.Input,{placeholder:`AppstoreOutlined`})})]})})]})}var FD=`/admin/global`;function ID(e){let t=e?.data??e;return t&&typeof t==`object`&&`data`in t&&`total`in t?{items:t.data??[],total:t.total??0}:{items:Array.isArray(t)?t:[],total:Array.isArray(t)?t.length:0}}function LD(e={}){let t=new URLSearchParams;Object.entries(e).forEach(([e,n])=>{n!=null&&n!==``&&t.append(e,String(n))});let n=t.toString();return n?`?${n}`:``}function RD(e,t){let n=String(e||``).trim().toLowerCase();if(!n)throw Error(`regionPath: a region key is required`);return`/admin/regions/${encodeURIComponent(n)}${t}`}async function zD({includeInactive:e=!1,signal:n}={}){let r=await t.o(t.x,`${FD}/regions${LD({includeInactive:e||void 0})}`,{signal:n}),i=r?.data??r;return Array.isArray(i)?i:[]}async function BD(e,{allowEmpty:n=!1,signal:r}={}){return t.o(t.x,`${FD}/regions${LD({allowEmpty:n||void 0})}`,{method:`POST`,body:JSON.stringify(e),signal:r})}async function VD(e,{signal:n}={}){return t.o(t.x,`${FD}/regions/${encodeURIComponent(e)}`,{method:`DELETE`,signal:n})}async function HD({signal:e}={}){let n=await t.o(t.x,`${FD}/platform-access`,{signal:e}),r=n?.data??n;return Array.isArray(r)?r:[]}async function UD(e,{signal:n}={}){return t.o(t.x,`${FD}/platform-access`,{method:`POST`,body:JSON.stringify(e),signal:n})}async function WD(e,{signal:n}={}){return t.o(t.x,`${FD}/platform-access/${encodeURIComponent(e)}`,{method:`DELETE`,signal:n})}async function GD({signal:e}={}){try{return await zD({signal:e}),!0}catch(e){if(e?.name===`AbortError`)throw e;return!1}}async function KD({search:e,regionKey:n,limit:r=25,offset:i=0,signal:a}={}){return ID(await t.o(t.x,`${FD}/users${LD({search:e,regionKey:n,limit:r,offset:i})}`,{signal:a}))}async function qD({regionKey:e,action:n,limit:r=50,offset:i=0,signal:a}={}){return ID(await t.o(t.x,`${FD}/audit${LD({regionKey:e,action:n,limit:r,offset:i})}`,{signal:a}))}async function JD(e,{signal:n}={}){let r=await t.o(t.x,RD(e,`/detail-defaults`),{signal:n});return r?.data??r??{}}async function YD(e,n,{signal:r}={}){return t.o(t.x,RD(e,`/detail-defaults`),{method:`POST`,body:JSON.stringify(n),signal:r})}async function XD(e,{signal:n}={}){return ID(await t.o(t.x,RD(e,`/users`),{signal:n}))}async function ZD(e,{signal:n}={}){return ID(await t.o(t.x,RD(e,`/roles`),{signal:n}))}var QD=[{value:`regions.read`,label:`Read regions & config`},{value:`config.write`,label:`Write regional config`},{value:`users.read`,label:`Read users across regions`},{value:`users.write`,label:`Move users / memberships`},{value:`access.admin`,label:`Grant & revoke platform access`}];async function $D({signal:e}={}){let n=await t.o(t.x,`${FD}/defaults`,{signal:e}),r=n?.data??n??{};return{regions:r.regions??[],common:r.common??{}}}async function eO(e,{regionKeys:n,signal:r}={}){return t.o(t.x,`${FD}/defaults`,{method:`PUT`,body:JSON.stringify({values:e,regionKeys:n??[]}),signal:r})}var tO=[{name:`phoneCountryCode`,label:`Phone country code`,placeholder:`+1`,emptyMeans:`Print no dial code at all.`},{name:`phoneFormat`,label:`Phone format`,placeholder:`3-3-4`},{name:`dateFormat`,label:`Date format`,placeholder:`DD MMM YYYY`,help:`Calendar dates only — no time, no zone.`},{name:`dateTimeFormat`,label:`Date & time format`,placeholder:`DD MMM YYYY, hh:mm A`},{name:`timeZone`,label:`Time zone`,placeholder:`Asia/Kolkata`,emptyMeans:`Each viewer sees their own browser's zone.`},{name:`booleanTrueLabel`,label:`Yes label`,placeholder:`Yes`},{name:`booleanFalseLabel`,label:`No label`,placeholder:`No`},{name:`emptyPlaceholder`,label:`Empty placeholder`,placeholder:`-`},{name:`separator`,label:`Separator`,placeholder:` · `},{name:`s3BaseUrl`,label:`S3 base URL`,placeholder:`https://…`},{name:`region`,label:`Region profile`,placeholder:`US / UK / IND`,help:`Key into FormGroup.regionRules. Usually set per region, not globally.`}];async function nO({serviceKey:e=`pyOps`,signal:n}={}){let r=await t.o(t.x,`${FD}/ai-services${LD({serviceKey:e})}`,{signal:n}),i=r?.data??r??{};return{serviceKey:i.serviceKey??e,regions:i.regions??[],missingRegions:i.missingRegions??[],consistent:!!i.consistent}}async function rO(e,{regionKeys:n,signal:r}={}){return t.o(t.x,`${FD}/ai-services`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,regionKeys:n??[]}),signal:r})}var{Text:iO}=c.Typography;function aO({regions:e}){let[t,n]=(0,s.useState)(!0),[r,i]=(0,s.useState)(!1),[a,o]=(0,s.useState)([]),[d,f]=(0,s.useState)({}),[p,m]=(0,s.useState)({}),[h,g]=(0,s.useState)([]),_=(0,s.useRef)(null),v=(0,s.useCallback)(async()=>{_.current?.abort();let e=new AbortController;_.current=e,n(!0);try{let{regions:t,common:n}=await $D({signal:e.signal});o(t),f(n),m({})}catch(e){e?.name!==`AbortError`&&c.message.error(e?.message||`Could not load defaults`)}finally{n(!1)}},[]);(0,s.useEffect)(()=>(queueMicrotask(v),()=>_.current?.abort()),[v]);let y=(0,s.useMemo)(()=>(a.length?a:e).map(e=>e.regionKey||e.key),[a,e]),b=h.length?h:y,x=Object.keys(p),S=async()=>{if(!x.length){c.message.info(`Nothing changed`);return}i(!0);try{await eO(p,{regionKeys:h}),c.message.success(`Updated ${x.length} setting${x.length===1?``:`s`} across ${b.length} region${b.length===1?``:`s`}`),await v()}catch(e){c.message.error(e?.message||`Could not save defaults`)}finally{i(!1)}};if(t)return(0,u.jsx)(`div`,{style:{padding:48,textAlign:`center`},children:(0,u.jsx)(c.Spin,{})});if(!y.length)return(0,u.jsx)(c.Empty,{description:`No active regions. Register regions before setting defaults across them.`});let C=[{title:`Setting`,dataIndex:`label`,key:`label`,width:210,render:(e,t)=>(0,u.jsxs)(c.Space,{direction:`vertical`,size:0,children:[(0,u.jsx)(iO,{strong:!0,children:e}),(0,u.jsx)(iO,{type:`secondary`,style:{fontSize:11},children:t.name})]})},...a.map(e=>({title:e.label?.trim()||e.regionKey,key:e.regionKey,width:150,render:(t,n)=>{if(!Object.prototype.hasOwnProperty.call(e.values||{},n.name))return(0,u.jsx)(c.Tooltip,{title:`Never set for this region — it falls back to the built-in default.`,children:(0,u.jsx)(iO,{type:`secondary`,style:{fontSize:12},children:`not set`})});let r=e.values[n.name];return r===``?(0,u.jsx)(c.Tooltip,{title:n.emptyMeans||`Explicitly set to empty.`,children:(0,u.jsx)(c.Tag,{color:`blue`,children:`empty`})}):(0,u.jsx)(iO,{style:{fontSize:12},children:String(r)})}})),{title:`Set for all`,key:`edit`,width:220,render:(e,t)=>{let n=Object.prototype.hasOwnProperty.call(p,t.name);return(0,u.jsxs)(c.Space,{direction:`vertical`,size:2,style:{width:`100%`},children:[(0,u.jsx)(c.Input,{size:`small`,placeholder:t.placeholder,value:n?p[t.name]:void 0,status:n?`warning`:void 0,onChange:e=>m(n=>({...n,[t.name]:e.target.value}))}),n&&(0,u.jsxs)(c.Space,{size:4,children:[(0,u.jsx)(c.Button,{size:`small`,type:`link`,style:{padding:0,height:18,fontSize:11},onClick:()=>m(e=>{let n={...e};return delete n[t.name],n}),children:`cancel`}),p[t.name]===``&&t.emptyMeans&&(0,u.jsx)(c.Tooltip,{title:t.emptyMeans,children:(0,u.jsx)(c.Tag,{color:`blue`,style:{fontSize:10,margin:0},children:`will save as empty`})})]})]})}}],w=tO.map(e=>({...e,key:e.name})),T=w.filter(e=>!Object.prototype.hasOwnProperty.call(d,e.name)).length;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Alert,{type:`info`,showIcon:!0,icon:(0,u.jsx)(l.GlobalOutlined,{}),style:{marginBottom:12},message:`These settings are written into every region you select`,description:(0,u.jsxs)(u.Fragment,{children:[`They drive how dates, times, phone numbers and empty values render — in forms, detail views and cards alike. Each region keeps its own copy, so you can still override one afterwards.`,T>0&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`br`,{}),(0,u.jsx)(l.WarningOutlined,{style:{color:`#d46b08`}}),` `,(0,u.jsx)(iO,{strong:!0,children:T}),` of `,w.length,` settings are not currently identical across regions — the columns below show what each one holds.`]})]})}),(0,u.jsxs)(c.Space,{style:{marginBottom:12},wrap:!0,children:[(0,u.jsx)(iO,{strong:!0,children:`Apply to:`}),(0,u.jsx)(c.Checkbox,{checked:h.length===0,onChange:e=>g(e.target.checked?[]:y),children:`All regions`}),h.length>0&&(0,u.jsx)(c.Checkbox.Group,{value:h,onChange:g,options:a.map(e=>({label:e.label?.trim()||e.regionKey,value:e.regionKey}))}),(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:v,children:`Refresh`}),(0,u.jsx)(c.Button,{type:`primary`,loading:r,disabled:!x.length,onClick:S,children:x.length?`Save ${x.length} change${x.length===1?``:`s`} to ${b.length} region${b.length===1?``:`s`}`:`Save`})]}),(0,u.jsx)(c.Table,{size:`small`,rowKey:`name`,columns:C,dataSource:w,pagination:!1,scroll:{x:`max-content`}}),(0,u.jsx)(iO,{type:`secondary`,style:{display:`block`,marginTop:12,fontSize:12},children:`Only the rows you edit are sent. Everything else is left exactly as it is, per region.`})]})}var oO=`/v1/integration-feeds`;function sO(e){return e?.data??e??null}async function cO(){return sO(await t.o(t.O,`${oO}/providers`))}async function lO(){return sO(await t.o(t.O,`${oO}/targets`))}async function uO(e){return sO(await t.o(t.O,oO,_O(e)))}async function dO(e,n,r=25){return sO(await t.o(t.O,`${oO}/${encodeURIComponent(e)}/runs?limit=${encodeURIComponent(r)}`,_O(n)))}async function fO(e,n,r){return sO(await t.o(t.O,`${oO}/otp/request`,{..._O(r),method:`POST`,body:JSON.stringify({feedKey:e,action:n})}))}async function pO(e,n,{otp:r,appId:i,config:a,acknowledgeLegacyStopped:o,previewLimit:s}={}){let c={otp:r};return a!==void 0&&(c.config=a),o&&(c.acknowledgeLegacyStopped=!0),s&&(c.previewLimit=s),sO(await t.o(t.O,`${oO}/${encodeURIComponent(e)}/actions/${encodeURIComponent(n)}`,{..._O(i),method:`POST`,body:JSON.stringify(c)}))}async function mO(e,{otp:n,appId:r,values:i,clear:a}={}){return sO(await t.o(t.O,`${oO}/providers/${encodeURIComponent(e)}/credentials`,{..._O(r),method:`POST`,body:JSON.stringify(a?{otp:n,clear:!0}:{otp:n,values:i})}))}async function hO(e,{otp:n,appId:r}={}){return sO(await t.o(t.O,`${oO}/targets/${encodeURIComponent(e)}/unlock`,{..._O(r),method:`POST`,body:JSON.stringify({otp:n})}))}var gO={SAVE:`save`,ENABLE:`enable`,SUSPEND:`suspend`,RUN:`run`,STATUS_SYNC:`statusSync`,PREVIEW:`preview`,DELETE:`delete`,CREDENTIALS:`credentials`,UNLOCK_TARGET:`unlockTarget`};function _O(e){return e?{headers:{"X-App-Id":e}}:{}}var{Text:vO,Paragraph:yO,Title:bO}=c.Typography;function xO(e){let t=String(e||``).trim();return t?`Cron, or "@every 30s" / "@every 10s". This server's minimum is ${t}.`:`Cron, or a duration such as "@every 30s".`}var SO={feedKey:``,label:``,provider:``,importEnabled:!0,importSchedule:`*/5 * * * *`,importPageSize:200,maxPagesPerRun:50,maxCreatesPerRun:100,statusSyncEnabled:!0,statusSyncSchedule:`*/30 * * * *`,statusPageSize:500,maxStatusUpdatesPerRun:500,timezone:`UTC`,notifyOnCreate:!0,statusMapping:{},rules:[]},CO=[{value:`startsWith`,label:`starts with`},{value:`equals`,label:`is exactly`},{value:`contains`,label:`contains`},{value:`any`,label:`anything else (catch-all)`}];function wO(e){let t={succeeded:`green`,partial:`orange`,failed:`red`,skipped:`default`}[e]||`default`;return(0,u.jsx)(c.Tag,{color:t,children:e||`—`})}function TO(e){if(!e)return`never`;let t=new Date(e);return Number.isNaN(t.getTime())||t.getUTCFullYear()<=1?`never`:t.toLocaleString()}function EO(e){return e.requiresApproval?`🔒 ${e.database} (app id: ${e.appId}) — needs approval`:e.usable?`${e.database} (app id: ${e.appId}${e.source?` · ${e.source}`:``})`:`${e.appId} — unavailable: ${e.problem}`}function DO({label:e,children:t}){return(0,u.jsxs)(`div`,{style:{minWidth:0},children:[(0,u.jsx)(vO,{type:`secondary`,style:{fontSize:12,display:`block`,textTransform:`uppercase`,letterSpacing:.4},children:e}),(0,u.jsx)(`div`,{style:{fontSize:14,marginTop:2},children:t})]})}function OO(){let[e,t]=(0,s.useState)([]),[n,r]=(0,s.useState)(``),[i,a]=(0,s.useState)([]),[o,d]=(0,s.useState)(``),[f,p]=(0,s.useState)([]),[m,h]=(0,s.useState)({}),[g,_]=(0,s.useState)(!1),[v,y]=(0,s.useState)(``),[b,x]=(0,s.useState)(!1),[S,C]=(0,s.useState)(``),[w,T]=(0,s.useState)(!1),[E,D]=(0,s.useState)(null),[O,k]=(0,s.useState)(null),[A,j]=(0,s.useState)(null),[M,N]=(0,s.useState)(null),P=(0,s.useCallback)(e=>lO().then(n=>{let i=n?.targets||[];if(t(i),x(!!n?.schedulerOn),C(n?.minInterval||``),e){r(e);return}let a=i.find(e=>e.usable);r(e=>e||(a?a.appId:``))}).catch(e=>y(e?.message||`Could not read the available databases`)),[]);(0,s.useEffect)(()=>{let e=!1;return queueMicrotask(()=>{e||P()}),cO().then(t=>{e||(a(t?.providers||[]),d(t?.approver||``))}).catch(()=>{}),()=>{e=!0}},[P]);function F(t){let i=e.find(e=>e.appId===t);if(i){if(i.usable){r(t);return}i.requiresApproval&&z({feedKey:`target:${t}`,action:gO.UNLOCK_TARGET,title:`Unlock ${i.database}`,danger:!0,description:`You are about to work on ${i.database} (app id ${t}). Feeds you run there write jobs into that database. The unlock lasts one hour and is recorded against your name.`,perform:e=>hO(t,{otp:e,appId:n}),onDone:()=>P(t)})}}let I=(0,s.useCallback)(()=>{n&&(_(!0),y(``),uO(n).then(e=>p(e?.feeds||[])).catch(e=>{p([]),y(e?.message||`Could not load the feeds`)}).finally(()=>_(!1)))},[n]);(0,s.useEffect)(()=>{queueMicrotask(I)},[I]);let L=(0,s.useMemo)(()=>e.find(e=>e.appId===n),[e,n]);function R(e){dO(e,n).then(t=>h(n=>({...n,[e]:t?.runs||[]}))).catch(e=>c.message.error(e?.message||`Could not load the run history`))}function z(e){k(e)}function B(){k(null)}async function V(e){let{feedKey:t,action:r,payload:i,perform:a}=O;try{return a?await a(e):await pO(t,r,{otp:e,appId:n,...i||{}})}catch(e){let n=e?.message||``;if(r===gO.ENABLE&&n.includes(`another importer is still filling`))return k(null),j({feedKey:t,reason:n}),null;throw e}}return(0,u.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.CloudDownloadOutlined,{}),title:`Job Feeds`,extra:(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(c.Button,{size:`large`,icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:I,disabled:!n,children:`Reload`}),(0,u.jsx)(c.Button,{size:`large`,type:`primary`,icon:(0,u.jsx)(l.PlusOutlined,{}),disabled:!n||i.length===0,onClick:()=>{D(null),T(!0)},children:`Add Feed`})]}),children:[(0,u.jsx)(`div`,{className:`admin-accent-bar`}),(0,u.jsxs)(yO,{type:`secondary`,style:{marginBottom:16},children:[`Import job requisitions from an external system on a schedule, and keep their statuses in step. Each feed decides which database it writes to and which tenant, client and owner each job gets. Every action is confirmed by a one-time code emailed to `,o||`the registered approver`,`.`]}),(0,u.jsxs)(c.Row,{gutter:[16,16],align:`bottom`,children:[(0,u.jsxs)(c.Col,{xs:24,lg:12,children:[(0,u.jsxs)(vO,{strong:!0,style:{display:`block`,marginBottom:6},children:[(0,u.jsx)(l.DatabaseOutlined,{}),` Target database`]}),(0,u.jsx)(c.Select,{size:`large`,style:{width:`100%`},value:n||void 0,placeholder:`Select the database this feed writes into`,onChange:F,options:e.map(e=>({value:e.appId,disabled:!e.usable&&!e.requiresApproval,label:EO(e)}))}),(0,u.jsxs)(vO,{type:`secondary`,style:{fontSize:12,display:`block`,marginTop:6},children:[(0,u.jsx)(l.LockOutlined,{}),` Databases other than your own are locked. Choosing one asks for a confirmation code, then unlocks it for you for an hour.`]})]}),(0,u.jsx)(c.Col,{xs:24,lg:12,children:b?(0,u.jsx)(c.Alert,{type:`success`,showIcon:!0,message:`The background scheduler is running — active feeds run on their schedule.`}):(0,u.jsx)(c.Alert,{type:`warning`,showIcon:!0,message:`The background scheduler is OFF on this server. Feeds can be run manually, but nothing runs on a schedule.`})})]}),e.length===0&&(0,u.jsx)(c.Alert,{style:{marginTop:16},type:`warning`,showIcon:!0,message:`No database is available for job feeds`,description:`You can always configure a feed for the database your own session belongs to, so this usually means that database is not registered on this server. To offer a DIFFERENT database — another region, or production — an operator must name it in JOB_FEED_TARGET_APPIDS.`}),v&&(0,u.jsx)(c.Alert,{style:{marginTop:16},type:`error`,showIcon:!0,message:v})]}),A&&(0,u.jsx)(Z,{title:`This feed was not enabled`,children:(0,u.jsx)(c.Alert,{type:`error`,showIcon:!0,message:`Another importer is still writing this source into the target database`,description:(0,u.jsxs)(c.Space,{direction:`vertical`,children:[(0,u.jsx)(vO,{children:A.reason}),(0,u.jsx)(vO,{type:`secondary`,children:`Enabling anyway means two writers create the same jobs, and the duplicates cannot be told apart afterwards. Only continue once the previous importer and its migration sync are stopped.`}),(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(c.Button,{onClick:()=>j(null),children:`Cancel`}),(0,u.jsx)(c.Button,{danger:!0,onClick:()=>{let{feedKey:e}=A;j(null),z({feedKey:e,action:gO.ENABLE,title:`Enable anyway`,danger:!0,description:`Confirming states that the previous importer has been stopped. This is recorded against your name.`,payload:{acknowledgeLegacyStopped:!0},onDone:I})},children:`I have stopped it — enable anyway`})]})]})})}),g&&f.length===0&&(0,u.jsx)(Z,{title:null,children:(0,u.jsx)(`div`,{style:{textAlign:`center`,padding:32},children:(0,u.jsx)(c.Spin,{})})}),!g&&f.length===0&&(0,u.jsx)(Z,{title:null,children:(0,u.jsx)(c.Empty,{description:n?`No feeds are configured in ${L?.database||`this database`} yet`:`Select a database first`,children:n&&i.length>0&&(0,u.jsx)(c.Button,{size:`large`,type:`primary`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>{D(null),T(!0)},children:`Add the first feed`})})}),f.map(e=>(0,u.jsx)(kO,{feed:e,providers:i,target:L,runs:m[e.feedKey],onLoadRuns:()=>R(e.feedKey),onEdit:()=>{D(e),T(!0)},onCredentials:()=>N(i.find(t=>t.key===e.provider)||null),onAction:z,onDone:I},e.feedKey)),(0,u.jsx)(jO,{minInterval:S,open:w,feed:E,providers:i,target:L,onClose:()=>T(!1),onSave:e=>{T(!1),z({feedKey:e.feedKey,action:gO.SAVE,title:E?`Save this feed`:`Create this feed`,description:`The configuration is stored in ${L?.database||`the selected database`}. Saving never starts a feed — enable it separately.`,payload:{config:e},onDone:I})}}),(0,u.jsx)(MO,{provider:M,target:L,onClose:()=>N(null),onSubmit:e=>{let t=M.key;N(null),z({feedKey:`provider:${t}`,action:gO.CREDENTIALS,title:`Credentials for ${M.label}`,description:`Stored encrypted for ${L?.database||`the selected database`}. They are never shown again.`,perform:r=>mO(t,{otp:r,appId:n,values:e}),onDone:I})}}),O&&(0,u.jsx)(zC,{open:!0,title:O.title,description:O.description,danger:O.danger,confirmLabel:`Confirm`,onRequestOtp:()=>fO(O.feedKey,O.action,n),onConfirm:V,onVerified:e=>{B(),O.onDone?.();let t=e?.data?.message||e?.message;t&&c.message.info(t)},onCancel:B})]})}function kO({feed:e,providers:t,target:n,runs:r,onLoadRuns:i,onEdit:a,onCredentials:o,onAction:s,onDone:d}){let f=t.find(t=>t.key===e.provider),p=e.status===`active`,m=(e.rules||[]).filter(e=>e.enabled).length,h=n?.database||e.targetAppId,g=(t,n,r,i={})=>s({feedKey:e.feedKey,action:t,title:n,description:r,onDone:d,...i});return(0,u.jsxs)(Z,{title:(0,u.jsxs)(c.Space,{size:12,wrap:!0,children:[(0,u.jsx)(c.Badge,{status:p?`processing`:`default`}),(0,u.jsx)(`span`,{style:{fontSize:16,fontWeight:600},children:e.label||e.feedKey}),(0,u.jsx)(c.Tag,{color:p?`green`:`default`,style:{fontSize:13,padding:`2px 10px`},children:p?`Active`:`Suspended`}),(0,u.jsx)(vO,{type:`secondary`,code:!0,children:e.feedKey})]}),extra:(0,u.jsxs)(c.Space,{size:4,children:[(0,u.jsx)(c.Tooltip,{title:`Edit this feed's settings and routing rules`,children:(0,u.jsx)(c.Button,{size:`large`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:a,children:`Edit`})}),(0,u.jsx)(c.Popconfirm,{title:`Delete this feed?`,description:`Jobs it already imported are not touched. You will still need to confirm with a code.`,okText:`Delete`,okButtonProps:{danger:!0},onConfirm:()=>g(gO.DELETE,`Delete this feed`,`The feed configuration is removed. Imported jobs are left alone.`,{danger:!0}),children:(0,u.jsx)(c.Button,{size:`large`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{}),children:`Delete`})})]}),children:[(0,u.jsxs)(c.Row,{gutter:[24,16],style:{marginBottom:20},children:[(0,u.jsx)(c.Col,{xs:12,md:8,lg:5,children:(0,u.jsxs)(DO,{label:`Source`,children:[(0,u.jsx)(`div`,{children:f?f.label:(0,u.jsx)(c.Tag,{color:`red`,children:e.provider||`unknown`})}),f&&!f.configured&&(0,u.jsxs)(vO,{type:`danger`,style:{fontSize:12},children:[`no credentials for `,h]}),f?.credentials?.source===`entered in admin`&&(0,u.jsxs)(vO,{type:`secondary`,style:{fontSize:12},children:[`credentials set by `,f.credentials.updatedBy||`an admin`]}),f?.credentials?.source===`server configuration`&&(0,u.jsx)(vO,{type:`secondary`,style:{fontSize:12},children:`credentials from server config`})]})}),(0,u.jsx)(c.Col,{xs:12,md:8,lg:5,children:(0,u.jsx)(DO,{label:`Writes into`,children:(0,u.jsx)(vO,{strong:!0,children:h})})}),(0,u.jsx)(c.Col,{xs:12,md:8,lg:5,children:(0,u.jsxs)(DO,{label:`Import`,children:[e.importEnabled?(0,u.jsx)(vO,{code:!0,children:e.importSchedule}):(0,u.jsx)(vO,{type:`secondary`,children:`off`}),(0,u.jsx)(`div`,{children:(0,u.jsxs)(vO,{type:`secondary`,style:{fontSize:12},children:[`last: `,TO(e.lastImportAt)]})})]})}),(0,u.jsx)(c.Col,{xs:12,md:8,lg:5,children:(0,u.jsxs)(DO,{label:`Status sync`,children:[e.statusSyncEnabled?(0,u.jsx)(vO,{code:!0,children:e.statusSyncSchedule}):(0,u.jsx)(vO,{type:`secondary`,children:`off`}),(0,u.jsx)(`div`,{children:(0,u.jsxs)(vO,{type:`secondary`,style:{fontSize:12},children:[`last: `,TO(e.lastStatusSyncAt)]})})]})}),(0,u.jsx)(c.Col,{xs:12,md:8,lg:4,children:(0,u.jsxs)(DO,{label:`Rules`,children:[(0,u.jsx)(vO,{strong:!0,children:m}),` `,(0,u.jsxs)(vO,{type:`secondary`,children:[`of `,(e.rules||[]).length,` enabled`]})]})})]}),(0,u.jsxs)(`div`,{style:{marginBottom:20},children:[(0,u.jsx)(vO,{type:`secondary`,style:{fontSize:12,textTransform:`uppercase`,letterSpacing:.4},children:`Routing — first match wins`}),(0,u.jsx)(`div`,{style:{marginTop:8},children:(e.rules||[]).map(e=>(0,u.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8,alignItems:`center`,padding:`8px 12px`,marginBottom:6,borderRadius:8,background:`rgba(0,0,0,0.02)`,border:`1px solid rgba(0,0,0,0.06)`,opacity:e.enabled?1:.55},children:[(0,u.jsx)(c.Tag,{color:e.enabled?`blue`:`default`,children:e.enabled?`on`:`off`}),(0,u.jsx)(vO,{strong:!0,children:e.label||e.key}),(0,u.jsx)(vO,{type:`secondary`,children:e.match?.op===`any`?`everything else`:`${e.match?.field} ${CO.find(t=>t.value===e.match?.op)?.label||e.match?.op} "${e.match?.value}"`}),(0,u.jsxs)(vO,{type:`secondary`,style:{fontSize:12},children:[`→ client `,String(e.clientId||``).slice(-6),` · tenant `,String(e.tenantId||``).slice(-6)]})]},e.key))})]}),(0,u.jsxs)(c.Space,{size:10,wrap:!0,children:[p?(0,u.jsx)(c.Button,{size:`large`,icon:(0,u.jsx)(l.PauseCircleOutlined,{}),onClick:()=>g(gO.SUSPEND,`Suspend this feed`,`Scheduled imports and status syncs stop. Nothing already imported is changed.`),children:`Suspend`}):(0,u.jsx)(c.Button,{size:`large`,type:`primary`,icon:(0,u.jsx)(l.PlayCircleOutlined,{}),onClick:()=>g(gO.ENABLE,`Enable this feed`,`The feed will import into ${h} on its schedule.`),children:`Enable`}),(0,u.jsx)(c.Tooltip,{title:`Fetch and map jobs without writing anything`,children:(0,u.jsx)(c.Button,{size:`large`,icon:(0,u.jsx)(l.EyeOutlined,{}),onClick:()=>g(gO.PREVIEW,`Preview this feed`,`A dry run against ${h}. It fetches and maps jobs and writes NOTHING.`,{onDone:i}),children:`Preview (dry run)`})}),(0,u.jsx)(c.Button,{size:`large`,icon:(0,u.jsx)(l.CloudDownloadOutlined,{}),onClick:()=>g(gO.RUN,`Import now`,`This WRITES new jobs into ${h}.`,{onDone:i}),children:`Import now`}),(0,u.jsx)(c.Button,{size:`large`,icon:(0,u.jsx)(l.SyncOutlined,{}),onClick:()=>g(gO.STATUS_SYNC,`Sync statuses now`,`Updates the status of existing jobs in ${h}.`,{onDone:i}),children:`Sync statuses`}),(0,u.jsx)(c.Tooltip,{title:`Enter the source credentials used for ${h}`,children:(0,u.jsx)(c.Button,{size:`large`,type:f&&!f.configured?`primary`:`default`,danger:f&&!f.configured,icon:(0,u.jsx)(l.KeyOutlined,{}),onClick:o,disabled:!f,children:f&&!f.configured?`Add credentials`:`Credentials`})})]}),(0,u.jsx)(c.Collapse,{ghost:!0,style:{marginTop:12},onChange:e=>e.length&&i(),items:[{key:`runs`,label:(0,u.jsx)(vO,{strong:!0,children:`Run history`}),children:(0,u.jsx)(AO,{runs:r})}]})]})}function AO({runs:e}){return e?e.length===0?(0,u.jsx)(vO,{type:`secondary`,children:`This feed has not run yet.`}):(0,u.jsx)(c.Table,{rowKey:e=>`${e.startedAt}-${e.kind}`,size:`small`,pagination:!1,dataSource:e,columns:[{title:`When`,dataIndex:`startedAt`,width:170,render:TO},{title:`Kind`,dataIndex:`kind`,width:100},{title:`By`,dataIndex:`actor`,width:160,render:(e,t)=>e||t.trigger},{title:`Result`,dataIndex:`outcome`,width:110,render:wO},{title:`Detail`,key:`detail`,render:(e,t)=>(0,u.jsxs)(c.Space,{direction:`vertical`,size:0,children:[(0,u.jsx)(vO,{style:{fontSize:12},children:t.message}),t.counts?.unrouted>0&&(0,u.jsxs)(vO,{type:`warning`,style:{fontSize:12},children:[t.counts.unrouted,` job(s) matched no rule and were skipped`]}),(t.problems||[]).slice(0,3).map(e=>(0,u.jsx)(vO,{type:`danger`,style:{fontSize:12},children:e},e))]})}]}):(0,u.jsx)(vO,{type:`secondary`,children:`Loading…`})}function jO({open:e,feed:t,providers:n,target:r,minInterval:i,onClose:a,onSave:o}){let[d]=c.Form.useForm(),f=c.Form.useWatch(`provider`,d),p=(0,s.useMemo)(()=>n.find(e=>e.key===f)||null,[n,f]);(0,s.useEffect)(()=>{if(!e)return;let r=t?{...SO,...t}:{...SO,provider:n[0]?.key||``};d.setFieldsValue(r)},[e,t,n,d]);let m=p?.matchFields||[];async function h(){try{let e=await d.validateFields();o({...SO,...t||{},...e})}catch{c.message.error(`Check the highlighted fields`)}}return(0,u.jsxs)(c.Drawer,{open:e,onClose:a,width:900,title:t?`Edit feed: ${t.label||t.feedKey}`:`Add a job feed`,extra:(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(c.Button,{size:`large`,onClick:a,children:`Cancel`}),(0,u.jsx)(c.Button,{size:`large`,type:`primary`,onClick:h,children:`Continue`})]}),destroyOnClose:!0,children:[(0,u.jsx)(c.Alert,{type:`info`,showIcon:!0,style:{marginBottom:16},message:`This feed will be stored in ${r?.database||`the selected database`}.`,description:`Saving stores the configuration only. A feed never imports anything until it is enabled, and both steps need a confirmation code.`}),(0,u.jsxs)(c.Form,{form:d,layout:`vertical`,children:[(0,u.jsxs)(c.Row,{gutter:12,children:[(0,u.jsx)(c.Col,{span:8,children:(0,u.jsx)(c.Form.Item,{name:`feedKey`,label:`Key`,tooltip:`A permanent identifier. It is stored on every job this feed imports, so it cannot be renamed later.`,rules:[{required:!0,message:`A key is required`},{pattern:/^[a-z0-9][a-z0-9-]{1,40}$/,message:`Lowercase letters, digits and hyphens only`}],children:(0,u.jsx)(c.Input,{placeholder:`client-job-feed`,disabled:!!t})})}),(0,u.jsx)(c.Col,{span:8,children:(0,u.jsx)(c.Form.Item,{name:`label`,label:`Name`,rules:[{required:!0,message:`A name is required`}],children:(0,u.jsx)(c.Input,{placeholder:`Client job feed`})})}),(0,u.jsx)(c.Col,{span:8,children:(0,u.jsx)(c.Form.Item,{name:`provider`,label:`Source system`,rules:[{required:!0}],children:(0,u.jsx)(c.Select,{options:n.map(e=>({value:e.key,label:e.configured?e.label:`${e.label} (no credentials on this server)`}))})})})]}),p&&!p.configured&&(0,u.jsx)(c.Alert,{type:`warning`,showIcon:!0,style:{marginBottom:16},message:`This server holds no credentials for that source`,description:`The feed can be configured and saved, but it cannot fetch anything until the credentials are in place.`}),(0,u.jsxs)(c.Row,{gutter:12,children:[(0,u.jsx)(c.Col,{span:6,children:(0,u.jsx)(c.Form.Item,{name:`importEnabled`,label:`Import jobs`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{})})}),(0,u.jsx)(c.Col,{span:6,children:(0,u.jsx)(c.Form.Item,{name:`importSchedule`,label:`Import schedule`,extra:xO(i),children:(0,u.jsx)(c.Input,{placeholder:`*/5 * * * *`})})}),(0,u.jsx)(c.Col,{span:6,children:(0,u.jsx)(c.Form.Item,{name:`statusSyncEnabled`,label:`Sync statuses`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{})})}),(0,u.jsx)(c.Col,{span:6,children:(0,u.jsx)(c.Form.Item,{name:`statusSyncSchedule`,label:`Status schedule`,extra:xO(i),children:(0,u.jsx)(c.Input,{placeholder:`*/30 * * * *`})})})]}),(0,u.jsxs)(c.Row,{gutter:12,children:[(0,u.jsx)(c.Col,{span:6,children:(0,u.jsx)(c.Form.Item,{name:`timezone`,label:`Timezone`,children:(0,u.jsx)(c.Input,{placeholder:`UTC`})})}),(0,u.jsx)(c.Col,{span:6,children:(0,u.jsx)(c.Form.Item,{name:`importPageSize`,label:`Jobs per page`,children:(0,u.jsx)(c.InputNumber,{min:1,max:500,style:{width:`100%`}})})}),(0,u.jsx)(c.Col,{span:6,children:(0,u.jsx)(c.Form.Item,{name:`maxCreatesPerRun`,label:`Max new jobs per run`,children:(0,u.jsx)(c.InputNumber,{min:1,max:500,style:{width:`100%`}})})}),(0,u.jsx)(c.Col,{span:6,children:(0,u.jsx)(c.Form.Item,{name:`maxStatusUpdatesPerRun`,label:`Max status updates per run`,children:(0,u.jsx)(c.InputNumber,{min:1,max:2e3,style:{width:`100%`}})})})]}),(0,u.jsx)(c.Form.Item,{name:`notifyOnCreate`,label:`Email a summary when jobs are imported`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{})}),(0,u.jsx)(bO,{level:5,style:{marginTop:8},children:`Routing rules`}),(0,u.jsx)(yO,{type:`secondary`,style:{fontSize:13},children:`Rules are tried in order and the first match wins. A job that matches no rule is skipped and counted, never imported into a default tenant. Each rule decides the tenant, the client and the service account the job is created as.`}),(0,u.jsx)(c.Form.List,{name:`rules`,children:(e,{add:t,remove:n})=>(0,u.jsxs)(u.Fragment,{children:[e.map(e=>(0,u.jsxs)(Z,{title:null,style:{marginBottom:12},children:[(0,u.jsxs)(c.Row,{gutter:12,children:[(0,u.jsx)(c.Col,{span:5,children:(0,u.jsx)(c.Form.Item,{...e,name:[e.name,`key`],label:`Rule key`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{placeholder:`india`})})}),(0,u.jsx)(c.Col,{span:6,children:(0,u.jsx)(c.Form.Item,{...e,name:[e.name,`label`],label:`Name`,children:(0,u.jsx)(c.Input,{placeholder:`India`})})}),(0,u.jsx)(c.Col,{span:4,children:(0,u.jsx)(c.Form.Item,{...e,name:[e.name,`enabled`],label:`Enabled`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{})})}),(0,u.jsx)(c.Col,{span:9,children:(0,u.jsx)(c.Form.Item,{label:`Match`,children:(0,u.jsxs)(c.Space.Compact,{style:{width:`100%`},children:[(0,u.jsx)(c.Form.Item,{...e,name:[e.name,`match`,`field`],noStyle:!0,children:(0,u.jsx)(c.Select,{style:{width:`38%`},placeholder:`field`,options:m.map(e=>({value:e,label:e}))})}),(0,u.jsx)(c.Form.Item,{...e,name:[e.name,`match`,`op`],noStyle:!0,children:(0,u.jsx)(c.Select,{style:{width:`32%`},options:CO})}),(0,u.jsx)(c.Form.Item,{...e,name:[e.name,`match`,`value`],noStyle:!0,children:(0,u.jsx)(c.Input,{style:{width:`30%`},placeholder:`IND_`})})]})})})]}),(0,u.jsxs)(c.Row,{gutter:12,children:[(0,u.jsx)(c.Col,{span:6,children:(0,u.jsx)(c.Form.Item,{...e,name:[e.name,`tenantId`],label:`Tenant id`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{})})}),(0,u.jsx)(c.Col,{span:6,children:(0,u.jsx)(c.Form.Item,{...e,name:[e.name,`businessId`],label:`Business id`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{})})}),(0,u.jsx)(c.Col,{span:6,children:(0,u.jsx)(c.Form.Item,{...e,name:[e.name,`businessUnitId`],label:`Business unit id`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{})})}),(0,u.jsx)(c.Col,{span:6,children:(0,u.jsx)(c.Form.Item,{...e,name:[e.name,`clientId`],label:`Client id`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{})})})]}),(0,u.jsxs)(c.Row,{gutter:12,children:[(0,u.jsx)(c.Col,{span:10,children:(0,u.jsx)(c.Form.Item,{...e,name:[e.name,`serviceUserId`],label:`Created by (service account id)`,tooltip:`The Mongo _id of a user in the target database marked as a service account. Jobs are created as that user, and the server refuses any user not marked.`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{})})}),(0,u.jsx)(c.Col,{span:14,children:(0,u.jsx)(c.Form.Item,{...e,name:[e.name,`notifyEmails`],label:`Notify these addresses`,tooltip:`One summary email per run, listing the jobs imported by this rule.`,children:(0,u.jsx)(c.Select,{mode:`tags`,tokenSeparators:[`,`,` `],placeholder:`name@example.com`})})})]}),(0,u.jsx)(c.Button,{danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{}),onClick:()=>n(e.name),children:`Remove rule`})]},e.key)),(0,u.jsx)(c.Button,{type:`dashed`,size:`large`,block:!0,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>t({enabled:!0,match:{op:`startsWith`},notifyEmails:[]}),children:`Add a routing rule`})]})}),p?.externalStatuses?.length>0&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(bO,{level:5,style:{marginTop:24},children:`Status overrides (optional)`}),(0,u.jsx)(yO,{type:`secondary`,style:{fontSize:13},children:`By default each source status is mapped by the connector. Override one here if this client uses a status differently. A status nothing can map leaves the job untouched.`}),(0,u.jsx)(c.Form.Item,{name:`statusMapping`,noStyle:!0,children:(0,u.jsx)(NO,{externalStatuses:p.externalStatuses})})]})]})]})}function MO({provider:e,target:t,onClose:n,onSubmit:r}){let[i]=c.Form.useForm();if((0,s.useEffect)(()=>{e&&i.resetFields()},[e,i]),!e)return null;let a=e.credentialFields||[],o=e.credentials||{};async function d(){let e=await i.validateFields().catch(()=>null);if(!e)return;let t=Object.fromEntries(Object.entries(e).filter(([,e])=>String(e||``).trim()!==``));if(Object.keys(t).length===0){c.message.error(`Enter at least one value`);return}r(t)}return(0,u.jsxs)(c.Modal,{open:!0,title:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.KeyOutlined,{}),` `,e.label,` credentials`]}),onCancel:n,okText:`Continue`,onOk:d,destroyOnClose:!0,width:560,children:[(0,u.jsx)(c.Alert,{type:`info`,showIcon:!0,style:{marginBottom:16},message:`Stored for ${t?.database||`the selected database`}`,description:`Values are encrypted before they are written and are never shown again. Each database keeps its own credentials, so a test database and the live one can use different accounts. Saving needs a confirmation code.`}),(0,u.jsx)(c.Form,{form:i,layout:`vertical`,children:a.map(e=>(0,u.jsx)(c.Form.Item,{name:e.key,label:e.label,help:e.help,extra:o.hints?.[e.key]?`Currently set: ${o.hints[e.key]} — leave blank to keep it`:void 0,children:e.secret?(0,u.jsx)(c.Input.Password,{autoComplete:`new-password`,placeholder:`Enter to set or replace`}):(0,u.jsx)(c.Input,{placeholder:`Enter to set or replace`})},e.key))})]})}function NO({value:e={},onChange:t,externalStatuses:n}){let r=[`Active`,`In Active`,`On Hold`,`Partially Fulfilled`,`Fulfilled`];return(0,u.jsx)(`div`,{children:n.map(n=>(0,u.jsxs)(c.Row,{gutter:12,align:`middle`,style:{marginBottom:6},children:[(0,u.jsx)(c.Col,{span:8,children:(0,u.jsx)(vO,{code:!0,children:n})}),(0,u.jsx)(c.Col,{span:10,children:(0,u.jsx)(c.Select,{allowClear:!0,style:{width:`100%`},placeholder:`connector default`,value:e?.[n]||void 0,onChange:r=>{let i={...e||{}};r?i[n]=r:delete i[n],t?.(i)},options:r.map(e=>({value:e,label:e}))})})]},n))})}var{Text:PO,Paragraph:FO}=c.Typography;function IO({regions:e=[]}){let[t]=c.Form.useForm(),[n,r]=(0,s.useState)(!0),[i,a]=(0,s.useState)(!1),[o,l]=(0,s.useState)([]),[d,f]=(0,s.useState)([]),[p,m]=(0,s.useState)(!0),[h,g]=(0,s.useState)(``),[_]=(0,s.useState)(`pyOps`),v=(0,s.useRef)(null),y=(0,s.useCallback)(async()=>{v.current?.abort();let e=new AbortController;v.current=e,r(!0),g(``);try{let n=await nO({serviceKey:_,signal:e.signal});l(n.regions),f(n.missingRegions),m(n.consistent);let r=n.regions.find(e=>e.exists);t.setFieldsValue({serviceKey:n.serviceKey,baseUrl:r?.baseUrl??``,authHeader:r?.authHeader??``,enabled:!r||r.enabled})}catch(e){e?.name!==`AbortError`&&g(e?.message||`Failed to load AI services`)}finally{r(!1)}},[t,_]);(0,s.useEffect)(()=>(queueMicrotask(y),()=>v.current?.abort()),[y]);async function b(){let e;try{e=await t.validateFields()}catch{return}a(!0);try{let n={serviceKey:e.serviceKey,baseUrl:e.baseUrl,authHeader:e.authHeader??``,enabled:e.enabled!==!1};e.authValue&&(n.authValue=e.authValue);let r=await rO(n,{regionKeys:[]}),i=r?.data?.regions??r?.regions??[];c.message.success(`Applied to ${i.length||`all`} region${i.length===1?``:`s`}`),t.setFieldsValue({authValue:``}),await y()}catch(e){c.message.error(e?.message||`Could not apply`)}finally{a(!1)}}return(0,u.jsxs)(c.Spin,{spinning:n,children:[h&&(0,u.jsx)(c.Alert,{type:`error`,showIcon:!0,message:h,style:{marginBottom:12}}),!n&&d.length>0&&(0,u.jsx)(c.Alert,{type:`warning`,showIcon:!0,style:{marginBottom:12},message:`${d.length} region${d.length===1?``:`s`} cannot use AI actions`,description:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(FO,{style:{marginBottom:6},children:[(0,u.jsx)(`b`,{children:d.join(`, `)}),` `,d.length===1?`has`:`have`,` no`,` `,(0,u.jsx)(`code`,{children:_}),` registration, so every AI action there fails with “AI service is not configured for this tenant”.`]}),(0,u.jsx)(PO,{type:`secondary`,children:`Apply the settings below to all regions to fix this.`})]})}),!n&&d.length===0&&!p&&(0,u.jsx)(c.Alert,{type:`info`,showIcon:!0,style:{marginBottom:12},message:`Regions disagree`,description:`Every region has the service, but not with the same base URL or enabled state.`}),(0,u.jsx)(c.Card,{size:`small`,title:`Apply ${_} to every region`,style:{marginBottom:16},children:(0,u.jsxs)(c.Form,{form:t,layout:`vertical`,disabled:i,children:[(0,u.jsx)(c.Form.Item,{name:`serviceKey`,label:`Service key`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{disabled:!0})}),(0,u.jsx)(c.Form.Item,{name:`baseUrl`,label:`Base URL`,rules:[{required:!0,message:`Base URL is required`}],extra:(0,u.jsxs)(u.Fragment,{children:[`The action's endpoint path is appended to this — e.g.`,` `,(0,u.jsx)(`code`,{children:`/v1/parse`}),`. This URL is called by the `,(0,u.jsx)(`b`,{children:`backend`}),`, not the browser, so it must be reachable `,(0,u.jsx)(`b`,{children:`from the API server`}),`. A public URL works only if a reverse-proxy rule forwards it to the Python service`,(0,u.jsx)(`b`,{children:` with the path prefix stripped`}),`; an internal address (`,(0,u.jsx)(`code`,{children:`host:7020`}),`) needs no proxy rule at all.`]}),children:(0,u.jsx)(c.Input,{placeholder:`https://zinnext.com/pyOps`})}),(0,u.jsx)(c.Form.Item,{name:`authHeader`,label:`Auth header`,extra:`Optional, e.g. Authorization or x-api-key.`,children:(0,u.jsx)(c.Input,{placeholder:`x-api-key`})}),(0,u.jsx)(c.Form.Item,{name:`authValue`,label:`Credential`,extra:`Leave blank to keep the stored credential unchanged. It is never displayed.`,children:(0,u.jsx)(c.Input.Password,{placeholder:`unchanged`,autoComplete:`new-password`})}),(0,u.jsx)(c.Form.Item,{name:`enabled`,label:`Enabled`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{})}),(0,u.jsx)(c.Button,{type:`primary`,loading:i,onClick:b,children:`Apply to all regions`})]})}),(0,u.jsx)(c.Table,{size:`small`,rowKey:`regionKey`,columns:[{title:`Region`,dataIndex:`label`,key:`label`,render:(e,t)=>(0,u.jsxs)(c.Space,{size:6,children:[(0,u.jsx)(PO,{strong:!0,children:e||t.regionKey}),(0,u.jsx)(c.Tag,{children:t.regionKey})]})},{title:`Status`,key:`status`,width:150,render:(e,t)=>t.exists?(0,u.jsx)(c.Tag,{color:t.enabled?`green`:`orange`,children:t.enabled?`Configured`:`Disabled`}):(0,u.jsx)(c.Tag,{color:`red`,children:`Not configured`})},{title:`Base URL`,dataIndex:`baseUrl`,key:`baseUrl`,render:e=>e?(0,u.jsx)(`code`,{children:e}):(0,u.jsx)(PO,{type:`secondary`,children:`—`})},{title:`Credential`,key:`auth`,width:120,render:(e,t)=>t.hasAuthValue?(0,u.jsx)(c.Tag,{color:`blue`,children:`Stored`}):(0,u.jsx)(PO,{type:`secondary`,children:`None`})}],dataSource:o,pagination:!1,locale:{emptyText:e.length?`No regions returned`:`No regions configured`}})]})}var{Text:LO,Title:RO}=c.Typography;function zO(){let[e,t]=(0,s.useState)(`regions`),[n,r]=(0,s.useState)([]),[i,a]=(0,s.useState)(!0),[o,d]=(0,s.useState)(null),f=(0,s.useRef)(null),p=(0,s.useCallback)(()=>{f.current?.abort();let e=new AbortController;return f.current=e,e.signal},[]),m=(0,s.useCallback)(async()=>{a(!0),d(null);try{let e=await zD({includeInactive:!0,signal:p()});r(e)}catch(e){if(e?.name===`AbortError`)return;d(e?.message||`Could not load regions`)}finally{a(!1)}},[p]);return(0,s.useEffect)(()=>(queueMicrotask(m),()=>f.current?.abort()),[m]),(0,u.jsxs)(`div`,{style:{padding:`4px 0`},children:[(0,u.jsxs)(c.Space,{align:`start`,style:{width:`100%`,justifyContent:`space-between`,marginBottom:12},children:[(0,u.jsxs)(`div`,{children:[(0,u.jsxs)(RO,{level:4,style:{margin:0},children:[(0,u.jsx)(l.SafetyCertificateOutlined,{}),` Platform`]}),(0,u.jsx)(LO,{type:`secondary`,children:`Cross-region administration. Every action here is authorised server-side and recorded in the audit trail.`})]}),(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:m,children:`Refresh`})]}),o&&(0,u.jsx)(c.Alert,{type:`error`,showIcon:!0,style:{marginBottom:12},message:`Could not load platform data`,description:(0,u.jsxs)(u.Fragment,{children:[o,(0,u.jsx)(`br`,{}),(0,u.jsx)(LO,{type:`secondary`,children:`If this reads as a permission failure, your platform access may have been revoked, or your session may predate it — sign out and back in, then try again.`})]})}),(0,u.jsx)(c.Tabs,{activeKey:e,onChange:e=>{f.current?.abort(),t(e)},items:[{key:`regions`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.GlobalOutlined,{}),` Regions`]}),children:(0,u.jsx)(BO,{regions:n,loading:i,onChanged:m})},{key:`defaults`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.SettingOutlined,{}),` Global Defaults`]}),children:(0,u.jsx)(aO,{regions:n})},{key:`ai-services`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.ApiOutlined,{}),` AI Services`]}),children:(0,u.jsx)(IO,{regions:n})},{key:`users`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.TeamOutlined,{}),` All Users`]}),children:(0,u.jsx)(WO,{regions:n})},{key:`access`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.KeyOutlined,{}),` Access`]}),children:(0,u.jsx)(GO,{})},{key:`job-feeds`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.CloudDownloadOutlined,{}),` Job Feeds`]}),children:(0,u.jsx)(OO,{})},{key:`audit`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.AuditOutlined,{}),` Audit`]}),children:(0,u.jsx)(KO,{regions:n})}]})]})}function BO({regions:e,loading:t,onChanged:n}){let[r,i]=(0,s.useState)(null),[a,o]=(0,s.useState)(null);return t?(0,u.jsx)(`div`,{style:{padding:48,textAlign:`center`},children:(0,u.jsx)(c.Spin,{})}):e.length?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Space,{style:{marginBottom:16},children:(0,u.jsx)(c.Button,{type:`primary`,onClick:()=>i({}),children:`Register region`})}),(0,u.jsx)(c.Row,{gutter:[16,16],children:e.map(e=>(0,u.jsx)(c.Col,{xs:24,md:12,xl:8,children:(0,u.jsx)(c.Card,{size:`small`,title:(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(l.GlobalOutlined,{}),(0,u.jsx)(`span`,{children:e.label?.trim()||e.key}),e.isHome&&(0,u.jsx)(c.Tag,{color:`blue`,children:`Your region`}),!e.isActive&&(0,u.jsx)(c.Tag,{children:`Inactive`})]}),extra:(0,u.jsx)(c.Tag,{color:`default`,children:e.key}),actions:[(0,u.jsx)(c.Button,{type:`link`,onClick:()=>i(e),children:`Edit`},`edit`),(0,u.jsx)(c.Button,{type:`link`,icon:(0,u.jsx)(l.SettingOutlined,{}),onClick:()=>o(e),children:`Display defaults`},`defaults`)],children:(0,u.jsxs)(c.Space,{direction:`vertical`,size:4,style:{width:`100%`},children:[(0,u.jsxs)(c.Row,{children:[(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(LO,{type:`secondary`,children:`Organization`})}),(0,u.jsx)(c.Col,{span:12,children:e.organizationName?.trim()?(0,u.jsx)(LO,{strong:!0,children:e.organizationName}):(0,u.jsx)(c.Tooltip,{title:`Not set: this region's users see Zinnext in the header.`,children:(0,u.jsx)(LO,{type:`secondary`,children:`Zinnext (default)`})})})]}),(0,u.jsxs)(c.Row,{children:[(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(LO,{type:`secondary`,children:`Users`})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(LO,{strong:!0,children:e.userCount??`—`})})]}),(0,u.jsxs)(c.Row,{children:[(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(LO,{type:`secondary`,children:`Region profile`})}),(0,u.jsx)(c.Col,{span:12,children:e.regionProfile?(0,u.jsx)(c.Tag,{color:`geekblue`,children:e.regionProfile}):(0,u.jsx)(c.Tooltip,{title:`No per-region rule overrides apply (FormGroup.regionRules is not used for this region).`,children:(0,u.jsx)(LO,{type:`secondary`,children:`none`})})})]}),(0,u.jsxs)(c.Row,{children:[(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(LO,{type:`secondary`,children:`Display defaults`})}),(0,u.jsx)(c.Col,{span:12,children:e.hasDisplayDefaults?(0,u.jsx)(c.Badge,{status:`success`,text:`configured`}):(0,u.jsx)(c.Tooltip,{title:`This region has no display-defaults document, so it falls back to the built-in formats.`,children:(0,u.jsx)(c.Badge,{status:`warning`,text:`not set`})})})]}),(0,u.jsx)(LO,{type:`secondary`,style:{fontSize:11,wordBreak:`break-all`},children:e.tenantId})]})})},e.key))}),(0,u.jsx)(VO,{region:r,onClose:()=>i(null),onSaved:n}),(0,u.jsx)(UO,{region:a,onClose:()=>o(null)})]}):(0,u.jsxs)(c.Empty,{description:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`div`,{children:`No regions registered yet.`}),(0,u.jsx)(LO,{type:`secondary`,children:`A region binds a name to one tenant / business / business-unit triple. Until one exists, nothing can be administered across regions.`})]}),children:[(0,u.jsx)(c.Button,{type:`primary`,onClick:()=>i({}),children:`Register the first region`}),(0,u.jsx)(VO,{region:r,onClose:()=>i(null),onSaved:n})]})}function VO({region:e,onClose:t,onSaved:n}){let[r]=c.Form.useForm(),[i,a]=(0,s.useState)(!1),o=e&&!e.key;if((0,s.useEffect)(()=>{e&&queueMicrotask(()=>r.setFieldsValue({isActive:!0,order:0,...e}))},[e,r]),!e)return null;let l=async(e=!1)=>{let i=await r.validateFields();a(!0);try{await BD(i,{allowEmpty:e}),c.message.success(`Region saved`),n?.(),t()}catch(e){String(e?.message||``).includes(`no users exist`)?c.Modal.confirm({title:`No users found for that tenant scope`,content:`Nothing in this database matches that tenant / business / business-unit triple. That usually means one of the ids has a typo — two live tenants already differ by a single character. Register it anyway only if the region is genuinely empty.`,okText:`Register anyway`,okButtonProps:{danger:!0},cancelText:`Let me check the ids`,onOk:()=>l(!0)}):c.message.error(e?.message||`Could not save region`)}finally{a(!1)}};return(0,u.jsxs)(c.Drawer,{open:!0,width:520,onClose:t,title:o?`Register region`:`Edit ${e.label||e.key}`,extra:(0,u.jsx)(c.Button,{type:`primary`,loading:i,onClick:()=>l(!1),children:`Save`}),children:[(0,u.jsx)(c.Alert,{type:`info`,showIcon:!0,style:{marginBottom:16},message:`A region is a name for a tenant scope`,description:`It does not create or move data. It binds a stable key to an existing tenant / business / business-unit triple so that key can be used in URLs and audit records.`}),(0,u.jsxs)(c.Form,{form:r,layout:`vertical`,children:[(0,u.jsx)(c.Form.Item,{name:`key`,label:`Region key`,tooltip:`The identifier. It appears in URLs and audit rows, so it never changes once used. Lower-case, no spaces.`,rules:[{required:!0,message:`A region key is required`},{pattern:/^[a-z0-9][a-z0-9-]*$/,message:`Lower-case letters, digits and hyphens only`}],children:(0,u.jsx)(c.Input,{placeholder:`us`,disabled:!o})}),(0,u.jsx)(c.Form.Item,{name:`label`,label:`Display name`,rules:[{required:!0,message:`A display name is required`}],children:(0,u.jsx)(c.Input,{placeholder:`United States`})}),(0,u.jsx)(c.Form.Item,{name:`organizationName`,label:`Organization name`,tooltip:`Shown in the application header for this region's users (after they sign in). Leave blank to show Zinnext.`,rules:[{max:120,message:`At most 120 characters`}],children:(0,u.jsx)(c.Input,{placeholder:`Zinnext`,allowClear:!0})}),(0,u.jsx)(c.Form.Item,{name:`tenantId`,label:`Tenant ID`,rules:[{required:!0,len:24,message:`24-character ObjectId`}],children:(0,u.jsx)(c.Input,{placeholder:`24-character ObjectId`,disabled:!o})}),(0,u.jsx)(c.Form.Item,{name:`businessId`,label:`Business ID`,rules:[{required:!0,len:24,message:`24-character ObjectId`}],children:(0,u.jsx)(c.Input,{disabled:!o})}),(0,u.jsx)(c.Form.Item,{name:`businessUnitId`,label:`Business Unit ID`,rules:[{required:!0,len:24,message:`24-character ObjectId`}],children:(0,u.jsx)(c.Input,{disabled:!o})}),(0,u.jsx)(c.Form.Item,{name:`regionProfile`,label:`Region profile`,tooltip:`Selects which FormGroup.regionRules profile applies. Leave blank for none.`,children:(0,u.jsx)(c.Select,{allowClear:!0,placeholder:`none`,options:[{value:`US`},{value:`UK`},{value:`IND`}]})}),(0,u.jsx)(c.Form.Item,{name:`order`,label:`Display order`,children:(0,u.jsx)(c.InputNumber,{min:0,style:{width:`100%`}})}),(0,u.jsx)(c.Form.Item,{name:`isActive`,label:`Active`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{})})]}),!o&&(0,u.jsx)(c.Button,{danger:!0,block:!0,onClick:()=>c.Modal.confirm({title:`Deactivate ${e.label||e.key}?`,content:`It stops being selectable and stops resolving. The record is kept so historical audit rows still make sense.`,okText:`Deactivate`,okButtonProps:{danger:!0},onOk:async()=>{await VD(e.key),c.message.success(`Region deactivated`),n?.(),t()}}),children:`Deactivate region`})]})}var HO=[{name:`phoneCountryCode`,label:`Phone country code`,placeholder:`+1`,help:`Empty means print no dial code at all. That is a real setting, not a blank.`},{name:`phoneFormat`,label:`Phone format`,placeholder:`(###) ###-####`},{name:`dateFormat`,label:`Date format`,placeholder:`DD MMM YYYY`,help:`Calendar dates only — no time, no zone.`},{name:`dateTimeFormat`,label:`Date & time format`,placeholder:`DD MMM YYYY, hh:mm A`},{name:`timeZone`,label:`Time zone`,placeholder:`Asia/Kolkata`,help:`IANA name. Empty means each viewer sees their own zone.`},{name:`booleanTrueLabel`,label:`Yes label`,placeholder:`Yes`},{name:`booleanFalseLabel`,label:`No label`,placeholder:`No`},{name:`emptyPlaceholder`,label:`Empty placeholder`,placeholder:`-`},{name:`separator`,label:`Separator`,placeholder:` · `}];function UO({region:e,onClose:t}){let[n]=c.Form.useForm(),[r,i]=(0,s.useState)(!1),[a,o]=(0,s.useState)(!1),d=(0,s.useRef)(null);return(0,s.useEffect)(()=>{if(!e)return;d.current?.abort();let t=new AbortController;return d.current=t,queueMicrotask(()=>{i(!0),JD(e.key,{signal:t.signal}).then(e=>n.setFieldsValue(e||{})).catch(e=>{e?.name!==`AbortError`&&c.message.error(e?.message||`Could not load defaults`)}).finally(()=>i(!1))}),()=>t.abort()},[e,n]),e?(0,u.jsxs)(c.Drawer,{open:!0,width:560,onClose:t,title:(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(l.SettingOutlined,{}),`Display defaults — `,e.label||e.key]}),extra:(0,u.jsx)(c.Button,{type:`primary`,loading:a,onClick:async()=>{let r=await n.validateFields();o(!0);try{await YD(e.key,r),c.message.success(`Display defaults saved for ${e.label||e.key}`),t()}catch(e){c.message.error(e?.message||`Could not save defaults`)}finally{o(!1)}},children:`Save`}),children:[(0,u.jsx)(c.Alert,{type:`warning`,showIcon:!0,style:{marginBottom:16},message:`These apply to this region only`,description:`Everyone in ${e.label||e.key} will see dates, times and phone numbers rendered with these settings. Other regions are unaffected.`}),(0,u.jsx)(c.Spin,{spinning:r,children:(0,u.jsx)(c.Form,{form:n,layout:`vertical`,children:HO.map(e=>(0,u.jsx)(c.Form.Item,{name:e.name,label:e.label,extra:e.help,children:(0,u.jsx)(c.Input,{placeholder:e.placeholder,allowClear:!0})},e.name))})})]}):null}function WO({regions:e}){let[t,n]=(0,s.useState)([]),[r,i]=(0,s.useState)(0),[a,o]=(0,s.useState)(!1),[l,d]=(0,s.useState)(``),[f,p]=(0,s.useState)(),[m,h]=(0,s.useState)(1),g=(0,s.useRef)(null),_=(0,s.useCallback)(async()=>{g.current?.abort();let e=new AbortController;g.current=e,o(!0);try{let{items:t,total:r}=await KD({search:l,regionKey:f,limit:25,offset:(m-1)*25,signal:e.signal});n(t),i(r)}catch(e){e?.name!==`AbortError`&&c.message.error(e?.message||`Could not load users`)}finally{o(!1)}},[l,f,m]);(0,s.useEffect)(()=>(queueMicrotask(_),()=>g.current?.abort()),[_]);let v=(0,s.useMemo)(()=>e.map(e=>({value:e.key,label:e.label?.trim()||e.key})),[e]);return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(c.Space,{style:{marginBottom:16},wrap:!0,children:[(0,u.jsx)(c.Input.Search,{allowClear:!0,placeholder:`Search name or email`,style:{width:280},onSearch:e=>{h(1),d(e)}}),(0,u.jsx)(c.Select,{allowClear:!0,placeholder:`All regions`,style:{width:200},options:v,onChange:e=>{h(1),p(e)}})]}),(0,u.jsx)(c.Alert,{type:`info`,showIcon:!0,style:{marginBottom:12},message:`Only users in registered regions appear here`,description:`A tenant scope that is not registered as a region is deliberately excluded, so orphaned or mistyped tenants are not exposed through this screen.`}),(0,u.jsx)(c.Table,{rowKey:e=>e._id||e.email,size:`small`,loading:a,columns:[{title:`Email`,dataIndex:`email`,key:`email`},{title:`Name`,key:`name`,render:(e,t)=>t.userName||[t.firstName,t.lastName].filter(Boolean).join(` `)||`—`},{title:`Region`,key:`region`,render:(e,t)=>t.regionKey?(0,u.jsx)(c.Tag,{color:`blue`,children:t.regionLabel||t.regionKey}):(0,u.jsx)(c.Tooltip,{title:`This user's tenant scope is not registered as a region.`,children:(0,u.jsx)(c.Tag,{children:`unregistered`})})},{title:`Role ID`,dataIndex:`roleId`,key:`roleId`,width:90}],dataSource:t,pagination:{current:m,pageSize:25,total:r,showSizeChanger:!1,onChange:h,showTotal:e=>`${e} user${e===1?``:`s`}`}})]})}function GO(){let[e,t]=(0,s.useState)([]),[n,r]=(0,s.useState)(!1),[i,a]=(0,s.useState)(!1),[o]=c.Form.useForm(),d=(0,s.useCallback)(async()=>{r(!0);try{t(await HD())}catch(e){c.message.error(e?.message||`Could not load platform access`)}finally{r(!1)}},[]);return(0,s.useEffect)(()=>{queueMicrotask(d)},[d]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Alert,{type:`warning`,showIcon:!0,style:{marginBottom:16},message:`Platform access spans every region`,description:`Grant it to as few people as possible, and prefer a time-boxed grant. Access is verified on every request, so revoking takes effect immediately rather than when a token expires.`}),(0,u.jsxs)(c.Space,{style:{marginBottom:16},children:[(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.ApiOutlined,{}),onClick:()=>a(!0),children:`Grant access`}),(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:d,children:`Refresh`})]}),(0,u.jsx)(c.Table,{rowKey:e=>e.userId,size:`small`,loading:n,columns:[{title:`Email`,dataIndex:`email`,key:`email`},{title:`Status`,key:`status`,render:(e,t)=>t.isActive?(0,u.jsx)(c.Badge,{status:`success`,text:`Active`}):(0,u.jsx)(c.Badge,{status:`default`,text:`Revoked`})},{title:`Scopes`,dataIndex:`scopes`,key:`scopes`,render:e=>(e||[]).map(e=>(0,u.jsx)(c.Tag,{children:e},e))},{title:``,key:`actions`,width:100,render:(e,t)=>t.isActive&&(0,u.jsx)(c.Button,{danger:!0,type:`link`,onClick:()=>c.Modal.confirm({title:`Revoke platform access for ${t.email}?`,content:`They keep their ordinary account and their own region. Cross-region administration stops working on their next request — not when their session expires.`,okText:`Revoke`,okButtonProps:{danger:!0},onOk:async()=>{try{await WD(t.userId),c.message.success(`Access revoked`),d()}catch(e){c.message.error(e?.message||`Could not revoke`)}}}),children:`Revoke`})}],dataSource:e}),(0,u.jsxs)(c.Modal,{open:i,title:(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(l.UserOutlined,{}),`Grant platform access`]}),onCancel:()=>a(!1),okText:`Grant`,onOk:async()=>{let e=await o.validateFields();try{await UD(e),c.message.success(`Platform access granted`),a(!1),o.resetFields(),d()}catch(e){c.message.error(e?.message||`Could not grant access`)}},children:[(0,u.jsx)(c.Alert,{type:`info`,showIcon:!0,style:{marginBottom:16},message:`This grants authority to an existing account`,description:`No password is created or changed here. The user must sign out and back in before it takes effect, because platform authority is keyed to an identifier older sessions do not carry.`}),(0,u.jsxs)(c.Form,{form:o,layout:`vertical`,children:[(0,u.jsx)(c.Form.Item,{name:`userId`,label:`User ID`,tooltip:`The user's stable Mongo _id — not their email and not a legacy numeric id. Copy it from the All Users tab.`,rules:[{required:!0,len:24,message:`A 24-character user _id is required`}],children:(0,u.jsx)(c.Input,{placeholder:`24-character ObjectId`})}),(0,u.jsx)(c.Form.Item,{name:`scopes`,label:`Scopes`,rules:[{required:!0,message:`Select at least one scope`}],children:(0,u.jsx)(c.Select,{mode:`multiple`,options:QD,placeholder:`Select scopes`})}),(0,u.jsx)(c.Form.Item,{name:`expiresAt`,label:`Expires`,extra:`Optional. RFC3339, e.g. 2026-12-31T23:59:59Z. Time-boxed access is safer.`,children:(0,u.jsx)(c.Input,{placeholder:`2026-12-31T23:59:59Z`})})]})]})]})}function KO({regions:e}){let[t,n]=(0,s.useState)([]),[r,i]=(0,s.useState)(0),[a,o]=(0,s.useState)(!1),[l,d]=(0,s.useState)(),[f,p]=(0,s.useState)(1);return(0,s.useEffect)(()=>{let e=!1,t=new AbortController;return queueMicrotask(()=>{e||(o(!0),qD({regionKey:l,limit:50,offset:(f-1)*50,signal:t.signal}).then(({items:t,total:r})=>{e||(n(t),i(r))}).catch(e=>{e?.name!==`AbortError`&&c.message.error(e?.message||`Could not load audit`)}).finally(()=>{e||o(!1)}))}),()=>{e=!0,t.abort()}},[l,f]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Space,{style:{marginBottom:16},children:(0,u.jsx)(c.Select,{allowClear:!0,placeholder:`All regions`,style:{width:200},options:e.map(e=>({value:e.key,label:e.label?.trim()||e.key})),onChange:e=>{p(1),d(e)}})}),(0,u.jsx)(c.Table,{rowKey:e=>e._id||`${e.at}-${e.action}`,size:`small`,loading:a,columns:[{title:`When`,dataIndex:`at`,key:`at`,width:190,render:e=>e?new Date(e).toLocaleString():`—`},{title:`Actor`,dataIndex:`actorEmail`,key:`actorEmail`},{title:`Action`,dataIndex:`action`,key:`action`,render:e=>(0,u.jsx)(c.Tag,{children:e})},{title:`Region`,dataIndex:`targetRegion`,key:`targetRegion`,render:e=>e?(0,u.jsx)(c.Tag,{color:`blue`,children:e}):(0,u.jsx)(LO,{type:`secondary`,children:`platform`})},{title:`Route`,dataIndex:`route`,key:`route`,render:e=>(0,u.jsx)(LO,{type:`secondary`,style:{fontSize:12},children:e})}],dataSource:t,pagination:{current:f,pageSize:50,total:r,showSizeChanger:!1,onChange:p}})]})}var{Content:qO,Header:JO,Sider:YO}=c.Layout,{Text:XO,Title:ZO}=c.Typography;function QO(e){return String(e??``).trim().replace(/[\s_-]+/g,` `).toUpperCase()}function $O(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function ek(e){return String(e||``).trim().toLowerCase()}function tk(e){return e?.key||e?.collectionName||e?.value||``}function nk(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=tk(e);if(!t)return;let o=ek(e.key||t),s=ek(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||$O(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=ek(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:$O(t),value:t,disabled:!1}))}),n}function rk(e){return QO(e?.user_type_name??e?.userTypeName??e?.name)===`SUPER ADMIN`}function ik(e){return`${e?.first_name??e?.firstName??``} ${e?.last_name??e?.lastName??``}`.trim()||e?.username||e?.userName||e?.email||`User ${e?.user_id??e?.userId??``}`}function ak(e){let t=new Set;return e.reduce((e,n)=>{let r=ik(n),i=n?.user_id??n?.userId,a=String(r).trim().toLowerCase()||String(i??``);return t.has(a)?e:(t.add(a),e.push({label:r,value:i}),e)},[])}function ok(e){return e.flatMap(e=>{let t=e.menu_id??e.menuId??e.MenuID,n=e.menu_name??e.menuName??e.MenuName??`Menu ${t??``}`,r=e.menu_key??e.menuKey??e.MenuKey??``,i=e.permissions??e.Permissions??{};return Object.entries(i).map(([e,i])=>{let a=i.permission_id??i.permissionId??i.PermissionID,o=i.permission_key??i.permissionKey??i.PermissionKey??e,s=i.value??i.Value??i.access_value??i.accessValue??i;return{key:`${r??n??t}:${a??o}`,menuId:t,menuName:n,menuKey:r,permissionId:a,permissionKey:o,accessValue:+(Number(s)===1)}})})}function sk(e){return String(e.menuKey??e.menuName??e.menuId).trim().toLowerCase()}var ck=[{permissionId:null,permissionKey:`my_jobs`,permissionName:`My Jobs`},{permissionId:null,permissionKey:`all_jobs`,permissionName:`All Jobs`},{permissionId:null,permissionKey:`sendApprove`,permissionName:`Send Approve`}];function lk(e){let t=Array.isArray(e)?e:e?.permissions??e?.actions??e?.data??e,n=(Array.isArray(t)?t:Object.values(t??{})).map(e=>({permissionId:e.permission_id??e.permissionId??e.legacyPermissionId??e.id??null,permissionKey:e.permission_key??e.permissionKey??e.key,permissionName:e.permission_name??e.permissionName??e.name??e.label})).filter(e=>e.permissionKey),r=new Set(n.map(e=>String(e.permissionKey).trim().toLowerCase()));return ck.forEach(e=>{r.has(e.permissionKey.toLowerCase())||n.push(e)}),n}function uk(e={}){return String(e.permissionName??``).trim()||String(e.permissionKey??``).replaceAll(`_`,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/\b\w/g,e=>e.toUpperCase())}function dk({title:e,description:t,selectedName:n,loading:r,saving:i,rows:a,onChange:o,onMove:s,onSave:d}){let f=Object.values(a.reduce((e,t)=>{let n=sk(t);return e[n]||(e[n]={key:n,menuName:t.menuName,menuKey:t.menuKey,permissions:[]}),e[n].permissions.push(t),e},{}));return(0,u.jsxs)(`section`,{className:`admin-editor`,children:[(0,u.jsxs)(`div`,{className:`admin-section-head`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(ZO,{level:4,children:e}),(0,u.jsx)(XO,{type:`secondary`,children:n||t})]}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.SaveOutlined,{}),loading:i,disabled:!n||a.length===0,onClick:d,children:`Save`})]}),r?(0,u.jsx)(`div`,{className:`admin-loading`,children:(0,u.jsx)(c.Spin,{})}):f.length?(0,u.jsx)(c.Table,{size:`small`,rowKey:`key`,columns:[{title:`Menu`,dataIndex:`menuName`,width:220,render:(e,t)=>(0,u.jsxs)(`div`,{className:`admin-menu-order-cell`,children:[(0,u.jsxs)(`div`,{className:`admin-menu-cell`,children:[(0,u.jsx)(`span`,{children:e}),(0,u.jsx)(XO,{type:`secondary`,children:t.menuKey})]}),(0,u.jsxs)(c.Space,{size:2,children:[(0,u.jsx)(c.Button,{size:`small`,type:`text`,icon:(0,u.jsx)(l.ArrowUpOutlined,{}),onClick:()=>s(t.key,-1),"aria-label":`Move ${e} up`}),(0,u.jsx)(c.Button,{size:`small`,type:`text`,icon:(0,u.jsx)(l.ArrowDownOutlined,{}),onClick:()=>s(t.key,1),"aria-label":`Move ${e} down`})]})]})},{title:`Actions`,dataIndex:`permissions`,render:e=>(0,u.jsx)(`div`,{className:`admin-permission-controls`,children:e.filter(e=>wS(e.menuName??e.menuKey,e.permissionKey)).map(e=>(0,u.jsx)(`label`,{className:`admin-permission-control`,children:(0,u.jsx)(c.Checkbox,{checked:e.accessValue===1,onChange:t=>o(e.key,+!!t.target.checked),"aria-label":`${e.menuName} ${e.permissionKey}`,children:uk(e)})},e.key))})}],dataSource:f,pagination:!1,scroll:{y:420}}):(0,u.jsx)(c.Empty,{description:`Select a record to customize permissions`})]})}function fk({onLogout:e}){let[r]=c.Form.useForm(),[i]=c.Form.useForm(),[a,o]=(0,s.useState)(`users`),[d,f]=(0,s.useState)(!0),[p,m]=(0,s.useState)(!1),[h,g]=(0,s.useState)(!1),[_,v]=(0,s.useState)([]),[y,b]=(0,s.useState)(0),[x,S]=(0,s.useState)(1),[C,w]=(0,s.useState)(10),[T,E]=(0,s.useState)(``),[D,O]=(0,s.useState)(!1),[k,A]=(0,s.useState)([]),[j,M]=(0,s.useState)([]),[N,P]=(0,s.useState)([]),[F,I]=(0,s.useState)(null),[L,R]=(0,s.useState)([]),[z,B]=(0,s.useState)(!1),[V,H]=(0,s.useState)(null),[ee,te]=(0,s.useState)(!1),[ne,re]=(0,s.useState)(null),[ie,ae]=(0,s.useState)([]),[oe,se]=(0,s.useState)(!1),[ce,U]=(0,s.useState)(!1),[W,le]=(0,s.useState)(null),[ue,de]=(0,s.useState)(!1),[G,fe]=(0,s.useState)(null),[pe,me]=(0,s.useState)(`listView`),[he,ge]=(0,s.useState)([]),[_e,K]=(0,s.useState)([]),[q,J]=(0,s.useState)(!1),[ve,ye]=(0,s.useState)(!1),be=t.d(),xe=(0,s.useMemo)(()=>he.filter(e=>!e.disabled),[he]),Se=!q&&xe.length===0,Ce=(0,s.useCallback)(async()=>{J(!0);try{let[e,t]=await Promise.all([n.ri(),n.Yr()]),r=nk(e.modules,t),i=new Set(r.filter(e=>!e.disabled).map(e=>e.value));ge(r),K(e=>e.filter(e=>i.has(e)))}catch{c.message.error(`Failed to load seed status`)}finally{J(!1)}},[]);(0,s.useEffect)(()=>{Ce()},[Ce]);async function we(){if(_e.length===0){c.message.warning(Se?`All modules already seeded.`:`Select at least one module to seed.`);return}ye(!0);try{await n.Li(_e),c.message.success(`User type field config seeded`),K([]),await Ce()}catch(e){c.message.error(e?.message||`Seed failed`)}finally{ye(!1)}}async function Te(){f(!0);try{let[e,t,n]=await Promise.allSettled([fS(),gS(),bS()]),r=e.status===`fulfilled`?e.value:[];e.status===`rejected`&&c.message.error(e.reason?.message||`Unable to load user types`),A(r??[]),M(t.status===`fulfilled`?t.value??[]:[]),P(n.status===`fulfilled`?lk(n.value):[]),I((r??[])[0]?.user_type_id??null)}catch(e){c.message.error(e.message||`Unable to load admin data`)}finally{f(!1)}}(0,s.useEffect)(()=>{queueMicrotask(()=>{Te()})},[]);let Ee=(0,s.useCallback)(async()=>{O(!0);try{let{users:e,total:t}=await sS({limit:C,offset:(x-1)*C,search:T});v(e??[]),b(t??0)}catch(e){c.message.error(e?.message||`Unable to load users`),v([]),b(0)}finally{O(!1)}},[x,C,T]);(0,s.useEffect)(()=>{Ee()},[Ee]),(0,s.useEffect)(()=>{queueMicrotask(()=>{if(!F){R([]);return}m(!0),xS(F).then(e=>{let t=ok(e??[]),n=new Map(t.map(e=>[`${sk(e)}:${String(e.permissionKey).toLowerCase()}`,e.accessValue])),r=j.flatMap(e=>N.map(t=>{let r=String(e.menu_key??e.menu_name??e.menu_id).trim().toLowerCase(),i=String(t.permissionKey).toLowerCase();return{key:`${e.menu_key??e.menu_name??e.menu_id}:${t.permissionId??t.permissionKey}`,menuId:e.menu_id,menuName:e.menu_name,menuKey:e.menu_key,permissionId:t.permissionId,permissionKey:t.permissionKey,accessValue:n.get(`${r}:${i}`)??0}}));R(r)}).catch(e=>c.message.error(e.message||`Unable to load role permissions`)).finally(()=>m(!1))})},[F,j,N]);let De=(0,s.useMemo)(()=>k.find(e=>e.user_type_id===F),[F,k]),Oe=(0,s.useMemo)(()=>k.reduce((e,t)=>({...e,[t.user_type_id]:t.user_type_name}),{}),[k]),ke=(0,s.useMemo)(()=>_.reduce((e,t)=>({...e,[t.user_id]:ik(t)}),{}),[_]),Ae=(0,s.useMemo)(()=>k.filter(e=>!rk(e)),[k]),je=(0,s.useMemo)(()=>_.filter(e=>!rk({user_type_id:e.user_type_id,user_type_name:Oe[e.user_type_id]})),[Oe,_]);(0,s.useEffect)(()=>{if(!z){ae([]);return}let e=Number(r.getFieldValue(`user_type_id`)??0);if(!e){ae([]);return}let t=!1;return se(!0),cS(e).then(e=>{t||ae(e.filter(e=>!V||e.user_id!==V.user_id))}).catch(e=>{t||(c.message.error(e.message||`Unable to load reporting users`),ae([]))}).finally(()=>{t||se(!1)}),()=>{t=!0}},[V,r,z]);let Me=(0,s.useMemo)(()=>{let e=ak(ie),t=Number(V?.reporting_id??V?.reportingId??0);return!t||e.some(e=>Number(e.value)===t)?e:[{label:V?.reportingName??V?.reporting_name??ke[t]??`User ${t}`,value:t},...e]},[V,ie,ke]),Ne=(0,s.useMemo)(()=>{let e=Ae.map(e=>({label:e.user_type_name,value:e.user_type_id}));if(!V)return e;let t=Number(V.user_type_id??0);return e.some(e=>Number(e.value)===t)?e:[{label:Oe[t]??V.userType??V.roleName??(t>0?`Type ${t}`:`Unassigned`),value:t},...e]},[V,Ae,Oe]);k.length,j.length;let Pe=[{key:`form-groups`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.AppstoreAddOutlined,{}),` Form Groups`]}),title:`Form Groups`,description:`Build module add and edit form groups with validations, dropdowns, and custom forms.`,component:(0,u.jsx)(qw,{})},{key:`detail-groups`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.BgColorsOutlined,{}),` Detail Groups`]}),title:`Detail Groups`,description:`Control detail-view labels, rendering, lookups, merged fields, and display defaults.`,component:(0,u.jsx)(kT,{})},{key:`actions`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.ThunderboltOutlined,{}),` Actions`]}),title:`Actions`,description:`Manage row action buttons and their visibility rules from one workspace.`,component:(0,u.jsx)(yE,{})},{key:`templates`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.MailOutlined,{}),` Templates`]}),title:`Templates`,description:`Manage reusable email templates and signatures.`,component:(0,u.jsx)(jE,{})},{key:`ai-services`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.ThunderboltOutlined,{}),` AI Services`]}),title:`AI Services`,description:`Register the AI and automation services used by admin-configured AI actions.`,component:(0,u.jsx)(RE,{})},{key:`bgc-integration`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.SafetyCertificateOutlined,{}),` Integrations`]}),title:`Integrations`,description:`Manage manual and API integrations used across application workflows.`,component:(0,u.jsx)(WE,{})},{key:`automations`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.ApartmentOutlined,{}),` Automations`]}),title:`Automations`,description:`Reference ids, duplicate checks, cross-module snapshots, reporting-chain hierarchy expansion, board updates, notifications, and cache invalidation — per module, config-driven.`,component:(0,u.jsx)(iD,{})},{key:`workflows`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.ApartmentOutlined,{}),` Workflows`]}),title:`Workflows`,description:`Event-driven behavior per module (beforeCreate/afterCreate/…): the metadata the platform Workflow Engine executes — where the jobs, candidates, and submissions create flows live.`,component:(0,u.jsx)(fD,{})},{key:`masters`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.AppstoreAddOutlined,{}),` Masters`]}),title:`Masters`,description:`Shared Location and Tax lists used across modules (e.g. the submission form’s W2 employer section).`,component:(0,u.jsx)(jD,{})}],[Fe,Ie]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=new AbortController;return GD({signal:e.signal}).then(Ie).catch(()=>Ie(!1)),()=>e.abort()},[]);let Le=[...Fe?[{key:`platform`,icon:(0,u.jsx)(l.SafetyCertificateOutlined,{}),label:`Platform`}]:[],{key:`users`,icon:(0,u.jsx)(l.UserOutlined,{}),label:`Users`},{key:`roles`,icon:(0,u.jsx)(l.TeamOutlined,{}),label:`User Types`},{key:`menus`,icon:(0,u.jsx)(l.MenuOutlined,{}),label:`Menus`},{key:`configurations`,icon:(0,u.jsx)(l.AppstoreAddOutlined,{}),label:`Configurations`},{key:`integrations`,icon:(0,u.jsx)(l.SafetyCertificateOutlined,{}),label:`Integrations`}];function Re(e,t){R(n=>n.map(n=>n.key===e?{...n,accessValue:t}:n))}async function ze(){g(!0);try{await SS(F,L.map(e=>({menu_id:e.menuId,menu_name:e.menuName,menu_key:e.menuKey,permission_id:e.permissionId,permission_key:e.permissionKey,access_value:e.accessValue,updated_by:be?.userId??null}))),c.message.success(`Role permissions updated`)}catch(e){c.message.error(e.message||`Unable to save role permissions`)}finally{g(!1)}}function Be(){H(null),r.resetFields(),r.setFieldsValue({status:`ACTIVE`,user_type_id:Ae[0]?.user_type_id,reporting_id:0}),B(!0)}function Ve(e){H(e),r.setFieldsValue({first_name:e.first_name,last_name:e.last_name,username:e.username,email:e.email,mobile:e.mobile,user_type_id:e.user_type_id,reporting_id:e.reporting_id??e.reportingId??0,profile_image:e.profile_image,status:e.status}),B(!0)}async function He(e){te(!0);try{let t={...e,status:e.status===1||e.status===`1`||e.status===!0?`ACTIVE`:e.status===0||e.status===`0`||e.status===!1?`INACTIVE`:String(e.status??`ACTIVE`).toUpperCase(),updated_by:be?.userId??null,created_by:be?.userId??null};t.password||delete t.password,V?(await uS(V.user_id,t),c.message.success(`User updated`)):(await lS(t),c.message.success(`User created`)),B(!1),H(null),await Ee()}catch(e){c.message.error(e.message||`Unable to save user`)}finally{te(!1)}}async function Ue(e){re(e);try{await dS(e),c.message.success(`User deleted`),await Ee()}catch(e){c.message.error(e.message||`Unable to delete user`)}finally{re(null)}}function We(e,t){me(`listView`),fe({kind:e,record:t}),e===`role`&&I(t.user_type_id)}function Y(e,t){R(n=>{let r=[...new Set(n.map(sk))],i=r.indexOf(e),a=i+t;if(i<0||a<0||a>=r.length)return n;[r[i],r[a]]=[r[a],r[i]];let o=new Map(r.map((e,t)=>[e,t]));return[...n].sort((e,t)=>o.get(sk(e))-o.get(sk(t)))})}function Ge(){le(null),i.resetFields(),i.setFieldsValue({status:`ACTIVE`}),U(!0)}function Ke(e){le(e),U(!0),i.setFieldsValue(e)}async function qe(e){de(!0);try{let t=be?.userId??null,n=!!W,r=n?await mS(W.user_type_id,{...e,updated_by:t}):await pS({...e,created_by:t,visible_menu_ids:[]}),i=r.user_type_id;c.message.success(n?`User type updated`:`User type created. Customize its menus and permissions.`),U(!1),await Te(),I(i),n||(me(`permissions`),fe({kind:`role`,record:{...e,...r,user_type_id:i,user_type_name:r.user_type_name??e.user_type_name}}))}catch(e){c.message.error(e.message||`Unable to save role`)}finally{de(!1)}}async function X(e){try{await hS(e),c.message.success(`Role deleted`),await Te()}catch(e){c.message.error(e.message||`Unable to delete role`)}}return(0,u.jsxs)(c.Layout,{className:`admin-shell`,children:[(0,u.jsx)(YO,{width:248,className:`admin-sider`,children:(0,u.jsxs)(`div`,{className:`admin-sidebar-nav`,children:[(0,u.jsx)(XO,{className:`admin-sidebar-title`,children:`Admin Menu`}),(0,u.jsx)(c.Menu,{theme:`dark`,mode:`inline`,selectedKeys:[a],onClick:({key:e})=>o(e),items:Le})]})}),(0,u.jsx)(c.Layout,{children:(0,u.jsxs)(qO,{className:`admin-content`,children:[(0,u.jsx)(u.Fragment,{children:(0,u.jsx)(c.Tabs,{activeKey:a,onChange:o,tabBarStyle:{display:`none`},items:[{key:`users`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.UserOutlined,{}),` Users`]}),children:(0,u.jsx)(`div`,{className:`admin-stack`,children:(0,u.jsxs)(`section`,{className:`admin-section`,children:[(0,u.jsxs)(`div`,{className:`admin-section-head`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(ZO,{level:4,children:`Users`}),(0,u.jsx)(XO,{type:`secondary`,children:`Create and manage users with non-super-admin user types.`})]}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:Be,children:`Add`})]}),(0,u.jsx)(kh,{listName:`Users`,loading:D,fields:[{label:`Name`,value:`first_name`,render:(e,t)=>`${e??``} ${t.last_name??``}`.trim()||t.username},{label:`Email`,value:`email`},{label:`User Type`,value:`user_type_id`,width:160,render:(e,t)=>Oe[e]||t?.userType||t?.user_type||(Number(e)>0?`Type ${e}`:`—`)},{label:`Reporting Manager`,value:`reporting_id`,width:180,render:(e,t)=>ke[e]||t?.reportingName||t?.reporting_name||(Number(e)>0?`User ${e}`:`None`)},{label:`Status`,value:`status`,width:110,sorter:!1,render:e=>(0,u.jsx)(c.Tag,{color:e===`ACTIVE`?`green`:`default`,children:e})},{label:`Actions`,value:`_actions`,width:150,sorter:!1,render:(e,t)=>(0,u.jsxs)(c.Space,{size:4,children:[(0,u.jsx)(c.Button,{"aria-label":`Edit user`,icon:(0,u.jsx)(l.EditOutlined,{}),size:`small`,onClick:()=>Ve(t)}),(0,u.jsx)(c.Popconfirm,{title:`Delete user?`,description:`This removes the user from the auth database.`,okText:`Delete`,okButtonProps:{danger:!0},onConfirm:()=>Ue(t.user_id),children:(0,u.jsx)(c.Button,{danger:!0,"aria-label":`Delete user`,icon:(0,u.jsx)(l.DeleteOutlined,{}),loading:ne===t.user_id,size:`small`})})]})}],dataSource:je.map(e=>({...e,key:e.user_id})),total:y,current:x,pageSize:C,onPageChange:S,onPageSizeChange:e=>{w(e),S(1)},onSearch:e=>{E(e??``),S(1)},rowSelection:!1})]})})},{key:`roles`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.TeamOutlined,{}),` User Types`]}),children:(0,u.jsxs)(`div`,{className:`admin-stack`,children:[(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.AppstoreOutlined,{}),title:`Field Config Seed`,style:{marginBottom:12},children:[(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[(0,u.jsx)(`div`,{style:{minWidth:320,flex:1},children:(0,u.jsx)(c.Select,{mode:`multiple`,allowClear:!0,showSearch:!0,value:_e,options:he,placeholder:Se?`All modules already seeded`:`Select modules or collections to seed`,disabled:q||ve||Se,loading:q,onChange:K,style:{width:`100%`}})}),(0,u.jsx)(c.Button,{type:`primary`,loading:ve,disabled:q||_e.length===0,onClick:we,children:`Seed Field Config`})]}),(0,u.jsx)(XO,{type:`secondary`,style:{display:`block`,marginTop:8,fontSize:12},children:Se?`Seed is disabled because all configured modules already have user type field config data.`:`Already seeded modules are disabled. New modules or collections can still be seeded.`})]}),(0,u.jsxs)(`section`,{className:`admin-section`,children:[(0,u.jsxs)(`div`,{className:`admin-section-head`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(ZO,{level:4,children:`User Types`}),(0,u.jsx)(XO,{type:`secondary`,children:`Role level permissions are inherited by users.`})]}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:Ge,children:`Add Role`})]}),(0,u.jsx)(kh,{listName:`User Types`,loading:d,fields:[{label:`User Type`,value:`user_type_name`},{label:`Description`,value:`description`},{label:`Status`,value:`status`,width:110,sorter:!1,render:e=>(0,u.jsx)(c.Tag,{color:e===`ACTIVE`?`green`:`default`,children:e})},{label:`Actions`,value:`_actions`,width:260,sorter:!1,render:(e,t)=>{let n=Number(t.role_type)===1;return(0,u.jsxs)(c.Space,{size:4,children:[(0,u.jsx)(c.Button,{"aria-label":`Configure role`,size:`small`,onClick:()=>We(`role`,t),children:`Config`}),(0,u.jsx)(c.Button,{"aria-label":`Edit role`,icon:(0,u.jsx)(l.EditOutlined,{}),size:`small`,onClick:()=>Ke(t)}),n&&!rk(t)&&(0,u.jsx)(c.Popconfirm,{title:`Delete role?`,onConfirm:()=>X(t.user_type_id),children:(0,u.jsx)(c.Button,{"aria-label":`Delete role`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{}),size:`small`})})]})}}],dataSource:k.map(e=>({...e,key:e.user_type_id,roleId:e.user_type_id,roleName:e.user_type_name})),total:k.length,rowSelection:!1})]})]})},{key:`menus`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.MenuOutlined,{}),` Menus`]}),children:(0,u.jsx)(PD,{})},{key:`configurations`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.AppstoreAddOutlined,{}),` Configurations`]}),children:(0,u.jsxs)(`section`,{className:`admin-section admin-config-workspace`,children:[(0,u.jsxs)(`div`,{className:`admin-section-head`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(ZO,{level:4,children:`Configuration Center`}),(0,u.jsx)(XO,{type:`secondary`,children:`CORE-THEME admin modules embedded into the admin dashboard.`})]}),(0,u.jsxs)(c.Tag,{color:`blue`,children:[Pe.length,` configurations`]})]}),(0,u.jsx)(c.Tabs,{className:`admin-config-tabs`,defaultActiveKey:`form-groups`,tabPosition:`left`,items:Pe.map(e=>({key:e.key,label:e.label,children:(0,u.jsxs)(`div`,{className:`admin-config-panel`,children:[(0,u.jsx)(`div`,{className:`admin-config-panel-head`,children:(0,u.jsxs)(`div`,{children:[(0,u.jsx)(ZO,{level:4,children:e.title}),(0,u.jsx)(XO,{type:`secondary`,children:e.description})]})}),(0,u.jsx)(`div`,{className:`admin-config-panel-body`,children:e.component})]})}))})]})},...Fe?[{key:`platform`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.SafetyCertificateOutlined,{}),` Platform`]}),children:(0,u.jsx)(`section`,{className:`admin-section admin-config-workspace`,children:(0,u.jsx)(zO,{})})}]:[],{key:`integrations`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.SafetyCertificateOutlined,{}),` Integrations`]}),children:(0,u.jsxs)(`section`,{className:`admin-section admin-config-workspace`,children:[(0,u.jsx)(`div`,{className:`admin-section-head`,children:(0,u.jsxs)(`div`,{children:[(0,u.jsx)(ZO,{level:4,children:`Integrations`}),(0,u.jsx)(XO,{type:`secondary`,children:`Configure external services used by onboarding and other workflows.`})]})}),(0,u.jsx)(`div`,{className:`admin-config-panel`,children:(0,u.jsx)(`div`,{className:`admin-config-panel-body`,children:(0,u.jsx)(WE,{})})})]})}]})}),(0,u.jsxs)(c.Modal,{className:`uss-modal`,title:`Configure User Type: ${G?.record?.user_type_name??``}`,open:!!G,onCancel:()=>fe(null),footer:null,destroyOnHidden:!0,width:900,children:[(0,u.jsx)(`div`,{className:`uss-config-toggle`,style:{marginBottom:12},children:[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`},{key:`actions`,label:`Actions`}].map(e=>(0,u.jsx)(`button`,{type:`button`,className:`uss-config-btn${pe===e.key?` active`:``}`,onClick:()=>me(e.key),children:e.label},e.key))}),G&&pe===`permissions`?(0,u.jsx)(dk,{title:`Role Permissions`,description:`Configure menu permissions for this user type`,selectedName:De?.user_type_name,loading:p,saving:h,rows:L,onChange:Re,onMove:Y,onSave:ze}):G&&pe===`actions`?(0,u.jsx)(oC,{role:{...G.record,roleId:G.record.user_type_id,roleName:G.record.user_type_name}},`${G.record?.user_type_id}-actions`):G&&pe===`form`?(0,u.jsx)(QS,{role:{...G.record,roleId:G.record.user_type_id,roleName:G.record.user_type_name}},`${G.record?.user_type_id}-form`):G?(0,u.jsx)(VS,{role:{...G.record,roleId:G.record.user_type_id,roleName:G.record.user_type_name},configType:pe},`${G.record?.user_type_id}-${pe}`):null]}),(0,u.jsx)(c.Modal,{className:`admin-role-modal`,title:W?`Edit User Type`:`Create User Type`,open:ce,onCancel:()=>U(!1),onOk:()=>i.submit(),okText:W?`Save`:`Next`,confirmLoading:ue,destroyOnHidden:!0,width:900,children:(0,u.jsxs)(c.Form,{form:i,layout:`vertical`,onFinish:qe,children:[(0,u.jsx)(c.Form.Item,{name:`user_type_name`,label:`Role name`,rules:[{required:!0,message:`Role name is required`}],children:(0,u.jsx)(c.Input,{placeholder:`Recruiter`})}),(0,u.jsx)(c.Form.Item,{name:`description`,label:`Description`,children:(0,u.jsx)(c.Input.TextArea,{rows:3})}),(0,u.jsx)(c.Form.Item,{name:`status`,label:`Status`,extra:W&&Number(W.role_type)!==1?`Built-in user types cannot be deactivated.`:void 0,children:(0,u.jsx)(c.Select,{disabled:!!W&&Number(W.role_type)!==1,options:[{value:`ACTIVE`},{value:`INACTIVE`}]})})]})}),(0,u.jsx)(c.Modal,{className:`admin-user-modal`,title:V?`Edit User`:`Add User`,open:z,onCancel:()=>B(!1),onOk:()=>r.submit(),confirmLoading:ee,destroyOnHidden:!0,children:(0,u.jsxs)(c.Form,{form:r,layout:`vertical`,requiredMark:!1,onFinish:He,children:[(0,u.jsxs)(`div`,{className:`admin-form-row`,children:[(0,u.jsx)(c.Form.Item,{label:`First Name`,name:`first_name`,rules:[{required:!0,message:`First name is required`}],children:(0,u.jsx)(c.Input,{placeholder:`John`})}),(0,u.jsx)(c.Form.Item,{label:`Last Name`,name:`last_name`,children:(0,u.jsx)(c.Input,{placeholder:`Doe`})})]}),(0,u.jsx)(c.Form.Item,{label:`Username`,name:`username`,rules:[{required:!0,message:`Username is required`}],children:(0,u.jsx)(c.Input,{placeholder:`john.doe`})}),(0,u.jsx)(c.Form.Item,{label:`Email`,name:`email`,rules:[{required:!0,message:`Email is required`},{type:`email`,message:`Enter a valid email`}],children:(0,u.jsx)(c.Input,{placeholder:`john@example.com`})}),(0,u.jsx)(c.Form.Item,{label:`Password`,name:`password`,rules:V?[]:[{required:!0,message:`Password is required`}],children:(0,u.jsx)(c.Input.Password,{placeholder:V?`Leave empty to keep current password`:`Password`})}),(0,u.jsxs)(`div`,{className:`admin-form-row`,children:[(0,u.jsx)(c.Form.Item,{label:`Mobile`,name:`mobile`,children:(0,u.jsx)(c.Input,{placeholder:`9999999999`})}),(0,u.jsx)(c.Form.Item,{label:`User Type`,name:`user_type_id`,rules:[{required:!0,message:`User type is required`}],children:(0,u.jsx)(c.Select,{placeholder:`Select user type`,onChange:()=>{ae([]),queueMicrotask(()=>{let e=Number(r.getFieldValue(`user_type_id`)??0);e&&(se(!0),cS(e).then(e=>{ae(e.filter(e=>!V||e.user_id!==V.user_id))}).catch(e=>{c.message.error(e.message||`Unable to load reporting users`),ae([])}).finally(()=>{se(!1)}))})},options:Ne})})]}),(0,u.jsx)(c.Form.Item,{label:`Reporting Manager`,name:`reporting_id`,children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,loading:oe,placeholder:`Select reporting manager`,optionFilterProp:`label`,options:[{label:`None`,value:0},...Me]})}),(0,u.jsx)(c.Form.Item,{label:`Profile Image`,name:`profile_image`,children:(0,u.jsx)(c.Input,{placeholder:`https://...`})}),(0,u.jsx)(c.Form.Item,{label:`Status`,name:`status`,children:(0,u.jsx)(c.Select,{options:[{label:`ACTIVE`,value:`ACTIVE`},{label:`INACTIVE`,value:`INACTIVE`}]})})]})})]})})]})}var pk=fk;function mk(e,t){return String(e||t).replace(/\/\*$/,``).replace(/\/+$/,``)||t}function hk({loginPath:e=`/login`,adminPath:t=`/admin`,fallbackPath:n=`/`}){let r=(0,f.useNavigate)(),i=mk(e,`/login`),a=mk(t,`/admin`),o=`${a}/*`;return(0,u.jsxs)(f.Routes,{children:[(0,u.jsx)(f.Route,{path:i,element:(0,u.jsx)(px,{defaultRedirectPath:a,onLogin:()=>r(a,{replace:!0})})}),(0,u.jsx)(f.Route,{path:o,element:(0,u.jsx)(ix,{loginPath:i,children:(0,u.jsx)(fx,{children:(0,u.jsx)(pk,{onLogout:()=>r(i,{replace:!0})})})})}),(0,u.jsx)(f.Route,{path:n,element:(0,u.jsx)(f.Navigate,{to:a,replace:!0})}),(0,u.jsx)(f.Route,{path:`*`,element:(0,u.jsx)(f.Navigate,{to:a,replace:!0})})]})}function gk(e){return(0,u.jsx)(f.BrowserRouter,{children:(0,u.jsx)(hk,{...e})})}var _k=/[<>]/,vk=/^[^,\s@<>]+@[^,\s@<>]+\.[^\s@<>]{2,}$/,yk=/^\d+@\d+(?:\.[A-Za-z0-9-]+)+$/;function bk(e){return Array.isArray(e)?e.map(String).map(e=>e.trim()).filter(Boolean):String(e??``).split(`,`).map(e=>e.trim()).filter(Boolean)}function xk(e){return Array.isArray(e)?e.some(e=>_k.test(String(e??``))):_k.test(String(e??``))}function Sk(e){let t=String(e??``).trim();return!!t&&!_k.test(t)&&!yk.test(t)&&vk.test(t)}function Ck(e){return bk(e).filter(e=>!Sk(e))}function wk(e){return Ck(e).length===0}var{Text:Tk}=c.Typography,Ek=new Set([`file`,`document`,`attachment`]),Dk=`To, CC and BCC cannot contain < or > characters.`,Ok=`Add email ID separated by commas`,kk={to:`To Mail`,cc:`Cc`,bcc:`Bcc`};function Ak(e){return Ek.has(String(e?.type??``).trim().toLowerCase())}function jk(e){return String(e??``).trim().toLowerCase().replace(/[^a-z0-9]/g,``)}function Mk(e){return e?typeof e==`string`?e:String(typeof e==`object`?e?._id??e?.id??e?.$oid??``:e):``}function Nk(e,t,n){if(!e)return``;let r=jk(t),i=jk(n);if(!r||r===i||r.replace(/s$/,``)===i.replace(/s$/,``))return Mk(e?._id??e?.id);let a=r.replace(/s$/,``),o=[`${a}Id`,`${r}Id`,a,r,`${a}._id`,`${r}._id`];for(let t of o){let n=Mk(Lk(e,t));if(n)return n}return``}async function Pk(e){let t=e?.fileUrl??e?.url??e?.downloadUrl;if(!t)return null;let n=await fetch(t);if(!n.ok)throw Error(`Unable to load attachment ${e?.fileName||``}`.trim());let r=await n.blob(),i=e?.fileName??e?.uploadedFileName??e?.uniqueName??`attachment`;return new File([r],i,{type:e?.contentType||r.type||`application/octet-stream`})}async function Fk(e,t,r){if(!t)return[];let i=[];(e?.placeholders??[]).forEach(e=>{(e?.holders??[]).filter(Ak).forEach(a=>{let o=Nk(t,e?.moduleName,r);o&&i.push((async()=>{let t=await n.Un(e.moduleName,o,a.value);return Promise.all((t?.data??[]).map(Pk))})())})});let a=(await Promise.all(i)).flat().filter(Boolean),o=new Set;return a.filter(e=>{let t=`${e.name}:${e.size}:${e.type}`;return!o.has(t)&&(o.add(t),!0)})}function Ik(e,t){return[...new Set([...bk(e),...bk(t)])].join(`, `)}function Lk(e,t,n=``){let r=String(n??``).trim().toLowerCase();return String(t??``).split(`.`).reduce((e,t)=>{let n=e;return Array.isArray(n)&&r===`last`&&(n=n.at(-1)),n?.[t]},e)}function Rk(e,t,n){if(!n)return String(e??``);let r=new Map;return(t??[]).forEach(e=>(e.holders??[]).forEach(e=>{r.set(e.key,Ak(e)?``:Lk(n,e.value,e.arrayMode))})),String(e??``).replace(/{{\.?([\w.]+)}}/g,(e,t)=>{let n=r.get(t);return n==null?e:String(n)})}function zk(e,t){let n=e;for(;n&&n!==t;){if(n instanceof HTMLElement){let e=window.getComputedStyle(n);if(/(auto|scroll)/.test(e.overflowY)&&n.scrollHeight>n.clientHeight)return n}n=n.parentElement}return t?.querySelector?.(`.mail-popup__body`)??null}function Bk({value:e,onChange:t,defaultTemplateId:r=``,templateApplyKey:i=``,ready:a=!0,title:o=`Mail`,hint:d,bccHint:f,afterBcc:p,beforeFields:m,className:h=``,contextRecords:g=[],moduleName:_=``,requiredTo:v=!1,requiredSubject:y=!1,requiredBody:b=!1}){let x=(0,s.useRef)(``),S=n=>t?.({...e,...n});function C(e){xk(String(e?.nativeEvent?.data??e?.data??``))&&(e.preventDefault(),c.message.warning(Dk))}function w(e){xk(String(e?.clipboardData?.getData?.(`text`)??``))&&(e.preventDefault(),c.message.warning(Dk))}function T(e,t){if(xk(t)){c.message.warning(Dk);return}let n=(Array.isArray(t)?t:bk(t)).map(e=>String(e??``).trim()).filter(Boolean),r=Ck(n);if(r.length){let t=kk[e]??`Recipient`,i=r[0];c.message.warning(`${t}: enter a valid email address${i?` (${i})`:``}`),S({[e]:n.filter(Sk).join(`, `)});return}S({[e]:n.join(`, `)})}function E(t){let n=Ck(e?.[t]);return n.length?`Enter a valid email address: ${n[0]}`:``}function D(t,{placeholder:n=Ok,required:r=!1}={}){let i=E(t);return(0,u.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,u.jsx)(c.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`],value:bk(e?.[t]),onChange:e=>T(t,e),onInputKeyDown:e=>{(e.key===`<`||e.key===`>`)&&(e.preventDefault(),c.message.warning(Dk))},variant:`borderless`,status:i?`error`:void 0,className:`mail-popup__recipient-select`,style:{width:`100%`},placeholder:n,"aria-required":r,"aria-invalid":!!i}),i&&(0,u.jsx)(Tk,{type:`danger`,style:{display:`block`,fontSize:12,lineHeight:1.35,marginTop:2},children:i})]})}function O(e){let t=zk(e.target,e.currentTarget);if(!t)return;let n=t.scrollHeight-t.clientHeight;if(n<=0)return;let r=Math.max(0,Math.min(n,t.scrollTop+e.deltaY));r!==t.scrollTop&&(t.scrollTop=r),e.preventDefault(),e.stopPropagation()}async function k(t,n=!1){if(t)try{let r=await zT(t),i=g[0],a=await Fk(r,i,_);S({to:Ik(e.to,(r?.toMail??[]).map(e=>Rk(e,r?.placeholders,i))),cc:Ik(e.cc,(r?.ccMail??[]).map(e=>Rk(e,r?.placeholders,i))),bcc:Ik(e.bcc,(r?.bccMail??[]).map(e=>Rk(e,r?.placeholders,i))),subject:Rk(r?.subject,r?.placeholders,i),contents:Rk(r?.body,r?.placeholders,i),attachments:a}),n||c.message.success(`Loaded ${r?.name||`email template`}`)}catch(e){n||c.message.error(e?.message||`Could not load email template`)}}return(0,s.useEffect)(()=>{let e=`${r}::${i}`;!a||!r||x.current===e||(x.current=e,k(r,!0))},[r,i,a]),(0,u.jsxs)(`div`,{className:`common-mail-composer ${h}`.trim(),onWheelCapture:O,children:[(0,u.jsx)(`div`,{className:`mail-popup__header`,children:(0,u.jsxs)(`div`,{className:`mail-popup__header-brand`,children:[(0,u.jsx)(`span`,{className:`dynamic-popup__header-icon-box`,children:(0,u.jsx)(l.MailOutlined,{})}),(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`span`,{className:`dynamic-popup__header-label`,children:o}),d&&(0,u.jsx)(Tk,{type:`secondary`,className:`mail-popup__header-hint`,children:d})]})]})}),(0,u.jsxs)(`div`,{className:`mail-popup__body`,children:[m&&(0,u.jsxs)(u.Fragment,{children:[m,(0,u.jsx)(c.Divider,{})]}),(0,u.jsxs)(`div`,{className:`mail-popup__field-row`,onBeforeInputCapture:C,onPasteCapture:w,children:[(0,u.jsxs)(Tk,{type:`secondary`,className:`mail-popup__field-label`,children:[`To Mail`,v&&(0,u.jsx)(`span`,{className:`mail-popup__required-mark`,"aria-hidden":`true`,children:`*`})]}),D(`to`,{required:v}),(0,u.jsxs)(`div`,{className:`mail-popup__cc-bcc-actions`,children:[!e.showCc&&(0,u.jsx)(`span`,{className:`mail-popup__cc-bcc-link`,onClick:()=>S({showCc:!0}),children:`Cc`}),!e.showBcc&&(0,u.jsx)(`span`,{className:`mail-popup__cc-bcc-link`,onClick:()=>S({showBcc:!0}),children:`Bcc`})]})]}),(0,u.jsx)(c.Divider,{}),e.showCc&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`mail-popup__field-row`,onBeforeInputCapture:C,onPasteCapture:w,children:[(0,u.jsx)(Tk,{type:`secondary`,className:`mail-popup__field-label`,children:`Cc`}),D(`cc`)]}),(0,u.jsx)(c.Divider,{})]}),e.showBcc&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`mail-popup__field-row`,onBeforeInputCapture:C,onPasteCapture:w,children:[(0,u.jsx)(Tk,{type:`secondary`,className:`mail-popup__field-label`,children:`Bcc`}),D(`bcc`,{placeholder:f||Ok})]}),p,(0,u.jsx)(c.Divider,{})]}),(0,u.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,u.jsxs)(Tk,{type:`secondary`,className:`mail-popup__field-label`,children:[`Subject`,y&&(0,u.jsx)(`span`,{className:`mail-popup__required-mark`,"aria-hidden":`true`,children:`*`})]}),(0,u.jsx)(c.Input,{variant:`borderless`,value:e.subject,onChange:e=>S({subject:e.target.value}),placeholder:`Enter subject`,className:`mail-popup__field-input`,"aria-required":y})]}),(0,u.jsx)(c.Divider,{}),!!e.attachments?.length&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,u.jsx)(Tk,{type:`secondary`,className:`mail-popup__field-label`,children:`Attachments`}),(0,u.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:6,padding:`4px 0`},children:e.attachments.map((e,t)=>(0,u.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,u.jsx)(l.PaperClipOutlined,{}),e.name]},`${e.name}:${e.size}:${t}`))})]}),(0,u.jsx)(c.Divider,{})]}),(0,u.jsxs)(`div`,{className:`mail-popup__message-section`,children:[(0,u.jsxs)(Tk,{type:`secondary`,className:`mail-popup__message-label`,children:[`Body`,b&&(0,u.jsx)(`span`,{className:`mail-popup__required-mark`,"aria-hidden":`true`,children:`*`})]}),(0,u.jsx)(n.Xn,{value:e.contents,onChange:e=>S({contents:e})})]})]})]})}var Vk=new Set([`true`,`1`,`yes`,`y`,`on`]),Hk=/^[a-fA-F0-9]{24}$/,Uk=[`email`,`candidateEmail`,`candidate_email`,`emailId`,`mailId`,`alternateEmail`,`altEmail`,`basicDetails.email`,`basicDetails.alternateEmail`,`basicDetails.altEmail`,`candidate.email`,`candidate.emailId`,`submission.email`,`submission.candidateEmail`,`customFields.diceProfileData.email`];function Wk(e,t=!1){return e==null||e===``?t:e===!0||e===!1?e:typeof e==`number`?e===1:typeof e==`string`?Vk.has(e.trim().toLowerCase()):t}function Gk(e){return String(e??``).trim().toLowerCase().replace(/[^a-z0-9]/g,``)}function Kk(e){return[`candidate`,`candidates`,`sourcecandidate`,`sourcecandidates`].includes(Gk(e))}function qk(e,t){if(!(!e||!t))return String(t).split(`.`).reduce((e,t)=>e?.[t],e)}function Jk(e,t={},n={}){let r=Array.isArray(e?.recipientFields)?e.recipientFields:String(e?.recipientFields??``).split(`,`),i=[t.recipientField,t.recipientPath,n.recipientField,n.recipientPath],a=[...r,...i].map(e=>String(e??``).trim()).filter(Boolean);return a.length?[...new Set(a)]:Uk}function Yk(e={}){return[e?.jobId,e?.jobID,e?.job_id,e?.popupContext?.jobId,e?.popupContext?.jobID,e?.popupContext?.job_id].some(e=>{let t=e&&typeof e==`object`?e?._id??e?.id??e?.$oid:e;return Hk.test(String(t??``).trim())})}function Xk(e={}){return(Wk(e?.forceJobBasedMail)||Wk(e?.popupContext?.forceJobBasedMail))&&Yk(e)}function Zk({popupAction:e={},state:t={},moduleName:n=``}={}){let r=e.mailConfig??t.mailConfig,i=Xk(t),a=i||Wk(e.requireJobId)||Wk(t.requireJobId)||Kk(n);if(!r||typeof r!=`object`)return{configured:!1,forcedJobContext:i,jobBased:a,recipientSource:`selectedRecords`,recipientFields:Jk({},e,t),recipientMode:`allSelected`,removeDuplicateRecipients:!0,jobIdSource:`context`,jobIdField:`jobId`,jobIdReadOnly:i,autoFetchJobContent:!0,requiredTo:!0,requiredJobId:a,requiredSubject:!0,requiredBody:!0};let o=i||Wk(r.jobBased,a);return{configured:!0,forcedJobContext:i,jobBased:o,recipientSource:[`selectedRecords`,`manual`].includes(r.recipientSource)?r.recipientSource:`selectedRecords`,recipientFields:Jk(r,e,t),recipientMode:r.recipientMode===`firstSelected`?`firstSelected`:`allSelected`,removeDuplicateRecipients:Wk(r.removeDuplicateRecipients,!0),jobIdSource:i?`context`:[`context`,`selectedRecord`,`manual`].includes(r.jobIdSource)?r.jobIdSource:`context`,jobIdField:String(r.jobIdField??`jobId`).trim()||`jobId`,jobIdReadOnly:i||Wk(r.jobIdReadOnly,!1),autoFetchJobContent:i||Wk(r.autoFetchJobContent,o),requiredTo:Wk(r.requiredTo,!0),requiredJobId:i||Wk(r.requiredJobId,o),requiredSubject:Wk(r.requiredSubject,!0),requiredBody:Wk(r.requiredBody,!0)}}function Qk(e=[],t=`allSelected`){let n=Array.isArray(e)?e.filter(Boolean):[];return t===`firstSelected`?n.slice(0,1):n}function $k(e={}){return!e.forcedJobContext&&e.requiredJobId&&!(e.configured&&e.jobBased)}function eA(e,t={},n=[]){let r=e?.jobIdSource??`context`,i=e?.jobIdField||`jobId`;if(r===`manual`)return``;let a=(e,t=i)=>{let n=[qk(e,t),t===`jobId`?e?.jobId:void 0,e?.jobId,e?.jobID,e?.job_id,e?.job?._id,e?.job?.id,e?._id,e?.id];for(let e of n){if(e&&typeof e==`object`){let t=e?._id??e?.id??e?.$oid;if(t!=null&&String(t).trim())return String(t)}if(e!=null&&String(e).trim())return String(e)}return``},o=[t,t?.popupContext].filter(Boolean);return(()=>{for(let e of o){let t=a(e);if(t)return t}return``})()||(r===`selectedRecord`?a(n?.[0]):``)}var{Text:tA}=c.Typography,nA=/^[a-fA-F0-9]{24}$/,rA=new Set([`file`,`document`,`attachment`]);function iA(e){let t=String(e??``);return t.trim()?t.replace(/<br\s*\/?\s*>/gi,` `).replace(/<[^>]*>/g,` `).replace(/ | /gi,` `).replace(/\s+/g,` `).trim().length>0||/<(img|table|hr)\b/i.test(t):!1}async function aA(e){let t=e?.fileUrl??e?.url??e?.downloadUrl;if(!t)return null;let n=await fetch(t);if(!n.ok)throw Error(`Unable to load attachment ${e?.fileName||``}`.trim());let r=await n.blob(),i=e?.fileName??e?.uploadedFileName??e?.uniqueName??`attachment`;return new File([r],i,{type:e?.contentType||r.type||`application/octet-stream`})}async function oA(e,t,r=[]){let i=String(e??``);if(!i||!r.length||!t)return{contents:i,attachments:[]};let a=(await n.hi(t).catch(()=>[])).filter(e=>rA.has(String(e?.type??``).trim().toLowerCase())).filter(e=>{let t=String(e?.value??e?.field??e?.fieldKey??e?.key??e?.name??``).replace(/^\./,``);return t&&(i.includes(`{{.${t}}}`)||i.includes(`{{${t}}}`))});if(!a.length)return{contents:i,attachments:[]};let o=[];for(let e of a){let a=String(e?.value??e?.field??e?.fieldKey??e?.key??e?.name??``).replace(/^\./,``);i=i.replaceAll(`{{.${a}}}`,``).replaceAll(`{{${a}}}`,``);for(let e of r){let r=String(e?._id??e?.id??``);if(!nA.test(r))continue;let i=await n.Un(t,r,a).catch(()=>({data:[]})),s=await Promise.all((i?.data??[]).map(aA));o.push(...s.filter(Boolean))}}let s=new Set,c=o.filter(e=>{let t=`${e.name}:${e.size}:${e.type}`;return!s.has(t)&&(s.add(t),!0)});return{contents:i,attachments:c}}function sA(e,...t){for(let n of t){let t=String(n).split(`.`).reduce((e,t)=>e?.[t],e);if(t!=null&&String(t).trim()!==``)return t}}function cA(e){let t=sA(e,`jobReferenceId`,`clientJobId`,`jobCode`,`reqId`,`jobId`),n=sA(e,`jobTitle`,`title`,`name`),r=sA(e,`jobRecruitmentStatus`,`recruitmentStatus`,`jobStatus`,`status`),i=[t,n].filter(Boolean).join(` - `)||String(sA(e,`_id`,`id`)??`Job`);return r?`${i} — ${r}`:i}function lA(e){let t=sA(e,`_id`,`id`,`jobId`);if(!t)return null;let n=e?.disable===!0||e?.disabled===!0,r=sA(e,`jobRecruitmentStatus`,`recruitmentStatus`,`jobStatus`,`status`),i=String(e?.message??r??``).trim();return{value:String(t),label:cA(e),disabled:n,title:n&&i?i:void 0,raw:e}}function uA(e=[]){let t={...e?.recordMeta??{}},n=(e=[])=>{e.forEach(e=>{!e||typeof e!=`object`||(e.field&&e.value!==void 0&&(t[e.field]=e.value),Array.isArray(e.fields)&&n(e.fields),Array.isArray(e.rows)&&e.rows.forEach(e=>n(e.fields??e)))})};return n(Array.isArray(e)?e:[]),t}async function dA(e){return nA.test(String(e??``))?cA({...uA(await Xn({module:`jobs`,id:e,view:`detail`})),_id:e}):``}function fA(e=[],t=[]){let n=[...new Set(t.filter(Boolean))];return e.flatMap(e=>n.map(t=>sA(e,t))).flatMap(e=>Array.isArray(e)?e:[e]).flatMap(bk)}function pA(e){let t=sA(e,`jobId`,`job_id`,`job._id`,`job.id`,`jobs._id`,`jobs.id`);return typeof t==`object`?sA(t,`_id`,`id`,`$oid`):t}function mA(e={}){return{subject:e.subject??e.Subject??``,contents:e.contents??e.Contents??e.body??e.Body??``,toMail:e.toMail??e.ToMail??[],ccMail:e.ccMail??e.CcMail??[],bccMail:e.bccMail??e.BccMail??[]}}function hA(e,t=!0){let n=e.flatMap(bk);return(t?[...new Set(n)]:n).join(`, `)}function gA(){let e=(0,f.useNavigate)(),{state:t={}}=(0,f.useLocation)(),{selectedIds:n=[],selectedRecords:r=[],recipients:i=[],subject:a=``,onSend:o,moduleName:l=``,popupAction:d={}}=t,p=(0,s.useMemo)(()=>Zk({popupAction:d,state:t,moduleName:l}),[l,d,t]),m=String(d.defaultTemplateId??t.defaultTemplateId??``).trim(),h=(0,s.useMemo)(()=>Qk(r,p.recipientMode),[p.recipientMode,r]),g=(0,s.useMemo)(()=>p.recipientMode===`firstSelected`?n.slice(0,1):n,[p.recipientMode,n]),_=g.join(`|`),v=(0,s.useMemo)(()=>{let e=p.recipientSource===`selectedRecords`?fA(h,p.recipientFields):[];return hA([...i,...e],p.removeDuplicateRecipients)},[p.recipientFields,p.recipientSource,p.removeDuplicateRecipients,h,i]),y=String(eA(p,t,r)??``).trim(),b=String(pA(r[0])??``).trim(),x=y||(p.configured?``:b),S=n[0]??r[0]?._id??r[0]?.id??``,C=p.jobBased||p.requiredJobId?x:String(x||(p.configured?``:S)||``),w=p.jobIdReadOnly&&p.jobIdSource!==`manual`&&nA.test(x),T=$k(p),[E,D]=(0,s.useState)(x),[O,k]=(0,s.useState)(C),[A,j]=(0,s.useState)(``),[M,N]=(0,s.useState)({to:v,cc:``,bcc:``,subject:a,contents:``,attachments:[],showCc:!1,showBcc:!1}),P=p.autoFetchJobContent&&nA.test(C),[F,I]=(0,s.useState)(!P),[L,R]=(0,s.useState)(!1),[z,B]=(0,s.useState)([]),[V,H]=(0,s.useState)(!1),[ee,te]=(0,s.useState)(!1),ne=(0,s.useRef)(!1),re=(0,s.useRef)(``),ie=(0,s.useRef)(``),ae=(0,s.useRef)(0);(0,s.useEffect)(()=>{if(p.recipientSource!==`selectedRecords`||!Kk(l)||ne.current||bk(M.to).length>0||g.length===0||re.current===_)return;let e=!1;return re.current=_,Sn(g).then(t=>{if(e)return;let n=fA(Qk(t,p.recipientMode),p.recipientFields);n.length&&N(e=>bk(e.to).length>0?e:{...e,to:hA(n,p.removeDuplicateRecipients)})}).catch(t=>{e||c.message.error(t?.message||`Could not load candidate emails`)}),()=>{e=!0}},[M.to,p.recipientFields,p.recipientMode,p.recipientSource,p.removeDuplicateRecipients,l,g,_]),(0,s.useEffect)(()=>{if(p.recipientSource!==`selectedRecords`||Kk(l)||!l||ne.current||bk(M.to).length>0||g.length===0||ie.current===_)return;let e=!1;return ie.current=_,Promise.all(g.map(e=>Cn(l,e).catch(()=>null))).then(t=>{if(e)return;let n=fA(t.filter(Boolean),p.recipientFields);n.length&&N(e=>bk(e.to).length>0?e:{...e,to:hA(n,p.removeDuplicateRecipients)})}).catch(t=>{e||c.message.error(t?.message||`Could not load recipient emails`)}),()=>{e=!0}},[M.to,p.recipientFields,p.recipientSource,p.removeDuplicateRecipients,l,g,_]),(0,s.useEffect)(()=>{if(!p.autoFetchJobContent||!O){I(!0),R(!1);return}if(!nA.test(O)){I(!p.requiredJobId);return}let e=++ae.current,t=!1;async function n(){I(!1),R(!0),N(e=>({...e,contents:``}));try{let[n,i]=await Promise.all([xn(O),w?dA(O).catch(()=>``):Promise.resolve(``)]),o=mA(n),s=await oA(o.contents||``,l,r),u=s.contents;if(u.trim())try{u=await wn(u,o.subject||a)}catch(n){!t&&e===ae.current&&c.message.warning(n?.message||`Mail content formatting failed. Showing original content.`)}if(t||e!==ae.current)return;i&&j(i),N(e=>({...e,subject:o.subject||e.subject,to:p.configured?e.to:o.toMail?.length?Array.isArray(o.toMail)?o.toMail.join(`, `):String(o.toMail):e.to,cc:o.ccMail?.length?Array.isArray(o.ccMail)?o.ccMail.join(`, `):String(o.ccMail):e.cc,bcc:o.bccMail?.length?Array.isArray(o.bccMail)?o.bccMail.join(`, `):String(o.bccMail):e.bcc,contents:u||s.contents||e.contents,attachments:s.attachments,showCc:e.showCc||!!o.ccMail?.length,showBcc:e.showBcc||!!o.bccMail?.length}))}catch(n){!t&&e===ae.current&&p.requiredJobId&&c.message.error(n?.message||`Could not load mail template for this Job ID`)}finally{!t&&e===ae.current&&(I(!0),R(!1))}}return n(),()=>{t=!0}},[O,p.autoFetchJobContent,p.configured,p.requiredJobId]);function se(e=E){let t=String(e??``).trim();if(!nA.test(t)){k(``),j(``),t&&c.message.warning(`Enter a valid 24-character Job ID`);return}if(p.autoFetchJobContent&&I(!1),t===O){k(``),queueMicrotask(()=>k(t));return}k(t)}function ce(e,t){if(t?.disabled)return;if(!e){k(``),D(``),j(``);return}let n=t?.label??``;D(String(n||(e??``))),j(n?String(n):``),se(e)}function U(e){let t=String(e??``).trim();if(D(t),t.length<3){B([]);return}H(!0),oe(t).then(e=>{let t=(Array.isArray(e)?e:[]).map(lA).filter(Boolean);B(t)}).catch(e=>c.message.error(e?.message||`Unable to search jobs`)).finally(()=>H(!1))}let W=bk(M.to).length>0,le=F&&(!p.requiredJobId||nA.test(O))&&(!p.requiredTo||W)&&wk(M.to)&&wk(M.cc)&&wk(M.bcc)&&(!p.requiredSubject||M.subject.trim().length>0)&&(!p.requiredBody||iA(M.contents));async function ue(){if(!(!le||ee)){te(!0);try{await Tn({jobId:O,toMail:bk(M.to),ccMail:bk(M.cc),bccMail:bk(M.bcc),subject:M.subject,contents:M.contents,attachments:M.attachments??[]}),c.message.success(`Mail sent successfully`),typeof o==`function`&&o({...M,message:M.contents,selectedIds:n}),e(-1)}catch(e){c.message.error(e?.message||`Failed to send mail`)}finally{te(!1)}}}function de(e){e?.to!==M.to&&(ne.current=!0),N(e)}let G=T?(0,u.jsxs)(`div`,{className:`mail-popup__job-row`,children:[(0,u.jsxs)(tA,{type:`secondary`,className:`mail-popup__field-label`,children:[`Job ID`,p.requiredJobId&&(0,u.jsx)(`span`,{className:`mail-popup__required-mark`,"aria-hidden":`true`,children:`*`})]}),w?(0,u.jsx)(c.Input,{value:A||O,readOnly:!0,className:`mail-popup__job-input`,"aria-required":p.requiredJobId}):(0,u.jsx)(c.Select,{showSearch:!0,allowClear:!0,filterOption:!1,value:O||void 0,searchValue:E,onSearch:U,onChange:ce,onClear:()=>{k(``),D(``),B([])},placeholder:`Minimum 3 characters`,notFoundContent:V||L?(0,u.jsx)(c.Spin,{size:`small`}):null,options:z,className:`mail-popup__job-input`,"aria-required":p.requiredJobId})]}):null;return(0,u.jsx)(c.Drawer,{open:!0,placement:`right`,onClose:()=>e(-1),closable:!1,rootClassName:`mail-popup`,width:620,maskClosable:!1,footer:(0,u.jsxs)(`div`,{className:`mail-popup__footer`,children:[(0,u.jsx)(c.Button,{onClick:()=>e(-1),children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,loading:ee,disabled:!le,onClick:ue,children:`Send`})]}),children:(0,u.jsx)(c.Spin,{spinning:L,description:`Loading mail content...`,size:`large`,children:(0,u.jsx)(Bk,{value:M,onChange:de,moduleName:l,defaultTemplateId:m,templateApplyKey:p.autoFetchJobContent?O:``,ready:F,contextRecords:r,requiredTo:p.requiredTo,requiredSubject:p.requiredSubject,requiredBody:p.requiredBody,beforeFields:G})})})}var{Text:_A}=c.Typography,vA=e=>e===!0||e===1||e===`1`;function yA(e){return e?e.trim().split(/\s+/).slice(0,2).map(e=>e[0].toUpperCase()).join(``):`?`}function bA(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 xA(e){return e?e.email??e.emailId??e.emailAddress??``:``}function SA(e){return e?e.status?e.status:e.stage?e.stage:typeof e.isActive==`boolean`?e.isActive?`Active`:`Inactive`:``:``}function CA(e,t){let n=String(e?.type??``).trim().toLowerCase(),r=String(e?.renderType??``).trim().toLowerCase(),i=`${e?.field??``} ${e?.label??``}`.toLowerCase();if(!([`file`,`document`,`upload`].includes(n)||[`file`,`document`,`upload`].includes(r)||/resume|cv|document|attachment/i.test(i)))return e;let a=String(e?.field??``).trim().toLowerCase(),o=/resume|cv/.test(i),s=/document|attachment|file|upload/.test(i),c=t.filter(e=>{let t=String(e?.fieldName??e?.field??e?.formField??e?.key??``).trim().toLowerCase(),n=`${t} ${e?.fileName??``} ${e?.name??``}`.toLowerCase();return!!(t&&a&&t===a||t&&a&&(t.includes(a)||a.includes(t))||o&&/resume|cv/.test(n)||s&&(/document|attachment|file|upload|resume|cv/.test(n)||!t))}).map(t=>({name:t?.fileName||t?.name||t?.uploadedFileName||t?.originalName||e?.label||`Document`,url:t?.fileUrl||t?.downloadUrl||t?.signedUrl||t?.url||``,type:t?.mimeType||t?.contentType||t?.type})).filter(e=>e.url);return c.length?{...e,value:c,renderType:`document`}:e}function wA(e){let t=bu(e);return[...e].filter(e=>!vA(e.hideGroup)&&!vA(e.hideGroupInDetail)).filter(e=>xu(e,t)).sort((e,t)=>Number(e.order??0)-Number(t.order??0)).map(e=>({...e,fields:[...e.fields??[]].filter(e=>String(e.field??``).trim()!==``&&(e.show===void 0||vA(e.show))&&xu(e,t)).map(e=>({...e,label:Cu(e,t)})).sort((e,t)=>Number(e.order??0)-Number(t.order??0))})).filter(e=>e.fields.length)}function TA({record:e}){let t=bA(e),n=xA(e),r=SA(e);return!t&&!n?null:(0,u.jsxs)(`div`,{className:`preview-profile-card`,children:[(0,u.jsxs)(`div`,{className:`preview-profile-card__info`,children:[(0,u.jsx)(c.Avatar,{className:`preview-profile-card__avatar`,children:yA(t)}),(0,u.jsxs)(`div`,{className:`preview-profile-card__text`,children:[t&&(0,u.jsx)(`span`,{className:`preview-profile-card__name`,children:t}),n&&(0,u.jsx)(`span`,{className:`preview-profile-card__email`,children:n})]})]}),r&&(0,u.jsx)(c.Tag,{className:`preview-profile-card__status`,children:r})]})}function EA({fields:e,centralDocuments:t=[],recordValueMap:i={}}){let[a,o]=(0,s.useState)([]),[c,l]=(0,s.useState)(0),[d,f]=(0,s.useState)(!1);if(!e?.length)return null;function p(e,t){o(e),l(t),f(!0)}return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`div`,{className:`preview-field-grid`,children:e.map(e=>{let r=CA(e,t),a=r.value,o=r.renderType===`document`?n.in(a).filter(e=>e.url):[];return o.length?(0,u.jsxs)(`div`,{className:`preview-field-card preview-field-card--documents`,children:[(0,u.jsx)(`span`,{className:`preview-field-card__label`,children:r.label}),(0,u.jsx)(`div`,{className:`preview-document-list`,children:o.map((e,t)=>(0,u.jsxs)(`button`,{type:`button`,className:`preview-document-link`,onClick:()=>p(o,t),title:`Preview ${e.name||`document`}`,children:[(0,u.jsx)(`span`,{className:`preview-document-link__name`,children:e.name||`Document ${t+1}`}),(0,u.jsx)(`span`,{className:`preview-document-link__action`,children:`Preview`})]},`${e.url}-${t}`))})]},r.field??r.label):(0,u.jsxs)(`div`,{className:`preview-field-card`,children:[(0,u.jsx)(`span`,{className:`preview-field-card__label`,children:r.label}),(0,u.jsx)(`span`,{className:`preview-field-card__value`,children:(0,u.jsx)(xd,{field:r,record:i})})]},r.field??r.label)})}),(0,u.jsx)(r.t,{documents:a,open:d,onClose:()=>f(!1),initialIndex:c})]})}function DA(){let e=(0,f.useNavigate)(),{moduleName:t=``,record:r=null}=(0,f.useLocation)().state??{},i=r?.id??r?._id,[a,o]=(0,s.useState)([]),[l,d]=(0,s.useState)(!!(t&&i)),[p,m]=(0,s.useState)(null),[h,g]=(0,s.useState)([]),[_,v]=(0,s.useState)(0),y=(0,s.useRef)(null),b=(0,s.useRef)(null),x=(0,s.useRef)([]),S=(0,s.useRef)([]),C=(0,s.useMemo)(()=>wA(a),[a]),w=(0,s.useMemo)(()=>bu(a),[a]);(0,s.useEffect)(()=>{if(!t||!i)return;let e=!1;return Promise.all([Xn({module:t,id:i,view:`detail`}),n.Un(t,i).catch(()=>({data:[]}))]).then(([t,n])=>{e||(o(Array.isArray(t)?t:[]),g(Array.isArray(n)?n:n?.data??[]),d(!1))}).catch(t=>{e||(m(t.message||`Failed to load preview`),g([]),d(!1))}),()=>{e=!0}},[t,i]);function T(){e(-1)}function E(e,t){return e?.label??e?.name??`Section ${t+1}`}function D(e){let t=y.current,n=S.current[e];if(!t||!n)return;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=(t.querySelector(`.preview-stepper-wrap`)?.offsetHeight??0)+12,o=t.scrollTop+i.top-r.top-a;v(e),t.scrollTo({top:Math.max(0,o),behavior:`smooth`})}function O(){let e=y.current;if(!e||!S.current.length)return;let t=e.getBoundingClientRect().top+(e.querySelector(`.preview-stepper-wrap`)?.offsetHeight??0)+24,n=0;S.current.forEach((e,r)=>{e&&e.getBoundingClientRect().top<=t&&(n=r)}),v(e=>e===n?e:n)}(0,s.useEffect)(()=>{let e=b.current,t=x.current[_];if(!e||!t)return;let n=t.offsetLeft-(e.clientWidth-t.offsetWidth)/2,r=Math.max(0,e.scrollWidth-e.clientWidth),i=Math.min(Math.max(0,n),r);typeof e.scrollTo==`function`?e.scrollTo({left:i,behavior:`smooth`}):e.scrollLeft=i},[_,C.length]);function k(){return C.length?(0,u.jsx)(`div`,{ref:b,className:`preview-stepper-wrap`,"aria-label":`Preview sections`,children:(0,u.jsx)(`div`,{className:`preview-stepper`,children:C.map((e,t)=>(0,u.jsxs)(`div`,{className:`preview-stepper__segment`,children:[(0,u.jsxs)(`button`,{type:`button`,className:`preview-stepper__item`,ref:e=>{x.current[t]=e},onClick:()=>D(t),"aria-current":_===t?`step`:void 0,title:`Go to ${E(e,t)}`,children:[(0,u.jsx)(`span`,{className:[`preview-stepper__circle`,t<_?`preview-stepper__circle--done`:``,t===_?`preview-stepper__circle--active`:``].filter(Boolean).join(` `),children:t+1}),(0,u.jsx)(`span`,{className:[`preview-stepper__label`,t===_?`preview-stepper__label--active`:``].filter(Boolean).join(` `),children:E(e,t)})]}),t<C.length-1&&(0,u.jsx)(`span`,{className:[`preview-stepper__line`,t<_?`preview-stepper__line--done`:``].filter(Boolean).join(` `),"aria-hidden":`true`})]},e.name??e.id??t))})}):null}let A=(0,u.jsxs)(`div`,{className:`preview-modal-header`,children:[(0,u.jsx)(`span`,{className:`preview-modal-module`,children:t.toUpperCase()}),(0,u.jsx)(`span`,{className:`preview-modal-title`,children:t?` Details`:`Preview`})]}),j=(0,u.jsx)(`div`,{className:`wizard-footer preview-scroll-footer`,children:(0,u.jsx)(`div`,{className:`wizard-footer-nav`,children:(0,u.jsx)(c.Button,{onClick:T,children:`Close`})})});function M(){return!t||!i?(0,u.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:`Preview id is missing.`}):l?(0,u.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:(0,u.jsx)(c.Spin,{size:`small`})}):p?(0,u.jsx)(`div`,{className:`job-preview-content job-preview-status job-preview-error`,children:p}):C.length?(0,u.jsx)(`div`,{className:`preview-section-list`,children:C.map((e,t)=>(0,u.jsxs)(`section`,{ref:e=>{S.current[t]=e},className:`preview-section-card`,"data-section-index":t,children:[(0,u.jsxs)(`div`,{className:`preview-section-card__header`,children:[(0,u.jsx)(`span`,{className:`preview-section-card__number`,children:t+1}),(0,u.jsx)(`span`,{className:`preview-section-card__title`,children:E(e,t)})]}),(0,u.jsx)(`div`,{className:`preview-section-card__body`,children:e.fields?.length>0?(0,u.jsx)(EA,{fields:e.fields,centralDocuments:h,recordValueMap:w}):(0,u.jsx)(_A,{type:`secondary`,children:`No fields in this group.`})})]},e.name??e.id??t))}):(0,u.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:`No form groups found.`})}return(0,u.jsx)(c.Modal,{centered:!0,className:`wizard-modal preview-modal preview-scroll-modal`,footer:j,open:!0,title:A,width:`min(900px, calc(100vw - 32px))`,onCancel:T,mask:{closable:!1},children:(0,u.jsxs)(`div`,{ref:y,className:`wizard-body preview-scroll-body`,onScroll:O,children:[!l&&!p&&C.length>0&&k(),r&&(0,u.jsx)(TA,{record:r}),M()]})})}var{Text:OA}=c.Typography;function kA({moduleName:e=`candidate`,backPath:t=``}){let n=(0,f.useNavigate)(),r=(0,f.useLocation)(),i=(0,f.useParams)().id,a=!!r.state?.background,[o,d]=(0,s.useState)(null),p=(0,s.useCallback)(()=>{n(a?-1:t||`/${e}s`)},[a,n,t,e]),m=o?.name||o?.fullName||o?.candidateName||[o?.firstName,o?.lastName].filter(Boolean).join(` `)||`Details`,h=(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`baseline`,gap:12,paddingRight:32},children:[(0,u.jsx)(`span`,{style:{fontWeight:600},children:m}),i&&(0,u.jsxs)(f.Link,{to:`/${e}s/detailview/${i}`,style:{fontSize:13,fontWeight:400,whiteSpace:`nowrap`},children:[(0,u.jsx)(l.ExportOutlined,{}),` Open full page`]})]});return(0,u.jsx)(c.Modal,{open:!0,title:h,onCancel:p,footer:null,width:`92vw`,style:{top:24,maxWidth:1400},styles:{body:{maxHeight:`85vh`,overflow:`auto`,padding:0}},destroyOnHidden:!0,children:i?(0,u.jsx)(Yp,{moduleName:e,id:i,onHeaderData:d}):(0,u.jsx)(`div`,{style:{padding:24},children:(0,u.jsx)(OA,{type:`secondary`,children:`No record id.`})})})}kA.propTypes={moduleName:p.default.string,backPath:p.default.string};var{Text:AA}=c.Typography,{TextArea:jA}=c.Input,MA=[{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 NA(e){switch(e.type){case`select`:return(0,u.jsx)(c.Select,{placeholder:e.placeholder,options:e.options,style:{width:`100%`}});case`textarea`:return(0,u.jsx)(jA,{rows:3,placeholder:e.placeholder});case`number`:return(0,u.jsx)(c.InputNumber,{placeholder:e.placeholder,style:{width:`100%`}});default:return(0,u.jsx)(c.Input,{type:e.inputType||`text`,placeholder:e.placeholder})}}function PA({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,u.jsxs)(`div`,{className:`wizard-review-content`,children:[r.map(e=>(0,u.jsxs)(`div`,{className:`wizard-review-section`,children:[(0,u.jsx)(AA,{className:`wizard-review-section-title`,children:e.title}),(0,u.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,u.jsxs)(`div`,{className:`wizard-review-row`,children:[(0,u.jsx)(`span`,{className:`wizard-review-label`,children:e.label}),(0,u.jsx)(`span`,{className:`wizard-review-separator`,children:`:`}),(0,u.jsx)(`span`,{className:`wizard-review-value`,children:r})]},e.name)})})]},e.key)),(0,u.jsxs)(`div`,{className:`wizard-review-confirm-note`,children:[(0,u.jsx)(l.CheckCircleOutlined,{className:`wizard-review-confirm-icon`}),(0,u.jsx)(AA,{type:`secondary`,children:`Please review the information above before submitting.`})]})]}):(0,u.jsx)(`div`,{className:`wizard-review-empty`,children:(0,u.jsx)(AA,{type:`secondary`,children:`No data entered yet.`})})}function FA(){let[e]=c.Form.useForm(),t=(0,f.useNavigate)(),{title:n=`Wizard`,moduleName:r=``,steps:i=MA,onSubmit:a}=(0,f.useLocation)().state??{},[o,l]=(0,s.useState)(0),d=i[o],p=o===i.length-1,m=o===0;function h(){t(-1)}function g(){let t=(d.fields||[]).map(e=>e.name);e.validateFields(t.length>0?t:void 0).then(()=>{l(e=>e+1)})}function _(){l(e=>e-1)}function v(){let n=e.getFieldsValue();typeof a==`function`&&a(n),t(-1)}let y=i.map((e,t)=>({title:e.title,description:e.description,status:t<o?`finish`:t===o?`process`:`wait`})),b=r?`${n} — ${r}`:n;return(0,u.jsxs)(c.Modal,{open:!0,title:b,footer:(0,u.jsxs)(`div`,{className:`wizard-footer`,children:[(0,u.jsx)(c.Button,{onClick:h,children:`Cancel`}),(0,u.jsxs)(`div`,{className:`wizard-footer-nav`,children:[!m&&(0,u.jsx)(c.Button,{onClick:_,children:`Back`}),p?(0,u.jsx)(c.Button,{type:`primary`,onClick:v,children:`Submit`}):(0,u.jsx)(c.Button,{type:`primary`,onClick:g,children:`Next`})]})]}),onCancel:h,width:`min(680px, calc(100vw - 32px))`,centered:!0,className:`wizard-modal`,children:[(0,u.jsx)(`div`,{className:`wizard-steps-container`,children:(0,u.jsx)(c.Steps,{current:o,items:y,size:`small`,className:`wizard-steps`})}),(0,u.jsx)(`div`,{className:`wizard-body`,children:(0,u.jsxs)(c.Form,{form:e,layout:`vertical`,children:[i.filter(e=>!e.isReview).map((e,t)=>(0,u.jsx)(`div`,{style:{display:t===o?`block`:`none`},children:(0,u.jsx)(c.Row,{gutter:16,children:(e.fields||[]).map(e=>(0,u.jsx)(c.Col,{span:e.span||24,children:(0,u.jsx)(c.Form.Item,{name:e.name,label:e.label,rules:[...e.required?[{required:!0,message:`${e.label} is required`}]:[],...e.rules||[]],children:NA(e)})},e.name))})},e.key)),d.isReview&&(0,u.jsx)(PA,{steps:i,form:e})]})})]})}function IA({titleText:e,titleIcon:t}){let n=t===`delete`;return(0,u.jsxs)(`span`,{className:`dynamic-popup__header`,children:[(0,u.jsx)(`span`,{className:`dynamic-popup__header-icon-box${n?` dynamic-popup__header-icon-box--danger`:``}`,children:n?(0,u.jsx)(l.DeleteOutlined,{}):(0,u.jsx)(l.AppstoreOutlined,{})}),(0,u.jsx)(`span`,{className:`dynamic-popup__header-label`,children:e})]})}function LA({note:e,description:t,showSelectedCount:r,count:i,itemLabel:a,bodyText:o,deleteError:s}){return(0,u.jsxs)(u.Fragment,{children:[e&&(0,u.jsx)(n.Zn,{variant:`body`,color:`secondary`,className:`dynamic-popup__note`,children:e}),t&&(0,u.jsx)(n.Zn,{variant:`body`,className:`dynamic-popup__description`,children:t}),r&&i>0&&(0,u.jsxs)(n.Zn,{variant:`body`,className:`dynamic-popup__selected-count`,children:[`Changing status for `,(0,u.jsx)(`strong`,{children:i}),` selected `,a,`.`]}),o&&(0,u.jsx)(n.Zn,{variant:`body`,children:o}),s&&(0,u.jsx)(n.Zn,{variant:`caption`,color:`danger`,className:`dynamic-popup__error`,children:s})]})}function RA({footerNote:e}){return e?(0,u.jsx)(n.Zn,{variant:`caption`,color:`secondary`,className:`dynamic-popup__footer-note`,children:e}):null}function zA(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t?.[n]??``).trim()}function BA(e){return String(e).replace(/\(\s*\)/g,``).replace(/\s+/g,` `).replace(/(^|\s)([-–—·|])(?=\s*\2)/g,``).replace(/^[\s\-–—·|]+/,``).replace(/[\s\-–—·|]+$/,``).trim()}function VA(e){if(!e)return!1;let t=new Date(e).getTime();return Number.isNaN(t)||t<=0?!1:t<=Date.now()+864e5}function HA(e){if(!VA(e))return``;let t=new Date(e),n=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date,i=Math.round((n(r)-n(t))/864e5);if(i<=0)return`Today`;if(i===1)return`Yesterday`;if(i<=30)return`${i} days ago`;let a=(r.getFullYear()-t.getFullYear())*12+(r.getMonth()-t.getMonth());if(r.getDate()<t.getDate()&&--a,a=Math.max(1,a),a<12)return`${a} month${a===1?``:`s`} ago`;let o=Math.floor(a/12);return`${o} year${o===1?``:`s`} ago`}function UA(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 WA(e){let t=Array.isArray(e?.submissionHistory)?e.submissionHistory:[],n=[e?.lastSubmittedAt,e?.submittedAt,...t.map(e=>e?.submittedAt)].filter(Boolean);return n.length?n.reduce((e,t)=>new Date(t)>new Date(e)?t:e):null}function GA(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:HA(UA(e))}:e,o=(i?BA(zA(i,a)):null)||(n?e?.[n]:null)||e?.name||e?.fullName||e?.candidateName||e?.title||e?.displayName||e?.text||e?.applicantReferenceId||e?.applicantRefrenceId||String(Object.values(e||{})[0]??``),s=(r?e?.[r]:null)??e?.id??e?._id??e?.applicantReferenceId??e?.applicantRefrenceId??String(Object.values(e||{})[0]??``),c=e?.disabled===!0||e?.disable===!0,l=String(e?.optionNote??``).trim(),u={label:l?`${String(o)} — ${l}`:String(o),value:String(s),_raw:e};if(c&&(u.disabled=!0),l&&(u.title=l),e?.isSubmitted===!0||e?.alreadySubmitted===!0){u.alreadySubmitted=!0,u.existingSubmissionId=String(e?.existingSubmissionId??e?.jobSubmissionId??e?.submissionId??``);let t=e?.submittedAt||WA(e);t&&(u.submittedAt=t)}if(e?.isFromSubmission===!0&&e?.submissionId){u.isFromSubmission=!0,u.priorSubmissionId=String(e.submissionId);let t=e?.lastSubmittedAt||WA(e);t&&(u.priorSubmittedAt=t)}return u}function KA(e,t){return(t?.[e.optionsKey]??e.defaultOptions??[]).map(t=>GA(t,e))}function qA(e={}){return{selectedIds:[],selectedRecords:[],moduleName:``,removedIds:[],...e}}var JA=`DD MMM YYYY`,YA=`DD MMM YYYY, h:mm A`;function XA(e,t){if(e==null||e===``)return``;let n=(0,d.default)(e);return n.isValid()?t===`relative`?HA(e)||(VA(e)?n.format(JA):`Not updated`):VA(e)?n.format(JA):``:String(e)}function ZA(e,t){return e?String(e).includes(`{`)?BA(zA(e,t)):String(t?.[e]??e).trim():``}function QA(e){if(e?.alreadySubmitted){let t=e?.submittedAt?(0,d.default)(e.submittedAt):null;return{tone:`blocked`,tooltip:t?.isValid()?`Already submitted to this job on ${t.format(YA)}`:`Already submitted to this job — a candidate can only be submitted once per job`}}if(e?.isFromSubmission){let t=e?.priorSubmittedAt?(0,d.default)(e.priorSubmittedAt):null;return{tone:`history`,tooltip:t?.isValid()?`Previously submitted on ${t.format(YA)} — this form will prefill from it`:`Submitted to another job before — this form will prefill from it`}}return null}function $A(e,t){return e?.alreadySubmitted||!e?.disabled?``:String(t?.message??e?.title??``).trim()}function ej({meta:e}){return(0,u.jsx)(`div`,{className:`dynamic-popup__option-dates`,children:e.map(e=>(0,u.jsxs)(s.Fragment,{children:[(0,u.jsx)(`span`,{className:`dynamic-popup__option-date-label`,children:e.label}),(0,u.jsx)(`span`,{className:`dynamic-popup__option-date-value`,children:e.text})]},e.label))})}function tj({option:e,layout:t}){let n=e?._raw??e??{},r=ZA(t.id,n),i=ZA(t.title,n)||String(e?.label??``),a=ZA(t.subtitle,n),o=ZA(t.titleAccent?.key,n),s=ZA(t.titleAccent?.toneKey,n),d=t.titleAccent?.prefix??``,f=(t.meta??[]).map(e=>({label:e.label,text:XA(n?.[e.key],e.type)||e.emptyText||``})).filter(e=>e.text),p=$A(e,n),m=QA(e);return(0,u.jsxs)(`div`,{className:`dynamic-popup__option`,children:[(0,u.jsx)(`span`,{className:`dynamic-popup__option-tick${m?` dynamic-popup__option-tick--${m.tone}`:``}`,children:m&&(0,u.jsx)(c.Tooltip,{title:m.tooltip,placement:`topLeft`,children:(0,u.jsx)(l.CheckCircleFilled,{"aria-label":m.tooltip})})}),(0,u.jsxs)(`div`,{className:`dynamic-popup__option-main`,children:[(0,u.jsxs)(`div`,{className:`dynamic-popup__option-head`,children:[r&&(0,u.jsx)(`span`,{className:`dynamic-popup__option-id`,children:r}),(0,u.jsxs)(`span`,{className:`dynamic-popup__option-title`,children:[(0,u.jsx)(`span`,{className:`dynamic-popup__option-title-text`,children:i}),o&&(0,u.jsx)(`span`,{className:`dynamic-popup__option-title-accent${s?` dynamic-popup__option-title-accent--${s}`:``}`,children:`${d}${o}`})]}),p&&(0,u.jsx)(`span`,{className:`dynamic-popup__option-flag`,children:p})]}),a&&(0,u.jsx)(`div`,{className:`dynamic-popup__option-sub`,children:a})]}),e?.alreadySubmitted?(0,u.jsx)(`span`,{className:`dynamic-popup__option-onjob`,children:`On this job`}):f.length>0&&(0,u.jsx)(ej,{meta:f})]})}var{Text:nj}=c.Typography,{TextArea:rj}=c.Input,ij=[{label:`$`,value:`$`},{label:`EUR`,value:`EUR`},{label:`GBP`,value:`GBP`},{label:`INR`,value:`INR`}],aj=[{label:`Hourly`,value:`Hourly`},{label:`Daily`,value:`Daily`},{label:`Weekly`,value:`Weekly`},{label:`Monthly`,value:`Monthly`},{label:`Yearly`,value:`Yearly`}];function oj(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 sj({field:e,value:t,onChange:n}){return(0,u.jsx)(c.Input,{value:t,onChange:n,placeholder:e.placeholder,maxLength:e.maxLength,prefix:(0,u.jsx)(l.CrownOutlined,{})})}function cj({field:e,value:t,onChange:n}){return(0,u.jsx)(rj,{value:t,onChange:n,rows:e.rows??5,placeholder:e.placeholder})}function lj({field:e,options:t,value:n,onChange:r}){let i=oj(t);return(0,u.jsx)(c.Select,{showSearch:!0,value:n,onChange:r,options:i,placeholder:e.placeholder,className:`dynamic-popup__field-select`,optionFilterProp:`label`,optionRender:dj,prefix:(0,u.jsx)(l.CrownOutlined,{})})}function uj({field:e,options:t,value:n,onChange:r}){let i=oj(t);return(0,u.jsx)(c.Select,{mode:`multiple`,showSearch:!0,value:n,onChange:r,options:i,placeholder:e.placeholder,className:`dynamic-popup__field-select`,optionFilterProp:`label`,optionRender:dj,prefix:(0,u.jsx)(l.CrownOutlined,{})})}function dj(e){let t=e?.data??e;return!t?.assigned&&!t?.assignedTag?e?.label:(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8},children:[(0,u.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e?.label}),(0,u.jsx)(c.Tag,{color:`default`,style:{marginInlineEnd:0},children:t.assignedTag??`Assigned`})]})}var fj=3;function pj({field:e,options:t,onSearch:n,searchLoading:r=!1,value:i,onChange:a,popupContext:o}){let d=oj(t),f=e.optionLayout,p=new Map(d.map(e=>[String(e?.value??``),e])),m=e.multiSelect||e.multiple||e.mode===`multiple`?`multiple`:e.mode,h=m===`multiple`||m===`tags`,g=e.searchMinLength??fj,[_,v]=(0,s.useState)(``),y=(0,s.useRef)(null),b=(0,s.useRef)(!1);async function x(t,n){let r=Array.isArray(t)?Array.isArray(n)?n:t.map(e=>p.get(String(e??``))).filter(Boolean):n??p.get(String(t??``));(typeof e.onSelectGuard!=`function`||await e.onSelectGuard({value:t,option:r,field:e,popupContext:o,confirm:c.Modal.confirm})!==!1)&&a?.(t)}function S(e){v(e),b.current=!1,n?.(e)}function C(e){e.key===`Enter`&&r&&n&&!h&&_.trim()&&(b.current=!0,e.preventDefault())}(0,s.useEffect)(()=>{if(r||!b.current)return;b.current=!1;let e=d.find(e=>e&&!e.disabled);e&&Promise.resolve(x(e.value,e)).finally(()=>y.current?.blur())},[r]);let w=!!n&&_.trim().length>0&&_.trim().length<g,T=(0,u.jsxs)(`div`,{className:`dynamic-popup__search-status`,role:`status`,"aria-live":`polite`,style:{display:`flex`,alignItems:`center`,gap:8,padding:`10px 12px`,color:`#8c8c8c`},children:[(0,u.jsx)(c.Spin,{size:`small`}),(0,u.jsx)(`span`,{children:_.trim().length>=g?`Searching "${_.trim()}"…`:`Loading…`})]}),E=e.notFoundContent??null;return n&&r?E=T:n&&E===null&&_.trim().length>=g&&(E=(0,u.jsx)(`div`,{style:{padding:`10px 12px`,color:`#8c8c8c`},children:`No matches found`})),(0,u.jsx)(c.Select,{ref:y,mode:m,showSearch:!0,filterOption:!1,notFoundContent:E,loading:!!n&&r,value:i,onChange:x,options:d,placeholder:e.placeholder,onSearch:n?S:void 0,onKeyDown:C,popupRender:n?e=>(0,u.jsxs)(u.Fragment,{children:[w&&!r?(0,u.jsx)(`div`,{style:{padding:`6px 12px`,fontSize:12,color:`#8c8c8c`},children:`Type at least ${g} characters to search — showing recent`}):null,r?T:e]}):void 0,className:`dynamic-popup__field-select${f?` dynamic-popup__field-select--rich`:``}`,popupClassName:f?`dynamic-popup__option-dropdown`:void 0,listHeight:f?340:void 0,optionLabelProp:`label`,optionRender:f?e=>(0,u.jsx)(tj,{option:e?.data??e,layout:f}):void 0,prefix:(0,u.jsx)(l.CrownOutlined,{})})}function mj({field:e,mentionOpts:t,onMentionSearch:n,value:r,onChange:i}){let a=Number(e.maxLength)>0?Number(e.maxLength):void 0,o=String(r??``).length;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Mentions,{value:r,onChange:i,rows:e.rows??5,placeholder:e.placeholder,prefix:`@`,options:t,onSearch:n,maxLength:a,className:`dynamic-popup__mention-textarea`}),a?(0,u.jsxs)(`div`,{className:`dynamic-popup__char-count`,style:{textAlign:`right`,fontSize:12,marginTop:4,color:o>a*.9?`#b45309`:`#8c8c8c`},children:[o,` / `,a]}):null]})}function hj({field:e={},value:t={},onChange:n}){let r=t.period??`Hourly`,i=t.isRange??!1;function a(e){n?.({...t,...e})}(0,s.useEffect)(()=>{let e={};t.currency??(e.currency=`$`),t.period??(e.period=`Hourly`),Object.keys(e).length&&n?.({...t,...e})},[]);let o=Number(i?t.maxAmount:t.amount),l=i&&t.minAmount!=null&&t.maxAmount!=null&&Number(t.maxAmount)<=Number(t.minAmount),d=e.rateCeiling!=null&&Number.isFinite(o)&&o>Number(e.rateCeiling);return(0,u.jsxs)(`div`,{children:[(0,u.jsxs)(c.Space.Compact,{style:{width:`100%`},children:[i?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.InputNumber,{controls:!1,placeholder:`From`,value:t.minAmount,onChange:e=>a({minAmount:e}),style:{flex:1}}),(0,u.jsx)(c.InputNumber,{controls:!1,placeholder:`To`,value:t.maxAmount,onChange:e=>a({maxAmount:e}),style:{flex:1}})]}):(0,u.jsx)(c.InputNumber,{controls:!1,placeholder:`0`,value:t.amount,onChange:e=>a({amount:e}),style:{flex:2}}),(0,u.jsx)(c.Select,{value:t.currency??`$`,options:ij,onChange:e=>a({currency:e}),style:{width:80}}),(0,u.jsx)(c.Select,{value:r,options:aj,onChange:e=>a({period:e}),style:{width:110}})]}),(l||d)&&(0,u.jsxs)(`div`,{style:{marginTop:4},children:[l&&(0,u.jsx)(nj,{type:`danger`,style:{fontSize:12,display:`block`},children:`To rate must be greater than From rate.`}),d&&(0,u.jsxs)(nj,{type:`danger`,style:{fontSize:12,display:`block`},children:[`Rate must not exceed the client rate (`,e.rateCeiling,`).`]})]}),(0,u.jsxs)(c.Space,{size:`small`,style:{marginTop:8},children:[(0,u.jsx)(c.Switch,{checked:i,onChange:e=>a({isRange:e})}),(0,u.jsx)(`span`,{children:`Range`})]})]})}function gj({field:e,value:t,onChange:n}){return(0,u.jsx)(c.DatePicker,{value:t,onChange:n,placeholder:e.placeholder??`Select date`,style:{width:`100%`},format:`YYYY-MM-DD`})}function _j({field:e,checked:t,onChange:n}){return(0,u.jsx)(c.Checkbox,{checked:t,onChange:n,children:e.checkboxLabel})}function vj({field:e,value:t,onChange:n}){return(0,u.jsx)(c.InputNumber,{value:t,onChange:n,min:e.min,max:e.max,placeholder:e.placeholder,style:{width:`100%`}})}function yj({options:e,value:t,onChange:n}){return(0,u.jsx)(c.Radio.Group,{value:t,onChange:n,options:e})}var bj={input:sj,text:sj,textarea:cj,select:lj,"multi-select":uj,"search-select":pj,"mention-textarea":mj,"candidate-rate":hj,"priority-checkbox":_j,"date-picker":gj,number:vj,radio:yj};function xj(e){return e===`priority-checkbox`?{valuePropName:`checked`}:{}}var Sj=new Set([`input`,`text`,`textarea`,`mention-textarea`]);function Cj({form:e,fields:t,initialValues:r,dynamicOptions:i,popupContext:a,extraData:o,removedIds:l,setRemovedIds:d,onRemoveAssigned:f,showAlreadyAssigned:p,onValuesChange:m,getSearchHandler:h,searchLoading:g={},getMentionSearchHandler:_,mentionOptions:v}){let[y,b]=(0,s.useState)([]),x=(o?.recruitersData??[]).filter(e=>{let t=String(e?.user_id??e?.id??e?.userId??``);return t&&!l.includes(t)}),S=p&&o,C=new Set(p?x.map(e=>String(e?.user_id??e?.id??e?.userId??``).trim()).filter(Boolean):[]),w=e=>C.size===0||!Array.isArray(e)?e:e.map(e=>{let t=String((e&&typeof e==`object`?e.value??e.id:e)??``).trim();return!C.has(t)||!e||typeof e!=`object`?e:{...e,disabled:!0,assigned:!0,assignedTag:`Assigned`,title:e.title??`Already assigned to this job`}});return!t.length&&!S?null:(0,u.jsxs)(u.Fragment,{children:[S&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`dynamic-popup__already-assigned`,children:[(0,u.jsx)(n.Zn,{variant:`caption`,color:`secondary`,children:`Already Assigned People`}),(0,u.jsx)(`div`,{style:{marginTop:6,display:`flex`,flexWrap:`wrap`,gap:6},children:x.length===0?(0,u.jsx)(n.Zn,{variant:`caption`,color:`secondary`,children:`No one is currently assigned to this job.`}):x.map(e=>{let t=String(e?.user_id??e?.id??e?.userId??``),n=e?.name??e?.user_name??e?.userName??e?.email??`Assigned user`,r=y.includes(t);return(0,u.jsxs)(c.Tag,{closable:!r,onClose:async n=>{if(n.preventDefault(),!(!t||r)){b(e=>Array.from(new Set([...e,t])));try{typeof f==`function`&&await f({id:t,recruiter:e}),d(e=>Array.from(new Set([...e,t]))),c.message.success(`User unassigned successfully`)}catch(e){c.message.error(e?.message??`Failed to unassign user`)}finally{b(e=>e.filter(e=>e!==t))}}},children:[r&&(0,u.jsx)(c.Spin,{size:`small`,style:{marginRight:6}}),n]},t||n)})})]}),(0,u.jsx)(c.Divider,{style:{margin:`12px 0`}})]}),t.length>0&&(0,u.jsx)(c.Form,{form:e,layout:`vertical`,initialValues:r,onValuesChange:(e,t)=>m(t),children:wj(t).map(e=>Tj(e,e=>{let t=w(i[e.name]??KA(e,a)),r=h(e),o=_(e),s=v[e.name]??[],l=xj(e.type),d=bj[e.type],f=[];return e.required&&f.push({required:!0,message:`${e.label||`This field`} is required`}),typeof e.validator==`function`&&f.push({validator:(t,n)=>{let r=e.validator(n,a);return r?Promise.reject(Error(r)):Promise.resolve()}}),Sj.has(e.type)&&f.push(n.On({label:e.label,field:e.name,type:e.type})),(0,u.jsx)(c.Form.Item,{name:e.name,label:e.label,rules:f,...l,children:d?(0,u.jsx)(d,{field:e,options:t,onSearch:r,searchLoading:!!g[e.name],mentionOpts:s,onMentionSearch:o,popupContext:a}):null},e.name)}))})]})}function wj(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 Tj(e,t){return e.length===1?t(e[0]):(0,u.jsx)(`div`,{style:{display:`flex`,gap:8,alignItems:`flex-start`},children:e.map((e,n)=>(0,u.jsx)(`div`,{style:{flex:n===0?2:1,minWidth:0},children:t(e)},e.name))},`row-${e.map(e=>e.name).join(`-`)}`)}function Ej(e){return[`select`,`multi-select`,`search-select`,`radio`].includes(e?.type)&&e?.dataSource===`master`&&e?.masterName}function Dj(e){let t=e?.data??e;return Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.items)?t.items:Array.isArray(t?.rows)?t.rows:Array.isArray(t?.records)?t.records:[]}function Oj(e){let t=String(e?.masterName??``).trim().toLowerCase();return t===`clientsubmissions`||t===`clientsubmissionstatus`}function kj(e){if(e==null)return null;if(typeof e==`string`){let t=e.trim();return t?{label:t,value:t,_raw:{name:t}}:null}let t=String(e?.name??e?.clientSubmissionStatusText??e?.label??e?.text??``).trim();if(!t)return null;let n=Number(e?.id??e?.uniqueId??e?.clientSubmissionStatusId??e?.value??0)||0;return{label:t,value:t,_raw:{...e,...n>0?{id:n,uniqueId:n}:{},name:t,type:String(e?.type??e?.clientSubmissionStatusType??``).trim(),isInitialStatus:e?.isInitialStatus===!0,isTerminalStatus:e?.isTerminalStatus===!0,allowedNextStatusIds:Array.isArray(e?.allowedNextStatusIds)?e.allowedNextStatusIds.map(Number).filter(e=>Number.isInteger(e)&&e>0):[]}}}function Aj(e,t){return Oj(t)?kj(e):GA(e,t)}function jj(e){let t=e?.clientSubmissionStatus,n=Number((t&&typeof t==`object`?t?.clientSubmissionStatusId??t?.id??t?.uniqueId:void 0)??e?.clientSubmissionStatusId??e?.clientStatusId??e?.[`clientSubmissionStatus.clientSubmissionStatusId`]??0)||0,r=t&&typeof t==`object`?t?.clientSubmissionStatusText??t?.name??t?.text??t?.label:t;return{id:n,text:String(r??e?.clientSubmissionStatusText??e?.clientStatus??e?.clientStatusText??e?.[`clientSubmissionStatus.clientSubmissionStatusText`]??``).trim()}}function Mj(e){let t=Number(e?.id??0)||0,n=String(e?.text??``).trim();return n&&n.toLowerCase()===`not submitted`?!0:t<=0&&!n}function Nj(e){return Number(e?._raw?.id??e?._raw?.uniqueId??0)||0}function Pj(e){let t=e?._raw?.allowedNextStatusIds;return Array.isArray(t)?t.map(Number).filter(e=>Number.isInteger(e)&&e>0):[]}function Fj(e){let t=e?.data??e;return t?Array.isArray(t)?t[0]??null:t?.record&&typeof t.record==`object`?t.record:t?.data&&typeof t.data==`object`&&!Array.isArray(t.data)?t.data:typeof t==`object`?t:null:null}function Ij(e){return(Array.isArray(e?.selectedRecords)?e.selectedRecords.filter(Boolean):[]).some(e=>!Mj(jj(e)))?!0:!Mj(jj(e??{}))}async function Lj(e,n){if(Ij(e))return e;let r=e?.selectedIds?.[0]??e?.selectedRecords?.[0]?._id??e?.selectedRecords?.[0]?.id;if(!r)return e;let i=String(e?.moduleName??`submissions`).trim()||`submissions`,a=new URLSearchParams({module:i,id:String(r)});n&&a.set(`app_id`,n);try{let r=Fj(await t.o(t.x,`/module-data-detail?${a.toString()}`,{headers:n?{"X-App-Id":n}:void 0}));if(!r)return e;let i=Array.isArray(e?.selectedRecords)?e.selectedRecords:[];return{...e,selectedRecords:i.length?i.map((e,t)=>t===0?{...e,...r}:e):[r]}}catch(t){return console.warn(`[DynamicPopup] Could not load selected submission detail for client status transition:`,t),e}}function Rj(e,t){if(!Array.isArray(e)||!e.length)return[];if(!e.some(e=>e?._raw?.isInitialStatus===!0||e?._raw?.isTerminalStatus===!0||Array.isArray(e?._raw?.allowedNextStatusIds)))return e;let n=Array.isArray(t?.selectedRecords)?t.selectedRecords.filter(Boolean):[],r={clientSubmissionStatus:t?.clientSubmissionStatus,clientSubmissionStatusId:t?.clientSubmissionStatusId,clientSubmissionStatusText:t?.clientSubmissionStatusText,clientStatus:t?.clientStatus,clientStatusId:t?.clientStatusId,clientStatusText:t?.clientStatusText,"clientSubmissionStatus.clientSubmissionStatusId":t?.[`clientSubmissionStatus.clientSubmissionStatusId`],"clientSubmissionStatus.clientSubmissionStatusText":t?.[`clientSubmissionStatus.clientSubmissionStatusText`]},i=n.length?n:[r];return e.filter(t=>i.every(n=>{let i=jj(n);if(Mj(i)){let e=jj(r);Mj(e)||(i=e)}if(Mj(i))return t?._raw?.isInitialStatus===!0;let a=e.find(e=>{let t=Nj(e),n=String(e?.label??``).trim();return i.id>0&&t===i.id||i.text&&n.toLowerCase()===i.text.toLowerCase()});return!a||a?._raw?.isTerminalStatus===!0?!1:Pj(a).includes(Nj(t))}))}function zj({open:e,config:n,api:r,fields:i,popupContext:a,formValues:o}){let[c,l]=(0,s.useState)({}),[u,d]=(0,s.useState)(null);return(0,s.useEffect)(()=>{e||(l({}),d(null))},[e]),(0,s.useEffect)(()=>{if(!e||!n||!r.getOptions)return;let t=new AbortController;return i.forEach(e=>{!e.fetchOptionsKey||e.fetchOptionsParamKey||Promise.resolve(r.getOptions(e,void 0,a)).then(n=>{t.signal.aborted||l(t=>({...t,[e.name]:n}))}).catch(n=>{t.signal.aborted||console.error(`[DynamicPopup] Failed to load options for field "${e.name}":`,n)})}),()=>t.abort()},[e,r,n,i,a]),(0,s.useEffect)(()=>{if(!e||!n)return;let r=i.filter(Ej);if(!r.length)return;let o=new AbortController;return r.forEach(e=>{let n=new URLSearchParams({masterName:e.masterName,offset:`0`,limit:String(e.limit??50)}),r=String(t.b??``).trim();r&&n.set(`app_id`,r),t.o(t.x,`/masters/dropdown?${n.toString()}`,{headers:r?{"X-App-Id":r}:void 0}).then(async t=>{if(o.signal.aborted)return;let n=Dj(t).map(t=>Aj(t,e)).filter(Boolean),i=a;if(Oj(e)&&(i=await Lj(a,r)),o.signal.aborted)return;let s=Oj(e)?Rj(n,i):n;l(t=>({...t,[e.name]:s}))}).catch(t=>{o.signal.aborted||console.error(`[DynamicPopup] Failed to load master options for field "${e.name}":`,t)})}),()=>o.abort()},[e,n,i,a]),(0,s.useEffect)(()=>{if(!e||!n||!r.getOptions)return;let t=i.filter(e=>e.fetchOptionsKey&&e.fetchOptionsParamKey);if(!t.length)return;let s=new AbortController;return t.forEach(e=>{let t=o[e.fetchOptionsParamKey]??a[e.fetchOptionsParamKey],n={[e.fetchOptionsParamKey]:t};Promise.resolve(r.getOptions(e,n,a)).then(t=>{s.signal.aborted||l(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,r,n,i,o,a]),(0,s.useEffect)(()=>{if(!e||!n||!r.loadExtraData)return;let t=new AbortController;return Promise.resolve(r.loadExtraData(a)).then(e=>{t.signal.aborted||d(e)}).catch(e=>{t.signal.aborted||(console.error(`[DynamicPopup] Failed to load extra data:`,e),d(null))}),()=>t.abort()},[e,r,n,a]),{dynamicOptions:c,setDynamicOptions:l,extraData:u}}var Bj=400,Vj=3,Hj=Object.freeze({});function Uj({api:e,open:t,fields:n=[],popupContext:r,setDynamicOptions:i,getFieldValue:a}){let[o,c]=(0,s.useState)({}),[l,u]=(0,s.useState)({}),d=(0,s.useCallback)((e,t)=>{u(n=>!!n[e]===t?n:{...n,[e]:t})},[]),f=(0,s.useRef)({}),p=(0,s.useRef)({}),m=(0,s.useRef)({}),h=(0,s.useRef)({}),g=(0,s.useRef)({}),_=(0,s.useCallback)((t,n)=>{let o=e.searchOptions??e.searchFetcher;if(typeof o!=`function`)return;p.current[t.name]?.abort();let s=new AbortController;return p.current[t.name]=s,h.current[t.name]=n,g.current[t.name]=!0,d(t.name,!0),Promise.resolve(o(t,n,r)).then(e=>{if(s.signal.aborted)return;let n=(Array.isArray(e)?e:e?.items??e?.list??[]).map(e=>GA(e,t)),o=t.initialOptionKey?r[t.initialOptionKey]:null,c=Array.isArray(o)?o:o?[o]:[],l=new Set(n.map(e=>e.value)),u=c.filter(e=>!l.has(e.value)),f=a?.(t.name),p=new Set((Array.isArray(f)?f:[f]).filter(e=>e!=null&&e!==``).map(String));i(e=>{let r=p.size?(e[t.name]??[]).filter(e=>p.has(String(e?.value))&&!l.has(e?.value)&&!u.some(t=>t.value===e?.value)):[];return{...e,[t.name]:[...u,...n,...r]}}),g.current[t.name]=!1,d(t.name,!1)}).catch(e=>{s.signal.aborted||(g.current[t.name]=!1,d(t.name,!1),console.error(`[DynamicPopup] Search failed for field "${t.name}":`,e))}),s},[e,r,i,a,d]),v=n.filter(e=>(e.searchFetchKey||e.searchFetcher)&&e.preloadOptions!==!1),y=v.map(e=>e.name).join(`|`),b=(0,s.useRef)({runSearch:_,preloadFields:v});(0,s.useEffect)(()=>{b.current={runSearch:_,preloadFields:v}}),(0,s.useEffect)(()=>{if(!t||!y)return;let{runSearch:e,preloadFields:n}=b.current,r=n.map(t=>e(t,``)).filter(Boolean);return()=>{r.forEach(e=>e.abort()),u({})}},[t,y]);function x(t){if(!t.searchFetchKey&&!t.searchFetcher||typeof(e.searchOptions??e.searchFetcher)!=`function`)return;let n=t.searchMinLength??Vj;return e=>{clearTimeout(f.current[t.name]);let r=String(e??``).trim(),i=r.length<n?``:r;if(i===``&&h.current[t.name]===``){d(t.name,!!g.current[t.name]);return}d(t.name,!0),f.current[t.name]=setTimeout(()=>{_(t,i)},Bj)}}function S(t){let n=e.getMentionOptions??e.mentionFetcher;if(typeof n==`function`)return e=>{m.current[t.name]?.abort();let i=new AbortController;m.current[t.name]=i,Promise.resolve(n(t,e,r)).then(e=>{if(i.signal.aborted)return;let n=Array.isArray(e)?e:e?.items??e?.list??[];c(e=>({...e,[t.name]:n.map(e=>({value:e.user_name??e.userName??e.username??String(e),label:e.user_name??e.userName??e.username??String(e)}))}))}).catch(e=>{i.signal.aborted||console.error(`[DynamicPopup] Mention search failed for field "${t.name}":`,e)})}}return{mentionOptions:o,searchLoading:t?l:Hj,getSearchHandler:x,getMentionSearchHandler:S}}function Wj({form:e,config:t,api:n,popupContext:r,resolvedIds:i,dynamicOptions:a,extraData:o,removedIds:l,removalOnlySubmit:u=!1,fields:d,onClose:f,onSubmit:p}){let[m,h]=(0,s.useState)(!1),[g,_]=(0,s.useState)(null);async function v(e){let t={resolvedIds:i,dynamicOptions:a,extraData:o,removedIds:l};if(typeof n.submit==`function`)return n.submit(e,r,t);if(typeof p==`function`)return p(e,r,t)}function y(){if(t){if(!d.length){if(t.mode===`delete`&&typeof n.deleteItems==`function`){h(!0),_(null),Promise.resolve(n.deleteItems(i,r)).then(()=>{c.message.success(t.successMessage||`Deleted successfully`),f({success:!0})}).catch(e=>{let t=e?.message||`Delete failed. Please try again.`;_(t),h(!1),c.message.error(t)});return}if(typeof n.onOk==`function`){h(!0),Promise.resolve(n.onOk(r)).then(()=>f({success:!0})).catch(e=>{let t=e?.message||`Failed. Please try again.`;c.message.error(t),h(!1)});return}if(typeof n.submit==`function`){h(!0),Promise.resolve(v({})).then(e=>{e?.navigated||(c.message.success(t.successMessage||`Saved successfully`),f({success:!0}))}).catch(e=>{c.message.error(e?.message||`Failed. Please try again.`)}).finally(()=>h(!1));return}f();return}if(u){h(!0),Promise.resolve(v(e.getFieldsValue())).then(e=>{e?.navigated||(c.message.success(t.successMessage||`Saved successfully`),f({success:!0}))}).catch(e=>{c.message.error(e?.message||`Failed. Please try again.`)}).finally(()=>h(!1));return}e.validateFields().then(async e=>{h(!0);try{if((await v(e))?.navigated)return;c.message.success(t.successMessage||`Saved successfully`),f({success:!0})}catch(e){c.message.error(e?.message||`Failed. Please try again.`)}finally{h(!1)}}).catch(()=>{})}}function b(){h(!1),_(null)}return{handleOk:y,confirming:m,deleteError:g,resetSubmitState:b}}function Gj(e){return!!(e.multiSelect||e.multiple||e.mode===`multiple`)}function Kj({open:e=!0,config:t,context:n={},onClose:r,onSubmit:i,api:a={}}){let[o]=c.Form.useForm(),[l,f]=(0,s.useState)({}),[p,m]=(0,s.useState)([]),h=c.Form.useWatch([],o,{preserve:!0})??{},g=(0,s.useMemo)(()=>qA(n),[n]),{selectedIds:_=[],selectedRecords:v=[],moduleName:y=``}=g,b=(0,s.useMemo)(()=>_.map((e,t)=>{let n=v[t];return n?.id??n?._id??e}),[_,v]),x=(0,s.useMemo)(()=>t?typeof t.getFields==`function`?t.getFields(g):t.fields??[]:[],[t,g]),S=(0,s.useMemo)(()=>{let e={};return x.forEach(t=>{if(t.initialOptionKey){let n=g[t.initialOptionKey],r=Array.isArray(n)?n:n?[n]:[];if(!r.length)return;e[t.name]=Gj(t)?r.map(e=>e.value):r[0].value;return}let n=g[t.initialValueKey];!t.initialValueKey||n===void 0||(e[t.name]=t.type===`date-picker`?(0,d.default)(n):n)}),e},[x,g]),{dynamicOptions:C,setDynamicOptions:w,extraData:T}=zj({open:e,config:t,api:a,fields:x,popupContext:g,formValues:l}),{mentionOptions:E,searchLoading:D,getSearchHandler:O,getMentionSearchHandler:k}=Uj({api:a,open:e,fields:x,popupContext:g,setDynamicOptions:w,getFieldValue:(0,s.useCallback)(e=>o.getFieldValue(e),[o])});(0,s.useEffect)(()=>{if(!e)return;let t={};x.forEach(e=>{if(!e.initialOptionKey)return;let n=g[e.initialOptionKey],r=Array.isArray(n)?n:n?[n]:[];r.length&&(t[e.name]=r)}),Object.keys(t).length&&w(e=>({...e,...t}))},[e,x,g]);function A(e){typeof r==`function`&&r(e)}let j=x.filter(e=>e.required),M=j.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)}),N=(g.removedIds??[]).length,P=p.length>N,F=j.some(e=>{let t=h[e.name];return!(t==null||t===``||Array.isArray(t)&&t.length===0)}),{handleOk:I,confirming:L,deleteError:R,resetSubmitState:z}=Wj({form:o,config:t,api:a,popupContext:g,resolvedIds:b,dynamicOptions:C,extraData:T,removedIds:p,removalOnlySubmit:!!t?.allowRemovalOnlySubmit&&P&&!F,fields:x,onClose:A,onSubmit:i});(0,s.useEffect)(()=>{e&&(o.resetFields(),f(S??{}),m(g.removedIds??[]),z())},[e,S]);let B=!!t?.autoSubmitWhenNoFields&&x.length===0;(0,s.useEffect)(()=>{!e||!B||I()},[e,B]);let V=_.length,H=String(y).replace(/s$/i,``),ee=V===1?H:y,te=v[0]??{},ne=t?.getTitleText?t.getTitleText(V,ee,te,g):t?.title,re=V===1?te.jobTitle??te.title??te.name??te.fullName??te.candidateName??null:null,ie=t?.getBodyText?t.getBodyText(V,H,ee,re,g):t?.bodyText??null,ae=typeof t?.getNote==`function`?t.getNote(g):t?.note,oe=t?.disabledUntilFilled&&!M&&!P;if(!t||!e||B)return null;let se=t.component;return se?(0,u.jsx)(c.Modal,{open:e,title:t.title||t.getTitleText?(0,u.jsx)(IA,{titleText:ne,titleIcon:t.titleIcon}):null,footer:null,width:t.width??760,centered:!0,maskClosable:!1,onCancel:()=>A(),className:`dynamic-popup${t.className?` ${t.className}`:``}`,children:(0,u.jsx)(se,{context:g,selectedIds:b,selectedRecords:v,moduleName:y,onClose:A})}):(0,u.jsxs)(c.Modal,{open:e,title:(0,u.jsx)(IA,{titleText:ne,titleIcon:t.titleIcon}),okText:t.okText||`OK`,cancelText:t.cancelText??`Cancel`,onOk:I,onCancel:()=>A(),okButtonProps:{danger:t.okButtonDanger,disabled:oe,loading:L},cancelButtonProps:{disabled:L},closable:!L,maskClosable:!1,width:t.width??480,centered:!0,className:`dynamic-popup${t.className?` ${t.className}`:``}`,children:[(0,u.jsx)(LA,{note:ae,description:t.description,showSelectedCount:t.showSelectedCount,count:V,itemLabel:ee,bodyText:ie,deleteError:R}),(0,u.jsx)(RA,{footerNote:t.footerNote}),(0,u.jsx)(Cj,{form:o,fields:x,initialValues:S,dynamicOptions:C,popupContext:g,extraData:T,removedIds:p,setRemovedIds:m,onRemoveAssigned:a.removeAssignedUser?e=>a.removeAssignedUser(e,g):void 0,showAlreadyAssigned:t.showAlreadyAssigned,onValuesChange:f,getSearchHandler:O,searchLoading:D,getMentionSearchHandler:k,mentionOptions:E})]})}var qj={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:[]},Jj={deleteItems:async(e,t)=>{await ae(t.moduleName,e)}},Yj=new Map;async function Xj(e){return e?(Yj.has(e)||Yj.set(e,o.r({module:e}).catch(t=>(Yj.delete(e),console.warn(`[in-progress gate] could not read ${e} form groups:`,t),[]))),Yj.get(e)):[]}function Zj(e=[],t){return e.some(e=>{let r=n.F(e,t);return r&&r.severity!==`allow`})}async function Qj({targetModule:e,sourceModule:t,recordId:r,region:i}={}){let a={severity:`allow`,message:``,group:null};if(!e||!t||!r)return a;let s=i??n.fr().region;try{let i=await Xj(e);if(!Zj(i,s))return a;let c=await o.r({module:t,id:r}),l={};for(let e of c){let t=e?.payloadKey||e?.name;t&&Array.isArray(e?.rows)&&(l[t]=e.rows)}return n.z(i,s,l)}catch(e){return console.warn(`[in-progress gate] check skipped:`,e),a}}var $j=`Already submitted`,eM=`submissions`,tM=`candidates`,nM=864e5,rM=90,iM=`This candidate was created or last updated more than 90 days ago. Only candidates created or updated within the last 90 days can be selected. Please update this candidate first.`,aM=[`createdAt`,`createdDate`,`dateCreated`,`created_on`,`createdOn`],oM=[`updatedAt`,`updatedDate`,`lastUpdatedAt`,`lastUpdatedDate`,`modifiedAt`,`modifiedDate`];function sM(e,t){for(let n of t){let t=e?.[n];if(!t)continue;let r=new Date(t);if(!Number.isNaN(r.getTime()))return r}return null}function cM(e){return sM(e,aM)}function lM(e){return sM(e,oM)}function uM(e){if(!(e instanceof Date)||Number.isNaN(e.getTime()))return null;let t=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();return Math.max(0,Math.floor((t(new Date)-t(e))/nM))}function dM(e){return e===null?``:e<=14?`green`:e<=89?`yellow`:`red`}function fM(e,t=rM){if(!e)return!1;let n=Date.now()-t*nM,r=cM(e),i=lM(e),a=r&&r.getTime()>=n,o=i&&i.getTime()>=n;return!a&&!o}var pM=6e4;function mM(e){let t=cM(e),n=oM.map(t=>e?.[t]).find(e=>VA(e)),r=n?new Date(n?.$date??n):null;return r&&!Number.isNaN(r.getTime())&&(!t||r.getTime()-t.getTime()>pM)?r:t}function hM(e){let t=mM(e);if(!t||!VA(t))return{createdAgo:``,createdAgoTone:``};let n=HA(t);return n?{createdAgo:n,createdAgoTone:dM(uM(t))}:{createdAgo:``,createdAgoTone:``}}function gM(e){for(let t of[`applicantRefrenceId`,`applicantReferanceId`,`applicantReferenceId`]){let n=e?.[t];if(typeof n==`string`&&n.trim())return n.trim()}return``}function _M(e){return{...e,applicantRefrenceId:gM(e),...hM(e),isStaleCandidate:fM(e)}}function vM(e){return String(e?.applicantId??e?._id??e?.id??``)}var yM=null;async function bM(){return yM||=n.fi(tM).then(e=>e?.strategies?.duplicateCheck?.editRoute??``).catch(()=>``),yM}async function xM(e){let t=vM(e);if(!t)return``;let n=await bM();return n?n.replace(/:(_?id)\b/g,encodeURIComponent(t)):``}async function SM({option:e,popupContext:t,confirm:n}){let r=e?._raw??e??{},i=vM(r);if(i){let e=await Qj({targetModule:eM,sourceModule:tM,recordId:i});if(e.severity===`block`)return new Promise(t=>{n({title:`This candidate cannot be submitted`,content:e.message,okText:`Pick someone else`,cancelText:`Close`,onOk:()=>t(!1),onCancel:()=>t(!1)})})}if(!fM(r))return!0;let a=t?.navigate;return!a||!i?!1:new Promise(e=>{n({title:`Candidate update required`,content:iM,okText:`OK`,cancelText:`Cancel`,onOk:async()=>{let t=await xM(r);t&&a(t),e(!1)},onCancel:()=>e(!1)})})}function CM(e,t,n){return{...e,label:`${e.label} - ${$j}`,disabled:!0,title:`${$j}${t?` (submission ${t})`:``}`,alreadySubmitted:!0,existingSubmissionId:t||``,...n?{submittedAt:n}:{}}}var wM={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 Te({searchQuery:t,candidateId:r})}catch{a=!1;let e=await Zn({searchQuery:t,candidateId:r});i=Array.isArray(e?.data)?e.data:[]}let o=i.map(e=>({label:[e.jobReferenceId??e.clientJobReferenceId,e.jobTitle].filter(Boolean).join(` - `)||String(e._id??``),value:e._id??``,_raw:e}));if(a)return o.map(e=>{if(e._raw?.isSubmitted||e._raw?.alreadySubmitted)return CM(e,e._raw?.jobSubmissionId||``,e._raw?.submittedAt||``);if(e._raw?.disable){let t=String(e._raw?.message??``).trim();return{...e,disabled:!0,label:t?`${e.label} - ${t}`:e.label,title:t}}return e});let s=await De({applicantId:r,jobIds:o.map(e=>e.value)}).catch(()=>new Map);return o.map(e=>{let t=s.get(String(e.value));return t?CM(e,t.submissionId,t.submittedAt):e})}if(e.searchFetchKey===`quickSubmitCandidates`){let e=n.selectedRecords?.[0]??{},r=n.jobId??e.jobId??e.id??e._id??n.selectedIds?.[0],i,a=new Map;try{i=await Ee({search:t,jobId:r})}catch{let e=await hs({isFromSubmission:n.isFromSubmission,jobId:r,submissionId:n.submissionId,search:t});i=Array.isArray(e)?e:[],a=await De({jobId:r,applicantIds:i.map(vM)}).catch(()=>new Map)}return i.map(e=>_M(e)).map(e=>{let t=a.get(vM(e));if(!(t||e?.isSubmitted===!0||e?.alreadySubmitted===!0))return e;let n=t?.submissionId||e?.jobSubmissionId||``,r=t?.submittedAt||e?.submittedAt||``;return{...e,disabled:!0,optionNote:$j,isSubmitted:!0,alreadySubmitted:!0,existingSubmissionId:n,...r?{submittedAt:r}:{}}})}return[]},submit:async(e,t,n)=>{let{navigate:r,selectedRecords:i=[],selectedIds:a=[],moduleName:o}=t,s=i[0]??{},c,l;t.jobId?(c=t.jobId,l=s.id??s._id??a[0]??``):o===`candidate`?(c=e.jobId??``,l=s.id??s._id??a[0]??``):(c=s.jobId??s.id??s._id??a[0]??``,l=e.candidate??``);let u=n?.dynamicOptions?.candidate?.find(e=>vM(e?._raw)===String(l)),d=n?.dynamicOptions?.jobId?.find(e=>String(e?.value)===String(c)),f=u?._raw?.isSubmitted||u?._raw?.alreadySubmitted||d?.alreadySubmitted||d?._raw?.isSubmitted||d?._raw?.alreadySubmitted;if(!c||!l)throw Error(`Select both a job and a candidate to quick submit.`);if(fM(u?._raw))throw Error(iM);let p=await Qj({targetModule:eM,sourceModule:tM,recordId:l});if(p.severity===`block`)throw Error(p.message);let m=f,h=u?._raw?.existingSubmissionId||u?._raw?.jobSubmissionId||d?.existingSubmissionId||d?._raw?.jobSubmissionId||``;try{let e=await we({jobId:c,applicantId:l});m||=!!e?.exists,h=e?.submissionId||h}catch(e){throw Error(`Could not verify existing submissions (${e?.message??`request failed`}). Please try again.`,{cause:e})}if(m)throw Error(`This candidate is already submitted for this job${h?` (submission ${h})`:``}.`);let g=new URLSearchParams;l&&g.set(`candidateId`,l);let _=u?.priorSubmissionId||u?._raw?.submissionId||d?.priorSubmissionId||d?._raw?.submissionId||``;_?(g.set(`submissionId`,String(_)),g.set(`isFromSubmission`,`true`)):g.set(`isFromSubmission`,`false`);let v=fs(ms({jobId:c,applicantId:l}).catch(()=>[]));return r(`/submission-create/${c}?${g.toString()}`,{state:{relevantSkillsToken:v}}),{navigated:!0}}},TM={title:`Submit`,okText:`Submit`,width:640,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getNote:e=>e.moduleName===`candidate`?`Note: Select a job to submit this candidate.`:`Note: Select a candidate to submit for this job`,getFields:e=>e.jobId?[]:e.moduleName===`candidate`?[{name:`jobId`,label:`Job list`,type:`search-select`,required:!0,placeholder:`Search Job ID / job name - or pick a recent job`,searchFetchKey:`quickSubmitJobList`,optionLayout:{id:`{jobReferenceId}`,title:`{jobTitle}`,subtitle:`{clientJobReferenceId}`,meta:[{label:`Created`,key:`createdAt`,type:`date`},{label:`Updated`,key:`updatedAt`,type:`relative`}]}}]:[{name:`candidate`,label:`Candidate`,type:`search-select`,required:!0,placeholder:`Search candidate name / email - or pick a recent candidate`,optionsKey:`candidateOptions`,searchFetchKey:`quickSubmitCandidates`,labelTemplate:`{applicantRefrenceId} - {firstName} {lastName} - {createdAgo}`,valueKey:`applicantId`,optionLayout:{id:`{applicantRefrenceId}`,title:`{firstName} {lastName}`,titleAccent:{key:`createdAgo`,toneKey:`createdAgoTone`,prefix:` - `},subtitle:`{designation} - {email}`,meta:[{label:`Created`,key:`createdAt`,type:`date`},{label:`Updated`,key:`updatedAt`,type:`date`,emptyText:`Not updated`}]},onSelectGuard:SM}]},EM={title:`Add Notes & Share`,okText:`Save & Share`,width:480,fields:[{name:`notes`,label:`Notes`,type:`mention-textarea`,required:!0,rows:5,maxLength:2e3,placeholder:`Add your notes on the job. Use '@' to mention someone.`,mentionFetchKey:`mentionUsers`}]},DM=e=>e?.data??e;async function OM({relatedId:e,notes:n,title:r,notesFor:i}){return DM(await Nn(t.x,`/notes`,{method:`POST`,body:JSON.stringify({relatedId:e,notes:n,title:r,notesFor:i})}))}var kM={getMentionOptions:async(e,t)=>se(t),submit:async(e,t)=>{let n=Array.isArray(t.selectedIds)?t.selectedIds[0]:t.selectedIds;if(!n)throw Error(`Please select a record before adding a note.`);await OM({relatedId:String(n),notes:e.notes,notesFor:t.moduleName})}},AM={name:`jobId`,label:`Job Title / ID`,type:`search-select`,required:!0,placeholder:`Minimum 3 characters`,searchFetchKey:`tagToJobJobList`,multiSelect:!0,valueKey:`_id`,labelTemplate:`{jobReferenceId} - {jobTitle} — {jobRecruitmentStatus}`,initialOptionKey:`jobOption`},jM={name:`hiringStage`,label:`Hiring stage`,type:`select`,required:!0,optionsKey:`hiringStageOptions`,defaultOptions:[{label:`Shortlisted`,value:`shortlisted`},{label:`Pipeline`,value:`pipeline`}],initialValueKey:`hiringStage`},MM={title:`Tag to Jobs`,okText:`Tag`,width:480,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getFields:e=>e.jobId&&e.hiringStage?[]:[AM,jM]},NM=e=>e?.data??e;function PM(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 FM(e){return e?Array.isArray(e.data)?e.data.map(PM):e.stage&&Array.isArray(e.stage.data)?e.stage.data.map(PM):Array.isArray(e)?e.map(PM):[]:[]}async function IM(e=1,n=10){let r=await t.o(t.x,`/workflow/list/all?page=${e}&limit=${n}`),i=NM(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 LM(e,n){let r=NM(await t.o(t.x,`/workflow/${e}/stage/${n}`));return Array.isArray(r)?{data:r}:r}async function RM(e,n){if(!e||!n)return null;try{let r=new URLSearchParams({module:e,limit:`1`,offset:`0`,scope:`allJobs`,filters:JSON.stringify([{field:`_id`,op:`in`,values:[String(n)],operator:`and`}])}),i=NM(await t.o(t.x,`/module-data-list?${r}`));if(Array.isArray(i))return i[0]??null;if(i?.data&&Array.isArray(i.data))return i.data[0]??null;let a=i?.rows??i?.records??i?.items??i?.list;return Array.isArray(a)?a[0]??null:i??null}catch(t){return console.error(`[getModuleRecordById] failed: ${e}/${n}`,t),null}}async function zM(e){return NM(await t.o(t.T,`/source/workflow-instance`,{method:`POST`,body:JSON.stringify(e)}))}var BM={pipeline:`pipeline`,goodfited:`goodfited`,contacted:`contacted`,submitted:`submitted`,shortlisted:`shortlisted`,interviewinprogress:`interviewInprogress`,selected:`selected`};function VM(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 HM(e){let t=String(e??``).trim();return t?BM[t.toLowerCase()]??t:``}function UM(e,t){let n=VM(e,`candidateId`,`candidate_id`,`applicantId`,`applicantID`,`applicantReferenceId`,`applicantRefrenceId`,`_id`,`id`)??t;if(!n)return null;let r=(VM(e,`candidateName`,`candidate_name`,`fullName`,`name`)??[VM(e,`firstName`,`first_name`),VM(e,`lastName`,`last_name`)].filter(Boolean).join(` `))||void 0,i={candidateId:String(n),candidateName:r,phone:VM(e,`phone`,`phoneNumber`,`phone_number`,`mobile`,`mobileNumber`,`mobile_number`),source:VM(e,`source`,`sourceType`,`candidateSource`,`profileSource`),submittedAt:VM(e,`submittedAt`,`lastSubmittedAt`,`updatedAt`),remarks:VM(e,`remarks`,`comment`,`comments`,`notes`),assignedRecruiter:VM(e,`assignedRecruiter`,`recruiterName`,`ownerName`,`assignedToName`),screeningStatus:VM(e,`screeningStatus`,`screening.status`,`screeningResult`),screeningScore:VM(e,`screeningScore`,`screening.score`,`score`),assignedDate:VM(e,`assignedDate`,`assignedAt`,`createdAt`)};return Object.fromEntries(Object.entries(i).filter(([,e])=>e!=null&&e!==``))}var WM={searchOptions:async(e,t)=>e.searchFetchKey===`tagToJobJobList`?oe(t):[],submit:async(e,t)=>{let n=e.jobId??t.jobId,r=Array.isArray(n)?n:[n].filter(Boolean),i=HM(e.hiringStage??t.hiringStage),a=Array.isArray(t.selectedIds)?t.selectedIds:[],o=Array.isArray(t.selectedRecords)?t.selectedRecords:[],s=Math.max(a.length,o.length,1);for(let e of r)for(let t=0;t<s;t+=1){let n=a[t]?String(a[t]):``,r=UM(o[t]??{},n);await zM({jobId:e,module:`jobs`,currentStage:i,...r?{candidateDetails:r}:{}})}let c=await le({jobId:n,candidateIds:t.selectedIds,hiringStage:i,hiriringStatusChangeType:t.hiriringStatusChangeType||`tagToJobs`});if(c?.status===!1)throw Error(c?.error||`Could not update hiring stage`)}},GM={title:`Change Status`,okText:`Apply`,width:420,showSelectedCount:!0,fields:[{name:`status`,label:`New Status`,type:`select`,required:!0,placeholder:`Select a status`,dataSource:`master`,masterName:`clientSubmissions`,labelKey:`name`,valueKey:`name`,initialValueKey:`currentStatus`,defaultOptions:[{label:`Active`,value:`active`},{label:`Inactive`,value:`inactive`},{label:`Pending`,value:`pending`},{label:`Closed`,value:`closed`}]}]};function KM(e,t){let n=String(e??``).trim().toLowerCase();return(Array.isArray(t?.status)?t.status:[]).find(e=>String(e?.value??``).trim().toLowerCase()===n||String(e?.label??``).trim().toLowerCase()===n||String(e?._raw?.name??``).trim().toLowerCase()===n)??null}var qM={submit:async(e,t,n)=>{let r=KM(e.status,n?.dynamicOptions),i=r?._raw??{},a={clientSubmissionStatusText:String(i.name??r?.label??e.status??``).trim(),clientSubmissionStatusId:Number(i.id??i.uniqueId??0)||0,clientSubmissionStatusType:String(i.type??``).trim()};await ie(t.moduleName,t.selectedIds,a)}},JM={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:[]},YM={onOk:async e=>{await Oe({jobId:e.jobId??e.selectedIds[0],candidateIds:e.selectedIds})}},XM={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`}]},ZM={getOptions:async e=>e.fetchOptionsKey===`candidateGroups`?ue():[],submit:async(e,t,{dynamicOptions:n})=>{let r=(n.groupId??[]).find(t=>String(t.value)===String(e.groupId));await de({candidateIds:t.selectedIds,groupId:e.groupId,groupName:r?.label??``})}},QM=[{title:`Name`,key:`name`,render:(e,t)=>t.name||`${t.first_name??``} ${t.last_name??``}`.trim()||t.user_name||`Assigned user`},{title:`Role`,dataIndex:`role_name`,key:`role`,render:e=>e||`-`},{title:`Reporting`,dataIndex:`reporting_name`,key:`reporting`,render:e=>e||`-`}];function $M({selectedIds:e,onClose:t}){let n=e?.[0],[r,i]=(0,s.useState)(!0),[a,o]=(0,s.useState)(!1),[d,f]=(0,s.useState)({assignedUsers:[],totalSubmissions:0,message:``}),[p,m]=(0,s.useState)([]);(0,s.useEffect)(()=>{let e=!1;return i(!0),Promise.all([fe(n).catch(t=>(e||c.message.error(t?.message??`Failed to load self-assign details`),{assignedUsers:[],totalSubmissions:0,message:``})),ge(n).catch(()=>({recruitersData:[]}))]).then(([t,n])=>{e||(f(t),m(Array.isArray(n?.recruitersData)?n.recruitersData:[]))}).finally(()=>{e||i(!1)}),()=>{e=!0}},[n]);let h=async()=>{o(!0);try{await G({jobIds:[n]}),c.message.success(`Job assigned successfully`),t?.({success:!0})}catch(e){c.message.error(e?.message??`Failed to assign job`)}finally{o(!1)}};if(r)return(0,u.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,u.jsx)(c.Spin,{size:`large`})});let g=p.map(e=>({user_id:e.recruiterId??e.id??e.user_id,name:e.name??``,role_name:e.role_name??e.roleName??``,reporting_name:e.reporting_name??e.reportingName??``})),_=new Map(g.map(e=>[String(e.user_id??``),e])),v=(d.assignedUsers?.length??0)>0?d.assignedUsers.map(e=>{let t=e.user_id??e.userId??e.recruiterId??e.id,n=_.get(String(t??``))??{};return{...e,user_id:t,name:n.name||e.name||``,role_name:n.role_name||e.role_name||e.roleName||``,reporting_name:n.reporting_name||e.reporting_name||e.reportingName||``}}):g,y=v.length>0;return(0,u.jsxs)(`div`,{className:`self-assign-popup-body`,children:[y?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`div`,{style:{fontWeight:700,marginBottom:8},children:`Team Members Allocated`}),(0,u.jsx)(c.Table,{columns:QM,dataSource:v,pagination:!1,rowKey:e=>e.user_id??`${e.first_name}-${e.last_name}`,size:`small`,className:`mb-3 no-header-bg`,scroll:{y:200}}),(0,u.jsxs)(`div`,{className:`warning-card`,style:{display:`flex`,alignItems:`center`,gap:8,marginTop:12},children:[(0,u.jsx)(l.ExclamationCircleFilled,{style:{color:`#faad14`,fontSize:18}}),(0,u.jsx)(`div`,{style:{fontSize:13},children:`These users are already assigned to this job. Do you still want to assign yourself as well?`})]})]}):(0,u.jsx)(`div`,{style:{padding:`8px 0`},children:d.message||`No one is currently assigned to this job. Do you want to assign yourself?`}),(0,u.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:12,marginTop:24},children:[(0,u.jsx)(c.Button,{size:`small`,onClick:()=>t?.(),disabled:a,children:`No`}),(0,u.jsx)(c.Button,{type:`primary`,size:`small`,onClick:h,loading:a,children:`Yes`})]})]})}$M.propTypes={selectedIds:p.default.array,onClose:p.default.func};var eN={title:`Self Assign`,width:480,className:`self-assign-modal`,component:$M},tN={submit:async()=>{}};function nN(e={}){let t=Array.isArray(e.jobPayDetails)?e.jobPayDetails[e.jobPayDetails.length-1]:e.jobPayDetails??e.clientBudget??{},n=Number(t.clientBudgetEnd),r=Number(t.clientBudgetStart);return Number.isFinite(n)&&n>0?n:Number.isFinite(r)&&r>0?r:null}var rN={getTitleText:(e,t,n)=>{let r=n?.jobTitle||n?.title||``;return r?`Assign - ${r}`:`Assign`},okText:`Assign`,width:520,disabledUntilFilled:!0,showAlreadyAssigned:!0,allowRemovalOnlySubmit:!0,getFields:e=>(nN(e?.selectedRecords?.[0]??{}),[{name:`assignToUserId`,label:`Assign to`,type:`multi-select`,required:!0,placeholder:`Select recruiter(s)`,fetchOptionsKey:`assignToUsers`}])},iN={getOptions:async(e,t,n)=>e.fetchOptionsKey===`assignToUsers`?me(n?.selectedIds?.[0]):[],loadExtraData:async e=>ge(e.selectedIds[0]),removeAssignedUser:async({id:e},t)=>_e({jobId:t.selectedIds[0],userId:e}),submit:async(e,t,{removedIds:n,extraData:r})=>{await ve({jobIds:t.selectedIds,userId:e.assignToUserId,removedIds:n,existingRecruiters:r?.recruitersData})}},aN={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`}]},oN={getMentionOptions:async(e,t)=>se(t),submit:async(e,t)=>{let n=e.targetDate?e.targetDate.toISOString():``;t.editingNoteId?await U(t.editingNoteId,{title:e.heading,targetDate:n,notes:e.comments}):await ce({relatedIds:t.selectedIds,module:t.moduleName,title:e.heading,targetDate:n,notes:e.comments}),window.dispatchEvent(new Event(`sticky-notes:refresh`))}},sN={title:`Move to Onboarding`,bodyText:`Are you sure you want to move this candidate to onboarding?`,okText:`Yes`,cancelText:`No`,width:420,successMessage:`Moved to onboarding successfully`,successNavigate:`/onboarding`,fields:[{name:`sendOnboardingEmail`,type:`priority-checkbox`,checkboxLabel:`Send Onboarding Email`}]},cN={submit:async(e,t)=>{await ye({submissionId:t.selectedRecords?.[0]?.submissionId,isMail:e.sendOnboardingEmail})}};function lN(e){return Array.isArray(e)?e[e.length-1]??{}:e&&typeof e==`object`?e:{}}var uN={USD:`$`,INR:`₹`,EUR:`€`,GBP:`£`};function dN(e,t,n){let r=lN(e?.[t])[n];if(r!=null&&r!==``)return r;let i=e?.[`${t}.${n}`];return i!=null&&i!==``?i:void 0}function fN(e){let t=e.selectedRecords?.[0]??{},n=dN(t,`candidateRate`,`candidateAcceptedRate`)??dN(t,`candidateBudget`,`candidateBudgetStart`);if(n===void 0||Number(n)===0)return null;let r=dN(t,`candidateRate`,`candidateAcceptedCurrency`)??dN(t,`candidateBudget`,`candidateBudgetCurrency`);return{amount:n,symbol:dN(t,`candidateRate`,`candidateAcceptedCurrencySymbol`)??dN(t,`candidateBudget`,`candidateBudgetCurrencySymbol`)??uN[String(r??``).toUpperCase()]??(r||`$`),unit:dN(t,`candidateRate`,`candidateAcceptedPayUnit`)??dN(t,`candidateBudget`,`candidateBudgetUnit`)??``}}var pN={title:`Approve Rate`,okText:`Approve`,width:520,className:`medium-modal`,successMessage:`Rate approved`,getBodyText:(e,t,n,r,i)=>{let a=fN(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=fN(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`}]}]},mN={submit:async(e,t)=>{let n=t.selectedIds[0];if(await be(n,{candidateProposedRate:e.candidateProposedRate,candidateProposedRateCurrency:e.candidateProposedRateCurrency,candidateProposedRateUnit:e.candidateProposedRateUnit,submitVia:e.submitVia}),e.submitVia===`VMS`)try{await xe(n)}catch{c.message.warning(`Approved. VMS notification could not be sent — use Send Mail to notify the client.`)}else c.message.info(`Approved — use Send Mail to notify the client.`)}};async function hN(e,n={}){let r=t.u();if(!r){let e=Error(`Authentication required`);throw e.status=401,e}let i=await fetch(`${t.D}${e}`,{...n,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${r}`,...n.headers}});if(i.status===401&&t.h(),!i.ok){let e=Error(`API ${i.status}: ${i.statusText}`);throw e.status=i.status,e}return i.json()}async function gN(e){let t=await hN(`/mail-form?${new URLSearchParams({submissionId:e,submissionType:`manager`}).toString()}`);return t.data??t}function _N(...e){return e.map(e=>e==null?``:String(e).trim()).find(Boolean)??``}var vN=(e,t)=>!!e&&e.toLowerCase()===_N(t).toLowerCase();function yN(e,t,n){let r=_N(t.submittedBy);return _N(vN(r,n)||vN(r,e.submitSource)||vN(r,e.supplierName)||vN(r,e.source)||vN(r,e.candidateSource)?``:r,e.recruitingUserName,e.recruitingUserEmail,e.signatureEmail)}function bN(e,t={}){let n=yy(e,t.employerName);return{client:t.clientName??e.clientName,role:t.jobTitle??e.jobTitle??e.designation,reqId:t.reqId??e.jobClientRefrenceId??e.mspReqId??e.submissionId,name:t.candidateName||[e.firstName,e.lastName].filter(Boolean).join(` `)||e.candidateFullName,location:t.jobLocation??e.city??e.currentLocation??e.jobLocation,vendor:n,submittedBy:yN(e,t,n),submittedAt:t.createdAt??e.createdAt,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function xN(e){return Array.isArray(e)?e[e.length-1]:e}function SN(e={}){let t=xN(e?.proposedRate)?.candidateProposedRate??e?.candidateProposedRate??e?.proposedRateValue,n=Number(t);return Number.isFinite(n)?n:0}function CN(e,t={}){let n=xN((e?.record?.job??e?.job??t?.job??{})?.jobPayDetails)??{},r=e?.record?.submission??t??{},i=xN(r?.clientBudget)??r?.clientBudget??{},a=n?.clientBudgetEnd??n?.clientBudgetStart??i?.clientBudgetEnd??i?.clientBudgetStart,o=Number(a);return Number.isFinite(o)?o:0}function wN(e={}){let t=String(e?.currencyRaw??``).trim().toUpperCase(),n=String(e?.currency??``).trim();return n&&!/^[A-Z]{3}$/i.test(n)?n:t===`USD`||n.toUpperCase()===`USD`?`$`:t===`INR`||n.toUpperCase()===`INR`?`₹`:t===`EUR`||n.toUpperCase()===`EUR`?`€`:t===`GBP`||n.toUpperCase()===`GBP`?`£`:n||t}function TN(e={}){return String(e?.rateUnit??`hr`).trim().replace(/^\/+/,``)||`hr`}function EN(e,t={}){let n=Number(e);return Number.isFinite(n)?`${wN(t)}${n}/${TN(t)}`:``}function DN(e,t,n){if(n==null||n===``)return String(e??``);let r=String(e??``),i=String(n),a=!1,o=RegExp(`(<(?:td|th)[^>]*>[\\s\\S]*?${t}[\\s\\S]*?</(?:td|th)>\\s*<(?:td|th)[^>]*>)([\\s\\S]*?)(</(?:td|th)>)`,`gi`);r=r.replace(o,(e,t,n,r)=>(a=!0,`${t}${i}${r}`));let s=RegExp(`(<(?:strong|b)[^>]*>\\s*${t}\\s*:?\\s*</(?:strong|b)>\\s*)([\\s\\S]*?)(?=</(?:li|p|div)>)`,`gi`);if(r=r.replace(s,(e,t)=>(a=!0,`${t}${i}`)),!a){let e=RegExp(`(${t}\\s*:?[ \\t]*)([^<\\r\\n]*)`,`gi`);r=r.replace(e,(e,t)=>`${t}${i}`)}return r}function ON(e,t,n,r,i){let a=Number(n?.proposedRate),o=Number.isFinite(a)?a:SN(t),s=Number(n?.clientJobRate),c=Number.isFinite(s)&&s>0?s:CN(r,i),l={proposedRate:o,jobBillRate:c},u=String(e??``).replace(/{{\.?((?:proposedRate)|(?:jobBillRate))}}/g,(e,t)=>{let n=l[t];return n==null?e:String(n)});return u=DN(u,`(?:Proposed\\s*Rate|Pay\\s*Rate)`,EN(o,n)),u=DN(u,`(?:Job\\s*)?Bill\\s*Rate`,EN(c,n)),u}function kN(e){let t=e?.$oid??e?._id?.$oid??e?._id??e?.id?.$oid??e?.id??e;if(t==null||typeof t==`object`)return``;let n=String(t).trim();return/^[a-f\d]{24}$/i.test(n)?n:``}function AN(...e){for(let t of e){let e=[t?.jobId,t?.JobId,t?.job_id,t?.jobDetails?._id,t?.jobDetails?.id,t?.job?._id,t?.job?.id,t?.submission?.jobId,t?.submission?.JobId,t?.submission?.job_id,t?.submission?.jobDetails?._id,t?.submission?.jobDetails?.id,t?.submission?.job?._id,t?.submission?.job?.id,t?.recordMeta?.jobId,t?.recordMeta?.JobId,t?.recordMeta?.job_id,t?.submission?.recordMeta?.jobId,t?.submission?.recordMeta?.JobId,t?.submission?.recordMeta?.job_id].map(kN).find(Boolean);if(e)return e}return``}function jN(e){if(!e?.referralId)return{};let t=Number(e.referralRate??e.referalRate??0)||0,n=String(e.referralType??e.referalType??`RECURRING`).trim()||`RECURRING`,r=e.referralId??e.referalId;return{referralId:r,referalId:r,referralRate:t,referalRate:t,referralType:n,referalType:n,referralEnabled:!0,referalEnabled:!0,isReferralApplicable:!0,referralDetails:{referralId:r,referalId:r,referralRate:t,referalRate:t,referralType:n,referalType:n,referralEnabled:!0,referalEnabled:!0,isReferralApplicable:!0}}}function MN(e=``){return String(e??``).replace(/map\[[^\]]*(?:resume|document|attachment|file)[^\]]*\]/gi,``).replace(/<p>\s*<\/p>/gi,``).replace(/(?:<br\s*\/?>\s*){3,}/gi,`<br><br>`).trim()}function NN(...e){for(let t of e){let e=[t?.candidateId,t?.applicantId,t?.candidate?._id,t?.candidate?.id,t?.submission?.candidateId,t?.submission?.applicantId,t?.recordMeta?.candidateId,t?.recordMeta?.applicantId].map(kN).find(Boolean);if(e)return e}return``}async function PN(e){let t=e?.fileUrl??e?.downloadUrl??e?.url;if(!t)return null;let n=await fetch(t);if(!n.ok)throw Error(`Unable to load ${e?.fileName||`resume`}`);let r=await n.blob(),i=e?.fileName??e?.uploadedFileName??e?.originalName??e?.uniqueName??`resume`;return new File([r],i,{type:e?.contentType||r.type||`application/octet-stream`})}async function FN(e,r,i){let a=[],o=await n.Un(`submissions`,e,`resume`).catch(()=>({data:[]}));a.push(...o?.data??[]);let s=NN(r?.record?.submission,i,r?.record);if(!s){let n=await t.o(t.x,`/module/list?module=submissions&id=${encodeURIComponent(e)}`).catch(()=>({})),r=n?.data??n??{};s=NN((Array.isArray(r?.data)?r.data:Array.isArray(r)?r:[])[0])}if(s){let e=await n.Un(`candidates`,s,`resume`).catch(()=>({data:[]}));a.push(...e?.data??[])}let c=(await Promise.all(a.map(PN))).filter(Boolean),l=new Set;return c.filter(e=>{let t=`${e.name}:${e.size}:${e.type}`;return!l.has(t)&&(l.add(t),!0)})}function IN(e={}){return{to:(e.to??e.To??[]).map(e=>e.email??e.Email??e).filter(Boolean).join(`, `),cc:(e.cc??e.Cc??[]).map(e=>e.email??e.Email??e).filter(Boolean).join(`, `),bcc:(e.bcc??e.Bcc??[]).map(e=>e.email??e.Email??e).filter(Boolean).join(`, `),subject:e.subject??e.Subject??``,contents:MN(e.content?.value??e.Content?.Value??e.contents??e.body??``)}}function LN({context:e,selectedIds:t,selectedRecords:n,moduleName:r,onClose:i}){let a=n?.[0]??{},o=t?.[0]??Zv(a),[l,d]=(0,s.useState)(null),[f,p]=(0,s.useState)(!0),[m,h]=(0,s.useState)([]),[g,_]=(0,s.useState)(!1),[v,y]=(0,s.useState)(`vms`),[b,x]=(0,s.useState)(null),[S,C]=(0,s.useState)(null),[w,T]=(0,s.useState)(!1),[E,D]=(0,s.useState)(!1),[O,k]=(0,s.useState)(!1),[A,j]=(0,s.useState)(!1),[M,N]=(0,s.useState)({to:``,cc:``,bcc:``,subject:``,contents:``,attachments:[],showCc:!1,showBcc:!1});(0,s.useEffect)(()=>{let e=!1;return Gy(o,a).then(t=>{e||d(t)}).catch(t=>{e||(c.message.error(t?.message??`Unable to load finance details`),d({record:{submission:a},lookups:{},display:{}}))}).finally(()=>{e||p(!1)}),()=>{e=!0}},[o]),(0,s.useEffect)(()=>{let e=!1;return eb().then(t=>{e||h(t)}).catch(()=>{}),()=>{e=!0}},[]);let P=async()=>{if(b){if(v===`mail`){_(!1),D(!0),k(!0);try{let[e,t]=await Promise.all([gN(o).then(IN),FN(o,l,a).catch(e=>(console.warn(`Unable to resolve resume attachment:`,e),[]))]),n=l?.record?.submission??a;N({to:ON(e.to,n,b,l,a),cc:ON(e.cc,n,b,l,a),bcc:ON(e.bcc,n,b,l,a),subject:ON(e.subject,n,b,l,a),contents:ON(e.contents,n,b,l,a),attachments:t,showCc:!!e.cc,showBcc:!!e.bcc})}catch(e){c.message.error(e?.message??`Unable to prepare approval mail`)}finally{k(!1)}return}T(!0);try{await be(o,{candidateProposedRate:b.proposedRate,candidateProposedRateCurrency:b.currencyRaw??b.currency,candidateProposedRateUnit:b.rateUnit,submitVia:`VMS`,...jN(S)}),c.message.success(`Submission approved`),_(!1),x(null),C(null),i?.({success:!0})}catch(e){c.message.error(e?.message??`Unable to approve submission`)}finally{T(!1)}}},F=String(M.contents??``).replace(/<[^>]*>/g,` `).replace(/ /gi,` `).trim(),I=/{{\s*\.?[\w.]+\s*}}/.test(`${M.subject??``} ${M.contents??``}`),L=``;O||(bk(M.to).length===0?L=`Add at least one recipient in To.`:wk(M.to)?wk(M.cc)?wk(M.bcc)?String(M.subject??``).trim()?F?I&&(L=`The message still contains unfilled placeholders ({{…}}). Fill them in before sending.`):L=`The message body is empty.`:L=`Enter a subject.`:L=`One or more Bcc addresses are not valid e-mail addresses.`:L=`One or more Cc addresses are not valid e-mail addresses.`:L=`One or more To addresses are not valid e-mail addresses.`);let R=!O&&!L,z=async()=>{if(!b||!R||A)return;j(!0);let e={candidateProposedRate:b.proposedRate,candidateProposedRateCurrency:b.currencyRaw??b.currency,candidateProposedRateUnit:b.rateUnit};try{await be(o,{...e,submitVia:`VMS`,...jN(S)});let t=AN(l?.record,a);if(!t)c.message.warning(`Submission approved, but job details were not available to send mail`);else try{await Tn({jobId:t,toMail:bk(M.to),ccMail:bk(M.cc),bccMail:bk(M.bcc),subject:M.subject,contents:M.contents,attachments:M.attachments??[]}),c.message.success(`Approval mail sent and submission approved`)}catch(e){c.message.warning(e?.message?`Submission approved, but mail was not sent: ${e.message}`:`Submission approved, but mail was not sent`)}D(!1),x(null),C(null),i?.({success:!0})}catch(e){c.message.error(e?.message??`Unable to send approval mail`)}finally{j(!1)}},B=(0,s.useMemo)(()=>({submissionApprove:async({computed:e,referral:t})=>{x(e),C(t??null),y(`vms`),_(!0)},submissionReject:async()=>{e?.navigate?.(`/popup/reject`,{replace:!0,state:{background:e?.background??null,selectedIds:t,selectedRecords:n,moduleName:r}})}}),[e,t,n,r]);return f||!l?(0,u.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,u.jsx)(c.Spin,{size:`large`})}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Py,{type:Tv,record:l.record,lookups:l.lookups,identity:bN(a,l.display),referralOptions:m,currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:B,onClose:()=>i?.(),variant:`popup`}),(0,u.jsx)(c.Modal,{title:`Choose approval method`,open:g,okText:`Approve`,confirmLoading:w,onOk:P,onCancel:()=>{w||(_(!1),x(null),C(null))},children:(0,u.jsxs)(c.Radio.Group,{value:v,onChange:e=>y(e.target.value),style:{display:`grid`,gap:12},children:[(0,u.jsx)(c.Radio,{value:`vms`,children:`Via VMS`}),(0,u.jsx)(c.Radio,{value:`mail`,children:`Via Mail`})]})}),(0,u.jsx)(c.Drawer,{open:E,placement:`right`,onClose:()=>{A||D(!1)},closable:!1,rootClassName:`mail-popup`,width:620,maskClosable:!1,footer:(0,u.jsxs)(`div`,{className:`mail-popup__footer`,children:[L&&(0,u.jsx)(`span`,{role:`alert`,style:{color:`var(--color-error, #cf1322)`,marginRight:`auto`,fontSize:13},children:L}),(0,u.jsx)(c.Button,{onClick:()=>D(!1),disabled:A,children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,loading:A,disabled:!R,onClick:z,children:`Send`})]}),children:O?(0,u.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,u.jsx)(c.Spin,{size:`large`})}):(0,u.jsx)(Bk,{value:M,onChange:N,moduleName:`submissions`,ready:!O,title:`Submit Via Mail`,contextRecords:[l.record?.submission??a],requiredTo:!0,requiredSubject:!0,requiredBody:!0})})]})}LN.propTypes={context:p.default.object,selectedIds:p.default.array,selectedRecords:p.default.array,moduleName:p.default.string,onClose:p.default.func};var RN={title:`Manager Approve`,width:780,className:`fa-modal manager-approve-modal`,component:LN},zN={submit:async()=>{}};function BN(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 VN(e){return String(e??``).toLowerCase().replace(/\b\w/g,e=>e.toUpperCase())}function HN({selectedIds:e,selectedRecords:t,onClose:r}){let i=t?.[0]??{},a=e?.[0]??Zv(i),[o,l]=(0,s.useState)(null),[d,f]=(0,s.useState)(``),[p,m]=(0,s.useState)(!0);(0,s.useEffect)(()=>{let e=!1;return m(!0),Promise.all([Gy(a,i),n.In(`submission`,a).catch(()=>[])]).then(([t,n])=>{if(e)return;let r=BN(n);f(Zv(t?.meta?.workforceEngagementId??i?.onboarding?.workforceEngagementId??i?.workforceEngagementId));let a=t?.meta?.rejectReasonComments||r?.activityComments||``;l({...t,record:{...t.record,submission:{...t.record.submission,cfoRejectionReason:a?VN(a):``,cfoRejectedAt:t?.meta?.rejectedAt??r?.activityTime??null}}})}).catch(t=>{e||(c.message.error(t?.message??`Unable to load finance details`),l({record:{submission:i},lookups:{},display:{}}))}).finally(()=>{e||m(!1)}),()=>{e=!0}},[a]);let h=(0,s.useMemo)(()=>({submissionReapproveSend:async({computed:e})=>{await Se(d,{submissionId:a,billRate:e.proposedRate,payRate:e.employerRate,currency:e.currencyRaw??e.currency,rateUnit:e.rateUnit,vmsPercent:e.clientVmsPercent}),await be(a,{candidateProposedRate:e.proposedRate,candidateProposedRateCurrency:e.currencyRaw??e.currency,candidateProposedRateUnit:e.rateUnit,submitVia:`Mail`,context:`resend`}),c.message.success(`Re-approved and sent for CFO approval`),r?.({success:!0})}}),[a,d,r]);return p||!o?(0,u.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,u.jsx)(c.Spin,{size:`large`})}):(0,u.jsx)(Py,{type:kv,record:o.record,lookups:o.lookups,identity:bN(i,o.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:h,onClose:()=>r?.(),variant:`popup`})}HN.propTypes={selectedIds:p.default.array,selectedRecords:p.default.array,onClose:p.default.func};var UN={title:`Re-Approve`,width:780,className:`fa-modal manager-approve-modal`,component:HN},WN={submit:async()=>{}},GN=[{id:1,name:`Re-Submission`},{id:2,name:`Candidate doesn't fit into the profile`},{id:3,name:`Incomplete candidate details - (Re-Submission)`}],KN={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:GN.map(e=>({label:e.name,value:e.id}))},{name:`rejectReasonComments`,label:`Comments`,type:`textarea`,required:!0,rows:4}]},qN={submit:async(e,t)=>{let n=GN.find(t=>String(t.id)===String(e.rejectReason));await Ce({submissionId:t.selectedIds[0],rejectReasonId:e.rejectReason,rejectReason:n?.name??``,rejectReasonComments:e.rejectReasonComments})}},JN={delete:qj,"quick-submit":TM,"add-notes":EM,"tag-to-job":MM,"change-status":GM,"remove-from-shortlist":JM,"add-to-groups":XM,"self-assign":eN,"others-assign":rN,"sticky-notes":aN,"move-to-onboarding":sN,"approve-rate":pN,"manager-approve":RN,"manager-reapprove":UN,reject:KN},YN={delete:Jj,"quick-submit":wM,"add-notes":kM,"tag-to-job":WM,"change-status":qM,"remove-from-shortlist":YM,"add-to-groups":ZM,"self-assign":tN,"others-assign":iN,"sticky-notes":oN,"move-to-onboarding":cN,"approve-rate":mN,"manager-approve":zN,"manager-reapprove":WN,reject:qN};function XN(e){let t=e?.data??e;return Array.isArray(t)?t:t?.data??t?.rows??t?.records??t?.items??t?.list??[]}function ZN(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 QN(e){let t=String(ZN(e,`isDeleted`,`deleted`)).toLowerCase(),n=String(ZN(e,`assignmentStatus`,`status`)).toLowerCase();return t!==`true`&&t!==`1`&&![`removed`,`inactive`,`deleted`].includes(n)}function $N(e){let t=ZN(e,`candidateName`,`candidate_name`,`fullName`,`name`);return t?String(t):[ZN(e,`firstName`,`first_name`),ZN(e,`lastName`,`last_name`)].filter(Boolean).join(` `)||`Unnamed candidate`}function eP(e){return String(ZN(e,`candidateId`,`candidate_id`,`candidate._id`,`candidate.id`))}function tP(e){return String(ZN(e,`workforceEngagementId`,`engagementId`,`_id`,`id`))}function nP(e){return String(ZN(e,`batchName`,`name`,`title`,`batch_name`))}function rP({open:e=!0,context:r={},onClose:i}){let[a,o]=(0,s.useState)([]),[l,d]=(0,s.useState)([]),[f,p]=(0,s.useState)(``),[m,h]=(0,s.useState)(!0),[g,_]=(0,s.useState)(!1),[v,y]=(0,s.useState)(``),[b,x]=(0,s.useState)(new Map),S=String(r.selectedIds?.[0]??r.selectedRecords?.[0]?._id??r.selectedRecords?.[0]?.id??r.batchId??``);(0,s.useEffect)(()=>{if(!e)return;let t=!1;return Promise.resolve().then(()=>(t||h(!0),Promise.all([n.Kn(`onboarding`,200,0),n.Kn(`batchCandidates`,1e3,0).catch(()=>[])]))).then(([e,n])=>{t||(o(XN(e)),x(new Map(XN(n).filter(QN).map(e=>[String(ZN(e,`candidateId`,`candidate_id`)),e]).filter(([e])=>e))))}).catch(e=>{t||y(e.message||`Unable to load onboarding candidates`)}).finally(()=>{t||h(!1)}),()=>{t=!0}},[e]);let C=(0,s.useMemo)(()=>{let e=f.trim().toLowerCase();return e?a.filter(t=>[$N(t),ZN(t,`email`,`candidateEmail`,`candidate_email`),ZN(t,`status`,`onboardingStatus`,`onboarding_status`)].some(t=>String(t).toLowerCase().includes(e))):a},[a,f]);async function w(){if(!S){y(`Select a batch before adding candidates`);return}let e=a.filter(e=>l.includes(tP(e)));if(!e.length)return;let o=e.map(e=>({record:e,assignment:b.get(eP(e))})).filter(e=>e.assignment);if(o.length){let e=o.map(({record:e})=>$N(e)).join(`, `);y(`${e} ${o.length===1?`is`:`are`} already added to a batch. Each candidate can be added to only one batch.`);return}_(!0),y(``);try{let{userId:a}=t.s(),o=nP(r.selectedRecords?.[0])||nP(r);await Promise.all(e.map(e=>n.Or(`batchCandidates`,{schemaVersion:1,batchId:S,batchName:o,candidateId:eP(e),workforceEngagementId:tP(e),source:`ONBOARDING`,assignmentStatus:`ASSIGNED`,assignedAt:new Date().toISOString(),assignedBy:a??0,isDeleted:!1}))),c.message.success(`${e.length} candidate${e.length===1?``:`s`} added to the batch`),i?.({refresh:!0})}catch(e){y(e.message||`Unable to add candidates to the batch`)}finally{_(!1)}}return(0,u.jsxs)(c.Modal,{open:e,title:`Add Candidate to Batch`,okText:`Add`,onOk:w,onCancel:()=>i?.(),okButtonProps:{disabled:l.length===0||!S,loading:g},cancelButtonProps:{disabled:g},closable:!g,maskClosable:!1,width:760,centered:!0,children:[v&&(0,u.jsx)(c.Alert,{type:`error`,showIcon:!0,message:v,style:{marginBottom:12}}),(0,u.jsx)(c.Input.Search,{allowClear:!0,placeholder:`Search onboarding candidates`,value:f,onChange:e=>p(e.target.value),style:{marginBottom:12}}),(0,u.jsx)(c.Table,{rowKey:e=>tP(e),columns:[{title:`Candidate`,key:`candidate`,render:(e,t)=>$N(t)},{title:`Email`,key:`email`,render:(e,t)=>ZN(t,`email`,`candidateEmail`,`candidate_email`)||`—`},{title:`Onboarding status`,key:`status`,render:(e,t)=>ZN(t,`status`,`onboardingStatus`,`onboarding_status`)||`—`}],dataSource:C,loading:m,size:`small`,pagination:{pageSize:10,showSizeChanger:!1},rowSelection:{selectedRowKeys:l,onChange:d,getCheckboxProps:e=>{let t=b.get(eP(e));return{disabled:!eP(e)||!tP(e)||!!t,title:t?`Candidate is already added to a batch`:void 0}}},locale:{emptyText:m?`Loading candidates…`:`No onboarding candidates found`}})]})}var iP={text:`input`,string:`input`,textarea:`textarea`,date:`date-picker`,datepicker:`date-picker`,multiselect:`multi-select`,lookup:`search-select`};function aP(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:iP[String(e.type??`text`).toLowerCase()]??e.type??`input`,required:e.required??e.req===1,options:(e.options??[]).map(e=>({label:e.label??e.name??e.value,value:e.value??e.id??e.label}))}))),n=oP(e.successNavigate);return{title:e.label,fields:t,...n?{successNavigate:n}:{}}}function oP(e){let t=String(e??``).trim();return!t||!t.startsWith(`/`)||t.startsWith(`//`)||/^[a-z][a-z0-9+.-]*:/i.test(t)?null:t}function sP(e,t=[]){if(!e||!Array.isArray(t)||!t.length)return e;let n=new Map(t.filter(e=>e?.name).map(e=>[String(e.name),e]));return n.size?{...e,fields:(e.fields??[]).map(r=>{let i=n.get(String(r.name))??n.get(String(r.label))??(n.size===1&&(e.fields??[]).length===1?t[0]:null);if(!i)return r;let{name:a,...o}=i;return{...r,...o}})}:e}function cP({apiMap:e={},extraConfigs:r={}}){let i=(0,s.useMemo)(()=>({...YN,...e}),[e]),a=(0,s.useMemo)(()=>{let e={...JN};return Object.entries(r).forEach(([t,n])=>{e[t]={...e[t]??{},...n}}),e},[r]),{popupKey:o}=(0,f.useParams)(),c=(0,f.useNavigate)(),{state:l={}}=(0,f.useLocation)(),[d,p]=(0,s.useState)({key:``,config:null});(0,s.useEffect)(()=>{let e=!1;if(!o||!l.moduleName)return;let t=`${l.moduleName}:${o}`;return n.ei(l.moduleName,`popup`,o).then(n=>{e||p({key:t,config:aP(n[0])})}).catch(()=>{e||p({key:t,config:null})}),()=>{e=!0}},[o,l.moduleName]);let m=(0,s.useMemo)(()=>{let e=a[o],t=`${l.moduleName}:${o}`,n=d.key===t?d.config:null;return sP(n?{...e,...n}:e,l.popupAction?.popupFieldOverrides)},[d,a,o,l.moduleName,l.popupAction?.popupFieldOverrides]),h=(0,s.useMemo)(()=>({selectedIds:l.selectedIds??[],selectedRecords:l.selectedRecords??[],moduleName:l.moduleName??``,navigate:c,background:l.background??null,...l.popupContext??{}}),[c,l.selectedIds,l.selectedRecords,l.moduleName,l.popupContext,l.background]),g=(0,s.useMemo)(()=>{let e=l.popupAction;return e?.apiPath?{submit:(n,r)=>{let i=String(e.apiMethod||`POST`).toUpperCase();return t.o(t.x,e.apiPath.startsWith(`/`)?e.apiPath:`/${e.apiPath}`,{method:i,body:[`GET`,`DELETE`].includes(i)?void 0:JSON.stringify({...n,selectedIds:r.selectedIds,selectedRecords:r.selectedRecords,moduleName:r.moduleName})})}}:{}},[l.popupAction]),_=e=>{let t=l.background;if(e?.success&&m?.successNavigate){c(m.successNavigate,{replace:!0,state:{refreshTimestamp:Date.now()}});return}if(e?.success&&t?.pathname){c(`${t.pathname}${t.search??``}`,{replace:!0,state:{...t.state??{},refreshTimestamp:Date.now()}});return}c(-1)};return o===`add-batch-candidate`?(0,u.jsx)(rP,{open:!0,context:h,onClose:_}):(0,u.jsx)(Kj,{open:!0,config:m,context:h,onClose:_,api:{...i[o]??{},...g}})}var lP={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`}]},uP={getVendorList:({jobId:e,limit:t,offset:n,type:r})=>bn({jobId:e,limit:t,offset:n,sortBy:`new`,type:r}),getMailDetails:e=>xn(e),submit:({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})=>Tn({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})},dP=lP.vendorColumns.map(e=>({...e,render:e=>e||`-`}));function fP(){let e=(0,f.useNavigate)(),t=(0,f.useLocation)(),{selectedIds:n=[],selectedRecords:r=[],recipients:i=[],subject:a=``,onSend:o,moduleName:d=``,popupAction:p={}}=t.state??{},m=n[0]??r[0]?._id??r[0]?.id,[h,g]=(0,s.useState)({to:i.join(`, `),cc:``,bcc:``,subject:a,contents:``,showCc:!1,showBcc:!1}),[_,v]=(0,s.useState)(!m),[y,b]=(0,s.useState)(lP.defaultTab),[x,S]=(0,s.useState)(``),[C,w]=(0,s.useState)([]),[T,E]=(0,s.useState)(0),[D,O]=(0,s.useState)(0),[k,A]=(0,s.useState)(0),[j,M]=(0,s.useState)(1),[N,P]=(0,s.useState)(lP.defaultPageSize),[F,I]=(0,s.useState)(!1),[L,R]=(0,s.useState)([]);(0,s.useEffect)(()=>{if(!m)return;let e=!1;I(!0);let t=x?100:N,n=x?0:(j-1)*N;return uP.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,s.useEffect)(()=>{m&&uP.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,s.useMemo)(()=>L.map(e=>C.find(t=>t.vendorId===e)?.vendorEmail??``).filter(Boolean),[L,C]),B=(0,s.useMemo)(()=>({...h,bcc:[...new Set([...bk(h.bcc),...z])].join(`, `),showBcc:h.showBcc||z.length>0}),[h,z]);function V(e){let t=new Set(z);g({...e,bcc:bk(e.bcc).filter(e=>!t.has(e)).join(`, `)})}let H=(bk(B.to).length||bk(B.bcc).length)&&wk(B.to)&&wk(B.cc)&&wk(B.bcc)&&B.subject.trim(),ee=e=>e===`myVendor`?T:D;function te(){e(-1)}function ne(){H&&uP.submit({jobId:m,toMail:bk(B.to),ccMail:bk(B.cc),bccMail:bk(B.bcc),subject:B.subject,contents:B.contents}).then(t=>{t?.status===!0?(c.message.success(t?.data||`Mail sent successfully.`),typeof o==`function`&&o({...B,message:B.contents,selectedIds:n}),e(-1)):c.message.error(t?.message||t?.data||`Failed to send mail. Please try again.`)}).catch(e=>{c.message.error(e?.message||`Failed to send mail. Please try again.`)})}let re=(0,s.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,u.jsx)(c.Drawer,{open:!0,placement:`right`,onClose:te,closable:!1,rootClassName:`vendor-share`,width:`95%`,footer:(0,u.jsxs)(`div`,{className:`vendor-share__footer`,children:[(0,u.jsx)(c.Button,{onClick:te,children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,disabled:!H,onClick:ne,children:`Send`})]}),children:(0,u.jsxs)(`div`,{className:`vendor-share__body`,children:[(0,u.jsxs)(`div`,{className:`vendor-share__left`,children:[(0,u.jsxs)(`div`,{className:`vendor-share__vendor-header`,children:[(0,u.jsxs)(`div`,{className:`vendor-share__vendor-header-row`,children:[(0,u.jsx)(c.Button,{type:`text`,icon:(0,u.jsx)(l.CloseOutlined,{}),onClick:te,size:`small`,style:{marginRight:8}}),(0,u.jsx)(`span`,{className:`dynamic-popup__header-icon-box`,children:(0,u.jsx)(l.TeamOutlined,{})}),(0,u.jsx)(`span`,{className:`dynamic-popup__header-label`,children:`Vendor List`}),(0,u.jsxs)(`div`,{className:`vendor-share__vendor-search`,children:[(0,u.jsx)(l.SearchOutlined,{className:`vendor-share__search-icon`}),(0,u.jsx)(c.Input,{variant:`borderless`,placeholder:`Search vendor`,value:x,onChange:e=>{S(e.target.value),M(1)},className:`vendor-share__search-input`})]})]}),(0,u.jsx)(`div`,{className:`vendor-share__vendor-tabs`,children:lP.vendorTabs.map(e=>(0,u.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,` (`,ee(e.key),`)`]},e.key))})]}),(0,u.jsx)(`div`,{className:`vendor-share__vendor-table-wrapper`,children:(0,u.jsx)(c.Table,{rowKey:e=>e.vendorId,columns:dP,dataSource:re,loading:F,pagination:!1,size:`small`,rowSelection:{selectedRowKeys:L,onChange:e=>{e.length>lP.maxVendorSelect||R(e)}},scroll:{y:`calc(100vh - 340px)`}})}),(0,u.jsx)(`div`,{className:`vendor-share__vendor-footer`,children:(0,u.jsx)(Be,{current:j,pageSize:N,total:k,onChange:e=>M(e),onPageSizeChange:e=>P(e)})})]}),(0,u.jsx)(`div`,{className:`vendor-share__right`,children:(0,u.jsx)(Bk,{value:B,onChange:V,moduleName:d,defaultTemplateId:p.defaultTemplateId??t.state?.defaultTemplateId??``,ready:_,contextRecords:r,title:`Share`,hint:`Select vendors or add email addresses`,bccHint:`Vendor emails are added automatically`,afterBcc:L.length>0?(0,u.jsxs)(`div`,{className:`vendor-share__selected-count`,children:[L.length,` / `,lP.maxVendorSelect,` Vendors selected`]}):null})})]})})}var pP={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].*$/},mP={SINGLE_FILE_COUNT:1,MULTI_FILE_COUNT:5,MAX_FILE_SIZE:2,ALLOWED_FILE_TYPES:[`image/jpeg`,`image/png`,`application/pdf`]},hP={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 ${mP.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.`},gP={FIRST_NAME_MIN:3,FIRST_NAME_MAX:30},_P={REMARKS_MIN:10,REMARKS_MAX:250},vP={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)}`}},yP={required:(e=`Field`)=>({required:!0,message:hP.REQUIRED(e)}),email:()=>({pattern:pP.EMAIL,message:hP.INVALID_EMAIL}),phone:()=>({pattern:pP.PHONE,message:hP.INVALID_PHONE}),password:()=>({pattern:pP.PASSWORD,message:hP.INVALID_PASSWORD}),alphabets:()=>({pattern:pP.ALPHABETS,message:hP.INVALID_ALPHABETS}),alphanumeric:()=>({pattern:pP.ALPHANUMERIC,message:hP.INVALID_ALPHANUMERIC}),number:()=>({pattern:pP.NUMBER,message:hP.INVALID_NUMBER}),url:()=>({pattern:pP.URL,message:hP.INVALID_URL}),candidateId:(e=`ID`)=>({pattern:pP.CANDIDATE_ID,message:hP.INVALID_CANDIDATE_ID(e)}),remarks:()=>({pattern:pP.REMARKS,message:hP.INVALID_REMARKS,REMARKS_MIN:`Remarks must be at least ${_P.REMARKS_MIN} characters.`,REMARKS_MAX:`Remarks must not exceed ${_P.REMARKS_MAX} characters.`}),designation:()=>({pattern:pP.DESIGNATION,message:hP.INVALID_DESIGNATION}),dob:(e=!0)=>({validator:(t,n)=>{if(!n)return e?Promise.reject(Error(`Date of Birth is required.`)):Promise.resolve();if(!pP.DOB.test(n))return Promise.reject(Error(hP.INVALID_DOB));let r=(0,d.default)(n,`MM/DD/YYYY`,!0);if(!r.isValid())return Promise.reject(Error(hP.INVALID_DOB));let i=(0,d.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:pP.LINKEDIN,message:hP.INVALID_LINKEDIN}),companyName:()=>({pattern:pP.COMPANY_NAME,message:hP.INVALID_COMPANY_NAME}),firstName:()=>({pattern:pP.FIRST_NAME,message:hP.INVALID_FIRST_NAME,FIRST_NAME_MIN:`First Name must be at least ${gP.FIRST_NAME_MIN} characters.`,FIRST_NAME_MAX:`First Name must not exceed ${gP.FIRST_NAME_MAX} characters.`}),firstNameMinLength:()=>({min:gP.FIRST_NAME_MIN,message:hP.FIRST_NAME_MIN}),firstNameMaxLength:()=>({max:gP.FIRST_NAME_MAX,message:hP.FIRST_NAME_MAX}),remarksMinLength:()=>({min:_P.REMARKS_MIN,message:hP.REMARKS_MIN}),remarksMaxLength:()=>({max:_P.REMARKS_MAX,message:hP.REMARKS_MAX}),fullName:()=>({pattern:pP.FULL_NAME,message:hP.INVALID_FULL_NAME}),noSpaces:()=>({pattern:pP.NO_SPACES,message:hP.NO_SPACES_ALLOWED}),startsWithCapital:()=>({pattern:pP.STARTS_WITH_CAPITAL,message:hP.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<=mP.MAX_FILE_SIZE))return c.message.error(hP.INVALID_FILE_SIZE),Promise.reject(Error(hP.INVALID_FILE_SIZE));if(!mP.ALLOWED_FILE_TYPES.includes(t.type))return Promise.reject(Error(hP.INVALID_FILE_TYPE))}return Promise.resolve()}}),singleFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>mP.SINGLE_FILE_COUNT)return Promise.reject(Error(hP.SINGLE_FILE_ONLY));let n=t[0];return n.size/1024/1024<mP.MAX_FILE_SIZE?mP.ALLOWED_FILE_TYPES.includes(n.type)?Promise.resolve():Promise.reject(Error(hP.INVALID_FILE_TYPE)):Promise.reject(Error(hP.INVALID_FILE_SIZE))}}),multiFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>mP.MULTI_FILE_COUNT)return Promise.reject(Error(hP.INVALID_FILE_COUNT));for(let e of t){if(!(e.size/1024/1024<mP.MAX_FILE_SIZE))return Promise.reject(Error(hP.INVALID_FILE_SIZE));if(!mP.ALLOWED_FILE_TYPES.includes(e.type))return Promise.reject(Error(hP.INVALID_FILE_TYPE))}return Promise.resolve()}})},bP={beforeUpload:e=>[`image/jpeg`,`image/png`,`application/pdf`].includes(e.type)?e.size/1024/1024<=2?!1:(c.message.error(`File upload must be 2 MB below.`),c.Upload.LIST_IGNORE):(c.message.error(`Only JPG, PNG and PDF files are allowed.`),c.Upload.LIST_IGNORE)},xP=()=>{let[e]=c.Form.useForm();return(0,u.jsx)(`div`,{style:{padding:24},children:(0,u.jsxs)(c.Form,{form:e,layout:`vertical`,onFinish:e=>{console.log(`Form Values:`,e)},autoComplete:`off`,children:[(0,u.jsxs)(c.Row,{gutter:16,children:[(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Email`,name:`email`,rules:[yP.required(`Email`),yP.email()],children:(0,u.jsx)(c.Input,{})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Phone Number`,name:`phone`,rules:[yP.required(`Phone Number`),yP.phone()],validateTrigger:[`onBlur`,`onChange`],children:(0,u.jsx)(c.Input,{maxLength:10,onChange:t=>{e.setFieldsValue({phone:vP.phoneFormatter(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Password`,name:`password`,rules:[yP.required(`Password`),yP.password()],children:(0,u.jsx)(c.Input.Password,{})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Full Name`,name:`fullName`,rules:[yP.required(`Full Name`),yP.alphabets(),yP.firstNameMinLength(),yP.firstNameMaxLength()],children:(0,u.jsx)(c.Input,{onChange:t=>{e.setFieldsValue({fullName:vP.firstNameFormatter(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Username`,name:`username`,rules:[yP.required(`Username`),yP.alphanumeric()],children:(0,u.jsx)(c.Input,{onChange:t=>{e.setFieldsValue({username:vP.removeExtraSpaces(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Website URL`,name:`website`,rules:[yP.required(`Website URL`),yP.url()],children:(0,u.jsx)(c.Input,{onChange:t=>{e.setFieldsValue({website:vP.removeExtraSpaces(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`MSP Req ID`,name:`mspreqID`,rules:[yP.required(`MSP Req ID`),yP.candidateId(`MSP Req ID`)],children:(0,u.jsx)(c.Input,{onChange:t=>{e.setFieldsValue({mspreqID:vP.removeExtraSpaces(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Candidate ID`,name:`candidateId`,rules:[yP.required(`Candidate ID`),yP.candidateId(`Candidate ID`)],children:(0,u.jsx)(c.Input,{onChange:t=>{e.setFieldsValue({candidateId:vP.removeExtraSpaces(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:24,children:(0,u.jsx)(c.Form.Item,{label:`Remarks`,name:`remarks`,rules:[yP.required(`Remarks`),yP.remarks(),yP.remarksMinLength(),yP.remarksMaxLength()],children:(0,u.jsx)(c.Input.TextArea,{rows:4})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Designation`,name:`designation`,rules:[yP.required(`Designation`),yP.designation()],children:(0,u.jsx)(c.Input,{})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Date of Birth`,name:`dob`,rules:[yP.dob()],children:(0,u.jsx)(c.Input,{placeholder:`MM/DD/YYYY`,maxLength:10,onChange:t=>{e.setFieldsValue({dob:vP.dobFormatter(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Company Name`,name:`companyName`,rules:[yP.required(`Company Name`),yP.companyName()],children:(0,u.jsx)(c.Input,{})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{name:`contractType`,label:`Contract Type`,children:(0,u.jsxs)(c.Select,{showSearch:!0,allowClear:!0,filterOption:(e,t)=>(t?.label??``).toLowerCase().includes(e.toLowerCase()),children:[(0,u.jsx)(c.Select.Option,{value:`C2C`,label:`C2C`,children:`C2C`}),(0,u.jsx)(c.Select.Option,{value:`W2-Contract`,label:`W2-Contract`,children:`W2-Contract`}),(0,u.jsx)(c.Select.Option,{value:`W2-Fulltime`,label:`W2-Fulltime`,children:`W2-Fulltime`}),(0,u.jsx)(c.Select.Option,{value:`1099`,label:`1099`,children:`1099`})]})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{name:`candidateProposedRateCurrency`,label:`Currency`,children:(0,u.jsxs)(c.Select,{showSearch:!0,allowClear:!0,children:[(0,u.jsx)(c.Select.Option,{value:`$`,children:`$`}),(0,u.jsx)(c.Select.Option,{value:`₹`,children:`₹`}),(0,u.jsx)(c.Select.Option,{value:`€`,children:`€`}),(0,u.jsx)(c.Select.Option,{value:`zł`,children:`zł`}),(0,u.jsx)(c.Select.Option,{value:`£`,children:`£`}),(0,u.jsx)(c.Select.Option,{value:`kr`,children:`kr`}),(0,u.jsx)(c.Select.Option,{value:`Fr`,children:`Fr`}),(0,u.jsx)(c.Select.Option,{value:`kr`,children:`kr`})]})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Resume new`,name:`resume`,children:(0,u.jsx)(c.Upload,{beforeUpload:bP.beforeUpload,maxCount:1,children:(0,u.jsx)(c.Button,{children:`Upload Resume`})})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Documents`,name:`documents`,valuePropName:`fileList`,getValueFromEvent:e=>e?.fileList,rules:[yP.multiFileUpload()],children:(0,u.jsx)(c.Upload,{multiple:!0,beforeUpload:bP.beforeUpload,children:(0,u.jsx)(c.Button,{children:`Upload Documents`})})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Upload File`,name:`file`,valuePropName:`fileList`,getValueFromEvent:e=>e?.fileList,rules:[yP.fileUpload()],children:(0,u.jsx)(c.Upload,{beforeUpload:bP.beforeUpload,maxCount:1,children:(0,u.jsx)(c.Button,{children:`Upload`})})})})]}),(0,u.jsx)(c.Row,{children:(0,u.jsx)(c.Form.List,{name:`users`,children:(e,{add:t,remove:n})=>(0,u.jsxs)(u.Fragment,{children:[e.map(({key:e,name:t,...r})=>(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{required:!0,...r,rules:[{required:!0,message:`First name is requried`}],name:[t,`first`],children:(0,u.jsx)(c.Input,{placeholder:`First Name`})})}),(0,u.jsx)(c.Col,{span:11,children:(0,u.jsx)(c.Form.Item,{...r,required:!0,name:[t,`last`],children:(0,u.jsx)(c.Input,{placeholder:`Last Name`})})}),(0,u.jsx)(c.Col,{span:1,children:(0,u.jsx)(l.MinusCircleOutlined,{onClick:()=>n(t)})})]})),(0,u.jsx)(c.Form.Item,{children:(0,u.jsx)(c.Button,{type:`dashed`,onClick:()=>t(),block:!0,icon:(0,u.jsx)(l.PlusOutlined,{}),children:`Add field`})})]})})}),(0,u.jsxs)(c.Form.Item,{children:[(0,u.jsx)(c.Button,{type:`primary`,htmlType:`submit`,children:`Submit`}),(0,u.jsx)(c.Button,{style:{marginLeft:10},onClick:()=>e.resetFields(),children:`Reset`})]})]})})};function SP({region:e,onExit:t}){if(!e||e.isHome)return null;let n=e.label?.trim()||e.key;return(0,u.jsxs)(`div`,{role:`status`,"aria-live":`polite`,style:{position:`sticky`,top:0,zIndex:1e3,display:`flex`,alignItems:`center`,gap:12,padding:`10px 16px`,background:`linear-gradient(90deg, #7c2d12 0%, #9a3412 100%)`,color:`#fff`,fontSize:14,fontWeight:600,boxShadow:`0 2px 8px rgba(0,0,0,.25)`,borderBottom:`2px solid #fdba74`},children:[(0,u.jsx)(l.GlobalOutlined,{style:{fontSize:16,flexShrink:0}}),(0,u.jsxs)(`span`,{style:{flex:1,minWidth:0},children:[`You are administering`,` `,(0,u.jsx)(`span`,{style:{background:`rgba(255,255,255,.18)`,padding:`2px 8px`,borderRadius:4,letterSpacing:`.02em`},children:n}),` — `,`changes here affect that region only, not your own.`]}),t&&(0,u.jsxs)(`button`,{type:`button`,onClick:t,style:{display:`inline-flex`,alignItems:`center`,gap:6,background:`rgba(255,255,255,.15)`,border:`1px solid rgba(255,255,255,.45)`,color:`#fff`,borderRadius:4,padding:`4px 12px`,fontSize:13,fontWeight:600,cursor:`pointer`,flexShrink:0},children:[(0,u.jsx)(l.SwapOutlined,{}),`Back to my region`]})]})}SP.propTypes={region:p.default.shape({key:p.default.string,label:p.default.string,isHome:p.default.bool}),onExit:p.default.func},SP.defaultProps={region:null,onExit:void 0};function CP(e){return(0,u.jsx)(fx,{children:(0,u.jsx)(fk,{...e})})}var{Text:wP}=c.Typography,TP=[{label:`Total Jobs`,value:1697,icon:`fileText`},{label:`Active Jobs`,value:1685,icon:`checkCircle`},{label:`My Jobs`,value:600,icon:`user`}],EP={fileText:(0,u.jsx)(l.FileTextOutlined,{}),checkCircle:(0,u.jsx)(l.CheckCircleOutlined,{}),user:(0,u.jsx)(l.UserOutlined,{}),filter:(0,u.jsx)(l.FilterOutlined,{})};function DP({stats:e=TP}){return(0,u.jsx)(c.Card,{children:(0,u.jsx)(c.Row,{gutter:[12,12],children:e.map(e=>(0,u.jsx)(c.Col,{xs:24,sm:24,md:8,lg:8,xl:8,children:(0,u.jsxs)(c.Card,{className:`stats-inner-card`,children:[(0,u.jsxs)(c.Space,{align:`center`,children:[EP[e.icon]??EP.fileText,(0,u.jsx)(wP,{children:e.label})]}),(0,u.jsx)(c.Statistic,{value:e.value})]})},e.label))})})}var{Text:OP}=c.Typography;function kP(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 AP(e){return{...e,key:e.USER_ID??e.user_id??e.userId??e.id??e._id,_name:kP(e),_email:e.email??e.EMAIL??e.user_email??``,_role:e.role_name??e.roleName??e.ROLE_NAME??``,_rawRef:e}}function jP(){let[e,t]=(0,s.useState)([]),[r,i]=(0,s.useState)(0),[a,o]=(0,s.useState)(!1),[d,f]=(0,s.useState)(1),[p,m]=(0,s.useState)(10),[h,g]=(0,s.useState)(``),_=(0,s.useCallback)(async({offset:e,limit:r,searchQuery:a}={})=>{o(!0);try{let o=await n.qr({offset:e,limit:r,searchQuery:a??``}),s=(o.users??[]).map(AP);t(s),i(o.total??s.length)}catch{c.message.error(`Failed to load users`)}finally{o(!1)}},[]);return(0,s.useEffect)(()=>{queueMicrotask(()=>{_({offset:(d-1)*p,limit:p,searchQuery:h})})},[_,d,p,h]),(0,u.jsx)(Z,{icon:(0,u.jsx)(l.TeamOutlined,{}),title:`Users`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,u.jsx)(kh,{listName:`Users`,dataSource:e,fields:[{label:`Name`,value:`_name`,width:220,render:(e,t)=>(0,u.jsxs)(`div`,{children:[(0,u.jsx)(OP,{strong:!0,style:{fontSize:13},children:e}),t._email&&(0,u.jsx)(`div`,{style:{fontSize:11,color:`var(--color-text-muted)`},children:t._email})]})},{label:`Role`,value:`_role`,width:180}],loading:a,total:r,current:d,pageSize:p,onPageChange:e=>f(e),onPageSizeChange:e=>{m(e),f(1)},onSearch:e=>{g(e),f(1)}})})}var{Text:MP}=c.Typography,NP=[{key:`job`,label:`Jobs`},{key:`candidate`,label:`Candidates`},{key:`submissions`,label:`Submissions`}],PP=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`}];function FP({field:e,index:t,onToggle:n,onReorder:r}){let i=(0,s.useRef)(null),[a,o]=(0,s.useState)(!1),[d,f]=(0,s.useState)(!1);function p(e){i.current=t,e.dataTransfer.effectAllowed=`move`,f(!0)}function m(){f(!1),o(!1)}function h(e){e.preventDefault(),o(!0)}function g(){o(!1)}function _(e){e.preventDefault(),o(!1),i.current!==null&&i.current!==t&&r(i.current,t),i.current=null}return(0,u.jsxs)(`div`,{draggable:!0,onDragStart:p,onDragEnd:m,onDragOver:h,onDragLeave:g,onDrop:_,className:`uss-field-row with-edit${a?` drag-over`:``}${d?` dragging`:``}`,children:[(0,u.jsx)(`span`,{className:`uss-drag-handle`,children:(0,u.jsx)(l.HolderOutlined,{})}),(0,u.jsxs)(`span`,{className:`uss-field-name`,children:[e.fieldName,(0,u.jsx)(`span`,{className:`uss-field-key`,children:e.fieldKey})]}),(0,u.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,u.jsx)(c.Switch,{size:`small`,checked:e.isVisible,onChange:e=>n(t,`isVisible`,e)})}),(0,u.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,u.jsx)(c.Switch,{size:`small`,checked:!!e.isEditable,onChange:e=>n(t,`isEditable`,e)})}),(0,u.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,u.jsx)(c.Switch,{size:`small`,checked:!!e.ismandatory,onChange:e=>n(t,`ismandatory`,e)})})]})}function IP({team:e,configType:t}){let[r,i]=(0,s.useState)({}),[a,o]=(0,s.useState)(!1),[l,d]=(0,s.useState)({}),[f,p]=(0,s.useState)(`job`);(0,s.useEffect)(()=>{e&&(o(!0),n.Si(e,t).then(i).catch(()=>c.message.error(`Failed to load field config`)).finally(()=>o(!1)))},[e,t]);let m=r[f]??[];function h(e,t){i(n=>({...n,[e]:typeof t==`function`?t(n[e]??[]):t}))}function g(e,t,n){h(f,r=>r.map((r,i)=>i===e?{...r,[t]:n}:r))}function _(e,t){h(f,n=>{let r=[...n],[i]=r.splice(e,1);return r.splice(t,0,i),r.map((e,t)=>({...e,order:t}))})}async function v(){let r=f;d(e=>({...e,[r]:!0}));try{await n.Xi(e,r,m,t),c.message.success(`Saved`)}catch{c.message.error(`Save failed`)}finally{d(e=>({...e,[r]:!1}))}}return(0,u.jsxs)(c.Spin,{spinning:a,children:[(0,u.jsx)(c.Tabs,{size:`small`,activeKey:f,onChange:p,items:NP.map(e=>({key:e.key,label:e.label}))}),(0,u.jsxs)(`div`,{className:`uss-field-header with-edit`,children:[(0,u.jsx)(`span`,{}),(0,u.jsx)(`span`,{children:`Field`}),(0,u.jsx)(`span`,{style:{textAlign:`center`},children:`Visible`}),(0,u.jsx)(`span`,{style:{textAlign:`center`},children:`Editable`}),(0,u.jsx)(`span`,{style:{textAlign:`center`},children:`Mandatory`})]}),(0,u.jsxs)(`div`,{className:`uss-field-list`,children:[m.length===0&&!a&&(0,u.jsx)(`div`,{className:`uss-empty`,children:`No fields found.`}),m.map((e,t)=>(0,u.jsx)(FP,{field:e,index:t,onToggle:g,onReorder:_},e.fieldKey??t))]}),(0,u.jsx)(`div`,{className:`uss-modal-footer`,children:(0,u.jsxs)(c.Button,{type:`primary`,size:`small`,loading:l[f],onClick:v,children:[`Save `,NP.find(e=>e.key===f)?.label]})})]})}function LP(){let[e,t]=(0,s.useState)(null),[r,i]=(0,s.useState)(!1),[a,o]=(0,s.useState)(!1),[d,f]=(0,s.useState)(`listView`),[p,m]=(0,s.useState)([]),[h,g]=(0,s.useState)(0),[_,v]=(0,s.useState)(!1),[y,b]=(0,s.useState)(``),[x,S]=(0,s.useState)(!1),C=(0,s.useCallback)(async()=>{v(!0);try{let e=await n.Kr();m(e.teams),g(e.total)}catch{c.message.error(`Failed to load teams`)}finally{v(!1)}},[]);(0,s.useEffect)(()=>{C()},[C]);function w(e){t(e),f(`listView`),i(!0)}function T(e){t(e),b(e.teamName??``),o(!0)}async function E(){if(!y.trim()){c.message.warning(`Team name is required`);return}S(!0);try{await n.Yi(e,{teamName:y.trim(),managerId:e.managerId,memberIds:e.memberIds}),c.message.success(`Team updated`),o(!1),C()}catch{c.message.error(`Failed to update team`)}finally{S(!1)}}return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Z,{icon:(0,u.jsx)(l.TeamOutlined,{}),title:`Teams`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,u.jsx)(kh,{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,u.jsxs)(`div`,{style:{display:`flex`,gap:4},children:[(0,u.jsx)(c.Button,{size:`small`,type:`link`,onClick:()=>T(t),children:`Edit`}),(0,u.jsx)(c.Button,{size:`small`,type:`link`,onClick:()=>w(t),children:`Configure`})]})}],loading:_,total:h})}),(0,u.jsx)(c.Modal,{open:a,onCancel:()=>o(!1),title:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(l.TeamOutlined,{style:{color:`var(--color-brand)`,marginRight:6}}),`Edit Team`]}),width:420,footer:null,destroyOnClose:!0,children:(0,u.jsxs)(`div`,{className:`uss-edit-team-body`,style:{paddingTop:12},children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`div`,{className:`uss-edit-team-label`,children:`Team Name`}),(0,u.jsx)(c.Input,{value:y,onChange:e=>b(e.target.value),onPressEnter:E,placeholder:`Enter team name`})]}),(0,u.jsxs)(`div`,{className:`uss-modal-footer`,children:[(0,u.jsx)(c.Button,{onClick:()=>o(!1),children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,loading:x,onClick:E,children:`Save`})]})]})}),(0,u.jsxs)(c.Modal,{className:`uss-modal`,open:r,onCancel:()=>i(!1),title:(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,u.jsx)(l.TeamOutlined,{style:{color:`var(--color-brand)`}}),(0,u.jsxs)(`span`,{children:[`Configure: `,e?.teamName]})]}),width:720,footer:null,destroyOnClose:!0,children:[(0,u.jsx)(`div`,{style:{marginBottom:12},children:(0,u.jsx)(`div`,{className:`uss-config-toggle`,children:PP.map(e=>(0,u.jsx)(`button`,{className:`uss-config-btn${d===e.key?` active`:``}`,onClick:()=>f(e.key),children:e.label},e.key))})}),e&&(0,u.jsx)(IP,{team:e,configType:d},`${e?.teamId}-${d}`)]})]})}var RP=[`view`,`add`,`edit`,`delete`],zP={view:`View`,add:`Add`,edit:`Edit`,delete:`Delete`,sourcing:`Sourcing`,assign:`Assign`,share:`Share`,change_status:`Status`,my_jobs:`My Jobs`,all_jobs:`All Jobs`,po_msa:`PO MSA`,reApprove:`ReApprove`,sendApprove:`Send Approve`};function BP(e){return zP[e]??e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function VP(e){let t=RP.filter(t=>e.includes(t)),n=e.filter(e=>!RP.includes(e)).sort();return[...t,...n]}function HP(e){let t=new Set;return Object.values(e).forEach(({permissions:e})=>Object.keys(e??{}).forEach(e=>t.add(e))),VP([...t])}function UP(e){let t=0,n=0;return Object.entries(e).forEach(([e,{permissions:r}])=>{Object.entries(r??{}).forEach(([r,{value:i}])=>{wS(e,r)&&(n++,i===`1`&&t++)})}),{enabled:t,total:n}}function WP(e={}){if(!e||typeof e!=`object`)return e;let t=Object.keys(e).find(e=>String(e).trim().toLowerCase()===`onboarding`);if(!t)return e;let n=e[t]??{},r={...n.permissions??{}};for(let e of[`sendApprove`,`reApprove`])Object.keys(r).some(t=>t.toLowerCase()===e.toLowerCase())||(r[e]={id:0,value:`0`});return{...e,[t]:{...n,permissions:r}}}function GP({value:e,onSave:t,className:n}){let[r,i]=(0,s.useState)(!1),[a,o]=(0,s.useState)(e);(0,s.useEffect)(()=>{o(e)},[e]);function c(){i(!1);let n=a.trim();n&&n!==e?t(n):o(e)}return r?(0,u.jsx)(`input`,{autoFocus:!0,className:`perm-inline-input${n?` ${n}`:``}`,value:a,style:{width:Math.max(48,a.length*8)},onChange:e=>o(e.target.value),onBlur:c,onKeyDown:t=>{t.key===`Enter`&&c(),t.key===`Escape`&&(i(!1),o(e)),t.stopPropagation()},onClick:e=>e.stopPropagation()}):(0,u.jsxs)(`span`,{className:`perm-editable-name${n?` ${n}`:``}`,onDoubleClick:e=>{e.stopPropagation(),i(!0)},children:[e,(0,u.jsx)(l.EditOutlined,{className:`perm-name-edit-icon`})]})}function KP({entry:e,label:t,onToggle:n,onLabelSave:r}){let[i,a]=(0,s.useState)(!1),[o,d]=(0,s.useState)(t),f=e?.value===`1`,p=!!e;(0,s.useEffect)(()=>{d(t)},[t]);function m(){a(!1);let e=o.trim();e&&e!==t?r(e):d(t)}return(0,u.jsx)(c.Tooltip,{title:p?f?`Click to disable`:`Click to enable`:`Not applicable for this module`,children:(0,u.jsxs)(`div`,{className:`perm-action-pill${f?` on`:``}${p?``:` na`}`,onClick:()=>{!i&&p&&n()},children:[(0,u.jsx)(`span`,{className:`perm-action-pill-dot${f?` on`:``}`}),i?(0,u.jsx)(`input`,{autoFocus:!0,className:`perm-pill-input`,value:o,style:{width:Math.max(36,o.length*7)},onChange:e=>d(e.target.value),onBlur:m,onKeyDown:e=>{e.key===`Enter`&&m(),e.key===`Escape`&&(a(!1),d(t)),e.stopPropagation()},onClick:e=>e.stopPropagation()}):(0,u.jsx)(`span`,{className:`perm-action-pill-label`,onDoubleClick:e=>{e.stopPropagation(),a(!0)},children:t}),f&&!i&&(0,u.jsx)(l.CheckOutlined,{className:`perm-action-pill-check`})]})})}function qP({menuName:e,menuData:t,permKeys:n,onChange:r,displayName:i,actionLabels:a,onModuleLabelSave:o,onActionLabelSave:s}){let c=t?.permissions??{},l=n.filter(t=>wS(e,t)),d=l.filter(e=>c[e]?.value===`1`).length,f=l.filter(e=>c[e]).length,p=f>0&&d===f;return(0,u.jsxs)(`div`,{className:`perm-module-card${p?` all-on`:d>0&&!p?` some-on`:``}`,children:[(0,u.jsxs)(`div`,{className:`perm-module-card-header`,children:[(0,u.jsx)(GP,{value:i,onSave:t=>o(e,t),className:`perm-module-card-name`}),f>0&&(0,u.jsxs)(`span`,{className:`perm-module-card-badge${d>0?` active`:``}`,children:[d,`/`,f]})]}),(0,u.jsx)(`div`,{className:`perm-module-card-body`,children:l.map(t=>(0,u.jsx)(KP,{entry:c[t],label:a[t]??BP(t),onToggle:()=>r(e,t),onLabelSave:e=>s(t,e)},t))})]})}function JP({role:e,moduleLabels:t={},actionLabels:r={},onModuleLabelSave:i=()=>{},onActionLabelSave:a=()=>{}}){let[o,d]=(0,s.useState)({}),[f,p]=(0,s.useState)({}),[m,h]=(0,s.useState)(!1),[g,_]=(0,s.useState)(!1),[v,y]=(0,s.useState)(!1),b=n._i(e);(0,s.useEffect)(()=>{b&&(h(!0),y(!1),n.bi(b).then(e=>{let t=WP(e);d(t),p(t)}).catch(()=>c.message.error(`Failed to load permissions`)).finally(()=>h(!1)))},[b]);function x(e,t){y(!0),p(n=>{let r=n[e]??{menuId:o[e]?.menuId??0,permissions:{}},i=r.permissions?.[t]??{id:0,value:`0`};return{...n,[e]:{...r,permissions:{...r.permissions,[t]:{...i,value:i.value===`1`?`0`:`1`}}}}})}async function S(){_(!0);try{await n.qi(b,f),d(f),y(!1),c.message.success(`Permissions saved`)}catch(e){c.message.error(e?.message||`Save failed`)}finally{_(!1)}}let C=(0,s.useMemo)(()=>Object.keys(f).sort(),[f]),w=(0,s.useMemo)(()=>HP(f),[f]),{enabled:T,total:E}=(0,s.useMemo)(()=>UP(f),[f]);return(0,u.jsxs)(c.Spin,{spinning:m,children:[(0,u.jsxs)(`div`,{className:`perm-panel-header`,children:[(0,u.jsxs)(`div`,{className:`perm-panel-title`,children:[(0,u.jsx)(l.LockOutlined,{style:{color:`var(--color-brand)`,marginRight:6}}),(0,u.jsx)(`span`,{children:e?.roleName}),!m&&E>0&&(0,u.jsxs)(c.Tag,{color:`blue`,style:{marginLeft:8,fontSize:11},children:[T,`/`,E,` enabled`]})]}),(0,u.jsx)(c.Button,{type:`primary`,size:`small`,icon:(0,u.jsx)(l.UnlockOutlined,{}),loading:g,disabled:!v,onClick:S,children:`Save Changes`})]}),(0,u.jsxs)(`div`,{className:`perm-hint`,children:[(0,u.jsx)(l.InfoCircleOutlined,{className:`perm-hint-icon`}),(0,u.jsxs)(`span`,{children:[`Click a pill to toggle. `,(0,u.jsx)(`strong`,{children:`Double-click`}),` a module name or action label to rename it — labels are saved locally.`]})]}),C.length===0&&!m?(0,u.jsx)(`div`,{className:`perm-empty`,children:`No permission entries found for this role.`}):(0,u.jsx)(`div`,{className:`perm-cards-grid`,children:C.map(e=>(0,u.jsx)(qP,{menuName:e,menuData:f[e],permKeys:w,onChange:x,displayName:t[e]??e,actionLabels:r,onModuleLabelSave:i,onActionLabelSave:a},e))})]})}var{Text:YP}=c.Typography,XP=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`}];function ZP(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function QP(e){return String(e||``).trim().toLowerCase()}function $P(e){return e?.key||e?.collectionName||e?.value||``}function eF(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=$P(e);if(!t)return;let o=QP(e.key||t),s=QP(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||ZP(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=QP(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:ZP(t),value:t,disabled:!1}))}),n}function tF(){let[e,t]=(0,s.useState)(null),[r,i]=(0,s.useState)(!1),[a,o]=(0,s.useState)(`listView`),[d,f]=(0,s.useState)([]),[p,m]=(0,s.useState)(0),[h,g]=(0,s.useState)(!1),[_,v]=(0,s.useState)([]),[y,b]=(0,s.useState)([]),[x,S]=(0,s.useState)(!1),[C,w]=(0,s.useState)(!1),T=(0,s.useMemo)(()=>_.filter(e=>!e.disabled),[_]),E=!x&&T.length===0,D=(0,s.useCallback)(async()=>{g(!0);try{let e=await n.Gr();f(e.roles),m(e.total)}catch{c.message.error(`Failed to load roles`)}finally{g(!1)}},[]),O=(0,s.useCallback)(async()=>{S(!0);try{let[e,t]=await Promise.all([n.ri(),n.Yr()]),r=eF(e.modules,t),i=new Set(r.filter(e=>!e.disabled).map(e=>e.value));v(r),b(e=>e.filter(e=>i.has(e)))}catch{c.message.error(`Failed to load seed status`)}finally{S(!1)}},[]);(0,s.useEffect)(()=>{D()},[D]),(0,s.useEffect)(()=>{O()},[O]);async function k(){if(y.length===0){c.message.warning(E?`All modules already seeded.`:`Select at least one module to seed.`);return}w(!0);try{await n.Li(y),c.message.success(`Role field config seeded`),b([]),await O()}catch(e){c.message.error(e?.message||`Seed failed`)}finally{w(!1)}}function A(e,n=`listView`){t(e),o(n),i(!0)}return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.AppstoreOutlined,{}),title:`Field Config Seed`,style:{marginBottom:12},children:[(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[(0,u.jsx)(`div`,{style:{minWidth:320,flex:1},children:(0,u.jsx)(c.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,u.jsx)(c.Button,{type:`primary`,loading:C,disabled:x||y.length===0,onClick:k,children:`Seed Field Config`})]}),(0,u.jsx)(YP,{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,u.jsx)(Z,{icon:(0,u.jsx)(l.SafetyOutlined,{}),title:`Roles`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,u.jsx)(kh,{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,u.jsxs)(c.Space,{size:2,children:[(0,u.jsx)(c.Button,{size:`small`,type:`link`,onClick:()=>A(t),children:`Configure`}),(0,u.jsx)(c.Button,{size:`small`,type:`link`,icon:(0,u.jsx)(l.LockOutlined,{}),onClick:()=>A(t,`permissions`),children:`Permissions`})]})}],loading:h,total:p})}),(0,u.jsxs)(c.Modal,{className:`uss-modal`,open:r,onCancel:()=>i(!1),title:(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,u.jsx)(l.SafetyOutlined,{style:{color:`var(--color-brand)`}}),(0,u.jsxs)(`span`,{children:[`Configure: `,e?.roleName]})]}),width:720,footer:null,destroyOnClose:!0,children:[(0,u.jsx)(`div`,{style:{marginBottom:12},children:(0,u.jsx)(`div`,{className:`uss-config-toggle`,children:XP.map(e=>(0,u.jsx)(`button`,{className:`uss-config-btn${a===e.key?` active`:``}`,onClick:()=>o(e.key),children:e.label},e.key))})}),e&&(a===`permissions`?(0,u.jsx)(JP,{role:e},e?.roleId):(0,u.jsx)(VS,{role:e,configType:a},`${e?.roleId}-${a}`))]})]})}var nF=`perm-module-labels`,rF=`perm-action-labels`;function iF(e){try{return JSON.parse(localStorage.getItem(e)??`{}`)}catch{return{}}}function aF(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function oF({label:e,onSave:t,onDelete:n,loading:r}){let[i,a]=(0,s.useState)(!1),[o,d]=(0,s.useState)(e);function f(){a(!1);let n=o.trim();n&&n!==e?t(n):d(e)}return(0,u.jsxs)(`div`,{className:`perm-manage-row`,children:[i?(0,u.jsx)(`input`,{autoFocus:!0,className:`perm-inline-input`,value:o,style:{flex:1,minWidth:0},onChange:e=>d(e.target.value),onBlur:f,onKeyDown:t=>{t.key===`Enter`&&f(),t.key===`Escape`&&(a(!1),d(e))}}):(0,u.jsx)(`span`,{className:`perm-manage-row-label`,children:e}),(0,u.jsxs)(`div`,{className:`perm-manage-row-actions`,children:[(0,u.jsx)(c.Button,{type:`text`,size:`small`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>{d(e),a(!0)},loading:r}),(0,u.jsx)(c.Popconfirm,{title:`Delete this item?`,onConfirm:n,okText:`Delete`,cancelText:`Cancel`,okType:`danger`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,icon:(0,u.jsx)(l.DeleteOutlined,{}),danger:!0})})]})]})}function sF({open:e,onClose:t}){let[r,i]=(0,s.useState)(`modules`),[a,o]=(0,s.useState)([]),[d,f]=(0,s.useState)(!1),[p,m]=(0,s.useState)(``),[h,g]=(0,s.useState)(!1),[_,v]=(0,s.useState)([]),[y,b]=(0,s.useState)(!1),[x,S]=(0,s.useState)(``),[C,w]=(0,s.useState)(``),[T,E]=(0,s.useState)(!1);(0,s.useEffect)(()=>{e&&(D(),O())},[e]);async function D(){f(!0);try{o(await n.ui())}catch{c.message.error(`Failed to load modules`)}finally{f(!1)}}async function O(){b(!0);try{v(await n.li())}catch{c.message.error(`Failed to load actions`)}finally{b(!1)}}async function k(){let e=p.trim();if(!e){c.message.warning(`Enter a module name`);return}g(!0);try{let t=await n.Er({menuName:e});o(e=>[...e,t]),m(``),c.message.success(`Module added`)}catch{c.message.error(`Failed to add module`)}finally{g(!1)}}async function A(e,t){try{await n.Ui(e,{menuName:t}),o(n=>n.map(n=>n.MENUID===e?{...n,MENUNAME:t}:n))}catch{c.message.error(`Failed to update module`)}}async function j(e){try{await n.Fr(e),o(t=>t.filter(t=>t.MENUID!==e)),c.message.success(`Module deleted`)}catch{c.message.error(`Failed to delete module`)}}async function M(){let e=x.trim(),t=C.trim().toLowerCase().replace(/\s+/g,`_`);if(!e||!t){c.message.warning(`Enter both name and key`);return}E(!0);try{let r=await n.Tr({permissionName:e,permissionKey:t});v(e=>[...e,r]),S(``),w(``),c.message.success(`Action added`)}catch(e){c.message.error(e?.message?.includes(`409`)||e?.status===409?`Permission key already exists`:`Failed to add action`)}finally{E(!1)}}async function N(e,t){try{await n.Hi(e,{permissionName:t}),v(n=>n.map(n=>n.permissionId===e?{...n,permissionName:t}:n))}catch{c.message.error(`Failed to update action`)}}async function P(e){try{await n.Pr(e),v(t=>t.filter(t=>t.permissionId!==e)),c.message.success(`Action deleted`)}catch{c.message.error(`Failed to delete action`)}}let F=[{key:`modules`,label:`Modules`,children:(0,u.jsxs)(c.Spin,{spinning:d,children:[(0,u.jsxs)(`div`,{className:`perm-manage-add-row`,children:[(0,u.jsx)(c.Input,{placeholder:`Module name`,value:p,onChange:e=>m(e.target.value),onPressEnter:k,style:{flex:1},size:`small`}),(0,u.jsx)(c.Button,{type:`primary`,size:`small`,icon:(0,u.jsx)(l.PlusOutlined,{}),loading:h,onClick:k,children:`Add`})]}),(0,u.jsxs)(`div`,{className:`perm-manage-list`,children:[a.length===0&&!d&&(0,u.jsx)(`div`,{className:`perm-empty`,style:{paddingTop:24},children:`No modules found`}),a.map(e=>(0,u.jsx)(oF,{label:e.MENUNAME,onSave:t=>A(e.MENUID,t),onDelete:()=>j(e.MENUID)},e.MENUID))]})]})},{key:`actions`,label:`Actions`,children:(0,u.jsxs)(c.Spin,{spinning:y,children:[(0,u.jsxs)(`div`,{className:`perm-manage-add-row`,children:[(0,u.jsx)(c.Input,{placeholder:`Action name (e.g. Approve)`,value:x,onChange:e=>S(e.target.value),style:{flex:1},size:`small`}),(0,u.jsx)(c.Input,{placeholder:`Key (e.g. approve)`,value:C,onChange:e=>w(e.target.value),onPressEnter:M,style:{width:140},size:`small`}),(0,u.jsx)(c.Button,{type:`primary`,size:`small`,icon:(0,u.jsx)(l.PlusOutlined,{}),loading:T,onClick:M,children:`Add`})]}),(0,u.jsxs)(`div`,{className:`perm-manage-list`,children:[_.length===0&&!y&&(0,u.jsx)(`div`,{className:`perm-empty`,style:{paddingTop:24},children:`No actions found`}),_.map(e=>(0,u.jsx)(oF,{label:`${e.permissionName} (${e.permissionKey})`,onSave:t=>N(e.permissionId,t),onDelete:()=>P(e.permissionId)},e.permissionId))]})]})}];return(0,u.jsx)(c.Modal,{open:e,onCancel:t,title:(0,u.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,u.jsx)(l.SettingOutlined,{style:{color:`var(--color-brand)`}}),`Manage Modules & Actions`]}),width:520,footer:null,destroyOnClose:!0,children:(0,u.jsx)(c.Tabs,{activeKey:r,onChange:i,size:`small`,items:F})})}function cF(){let[e,t]=(0,s.useState)([]),[r,i]=(0,s.useState)(!1),[a,o]=(0,s.useState)(null),[d,f]=(0,s.useState)(``),[p,m]=(0,s.useState)(!1),[h,g]=(0,s.useState)(()=>iF(nF)),[_,v]=(0,s.useState)(()=>iF(rF)),y=(0,s.useCallback)((e,t)=>{g(n=>{let r={...n,[e]:t};return aF(nF,r),r})},[]),b=(0,s.useCallback)((e,t)=>{v(n=>{let r={...n,[e]:t};return aF(rF,r),r})},[]);function x(){g({}),v({}),aF(nF,{}),aF(rF,{}),c.message.success(`Labels reset to defaults`)}let S=(0,s.useCallback)(async()=>{i(!0);try{let{roles:e}=await n.Gr();t(e),e.length>0&&o(e[0])}catch{c.message.error(`Failed to load roles`)}finally{i(!1)}},[]);(0,s.useEffect)(()=>{S()},[S]);let C=(0,s.useMemo)(()=>{let t=d.trim().toLowerCase();return t?e.filter(e=>e.roleName.toLowerCase().includes(t)):e},[e,d]),w=Object.keys(h).length>0||Object.keys(_).length>0;return(0,u.jsxs)(`div`,{className:`perm-page`,children:[(0,u.jsxs)(Z,{className:`perm-left-card`,icon:(0,u.jsx)(l.SafetyOutlined,{}),title:`Roles`,bodyStyle:{padding:0},children:[(0,u.jsx)(`div`,{className:`perm-role-search`,children:(0,u.jsx)(c.Input,{prefix:(0,u.jsx)(l.SearchOutlined,{}),placeholder:`Search roles…`,allowClear:!0,size:`small`,value:d,onChange:e=>f(e.target.value)})}),(0,u.jsx)(c.Spin,{spinning:r,children:(0,u.jsxs)(`div`,{className:`perm-role-list`,children:[C.length===0&&!r&&(0,u.jsx)(`div`,{className:`perm-role-empty`,children:`No roles found`}),C.map(e=>{let t=a?.roleId===e.roleId,n=e.description&&e.description!==`N/A`?e.description:e.roleType===0?`Default role`:`Custom role`;return(0,u.jsxs)(`div`,{className:`perm-role-item${t?` active`:``}`,onClick:()=>o(e),children:[(0,u.jsx)(`div`,{className:`perm-role-item-name`,children:e.roleName}),(0,u.jsx)(`div`,{className:`perm-role-item-desc`,children:n})]},e.roleId)})]})})]}),(0,u.jsx)(Z,{className:`perm-right-card`,icon:(0,u.jsx)(l.LockOutlined,{}),title:`Module Permissions`,extra:(0,u.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[w&&(0,u.jsx)(`button`,{className:`perm-reset-btn`,onClick:x,children:`Reset labels`}),(0,u.jsx)(c.Button,{size:`small`,icon:(0,u.jsx)(l.SettingOutlined,{}),onClick:()=>m(!0),children:`Manage`})]}),bodyStyle:{padding:`12px 16px`},children:a?(0,u.jsx)(JP,{role:a,moduleLabels:h,actionLabels:_,onModuleLabelSave:y,onActionLabelSave:b},a.roleId):(0,u.jsx)(`div`,{className:`perm-empty`,children:`Select a role from the left to manage its permissions.`})}),(0,u.jsx)(sF,{open:p,onClose:()=>m(!1)})]})}var{Title:lF,Text:uF}=c.Typography,dF=[{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 fF({items:e=dF}){return(0,u.jsx)(c.Card,{className:`onboarding-card`,title:(0,u.jsx)(lF,{level:5,children:`Onboarding`}),extra:(0,u.jsx)(c.Button,{type:`link`,children:`View all`}),children:(0,u.jsx)(c.Row,{gutter:[12,12],children:e.map(e=>(0,u.jsx)(c.Col,{xs:12,sm:6,md:6,lg:12,xl:12,children:(0,u.jsxs)(`div`,{className:`onboarding-item ${e.color}`,children:[(0,u.jsx)(uF,{className:`onboarding-item-label`,children:e.label}),(0,u.jsx)(c.Statistic,{value:e.value,className:`onboarding-stat`}),(0,u.jsx)(`div`,{className:`onboarding-item-footer`,children:(0,u.jsx)(uF,{className:`onboarding-item-sub`,children:e.sub})})]})},e.label))})})}var{Text:pF,Title:mF}=c.Typography,hF=[{group:`Dashboard`,items:[{id:`dashboard`,label:`Admin Dashboard`,icon:(0,u.jsx)(l.DashboardOutlined,{})}]},{group:`Settings`,items:[{id:`org`,label:`Organization`,icon:(0,u.jsx)(l.BankOutlined,{}),heading:`Organization Settings`,desc:`Manage your company profile and location details`,cards:[{label:`Company Information`,icon:(0,u.jsx)(l.BankOutlined,{}),desc:`Manage company profile, address and business details.`},{label:`Location`,icon:(0,u.jsx)(l.BuildOutlined,{}),desc:`Manage office locations, branches and regions.`}]},{id:`users`,label:`Users`,icon:(0,u.jsx)(l.UserOutlined,{}),heading:`Users`,desc:`Manage platform users and configure their field views.`,component:`users`},{id:`teams`,label:`Teams`,icon:(0,u.jsx)(l.TeamOutlined,{}),heading:`Teams`,desc:`Organize users into teams and configure field visibility per team.`,component:`teams`},{id:`roles`,label:`Roles`,icon:(0,u.jsx)(l.SafetyOutlined,{}),heading:`Roles`,desc:`Control permissions and configure field visibility per role.`,component:`roles`},{id:`permissions`,label:`Permissions`,icon:(0,u.jsx)(l.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,u.jsx)(l.FileTextOutlined,{}),heading:`Templates`,desc:`Email and signature templates for communications`,component:`templates`},{id:`ai-services`,label:`AI Services`,icon:(0,u.jsx)(l.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,u.jsx)(l.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,u.jsx)(l.BankOutlined,{}),heading:`Clients`,desc:`Manage client accounts and settings`,cards:[{label:`Clients`,icon:(0,u.jsx)(l.BankOutlined,{}),desc:`Manage client companies and account details.`}]}]},{group:`Forms`,items:[{id:`form-groups`,label:`Form Groups`,icon:(0,u.jsx)(l.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,u.jsx)(l.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,u.jsx)(l.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,u.jsx)(l.AppstoreOutlined,{}),heading:`Jobs Master`,desc:`Configure job sources and status types`,cards:[{label:`Sources`,icon:(0,u.jsx)(l.AppstoreOutlined,{}),desc:`Manage job source master values.`},{label:`Job Status`,icon:(0,u.jsx)(l.CheckCircleOutlined,{}),desc:`Configure job workflow status.`}]},{id:`candidates`,label:`Candidates`,icon:(0,u.jsx)(l.UserOutlined,{}),heading:`Candidates Master`,desc:`Skills, sources and work authorization settings`,cards:[{label:`Sources`,icon:(0,u.jsx)(l.AppstoreOutlined,{}),desc:`Manage candidate source values.`},{label:`Skills`,icon:(0,u.jsx)(l.SettingOutlined,{}),desc:`Manage skill master data.`},{label:`Work Authorization`,icon:(0,u.jsx)(l.SafetyOutlined,{}),desc:`Manage visa and authorization types.`}]},{id:`submissions`,label:`Submissions`,icon:(0,u.jsx)(l.FileTextOutlined,{}),heading:`Submissions Master`,desc:`Rejection reasons and submission status configuration`,cards:[{label:`Rejection Reasons`,icon:(0,u.jsx)(l.FileTextOutlined,{}),desc:`Manage common rejection reasons.`},{label:`Client Submission Status`,icon:(0,u.jsx)(l.CheckCircleOutlined,{}),desc:`Manage client submission statuses.`}]},{id:`clientmaster`,label:`Client Master`,icon:(0,u.jsx)(l.BankOutlined,{}),heading:`Client Master`,desc:`Payment terms, client types and contact types`,cards:[{label:`Payment Terms`,icon:(0,u.jsx)(l.FileTextOutlined,{}),desc:`Manage billing and payment terms.`},{label:`Client Type`,icon:(0,u.jsx)(l.AppstoreOutlined,{}),desc:`Classify client business types.`},{label:`Client Contact Type`,icon:(0,u.jsx)(l.TeamOutlined,{}),desc:`Manage client contact categories.`}]}]}],gF=[{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}],_F=[{name:`Tcs`,jobs:14,candidates:86},{name:`Empasis`,jobs:9,candidates:64},{name:`NovaSystems`,jobs:7,candidates:51},{name:`Brightwave`,jobs:5,candidates:38}],vF=[{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 yF(){return(0,u.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:16},children:[(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.DashboardOutlined,{}),title:`Admin Dashboard`,children:[(0,u.jsx)(`div`,{className:`admin-accent-bar`}),(0,u.jsx)(mF,{level:5,children:`Admin Dashboard`}),(0,u.jsx)(pF,{type:`secondary`,children:`Overview of jobs, candidates, onboarding and recent activity`})]}),(0,u.jsx)(`div`,{className:`admin-dashboard-stats`,children:(0,u.jsx)(DP,{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,u.jsxs)(`div`,{className:`admin-dashboard-mid-row`,children:[(0,u.jsx)(fF,{}),(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.AppstoreOutlined,{}),title:`Candidate Pipeline`,children:[(0,u.jsx)(pF,{type:`secondary`,style:{fontSize:12},children:`By stage (892 total)`}),(0,u.jsx)(`div`,{className:`admin-pipeline-bar`,children:gF.map(e=>(0,u.jsx)(`div`,{className:`admin-pipeline-seg`,style:{width:`${e.pct}%`,background:e.color}},e.label))}),(0,u.jsx)(`div`,{className:`admin-pipeline-legend`,children:gF.map(e=>(0,u.jsxs)(`div`,{className:`admin-pipeline-legend-item`,children:[(0,u.jsx)(`span`,{className:`admin-pipeline-dot`,style:{background:e.color}}),e.label,` `,e.count]},e.label))}),(0,u.jsx)(`div`,{className:`admin-divider`}),(0,u.jsx)(pF,{strong:!0,style:{fontSize:12},children:`Submission status`}),(0,u.jsxs)(`div`,{className:`admin-sub-status-list`,style:{marginTop:6},children:[(0,u.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,u.jsx)(pF,{style:{fontSize:13},children:`Pending client review`}),(0,u.jsx)(`span`,{className:`admin-badge warn`,children:`312`})]}),(0,u.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,u.jsx)(pF,{style:{fontSize:13},children:`Client approved`}),(0,u.jsx)(`span`,{className:`admin-badge success`,children:`248`})]}),(0,u.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,u.jsx)(pF,{style:{fontSize:13},children:`Rejected`}),(0,u.jsx)(`span`,{className:`admin-badge danger`,children:`89`})]})]})]})]}),(0,u.jsxs)(`div`,{className:`admin-dashboard-bottom-row`,children:[(0,u.jsx)(Z,{icon:(0,u.jsx)(l.BankOutlined,{}),title:`Top Clients`,extra:(0,u.jsx)(c.Button,{type:`link`,size:`small`,children:`View all`}),children:_F.map(e=>(0,u.jsxs)(`div`,{className:`admin-client-row`,children:[(0,u.jsxs)(`div`,{className:`admin-client-left`,children:[(0,u.jsx)(`div`,{className:`admin-client-icon`,children:(0,u.jsx)(l.BankOutlined,{})}),(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`div`,{className:`admin-client-name`,children:e.name}),(0,u.jsxs)(`div`,{className:`admin-client-sub`,children:[e.jobs,` open jobs`]})]})]}),(0,u.jsxs)(`div`,{className:`admin-client-right`,children:[(0,u.jsx)(`div`,{className:`admin-client-val`,children:e.candidates}),(0,u.jsx)(`div`,{className:`admin-client-sub`,children:`candidates`})]})]},e.name))}),(0,u.jsx)(Z,{icon:(0,u.jsx)(l.BellOutlined,{}),title:`Recent Activity`,children:vF.map((e,t)=>(0,u.jsxs)(`div`,{className:`admin-activity-row`,children:[(0,u.jsx)(`div`,{className:`admin-activity-dot`,style:{background:e.color}}),(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`div`,{className:`admin-activity-text`,children:e.text}),(0,u.jsx)(`div`,{className:`admin-activity-time`,children:e.time})]})]},t))})]}),(0,u.jsx)(Z,{icon:(0,u.jsx)(l.SettingOutlined,{}),title:`Admin Configuration Overview`,extra:(0,u.jsx)(c.Button,{type:`link`,size:`small`,children:`Manage`}),children:(0,u.jsxs)(c.Row,{gutter:[24,0],children:[(0,u.jsxs)(c.Col,{span:8,children:[(0,u.jsx)(pF,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`Settings`}),[[`Organization`,2],[`User Settings`,4],[`Templates`,2]].map(([e,t])=>(0,u.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,u.jsx)(pF,{style:{fontSize:12},children:e}),(0,u.jsxs)(`span`,{className:`admin-badge info`,children:[t,` items`]})]},e))]}),(0,u.jsxs)(c.Col,{span:8,children:[(0,u.jsx)(pF,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`Master`}),[[`Jobs`,2],[`Candidates`,3],[`Submissions`,2]].map(([e,t])=>(0,u.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,u.jsx)(pF,{style:{fontSize:12},children:e}),(0,u.jsxs)(`span`,{className:`admin-badge info`,children:[t,` items`]})]},e))]}),(0,u.jsxs)(c.Col,{span:8,children:[(0,u.jsx)(pF,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`System`}),[[`Total Groups`,4],[`Total Modules`,9],[`Config Items`,19]].map(([e,t])=>(0,u.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,u.jsx)(pF,{style:{fontSize:12},children:e}),(0,u.jsx)(pF,{strong:!0,style:{fontSize:12},children:t})]},e))]})]})})]})}function bF({activeSection:e,activeGroup:t,filteredCards:n,searchText:r,setSearchText:i,allItems:a,handleNav:o}){return(0,u.jsxs)(c.Row,{gutter:[16,16],children:[(0,u.jsx)(c.Col,{span:24,children:(0,u.jsxs)(Z,{icon:e?.icon,title:e?.heading,extra:(0,u.jsx)(c.Input,{className:`admin-search`,prefix:(0,u.jsx)(l.SearchOutlined,{}),placeholder:`Search settings…`,allowClear:!0,value:r,onChange:e=>i(e.target.value)}),children:[(0,u.jsx)(`div`,{className:`admin-accent-bar`}),(0,u.jsx)(mF,{level:5,children:e?.heading}),(0,u.jsx)(pF,{type:`secondary`,children:e?.desc})]})}),(0,u.jsx)(c.Col,{xs:24,xl:16,style:{alignSelf:`flex-start`},children:(0,u.jsx)(Z,{icon:(0,u.jsx)(l.AppstoreOutlined,{}),title:`Configuration Items`,extra:(0,u.jsxs)(pF,{type:`secondary`,children:[n.length,` item`,n.length===1?``:`s`]}),children:(0,u.jsx)(c.Row,{gutter:[14,14],children:n.length>0?n.map(e=>(0,u.jsx)(c.Col,{xs:24,sm:12,xl:8,children:(0,u.jsxs)(`div`,{className:`admin-config-item`,children:[(0,u.jsx)(`div`,{className:`admin-config-top-bar`}),(0,u.jsxs)(`div`,{className:`admin-config-body`,children:[(0,u.jsx)(`div`,{className:`admin-config-icon`,children:e.icon}),(0,u.jsxs)(`div`,{className:`admin-config-text`,children:[(0,u.jsx)(`span`,{className:`admin-config-label`,children:e.label}),(0,u.jsx)(`span`,{className:`admin-config-desc`,children:e.desc})]})]}),(0,u.jsx)(`div`,{className:`admin-config-divider`}),(0,u.jsx)(c.Button,{type:`link`,size:`small`,className:`admin-config-manage`,icon:(0,u.jsx)(l.RightOutlined,{}),iconPosition:`end`,children:`Manage`})]})},e.label)):(0,u.jsx)(c.Col,{span:24,children:(0,u.jsx)(`div`,{className:`admin-config-empty`,children:(0,u.jsx)(c.Empty,{description:`No settings found`,image:c.Empty.PRESENTED_IMAGE_SIMPLE})})})})})}),(0,u.jsx)(c.Col,{xs:24,xl:8,style:{alignSelf:`flex-start`},children:(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.FileTextOutlined,{}),title:`Section Overview`,children:[(0,u.jsx)(`div`,{className:`admin-overview-list`,children:hF.filter(e=>e.group!==`Dashboard`).map(e=>{let n=e.group===t?.group;return(0,u.jsxs)(`div`,{className:`admin-overview-item${n?` active`:``}`,onClick:()=>{let t=e.items[0];t&&o(t.id)},children:[(0,u.jsxs)(`div`,{className:`admin-overview-left`,children:[(0,u.jsx)(`div`,{className:`admin-overview-icon`,children:e.items[0]?.icon}),(0,u.jsxs)(`div`,{className:`admin-overview-text`,children:[(0,u.jsx)(`span`,{className:`admin-overview-name`,children:e.group}),(0,u.jsxs)(`span`,{className:`admin-overview-sub`,children:[e.items.length,` module`,e.items.length===1?``:`s`]})]})]}),(0,u.jsx)(`span`,{className:`admin-overview-count${n?` active`:``}`,children:e.items.length})]},e.group)})}),(0,u.jsxs)(`div`,{className:`admin-overview-footer`,children:[(0,u.jsx)(`span`,{className:`admin-overview-footer-label`,children:`Total configuration items`}),(0,u.jsx)(`span`,{className:`admin-overview-footer-value`,children:a.filter(e=>e.cards).reduce((e,t)=>e+t.cards.length,0)})]})]})})]})}function xF(){let[e,t]=(0,s.useState)(`dashboard`),[n,r]=(0,s.useState)(``),i=(0,s.useMemo)(()=>hF.flatMap(e=>e.items),[]),a=(0,s.useMemo)(()=>i.find(t=>t.id===e),[i,e]),o=(0,s.useMemo)(()=>hF.find(t=>t.items.some(t=>t.id===e)),[e]),d=(0,s.useMemo)(()=>{if(!a?.cards)return[];let e=n.trim().toLowerCase();return e?a.cards.filter(t=>t.label.toLowerCase().includes(e)||t.desc.toLowerCase().includes(e)):a.cards},[a,n]),f=(0,s.useMemo)(()=>hF.map(e=>({key:e.group,type:`group`,label:e.group,children:e.items.map(e=>({key:e.id,icon:e.icon,label:e.label}))})),[]),p=e=>{t(e),r(``)};return e===`dashboard`||a?.heading,(0,u.jsxs)(`main`,{className:`admin-page`,children:[(0,u.jsx)(`div`,{className:`admin-breadcrumb`,children:(0,u.jsx)(c.Breadcrumb,{items:[{title:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(l.HomeOutlined,{}),` Home`]})},{title:`Admin`}]})}),(0,u.jsxs)(c.Row,{gutter:[16,16],className:`admin-wrapper`,children:[(0,u.jsx)(c.Col,{xs:24,lg:6,xl:5,children:(0,u.jsxs)(Z,{title:`Admin Console`,icon:(0,u.jsx)(l.SettingOutlined,{}),children:[(0,u.jsxs)(`div`,{className:`admin-sidebar-banner`,children:[(0,u.jsx)(`span`,{className:`admin-sidebar-banner-title`,children:`Admin Panel`}),(0,u.jsx)(`span`,{className:`admin-sidebar-banner-sub`,children:`Configuration Center`}),(0,u.jsxs)(c.Row,{gutter:[8,0],children:[(0,u.jsx)(c.Col,{span:12,children:(0,u.jsxs)(`div`,{className:`admin-sidebar-pill`,children:[(0,u.jsx)(`span`,{className:`admin-sidebar-pill-label`,children:`Groups`}),(0,u.jsx)(`span`,{className:`admin-sidebar-pill-value`,children:hF.length})]})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsxs)(`div`,{className:`admin-sidebar-pill`,children:[(0,u.jsx)(`span`,{className:`admin-sidebar-pill-label`,children:`Modules`}),(0,u.jsx)(`span`,{className:`admin-sidebar-pill-value`,children:i.length})]})})]})]}),(0,u.jsx)(c.Menu,{mode:`inline`,selectedKeys:[e],items:f,onClick:({key:e})=>p(e),className:`admin-sidebar-menu`})]})}),(0,u.jsx)(c.Col,{xs:24,lg:18,xl:19,children:e===`dashboard`?(0,u.jsx)(yF,{}):a?.component===`form-groups`?(0,u.jsx)(qw,{}):a?.component===`detail-groups`?(0,u.jsx)(kT,{}):a?.component===`row-actions`?(0,u.jsx)(yE,{}):a?.component===`users`?(0,u.jsx)(jP,{}):a?.component===`teams`?(0,u.jsx)(LP,{}):a?.component===`roles`?(0,u.jsx)(tF,{}):a?.component===`permissions`?(0,u.jsx)(cF,{}):a?.component===`templates`?(0,u.jsx)(jE,{}):a?.component===`ai-services`?(0,u.jsx)(RE,{}):a?.component===`bgc-integration`?(0,u.jsx)(WE,{}):(0,u.jsx)(bF,{activeSection:a,activeGroup:o,filteredCards:d,searchText:n,setSearchText:r,allItems:i,handleNav:p})})]})]})}var{Title:SF}=c.Typography;function CF(){let e=(0,f.useNavigate)(),{state:t}=(0,f.useLocation)(),n=t?.moduleName||`stickyNotes`,r=t?.title||`Sticky Notes`,i={...t?.request,params:{...t?.request?.params,limit:200,offset:0}};return(0,u.jsxs)(`div`,{children:[(0,u.jsx)(c.Button,{type:`text`,icon:(0,u.jsx)(l.ArrowLeftOutlined,{}),onClick:()=>e(-1),style:{marginBottom:12},children:`Back`}),(0,u.jsx)(Bt,{moduleName:n,title:r,columns:4,request:i,viewAll:!1})]})}var{Text:wF,Title:TF}=c.Typography,EF=10485760,DF=`/templates/test_cases_flow_template.base64.txt`,OF=`test_cases_flow_template.xlsx`,kF=`module | subModule | step_order | description | actions | key | value | expected | scenario`,AF={idle:0,module_set:1,encoding:1,validating:2,preview:3,inserting:3,done:4,error:1},jF=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Bulk upload`,href:`/bulk-upload`}];function MF(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 NF(e){return e.filter(e=>e.row_status===`valid`).map(e=>{let t={...e};return delete t.row_status,delete t.errors,t})}function PF(e){return e.flatMap(e=>(e.errors??[]).map(t=>({id:e.id,...t})))}function FF({errors:e}){return(0,u.jsx)(`div`,{className:`bulk-tooltip-errors`,children:(e??[]).map((e,t)=>(0,u.jsx)(`div`,{children:e.message},`${e.field}-${t}`))})}function IF({errors:e,expanded:t,onToggle:n,onSummaryClick:r}){return e.length===0?null:(0,u.jsxs)(`div`,{className:`bulk-error-banner`,children:[(0,u.jsxs)(`div`,{className:`bulk-error-summary`,children:[(0,u.jsxs)(`button`,{type:`button`,className:`bulk-error-summary-main`,onClick:r,"aria-label":`Scroll to first invalid row`,children:[(0,u.jsx)(l.ExclamationCircleOutlined,{className:`bulk-error-icon`}),(0,u.jsxs)(`span`,{children:[e.length,` validation error(s) found`]})]}),(0,u.jsx)(c.Button,{type:`link`,onClick:n,"aria-expanded":t,children:t?`Hide Errors`:`View Errors`})]}),t&&(0,u.jsx)(`div`,{className:`bulk-error-list`,role:`region`,"aria-label":`Validation error details`,children:e.map((e,t)=>(0,u.jsxs)(`div`,{className:`bulk-error-line`,children:[(0,u.jsxs)(`span`,{className:`bulk-row-chip`,children:[`Row `,e.id]}),(0,u.jsx)(`span`,{children:e.message})]},`${e.id}-${e.field}-${t}`))})]})}function LF({rows:e,view:t,onViewChange:n,onConfirm:r,onReset:i,saving:a,firstInvalidRowId:o,firstInvalidRowRef:s}){let d=e.filter(e=>e.row_status===`invalid`),f=t===`errors`?d:e,p=d.length>0||a;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(c.Row,{justify:`space-between`,align:`middle`,gutter:[16,16],className:`bulk-table-toolbar`,children:[(0,u.jsx)(c.Col,{children:(0,u.jsxs)(c.Space.Compact,{children:[(0,u.jsx)(c.Button,{type:t===`all`?`primary`:`default`,onClick:()=>n(`all`),children:`All rows`}),(0,u.jsx)(c.Button,{type:t===`errors`?`primary`:`default`,onClick:()=>n(`errors`),children:`Errors only`})]})}),(0,u.jsx)(c.Col,{children:(0,u.jsxs)(wF,{type:`secondary`,children:[e.length,` row(s)`]})})]}),(0,u.jsx)(`div`,{className:`bulk-table-wrap`,children:(0,u.jsxs)(`table`,{className:`bulk-preview-table`,children:[(0,u.jsx)(`thead`,{children:(0,u.jsxs)(`tr`,{children:[(0,u.jsx)(`th`,{className:`bulk-col-row`,children:`Row`}),(0,u.jsx)(`th`,{className:`bulk-col-flow`,children:`Submodule`}),(0,u.jsx)(`th`,{className:`bulk-col-description`,children:`Description`}),(0,u.jsx)(`th`,{className:`bulk-col-keyword`,children:`Action`}),(0,u.jsx)(`th`,{className:`bulk-col-target`,children:`Key`}),(0,u.jsx)(`th`,{className:`bulk-col-status`,children:`Status`}),(0,u.jsx)(`th`,{className:`bulk-col-error`,children:`Error`})]})}),(0,u.jsx)(`tbody`,{children:f.map(e=>{let t=e.errors??[],n=e.row_status===`invalid`;return(0,u.jsxs)(`tr`,{ref:n&&e.id===o?s:null,className:n?`bulk-row-invalid`:``,children:[(0,u.jsx)(`td`,{children:e.id}),(0,u.jsx)(`td`,{title:e.submodule,children:e.submodule}),(0,u.jsx)(`td`,{title:e.description,children:e.description?e.description:(0,u.jsx)(`span`,{className:`bulk-empty-text`,children:`-empty-`})}),(0,u.jsx)(`td`,{children:(0,u.jsx)(`code`,{className:`bulk-code-chip`,children:e.actions})}),(0,u.jsx)(`td`,{title:e.key,children:e.key}),(0,u.jsx)(`td`,{children:n?(0,u.jsx)(c.Tag,{color:`red`,children:`Error`}):(0,u.jsx)(c.Tag,{color:`green`,children:`Valid`})}),(0,u.jsx)(`td`,{children:n?(0,u.jsx)(c.Tooltip,{title:(0,u.jsx)(FF,{errors:t}),placement:`left`,children:(0,u.jsxs)(`button`,{type:`button`,className:`bulk-error-info`,"aria-label":`View ${t.length} error(s) for row ${e.id}`,children:[(0,u.jsx)(l.InfoCircleOutlined,{}),(0,u.jsx)(c.Badge,{count:t.length,size:`small`})]})}):(0,u.jsx)(`span`,{className:`bulk-error-none`,children:`-`})})]},`${e.id}-${e.step_order}`)})})]})}),(0,u.jsxs)(c.Space,{className:`bulk-actions`,children:[(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:i,children:`Reset`}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.SaveOutlined,{}),loading:a,disabled:p,onClick:r,children:d.length>0?`Fix ${d.length} error(s) to proceed`:`Save to database`})]})]})}function RF(){let e=(0,f.useNavigate)(),r=(0,s.useMemo)(()=>t.l(),[]),i=(0,s.useRef)(null),a=(0,s.useRef)(null),[o,d]=(0,s.useState)([]),[p,m]=(0,s.useState)(``),[h,g]=(0,s.useState)(`idle`),[_,v]=(0,s.useState)(!1),[y,b]=(0,s.useState)(null),[x,S]=(0,s.useState)([]),[C,w]=(0,s.useState)(`all`),[T,E]=(0,s.useState)(null),[D,O]=(0,s.useState)(null),[k,A]=(0,s.useState)(!1),j=o.map(e=>({value:e.modulename,label:e.modulename})),M=PF(x),N=h===`encoding`||h===`validating`,P=!!p&&!N,F=AF[h]??0,I=x.find(e=>e.row_status===`invalid`)?.id,L=(0,s.useCallback)(()=>{m(``),g(`idle`),v(!1),b(null),S([]),w(`all`),E(null),O(null),i.current&&(i.current.value=``)},[]);(0,s.useEffect)(()=>{async function e(){try{let e=await kx({project:r?.name??``,activeOnly:!0});d(e?.items??[])}catch(e){console.error(e),c.message.error(`Unable to load modules.`)}}e()},[r?.name]);let R=e=>{m(e??``),S([]),O(null),E(null),b(null),A(!1),g(e?`module_set`:`idle`)},z=async e=>{if(!e||!P)return;let t=e.name.split(`.`).pop()?.toLowerCase();if(![`xlsx`,`csv`].includes(t)){g(`module_set`),E({message:`Invalid file type. Please upload an Excel .xlsx or CSV .csv file.`});return}if(e.size>EF){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 MF(e);g(`validating`);let i=await wx({filename:e.name,project:r?.name??``,module:p,file_base64:n,file_type:t});S(i?.rows??[]),w(`all`),g(`preview`)}catch(e){console.error(e),E(e.payload??{code:`NETWORK_ERROR`,message:e.message||`Could not reach the server.`}),g(`error`)}},B=async()=>{try{let e=await fetch(DF);if(!e.ok)throw Error(`Template file not found (${e.status})`);let t=(await e.text()).trim(),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);let i=new Blob([r],{type:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=OF,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(a),c.message.success(`Sample template downloaded.`)}catch(e){console.error(e),c.message.error(`Unable to download sample template.`)}},V=async()=>{g(`inserting`),E(null);try{let t=await Tx({project:r?.name??``,module:p,uploaded_by:localStorage.getItem(`user_Email`)??``,rows:NF(x)});O(t),g(`done`),c.message.success(`Bulk upload saved. Redirecting to view test cases...`),window.setTimeout(()=>e(`/viewTestCase`),900)}catch(e){console.error(e),E(e.payload??{code:`NETWORK_ERROR`,message:e.message||`Could not reach the server.`}),g(`preview`)}},H=(0,s.useCallback)(()=>{a.current?.scrollIntoView({behavior:`smooth`,block:`center`})},[]),ee=[`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,u.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,u.jsxs)(c.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,u.jsx)(c.Col,{children:(0,u.jsx)(n.s,{items:jF})}),r?.name&&(0,u.jsx)(c.Col,{children:(0,u.jsx)(wF,{strong:!0,children:r.name})})]}),(0,u.jsxs)(`div`,{className:`zt-page zt-page-wide bulk-page`,children:[(0,u.jsxs)(`div`,{className:`bulk-header`,children:[(0,u.jsx)(TF,{level:3,children:`Bulk upload test cases`}),(0,u.jsxs)(c.Space,{direction:`vertical`,size:4,children:[(0,u.jsx)(wF,{type:`secondary`,children:kF}),(0,u.jsx)(wF,{type:`secondary`,children:`Use the sample template for the required columns. Uploaded rows are saved as Active by default.`})]})]}),(0,u.jsx)(`div`,{className:`bulk-stepbar`,children:[`Select`,`Upload`,`Validate`,`Save`].map((e,t)=>(0,u.jsxs)(`span`,{className:t<F?`bulk-step-active`:``,children:[t+1,` `,e]},e))}),(0,u.jsx)(c.Card,{className:`v1-card zt-fall`,title:`1. Module selector`,children:(0,u.jsx)(c.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,u.jsxs)(c.Card,{className:`v1-card zt-fall`,title:`2. File upload`,extra:(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.DownloadOutlined,{}),onClick:B,children:`Download Sample Template`}),children:[(0,u.jsx)(c.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,u.jsxs)(`button`,{type:`button`,className:ee,disabled:!P,onClick:()=>i.current?.click(),onDragOver:e=>{e.preventDefault(),P&&v(!0)},onDragLeave:()=>v(!1),onDrop:e=>{e.preventDefault(),v(!1),z(e.dataTransfer.files?.[0])},children:[(0,u.jsx)(l.CloudUploadOutlined,{className:`bulk-upload-icon`}),y?(0,u.jsxs)(`span`,{className:`bulk-file-chip`,children:[y.name,` - `,Math.ceil(y.size/1024),` KB`]}):(0,u.jsx)(`span`,{children:`Drag & drop here, or click to browse`})]}),(0,u.jsx)(`input`,{ref:i,hidden:!0,type:`file`,accept:`.xlsx,.csv`,onChange:e=>z(e.target.files?.[0])}),N&&(0,u.jsx)(c.Progress,{percent:h===`encoding`?45:82,showInfo:!1,size:`small`}),T&&h!==`preview`&&(0,u.jsx)(c.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`})]}),x.length>0&&(0,u.jsxs)(c.Card,{className:`v1-card zt-fall`,title:`3. Validation result`,children:[(0,u.jsx)(IF,{errors:M,expanded:k,onToggle:()=>A(e=>!e),onSummaryClick:H}),T&&h===`preview`&&(0,u.jsx)(c.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`}),(0,u.jsx)(LF,{rows:x,view:C,onViewChange:w,onConfirm:V,onReset:L,saving:h===`inserting`,firstInvalidRowId:I,firstInvalidRowRef:a})]}),D&&h===`done`&&(0,u.jsxs)(c.Card,{className:`v1-card zt-fall`,title:`4. Upload complete`,children:[(0,u.jsxs)(c.Row,{gutter:[16,16],className:`bulk-metrics`,children:[(0,u.jsx)(c.Col,{xs:24,md:8,children:(0,u.jsxs)(`div`,{children:[(0,u.jsx)(wF,{children:`Total`}),(0,u.jsx)(`strong`,{children:x.length})]})}),(0,u.jsx)(c.Col,{xs:24,md:8,children:(0,u.jsxs)(`div`,{children:[(0,u.jsx)(wF,{children:`Inserted`}),(0,u.jsx)(`strong`,{children:D.inserted??0})]})}),(0,u.jsx)(c.Col,{xs:24,md:8,children:(0,u.jsxs)(`div`,{children:[(0,u.jsx)(wF,{children:`Failed`}),(0,u.jsx)(`strong`,{children:D.failed??0})]})})]}),(0,u.jsx)(c.Alert,{type:`success`,showIcon:!0,icon:(0,u.jsx)(l.CheckCircleOutlined,{}),message:`${D.inserted??0} test cases saved to database - module: ${p}`,className:`bulk-inline-alert`}),(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:L,children:`Upload another file`})]})]})]})}var zF=[{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:BF}=c.Typography,VF=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}],HF={tags:`regression`,active:1},UF={module:{dbName:`Modules`,formField:`module`,label:`Module`}};function WF(e=[]){return e.map(e=>({value:e,label:e}))}function GF(e=``){return String(e??``).trim()}function KF(e=``){return GF(e).toLowerCase()}function qF(e=[]){let t=new Map;return e.forEach(e=>{let n=GF(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function JF(e=[],t,n){let r=GF(t).toLowerCase(),i=GF(n).toLowerCase();return e.reduce((e,t)=>{let n=GF(t?.module).toLowerCase(),a=GF(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 YF({icon:e,title:t}){return(0,u.jsxs)(c.Space,{size:10,align:`center`,children:[(0,u.jsx)(`div`,{className:`v1-section-icon-box`,children:e}),(0,u.jsx)(BF,{strong:!0,className:`v1-section-label`,children:t})]})}function XF(){let[e]=c.Form.useForm(),[t]=c.Form.useForm(),[r,i]=(0,s.useState)([]),[a,o]=(0,s.useState)([]),[d,p]=(0,s.useState)([]),[m,h]=(0,s.useState)(!1),[g,_]=(0,s.useState)(!1),[v,y]=(0,s.useState)({open:!1,typeKey:`module`}),[b,x]=(0,s.useState)(!1),[S,C]=(0,s.useState)(!1),[w,T]=(0,s.useState)(!1),E=(0,f.useNavigate)(),D=UF[v.typeKey],O=(0,s.useMemo)(()=>WF(r),[r]),k=c.Form.useWatch(`module`,e),A=c.Form.useWatch(`flow`,e),j=!!GF(k),M=!!GF(A),N=!j,P=!j||!M,F=(e,t=[])=>{e===`module`&&i(t)},I=async()=>{h(!0);try{let e=await yx(UF.module.dbName);i(e?.items??[])}catch(e){console.error(`Unable to load testing options:`,e),c.message.error(`Unable to load testing options.`)}finally{h(!1)}},L=(0,s.useCallback)(async t=>{let n=GF(t);if(o([]),p([]),e.setFieldsValue({step_order:void 0}),n){_(!0);try{let e=await Cx({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];o(t),p(qF(t))}catch(e){console.error(`Unable to load flows:`,e),c.message.error(`Unable to load flows.`)}finally{_(!1)}}},[e]),R=(0,s.useCallback)(async(t,n,r)=>{let i=GF(t),a=GF(n);if(!i||!a){e.setFieldsValue({step_order:void 0});return}C(!0);try{e.setFieldsValue({step_order:JF(r,i,a)})}catch(e){console.error(`Unable to load step order:`,e),c.message.error(`Unable to load step order.`)}finally{C(!1)}},[e]);(0,s.useEffect)(()=>{Promise.resolve().then(I)},[]),(0,s.useEffect)(()=>{Promise.resolve().then(()=>L(k))},[L,k]),(0,s.useEffect)(()=>{Promise.resolve().then(()=>R(k,A,a))},[a,R,A,k]);let z=async t=>{let n={module:GF(t.module),flow:GF(t.flow),step_order:Number(t.step_order),description:GF(t.description),keyword:KF(t.keyword),target:GF(t.target),value:GF(t.value),expected:GF(t.expected),tags:t.tags?GF(t.tags):HF.tags,active:Number(t.active)};T(!0);try{await Sx(n),c.message.success(`Test case details saved successfully.`),e.resetFields(),o([]),p([])}catch(e){console.error(`Unable to save test case:`,e),c.message.error(`Unable to save test case.`)}finally{T(!1)}},B=(t,n)=>{e.setFieldsValue({[t]:GF(n)})},V=t=>{e.setFieldsValue({module:GF(t),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:HF.tags,value:void 0,expected:void 0})},H=t=>{e.setFieldsValue({flow:GF(t),step_order:void 0})},ee=e=>{let n=UF[e];y({open:!0,typeKey:e}),t.setFieldsValue({name:``,type:n.label})},te=()=>{y(e=>({...e,open:!1})),t.resetFields()},ne=async()=>{try{let n=GF((await t.validateFields()).name),r=await bx({name:n,type:D.dbName});F(v.typeKey,r?.items??[]),e.setFieldsValue({[D.formField]:n}),c.message.success(`${D.label} added successfully.`),te()}catch(e){if(e?.errorFields)return;console.error(`Unable to save testing option:`,e),c.message.error(`Unable to add ${D.label.toLowerCase()}.`)}finally{x(!1)}};return(0,u.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,u.jsxs)(c.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,u.jsx)(c.Col,{children:(0,u.jsx)(n.s,{items:VF})}),(0,u.jsx)(c.Col,{children:(0,u.jsx)(c.Button,{type:`link`,onClick:()=>E(`/zinnext-home`),children:`View Table`})})]}),(0,u.jsx)(`div`,{className:`v1-page`,children:(0,u.jsxs)(`div`,{className:`v1-page-inner`,children:[(0,u.jsx)(`div`,{className:`v1-page-header`,children:(0,u.jsxs)(c.Space,{align:`center`,size:10,children:[(0,u.jsx)(l.ProfileOutlined,{className:`v1-outer-icon`}),(0,u.jsx)(`div`,{children:(0,u.jsx)(BF,{strong:!0,style:{fontSize:16},children:`Add Test Case`})})]})}),(0,u.jsx)(Z,{children:(0,u.jsxs)(c.Form,{form:e,className:`v1-form`,layout:`vertical`,colon:!1,requiredMark:(e,{required:t})=>(0,u.jsxs)(u.Fragment,{children:[e,t&&(0,u.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),initialValues:HF,onFinish:z,autoComplete:`off`,children:[(0,u.jsx)(c.Card,{className:`v1-card`,title:(0,u.jsx)(YF,{icon:(0,u.jsx)(l.FileTextOutlined,{}),title:`Test Case Details`}),extra:(0,u.jsx)(BF,{type:`secondary`,className:`v1-card-subtitle`,children:`Module, flow, step order and execution data`}),children:(0,u.jsxs)(c.Row,{gutter:[24,0],children:[(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsxs)(c.Space.Compact,{style:{width:`100%`},children:[(0,u.jsx)(c.Form.Item,{label:`Module`,name:`module`,style:{flex:1},children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,loading:m,optionFilterProp:`label`,placeholder:`Select module`,options:O,onChange:V})}),(0,u.jsx)(c.Button,{"aria-label":`Add module`,icon:(0,u.jsx)(l.PlusOutlined,{}),style:{marginTop:30},onClick:()=>ee(`module`)})]})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Flow`,name:`flow`,children:(0,u.jsx)(c.AutoComplete,{maxLength:100,allowClear:!0,disabled:N,options:d,placeholder:g?`Loading flows`:`Enter flow`,onChange:H,filterOption:(e,t)=>t?.value?.toLowerCase().includes(e.toLowerCase())})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Step Order`,name:`step_order`,validateTrigger:[`onBlur`,`onChange`],children:(0,u.jsx)(c.Input,{maxLength:10,disabled:!0,placeholder:S?`Loading step order`:`Step order`})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Action`,name:`keyword`,children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,disabled:P,optionFilterProp:`label`,placeholder:`Select action`,options:zF,onChange:t=>e.setFieldsValue({keyword:KF(t)})})})}),(0,u.jsx)(c.Col,{xs:24,children:(0,u.jsx)(c.Form.Item,{label:`Description`,name:`description`,children:(0,u.jsx)(c.Input.TextArea,{rows:3,maxLength:255,disabled:P,placeholder:`Enter description`,showCount:!0,onBlur:e=>B(`description`,e.target.value)})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Key`,name:`target`,children:(0,u.jsx)(c.Input,{maxLength:255,disabled:P,placeholder:`Enter target`,onBlur:e=>B(`target`,e.target.value)})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Tags`,name:`tags`,children:(0,u.jsx)(c.Input,{maxLength:200,disabled:P,placeholder:`Enter tags`,prefix:(0,u.jsx)(l.TagsOutlined,{className:`v1-input-icon`}),onBlur:e=>B(`tags`,e.target.value)})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Value`,name:`value`,children:(0,u.jsx)(c.Input.TextArea,{rows:4,disabled:P,placeholder:`Enter value`,onBlur:e=>B(`value`,e.target.value)})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Expected`,name:`expected`,children:(0,u.jsx)(c.Input.TextArea,{rows:4,disabled:P,placeholder:`Enter expected result`,onBlur:e=>B(`expected`,e.target.value)})})})]})}),(0,u.jsx)(`div`,{className:`v1-form-actions`,children:(0,u.jsx)(c.Form.Item,{children:(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(c.Button,{type:`primary`,htmlType:`submit`,loading:w,disabled:P,children:`Submit`}),(0,u.jsx)(c.Button,{onClick:()=>{e.resetFields(),o([]),p([])},children:`Reset`})]})})})]})}),(0,u.jsx)(c.Modal,{title:`Add ${D.label}`,open:v.open,confirmLoading:b,okText:`Add`,onCancel:te,onOk:()=>{x(!0),ne()},destroyOnHidden:!0,children:(0,u.jsxs)(c.Form,{form:t,layout:`vertical`,colon:!1,className:`v1-form`,requiredMark:(e,{required:t})=>(0,u.jsxs)(u.Fragment,{children:[e,t&&(0,u.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),children:[(0,u.jsx)(c.Form.Item,{label:`Name`,name:`name`,children:(0,u.jsx)(c.Input,{maxLength:100,placeholder:`Enter ${D.label.toLowerCase()} name`,onBlur:e=>{t.setFieldsValue({name:GF(e.target.value)})}})}),(0,u.jsx)(c.Form.Item,{label:`Type`,name:`type`,children:(0,u.jsx)(c.Input,{disabled:!0})})]})})]})})]})}var{Text:ZF}=c.Typography,QF=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`}];function $F(e=``){return String(e??``).trim()}function eI(e=[],t){return e.map(e=>({value:e.id,label:e[t]}))}var tI=[{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,u.jsx)(c.Tag,{color:`green`,children:`Positive`}):(0,u.jsx)(c.Tag,{color:`red`,children:`Negative`})}],nI={key:!1,value:!1,expected:!1};function rI(e,t){return t?e[t]??nI:nI}function iI(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function aI(){let[e]=c.Form.useForm(),r=(0,f.useNavigate)(),[i]=(0,f.useSearchParams)(),a=i.get(`edit`),o=!!a,d=(0,s.useMemo)(()=>t.l(),[]),[p,m]=(0,s.useState)([]),[h,g]=(0,s.useState)([]),[_,v]=(0,s.useState)([]),[y,b]=(0,s.useState)(zF),[x,S]=(0,s.useState)({}),[C,w]=(0,s.useState)(!1),[T,E]=(0,s.useState)(!1),[D,O]=(0,s.useState)(!1),[k,A]=(0,s.useState)(!1),[j,M]=(0,s.useState)(!1),N=c.Form.useWatch(`module`,e),P=c.Form.useWatch(`submodule`,e),F=c.Form.useWatch(`actions`,e),I=!!N,L=!!P,R=(0,s.useMemo)(()=>rI(x,F),[x,F]),z=(0,s.useMemo)(()=>eI(p,`modulename`),[p]),B=(0,s.useMemo)(()=>eI(h,`submodulename`),[h]),V=(0,s.useMemo)(()=>p.find(e=>e.id===N)?.modulename??``,[p,N]),H=(0,s.useMemo)(()=>h.find(e=>e.id===P)?.submodulename??``,[P,h]),ee=(0,s.useCallback)(async()=>{try{let e=await xx();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),c.message.error(`Unable to load action validation rules.`)}},[]),te=(0,s.useCallback)(async e=>{if(!e){m([]);return}w(!0);try{let t=await kx({project:e,activeOnly:!0});m(t?.items??[])}catch(e){console.error(`Unable to load modules:`,e),c.message.error(`Unable to load modules.`)}finally{w(!1)}},[]),ne=(0,s.useCallback)(async(e,t)=>{if(!e||!t){g([]);return}E(!0);try{let n=await Mx({project:e,module:t,activeOnly:!0});g(n?.items??[])}catch(e){console.error(`Unable to load submodules:`,e),c.message.error(`Unable to load submodules.`)}finally{E(!1)}},[]),re=(0,s.useCallback)(async(t,n,r,i=``)=>{if(!t||!n||!r){v([]),e.setFieldsValue({step_order:void 0});return}O(!0);try{let[a,o]=await Promise.all([Fx({product_parent_ID:t,module_parent_ID:n,submodule_parent_ID:r,actions:i,limit:1e3}),Rx({product_parent_ID:t,module_parent_ID:n,submodule_parent_ID:r})]);v(a?.items??[]),e.setFieldsValue({step_order:o?.step_order??1})}catch(e){console.error(`Unable to load flows:`,e),c.message.error(`Unable to load flows.`)}finally{O(!1)}},[e]),ie=(0,s.useCallback)(async(e=``)=>{if(!(!d?.id||!N||!P)){O(!0);try{let t=await Fx({product_parent_ID:d.id,module_parent_ID:N,submodule_parent_ID:P,actions:e,limit:1e3});v(t?.items??[])}catch(e){console.error(`Unable to load action flows:`,e),c.message.error(`Unable to load action steps.`)}finally{O(!1)}}},[d?.id,N,P]),ae=(0,s.useCallback)(async()=>{if(!(!a||!d?.name)){M(!0);try{let t=await Lx(a);await ne(d.name,t.module);let n=await Fx({product_parent_ID:t.product_parent_ID,module_parent_ID:t.module_parent_ID,submodule_parent_ID:t.submodule_parent_ID,limit:1e3});v(n?.items??[]),e.setFieldsValue({module:t.module_parent_ID,submodule:t.submodule_parent_ID,step_order:t.step_order,actions:t.actions,key:t.key,value:t.value,expected:t.expected,description:t.description,scenario:t.scenario===1,active:Number(t.active)!==0})}catch(e){console.error(`Unable to load test flow:`,e),c.message.error(`Unable to load test flow for edit.`),r(`/viewTestCase`)}finally{M(!1)}}},[a,e,ne,r,d?.name]);return(0,s.useEffect)(()=>{if(!d){r(`/select-project`,{replace:!0});return}Promise.resolve().then(async()=>{await ee(),await te(d.name),a&&await ae()})},[d,r,ee,te,a,ae]),d?(0,u.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,u.jsxs)(c.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,u.jsx)(c.Col,{children:(0,u.jsx)(n.s,{items:QF})}),(0,u.jsx)(c.Col,{children:(0,u.jsxs)(c.Space,{size:6,className:`zt-section-title`,children:[(0,u.jsx)(l.ProjectOutlined,{}),(0,u.jsx)(ZF,{strong:!0,children:d.name})]})})]}),(0,u.jsx)(`div`,{className:`zt-page`,children:(0,u.jsxs)(c.Form,{form:e,layout:`vertical`,colon:!1,className:`v1-form`,initialValues:{scenario:!0,active:!0},onFinish:async t=>{let n={product_parent_ID:Number(d?.id),module_parent_ID:Number(t.module),submodule_parent_ID:Number(t.submodule),description:$F(t.description),actions:$F(t.actions),key:$F(t.key),value:$F(t.value),expected:$F(t.expected),scenario:+!!t.scenario,active:+!!t.active};A(!0);try{if(o){await zx(a,{...n,step_order:Number(t.step_order)}),c.message.success(`Test case updated successfully.`),r(`/viewTestCase`);return}await Ix(n),c.message.success(`Step saved (#${t.step_order}).`),e.setFieldsValue({actions:void 0,key:void 0,value:void 0,expected:void 0,description:void 0}),await re(n.product_parent_ID,n.module_parent_ID,n.submodule_parent_ID)}catch(e){console.error(`Unable to save test case:`,e),c.message.error(o?`Unable to update test case.`:`Unable to save step.`)}finally{A(!1)}},autoComplete:`off`,disabled:j,children:[(0,u.jsx)(c.Card,{className:`v1-card zt-fall`,title:(0,u.jsxs)(c.Space,{size:8,className:`zt-section-title`,children:[(0,u.jsx)(`span`,{className:`zt-step-tag`,children:`1`}),(0,u.jsx)(`span`,{children:`Module & Submodule`})]}),children:(0,u.jsxs)(c.Row,{gutter:[24,0],align:`bottom`,children:[(0,u.jsx)(c.Col,{xs:24,md:6,children:(0,u.jsx)(c.Form.Item,{label:`Module`,name:`module`,children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,loading:C,placeholder:`Select module`,options:z,onChange:t=>{let n=p.find(e=>e.id===t)?.modulename??``;e.setFieldsValue({module:t,submodule:void 0,step_order:void 0,actions:void 0,key:void 0,value:void 0,expected:void 0}),iI(e,[`actions`,`key`,`value`,`expected`]),g([]),v([]),ne(d?.name,n)}})})}),(0,u.jsx)(c.Col,{xs:24,md:6,children:(0,u.jsx)(c.Form.Item,{label:`Submodule`,name:`submodule`,children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,disabled:!I,loading:T,placeholder:I?`Select submodule`:`Select module first`,options:B,onChange:t=>{e.setFieldsValue({submodule:t,actions:void 0,key:void 0,value:void 0,expected:void 0}),iI(e,[`actions`,`key`,`value`,`expected`]),re(d?.id,N,t)}})})}),(0,u.jsx)(c.Col,{xs:24,md:6,children:(0,u.jsx)(c.Form.Item,{label:`Scenario`,name:`scenario`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{disabled:!L,checkedChildren:`Positive`,unCheckedChildren:`Negative`})})}),(0,u.jsx)(c.Col,{xs:24,md:6,children:(0,u.jsx)(c.Form.Item,{label:`Active`,name:`active`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{checkedChildren:`Active`,unCheckedChildren:`Inactive`})})})]})}),L&&(0,u.jsxs)(c.Card,{className:`v1-card zt-fall`,title:(0,u.jsxs)(c.Space,{size:8,className:`zt-section-title`,children:[(0,u.jsx)(`span`,{className:`zt-step-tag`,children:`2`}),(0,u.jsx)(l.FileTextOutlined,{}),(0,u.jsx)(`span`,{children:`Step Details`})]}),extra:(0,u.jsxs)(ZF,{type:`secondary`,children:[V,` / `,H]}),children:[(0,u.jsxs)(c.Row,{gutter:[24,0],children:[(0,u.jsx)(c.Col,{xs:24,md:6,children:(0,u.jsx)(c.Form.Item,{label:`Step Order`,name:`step_order`,children:(0,u.jsx)(c.Input,{disabled:!0,placeholder:D?`Loading…`:`Auto`})})}),(0,u.jsx)(c.Col,{xs:24,md:18,children:(0,u.jsx)(c.Form.Item,{label:`Action`,name:`actions`,rules:[{required:!0,message:`Mandatory Field`}],children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,placeholder:`Select action`,options:y,onChange:t=>{let n=rI(x,t);e.setFieldsValue({actions:t,key:n.key?e.getFieldValue(`key`):void 0,value:n.value?e.getFieldValue(`value`):void 0,expected:n.expected?e.getFieldValue(`expected`):void 0}),iI(e,[`key`,`value`,`expected`]),ie(t||``)}})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Key`,name:`key`,rules:[{required:R.key,message:`Key is required for this action`}],children:(0,u.jsx)(c.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,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Value`,name:`value`,rules:[{required:R.value,message:`Value is required for this action`}],children:(0,u.jsx)(c.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,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Expected`,name:`expected`,rules:[{required:R.expected,message:`Expected result is required for this action`}],children:(0,u.jsx)(c.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,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Description`,name:`description`,children:(0,u.jsx)(c.Input.TextArea,{rows:2,maxLength:255,showCount:!0,placeholder:`Enter description`})})})]}),(0,u.jsxs)(c.Space,{className:`zt-actions`,children:[(0,u.jsx)(c.Button,{onClick:()=>{if(o){r(`/viewTestCase`);return}e.resetFields(),g([]),v([]),E(!1),O(!1)},children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,htmlType:`submit`,loading:k||j,children:o?`Update Test Case`:`Save & Continue`})]})]},`${N}-${P}`),L&&(0,u.jsx)(c.Card,{className:`v1-card zt-fall`,title:(0,u.jsxs)(c.Space,{size:6,className:`zt-section-title`,children:[(0,u.jsx)(l.TableOutlined,{}),(0,u.jsx)(`span`,{children:`Added Steps`})]}),extra:(0,u.jsx)(c.Tag,{children:F?`${_.length} ${F} step(s)`:`${_.length} step(s)`}),children:(0,u.jsx)(kh,{listName:`Added Steps`,loading:D,fields:tI,dataSource:_,current:1,pageSize:Math.max(_.length,1),total:_.length,rowSelection:!1,className:`zt-list-plain zt-list-static`})})]})})]}):null}var{Text:oI}=c.Typography,sI=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`}];function cI(){let e=(0,f.useNavigate)(),r=(0,s.useMemo)(()=>t.l(),[]),[i,a]=(0,s.useState)([]),[o,d]=(0,s.useState)({}),[p,m]=(0,s.useState)(!1),[h,g]=(0,s.useState)(!1),[_,v]=(0,s.useState)(``),[y,b]=(0,s.useState)(!1),[x,S]=(0,s.useState)(1),[C,w]=(0,s.useState)(10),T=(0,s.useCallback)(async e=>{if(!e){a([]);return}m(!0);try{let[t,n]=await Promise.all([kx({project:e}),Mx({project:e})]);a(t?.items??[]);let r={};(n?.items??[]).forEach(e=>{let t=e.modulename;r[t]=(r[t]??0)+1}),d(r)}catch(e){console.error(e),c.message.error(`Unable to load modules.`)}finally{m(!1)}},[]);(0,s.useEffect)(()=>{if(!r){e(`/select-project`,{replace:!0});return}Promise.resolve().then(()=>T(r.name))},[r,e,T]);let E=async(e,t)=>{try{await jx(e.id,+!!t),a(n=>n.map(n=>n.id===e.id?{...n,active:+!!t}:n)),c.message.success(`Module ${t?`activated`:`deactivated`}.`)}catch(e){console.error(e),c.message.error(`Unable to update module status.`)}},D=async()=>{let e=_.trim();if(!e){c.message.warning(`Enter a module name.`);return}b(!0);try{await Ax({project:r.name,modulename:e}),c.message.success(`Module added.`),g(!1),v(``),S(1),T(r.name)}catch(e){console.error(e),c.message.error(`Unable to add module (maybe it already exists).`)}finally{b(!1)}},O=t=>{e(`/test-cases/zinnext/submodules?module=${encodeURIComponent(t.modulename)}`)};return r?(0,u.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,u.jsxs)(c.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,u.jsx)(c.Col,{children:(0,u.jsx)(n.s,{items:sI})}),(0,u.jsx)(c.Col,{children:(0,u.jsx)(c.Button,{type:`link`,onClick:()=>e(`/addTestCase`),children:`Back to Form`})})]}),(0,u.jsxs)(`div`,{className:`zt-page`,children:[(0,u.jsx)(c.Card,{className:`v1-card zt-bar`,children:(0,u.jsxs)(c.Row,{gutter:[16,16],align:`middle`,justify:`space-between`,children:[(0,u.jsx)(c.Col,{children:(0,u.jsxs)(c.Space,{size:6,className:`zt-section-title`,children:[(0,u.jsx)(l.ProjectOutlined,{}),(0,u.jsx)(`span`,{children:`Project:`}),(0,u.jsx)(oI,{strong:!0,children:r.name})]})}),(0,u.jsx)(c.Col,{children:(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>g(!0),children:`Add Module`})})]})}),(0,u.jsx)(c.Card,{className:`v1-card zt-fall`,title:(0,u.jsxs)(c.Space,{size:6,className:`zt-section-title`,children:[(0,u.jsx)(l.AppstoreOutlined,{}),(0,u.jsx)(`span`,{children:`Modules`})]}),children:(0,u.jsx)(kh,{listName:`Modules`,loading:p,fields:[{label:`Module`,value:`modulename`},{label:`Submodules`,value:`submoduleCount`,width:140,render:(e,t)=>(0,u.jsxs)(c.Button,{type:`link`,className:`zt-count-link`,onClick:()=>O(t),children:[o[t.modulename]??0,` submodule(s)`]})},{label:`Active`,value:`active`,width:120,render:(e,t)=>(0,u.jsx)(c.Switch,{checked:e===1,checkedChildren:`On`,unCheckedChildren:`Off`,onChange:e=>E(t,e)})}],dataSource:i,current:x,pageSize:C,total:i.length,onPageChange:S,onPageSizeChange:e=>{S(1),w(e)},rowSelection:!1,className:`zt-list-plain`})})]}),(0,u.jsx)(c.Modal,{title:`Add Module`,open:h,confirmLoading:y,okText:`Add`,onOk:D,onCancel:()=>{g(!1),v(``)},destroyOnHidden:!0,children:(0,u.jsxs)(c.Space,{direction:`vertical`,className:`zt-modal-stack`,children:[(0,u.jsxs)(oI,{type:`secondary`,children:[`Project: `,(0,u.jsx)(`b`,{children:r.name})]}),(0,u.jsx)(c.Input,{placeholder:`Enter module name`,maxLength:100,value:_,onChange:e=>v(e.target.value),onPressEnter:D})]})})]}):null}var{Text:lI}=c.Typography,uI=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`},{label:`Manage Submodules`,href:`/test-cases/zinnext/submodules`}];function dI(){let e=(0,f.useNavigate)(),[r]=(0,f.useSearchParams)(),i=(0,s.useMemo)(()=>t.l(),[]),a=r.get(`module`)??``,[o,d]=(0,s.useState)([]),[p,m]=(0,s.useState)(!1),[h,g]=(0,s.useState)(!1),[_,v]=(0,s.useState)(``),[y,b]=(0,s.useState)(!1),[x,S]=(0,s.useState)(1),[C,w]=(0,s.useState)(10),T=(0,s.useCallback)(async(e,t)=>{if(!e||!t){d([]);return}m(!0);try{let n=await Mx({project:e,module:t});d(n?.items??[])}catch(e){console.error(e),c.message.error(`Unable to load submodules.`)}finally{m(!1)}},[]);(0,s.useEffect)(()=>{if(!i){e(`/select-project`,{replace:!0});return}if(!a){e(`/manageModules`,{replace:!0});return}Promise.resolve().then(()=>T(i.name,a))},[i,a,e,T]);let E=async(e,t)=>{try{await Px(e.id,+!!t),d(n=>n.map(n=>n.id===e.id?{...n,active:+!!t}:n)),c.message.success(`Submodule ${t?`activated`:`deactivated`}.`)}catch(e){console.error(e),c.message.error(`Unable to update submodule status.`)}},D=async()=>{let e=_.trim();if(!e){c.message.warning(`Enter a submodule name.`);return}b(!0);try{await Nx({project:i.name,modulename:a,submodulename:e}),c.message.success(`Submodule added.`),g(!1),v(``),S(1),T(i.name,a)}catch(e){console.error(e),c.message.error(`Unable to add submodule (maybe it already exists).`)}finally{b(!1)}};return!i||!a?null:(0,u.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,u.jsxs)(c.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,u.jsx)(c.Col,{children:(0,u.jsx)(n.s,{items:uI})}),(0,u.jsx)(c.Col,{children:(0,u.jsx)(c.Button,{type:`link`,onClick:()=>e(`/manageModules`),children:`Back to Modules`})})]}),(0,u.jsxs)(`div`,{className:`zt-page`,children:[(0,u.jsx)(c.Card,{className:`v1-card zt-bar`,children:(0,u.jsxs)(c.Row,{gutter:[16,16],align:`middle`,justify:`space-between`,children:[(0,u.jsx)(c.Col,{children:(0,u.jsxs)(c.Space,{size:16,wrap:!0,className:`zt-section-title`,children:[(0,u.jsxs)(c.Space,{size:6,children:[(0,u.jsx)(l.ProjectOutlined,{}),(0,u.jsx)(`span`,{children:`Project:`}),(0,u.jsx)(lI,{strong:!0,children:i.name})]}),(0,u.jsxs)(c.Space,{size:6,children:[(0,u.jsx)(l.AppstoreOutlined,{}),(0,u.jsx)(`span`,{children:`Module:`}),(0,u.jsx)(lI,{strong:!0,children:a})]})]})}),(0,u.jsx)(c.Col,{children:(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>g(!0),children:`Add Submodule`})})]})}),(0,u.jsx)(c.Card,{className:`v1-card zt-fall`,title:(0,u.jsxs)(c.Space,{size:6,className:`zt-section-title`,children:[(0,u.jsx)(l.AppstoreOutlined,{}),(0,u.jsx)(`span`,{children:`Submodules`})]}),children:(0,u.jsx)(kh,{listName:`Submodules`,loading:p,fields:[{label:`Submodule`,value:`submodulename`},{label:`Active`,value:`active`,width:120,render:(e,t)=>(0,u.jsx)(c.Switch,{checked:e===1,checkedChildren:`On`,unCheckedChildren:`Off`,onChange:e=>E(t,e)})}],dataSource:o,current:x,pageSize:C,total:o.length,onPageChange:S,onPageSizeChange:e=>{S(1),w(e)},rowSelection:!1,className:`zt-list-plain`})})]}),(0,u.jsx)(c.Modal,{title:`Add Submodule`,open:h,confirmLoading:y,okText:`Add`,onOk:D,onCancel:()=>{g(!1),v(``)},destroyOnHidden:!0,children:(0,u.jsxs)(c.Space,{direction:`vertical`,className:`zt-modal-stack`,children:[(0,u.jsxs)(lI,{type:`secondary`,children:[`Project: `,(0,u.jsx)(`b`,{children:i.name}),` \xA0|\xA0 Module: `,(0,u.jsx)(`b`,{children:a})]}),(0,u.jsx)(c.Input,{placeholder:`Enter submodule name`,maxLength:100,value:_,onChange:e=>v(e.target.value),onPressEnter:D})]})})]})}var{Text:fI}=c.Typography,pI=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Table`,href:`/viewTestCase`}];function mI(){let e=(0,f.useNavigate)(),[r,i]=(0,s.useState)([]),[a,o]=(0,s.useState)(0),[d,p]=(0,s.useState)(!1),m=(0,s.useMemo)(()=>t.l(),[]),[h,g]=(0,s.useState)(``),[_,v]=(0,s.useState)(1),[y,b]=(0,s.useState)(20),[x,S]=(0,s.useState)(null),C=(0,s.useCallback)(async(e={})=>{p(!0);try{let t=await Fx({product_parent_ID:e.project??m?.id??``,search:e.search??h??``,limit:e.pageSize??y,offset:((e.page??_)-1)*(e.pageSize??y)});i(t?.items??[]),o(t?.total??0)}catch(e){console.error(e),c.message.error(`Unable to load test flows.`)}finally{p(!1)}},[m?.id,h,_,y]),w=e=>{c.Modal.confirm({title:`Delete Test Case`,icon:(0,u.jsx)(l.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 Bx(e.id),c.message.success(`Test case deleted successfully.`);let t=r.length===1&&_>1?_-1:_;v(t),await C({page:t})}catch(e){throw console.error(`Unable to delete test flow:`,e),c.message.error(`Unable to delete test case.`),e}finally{S(null)}}})};return(0,s.useEffect)(()=>{Promise.resolve().then(()=>{if(!m?.id){e(`/select-project`,{replace:!0});return}C({page:1})})},[]),(0,u.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,u.jsxs)(c.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,u.jsx)(c.Col,{children:(0,u.jsx)(n.s,{items:pI})}),(0,u.jsx)(c.Col,{children:(0,u.jsx)(c.Button,{type:`link`,onClick:()=>e(`/addTestCase`),children:`Back to Form`})})]}),(0,u.jsx)(`div`,{className:`zt-page zt-page-wide`,children:(0,u.jsxs)(c.Card,{className:`v1-card`,title:(0,u.jsxs)(c.Space,{size:6,className:`zt-section-title`,children:[(0,u.jsx)(l.TableOutlined,{}),(0,u.jsx)(`span`,{children:`Test Flows`})]}),extra:(0,u.jsxs)(fI,{type:`secondary`,children:[a,` row(s)`]}),children:[(0,u.jsxs)(c.Space,{wrap:!0,className:`zt-toolbar`,children:[(0,u.jsx)(c.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,u.jsx)(c.Button,{icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:()=>C(),children:`Refresh`})]}),(0,u.jsx)(kh,{listName:`Test Flows`,loading:d,fields:[{label:`Actions`,value:`rowActions`,width:112,fixed:`left`,sorter:!1,render:(t,n)=>(0,u.jsxs)(c.Space,{size:4,className:`zt-row-actions`,children:[(0,u.jsx)(c.Tooltip,{title:`Edit`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>e(`/addTestCase?edit=${n.id}`)})}),(0,u.jsx)(c.Tooltip,{title:`Delete`,children:(0,u.jsx)(c.Button,{danger:!0,type:`text`,size:`small`,icon:(0,u.jsx)(l.DeleteOutlined,{}),loading:x===n.id,onClick:()=>w(n)})})]})},{label:`ID`,value:`id`,width:70,fixed:`left`},{label:`Project`,value:`project`,width:130},{label:`Module`,value:`module`,width:130},{label:`Submodule`,value:`submodule`,width:140},{label:`Step`,value:`step_order`,width:70},{label:`Action`,value:`actions`,width:140},{label:`Key`,value:`key`,width:160,ellipsis:!0},{label:`Value`,value:`value`,width:200,ellipsis:!0},{label:`Expected`,value:`expected`,width:180,ellipsis:!0},{label:`Description`,value:`description`,width:180,ellipsis:!0},{label:`Scenario`,value:`scenario`,width:110,render:e=>e===1?(0,u.jsx)(c.Tag,{color:`green`,children:`Positive`}):(0,u.jsx)(c.Tag,{color:`red`,children:`Negative`})},{label:`Active`,value:`active`,width:90,render:e=>e===1?(0,u.jsx)(c.Tag,{color:`blue`,children:`Active`}):(0,u.jsx)(c.Tag,{children:`Inactive`})}],dataSource:r,current:_,pageSize:y,total:a,onPageChange:e=>{v(e),C({page:e})},onPageSizeChange:e=>{v(1),b(e),C({page:1,pageSize:e})},rowSelection:!1,className:`zt-list-plain`})]})})]})}var hI=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}];function gI(){return(0,u.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,u.jsx)(n.s,{items:hI}),(0,u.jsx)(ls,{moduleName:`test-flows`,rowKey:`id`})]})}var{Text:_I}=c.Typography,vI=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}],yI={tags:`regression`,active:1},bI={module:{dbName:`Modules`,formField:`module`,label:`Module`}},xI={key:!1,value:!1,expected:!1};function SI(e,t){return t?e[t]??xI:xI}function CI(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function wI(e=[]){return e.map(e=>({value:e,label:e}))}function TI(e=``){return String(e??``).trim()}function EI(e=[]){let t=new Map;return e.forEach(e=>{let n=TI(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function DI(e=[],t,n){let r=TI(t).toLowerCase(),i=TI(n).toLowerCase();return e.reduce((e,t)=>{let n=TI(t?.module).toLowerCase(),a=TI(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 OI({icon:e,title:t}){return(0,u.jsxs)(c.Space,{size:10,align:`center`,children:[(0,u.jsx)(`div`,{className:`v1-section-icon-box`,children:e}),(0,u.jsx)(_I,{strong:!0,className:`v1-section-label`,children:t})]})}function kI(){let[e]=c.Form.useForm(),[t]=c.Form.useForm(),[r,i]=(0,s.useState)([]),[a,o]=(0,s.useState)([]),[d,p]=(0,s.useState)([]),[m,h]=(0,s.useState)(zF),[g,_]=(0,s.useState)({}),[v,y]=(0,s.useState)(!1),[b,x]=(0,s.useState)(!1),[S,C]=(0,s.useState)({open:!1,typeKey:`module`}),[w,T]=(0,s.useState)(!1),[E,D]=(0,s.useState)(!1),[O,k]=(0,s.useState)(!1),A=(0,f.useNavigate)(),j=bI[S.typeKey],M=(0,s.useMemo)(()=>wI(r),[r]),N=c.Form.useWatch(`module`,e),P=c.Form.useWatch(`flow`,e),F=c.Form.useWatch(`keyword`,e),I=!!TI(N),L=!!TI(P),R=!I,z=!I||!L,B=(0,s.useMemo)(()=>SI(g,F),[g,F]),V=(e,t=[])=>{e===`module`&&i(t)},H=async()=>{y(!0);try{let e=await yx(bI.module.dbName);i(e?.items??[])}catch(e){console.error(`Unable to load testing options:`,e),c.message.error(`Unable to load testing options.`)}finally{y(!1)}},ee=async()=>{try{let e=await xx();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),c.message.error(`Unable to load action validation rules.`)}},te=(0,s.useCallback)(async t=>{let n=TI(t);if(o([]),p([]),e.setFieldsValue({step_order:void 0}),n){x(!0);try{let e=await Dx({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];o(t),p(EI(t))}catch(e){console.error(`Unable to load flows:`,e),c.message.error(`Unable to load flows.`)}finally{x(!1)}}},[e]),ne=(0,s.useCallback)(async(t,n,r)=>{let i=TI(t),a=TI(n);if(!i||!a){e.setFieldsValue({step_order:void 0});return}D(!0);try{e.setFieldsValue({step_order:DI(r,i,a)})}catch(e){console.error(`Unable to load step order:`,e),c.message.error(`Unable to load step order.`)}finally{D(!1)}},[e]);(0,s.useEffect)(()=>{Promise.resolve().then(async()=>{await Promise.all([H(),ee()])})},[]),(0,s.useEffect)(()=>{Promise.resolve().then(()=>te(N))},[te,N]),(0,s.useEffect)(()=>{Promise.resolve().then(()=>ne(N,P,a))},[a,ne,P,N]);let re=async t=>{let n={module:TI(t.module),flow:TI(t.flow),step_order:Number(t.step_order),description:TI(t.description),keyword:TI(t.keyword),target:TI(t.target),value:TI(t.value),expected:TI(t.expected),tags:t.tags?TI(t.tags):yI.tags,active:Number(t.active)};k(!0);try{await Ex(n),c.message.success(`LMS case details saved successfully.`),e.resetFields(),o([]),p([])}catch(e){console.error(`Unable to save LMS case:`,e),c.message.error(`Unable to save LMS case.`)}finally{k(!1)}},ie=(t,n)=>{e.setFieldsValue({[t]:TI(n)})},ae=t=>{e.setFieldsValue({module:TI(t),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:yI.tags,value:void 0,expected:void 0}),CI(e,[`keyword`,`target`,`value`,`expected`])},oe=t=>{e.setFieldsValue({flow:TI(t),step_order:void 0,keyword:void 0,target:void 0,value:void 0,expected:void 0}),CI(e,[`keyword`,`target`,`value`,`expected`])},se=t=>{let n=SI(g,t);e.setFieldsValue({keyword:TI(t),target:n.key?e.getFieldValue(`target`):void 0,value:n.value?e.getFieldValue(`value`):void 0,expected:n.expected?e.getFieldValue(`expected`):void 0}),CI(e,[`target`,`value`,`expected`])},ce=e=>{let n=bI[e];C({open:!0,typeKey:e}),t.setFieldsValue({name:``,type:n.label})},U=()=>{C(e=>({...e,open:!1})),t.resetFields()},W=async()=>{try{let n=TI((await t.validateFields()).name),r=await bx({name:n,type:j.dbName});V(S.typeKey,r?.items??[]),e.setFieldsValue({[j.formField]:n}),c.message.success(`${j.label} added successfully.`),U()}catch(e){if(e?.errorFields)return;console.error(`Unable to save testing option:`,e),c.message.error(`Unable to add ${j.label.toLowerCase()}.`)}finally{T(!1)}};return(0,u.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,u.jsxs)(c.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,u.jsx)(c.Col,{children:(0,u.jsx)(n.s,{items:vI})}),(0,u.jsx)(c.Col,{children:(0,u.jsx)(c.Button,{type:`link`,onClick:()=>A(`/lms-home`),children:`View Table`})})]}),(0,u.jsx)(`div`,{className:`v1-page`,children:(0,u.jsxs)(`div`,{className:`v1-page-inner`,children:[(0,u.jsx)(`div`,{className:`v1-page-header`,children:(0,u.jsxs)(c.Space,{align:`center`,size:10,children:[(0,u.jsx)(l.ProfileOutlined,{className:`v1-outer-icon`}),(0,u.jsx)(`div`,{children:(0,u.jsx)(_I,{strong:!0,style:{fontSize:16},children:`Add LMS Case`})})]})}),(0,u.jsx)(Z,{children:(0,u.jsxs)(c.Form,{form:e,className:`v1-form`,layout:`vertical`,colon:!1,requiredMark:(e,{required:t})=>(0,u.jsxs)(u.Fragment,{children:[e,t&&(0,u.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),initialValues:yI,onFinish:re,autoComplete:`off`,children:[(0,u.jsx)(c.Card,{className:`v1-card`,title:(0,u.jsx)(OI,{icon:(0,u.jsx)(l.FileTextOutlined,{}),title:`LMS Case Details`}),extra:(0,u.jsx)(_I,{type:`secondary`,className:`v1-card-subtitle`,children:`Module, flow, step order and execution data`}),children:(0,u.jsxs)(c.Row,{gutter:[24,0],children:[(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsxs)(c.Space.Compact,{style:{width:`100%`},children:[(0,u.jsx)(c.Form.Item,{label:`Module`,name:`module`,style:{flex:1},children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,loading:v,optionFilterProp:`label`,placeholder:`Select module`,options:M,onChange:ae})}),(0,u.jsx)(c.Button,{"aria-label":`Add module`,icon:(0,u.jsx)(l.PlusOutlined,{}),style:{marginTop:30},onClick:()=>ce(`module`)})]})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Flow`,name:`flow`,children:(0,u.jsx)(c.AutoComplete,{maxLength:100,allowClear:!0,disabled:R,options:d,placeholder:b?`Loading flows`:`Enter flow`,onChange:oe,filterOption:(e,t)=>t?.value?.toLowerCase().includes(e.toLowerCase())})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Step Order`,name:`step_order`,validateTrigger:[`onBlur`,`onChange`],children:(0,u.jsx)(c.Input,{maxLength:10,disabled:!0,placeholder:E?`Loading step order`:`Step order`})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Action`,name:`keyword`,children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,disabled:z,optionFilterProp:`label`,placeholder:`Select action`,options:m,onChange:se})})}),(0,u.jsx)(c.Col,{xs:24,children:(0,u.jsx)(c.Form.Item,{label:`Description`,name:`description`,children:(0,u.jsx)(c.Input.TextArea,{rows:3,maxLength:255,disabled:z,placeholder:`Enter description`,showCount:!0,onBlur:e=>ie(`description`,e.target.value)})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Key`,name:`target`,rules:[{required:B.key,message:`Key is required for this action`}],children:(0,u.jsx)(c.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=>ie(`target`,e.target.value)})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Tags`,name:`tags`,children:(0,u.jsx)(c.Input,{maxLength:200,disabled:z,placeholder:`Enter tags`,prefix:(0,u.jsx)(l.TagsOutlined,{className:`v1-input-icon`}),onBlur:e=>ie(`tags`,e.target.value)})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Value`,name:`value`,rules:[{required:B.value,message:`Value is required for this action`}],children:(0,u.jsx)(c.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=>ie(`value`,e.target.value)})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Expected`,name:`expected`,rules:[{required:B.expected,message:`Expected result is required for this action`}],children:(0,u.jsx)(c.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=>ie(`expected`,e.target.value)})})})]})}),(0,u.jsx)(`div`,{className:`v1-form-actions`,children:(0,u.jsx)(c.Form.Item,{children:(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(c.Button,{type:`primary`,htmlType:`submit`,loading:O,disabled:z,children:`Submit`}),(0,u.jsx)(c.Button,{onClick:()=>{e.resetFields(),o([]),p([])},children:`Reset`})]})})})]})}),(0,u.jsx)(c.Modal,{title:`Add ${j.label}`,open:S.open,confirmLoading:w,okText:`Add`,onCancel:U,onOk:()=>{T(!0),W()},destroyOnHidden:!0,children:(0,u.jsxs)(c.Form,{form:t,layout:`vertical`,colon:!1,className:`v1-form`,requiredMark:(e,{required:t})=>(0,u.jsxs)(u.Fragment,{children:[e,t&&(0,u.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),children:[(0,u.jsx)(c.Form.Item,{label:`Name`,name:`name`,children:(0,u.jsx)(c.Input,{maxLength:100,placeholder:`Enter ${j.label.toLowerCase()} name`,onBlur:e=>{t.setFieldsValue({name:TI(e.target.value)})}})}),(0,u.jsx)(c.Form.Item,{label:`Type`,name:`type`,children:(0,u.jsx)(c.Input,{disabled:!0})})]})})]})})]})}var AI=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}];function jI(){return(0,u.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,u.jsx)(n.s,{items:AI}),(0,u.jsx)(ls,{moduleName:`lms-flows`,rowKey:`id`})]})}var MI=[`referenceId`,`ReferenceId`,`candidateId`,`CandidateId`,`entityId`,`EntityId`,`id`,`Id`,`_id`];function NI(e=MI){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 PI(e,t=MI){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 FI=NI();function II(e){return typeof e==`function`?e:typeof e==`string`?NI([e]):Array.isArray(e)?NI(e):FI}function LI(e,t,n){return!t||typeof t!=`object`?e:{...t,...e,id:e?.id??t?.id??n}}function RI(e,t,n={}){return{status:`success`,total:t,data:{data:e,...n}}}var zI=[`fields`,`fieldConfig`,`tabs`,`tabField`,`actionRules`,`actions`,`columnActions`];function BI(e){let t=e?.data??e,n={};for(let r of zI){let i=e?.[r]??t?.[r];i==null||Array.isArray(i)&&i.length===0||(n[r]=i)}return n}var VI=e=>String(e??``).replace(/[^a-zA-Z0-9]/g,``).toLowerCase();function HI(e,t,n){let r=(Array.isArray(n)?n:[n]).map(VI).filter(Boolean),i=r.length?e.findIndex(e=>r.includes(VI(e?.value))||r.includes(VI(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 UI=(e,t)=>gi(e,t).rows,WI=(e,t)=>{let{rows:n,total:r}=gi(e,t);return{rows:n,total:r}};function GI(e,t){return function(n,r,i,a={}){return e(t??n,r,i,a)}}function KI(e){return!e||typeof e!=`object`||typeof(e.fetchByKeys??e.fetch??e.function)!=`function`?null:{...e,fetchByKeys:typeof e.fetchByKeys==`function`?e.fetchByKeys:null,fetch:typeof e.fetch==`function`?e.fetch:null,function:typeof e.function==`function`?e.function:null,extractRows:typeof e.extractRows==`function`?e.extractRows:UI,mergeRow:typeof e.mergeRow==`function`?e.mergeRow:LI,fetchById:typeof e.fetchById==`function`?e.fetchById:null}}function qI({fetchSecondaryByKeys:e,fetchSecondary:t,extractSecondaryRows:n,fetchSecondaryById:r,secondaryKey:i,mergeRow:a,secondaryFetchLimit:o}){return!e&&!t&&!r?[]:[KI({key:i,fetchByKeys:e?(t,n,r)=>e(t,n,r):null,function:t?({moduleName:e,options:n})=>t(e,o,0,n):null,extractRows:n,fetchById:r,mergeRow:a})].filter(Boolean)}function JI(e){if(typeof e==`function`)return t=>{let n=e(t);return n==null||n===``?[]:[String(n)]};let t=typeof e==`string`?[e]:Array.isArray(e)&&e.length?e:MI;return e=>PI(e,t)}function YI(e,t){let n=new Map;return e.forEach(e=>{for(let r of t(e))n.has(r)||n.set(r,e)}),n}function XI({moduleName:e,limit:t,offset:n,options:r,keys:i,primaryResponse:a,primaryRows:o,pageRows:s,total:c,source:l}){return{moduleName:e,limit:t,offset:n,options:r,keys:i,primaryResponse:a,primaryRows:o,pageRows:s,total:c,source:l}}async function ZI(e,t){if(typeof e.args==`function`){let n=e.args(t);return(e.fetch??e.function??e.fetchByKeys)(...Array.isArray(n)?n:[n])}if(Array.isArray(e.args))return(e.fetch??e.function??e.fetchByKeys)(...e.args);if(e.fetchByKeys&&Array.isArray(t.keys))return e.fetchByKeys(t.moduleName,t.keys,t.options,t);let n=e.fetch??e.function;return typeof n==`function`?n(t):null}function QI({fetchPrimaryPage:e,extractPrimaryPage:t=WI,fetchSecondaryByKeys:n,joinSources:r=[],fetchPrimary:i,extractPrimaryRows:a=UI,fetchSecondary:o,extractSecondaryRows:s=UI,fetchSecondaryById:c,primaryKey:l,secondaryKey:u,mergeRow:d=LI,secondaryFetchLimit:f=200,extraFields:p=[],extraFieldsAfter:m}){let h=Array.isArray(r)&&r.length?r.map(KI).filter(Boolean):qI({fetchSecondaryByKeys:n,fetchSecondary:o,extractSecondaryRows:s,fetchSecondaryById:c,secondaryKey:u,mergeRow:d,secondaryFetchLimit:f}),g=0;async function _(e,t,n,r){if(!e.fetchById||!r)return null;try{let i=await e.fetchById(n,r);return i&&t(i).includes(String(r))?i:null}catch(e){return console.error(`[mergedListApi] per-id join lookup failed for "${r}"`,e),null}}async function v(e,t,n,r,i){if(!n)return e;let a=t.extractRows(n,r)??[],o=II(t.primaryKey??l),s=JI(t.key),c=YI(a,s);return Promise.all(e.map(async e=>{let n=o(e),a=c.get(n)??(i()?null:await _(t,s,r,n));return t.mergeRow(e,a,n)}))}async function y(e,t,n,r){let i=e;for(let e of t)i=await v(i,e.source,e.response,n,r);return i}function b(e,t,n){let r={};for(let e of n){if(!e)continue;let t=BI(e);for(let e of Object.keys(t))r[e]??(r[e]=t[e])}return p.length&&(r.fields=HI(r.fields??[],p,m)),RI(e,t,r)}async function x({moduleName:e,limit:t,offset:n,options:r,primaryResponse:i,primaryRows:a,pageRows:o,total:s}){return Promise.all(h.map(async c=>{try{let u=II(c.primaryKey??l),d=[...new Set(o.map(u).filter(Boolean))];return c.fetchByKeys&&d.length===0?{source:c,response:null}:{source:c,response:await ZI(c,XI({moduleName:e,limit:t,offset:n,options:r,keys:d,primaryResponse:i,primaryRows:a,pageRows:o,total:s,source:c}))}}catch(e){return console.error(`[mergedListApi] join fetch failed — rendering page without that join`,e),{source:c,response:null}}}))}async function S(n,r,i,a,o){let s=await e(n,r,i,a),c=t(s,n)??{},l=Array.isArray(c.rows)?c.rows:[],u=Number.isFinite(Number(c.total))?Number(c.total):l.length,d=await x({moduleName:n,limit:r,offset:i,options:a,primaryResponse:s,primaryRows:l,pageRows:l,total:u});return b(await y(l,d,n,o),u,[s,...d.map(e=>e.response)])}async function C(e,t,n,r,o){let s=await i(e,t,n,r),c=a(s,e)??[],l=c.length,u=c.slice(n,n+t),d=await x({moduleName:e,limit:t,offset:n,options:r,primaryResponse:s,primaryRows:c,pageRows:u,total:l});return b(await y(u,d,e,o),l,[s,...d.map(e=>e.response)])}return async function(t,n=10,r=0,i={}){let a=++g,o=()=>a!==g;return e?S(t,n,r,i,o):C(t,n,r,i,o)}}function $I(e,t,n={}){return QI({fetchPrimary:()=>LM(e,t),extractPrimaryRows:FM,fetchSecondary:Vn,fetchSecondaryById:RM,secondaryFetchLimit:n.moduleFetchLimit??200})}function eL(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 tL(e){let t=Array.isArray(e?.stages)?e.stages:[];if(!t.length)return e;let n={};for(let e of t){let t=eL(e?.stageName);t&&(n[t]=Number(e?.count)||0)}return{...n,...e}}var nL=e=>{let t=Number(e?.targetSubmission??e?.targetSubmissions);return Number.isFinite(t)&&t>0?t:null};function rL({submittedCountField:e=`submittedCount`,progressField:t=`targetSubmissionProgress`}={}){return function(n,r,i){let a=LI(n,r,i),o=nL(a);return o!=null&&(a[t]=`${Number(a?.[e])||0} of ${o}`),a}}function iL(e={}){let t=rL();return QI({primaryKey:`_id`,extraFields:e.extraFields,extraFieldsAfter:e.extraFieldsAfter,fetchPrimaryPage:Vn,joinSources:[{key:`entityId`,fetchByKeys:(e,t,n,r)=>{let i=Math.max(1,Number(r?.limit)||10);return IM(Math.floor((Number(r?.offset)||0)/i)+1,i)},extractRows:e=>(e?.items??[]).map(tL),mergeRow:(e,n,r)=>{let i=t(e,n,r);return n?._id&&(i.workflowId=n._id),i}}]})}async function aL(e,t=10,n=0,r={},i={}){return gi(await iL(i)(e,t,n,r),e)}async function oL(e,t,n,r=10,i=0,a={}){return gi(await $I(e,t)(n,r,i,a),n)}typeof window<`u`&&(window.__CORE_THEME_BUILD__=`2026-09-22T15:59:09.131Z`);var sL=CP,cL=Ux(xF),lL=Ux(CF),uL=Ux(RF),dL=Ux(XF),fL=Ux(aI),pL=Ux(cI),mL=Ux(dI),hL=Ux(mI),gL=Ux(gI),_L=Ux(kI),vL=Ux(jI);exports.ADMIN_API_URL=t.v,exports.ADMIN_APP_ID=t.y,exports.APP_ID=t.b,exports.AUTH_URL=t.x,exports.ActivityNotesCard=fl,exports.ActivityTab=tl,exports.AddBatchCandidatePopup=rP,exports.AddFormV1=Rc,exports.AdminDashboard=CP,exports.AdminDashboardContent=fk,exports.AdminPage=sL,exports.AppAlert=zc,exports.AppButton=n.Ot,exports.AppShell=fx,exports.ApprovalActionBar=yv,exports.AssigneeAvatars=pl,exports.AuthGuard=ix,exports.BILLING_STATUS_FLOW=Bf,exports.BOOLEAN_API_KEYS=a_,exports.BOOLEAN_PARSEABLE_API_KEYS=Wh,exports.BULK_UPLOAD_DEFAULT_ACCEPT=ml,exports.BULK_UPLOAD_DEFAULT_MAX_SIZE_MB=hl,exports.Breadcrumb=n.s,exports.BulkUploadPage=uL,exports.BulkUploadPanel=Cl,exports.CANDIDATES_URL=t.S,exports.CONTRACT_C2C=Uv,exports.CONTRACT_W2=Hv,exports.CORE_URL=t.C,exports.CURRENCY_SYMBOLS=Vu,exports.CalendarCard=j,exports.CoreThemeAdminApp=gk,exports.CoreThemeAdminRoutes=hk,exports.CustomPagination=Be,exports.DEFAULT_HOURS_POLICY=V_,exports.DEFAULT_RESULTS_VIEW=t_,exports.DETAIL_VIEW_MODE_OPTIONS=n.gr,exports.DETAIL_VIEW_MODE_VALUES=n._r,exports.DETAIL_VIEW_POPUP_PATH=n.vr,exports.DayLogModal=dv,exports.DescriptionBlock=Il,exports.DetailHeaderCard=Hp,exports.DetailViewPage=Yp,exports.DetailViewPopup=kA,exports.DetailViewV1=Rd,exports.DocumentViewer=r.t,exports.DynamicCards=Bt,exports.DynamicPopup=Kj,exports.DynamicPopupRoute=cP,exports.DynamicTabs=F,exports.EditFormV1=sh,exports.FIELD_TYPE_REGISTRY=Tg,exports.FINANCE_APPROVAL_CONFIG=Pv,exports.FINANCE_TYPE_CFO=Dv,exports.FINANCE_TYPE_ONBOARDING_MANAGER=Ev,exports.FINANCE_TYPE_ONBOARDING_MANAGER_REAPPROVE=Av,exports.FINANCE_TYPE_ONLY_FINANCE=Ov,exports.FINANCE_TYPE_SUBMISSION_MANAGER=Tv,exports.FINANCE_TYPE_SUBMISSION_MANAGER_REAPPROVE=kv,exports.FileListCard=tb,exports.FinanceApprovalPanel=Py,exports.FinanceAvatar=xp,exports.FinanceBadge=Tp,exports.FinanceDayCell=xv,exports.FinanceDivider=pp,exports.FinanceEmployeeCell=Sp,exports.FinanceEmptyState=up,exports.FinanceEquation=mp,exports.FinanceHistoryTimeline=vp,exports.FinanceHoursGrid=lp,exports.FinanceKpiRow=cp,exports.FinanceLine=fp,exports.FinanceListToolbar=B_,exports.FinanceMarginBadge=Ep,exports.FinanceMoneyCell=wp,exports.FinanceRecordsTable=kp,exports.FinanceRowChevron=Dp,exports.FinanceSection=dp,exports.FinanceStatusPill=sp,exports.FinanceTextCell=Cp,exports.FinanceTimesheetAnalysis=Cv,exports.FinanceWorkflowSteps=hp,exports.GATEWAY_URL=t.w,exports.GLOBAL_DEFAULT_FIELDS=tO,exports.HOURS_MESSAGES=H_,exports.Header=jb,exports.HierarchyUserFilter=Gt,exports.JOBS_URL=t.T,exports.LegacyAdminPage=cL,exports.ListView=ls,exports.LmsHomePage=vL,exports.LmsTestForm=_L,exports.Login=px,exports.MailPopup=gA,exports.ManageModules=pL,exports.ManageSubmodules=mL,exports.ModuleRowActions=gh,exports.NotesPanel=vv,exports.NotesTab=dl,exports.OPEN_AS_OPTIONS=Kg,exports.PAYROLL_STATUS_FLOW=Vf,exports.PLATFORM_SCOPES=QD,exports.POPUP_CONFIGS=JN,exports.PYOPS_URL=t.E,exports.ParamCardView=Ch,exports.ParamListView=kh,exports.PeriodBadgeTag=ev,exports.PlatformSection=zO,exports.PreviewPopup=DA,exports.ProjectSelect=Hx,exports.ProofUploadPreview=_v,exports.QuickLogBar=mv,exports.QuickLogSelectionBar=fv,exports.RESULTS_VIEW_OPTIONS=e_,exports.RegionBanner=SP,exports.RejectionReasonModal=pv,exports.SUBMISSIONS_URL=t.D,exports.SearchBuilderV1=j_,exports.Sidebar=ex,exports.StatusBadge=N_,exports.StatusBadgeTag=$_,exports.StickyNotesFullPage=lL,exports.StylishDynamicTabs=F_,exports.TemplateEditor=L_,exports.TestForm=dL,exports.TestingHomePage=gL,exports.TimelineGroups=qc,exports.TimesheetDayCell=cv,exports.TipTapEditor=n.Xn,exports.UserForm=xP,exports.VendorShareDrawer=fP,exports.ViewSummaryWidget=Hi,exports.WizardPopup=FA,exports.ZINNEXT_URL=t.O,exports.ZinnextTableView=hL,exports.ZinnextTestForm=fL,exports.appNow=n.er,exports.applyIntegrationStatus=n.Sr,exports.approveSubmission=be,exports.buildAcceptAttr=bl,exports.buildBooleanRequest=u_,exports.buildCsv=tp,exports.buildDailyRows=Yf,exports.buildDayGradient=ov,exports.buildRateHistoryEntries=my,exports.buildWeeklyRollup=Qf,exports.clearSelectedProject=t.i,exports.colors=n.$n,exports.computeFinance=oy,exports.computeHoursPolicy=J_,exports.computeMarginBand=$f,exports.conditionMatches=n.f,exports.configureCoreTheme=t.k,exports.configuredFieldLabel=n.p,exports.createAllWorkflowsListFetcher=iL,exports.createMergedListFetcher=QI,exports.createModuleListFetchAdapter=GI,exports.createWorkflowStageListFetcher=$I,exports.currencySymbol=Hu,exports.deactivateRegion=VD,exports.defaultMergeRow=LI,exports.deleteIntegrationConfig=n.Nr,exports.deriveDayStats=Jf,exports.describeCapacity=X_,exports.downloadCsv=ap,exports.evaluateShowIfWith=n.m,exports.findEmployerRow=ey,exports.flattenGroups=Qv,exports.formatAmount=Ju,exports.formatApp=n.tr,exports.formatAppDateTime=n.nr,exports.formatFileSize=yl,exports.formatFinanceMoney=hy,exports.formatHours=jf,exports.formatMoney=Yu,exports.formatPercent=Nf,exports.formatRate=Xu,exports.getActivity=n.In,exports.getAllWorkflowsModuleList=aL,exports.getAppTimeZone=n.rr,exports.getApprovalDate=Lf,exports.getBgcIntegrationConfig=n.Zr,exports.getBgcIntegrationSummary=n.Qr,exports.getBillingActionStates=Hf,exports.getBooleanEligibleTypes=jg,exports.getCurrentRoleName=t.c,exports.getDetailDisplayDefaults=n.fr,exports.getFieldLabel=rp,exports.getFieldType=Dg,exports.getFileExtension=vl,exports.getFinanceApprovalConfig=zv,exports.getFormGroupsRaw=Wy,exports.getGlobalAiServices=nO,exports.getGlobalDefaults=$D,exports.getIntegrationConfig=n.ii,exports.getIntegrationConfigs=n.ai,exports.getIntegrationSummary=n.oi,exports.getModuleConfig=Ie,exports.getModuleDataDetail=n.Rn,exports.getPayrollActionStates=Uf,exports.getPeriodBadgeConfig=Re,exports.getRegionDetailDefaults=JD,exports.getSearchPopup=Ug,exports.getSelectedProject=t.l,exports.getStoredToken=t.u,exports.getStoredUser=t.d,exports.getUserRoles=t.f,exports.getVMSApprove=xe,exports.getValueStyle=ip,exports.getWorkflowStageModuleList=oL,exports.getWorkflowSteps=Wf,exports.grantPlatformAccess=UD,exports.hasPlatformAccess=GD,exports.humanizeEvent=If,Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Ps}}),exports.indexFieldConfig=np,exports.initialsOf=Pf,exports.insertTokenAtCursor=Jh,exports.isBooleanEligible=Og,exports.isBooleanParsable=Kh,exports.isTester=t.p,exports.listPlatformAccess=HD,exports.listPlatformAudit=qD,exports.listPlatformUsers=KD,exports.listRegionRoles=ZD,exports.listRegionUsers=XD,exports.listRegions=zD,exports.loadDetailDefaults=n.pr,exports.logout=t.h,exports.marginIncludesReferral=Vv,exports.matchLocationTax=ay,Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return _m}}),exports.normalizeContract=ny,exports.normalizeDetailViewMode=n.yr,Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return wl}}),exports.rateUnitLabel=Wu,exports.rateUnitShort=Ku,exports.readActionButtons=Xg,exports.reconcileHours=Y_,exports.regionPath=RD,exports.registerFieldType=Eg,exports.registerSearchPopup=Hg,exports.rejectSubmission=Ce,exports.requiredWhenActive=n.c,exports.requiredWhenRule=n.l,exports.resolveActivityMeta=Qc,exports.resolveAndCompute=sy,exports.resolveDayKind=K_,exports.resolveFinanceInputs=iy,exports.resolveMergeKey=FI,exports.resolveMergedListKey=FI,exports.resolveOpenAs=Jg,exports.resolveRejectionReason=Bv,exports.resolveResultsSearchPlaceholder=i_,exports.resolveResultsView=r_,exports.resolveSubmissionFinance=Gy,exports.revokePlatformAccess=WD,exports.runDetailViewOpen=n.br,exports.saveBgcIntegrationConfig=n.ki,exports.saveGlobalAiServices=rO,exports.saveGlobalDefaults=eO,exports.saveIntegrationConfig=n.Mi,exports.saveRegion=BD,exports.saveRegionDetailDefaults=YD,exports.setSelectedProject=t._,exports.showIfConditions=n.g,exports.stageCountKey=eL,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return mx}}),exports.testIntegrationConnection=n.zi,exports.toApp=n.ar,exports.toNumber=qu,exports.tzLabel=n.or,exports.tzShortLabel=n.sr,exports.unregisterSearchPopup=Wg,exports.useDropdownFields=nr,exports.useDropdownValues=Ui,exports.useEditForm=ib,exports.useFieldConfig=rr,exports.useFilterFields=ir,exports.useMenuPermission=pr,exports.useModuleActions=lh,exports.useRecordRefresh=Kp,exports.useTabRows=rb,exports.validateBooleanQuery=qh,exports.validateBulkFile=xl,exports.withAdminAppId=t.A,exports.withAppId=t.j,exports.withAuthGuard=Ux;
|
|
7
|
+
`).length)),value:r,className:`fg-mono-input`,style:{marginTop:8,fontSize:12},onChange:n=>{i(n.target.value);try{t({...e,config:JSON.parse(n.target.value||`{}`)}),o(!1)}catch{o(!0)}}})]})}function dD({open:e,doc:t,moduleOptions:n,onClose:r,onSave:i}){let[a,o]=(0,s.useState)(()=>({key:``,module:``,event:`afterCreate`,order:10,isActive:!0,condition:{},actions:[],...t??{}})),[d,f]=(0,s.useState)(()=>lD(t?.condition)),[p,m]=(0,s.useState)(!1),h=(e,t)=>o(n=>({...n,[e]:t}));return(0,u.jsx)(c.Modal,{open:e,onCancel:r,width:840,centered:!0,destroyOnClose:!0,maskClosable:!1,className:`fg-editor-modal`,title:(0,u.jsxs)(`span`,{className:`fg-drawer-title`,children:[(0,u.jsx)(l.ApartmentOutlined,{}),` `,t?`Edit Workflow`:`New Workflow`]}),footer:(0,u.jsxs)(`div`,{className:`fg-drawer-footer`,children:[(0,u.jsx)(c.Button,{onClick:r,children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.SaveOutlined,{}),onClick:()=>{if(!a.key?.trim())return c.message.error(`Key is required`);if(!a.module?.trim())return c.message.error(`Module is required`);if(p)return c.message.error(`Condition JSON is invalid`);if(!(a.actions??[]).length)return c.message.error(`At least one action is required`);if((a.actions??[]).some(e=>!e.type))return c.message.error(`Every action needs a type`);let e={...a};delete e.id,delete e._id,i(e)},children:`Save Workflow`})]}),children:(0,u.jsxs)(`div`,{className:`fg-form-section`,children:[(0,u.jsxs)(`div`,{className:`fg-field-meta-row`,children:[(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(aD,{type:`secondary`,style:{fontSize:12},children:`Key`}),(0,u.jsx)(c.Input,{size:`small`,placeholder:`jobs-create-after`,value:a.key??``,onChange:e=>h(`key`,e.target.value),className:`fg-mono-input`,disabled:!!t})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(aD,{type:`secondary`,style:{fontSize:12},children:`Module`}),(0,u.jsx)(c.Select,{size:`small`,style:{width:`100%`},showSearch:!0,value:a.module||void 0,options:n,onChange:e=>h(`module`,e),placeholder:`jobs`})]}),(0,u.jsxs)(`div`,{style:{flex:1},children:[(0,u.jsx)(aD,{type:`secondary`,style:{fontSize:12},children:`Event`}),(0,u.jsx)(c.Select,{size:`small`,style:{width:`100%`},value:a.event,options:oD.map(e=>({value:e})),onChange:e=>h(`event`,e)})]}),(0,u.jsxs)(`div`,{style:{width:90},children:[(0,u.jsx)(aD,{type:`secondary`,style:{fontSize:12},children:`Order`}),(0,u.jsx)(c.InputNumber,{size:`small`,style:{width:`100%`},value:a.order??10,onChange:e=>h(`order`,e??10)})]})]}),(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:12},children:[(0,u.jsx)(c.Switch,{size:`small`,checked:a.isActive!==!1,onChange:e=>h(`isActive`,e)}),(0,u.jsx)(aD,{style:{fontSize:13},children:`Active`})]}),(0,u.jsxs)(`div`,{style:{marginTop:12},children:[(0,u.jsxs)(aD,{type:`secondary`,style:{fontSize:12},children:[`Condition (all must match the payload; empty = always run) `,p&&(0,u.jsx)(c.Tag,{color:`red`,children:`invalid JSON`})]}),(0,u.jsx)(c.Input.TextArea,{rows:2,value:d,className:`fg-mono-input`,style:{fontSize:12},onChange:e=>{f(e.target.value);try{h(`condition`,JSON.parse(e.target.value||`{}`)),m(!1)}catch{m(!0)}}})]}),(0,u.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginTop:14},children:[(0,u.jsx)(aD,{strong:!0,style:{fontSize:13},children:`Actions (run in order)`}),(0,u.jsx)(c.Button,{size:`small`,type:`dashed`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>h(`actions`,[...a.actions??[],{type:``,config:{}}]),children:`Add Action`})]}),(a.actions??[]).map((e,t)=>(0,u.jsx)(uD,{action:e,onChange:e=>h(`actions`,a.actions.map((n,r)=>r===t?e:n)),onRemove:()=>h(`actions`,a.actions.filter((e,n)=>n!==t))},t)),(0,u.jsxs)(aD,{type:`secondary`,style:{fontSize:11,display:`block`,marginTop:8},children:[`Config supports `,(0,u.jsx)(`code`,{children:`{{field.path}}`}),`, `,(0,u.jsx)(`code`,{children:`{{now}}`}),`, `,(0,u.jsx)(`code`,{children:`{{__userId}}`}),`,`,` `,(0,u.jsx)(`code`,{children:`{{__userName}}`}),`, and `,(0,u.jsx)(`code`,{children:`{{hierarchy.<name>}}`}),` from a `,(0,u.jsx)(`code`,{children:`resolve`}),` action.`]})]})})}function fD(){let[e,t]=(0,s.useState)([]),[r,i]=(0,s.useState)([]),[a,o]=(0,s.useState)(!0),[d,f]=(0,s.useState)(``),[p,m]=(0,s.useState)(null),[h,g]=(0,s.useState)(``),[_,v]=(0,s.useState)(0);(0,s.useEffect)(()=>{let e=!1;return n.wi(`workflows`).then(n=>{e||t(n)}).catch(t=>{e||f(t?.message||`Failed to load workflows`)}).finally(()=>{e||o(!1)}),()=>{e=!0}},[_]),(0,s.useEffect)(()=>{n.Xr().then(e=>i(qS(e).map(({value:e,label:t})=>({value:e,label:t})))).catch(()=>i([]))},[]);let y=()=>{o(!0),f(``),v(e=>e+1)};async function b(e){try{await n.Fi(`workflows`,e),c.message.success(`Workflow "${e.key}" saved`),m(null),y()}catch(e){c.message.error(e?.message||`Could not save workflow`)}}async function x(e){try{await n.Rr(`workflows`,e),c.message.success(`Workflow "${e}" deleted`),y()}catch(e){c.message.error(e?.message||`Could not delete workflow`)}}async function S(e,t){let r={...e};delete r.id,delete r._id;try{await n.Fi(`workflows`,{...r,isActive:t}),y()}catch(e){c.message.error(e?.message||`Could not update workflow`)}}let C=(0,s.useMemo)(()=>e.filter(e=>!h||e.module===h),[e,h]);return(0,u.jsxs)(`div`,{className:`fg-section`,children:[(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.ApartmentOutlined,{}),title:`Workflows`,extra:(0,u.jsxs)(c.Space,{size:8,children:[(0,u.jsx)(c.Select,{size:`small`,style:{minWidth:160},allowClear:!0,placeholder:`Filter by module`,options:r,value:h||void 0,onChange:e=>g(e??``)}),(0,u.jsx)(c.Button,{size:`small`,icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:y,children:`Reload`}),(0,u.jsx)(c.Button,{type:`primary`,size:`small`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>m({doc:null}),children:`New Workflow`})]}),children:[(0,u.jsx)(`div`,{className:`admin-accent-bar`}),(0,u.jsxs)(aD,{type:`secondary`,style:{fontSize:13},children:[`Event-driven behavior per module — reference ids, duplicate checks, snapshots, hierarchy fan-outs, board updates, notifications, cache — executed by the platform Workflow Engine on every create/update/delete.`,(0,u.jsx)(c.Tag,{style:{marginLeft:8},children:`before*`}),` actions can block the write; `,(0,u.jsx)(c.Tag,{children:`after*`}),` actions are best-effort.`]})]}),(0,u.jsxs)(Z,{styles:{body:{paddingTop:8}},children:[d&&(0,u.jsx)(c.Alert,{type:`error`,showIcon:!0,message:d,style:{marginBottom:12}}),(0,u.jsxs)(c.Spin,{spinning:a,children:[(0,u.jsxs)(`div`,{style:{marginBottom:8},children:[(0,u.jsx)(c.Badge,{count:C.length,showZero:!0,color:`var(--color-brand)`}),` `,(0,u.jsx)(aD,{type:`secondary`,style:{fontSize:12},children:`workflows`})]}),(0,u.jsx)(c.Table,{rowKey:`key`,dataSource:C,columns:[{title:`Key`,dataIndex:`key`,key:`key`,render:e=>(0,u.jsx)(`code`,{className:`fg-table-code`,children:e})},{title:`Module`,dataIndex:`module`,key:`module`,width:130,render:e=>(0,u.jsx)(c.Tag,{color:`geekblue`,children:e})},{title:`Event`,dataIndex:`event`,key:`event`,width:130,render:e=>(0,u.jsx)(c.Tag,{color:String(e).startsWith(`before`)?`purple`:`green`,children:e})},{title:`Actions`,key:`acts`,render:(e,t)=>(0,u.jsx)(c.Space,{size:4,wrap:!0,children:(t.actions??[]).map((e,t)=>(0,u.jsx)(c.Tag,{style:{margin:0},children:e.type},t))})},{title:`Order`,dataIndex:`order`,key:`order`,width:70,align:`center`},{title:`Active`,key:`active`,width:80,align:`center`,render:(e,t)=>(0,u.jsx)(c.Switch,{size:`small`,checked:t.isActive!==!1,onChange:e=>S(t,e)})},{title:``,key:`ops`,width:90,align:`right`,render:(e,t)=>(0,u.jsxs)(c.Space,{size:4,children:[(0,u.jsx)(c.Tooltip,{title:`Edit`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>m({doc:t})})}),(0,u.jsx)(c.Popconfirm,{title:`Delete workflow "${t.key}"?`,onConfirm:()=>x(t.key),children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{})})})]})}],pagination:!1,size:`small`,className:`fg-table`,locale:{emptyText:(0,u.jsx)(c.Empty,{description:`No workflows configured.`,image:c.Empty.PRESENTED_IMAGE_SIMPLE})}})]})]}),(0,u.jsx)(dD,{open:!!p,doc:p?.doc,moduleOptions:r,onClose:()=>m(null),onSave:b},p?p.doc?.key??`new`:`closed`)]})}var{Text:pD}=c.Typography,mD=e=>e?._id??e?.id,hD=`masters`;function gD(){return{tenantId:localStorage.getItem(`tenantId`)||``,businessId:localStorage.getItem(`businessId`)||``,businessUnitId:localStorage.getItem(`businessUnitId`)||``}}function _D(e){return e&&typeof e==`object`?e.$oid??e.oid??e.id??``:e??``}function vD(e,t){return t.map(t=>_D(e?.[t])).find(e=>e!=null&&e!==``)??``}function yD(e,t){return[[t.tenantId,[`tid`,`tenantId`]],[t.businessId,[`bid`,`businessId`]],[t.businessUnitId,[`buid`,`businessUnitId`]]].every(([t,n])=>{if(!t)return!0;let r=String(vD(e,n));return!r||r===String(t)})}function bD(e){return Array.isArray(e?.masterFeeds)?e.masterFeeds:[]}function xD(e){return e.reduce((e,t)=>Math.max(e,Number(t?.uniqueId)||0),0)+1}function SD(e){return Array.isArray(e?.taxHistory)?e.taxHistory:[]}function CD(e){let t=e?.taxValue;if(t!=null&&t!==``)return Number(t);let n=SD(e).at(-1),r=n?.taxValue??n?.value;return r!=null&&r!==``?Number(r):void 0}function wD(e){if(!e)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(t)}function TD(e){let t=SD(e).at(-1);return t?.updatedAt??t?.timestamp??e?.updatedAt}function ED({open:e,record:t,onClose:r,onSaved:i}){let[a]=c.Form.useForm(),[o,l]=(0,s.useState)(!1),[d,f]=(0,s.useState)([]),[p,m]=(0,s.useState)(!1),h=(0,s.useRef)(null),g=!!t;(0,s.useEffect)(()=>{e&&queueMicrotask(()=>{a.resetFields(),a.setFieldsValue({name:t?.name??void 0,taxValue:CD(t)}),f(t?.name?[{label:t.name,value:t.name}]:[])})},[e,t,a]);function _(e){if(h.current&&clearTimeout(h.current),!e||e.trim().length<2){f([]);return}m(!0),h.current=setTimeout(()=>{n.si(e.trim()).then(f).catch(()=>f([])).finally(()=>m(!1))},350)}async function v(){let e=await a.validateFields(),r=Number(e.taxValue),o={name:e.name,taxValue:r,taxHistory:{taxValue:r}};l(!0);try{g?await n.Gi(`locations`,mD(t),o):await n.Or(`locations`,o),c.message.success(g?`Tax updated`:`Location and tax created`),i()}catch(e){c.message.error(e?.message||`Could not save location and tax`)}finally{l(!1)}}return(0,u.jsx)(c.Modal,{open:e,onCancel:r,onOk:v,confirmLoading:o,destroyOnHidden:!0,title:g?`Edit Tax — ${t?.name??``}`:`New Location`,children:(0,u.jsxs)(c.Form,{form:a,layout:`vertical`,children:[(0,u.jsx)(c.Form.Item,{name:`name`,label:`Location`,rules:[{required:!0,message:`Location is required`}],tooltip:g?`Location cannot be changed once created — only the tax is editable.`:`Search and pick from the location master.`,children:(0,u.jsx)(c.Select,{showSearch:!0,disabled:g,placeholder:`Type at least 2 characters to search…`,filterOption:!1,onSearch:_,notFoundContent:p?`Searching…`:null,options:d})}),(0,u.jsx)(c.Form.Item,{name:`taxValue`,label:`Tax`,rules:[{required:!0,message:`Tax is required`},{type:`number`,min:0,max:100,message:`Tax must be between 0 and 100`}],children:(0,u.jsx)(c.InputNumber,{style:{width:`100%`},min:0,max:100,step:.01,suffix:`%`,placeholder:`8.875`,autoFocus:g})})]})})}function DD({record:e}){let t=[...SD(e)].reverse();return t.length?(0,u.jsx)(c.Space,{direction:`vertical`,size:4,style:{padding:`4px 8px`},children:t.map((e,t)=>(0,u.jsxs)(c.Space,{size:10,children:[(0,u.jsxs)(c.Tag,{color:t===0?`green`:`default`,style:{margin:0},children:[e.taxValue??e.value,`%`]}),(0,u.jsx)(pD,{type:`secondary`,style:{fontSize:12},children:wD(e.updatedAt??e.timestamp)}),t===0&&(0,u.jsx)(pD,{type:`secondary`,style:{fontSize:12},children:`(current)`})]},t))}):(0,u.jsx)(c.Empty,{image:c.Empty.PRESENTED_IMAGE_SIMPLE,description:`No tax history yet`})}function OD(){let[e,t]=(0,s.useState)([]),[r,i]=(0,s.useState)(!1),[a,o]=(0,s.useState)(!1),[d,f]=(0,s.useState)(null);function p(){i(!0),n.Ci(`locations`).then(({items:e})=>t(e)).catch(e=>c.message.error(e?.message||`Could not load locations`)).finally(()=>i(!1))}(0,s.useEffect)(()=>{queueMicrotask(p)},[]);async function m(e){try{await n.Lr(`locations`,e),c.message.success(`Location deleted`),p()}catch(e){c.message.error(e?.message||`Could not delete location`)}}return(0,u.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,u.jsx)(Z,{title:`${e.length} location${e.length===1?``:`s`}`,extra:(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:p,children:`Reload`}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>{f(null),o(!0)},children:`New location`})]}),children:(0,u.jsx)(c.Table,{rowKey:mD,columns:[{title:`Location`,dataIndex:`name`,key:`name`},{title:`Tax`,key:`taxValue`,width:100,render:(e,t)=>{let n=CD(t);return Number.isFinite(n)?(0,u.jsxs)(c.Tag,{color:`blue`,children:[n,`%`]}):`—`}},{title:`Tax updated`,key:`taxUpdatedAt`,render:(e,t)=>wD(TD(t))},{title:`Created`,key:`createdAt`,responsive:[`lg`],render:(e,t)=>wD(t?.createdAt)},{title:``,key:`actions`,width:90,render:(e,t)=>(0,u.jsxs)(c.Space,{size:4,children:[(0,u.jsx)(c.Tooltip,{title:`Edit tax`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>{f(t),o(!0)}})}),(0,u.jsx)(c.Popconfirm,{title:`Delete this location?`,onConfirm:()=>m(mD(t)),children:(0,u.jsx)(c.Tooltip,{title:`Delete`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{})})})})]})}],dataSource:e,loading:r,size:`small`,pagination:!1,className:`fg-table`,expandable:{expandedRowRender:e=>(0,u.jsx)(DD,{record:e}),rowExpandable:e=>SD(e).length>0},locale:{emptyText:`No locations yet. Click "New location" to add one.`}})}),(0,u.jsx)(ED,{open:a,record:d,onClose:()=>o(!1),onSaved:()=>{o(!1),p()}})]})}function kD({open:e,record:t,onClose:r,onSaved:i}){let[a]=c.Form.useForm(),[o,d]=(0,s.useState)(!1),f=!!t,p=c.Form.useWatch(`masterName`,a),m=c.Form.useWatch(`masterFeeds`,a)??[],h=[`clientsubmissionstatus`,`clientsubmission`,`clientsubmissions`].includes(String(p??t?.masterName??``).trim().toLowerCase()),g=m.map(e=>({label:String(e?.name??``).trim()||`Status ${e?.uniqueId??``}`,value:Number(e?.uniqueId)})).filter(e=>Number.isInteger(e.value)&&e.value>0);function _(e,t){if(!t){a.setFieldValue([`masterFeeds`,e,`isInitialStatus`],!1);return}(a.getFieldValue(`masterFeeds`)??[]).forEach((t,n)=>{a.setFieldValue([`masterFeeds`,n,`isInitialStatus`],n===e)})}function v(e,t){a.setFieldValue([`masterFeeds`,e,`isTerminalStatus`],t),t&&a.setFieldValue([`masterFeeds`,e,`allowedNextStatusIds`],[])}(0,s.useEffect)(()=>{e&&queueMicrotask(()=>{a.resetFields();let e=t?.masterName??``,n=[`clientsubmissionstatus`,`clientsubmission`,`clientsubmissions`].includes(String(e).trim().toLowerCase()),r=bD(t),i=r.length?r.map(e=>({...e})):[{uniqueId:1,name:``,type:`neutral`,status:!0,isdeleted:!1}];if(n&&!i.some(e=>e?.status!==!1&&e?.isdeleted!==!0&&e?.isInitialStatus===!0)){let e=i.findIndex(e=>e?.status!==!1&&e?.isdeleted!==!0);e>=0&&(i=i.map((t,n)=>({...t,isInitialStatus:n===e,isTerminalStatus:t?.isTerminalStatus===!0,allowedNextStatusIds:Array.isArray(t?.allowedNextStatusIds)?t.allowedNextStatusIds:[]})))}a.setFieldsValue({masterName:e,schemaVersion:t?.schemaVersion??1,masterFeeds:i})})},[e,t,a]),(0,s.useEffect)(()=>{!e||!h||(Number(a.getFieldValue(`schemaVersion`))||1)<2&&a.setFieldValue(`schemaVersion`,2)},[e,h,a]);async function y(){let e=await a.validateFields(),r=gD(),o=[`clientsubmissionstatus`,`clientsubmission`,`clientsubmissions`].includes(String(e.masterName??``).trim().toLowerCase()),s=(e.masterFeeds??[]).map((e,t)=>{let n=Number(e.uniqueId)||t+1,r=o&&e.isTerminalStatus===!0,i=o&&!r?[...new Set((e.allowedNextStatusIds??[]).map(Number).filter(e=>Number.isInteger(e)&&e>0&&e!==n))]:[];return{uniqueId:n,name:String(e.name??``).trim(),type:String(e.type??``).trim(),status:e.status!==!1,...o?{isInitialStatus:e.isInitialStatus===!0,isTerminalStatus:r,allowedNextStatusIds:i}:{},isdeleted:e.isdeleted===!0}}).filter(e=>e.name);if(o){let e=s.filter(e=>e.status&&!e.isdeleted&&e.isInitialStatus);if(e.length===0){let t=s.findIndex(e=>e.status&&!e.isdeleted);t>=0&&(s[t]={...s[t],isInitialStatus:!0},e=[s[t]],a.setFieldValue([`masterFeeds`,t,`isInitialStatus`],!0))}if(e.length!==1){c.message.error(`Client Submission Status must have exactly one active Initial Status.`);return}}let l={...r,tid:r.tenantId,bid:r.businessId,buid:r.businessUnitId,schemaVersion:o?Math.max(2,Number(e.schemaVersion)||2):Number(e.schemaVersion)||1,masterName:e.masterName.trim(),masterFeeds:s};d(!0);try{f?await n.Gi(hD,mD(t),l):await n.Or(hD,l),c.message.success(f?`Master value updated`:`Master value created`),i()}catch(e){c.message.error(e?.message||`Could not save master value`)}finally{d(!1)}}return(0,u.jsx)(c.Modal,{open:e,onCancel:r,onOk:y,confirmLoading:o,destroyOnHidden:!0,title:f?`Edit Master Feed`:`New Master Feed`,width:1040,children:(0,u.jsxs)(c.Form,{form:a,layout:`vertical`,children:[(0,u.jsx)(c.Form.Item,{name:`masterName`,label:`Master Name`,rules:[{required:!0,message:`Master name is required`}],children:(0,u.jsx)(c.Input,{placeholder:`blacklistType`,autoFocus:!f,disabled:f})}),(0,u.jsx)(c.Form.Item,{name:`schemaVersion`,label:`Schema Version`,children:(0,u.jsx)(c.InputNumber,{min:1,style:{width:`100%`}})}),(0,u.jsx)(c.Form.List,{name:`masterFeeds`,children:(e,{add:t,remove:n})=>(0,u.jsxs)(c.Space,{direction:`vertical`,style:{width:`100%`},size:10,children:[e.map(({key:e,name:t})=>(0,u.jsxs)(c.Space,{align:`baseline`,wrap:!0,children:[(0,u.jsx)(c.Form.Item,{name:[t,`uniqueId`],label:`ID`,rules:[{required:!0,message:`ID required`}],children:(0,u.jsx)(c.InputNumber,{min:1,style:{width:90}})}),(0,u.jsx)(c.Form.Item,{name:[t,`name`],label:`Name`,rules:[{required:!0,message:`Name required`}],children:(0,u.jsx)(c.Input,{placeholder:`Dropdown label`,style:{width:280}})}),(0,u.jsx)(c.Form.Item,{name:[t,`type`],label:`Type`,children:(0,u.jsx)(c.Select,{allowClear:!0,placeholder:`Select type`,style:{width:120},options:[{label:`Positive`,value:`positive`},{label:`Neutral`,value:`neutral`},{label:`Negative`,value:`negative`}]})}),(0,u.jsx)(c.Form.Item,{name:[t,`status`],label:`Status`,initialValue:!0,children:(0,u.jsx)(c.Select,{style:{width:110},options:[{label:`Active`,value:!0},{label:`Inactive`,value:!1}]})}),(0,u.jsx)(c.Form.Item,{name:[t,`isdeleted`],label:`Deleted`,initialValue:!1,children:(0,u.jsx)(c.Select,{style:{width:110},options:[{label:`No`,value:!1},{label:`Yes`,value:!0}]})}),h&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Form.Item,{name:[t,`isInitialStatus`],label:`Initial`,initialValue:!1,tooltip:`The initial status is the only option shown before a candidate has a client submission status. Only one active initial status is allowed.`,children:(0,u.jsx)(c.Select,{style:{width:100},onChange:e=>_(t,e===!0),options:[{label:`Yes`,value:!0},{label:`No`,value:!1}]})}),(0,u.jsx)(c.Form.Item,{name:[t,`isTerminalStatus`],label:`End Status`,initialValue:!1,tooltip:`End Status stops the configured client submission flow. Once reached, Change Status is hidden and no next statuses are allowed.`,children:(0,u.jsx)(c.Select,{style:{width:105},onChange:e=>v(t,e===!0),options:[{label:`Yes`,value:!0},{label:`No`,value:!1}]})}),(0,u.jsx)(c.Form.Item,{noStyle:!0,shouldUpdate:(e,n)=>e?.masterFeeds?.[t]?.isTerminalStatus!==n?.masterFeeds?.[t]?.isTerminalStatus||e?.masterFeeds?.[t]?.uniqueId!==n?.masterFeeds?.[t]?.uniqueId||e?.masterFeeds!==n?.masterFeeds,children:({getFieldValue:e})=>{let n=e([`masterFeeds`,t,`isTerminalStatus`])===!0,r=Number(e([`masterFeeds`,t,`uniqueId`]));return(0,u.jsx)(c.Form.Item,{name:[t,`allowedNextStatusIds`],label:`Allowed Next Statuses`,tooltip:n?`End Status cannot move to another status.`:`Only these statuses will appear after the current status is saved.`,children:(0,u.jsx)(c.Select,{mode:`multiple`,allowClear:!0,disabled:n,placeholder:n?`End status`:`Select next statuses`,style:{minWidth:280},options:g.filter(e=>e.value!==r)})})}})]}),(0,u.jsx)(c.Tooltip,{title:`Remove row`,children:(0,u.jsx)(c.Button,{type:`text`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{}),onClick:()=>n(t)})})]},e)),(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>t({uniqueId:xD(a.getFieldValue(`masterFeeds`)??[]),name:``,type:`neutral`,status:!0,isdeleted:!1,...h?{isInitialStatus:!1,isTerminalStatus:!1,allowedNextStatusIds:[]}:{}}),children:`Add feed value`})]})})]})})}function AD(){let[e,t]=(0,s.useState)([]),[r,i]=(0,s.useState)(!1),[a,o]=(0,s.useState)(!1),[d,f]=(0,s.useState)(null),[p,m]=(0,s.useState)(``);function h(){let e=gD();i(!0),n.Ci(hD,{limit:500}).then(({items:n})=>{let r=n.filter(t=>yD(t,e));t(r)}).catch(e=>c.message.error(e?.message||`Could not load master values`)).finally(()=>i(!1))}(0,s.useEffect)(()=>{queueMicrotask(h)},[]);async function g(e){try{await n.Lr(hD,e),c.message.success(`Master value deleted`),h()}catch(e){c.message.error(e?.message||`Could not delete master value`)}}let _=p?e.filter(e=>String(e?.masterName??``).toLowerCase()===p.toLowerCase()):e,v=[...new Set(e.map(e=>e?.masterName).filter(Boolean))].sort((e,t)=>String(e).localeCompare(String(t))).map(e=>({label:e,value:e}));return(0,u.jsxs)(`div`,{className:`fg-section admin-config-section`,children:[(0,u.jsx)(Z,{title:`${_.length} master${_.length===1?``:`s`}`,extra:(0,u.jsxs)(c.Space,{wrap:!0,children:[(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,placeholder:`Filter master name`,value:p||void 0,options:v,onChange:e=>m(e??``),style:{minWidth:220}}),(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:h,children:`Reload`}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>{f(null),o(!0)},children:`New master`})]}),children:(0,u.jsx)(c.Table,{rowKey:mD,columns:[{title:`Master Name`,dataIndex:`masterName`,key:`masterName`,width:180},{title:`Feed Values`,key:`masterFeeds`,render:(e,t)=>(0,u.jsx)(c.Space,{wrap:!0,children:bD(t).filter(e=>!e.isdeleted).map(e=>(0,u.jsx)(c.Tag,{color:e.status===!1?`default`:`blue`,children:e.name},e.uniqueId??e.name))})},{title:`Count`,key:`count`,width:90,render:(e,t)=>bD(t).filter(e=>!e.isdeleted).length},{title:`Updated`,key:`updatedAt`,responsive:[`lg`],render:(e,t)=>wD(t?.updatedAt)},{title:``,key:`actions`,width:90,render:(e,t)=>(0,u.jsxs)(c.Space,{size:4,children:[(0,u.jsx)(c.Tooltip,{title:`Edit`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>{f(t),o(!0)}})}),(0,u.jsx)(c.Popconfirm,{title:`Delete this master?`,onConfirm:()=>g(mD(t)),children:(0,u.jsx)(c.Tooltip,{title:`Delete`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{})})})})]})}],dataSource:_,loading:r,size:`small`,pagination:{pageSize:10,showSizeChanger:!0},className:`fg-table`,locale:{emptyText:`No masters yet. Click "New master" to add one.`}})}),(0,u.jsx)(kD,{open:a,record:d,onClose:()=>o(!1),onSaved:()=>{o(!1),h()}})]})}function jD(){return(0,u.jsxs)(`div`,{className:`fg-section`,children:[(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.DatabaseOutlined,{}),title:`Master Collections`,children:[(0,u.jsx)(`div`,{className:`admin-accent-bar`}),(0,u.jsx)(pD,{type:`secondary`,style:{fontSize:13},children:`Create, update, and delete master documents, then customize multiple dropdown values inside masterFeeds. Records are saved with the current tenant, business, business unit, and master name.`})]}),(0,u.jsx)(AD,{}),(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.DatabaseOutlined,{}),title:`Location Tax Master`,children:[(0,u.jsx)(`div`,{className:`admin-accent-bar`}),(0,u.jsx)(pD,{type:`secondary`,style:{fontSize:13},children:`Pick a location from the master list and set its tax. Once added, only the tax can be changed — every change is kept in a timeline with its timestamp. Expand a row to see the full tax history.`})]}),(0,u.jsx)(OD,{})]})}var{Text:MD,Title:ND}=c.Typography;function PD(){let[e]=c.Form.useForm(),[t,n]=(0,s.useState)([]),[r,i]=(0,s.useState)(!0),[a,o]=(0,s.useState)(!1),[d,f]=(0,s.useState)(null),[p,m]=(0,s.useState)(!1);async function h(){i(!0);try{n(await gS())}catch(e){c.message.error(e.message||`Unable to load menus`)}finally{i(!1)}}(0,s.useEffect)(()=>{h()},[]);let g=(0,s.useMemo)(()=>t.filter(e=>!d||e.menu_id!==d.menu_id).map(e=>({label:e.menu_name,value:e.menu_id})),[d,t]);function _(){f(null),e.resetFields(),e.setFieldsValue({menu_type:`MENU`,display_order:t.length+1,status:`ACTIVE`}),m(!0)}function v(t){f(t),e.setFieldsValue(t),m(!0)}async function y(e){o(!0);try{d?await vS(d.menu_id,e):await _S(e),c.message.success(d?`Menu updated`:`Menu created`),m(!1),await h()}catch(e){c.message.error(e.message||`Unable to save menu`)}finally{o(!1)}}async function b(e){try{await yS(e),c.message.success(`Menu deleted`),await h()}catch(e){c.message.error(e.message||`Unable to delete menu`)}}return(0,u.jsxs)(`section`,{className:`admin-section`,children:[(0,u.jsxs)(`div`,{className:`admin-section-head`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(ND,{level:4,children:`Menus`}),(0,u.jsx)(MD,{type:`secondary`,children:`Manage records in the MongoDB menus collection.`})]}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:_,children:`Add Menu`})]}),(0,u.jsx)(c.Table,{rowKey:`menu_id`,loading:r,columns:[{title:`Name`,dataIndex:`menu_name`},{title:`Key`,dataIndex:`menu_key`,render:e=>(0,u.jsx)(c.Tag,{children:e})},{title:`Route / API`,dataIndex:`api_url`},{title:`Type`,dataIndex:`menu_type`,width:110},{title:`Order`,dataIndex:`display_order`,width:80},{title:`Status`,dataIndex:`status`,width:100,render:e=>(0,u.jsx)(c.Tag,{color:e===`ACTIVE`?`green`:`default`,children:e})},{title:``,key:`actions`,width:90,render:(e,t)=>(0,u.jsxs)(c.Space,{size:4,children:[(0,u.jsx)(c.Button,{"aria-label":`Edit menu`,size:`small`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>v(t)}),(0,u.jsx)(c.Popconfirm,{title:`Delete menu?`,onConfirm:()=>b(t.menu_id),children:(0,u.jsx)(c.Button,{"aria-label":`Delete menu`,danger:!0,size:`small`,icon:(0,u.jsx)(l.DeleteOutlined,{})})})]})}],dataSource:t,size:`small`,pagination:{pageSize:10}}),(0,u.jsx)(c.Modal,{title:d?`Edit Menu`:`Add Menu`,open:p,onCancel:()=>m(!1),onOk:()=>e.submit(),confirmLoading:a,destroyOnHidden:!0,children:(0,u.jsxs)(c.Form,{form:e,layout:`vertical`,onFinish:y,children:[(0,u.jsx)(c.Form.Item,{name:`menu_name`,label:`Menu name`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{})}),(0,u.jsx)(c.Form.Item,{name:`menu_key`,label:`Menu key`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{placeholder:`jobs`})}),(0,u.jsx)(c.Form.Item,{name:`api_url`,label:`Route / API URL`,children:(0,u.jsx)(c.Input,{placeholder:`/jobs`})}),(0,u.jsx)(c.Form.Item,{name:`component_name`,label:`Component`,children:(0,u.jsx)(c.Input,{placeholder:`Jobs`})}),(0,u.jsxs)(`div`,{className:`admin-form-row`,children:[(0,u.jsx)(c.Form.Item,{name:`menu_type`,label:`Type`,children:(0,u.jsx)(c.Select,{options:[{value:`MENU`},{value:`FOOTER`},{value:`CHILD`}]})}),(0,u.jsx)(c.Form.Item,{name:`parent_menu_id`,label:`Parent`,children:(0,u.jsx)(c.Select,{allowClear:!0,options:g})})]}),(0,u.jsxs)(`div`,{className:`admin-form-row`,children:[(0,u.jsx)(c.Form.Item,{name:`display_order`,label:`Display order`,children:(0,u.jsx)(c.InputNumber,{min:0})}),(0,u.jsx)(c.Form.Item,{name:`status`,label:`Status`,children:(0,u.jsx)(c.Select,{options:[{value:`ACTIVE`},{value:`INACTIVE`}]})})]}),(0,u.jsx)(c.Form.Item,{name:`icon`,label:`Icon`,children:(0,u.jsx)(c.Input,{placeholder:`AppstoreOutlined`})})]})})]})}var FD=`/admin/global`;function ID(e){let t=e?.data??e;return t&&typeof t==`object`&&`data`in t&&`total`in t?{items:t.data??[],total:t.total??0}:{items:Array.isArray(t)?t:[],total:Array.isArray(t)?t.length:0}}function LD(e={}){let t=new URLSearchParams;Object.entries(e).forEach(([e,n])=>{n!=null&&n!==``&&t.append(e,String(n))});let n=t.toString();return n?`?${n}`:``}function RD(e,t){let n=String(e||``).trim().toLowerCase();if(!n)throw Error(`regionPath: a region key is required`);return`/admin/regions/${encodeURIComponent(n)}${t}`}async function zD({includeInactive:e=!1,signal:n}={}){let r=await t.o(t.x,`${FD}/regions${LD({includeInactive:e||void 0})}`,{signal:n}),i=r?.data??r;return Array.isArray(i)?i:[]}async function BD(e,{allowEmpty:n=!1,signal:r}={}){return t.o(t.x,`${FD}/regions${LD({allowEmpty:n||void 0})}`,{method:`POST`,body:JSON.stringify(e),signal:r})}async function VD(e,{signal:n}={}){return t.o(t.x,`${FD}/regions/${encodeURIComponent(e)}`,{method:`DELETE`,signal:n})}async function HD({signal:e}={}){let n=await t.o(t.x,`${FD}/platform-access`,{signal:e}),r=n?.data??n;return Array.isArray(r)?r:[]}async function UD(e,{signal:n}={}){return t.o(t.x,`${FD}/platform-access`,{method:`POST`,body:JSON.stringify(e),signal:n})}async function WD(e,{signal:n}={}){return t.o(t.x,`${FD}/platform-access/${encodeURIComponent(e)}`,{method:`DELETE`,signal:n})}async function GD({signal:e}={}){try{return await zD({signal:e}),!0}catch(e){if(e?.name===`AbortError`)throw e;return!1}}async function KD({search:e,regionKey:n,limit:r=25,offset:i=0,signal:a}={}){return ID(await t.o(t.x,`${FD}/users${LD({search:e,regionKey:n,limit:r,offset:i})}`,{signal:a}))}async function qD({regionKey:e,action:n,limit:r=50,offset:i=0,signal:a}={}){return ID(await t.o(t.x,`${FD}/audit${LD({regionKey:e,action:n,limit:r,offset:i})}`,{signal:a}))}async function JD(e,{signal:n}={}){let r=await t.o(t.x,RD(e,`/detail-defaults`),{signal:n});return r?.data??r??{}}async function YD(e,n,{signal:r}={}){return t.o(t.x,RD(e,`/detail-defaults`),{method:`POST`,body:JSON.stringify(n),signal:r})}async function XD(e,{signal:n}={}){return ID(await t.o(t.x,RD(e,`/users`),{signal:n}))}async function ZD(e,{signal:n}={}){return ID(await t.o(t.x,RD(e,`/roles`),{signal:n}))}var QD=[{value:`regions.read`,label:`Read regions & config`},{value:`config.write`,label:`Write regional config`},{value:`users.read`,label:`Read users across regions`},{value:`users.write`,label:`Move users / memberships`},{value:`access.admin`,label:`Grant & revoke platform access`}];async function $D({signal:e}={}){let n=await t.o(t.x,`${FD}/defaults`,{signal:e}),r=n?.data??n??{};return{regions:r.regions??[],common:r.common??{}}}async function eO(e,{regionKeys:n,signal:r}={}){return t.o(t.x,`${FD}/defaults`,{method:`PUT`,body:JSON.stringify({values:e,regionKeys:n??[]}),signal:r})}var tO=[{name:`phoneCountryCode`,label:`Phone country code`,placeholder:`+1`,emptyMeans:`Print no dial code at all.`},{name:`phoneFormat`,label:`Phone format`,placeholder:`3-3-4`},{name:`dateFormat`,label:`Date format`,placeholder:`DD MMM YYYY`,help:`Calendar dates only — no time, no zone.`},{name:`dateTimeFormat`,label:`Date & time format`,placeholder:`DD MMM YYYY, hh:mm A`},{name:`timeZone`,label:`Time zone`,placeholder:`Asia/Kolkata`,emptyMeans:`Each viewer sees their own browser's zone.`},{name:`booleanTrueLabel`,label:`Yes label`,placeholder:`Yes`},{name:`booleanFalseLabel`,label:`No label`,placeholder:`No`},{name:`emptyPlaceholder`,label:`Empty placeholder`,placeholder:`-`},{name:`separator`,label:`Separator`,placeholder:` · `},{name:`s3BaseUrl`,label:`S3 base URL`,placeholder:`https://…`},{name:`region`,label:`Region profile`,placeholder:`US / UK / IND`,help:`Key into FormGroup.regionRules. Usually set per region, not globally.`}];async function nO({serviceKey:e=`pyOps`,signal:n}={}){let r=await t.o(t.x,`${FD}/ai-services${LD({serviceKey:e})}`,{signal:n}),i=r?.data??r??{};return{serviceKey:i.serviceKey??e,regions:i.regions??[],missingRegions:i.missingRegions??[],consistent:!!i.consistent}}async function rO(e,{regionKeys:n,signal:r}={}){return t.o(t.x,`${FD}/ai-services`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,regionKeys:n??[]}),signal:r})}var{Text:iO}=c.Typography;function aO({regions:e}){let[t,n]=(0,s.useState)(!0),[r,i]=(0,s.useState)(!1),[a,o]=(0,s.useState)([]),[d,f]=(0,s.useState)({}),[p,m]=(0,s.useState)({}),[h,g]=(0,s.useState)([]),_=(0,s.useRef)(null),v=(0,s.useCallback)(async()=>{_.current?.abort();let e=new AbortController;_.current=e,n(!0);try{let{regions:t,common:n}=await $D({signal:e.signal});o(t),f(n),m({})}catch(e){e?.name!==`AbortError`&&c.message.error(e?.message||`Could not load defaults`)}finally{n(!1)}},[]);(0,s.useEffect)(()=>(queueMicrotask(v),()=>_.current?.abort()),[v]);let y=(0,s.useMemo)(()=>(a.length?a:e).map(e=>e.regionKey||e.key),[a,e]),b=h.length?h:y,x=Object.keys(p),S=async()=>{if(!x.length){c.message.info(`Nothing changed`);return}i(!0);try{await eO(p,{regionKeys:h}),c.message.success(`Updated ${x.length} setting${x.length===1?``:`s`} across ${b.length} region${b.length===1?``:`s`}`),await v()}catch(e){c.message.error(e?.message||`Could not save defaults`)}finally{i(!1)}};if(t)return(0,u.jsx)(`div`,{style:{padding:48,textAlign:`center`},children:(0,u.jsx)(c.Spin,{})});if(!y.length)return(0,u.jsx)(c.Empty,{description:`No active regions. Register regions before setting defaults across them.`});let C=[{title:`Setting`,dataIndex:`label`,key:`label`,width:210,render:(e,t)=>(0,u.jsxs)(c.Space,{direction:`vertical`,size:0,children:[(0,u.jsx)(iO,{strong:!0,children:e}),(0,u.jsx)(iO,{type:`secondary`,style:{fontSize:11},children:t.name})]})},...a.map(e=>({title:e.label?.trim()||e.regionKey,key:e.regionKey,width:150,render:(t,n)=>{if(!Object.prototype.hasOwnProperty.call(e.values||{},n.name))return(0,u.jsx)(c.Tooltip,{title:`Never set for this region — it falls back to the built-in default.`,children:(0,u.jsx)(iO,{type:`secondary`,style:{fontSize:12},children:`not set`})});let r=e.values[n.name];return r===``?(0,u.jsx)(c.Tooltip,{title:n.emptyMeans||`Explicitly set to empty.`,children:(0,u.jsx)(c.Tag,{color:`blue`,children:`empty`})}):(0,u.jsx)(iO,{style:{fontSize:12},children:String(r)})}})),{title:`Set for all`,key:`edit`,width:220,render:(e,t)=>{let n=Object.prototype.hasOwnProperty.call(p,t.name);return(0,u.jsxs)(c.Space,{direction:`vertical`,size:2,style:{width:`100%`},children:[(0,u.jsx)(c.Input,{size:`small`,placeholder:t.placeholder,value:n?p[t.name]:void 0,status:n?`warning`:void 0,onChange:e=>m(n=>({...n,[t.name]:e.target.value}))}),n&&(0,u.jsxs)(c.Space,{size:4,children:[(0,u.jsx)(c.Button,{size:`small`,type:`link`,style:{padding:0,height:18,fontSize:11},onClick:()=>m(e=>{let n={...e};return delete n[t.name],n}),children:`cancel`}),p[t.name]===``&&t.emptyMeans&&(0,u.jsx)(c.Tooltip,{title:t.emptyMeans,children:(0,u.jsx)(c.Tag,{color:`blue`,style:{fontSize:10,margin:0},children:`will save as empty`})})]})]})}}],w=tO.map(e=>({...e,key:e.name})),T=w.filter(e=>!Object.prototype.hasOwnProperty.call(d,e.name)).length;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Alert,{type:`info`,showIcon:!0,icon:(0,u.jsx)(l.GlobalOutlined,{}),style:{marginBottom:12},message:`These settings are written into every region you select`,description:(0,u.jsxs)(u.Fragment,{children:[`They drive how dates, times, phone numbers and empty values render — in forms, detail views and cards alike. Each region keeps its own copy, so you can still override one afterwards.`,T>0&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`br`,{}),(0,u.jsx)(l.WarningOutlined,{style:{color:`#d46b08`}}),` `,(0,u.jsx)(iO,{strong:!0,children:T}),` of `,w.length,` settings are not currently identical across regions — the columns below show what each one holds.`]})]})}),(0,u.jsxs)(c.Space,{style:{marginBottom:12},wrap:!0,children:[(0,u.jsx)(iO,{strong:!0,children:`Apply to:`}),(0,u.jsx)(c.Checkbox,{checked:h.length===0,onChange:e=>g(e.target.checked?[]:y),children:`All regions`}),h.length>0&&(0,u.jsx)(c.Checkbox.Group,{value:h,onChange:g,options:a.map(e=>({label:e.label?.trim()||e.regionKey,value:e.regionKey}))}),(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:v,children:`Refresh`}),(0,u.jsx)(c.Button,{type:`primary`,loading:r,disabled:!x.length,onClick:S,children:x.length?`Save ${x.length} change${x.length===1?``:`s`} to ${b.length} region${b.length===1?``:`s`}`:`Save`})]}),(0,u.jsx)(c.Table,{size:`small`,rowKey:`name`,columns:C,dataSource:w,pagination:!1,scroll:{x:`max-content`}}),(0,u.jsx)(iO,{type:`secondary`,style:{display:`block`,marginTop:12,fontSize:12},children:`Only the rows you edit are sent. Everything else is left exactly as it is, per region.`})]})}var oO=`/v1/integration-feeds`;function sO(e){return e?.data??e??null}async function cO(){return sO(await t.o(t.O,oO))}async function lO(e,n){return sO(await t.o(t.O,`${oO}/otp/request`,{method:`POST`,body:JSON.stringify({feedKey:e,action:n})}))}var uO={ON:`enable`,OFF:`suspend`};async function dO(e,{importEnabled:n,statusSyncEnabled:r,otp:i,acknowledgeLegacyStopped:a}={}){let o={otp:i};return n!==void 0&&(o.import=n),r!==void 0&&(o.statusSync=r),a&&(o.acknowledgeLegacyStopped=!0),sO(await t.o(t.O,`${oO}/${encodeURIComponent(e)}/switches`,{method:`POST`,body:JSON.stringify(o)}))}var{Text:fO,Paragraph:pO}=c.Typography;function mO(e){if(!e)return`never`;let t=new Date(e);return Number.isNaN(t.getTime())||t.getUTCFullYear()<=1?`never`:t.toLocaleString()}function hO(){let[e,t]=(0,s.useState)([]),[n,r]=(0,s.useState)(``),[i,a]=(0,s.useState)(!0),[o,l]=(0,s.useState)(``),[d,f]=(0,s.useState)(``),p=(0,s.useCallback)(()=>cO().then(e=>{t(e?.feeds||[]),r(e?.database||e?.target?.database||``),l(``)}).catch(e=>l(e?.message||`Could not read the job feeds`)).finally(()=>a(!1)),[]);(0,s.useEffect)(()=>{p()},[p]);let[m,h]=(0,s.useState)(null);async function g(e,n,r,{acknowledgeLegacyStopped:i}={}){let a=`${e.feedKey}:${Object.keys(n)[0]}`;f(a);try{let a=await dO(e.feedKey,{...n,otp:r,acknowledgeLegacyStopped:i}),o=a?.feed;return o&&t(e=>e.map(e=>e.feedKey===o.feedKey?o:e)),a?.message&&c.message.success(a.message),!0}catch(t){if(t?.status===409&&!i)return c.Modal.confirm({title:`The previous importer still looks active`,content:(0,u.jsxs)(c.Space,{direction:`vertical`,children:[(0,u.jsx)(fO,{children:t.message}),(0,u.jsx)(fO,{strong:!0,children:`Turning this on while the old importer is running will import every job twice.`})]}),okText:`It is stopped — turn importing on`,cancelText:`Leave it off`,okButtonProps:{danger:!0},onOk:()=>g(e,n,r,{acknowledgeLegacyStopped:!0})}),!1;throw t}finally{f(``)}}return i?(0,u.jsx)(Z,{title:`Job Feeds`,children:(0,u.jsx)(c.Spin,{})}):(0,u.jsxs)(Z,{title:`Job Feeds`,children:[(0,u.jsxs)(pO,{type:`secondary`,style:{marginBottom:16},children:[`Imports job requisitions from an external system on a schedule, and keeps their statuses in step. Everything else about a feed — the database it writes into, the tenant and client each job gets, the schedules and the credentials — is set up outside this screen and cannot be changed here.`,n?(0,u.jsxs)(u.Fragment,{children:[` Feeds below write into `,(0,u.jsx)(fO,{code:!0,children:n}),`.`]}):null]}),o&&(0,u.jsx)(c.Alert,{type:`error`,showIcon:!0,message:o,style:{marginBottom:16}}),!o&&e.length===0&&(0,u.jsx)(c.Alert,{type:`info`,showIcon:!0,message:`No job feed is set up for this database`,description:`A feed is created by an operator, with its target database and routing already decided. Once one exists, its two switches appear here.`}),(0,u.jsx)(c.Space,{direction:`vertical`,size:16,style:{width:`100%`},children:e.map(e=>(0,u.jsx)(yO,{feed:e,busy:d,onChange:t=>h({feed:e,changes:t})},e.feedKey))}),m&&(0,u.jsx)(zC,{open:!0,title:_O(m.changes),description:vO(m.feed,m.changes,n),confirmLabel:gO(m.changes)?`Turn on`:`Turn off`,danger:gO(m.changes),onRequestOtp:()=>lO(m.feed.feedKey,gO(m.changes)?uO.ON:uO.OFF),onConfirm:e=>g(m.feed,m.changes,e),onVerified:()=>h(null),onCancel:()=>h(null)})]})}function gO(e){return Object.values(e).some(Boolean)}function _O(e){let t=`importEnabled`in e?`importing jobs`:`status updates`;return gO(e)?`Turn on ${t}?`:`Turn off ${t}?`}function vO(e,t,n){let r=n?` in ${n}`:``;return`importEnabled`in t?gO(t)?`"${e.label||e.feedKey}" will start importing job requisitions${r} on its schedule.`:`"${e.label||e.feedKey}" will stop importing. Jobs already imported are left untouched.`:gO(t)?`Status changes from the source will be applied to jobs already imported${r}.`:`Imported jobs will no longer follow status changes from the source.`}function yO({feed:e,busy:t,onChange:n}){let r=e.importEnabled||e.statusSyncEnabled;return(0,u.jsxs)(`div`,{className:`job-feed-switches`,style:{border:`1px solid #f0f0f0`,borderRadius:8,padding:16},children:[(0,u.jsxs)(c.Space,{align:`center`,style:{marginBottom:12},children:[(0,u.jsx)(fO,{strong:!0,style:{fontSize:16},children:e.label||e.feedKey}),r?(0,u.jsx)(c.Tag,{color:`green`,children:`On`}):(0,u.jsx)(c.Tag,{children:`Off`})]}),(0,u.jsxs)(c.Space,{direction:`vertical`,size:12,style:{width:`100%`},children:[(0,u.jsx)(bO,{label:`Import jobs`,hint:`Brings new job requisitions in on their schedule. Last import: ${mO(e.lastImportAt)}.`,checked:!!e.importEnabled,loading:t===`${e.feedKey}:import`,disabled:!!t,onChange:e=>n({importEnabled:e})}),(0,u.jsx)(bO,{label:`Keep statuses in step`,hint:`Applies status changes from the source to jobs already imported. Last sync: ${mO(e.lastStatusSyncAt)}.`,checked:!!e.statusSyncEnabled,loading:t===`${e.feedKey}:statusSync`,disabled:!!t,onChange:e=>n({statusSyncEnabled:e})})]})]})}function bO({label:e,hint:t,checked:n,loading:r,disabled:i,onChange:a}){return(0,u.jsxs)(c.Space,{align:`start`,size:12,children:[(0,u.jsx)(c.Switch,{checked:n,loading:r,disabled:i,onChange:a,"aria-label":e}),(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`div`,{children:(0,u.jsx)(fO,{strong:!0,children:e})}),(0,u.jsx)(fO,{type:`secondary`,style:{fontSize:12},children:t})]})]})}var{Text:xO,Paragraph:SO}=c.Typography;function CO({regions:e=[]}){let[t]=c.Form.useForm(),[n,r]=(0,s.useState)(!0),[i,a]=(0,s.useState)(!1),[o,l]=(0,s.useState)([]),[d,f]=(0,s.useState)([]),[p,m]=(0,s.useState)(!0),[h,g]=(0,s.useState)(``),[_]=(0,s.useState)(`pyOps`),v=(0,s.useRef)(null),y=(0,s.useCallback)(async()=>{v.current?.abort();let e=new AbortController;v.current=e,r(!0),g(``);try{let n=await nO({serviceKey:_,signal:e.signal});l(n.regions),f(n.missingRegions),m(n.consistent);let r=n.regions.find(e=>e.exists);t.setFieldsValue({serviceKey:n.serviceKey,baseUrl:r?.baseUrl??``,authHeader:r?.authHeader??``,enabled:!r||r.enabled})}catch(e){e?.name!==`AbortError`&&g(e?.message||`Failed to load AI services`)}finally{r(!1)}},[t,_]);(0,s.useEffect)(()=>(queueMicrotask(y),()=>v.current?.abort()),[y]);async function b(){let e;try{e=await t.validateFields()}catch{return}a(!0);try{let n={serviceKey:e.serviceKey,baseUrl:e.baseUrl,authHeader:e.authHeader??``,enabled:e.enabled!==!1};e.authValue&&(n.authValue=e.authValue);let r=await rO(n,{regionKeys:[]}),i=r?.data?.regions??r?.regions??[];c.message.success(`Applied to ${i.length||`all`} region${i.length===1?``:`s`}`),t.setFieldsValue({authValue:``}),await y()}catch(e){c.message.error(e?.message||`Could not apply`)}finally{a(!1)}}return(0,u.jsxs)(c.Spin,{spinning:n,children:[h&&(0,u.jsx)(c.Alert,{type:`error`,showIcon:!0,message:h,style:{marginBottom:12}}),!n&&d.length>0&&(0,u.jsx)(c.Alert,{type:`warning`,showIcon:!0,style:{marginBottom:12},message:`${d.length} region${d.length===1?``:`s`} cannot use AI actions`,description:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(SO,{style:{marginBottom:6},children:[(0,u.jsx)(`b`,{children:d.join(`, `)}),` `,d.length===1?`has`:`have`,` no`,` `,(0,u.jsx)(`code`,{children:_}),` registration, so every AI action there fails with “AI service is not configured for this tenant”.`]}),(0,u.jsx)(xO,{type:`secondary`,children:`Apply the settings below to all regions to fix this.`})]})}),!n&&d.length===0&&!p&&(0,u.jsx)(c.Alert,{type:`info`,showIcon:!0,style:{marginBottom:12},message:`Regions disagree`,description:`Every region has the service, but not with the same base URL or enabled state.`}),(0,u.jsx)(c.Card,{size:`small`,title:`Apply ${_} to every region`,style:{marginBottom:16},children:(0,u.jsxs)(c.Form,{form:t,layout:`vertical`,disabled:i,children:[(0,u.jsx)(c.Form.Item,{name:`serviceKey`,label:`Service key`,rules:[{required:!0}],children:(0,u.jsx)(c.Input,{disabled:!0})}),(0,u.jsx)(c.Form.Item,{name:`baseUrl`,label:`Base URL`,rules:[{required:!0,message:`Base URL is required`}],extra:(0,u.jsxs)(u.Fragment,{children:[`The action's endpoint path is appended to this — e.g.`,` `,(0,u.jsx)(`code`,{children:`/v1/parse`}),`. This URL is called by the `,(0,u.jsx)(`b`,{children:`backend`}),`, not the browser, so it must be reachable `,(0,u.jsx)(`b`,{children:`from the API server`}),`. A public URL works only if a reverse-proxy rule forwards it to the Python service`,(0,u.jsx)(`b`,{children:` with the path prefix stripped`}),`; an internal address (`,(0,u.jsx)(`code`,{children:`host:7020`}),`) needs no proxy rule at all.`]}),children:(0,u.jsx)(c.Input,{placeholder:`https://zinnext.com/pyOps`})}),(0,u.jsx)(c.Form.Item,{name:`authHeader`,label:`Auth header`,extra:`Optional, e.g. Authorization or x-api-key.`,children:(0,u.jsx)(c.Input,{placeholder:`x-api-key`})}),(0,u.jsx)(c.Form.Item,{name:`authValue`,label:`Credential`,extra:`Leave blank to keep the stored credential unchanged. It is never displayed.`,children:(0,u.jsx)(c.Input.Password,{placeholder:`unchanged`,autoComplete:`new-password`})}),(0,u.jsx)(c.Form.Item,{name:`enabled`,label:`Enabled`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{})}),(0,u.jsx)(c.Button,{type:`primary`,loading:i,onClick:b,children:`Apply to all regions`})]})}),(0,u.jsx)(c.Table,{size:`small`,rowKey:`regionKey`,columns:[{title:`Region`,dataIndex:`label`,key:`label`,render:(e,t)=>(0,u.jsxs)(c.Space,{size:6,children:[(0,u.jsx)(xO,{strong:!0,children:e||t.regionKey}),(0,u.jsx)(c.Tag,{children:t.regionKey})]})},{title:`Status`,key:`status`,width:150,render:(e,t)=>t.exists?(0,u.jsx)(c.Tag,{color:t.enabled?`green`:`orange`,children:t.enabled?`Configured`:`Disabled`}):(0,u.jsx)(c.Tag,{color:`red`,children:`Not configured`})},{title:`Base URL`,dataIndex:`baseUrl`,key:`baseUrl`,render:e=>e?(0,u.jsx)(`code`,{children:e}):(0,u.jsx)(xO,{type:`secondary`,children:`—`})},{title:`Credential`,key:`auth`,width:120,render:(e,t)=>t.hasAuthValue?(0,u.jsx)(c.Tag,{color:`blue`,children:`Stored`}):(0,u.jsx)(xO,{type:`secondary`,children:`None`})}],dataSource:o,pagination:!1,locale:{emptyText:e.length?`No regions returned`:`No regions configured`}})]})}var{Text:wO,Title:TO}=c.Typography;function EO(){let[e,t]=(0,s.useState)(`regions`),[n,r]=(0,s.useState)([]),[i,a]=(0,s.useState)(!0),[o,d]=(0,s.useState)(null),f=(0,s.useRef)(null),p=(0,s.useCallback)(()=>{f.current?.abort();let e=new AbortController;return f.current=e,e.signal},[]),m=(0,s.useCallback)(async()=>{a(!0),d(null);try{let e=await zD({includeInactive:!0,signal:p()});r(e)}catch(e){if(e?.name===`AbortError`)return;d(e?.message||`Could not load regions`)}finally{a(!1)}},[p]);return(0,s.useEffect)(()=>(queueMicrotask(m),()=>f.current?.abort()),[m]),(0,u.jsxs)(`div`,{style:{padding:`4px 0`},children:[(0,u.jsxs)(c.Space,{align:`start`,style:{width:`100%`,justifyContent:`space-between`,marginBottom:12},children:[(0,u.jsxs)(`div`,{children:[(0,u.jsxs)(TO,{level:4,style:{margin:0},children:[(0,u.jsx)(l.SafetyCertificateOutlined,{}),` Platform`]}),(0,u.jsx)(wO,{type:`secondary`,children:`Cross-region administration. Every action here is authorised server-side and recorded in the audit trail.`})]}),(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:m,children:`Refresh`})]}),o&&(0,u.jsx)(c.Alert,{type:`error`,showIcon:!0,style:{marginBottom:12},message:`Could not load platform data`,description:(0,u.jsxs)(u.Fragment,{children:[o,(0,u.jsx)(`br`,{}),(0,u.jsx)(wO,{type:`secondary`,children:`If this reads as a permission failure, your platform access may have been revoked, or your session may predate it — sign out and back in, then try again.`})]})}),(0,u.jsx)(c.Tabs,{activeKey:e,onChange:e=>{f.current?.abort(),t(e)},items:[{key:`regions`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.GlobalOutlined,{}),` Regions`]}),children:(0,u.jsx)(DO,{regions:n,loading:i,onChanged:m})},{key:`defaults`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.SettingOutlined,{}),` Global Defaults`]}),children:(0,u.jsx)(aO,{regions:n})},{key:`ai-services`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.ApiOutlined,{}),` AI Services`]}),children:(0,u.jsx)(CO,{regions:n})},{key:`users`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.TeamOutlined,{}),` All Users`]}),children:(0,u.jsx)(jO,{regions:n})},{key:`access`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.KeyOutlined,{}),` Access`]}),children:(0,u.jsx)(MO,{})},{key:`job-feeds`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.CloudDownloadOutlined,{}),` Job Feeds`]}),children:(0,u.jsx)(hO,{})},{key:`audit`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.AuditOutlined,{}),` Audit`]}),children:(0,u.jsx)(NO,{regions:n})}]})]})}function DO({regions:e,loading:t,onChanged:n}){let[r,i]=(0,s.useState)(null),[a,o]=(0,s.useState)(null);return t?(0,u.jsx)(`div`,{style:{padding:48,textAlign:`center`},children:(0,u.jsx)(c.Spin,{})}):e.length?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Space,{style:{marginBottom:16},children:(0,u.jsx)(c.Button,{type:`primary`,onClick:()=>i({}),children:`Register region`})}),(0,u.jsx)(c.Row,{gutter:[16,16],children:e.map(e=>(0,u.jsx)(c.Col,{xs:24,md:12,xl:8,children:(0,u.jsx)(c.Card,{size:`small`,title:(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(l.GlobalOutlined,{}),(0,u.jsx)(`span`,{children:e.label?.trim()||e.key}),e.isHome&&(0,u.jsx)(c.Tag,{color:`blue`,children:`Your region`}),!e.isActive&&(0,u.jsx)(c.Tag,{children:`Inactive`})]}),extra:(0,u.jsx)(c.Tag,{color:`default`,children:e.key}),actions:[(0,u.jsx)(c.Button,{type:`link`,onClick:()=>i(e),children:`Edit`},`edit`),(0,u.jsx)(c.Button,{type:`link`,icon:(0,u.jsx)(l.SettingOutlined,{}),onClick:()=>o(e),children:`Display defaults`},`defaults`)],children:(0,u.jsxs)(c.Space,{direction:`vertical`,size:4,style:{width:`100%`},children:[(0,u.jsxs)(c.Row,{children:[(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(wO,{type:`secondary`,children:`Organization`})}),(0,u.jsx)(c.Col,{span:12,children:e.organizationName?.trim()?(0,u.jsx)(wO,{strong:!0,children:e.organizationName}):(0,u.jsx)(c.Tooltip,{title:`Not set: this region's users see Zinnext in the header.`,children:(0,u.jsx)(wO,{type:`secondary`,children:`Zinnext (default)`})})})]}),(0,u.jsxs)(c.Row,{children:[(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(wO,{type:`secondary`,children:`Users`})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(wO,{strong:!0,children:e.userCount??`—`})})]}),(0,u.jsxs)(c.Row,{children:[(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(wO,{type:`secondary`,children:`Region profile`})}),(0,u.jsx)(c.Col,{span:12,children:e.regionProfile?(0,u.jsx)(c.Tag,{color:`geekblue`,children:e.regionProfile}):(0,u.jsx)(c.Tooltip,{title:`No per-region rule overrides apply (FormGroup.regionRules is not used for this region).`,children:(0,u.jsx)(wO,{type:`secondary`,children:`none`})})})]}),(0,u.jsxs)(c.Row,{children:[(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(wO,{type:`secondary`,children:`Display defaults`})}),(0,u.jsx)(c.Col,{span:12,children:e.hasDisplayDefaults?(0,u.jsx)(c.Badge,{status:`success`,text:`configured`}):(0,u.jsx)(c.Tooltip,{title:`This region has no display-defaults document, so it falls back to the built-in formats.`,children:(0,u.jsx)(c.Badge,{status:`warning`,text:`not set`})})})]}),(0,u.jsx)(wO,{type:`secondary`,style:{fontSize:11,wordBreak:`break-all`},children:e.tenantId})]})})},e.key))}),(0,u.jsx)(OO,{region:r,onClose:()=>i(null),onSaved:n}),(0,u.jsx)(AO,{region:a,onClose:()=>o(null)})]}):(0,u.jsxs)(c.Empty,{description:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`div`,{children:`No regions registered yet.`}),(0,u.jsx)(wO,{type:`secondary`,children:`A region binds a name to one tenant / business / business-unit triple. Until one exists, nothing can be administered across regions.`})]}),children:[(0,u.jsx)(c.Button,{type:`primary`,onClick:()=>i({}),children:`Register the first region`}),(0,u.jsx)(OO,{region:r,onClose:()=>i(null),onSaved:n})]})}function OO({region:e,onClose:t,onSaved:n}){let[r]=c.Form.useForm(),[i,a]=(0,s.useState)(!1),o=e&&!e.key;if((0,s.useEffect)(()=>{e&&queueMicrotask(()=>r.setFieldsValue({isActive:!0,order:0,...e}))},[e,r]),!e)return null;let l=async(e=!1)=>{let i=await r.validateFields();a(!0);try{await BD(i,{allowEmpty:e}),c.message.success(`Region saved`),n?.(),t()}catch(e){String(e?.message||``).includes(`no users exist`)?c.Modal.confirm({title:`No users found for that tenant scope`,content:`Nothing in this database matches that tenant / business / business-unit triple. That usually means one of the ids has a typo — two live tenants already differ by a single character. Register it anyway only if the region is genuinely empty.`,okText:`Register anyway`,okButtonProps:{danger:!0},cancelText:`Let me check the ids`,onOk:()=>l(!0)}):c.message.error(e?.message||`Could not save region`)}finally{a(!1)}};return(0,u.jsxs)(c.Drawer,{open:!0,width:520,onClose:t,title:o?`Register region`:`Edit ${e.label||e.key}`,extra:(0,u.jsx)(c.Button,{type:`primary`,loading:i,onClick:()=>l(!1),children:`Save`}),children:[(0,u.jsx)(c.Alert,{type:`info`,showIcon:!0,style:{marginBottom:16},message:`A region is a name for a tenant scope`,description:`It does not create or move data. It binds a stable key to an existing tenant / business / business-unit triple so that key can be used in URLs and audit records.`}),(0,u.jsxs)(c.Form,{form:r,layout:`vertical`,children:[(0,u.jsx)(c.Form.Item,{name:`key`,label:`Region key`,tooltip:`The identifier. It appears in URLs and audit rows, so it never changes once used. Lower-case, no spaces.`,rules:[{required:!0,message:`A region key is required`},{pattern:/^[a-z0-9][a-z0-9-]*$/,message:`Lower-case letters, digits and hyphens only`}],children:(0,u.jsx)(c.Input,{placeholder:`us`,disabled:!o})}),(0,u.jsx)(c.Form.Item,{name:`label`,label:`Display name`,rules:[{required:!0,message:`A display name is required`}],children:(0,u.jsx)(c.Input,{placeholder:`United States`})}),(0,u.jsx)(c.Form.Item,{name:`organizationName`,label:`Organization name`,tooltip:`Shown in the application header for this region's users (after they sign in). Leave blank to show Zinnext.`,rules:[{max:120,message:`At most 120 characters`}],children:(0,u.jsx)(c.Input,{placeholder:`Zinnext`,allowClear:!0})}),(0,u.jsx)(c.Form.Item,{name:`tenantId`,label:`Tenant ID`,rules:[{required:!0,len:24,message:`24-character ObjectId`}],children:(0,u.jsx)(c.Input,{placeholder:`24-character ObjectId`,disabled:!o})}),(0,u.jsx)(c.Form.Item,{name:`businessId`,label:`Business ID`,rules:[{required:!0,len:24,message:`24-character ObjectId`}],children:(0,u.jsx)(c.Input,{disabled:!o})}),(0,u.jsx)(c.Form.Item,{name:`businessUnitId`,label:`Business Unit ID`,rules:[{required:!0,len:24,message:`24-character ObjectId`}],children:(0,u.jsx)(c.Input,{disabled:!o})}),(0,u.jsx)(c.Form.Item,{name:`regionProfile`,label:`Region profile`,tooltip:`Selects which FormGroup.regionRules profile applies. Leave blank for none.`,children:(0,u.jsx)(c.Select,{allowClear:!0,placeholder:`none`,options:[{value:`US`},{value:`UK`},{value:`IND`}]})}),(0,u.jsx)(c.Form.Item,{name:`order`,label:`Display order`,children:(0,u.jsx)(c.InputNumber,{min:0,style:{width:`100%`}})}),(0,u.jsx)(c.Form.Item,{name:`isActive`,label:`Active`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{})})]}),!o&&(0,u.jsx)(c.Button,{danger:!0,block:!0,onClick:()=>c.Modal.confirm({title:`Deactivate ${e.label||e.key}?`,content:`It stops being selectable and stops resolving. The record is kept so historical audit rows still make sense.`,okText:`Deactivate`,okButtonProps:{danger:!0},onOk:async()=>{await VD(e.key),c.message.success(`Region deactivated`),n?.(),t()}}),children:`Deactivate region`})]})}var kO=[{name:`phoneCountryCode`,label:`Phone country code`,placeholder:`+1`,help:`Empty means print no dial code at all. That is a real setting, not a blank.`},{name:`phoneFormat`,label:`Phone format`,placeholder:`(###) ###-####`},{name:`dateFormat`,label:`Date format`,placeholder:`DD MMM YYYY`,help:`Calendar dates only — no time, no zone.`},{name:`dateTimeFormat`,label:`Date & time format`,placeholder:`DD MMM YYYY, hh:mm A`},{name:`timeZone`,label:`Time zone`,placeholder:`Asia/Kolkata`,help:`IANA name. Empty means each viewer sees their own zone.`},{name:`booleanTrueLabel`,label:`Yes label`,placeholder:`Yes`},{name:`booleanFalseLabel`,label:`No label`,placeholder:`No`},{name:`emptyPlaceholder`,label:`Empty placeholder`,placeholder:`-`},{name:`separator`,label:`Separator`,placeholder:` · `}];function AO({region:e,onClose:t}){let[n]=c.Form.useForm(),[r,i]=(0,s.useState)(!1),[a,o]=(0,s.useState)(!1),d=(0,s.useRef)(null);return(0,s.useEffect)(()=>{if(!e)return;d.current?.abort();let t=new AbortController;return d.current=t,queueMicrotask(()=>{i(!0),JD(e.key,{signal:t.signal}).then(e=>n.setFieldsValue(e||{})).catch(e=>{e?.name!==`AbortError`&&c.message.error(e?.message||`Could not load defaults`)}).finally(()=>i(!1))}),()=>t.abort()},[e,n]),e?(0,u.jsxs)(c.Drawer,{open:!0,width:560,onClose:t,title:(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(l.SettingOutlined,{}),`Display defaults — `,e.label||e.key]}),extra:(0,u.jsx)(c.Button,{type:`primary`,loading:a,onClick:async()=>{let r=await n.validateFields();o(!0);try{await YD(e.key,r),c.message.success(`Display defaults saved for ${e.label||e.key}`),t()}catch(e){c.message.error(e?.message||`Could not save defaults`)}finally{o(!1)}},children:`Save`}),children:[(0,u.jsx)(c.Alert,{type:`warning`,showIcon:!0,style:{marginBottom:16},message:`These apply to this region only`,description:`Everyone in ${e.label||e.key} will see dates, times and phone numbers rendered with these settings. Other regions are unaffected.`}),(0,u.jsx)(c.Spin,{spinning:r,children:(0,u.jsx)(c.Form,{form:n,layout:`vertical`,children:kO.map(e=>(0,u.jsx)(c.Form.Item,{name:e.name,label:e.label,extra:e.help,children:(0,u.jsx)(c.Input,{placeholder:e.placeholder,allowClear:!0})},e.name))})})]}):null}function jO({regions:e}){let[t,n]=(0,s.useState)([]),[r,i]=(0,s.useState)(0),[a,o]=(0,s.useState)(!1),[l,d]=(0,s.useState)(``),[f,p]=(0,s.useState)(),[m,h]=(0,s.useState)(1),g=(0,s.useRef)(null),_=(0,s.useCallback)(async()=>{g.current?.abort();let e=new AbortController;g.current=e,o(!0);try{let{items:t,total:r}=await KD({search:l,regionKey:f,limit:25,offset:(m-1)*25,signal:e.signal});n(t),i(r)}catch(e){e?.name!==`AbortError`&&c.message.error(e?.message||`Could not load users`)}finally{o(!1)}},[l,f,m]);(0,s.useEffect)(()=>(queueMicrotask(_),()=>g.current?.abort()),[_]);let v=(0,s.useMemo)(()=>e.map(e=>({value:e.key,label:e.label?.trim()||e.key})),[e]);return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(c.Space,{style:{marginBottom:16},wrap:!0,children:[(0,u.jsx)(c.Input.Search,{allowClear:!0,placeholder:`Search name or email`,style:{width:280},onSearch:e=>{h(1),d(e)}}),(0,u.jsx)(c.Select,{allowClear:!0,placeholder:`All regions`,style:{width:200},options:v,onChange:e=>{h(1),p(e)}})]}),(0,u.jsx)(c.Alert,{type:`info`,showIcon:!0,style:{marginBottom:12},message:`Only users in registered regions appear here`,description:`A tenant scope that is not registered as a region is deliberately excluded, so orphaned or mistyped tenants are not exposed through this screen.`}),(0,u.jsx)(c.Table,{rowKey:e=>e._id||e.email,size:`small`,loading:a,columns:[{title:`Email`,dataIndex:`email`,key:`email`},{title:`Name`,key:`name`,render:(e,t)=>t.userName||[t.firstName,t.lastName].filter(Boolean).join(` `)||`—`},{title:`Region`,key:`region`,render:(e,t)=>t.regionKey?(0,u.jsx)(c.Tag,{color:`blue`,children:t.regionLabel||t.regionKey}):(0,u.jsx)(c.Tooltip,{title:`This user's tenant scope is not registered as a region.`,children:(0,u.jsx)(c.Tag,{children:`unregistered`})})},{title:`Role ID`,dataIndex:`roleId`,key:`roleId`,width:90}],dataSource:t,pagination:{current:m,pageSize:25,total:r,showSizeChanger:!1,onChange:h,showTotal:e=>`${e} user${e===1?``:`s`}`}})]})}function MO(){let[e,t]=(0,s.useState)([]),[n,r]=(0,s.useState)(!1),[i,a]=(0,s.useState)(!1),[o]=c.Form.useForm(),d=(0,s.useCallback)(async()=>{r(!0);try{t(await HD())}catch(e){c.message.error(e?.message||`Could not load platform access`)}finally{r(!1)}},[]);return(0,s.useEffect)(()=>{queueMicrotask(d)},[d]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Alert,{type:`warning`,showIcon:!0,style:{marginBottom:16},message:`Platform access spans every region`,description:`Grant it to as few people as possible, and prefer a time-boxed grant. Access is verified on every request, so revoking takes effect immediately rather than when a token expires.`}),(0,u.jsxs)(c.Space,{style:{marginBottom:16},children:[(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.ApiOutlined,{}),onClick:()=>a(!0),children:`Grant access`}),(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:d,children:`Refresh`})]}),(0,u.jsx)(c.Table,{rowKey:e=>e.userId,size:`small`,loading:n,columns:[{title:`Email`,dataIndex:`email`,key:`email`},{title:`Status`,key:`status`,render:(e,t)=>t.isActive?(0,u.jsx)(c.Badge,{status:`success`,text:`Active`}):(0,u.jsx)(c.Badge,{status:`default`,text:`Revoked`})},{title:`Scopes`,dataIndex:`scopes`,key:`scopes`,render:e=>(e||[]).map(e=>(0,u.jsx)(c.Tag,{children:e},e))},{title:``,key:`actions`,width:100,render:(e,t)=>t.isActive&&(0,u.jsx)(c.Button,{danger:!0,type:`link`,onClick:()=>c.Modal.confirm({title:`Revoke platform access for ${t.email}?`,content:`They keep their ordinary account and their own region. Cross-region administration stops working on their next request — not when their session expires.`,okText:`Revoke`,okButtonProps:{danger:!0},onOk:async()=>{try{await WD(t.userId),c.message.success(`Access revoked`),d()}catch(e){c.message.error(e?.message||`Could not revoke`)}}}),children:`Revoke`})}],dataSource:e}),(0,u.jsxs)(c.Modal,{open:i,title:(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(l.UserOutlined,{}),`Grant platform access`]}),onCancel:()=>a(!1),okText:`Grant`,onOk:async()=>{let e=await o.validateFields();try{await UD(e),c.message.success(`Platform access granted`),a(!1),o.resetFields(),d()}catch(e){c.message.error(e?.message||`Could not grant access`)}},children:[(0,u.jsx)(c.Alert,{type:`info`,showIcon:!0,style:{marginBottom:16},message:`This grants authority to an existing account`,description:`No password is created or changed here. The user must sign out and back in before it takes effect, because platform authority is keyed to an identifier older sessions do not carry.`}),(0,u.jsxs)(c.Form,{form:o,layout:`vertical`,children:[(0,u.jsx)(c.Form.Item,{name:`userId`,label:`User ID`,tooltip:`The user's stable Mongo _id — not their email and not a legacy numeric id. Copy it from the All Users tab.`,rules:[{required:!0,len:24,message:`A 24-character user _id is required`}],children:(0,u.jsx)(c.Input,{placeholder:`24-character ObjectId`})}),(0,u.jsx)(c.Form.Item,{name:`scopes`,label:`Scopes`,rules:[{required:!0,message:`Select at least one scope`}],children:(0,u.jsx)(c.Select,{mode:`multiple`,options:QD,placeholder:`Select scopes`})}),(0,u.jsx)(c.Form.Item,{name:`expiresAt`,label:`Expires`,extra:`Optional. RFC3339, e.g. 2026-12-31T23:59:59Z. Time-boxed access is safer.`,children:(0,u.jsx)(c.Input,{placeholder:`2026-12-31T23:59:59Z`})})]})]})]})}function NO({regions:e}){let[t,n]=(0,s.useState)([]),[r,i]=(0,s.useState)(0),[a,o]=(0,s.useState)(!1),[l,d]=(0,s.useState)(),[f,p]=(0,s.useState)(1);return(0,s.useEffect)(()=>{let e=!1,t=new AbortController;return queueMicrotask(()=>{e||(o(!0),qD({regionKey:l,limit:50,offset:(f-1)*50,signal:t.signal}).then(({items:t,total:r})=>{e||(n(t),i(r))}).catch(e=>{e?.name!==`AbortError`&&c.message.error(e?.message||`Could not load audit`)}).finally(()=>{e||o(!1)}))}),()=>{e=!0,t.abort()}},[l,f]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Space,{style:{marginBottom:16},children:(0,u.jsx)(c.Select,{allowClear:!0,placeholder:`All regions`,style:{width:200},options:e.map(e=>({value:e.key,label:e.label?.trim()||e.key})),onChange:e=>{p(1),d(e)}})}),(0,u.jsx)(c.Table,{rowKey:e=>e._id||`${e.at}-${e.action}`,size:`small`,loading:a,columns:[{title:`When`,dataIndex:`at`,key:`at`,width:190,render:e=>e?new Date(e).toLocaleString():`—`},{title:`Actor`,dataIndex:`actorEmail`,key:`actorEmail`},{title:`Action`,dataIndex:`action`,key:`action`,render:e=>(0,u.jsx)(c.Tag,{children:e})},{title:`Region`,dataIndex:`targetRegion`,key:`targetRegion`,render:e=>e?(0,u.jsx)(c.Tag,{color:`blue`,children:e}):(0,u.jsx)(wO,{type:`secondary`,children:`platform`})},{title:`Route`,dataIndex:`route`,key:`route`,render:e=>(0,u.jsx)(wO,{type:`secondary`,style:{fontSize:12},children:e})}],dataSource:t,pagination:{current:f,pageSize:50,total:r,showSizeChanger:!1,onChange:p}})]})}var{Content:PO,Header:FO,Sider:IO}=c.Layout,{Text:LO,Title:RO}=c.Typography;function zO(e){return String(e??``).trim().replace(/[\s_-]+/g,` `).toUpperCase()}function BO(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function VO(e){return String(e||``).trim().toLowerCase()}function HO(e){return e?.key||e?.collectionName||e?.value||``}function UO(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=HO(e);if(!t)return;let o=VO(e.key||t),s=VO(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||BO(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=VO(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:BO(t),value:t,disabled:!1}))}),n}function WO(e){return zO(e?.user_type_name??e?.userTypeName??e?.name)===`SUPER ADMIN`}function GO(e){return`${e?.first_name??e?.firstName??``} ${e?.last_name??e?.lastName??``}`.trim()||e?.username||e?.userName||e?.email||`User ${e?.user_id??e?.userId??``}`}function KO(e){let t=new Set;return e.reduce((e,n)=>{let r=GO(n),i=n?.user_id??n?.userId,a=String(r).trim().toLowerCase()||String(i??``);return t.has(a)?e:(t.add(a),e.push({label:r,value:i}),e)},[])}function qO(e){return e.flatMap(e=>{let t=e.menu_id??e.menuId??e.MenuID,n=e.menu_name??e.menuName??e.MenuName??`Menu ${t??``}`,r=e.menu_key??e.menuKey??e.MenuKey??``,i=e.permissions??e.Permissions??{};return Object.entries(i).map(([e,i])=>{let a=i.permission_id??i.permissionId??i.PermissionID,o=i.permission_key??i.permissionKey??i.PermissionKey??e,s=i.value??i.Value??i.access_value??i.accessValue??i;return{key:`${r??n??t}:${a??o}`,menuId:t,menuName:n,menuKey:r,permissionId:a,permissionKey:o,accessValue:+(Number(s)===1)}})})}function JO(e){return String(e.menuKey??e.menuName??e.menuId).trim().toLowerCase()}var YO=[{permissionId:null,permissionKey:`my_jobs`,permissionName:`My Jobs`},{permissionId:null,permissionKey:`all_jobs`,permissionName:`All Jobs`},{permissionId:null,permissionKey:`sendApprove`,permissionName:`Send Approve`}];function XO(e){let t=Array.isArray(e)?e:e?.permissions??e?.actions??e?.data??e,n=(Array.isArray(t)?t:Object.values(t??{})).map(e=>({permissionId:e.permission_id??e.permissionId??e.legacyPermissionId??e.id??null,permissionKey:e.permission_key??e.permissionKey??e.key,permissionName:e.permission_name??e.permissionName??e.name??e.label})).filter(e=>e.permissionKey),r=new Set(n.map(e=>String(e.permissionKey).trim().toLowerCase()));return YO.forEach(e=>{r.has(e.permissionKey.toLowerCase())||n.push(e)}),n}function ZO(e={}){return String(e.permissionName??``).trim()||String(e.permissionKey??``).replaceAll(`_`,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/\b\w/g,e=>e.toUpperCase())}function QO({title:e,description:t,selectedName:n,loading:r,saving:i,rows:a,onChange:o,onMove:s,onSave:d}){let f=Object.values(a.reduce((e,t)=>{let n=JO(t);return e[n]||(e[n]={key:n,menuName:t.menuName,menuKey:t.menuKey,permissions:[]}),e[n].permissions.push(t),e},{}));return(0,u.jsxs)(`section`,{className:`admin-editor`,children:[(0,u.jsxs)(`div`,{className:`admin-section-head`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(RO,{level:4,children:e}),(0,u.jsx)(LO,{type:`secondary`,children:n||t})]}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.SaveOutlined,{}),loading:i,disabled:!n||a.length===0,onClick:d,children:`Save`})]}),r?(0,u.jsx)(`div`,{className:`admin-loading`,children:(0,u.jsx)(c.Spin,{})}):f.length?(0,u.jsx)(c.Table,{size:`small`,rowKey:`key`,columns:[{title:`Menu`,dataIndex:`menuName`,width:220,render:(e,t)=>(0,u.jsxs)(`div`,{className:`admin-menu-order-cell`,children:[(0,u.jsxs)(`div`,{className:`admin-menu-cell`,children:[(0,u.jsx)(`span`,{children:e}),(0,u.jsx)(LO,{type:`secondary`,children:t.menuKey})]}),(0,u.jsxs)(c.Space,{size:2,children:[(0,u.jsx)(c.Button,{size:`small`,type:`text`,icon:(0,u.jsx)(l.ArrowUpOutlined,{}),onClick:()=>s(t.key,-1),"aria-label":`Move ${e} up`}),(0,u.jsx)(c.Button,{size:`small`,type:`text`,icon:(0,u.jsx)(l.ArrowDownOutlined,{}),onClick:()=>s(t.key,1),"aria-label":`Move ${e} down`})]})]})},{title:`Actions`,dataIndex:`permissions`,render:e=>(0,u.jsx)(`div`,{className:`admin-permission-controls`,children:e.filter(e=>wS(e.menuName??e.menuKey,e.permissionKey)).map(e=>(0,u.jsx)(`label`,{className:`admin-permission-control`,children:(0,u.jsx)(c.Checkbox,{checked:e.accessValue===1,onChange:t=>o(e.key,+!!t.target.checked),"aria-label":`${e.menuName} ${e.permissionKey}`,children:ZO(e)})},e.key))})}],dataSource:f,pagination:!1,scroll:{y:420}}):(0,u.jsx)(c.Empty,{description:`Select a record to customize permissions`})]})}function $O({onLogout:e}){let[r]=c.Form.useForm(),[i]=c.Form.useForm(),[a,o]=(0,s.useState)(`users`),[d,f]=(0,s.useState)(!0),[p,m]=(0,s.useState)(!1),[h,g]=(0,s.useState)(!1),[_,v]=(0,s.useState)([]),[y,b]=(0,s.useState)(0),[x,S]=(0,s.useState)(1),[C,w]=(0,s.useState)(10),[T,E]=(0,s.useState)(``),[D,O]=(0,s.useState)(!1),[k,A]=(0,s.useState)([]),[j,M]=(0,s.useState)([]),[N,P]=(0,s.useState)([]),[F,I]=(0,s.useState)(null),[L,R]=(0,s.useState)([]),[z,B]=(0,s.useState)(!1),[V,H]=(0,s.useState)(null),[ee,te]=(0,s.useState)(!1),[ne,re]=(0,s.useState)(null),[ie,ae]=(0,s.useState)([]),[oe,se]=(0,s.useState)(!1),[ce,U]=(0,s.useState)(!1),[W,le]=(0,s.useState)(null),[ue,de]=(0,s.useState)(!1),[G,fe]=(0,s.useState)(null),[pe,me]=(0,s.useState)(`listView`),[he,ge]=(0,s.useState)([]),[_e,K]=(0,s.useState)([]),[q,J]=(0,s.useState)(!1),[ve,ye]=(0,s.useState)(!1),be=t.d(),xe=(0,s.useMemo)(()=>he.filter(e=>!e.disabled),[he]),Se=!q&&xe.length===0,Ce=(0,s.useCallback)(async()=>{J(!0);try{let[e,t]=await Promise.all([n.ri(),n.Yr()]),r=UO(e.modules,t),i=new Set(r.filter(e=>!e.disabled).map(e=>e.value));ge(r),K(e=>e.filter(e=>i.has(e)))}catch{c.message.error(`Failed to load seed status`)}finally{J(!1)}},[]);(0,s.useEffect)(()=>{Ce()},[Ce]);async function we(){if(_e.length===0){c.message.warning(Se?`All modules already seeded.`:`Select at least one module to seed.`);return}ye(!0);try{await n.Li(_e),c.message.success(`User type field config seeded`),K([]),await Ce()}catch(e){c.message.error(e?.message||`Seed failed`)}finally{ye(!1)}}async function Te(){f(!0);try{let[e,t,n]=await Promise.allSettled([fS(),gS(),bS()]),r=e.status===`fulfilled`?e.value:[];e.status===`rejected`&&c.message.error(e.reason?.message||`Unable to load user types`),A(r??[]),M(t.status===`fulfilled`?t.value??[]:[]),P(n.status===`fulfilled`?XO(n.value):[]),I((r??[])[0]?.user_type_id??null)}catch(e){c.message.error(e.message||`Unable to load admin data`)}finally{f(!1)}}(0,s.useEffect)(()=>{queueMicrotask(()=>{Te()})},[]);let Ee=(0,s.useCallback)(async()=>{O(!0);try{let{users:e,total:t}=await sS({limit:C,offset:(x-1)*C,search:T});v(e??[]),b(t??0)}catch(e){c.message.error(e?.message||`Unable to load users`),v([]),b(0)}finally{O(!1)}},[x,C,T]);(0,s.useEffect)(()=>{Ee()},[Ee]),(0,s.useEffect)(()=>{queueMicrotask(()=>{if(!F){R([]);return}m(!0),xS(F).then(e=>{let t=qO(e??[]),n=new Map(t.map(e=>[`${JO(e)}:${String(e.permissionKey).toLowerCase()}`,e.accessValue])),r=j.flatMap(e=>N.map(t=>{let r=String(e.menu_key??e.menu_name??e.menu_id).trim().toLowerCase(),i=String(t.permissionKey).toLowerCase();return{key:`${e.menu_key??e.menu_name??e.menu_id}:${t.permissionId??t.permissionKey}`,menuId:e.menu_id,menuName:e.menu_name,menuKey:e.menu_key,permissionId:t.permissionId,permissionKey:t.permissionKey,accessValue:n.get(`${r}:${i}`)??0}}));R(r)}).catch(e=>c.message.error(e.message||`Unable to load role permissions`)).finally(()=>m(!1))})},[F,j,N]);let De=(0,s.useMemo)(()=>k.find(e=>e.user_type_id===F),[F,k]),Oe=(0,s.useMemo)(()=>k.reduce((e,t)=>({...e,[t.user_type_id]:t.user_type_name}),{}),[k]),ke=(0,s.useMemo)(()=>_.reduce((e,t)=>({...e,[t.user_id]:GO(t)}),{}),[_]),Ae=(0,s.useMemo)(()=>k.filter(e=>!WO(e)),[k]),je=(0,s.useMemo)(()=>_.filter(e=>!WO({user_type_id:e.user_type_id,user_type_name:Oe[e.user_type_id]})),[Oe,_]);(0,s.useEffect)(()=>{if(!z){ae([]);return}let e=Number(r.getFieldValue(`user_type_id`)??0);if(!e){ae([]);return}let t=!1;return se(!0),cS(e).then(e=>{t||ae(e.filter(e=>!V||e.user_id!==V.user_id))}).catch(e=>{t||(c.message.error(e.message||`Unable to load reporting users`),ae([]))}).finally(()=>{t||se(!1)}),()=>{t=!0}},[V,r,z]);let Me=(0,s.useMemo)(()=>{let e=KO(ie),t=Number(V?.reporting_id??V?.reportingId??0);return!t||e.some(e=>Number(e.value)===t)?e:[{label:V?.reportingName??V?.reporting_name??ke[t]??`User ${t}`,value:t},...e]},[V,ie,ke]),Ne=(0,s.useMemo)(()=>{let e=Ae.map(e=>({label:e.user_type_name,value:e.user_type_id}));if(!V)return e;let t=Number(V.user_type_id??0);return e.some(e=>Number(e.value)===t)?e:[{label:Oe[t]??V.userType??V.roleName??(t>0?`Type ${t}`:`Unassigned`),value:t},...e]},[V,Ae,Oe]);k.length,j.length;let Pe=[{key:`form-groups`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.AppstoreAddOutlined,{}),` Form Groups`]}),title:`Form Groups`,description:`Build module add and edit form groups with validations, dropdowns, and custom forms.`,component:(0,u.jsx)(qw,{})},{key:`detail-groups`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.BgColorsOutlined,{}),` Detail Groups`]}),title:`Detail Groups`,description:`Control detail-view labels, rendering, lookups, merged fields, and display defaults.`,component:(0,u.jsx)(kT,{})},{key:`actions`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.ThunderboltOutlined,{}),` Actions`]}),title:`Actions`,description:`Manage row action buttons and their visibility rules from one workspace.`,component:(0,u.jsx)(yE,{})},{key:`templates`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.MailOutlined,{}),` Templates`]}),title:`Templates`,description:`Manage reusable email templates and signatures.`,component:(0,u.jsx)(jE,{})},{key:`ai-services`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.ThunderboltOutlined,{}),` AI Services`]}),title:`AI Services`,description:`Register the AI and automation services used by admin-configured AI actions.`,component:(0,u.jsx)(RE,{})},{key:`bgc-integration`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.SafetyCertificateOutlined,{}),` Integrations`]}),title:`Integrations`,description:`Manage manual and API integrations used across application workflows.`,component:(0,u.jsx)(WE,{})},{key:`automations`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.ApartmentOutlined,{}),` Automations`]}),title:`Automations`,description:`Reference ids, duplicate checks, cross-module snapshots, reporting-chain hierarchy expansion, board updates, notifications, and cache invalidation — per module, config-driven.`,component:(0,u.jsx)(iD,{})},{key:`workflows`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.ApartmentOutlined,{}),` Workflows`]}),title:`Workflows`,description:`Event-driven behavior per module (beforeCreate/afterCreate/…): the metadata the platform Workflow Engine executes — where the jobs, candidates, and submissions create flows live.`,component:(0,u.jsx)(fD,{})},{key:`masters`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.AppstoreAddOutlined,{}),` Masters`]}),title:`Masters`,description:`Shared Location and Tax lists used across modules (e.g. the submission form’s W2 employer section).`,component:(0,u.jsx)(jD,{})}],[Fe,Ie]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=new AbortController;return GD({signal:e.signal}).then(Ie).catch(()=>Ie(!1)),()=>e.abort()},[]);let Le=[...Fe?[{key:`platform`,icon:(0,u.jsx)(l.SafetyCertificateOutlined,{}),label:`Platform`}]:[],{key:`users`,icon:(0,u.jsx)(l.UserOutlined,{}),label:`Users`},{key:`roles`,icon:(0,u.jsx)(l.TeamOutlined,{}),label:`User Types`},{key:`menus`,icon:(0,u.jsx)(l.MenuOutlined,{}),label:`Menus`},{key:`configurations`,icon:(0,u.jsx)(l.AppstoreAddOutlined,{}),label:`Configurations`},{key:`integrations`,icon:(0,u.jsx)(l.SafetyCertificateOutlined,{}),label:`Integrations`}];function Re(e,t){R(n=>n.map(n=>n.key===e?{...n,accessValue:t}:n))}async function ze(){g(!0);try{await SS(F,L.map(e=>({menu_id:e.menuId,menu_name:e.menuName,menu_key:e.menuKey,permission_id:e.permissionId,permission_key:e.permissionKey,access_value:e.accessValue,updated_by:be?.userId??null}))),c.message.success(`Role permissions updated`)}catch(e){c.message.error(e.message||`Unable to save role permissions`)}finally{g(!1)}}function Be(){H(null),r.resetFields(),r.setFieldsValue({status:`ACTIVE`,user_type_id:Ae[0]?.user_type_id,reporting_id:0}),B(!0)}function Ve(e){H(e),r.setFieldsValue({first_name:e.first_name,last_name:e.last_name,username:e.username,email:e.email,mobile:e.mobile,user_type_id:e.user_type_id,reporting_id:e.reporting_id??e.reportingId??0,profile_image:e.profile_image,status:e.status}),B(!0)}async function He(e){te(!0);try{let t={...e,status:e.status===1||e.status===`1`||e.status===!0?`ACTIVE`:e.status===0||e.status===`0`||e.status===!1?`INACTIVE`:String(e.status??`ACTIVE`).toUpperCase(),updated_by:be?.userId??null,created_by:be?.userId??null};t.password||delete t.password,V?(await uS(V.user_id,t),c.message.success(`User updated`)):(await lS(t),c.message.success(`User created`)),B(!1),H(null),await Ee()}catch(e){c.message.error(e.message||`Unable to save user`)}finally{te(!1)}}async function Ue(e){re(e);try{await dS(e),c.message.success(`User deleted`),await Ee()}catch(e){c.message.error(e.message||`Unable to delete user`)}finally{re(null)}}function We(e,t){me(`listView`),fe({kind:e,record:t}),e===`role`&&I(t.user_type_id)}function Y(e,t){R(n=>{let r=[...new Set(n.map(JO))],i=r.indexOf(e),a=i+t;if(i<0||a<0||a>=r.length)return n;[r[i],r[a]]=[r[a],r[i]];let o=new Map(r.map((e,t)=>[e,t]));return[...n].sort((e,t)=>o.get(JO(e))-o.get(JO(t)))})}function Ge(){le(null),i.resetFields(),i.setFieldsValue({status:`ACTIVE`}),U(!0)}function Ke(e){le(e),U(!0),i.setFieldsValue(e)}async function qe(e){de(!0);try{let t=be?.userId??null,n=!!W,r=n?await mS(W.user_type_id,{...e,updated_by:t}):await pS({...e,created_by:t,visible_menu_ids:[]}),i=r.user_type_id;c.message.success(n?`User type updated`:`User type created. Customize its menus and permissions.`),U(!1),await Te(),I(i),n||(me(`permissions`),fe({kind:`role`,record:{...e,...r,user_type_id:i,user_type_name:r.user_type_name??e.user_type_name}}))}catch(e){c.message.error(e.message||`Unable to save role`)}finally{de(!1)}}async function X(e){try{await hS(e),c.message.success(`Role deleted`),await Te()}catch(e){c.message.error(e.message||`Unable to delete role`)}}return(0,u.jsxs)(c.Layout,{className:`admin-shell`,children:[(0,u.jsx)(IO,{width:248,className:`admin-sider`,children:(0,u.jsxs)(`div`,{className:`admin-sidebar-nav`,children:[(0,u.jsx)(LO,{className:`admin-sidebar-title`,children:`Admin Menu`}),(0,u.jsx)(c.Menu,{theme:`dark`,mode:`inline`,selectedKeys:[a],onClick:({key:e})=>o(e),items:Le})]})}),(0,u.jsx)(c.Layout,{children:(0,u.jsxs)(PO,{className:`admin-content`,children:[(0,u.jsx)(u.Fragment,{children:(0,u.jsx)(c.Tabs,{activeKey:a,onChange:o,tabBarStyle:{display:`none`},items:[{key:`users`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.UserOutlined,{}),` Users`]}),children:(0,u.jsx)(`div`,{className:`admin-stack`,children:(0,u.jsxs)(`section`,{className:`admin-section`,children:[(0,u.jsxs)(`div`,{className:`admin-section-head`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(RO,{level:4,children:`Users`}),(0,u.jsx)(LO,{type:`secondary`,children:`Create and manage users with non-super-admin user types.`})]}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:Be,children:`Add`})]}),(0,u.jsx)(kh,{listName:`Users`,loading:D,fields:[{label:`Name`,value:`first_name`,render:(e,t)=>`${e??``} ${t.last_name??``}`.trim()||t.username},{label:`Email`,value:`email`},{label:`User Type`,value:`user_type_id`,width:160,render:(e,t)=>Oe[e]||t?.userType||t?.user_type||(Number(e)>0?`Type ${e}`:`—`)},{label:`Reporting Manager`,value:`reporting_id`,width:180,render:(e,t)=>ke[e]||t?.reportingName||t?.reporting_name||(Number(e)>0?`User ${e}`:`None`)},{label:`Status`,value:`status`,width:110,sorter:!1,render:e=>(0,u.jsx)(c.Tag,{color:e===`ACTIVE`?`green`:`default`,children:e})},{label:`Actions`,value:`_actions`,width:150,sorter:!1,render:(e,t)=>(0,u.jsxs)(c.Space,{size:4,children:[(0,u.jsx)(c.Button,{"aria-label":`Edit user`,icon:(0,u.jsx)(l.EditOutlined,{}),size:`small`,onClick:()=>Ve(t)}),(0,u.jsx)(c.Popconfirm,{title:`Delete user?`,description:`This removes the user from the auth database.`,okText:`Delete`,okButtonProps:{danger:!0},onConfirm:()=>Ue(t.user_id),children:(0,u.jsx)(c.Button,{danger:!0,"aria-label":`Delete user`,icon:(0,u.jsx)(l.DeleteOutlined,{}),loading:ne===t.user_id,size:`small`})})]})}],dataSource:je.map(e=>({...e,key:e.user_id})),total:y,current:x,pageSize:C,onPageChange:S,onPageSizeChange:e=>{w(e),S(1)},onSearch:e=>{E(e??``),S(1)},rowSelection:!1})]})})},{key:`roles`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.TeamOutlined,{}),` User Types`]}),children:(0,u.jsxs)(`div`,{className:`admin-stack`,children:[(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.AppstoreOutlined,{}),title:`Field Config Seed`,style:{marginBottom:12},children:[(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[(0,u.jsx)(`div`,{style:{minWidth:320,flex:1},children:(0,u.jsx)(c.Select,{mode:`multiple`,allowClear:!0,showSearch:!0,value:_e,options:he,placeholder:Se?`All modules already seeded`:`Select modules or collections to seed`,disabled:q||ve||Se,loading:q,onChange:K,style:{width:`100%`}})}),(0,u.jsx)(c.Button,{type:`primary`,loading:ve,disabled:q||_e.length===0,onClick:we,children:`Seed Field Config`})]}),(0,u.jsx)(LO,{type:`secondary`,style:{display:`block`,marginTop:8,fontSize:12},children:Se?`Seed is disabled because all configured modules already have user type field config data.`:`Already seeded modules are disabled. New modules or collections can still be seeded.`})]}),(0,u.jsxs)(`section`,{className:`admin-section`,children:[(0,u.jsxs)(`div`,{className:`admin-section-head`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(RO,{level:4,children:`User Types`}),(0,u.jsx)(LO,{type:`secondary`,children:`Role level permissions are inherited by users.`})]}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:Ge,children:`Add Role`})]}),(0,u.jsx)(kh,{listName:`User Types`,loading:d,fields:[{label:`User Type`,value:`user_type_name`},{label:`Description`,value:`description`},{label:`Status`,value:`status`,width:110,sorter:!1,render:e=>(0,u.jsx)(c.Tag,{color:e===`ACTIVE`?`green`:`default`,children:e})},{label:`Actions`,value:`_actions`,width:260,sorter:!1,render:(e,t)=>{let n=Number(t.role_type)===1;return(0,u.jsxs)(c.Space,{size:4,children:[(0,u.jsx)(c.Button,{"aria-label":`Configure role`,size:`small`,onClick:()=>We(`role`,t),children:`Config`}),(0,u.jsx)(c.Button,{"aria-label":`Edit role`,icon:(0,u.jsx)(l.EditOutlined,{}),size:`small`,onClick:()=>Ke(t)}),n&&!WO(t)&&(0,u.jsx)(c.Popconfirm,{title:`Delete role?`,onConfirm:()=>X(t.user_type_id),children:(0,u.jsx)(c.Button,{"aria-label":`Delete role`,danger:!0,icon:(0,u.jsx)(l.DeleteOutlined,{}),size:`small`})})]})}}],dataSource:k.map(e=>({...e,key:e.user_type_id,roleId:e.user_type_id,roleName:e.user_type_name})),total:k.length,rowSelection:!1})]})]})},{key:`menus`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.MenuOutlined,{}),` Menus`]}),children:(0,u.jsx)(PD,{})},{key:`configurations`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.AppstoreAddOutlined,{}),` Configurations`]}),children:(0,u.jsxs)(`section`,{className:`admin-section admin-config-workspace`,children:[(0,u.jsxs)(`div`,{className:`admin-section-head`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(RO,{level:4,children:`Configuration Center`}),(0,u.jsx)(LO,{type:`secondary`,children:`CORE-THEME admin modules embedded into the admin dashboard.`})]}),(0,u.jsxs)(c.Tag,{color:`blue`,children:[Pe.length,` configurations`]})]}),(0,u.jsx)(c.Tabs,{className:`admin-config-tabs`,defaultActiveKey:`form-groups`,tabPosition:`left`,items:Pe.map(e=>({key:e.key,label:e.label,children:(0,u.jsxs)(`div`,{className:`admin-config-panel`,children:[(0,u.jsx)(`div`,{className:`admin-config-panel-head`,children:(0,u.jsxs)(`div`,{children:[(0,u.jsx)(RO,{level:4,children:e.title}),(0,u.jsx)(LO,{type:`secondary`,children:e.description})]})}),(0,u.jsx)(`div`,{className:`admin-config-panel-body`,children:e.component})]})}))})]})},...Fe?[{key:`platform`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.SafetyCertificateOutlined,{}),` Platform`]}),children:(0,u.jsx)(`section`,{className:`admin-section admin-config-workspace`,children:(0,u.jsx)(EO,{})})}]:[],{key:`integrations`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.SafetyCertificateOutlined,{}),` Integrations`]}),children:(0,u.jsxs)(`section`,{className:`admin-section admin-config-workspace`,children:[(0,u.jsx)(`div`,{className:`admin-section-head`,children:(0,u.jsxs)(`div`,{children:[(0,u.jsx)(RO,{level:4,children:`Integrations`}),(0,u.jsx)(LO,{type:`secondary`,children:`Configure external services used by onboarding and other workflows.`})]})}),(0,u.jsx)(`div`,{className:`admin-config-panel`,children:(0,u.jsx)(`div`,{className:`admin-config-panel-body`,children:(0,u.jsx)(WE,{})})})]})}]})}),(0,u.jsxs)(c.Modal,{className:`uss-modal`,title:`Configure User Type: ${G?.record?.user_type_name??``}`,open:!!G,onCancel:()=>fe(null),footer:null,destroyOnHidden:!0,width:900,children:[(0,u.jsx)(`div`,{className:`uss-config-toggle`,style:{marginBottom:12},children:[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`},{key:`actions`,label:`Actions`}].map(e=>(0,u.jsx)(`button`,{type:`button`,className:`uss-config-btn${pe===e.key?` active`:``}`,onClick:()=>me(e.key),children:e.label},e.key))}),G&&pe===`permissions`?(0,u.jsx)(QO,{title:`Role Permissions`,description:`Configure menu permissions for this user type`,selectedName:De?.user_type_name,loading:p,saving:h,rows:L,onChange:Re,onMove:Y,onSave:ze}):G&&pe===`actions`?(0,u.jsx)(oC,{role:{...G.record,roleId:G.record.user_type_id,roleName:G.record.user_type_name}},`${G.record?.user_type_id}-actions`):G&&pe===`form`?(0,u.jsx)(QS,{role:{...G.record,roleId:G.record.user_type_id,roleName:G.record.user_type_name}},`${G.record?.user_type_id}-form`):G?(0,u.jsx)(VS,{role:{...G.record,roleId:G.record.user_type_id,roleName:G.record.user_type_name},configType:pe},`${G.record?.user_type_id}-${pe}`):null]}),(0,u.jsx)(c.Modal,{className:`admin-role-modal`,title:W?`Edit User Type`:`Create User Type`,open:ce,onCancel:()=>U(!1),onOk:()=>i.submit(),okText:W?`Save`:`Next`,confirmLoading:ue,destroyOnHidden:!0,width:900,children:(0,u.jsxs)(c.Form,{form:i,layout:`vertical`,onFinish:qe,children:[(0,u.jsx)(c.Form.Item,{name:`user_type_name`,label:`Role name`,rules:[{required:!0,message:`Role name is required`}],children:(0,u.jsx)(c.Input,{placeholder:`Recruiter`})}),(0,u.jsx)(c.Form.Item,{name:`description`,label:`Description`,children:(0,u.jsx)(c.Input.TextArea,{rows:3})}),(0,u.jsx)(c.Form.Item,{name:`status`,label:`Status`,extra:W&&Number(W.role_type)!==1?`Built-in user types cannot be deactivated.`:void 0,children:(0,u.jsx)(c.Select,{disabled:!!W&&Number(W.role_type)!==1,options:[{value:`ACTIVE`},{value:`INACTIVE`}]})})]})}),(0,u.jsx)(c.Modal,{className:`admin-user-modal`,title:V?`Edit User`:`Add User`,open:z,onCancel:()=>B(!1),onOk:()=>r.submit(),confirmLoading:ee,destroyOnHidden:!0,children:(0,u.jsxs)(c.Form,{form:r,layout:`vertical`,requiredMark:!1,onFinish:He,children:[(0,u.jsxs)(`div`,{className:`admin-form-row`,children:[(0,u.jsx)(c.Form.Item,{label:`First Name`,name:`first_name`,rules:[{required:!0,message:`First name is required`}],children:(0,u.jsx)(c.Input,{placeholder:`John`})}),(0,u.jsx)(c.Form.Item,{label:`Last Name`,name:`last_name`,children:(0,u.jsx)(c.Input,{placeholder:`Doe`})})]}),(0,u.jsx)(c.Form.Item,{label:`Username`,name:`username`,rules:[{required:!0,message:`Username is required`}],children:(0,u.jsx)(c.Input,{placeholder:`john.doe`})}),(0,u.jsx)(c.Form.Item,{label:`Email`,name:`email`,rules:[{required:!0,message:`Email is required`},{type:`email`,message:`Enter a valid email`}],children:(0,u.jsx)(c.Input,{placeholder:`john@example.com`})}),(0,u.jsx)(c.Form.Item,{label:`Password`,name:`password`,rules:V?[]:[{required:!0,message:`Password is required`}],children:(0,u.jsx)(c.Input.Password,{placeholder:V?`Leave empty to keep current password`:`Password`})}),(0,u.jsxs)(`div`,{className:`admin-form-row`,children:[(0,u.jsx)(c.Form.Item,{label:`Mobile`,name:`mobile`,children:(0,u.jsx)(c.Input,{placeholder:`9999999999`})}),(0,u.jsx)(c.Form.Item,{label:`User Type`,name:`user_type_id`,rules:[{required:!0,message:`User type is required`}],children:(0,u.jsx)(c.Select,{placeholder:`Select user type`,onChange:()=>{ae([]),queueMicrotask(()=>{let e=Number(r.getFieldValue(`user_type_id`)??0);e&&(se(!0),cS(e).then(e=>{ae(e.filter(e=>!V||e.user_id!==V.user_id))}).catch(e=>{c.message.error(e.message||`Unable to load reporting users`),ae([])}).finally(()=>{se(!1)}))})},options:Ne})})]}),(0,u.jsx)(c.Form.Item,{label:`Reporting Manager`,name:`reporting_id`,children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,loading:oe,placeholder:`Select reporting manager`,optionFilterProp:`label`,options:[{label:`None`,value:0},...Me]})}),(0,u.jsx)(c.Form.Item,{label:`Profile Image`,name:`profile_image`,children:(0,u.jsx)(c.Input,{placeholder:`https://...`})}),(0,u.jsx)(c.Form.Item,{label:`Status`,name:`status`,children:(0,u.jsx)(c.Select,{options:[{label:`ACTIVE`,value:`ACTIVE`},{label:`INACTIVE`,value:`INACTIVE`}]})})]})})]})})]})}var ek=$O;function tk(e,t){return String(e||t).replace(/\/\*$/,``).replace(/\/+$/,``)||t}function nk({loginPath:e=`/login`,adminPath:t=`/admin`,fallbackPath:n=`/`}){let r=(0,f.useNavigate)(),i=tk(e,`/login`),a=tk(t,`/admin`),o=`${a}/*`;return(0,u.jsxs)(f.Routes,{children:[(0,u.jsx)(f.Route,{path:i,element:(0,u.jsx)(px,{defaultRedirectPath:a,onLogin:()=>r(a,{replace:!0})})}),(0,u.jsx)(f.Route,{path:o,element:(0,u.jsx)(ix,{loginPath:i,children:(0,u.jsx)(fx,{children:(0,u.jsx)(ek,{onLogout:()=>r(i,{replace:!0})})})})}),(0,u.jsx)(f.Route,{path:n,element:(0,u.jsx)(f.Navigate,{to:a,replace:!0})}),(0,u.jsx)(f.Route,{path:`*`,element:(0,u.jsx)(f.Navigate,{to:a,replace:!0})})]})}function rk(e){return(0,u.jsx)(f.BrowserRouter,{children:(0,u.jsx)(nk,{...e})})}var ik=/[<>]/,ak=/^[^,\s@<>]+@[^,\s@<>]+\.[^\s@<>]{2,}$/,ok=/^\d+@\d+(?:\.[A-Za-z0-9-]+)+$/;function sk(e){return Array.isArray(e)?e.map(String).map(e=>e.trim()).filter(Boolean):String(e??``).split(`,`).map(e=>e.trim()).filter(Boolean)}function ck(e){return Array.isArray(e)?e.some(e=>ik.test(String(e??``))):ik.test(String(e??``))}function lk(e){let t=String(e??``).trim();return!!t&&!ik.test(t)&&!ok.test(t)&&ak.test(t)}function uk(e){return sk(e).filter(e=>!lk(e))}function dk(e){return uk(e).length===0}var{Text:fk}=c.Typography,pk=new Set([`file`,`document`,`attachment`]),mk=`To, CC and BCC cannot contain < or > characters.`,hk=`Add email ID separated by commas`,gk={to:`To Mail`,cc:`Cc`,bcc:`Bcc`};function _k(e){return pk.has(String(e?.type??``).trim().toLowerCase())}function vk(e){return String(e??``).trim().toLowerCase().replace(/[^a-z0-9]/g,``)}function yk(e){return e?typeof e==`string`?e:String(typeof e==`object`?e?._id??e?.id??e?.$oid??``:e):``}function bk(e,t,n){if(!e)return``;let r=vk(t),i=vk(n);if(!r||r===i||r.replace(/s$/,``)===i.replace(/s$/,``))return yk(e?._id??e?.id);let a=r.replace(/s$/,``),o=[`${a}Id`,`${r}Id`,a,r,`${a}._id`,`${r}._id`];for(let t of o){let n=yk(wk(e,t));if(n)return n}return``}async function xk(e){let t=e?.fileUrl??e?.url??e?.downloadUrl;if(!t)return null;let n=await fetch(t);if(!n.ok)throw Error(`Unable to load attachment ${e?.fileName||``}`.trim());let r=await n.blob(),i=e?.fileName??e?.uploadedFileName??e?.uniqueName??`attachment`;return new File([r],i,{type:e?.contentType||r.type||`application/octet-stream`})}async function Sk(e,t,r){if(!t)return[];let i=[];(e?.placeholders??[]).forEach(e=>{(e?.holders??[]).filter(_k).forEach(a=>{let o=bk(t,e?.moduleName,r);o&&i.push((async()=>{let t=await n.Un(e.moduleName,o,a.value);return Promise.all((t?.data??[]).map(xk))})())})});let a=(await Promise.all(i)).flat().filter(Boolean),o=new Set;return a.filter(e=>{let t=`${e.name}:${e.size}:${e.type}`;return!o.has(t)&&(o.add(t),!0)})}function Ck(e,t){return[...new Set([...sk(e),...sk(t)])].join(`, `)}function wk(e,t,n=``){let r=String(n??``).trim().toLowerCase();return String(t??``).split(`.`).reduce((e,t)=>{let n=e;return Array.isArray(n)&&r===`last`&&(n=n.at(-1)),n?.[t]},e)}function Tk(e,t,n){if(!n)return String(e??``);let r=new Map;return(t??[]).forEach(e=>(e.holders??[]).forEach(e=>{r.set(e.key,_k(e)?``:wk(n,e.value,e.arrayMode))})),String(e??``).replace(/{{\.?([\w.]+)}}/g,(e,t)=>{let n=r.get(t);return n==null?e:String(n)})}function Ek(e,t){let n=e;for(;n&&n!==t;){if(n instanceof HTMLElement){let e=window.getComputedStyle(n);if(/(auto|scroll)/.test(e.overflowY)&&n.scrollHeight>n.clientHeight)return n}n=n.parentElement}return t?.querySelector?.(`.mail-popup__body`)??null}function Dk({value:e,onChange:t,defaultTemplateId:r=``,templateApplyKey:i=``,ready:a=!0,title:o=`Mail`,hint:d,bccHint:f,afterBcc:p,beforeFields:m,className:h=``,contextRecords:g=[],moduleName:_=``,requiredTo:v=!1,requiredSubject:y=!1,requiredBody:b=!1}){let x=(0,s.useRef)(``),S=n=>t?.({...e,...n});function C(e){ck(String(e?.nativeEvent?.data??e?.data??``))&&(e.preventDefault(),c.message.warning(mk))}function w(e){ck(String(e?.clipboardData?.getData?.(`text`)??``))&&(e.preventDefault(),c.message.warning(mk))}function T(e,t){if(ck(t)){c.message.warning(mk);return}let n=(Array.isArray(t)?t:sk(t)).map(e=>String(e??``).trim()).filter(Boolean),r=uk(n);if(r.length){let t=gk[e]??`Recipient`,i=r[0];c.message.warning(`${t}: enter a valid email address${i?` (${i})`:``}`),S({[e]:n.filter(lk).join(`, `)});return}S({[e]:n.join(`, `)})}function E(t){let n=uk(e?.[t]);return n.length?`Enter a valid email address: ${n[0]}`:``}function D(t,{placeholder:n=hk,required:r=!1}={}){let i=E(t);return(0,u.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,u.jsx)(c.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`],value:sk(e?.[t]),onChange:e=>T(t,e),onInputKeyDown:e=>{(e.key===`<`||e.key===`>`)&&(e.preventDefault(),c.message.warning(mk))},variant:`borderless`,status:i?`error`:void 0,className:`mail-popup__recipient-select`,style:{width:`100%`},placeholder:n,"aria-required":r,"aria-invalid":!!i}),i&&(0,u.jsx)(fk,{type:`danger`,style:{display:`block`,fontSize:12,lineHeight:1.35,marginTop:2},children:i})]})}function O(e){let t=Ek(e.target,e.currentTarget);if(!t)return;let n=t.scrollHeight-t.clientHeight;if(n<=0)return;let r=Math.max(0,Math.min(n,t.scrollTop+e.deltaY));r!==t.scrollTop&&(t.scrollTop=r),e.preventDefault(),e.stopPropagation()}async function k(t,n=!1){if(t)try{let r=await zT(t),i=g[0],a=await Sk(r,i,_);S({to:Ck(e.to,(r?.toMail??[]).map(e=>Tk(e,r?.placeholders,i))),cc:Ck(e.cc,(r?.ccMail??[]).map(e=>Tk(e,r?.placeholders,i))),bcc:Ck(e.bcc,(r?.bccMail??[]).map(e=>Tk(e,r?.placeholders,i))),subject:Tk(r?.subject,r?.placeholders,i),contents:Tk(r?.body,r?.placeholders,i),attachments:a}),n||c.message.success(`Loaded ${r?.name||`email template`}`)}catch(e){n||c.message.error(e?.message||`Could not load email template`)}}return(0,s.useEffect)(()=>{let e=`${r}::${i}`;!a||!r||x.current===e||(x.current=e,k(r,!0))},[r,i,a]),(0,u.jsxs)(`div`,{className:`common-mail-composer ${h}`.trim(),onWheelCapture:O,children:[(0,u.jsx)(`div`,{className:`mail-popup__header`,children:(0,u.jsxs)(`div`,{className:`mail-popup__header-brand`,children:[(0,u.jsx)(`span`,{className:`dynamic-popup__header-icon-box`,children:(0,u.jsx)(l.MailOutlined,{})}),(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`span`,{className:`dynamic-popup__header-label`,children:o}),d&&(0,u.jsx)(fk,{type:`secondary`,className:`mail-popup__header-hint`,children:d})]})]})}),(0,u.jsxs)(`div`,{className:`mail-popup__body`,children:[m&&(0,u.jsxs)(u.Fragment,{children:[m,(0,u.jsx)(c.Divider,{})]}),(0,u.jsxs)(`div`,{className:`mail-popup__field-row`,onBeforeInputCapture:C,onPasteCapture:w,children:[(0,u.jsxs)(fk,{type:`secondary`,className:`mail-popup__field-label`,children:[`To Mail`,v&&(0,u.jsx)(`span`,{className:`mail-popup__required-mark`,"aria-hidden":`true`,children:`*`})]}),D(`to`,{required:v}),(0,u.jsxs)(`div`,{className:`mail-popup__cc-bcc-actions`,children:[!e.showCc&&(0,u.jsx)(`span`,{className:`mail-popup__cc-bcc-link`,onClick:()=>S({showCc:!0}),children:`Cc`}),!e.showBcc&&(0,u.jsx)(`span`,{className:`mail-popup__cc-bcc-link`,onClick:()=>S({showBcc:!0}),children:`Bcc`})]})]}),(0,u.jsx)(c.Divider,{}),e.showCc&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`mail-popup__field-row`,onBeforeInputCapture:C,onPasteCapture:w,children:[(0,u.jsx)(fk,{type:`secondary`,className:`mail-popup__field-label`,children:`Cc`}),D(`cc`)]}),(0,u.jsx)(c.Divider,{})]}),e.showBcc&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`mail-popup__field-row`,onBeforeInputCapture:C,onPasteCapture:w,children:[(0,u.jsx)(fk,{type:`secondary`,className:`mail-popup__field-label`,children:`Bcc`}),D(`bcc`,{placeholder:f||hk})]}),p,(0,u.jsx)(c.Divider,{})]}),(0,u.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,u.jsxs)(fk,{type:`secondary`,className:`mail-popup__field-label`,children:[`Subject`,y&&(0,u.jsx)(`span`,{className:`mail-popup__required-mark`,"aria-hidden":`true`,children:`*`})]}),(0,u.jsx)(c.Input,{variant:`borderless`,value:e.subject,onChange:e=>S({subject:e.target.value}),placeholder:`Enter subject`,className:`mail-popup__field-input`,"aria-required":y})]}),(0,u.jsx)(c.Divider,{}),!!e.attachments?.length&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,u.jsx)(fk,{type:`secondary`,className:`mail-popup__field-label`,children:`Attachments`}),(0,u.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:6,padding:`4px 0`},children:e.attachments.map((e,t)=>(0,u.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,u.jsx)(l.PaperClipOutlined,{}),e.name]},`${e.name}:${e.size}:${t}`))})]}),(0,u.jsx)(c.Divider,{})]}),(0,u.jsxs)(`div`,{className:`mail-popup__message-section`,children:[(0,u.jsxs)(fk,{type:`secondary`,className:`mail-popup__message-label`,children:[`Body`,b&&(0,u.jsx)(`span`,{className:`mail-popup__required-mark`,"aria-hidden":`true`,children:`*`})]}),(0,u.jsx)(n.Xn,{value:e.contents,onChange:e=>S({contents:e})})]})]})]})}var Ok=new Set([`true`,`1`,`yes`,`y`,`on`]),kk=/^[a-fA-F0-9]{24}$/,Ak=[`email`,`candidateEmail`,`candidate_email`,`emailId`,`mailId`,`alternateEmail`,`altEmail`,`basicDetails.email`,`basicDetails.alternateEmail`,`basicDetails.altEmail`,`candidate.email`,`candidate.emailId`,`submission.email`,`submission.candidateEmail`,`customFields.diceProfileData.email`];function jk(e,t=!1){return e==null||e===``?t:e===!0||e===!1?e:typeof e==`number`?e===1:typeof e==`string`?Ok.has(e.trim().toLowerCase()):t}function Mk(e){return String(e??``).trim().toLowerCase().replace(/[^a-z0-9]/g,``)}function Nk(e){return[`candidate`,`candidates`,`sourcecandidate`,`sourcecandidates`].includes(Mk(e))}function Pk(e,t){if(!(!e||!t))return String(t).split(`.`).reduce((e,t)=>e?.[t],e)}function Fk(e,t={},n={}){let r=Array.isArray(e?.recipientFields)?e.recipientFields:String(e?.recipientFields??``).split(`,`),i=[t.recipientField,t.recipientPath,n.recipientField,n.recipientPath],a=[...r,...i].map(e=>String(e??``).trim()).filter(Boolean);return a.length?[...new Set(a)]:Ak}function Ik(e={}){return[e?.jobId,e?.jobID,e?.job_id,e?.popupContext?.jobId,e?.popupContext?.jobID,e?.popupContext?.job_id].some(e=>{let t=e&&typeof e==`object`?e?._id??e?.id??e?.$oid:e;return kk.test(String(t??``).trim())})}function Lk(e={}){return(jk(e?.forceJobBasedMail)||jk(e?.popupContext?.forceJobBasedMail))&&Ik(e)}function Rk({popupAction:e={},state:t={},moduleName:n=``}={}){let r=e.mailConfig??t.mailConfig,i=Lk(t),a=i||jk(e.requireJobId)||jk(t.requireJobId)||Nk(n);if(!r||typeof r!=`object`)return{configured:!1,forcedJobContext:i,jobBased:a,recipientSource:`selectedRecords`,recipientFields:Fk({},e,t),recipientMode:`allSelected`,removeDuplicateRecipients:!0,jobIdSource:`context`,jobIdField:`jobId`,jobIdReadOnly:i,autoFetchJobContent:!0,requiredTo:!0,requiredJobId:a,requiredSubject:!0,requiredBody:!0};let o=i||jk(r.jobBased,a);return{configured:!0,forcedJobContext:i,jobBased:o,recipientSource:[`selectedRecords`,`manual`].includes(r.recipientSource)?r.recipientSource:`selectedRecords`,recipientFields:Fk(r,e,t),recipientMode:r.recipientMode===`firstSelected`?`firstSelected`:`allSelected`,removeDuplicateRecipients:jk(r.removeDuplicateRecipients,!0),jobIdSource:i?`context`:[`context`,`selectedRecord`,`manual`].includes(r.jobIdSource)?r.jobIdSource:`context`,jobIdField:String(r.jobIdField??`jobId`).trim()||`jobId`,jobIdReadOnly:i||jk(r.jobIdReadOnly,!1),autoFetchJobContent:i||jk(r.autoFetchJobContent,o),requiredTo:jk(r.requiredTo,!0),requiredJobId:i||jk(r.requiredJobId,o),requiredSubject:jk(r.requiredSubject,!0),requiredBody:jk(r.requiredBody,!0)}}function zk(e=[],t=`allSelected`){let n=Array.isArray(e)?e.filter(Boolean):[];return t===`firstSelected`?n.slice(0,1):n}function Bk(e={}){return!e.forcedJobContext&&e.requiredJobId&&!(e.configured&&e.jobBased)}function Vk(e,t={},n=[]){let r=e?.jobIdSource??`context`,i=e?.jobIdField||`jobId`;if(r===`manual`)return``;let a=(e,t=i)=>{let n=[Pk(e,t),t===`jobId`?e?.jobId:void 0,e?.jobId,e?.jobID,e?.job_id,e?.job?._id,e?.job?.id,e?._id,e?.id];for(let e of n){if(e&&typeof e==`object`){let t=e?._id??e?.id??e?.$oid;if(t!=null&&String(t).trim())return String(t)}if(e!=null&&String(e).trim())return String(e)}return``},o=[t,t?.popupContext].filter(Boolean);return(()=>{for(let e of o){let t=a(e);if(t)return t}return``})()||(r===`selectedRecord`?a(n?.[0]):``)}var{Text:Hk}=c.Typography,Uk=/^[a-fA-F0-9]{24}$/,Wk=new Set([`file`,`document`,`attachment`]);function Gk(e){let t=String(e??``);return t.trim()?t.replace(/<br\s*\/?\s*>/gi,` `).replace(/<[^>]*>/g,` `).replace(/ | /gi,` `).replace(/\s+/g,` `).trim().length>0||/<(img|table|hr)\b/i.test(t):!1}async function Kk(e){let t=e?.fileUrl??e?.url??e?.downloadUrl;if(!t)return null;let n=await fetch(t);if(!n.ok)throw Error(`Unable to load attachment ${e?.fileName||``}`.trim());let r=await n.blob(),i=e?.fileName??e?.uploadedFileName??e?.uniqueName??`attachment`;return new File([r],i,{type:e?.contentType||r.type||`application/octet-stream`})}async function qk(e,t,r=[]){let i=String(e??``);if(!i||!r.length||!t)return{contents:i,attachments:[]};let a=(await n.hi(t).catch(()=>[])).filter(e=>Wk.has(String(e?.type??``).trim().toLowerCase())).filter(e=>{let t=String(e?.value??e?.field??e?.fieldKey??e?.key??e?.name??``).replace(/^\./,``);return t&&(i.includes(`{{.${t}}}`)||i.includes(`{{${t}}}`))});if(!a.length)return{contents:i,attachments:[]};let o=[];for(let e of a){let a=String(e?.value??e?.field??e?.fieldKey??e?.key??e?.name??``).replace(/^\./,``);i=i.replaceAll(`{{.${a}}}`,``).replaceAll(`{{${a}}}`,``);for(let e of r){let r=String(e?._id??e?.id??``);if(!Uk.test(r))continue;let i=await n.Un(t,r,a).catch(()=>({data:[]})),s=await Promise.all((i?.data??[]).map(Kk));o.push(...s.filter(Boolean))}}let s=new Set,c=o.filter(e=>{let t=`${e.name}:${e.size}:${e.type}`;return!s.has(t)&&(s.add(t),!0)});return{contents:i,attachments:c}}function Jk(e,...t){for(let n of t){let t=String(n).split(`.`).reduce((e,t)=>e?.[t],e);if(t!=null&&String(t).trim()!==``)return t}}function Yk(e){let t=Jk(e,`jobReferenceId`,`clientJobId`,`jobCode`,`reqId`,`jobId`),n=Jk(e,`jobTitle`,`title`,`name`),r=Jk(e,`jobRecruitmentStatus`,`recruitmentStatus`,`jobStatus`,`status`),i=[t,n].filter(Boolean).join(` - `)||String(Jk(e,`_id`,`id`)??`Job`);return r?`${i} — ${r}`:i}function Xk(e){let t=Jk(e,`_id`,`id`,`jobId`);if(!t)return null;let n=e?.disable===!0||e?.disabled===!0,r=Jk(e,`jobRecruitmentStatus`,`recruitmentStatus`,`jobStatus`,`status`),i=String(e?.message??r??``).trim();return{value:String(t),label:Yk(e),disabled:n,title:n&&i?i:void 0,raw:e}}function Zk(e=[]){let t={...e?.recordMeta??{}},n=(e=[])=>{e.forEach(e=>{!e||typeof e!=`object`||(e.field&&e.value!==void 0&&(t[e.field]=e.value),Array.isArray(e.fields)&&n(e.fields),Array.isArray(e.rows)&&e.rows.forEach(e=>n(e.fields??e)))})};return n(Array.isArray(e)?e:[]),t}async function Qk(e){return Uk.test(String(e??``))?Yk({...Zk(await Xn({module:`jobs`,id:e,view:`detail`})),_id:e}):``}function $k(e=[],t=[]){let n=[...new Set(t.filter(Boolean))];return e.flatMap(e=>n.map(t=>Jk(e,t))).flatMap(e=>Array.isArray(e)?e:[e]).flatMap(sk)}function eA(e){let t=Jk(e,`jobId`,`job_id`,`job._id`,`job.id`,`jobs._id`,`jobs.id`);return typeof t==`object`?Jk(t,`_id`,`id`,`$oid`):t}function tA(e={}){return{subject:e.subject??e.Subject??``,contents:e.contents??e.Contents??e.body??e.Body??``,toMail:e.toMail??e.ToMail??[],ccMail:e.ccMail??e.CcMail??[],bccMail:e.bccMail??e.BccMail??[]}}function nA(e,t=!0){let n=e.flatMap(sk);return(t?[...new Set(n)]:n).join(`, `)}function rA(){let e=(0,f.useNavigate)(),{state:t={}}=(0,f.useLocation)(),{selectedIds:n=[],selectedRecords:r=[],recipients:i=[],subject:a=``,onSend:o,moduleName:l=``,popupAction:d={}}=t,p=(0,s.useMemo)(()=>Rk({popupAction:d,state:t,moduleName:l}),[l,d,t]),m=String(d.defaultTemplateId??t.defaultTemplateId??``).trim(),h=(0,s.useMemo)(()=>zk(r,p.recipientMode),[p.recipientMode,r]),g=(0,s.useMemo)(()=>p.recipientMode===`firstSelected`?n.slice(0,1):n,[p.recipientMode,n]),_=g.join(`|`),v=(0,s.useMemo)(()=>{let e=p.recipientSource===`selectedRecords`?$k(h,p.recipientFields):[];return nA([...i,...e],p.removeDuplicateRecipients)},[p.recipientFields,p.recipientSource,p.removeDuplicateRecipients,h,i]),y=String(Vk(p,t,r)??``).trim(),b=String(eA(r[0])??``).trim(),x=y||(p.configured?``:b),S=n[0]??r[0]?._id??r[0]?.id??``,C=p.jobBased||p.requiredJobId?x:String(x||(p.configured?``:S)||``),w=p.jobIdReadOnly&&p.jobIdSource!==`manual`&&Uk.test(x),T=Bk(p),[E,D]=(0,s.useState)(x),[O,k]=(0,s.useState)(C),[A,j]=(0,s.useState)(``),[M,N]=(0,s.useState)({to:v,cc:``,bcc:``,subject:a,contents:``,attachments:[],showCc:!1,showBcc:!1}),P=p.autoFetchJobContent&&Uk.test(C),[F,I]=(0,s.useState)(!P),[L,R]=(0,s.useState)(!1),[z,B]=(0,s.useState)([]),[V,H]=(0,s.useState)(!1),[ee,te]=(0,s.useState)(!1),ne=(0,s.useRef)(!1),re=(0,s.useRef)(``),ie=(0,s.useRef)(``),ae=(0,s.useRef)(0);(0,s.useEffect)(()=>{if(p.recipientSource!==`selectedRecords`||!Nk(l)||ne.current||sk(M.to).length>0||g.length===0||re.current===_)return;let e=!1;return re.current=_,Sn(g).then(t=>{if(e)return;let n=$k(zk(t,p.recipientMode),p.recipientFields);n.length&&N(e=>sk(e.to).length>0?e:{...e,to:nA(n,p.removeDuplicateRecipients)})}).catch(t=>{e||c.message.error(t?.message||`Could not load candidate emails`)}),()=>{e=!0}},[M.to,p.recipientFields,p.recipientMode,p.recipientSource,p.removeDuplicateRecipients,l,g,_]),(0,s.useEffect)(()=>{if(p.recipientSource!==`selectedRecords`||Nk(l)||!l||ne.current||sk(M.to).length>0||g.length===0||ie.current===_)return;let e=!1;return ie.current=_,Promise.all(g.map(e=>Cn(l,e).catch(()=>null))).then(t=>{if(e)return;let n=$k(t.filter(Boolean),p.recipientFields);n.length&&N(e=>sk(e.to).length>0?e:{...e,to:nA(n,p.removeDuplicateRecipients)})}).catch(t=>{e||c.message.error(t?.message||`Could not load recipient emails`)}),()=>{e=!0}},[M.to,p.recipientFields,p.recipientSource,p.removeDuplicateRecipients,l,g,_]),(0,s.useEffect)(()=>{if(!p.autoFetchJobContent||!O){I(!0),R(!1);return}if(!Uk.test(O)){I(!p.requiredJobId);return}let e=++ae.current,t=!1;async function n(){I(!1),R(!0),N(e=>({...e,contents:``}));try{let[n,i]=await Promise.all([xn(O),w?Qk(O).catch(()=>``):Promise.resolve(``)]),o=tA(n),s=await qk(o.contents||``,l,r),u=s.contents;if(u.trim())try{u=await wn(u,o.subject||a)}catch(n){!t&&e===ae.current&&c.message.warning(n?.message||`Mail content formatting failed. Showing original content.`)}if(t||e!==ae.current)return;i&&j(i),N(e=>({...e,subject:o.subject||e.subject,to:p.configured?e.to:o.toMail?.length?Array.isArray(o.toMail)?o.toMail.join(`, `):String(o.toMail):e.to,cc:o.ccMail?.length?Array.isArray(o.ccMail)?o.ccMail.join(`, `):String(o.ccMail):e.cc,bcc:o.bccMail?.length?Array.isArray(o.bccMail)?o.bccMail.join(`, `):String(o.bccMail):e.bcc,contents:u||s.contents||e.contents,attachments:s.attachments,showCc:e.showCc||!!o.ccMail?.length,showBcc:e.showBcc||!!o.bccMail?.length}))}catch(n){!t&&e===ae.current&&p.requiredJobId&&c.message.error(n?.message||`Could not load mail template for this Job ID`)}finally{!t&&e===ae.current&&(I(!0),R(!1))}}return n(),()=>{t=!0}},[O,p.autoFetchJobContent,p.configured,p.requiredJobId]);function se(e=E){let t=String(e??``).trim();if(!Uk.test(t)){k(``),j(``),t&&c.message.warning(`Enter a valid 24-character Job ID`);return}if(p.autoFetchJobContent&&I(!1),t===O){k(``),queueMicrotask(()=>k(t));return}k(t)}function ce(e,t){if(t?.disabled)return;if(!e){k(``),D(``),j(``);return}let n=t?.label??``;D(String(n||(e??``))),j(n?String(n):``),se(e)}function U(e){let t=String(e??``).trim();if(D(t),t.length<3){B([]);return}H(!0),oe(t).then(e=>{let t=(Array.isArray(e)?e:[]).map(Xk).filter(Boolean);B(t)}).catch(e=>c.message.error(e?.message||`Unable to search jobs`)).finally(()=>H(!1))}let W=sk(M.to).length>0,le=F&&(!p.requiredJobId||Uk.test(O))&&(!p.requiredTo||W)&&dk(M.to)&&dk(M.cc)&&dk(M.bcc)&&(!p.requiredSubject||M.subject.trim().length>0)&&(!p.requiredBody||Gk(M.contents));async function ue(){if(!(!le||ee)){te(!0);try{await Tn({jobId:O,toMail:sk(M.to),ccMail:sk(M.cc),bccMail:sk(M.bcc),subject:M.subject,contents:M.contents,attachments:M.attachments??[]}),c.message.success(`Mail sent successfully`),typeof o==`function`&&o({...M,message:M.contents,selectedIds:n}),e(-1)}catch(e){c.message.error(e?.message||`Failed to send mail`)}finally{te(!1)}}}function de(e){e?.to!==M.to&&(ne.current=!0),N(e)}let G=T?(0,u.jsxs)(`div`,{className:`mail-popup__job-row`,children:[(0,u.jsxs)(Hk,{type:`secondary`,className:`mail-popup__field-label`,children:[`Job ID`,p.requiredJobId&&(0,u.jsx)(`span`,{className:`mail-popup__required-mark`,"aria-hidden":`true`,children:`*`})]}),w?(0,u.jsx)(c.Input,{value:A||O,readOnly:!0,className:`mail-popup__job-input`,"aria-required":p.requiredJobId}):(0,u.jsx)(c.Select,{showSearch:!0,allowClear:!0,filterOption:!1,value:O||void 0,searchValue:E,onSearch:U,onChange:ce,onClear:()=>{k(``),D(``),B([])},placeholder:`Minimum 3 characters`,notFoundContent:V||L?(0,u.jsx)(c.Spin,{size:`small`}):null,options:z,className:`mail-popup__job-input`,"aria-required":p.requiredJobId})]}):null;return(0,u.jsx)(c.Drawer,{open:!0,placement:`right`,onClose:()=>e(-1),closable:!1,rootClassName:`mail-popup`,width:620,maskClosable:!1,footer:(0,u.jsxs)(`div`,{className:`mail-popup__footer`,children:[(0,u.jsx)(c.Button,{onClick:()=>e(-1),children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,loading:ee,disabled:!le,onClick:ue,children:`Send`})]}),children:(0,u.jsx)(c.Spin,{spinning:L,description:`Loading mail content...`,size:`large`,children:(0,u.jsx)(Dk,{value:M,onChange:de,moduleName:l,defaultTemplateId:m,templateApplyKey:p.autoFetchJobContent?O:``,ready:F,contextRecords:r,requiredTo:p.requiredTo,requiredSubject:p.requiredSubject,requiredBody:p.requiredBody,beforeFields:G})})})}var{Text:iA}=c.Typography,aA=e=>e===!0||e===1||e===`1`;function oA(e){return e?e.trim().split(/\s+/).slice(0,2).map(e=>e[0].toUpperCase()).join(``):`?`}function sA(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 cA(e){return e?e.email??e.emailId??e.emailAddress??``:``}function lA(e){return e?e.status?e.status:e.stage?e.stage:typeof e.isActive==`boolean`?e.isActive?`Active`:`Inactive`:``:``}function uA(e,t){let n=String(e?.type??``).trim().toLowerCase(),r=String(e?.renderType??``).trim().toLowerCase(),i=`${e?.field??``} ${e?.label??``}`.toLowerCase();if(!([`file`,`document`,`upload`].includes(n)||[`file`,`document`,`upload`].includes(r)||/resume|cv|document|attachment/i.test(i)))return e;let a=String(e?.field??``).trim().toLowerCase(),o=/resume|cv/.test(i),s=/document|attachment|file|upload/.test(i),c=t.filter(e=>{let t=String(e?.fieldName??e?.field??e?.formField??e?.key??``).trim().toLowerCase(),n=`${t} ${e?.fileName??``} ${e?.name??``}`.toLowerCase();return!!(t&&a&&t===a||t&&a&&(t.includes(a)||a.includes(t))||o&&/resume|cv/.test(n)||s&&(/document|attachment|file|upload|resume|cv/.test(n)||!t))}).map(t=>({name:t?.fileName||t?.name||t?.uploadedFileName||t?.originalName||e?.label||`Document`,url:t?.fileUrl||t?.downloadUrl||t?.signedUrl||t?.url||``,type:t?.mimeType||t?.contentType||t?.type})).filter(e=>e.url);return c.length?{...e,value:c,renderType:`document`}:e}function dA(e){let t=bu(e);return[...e].filter(e=>!aA(e.hideGroup)&&!aA(e.hideGroupInDetail)).filter(e=>xu(e,t)).sort((e,t)=>Number(e.order??0)-Number(t.order??0)).map(e=>({...e,fields:[...e.fields??[]].filter(e=>String(e.field??``).trim()!==``&&(e.show===void 0||aA(e.show))&&xu(e,t)).map(e=>({...e,label:Cu(e,t)})).sort((e,t)=>Number(e.order??0)-Number(t.order??0))})).filter(e=>e.fields.length)}function fA({record:e}){let t=sA(e),n=cA(e),r=lA(e);return!t&&!n?null:(0,u.jsxs)(`div`,{className:`preview-profile-card`,children:[(0,u.jsxs)(`div`,{className:`preview-profile-card__info`,children:[(0,u.jsx)(c.Avatar,{className:`preview-profile-card__avatar`,children:oA(t)}),(0,u.jsxs)(`div`,{className:`preview-profile-card__text`,children:[t&&(0,u.jsx)(`span`,{className:`preview-profile-card__name`,children:t}),n&&(0,u.jsx)(`span`,{className:`preview-profile-card__email`,children:n})]})]}),r&&(0,u.jsx)(c.Tag,{className:`preview-profile-card__status`,children:r})]})}function pA({fields:e,centralDocuments:t=[],recordValueMap:i={}}){let[a,o]=(0,s.useState)([]),[c,l]=(0,s.useState)(0),[d,f]=(0,s.useState)(!1);if(!e?.length)return null;function p(e,t){o(e),l(t),f(!0)}return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`div`,{className:`preview-field-grid`,children:e.map(e=>{let r=uA(e,t),a=r.value,o=r.renderType===`document`?n.in(a).filter(e=>e.url):[];return o.length?(0,u.jsxs)(`div`,{className:`preview-field-card preview-field-card--documents`,children:[(0,u.jsx)(`span`,{className:`preview-field-card__label`,children:r.label}),(0,u.jsx)(`div`,{className:`preview-document-list`,children:o.map((e,t)=>(0,u.jsxs)(`button`,{type:`button`,className:`preview-document-link`,onClick:()=>p(o,t),title:`Preview ${e.name||`document`}`,children:[(0,u.jsx)(`span`,{className:`preview-document-link__name`,children:e.name||`Document ${t+1}`}),(0,u.jsx)(`span`,{className:`preview-document-link__action`,children:`Preview`})]},`${e.url}-${t}`))})]},r.field??r.label):(0,u.jsxs)(`div`,{className:`preview-field-card`,children:[(0,u.jsx)(`span`,{className:`preview-field-card__label`,children:r.label}),(0,u.jsx)(`span`,{className:`preview-field-card__value`,children:(0,u.jsx)(xd,{field:r,record:i})})]},r.field??r.label)})}),(0,u.jsx)(r.t,{documents:a,open:d,onClose:()=>f(!1),initialIndex:c})]})}function mA(){let e=(0,f.useNavigate)(),{moduleName:t=``,record:r=null}=(0,f.useLocation)().state??{},i=r?.id??r?._id,[a,o]=(0,s.useState)([]),[l,d]=(0,s.useState)(!!(t&&i)),[p,m]=(0,s.useState)(null),[h,g]=(0,s.useState)([]),[_,v]=(0,s.useState)(0),y=(0,s.useRef)(null),b=(0,s.useRef)(null),x=(0,s.useRef)([]),S=(0,s.useRef)([]),C=(0,s.useMemo)(()=>dA(a),[a]),w=(0,s.useMemo)(()=>bu(a),[a]);(0,s.useEffect)(()=>{if(!t||!i)return;let e=!1;return Promise.all([Xn({module:t,id:i,view:`detail`}),n.Un(t,i).catch(()=>({data:[]}))]).then(([t,n])=>{e||(o(Array.isArray(t)?t:[]),g(Array.isArray(n)?n:n?.data??[]),d(!1))}).catch(t=>{e||(m(t.message||`Failed to load preview`),g([]),d(!1))}),()=>{e=!0}},[t,i]);function T(){e(-1)}function E(e,t){return e?.label??e?.name??`Section ${t+1}`}function D(e){let t=y.current,n=S.current[e];if(!t||!n)return;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=(t.querySelector(`.preview-stepper-wrap`)?.offsetHeight??0)+12,o=t.scrollTop+i.top-r.top-a;v(e),t.scrollTo({top:Math.max(0,o),behavior:`smooth`})}function O(){let e=y.current;if(!e||!S.current.length)return;let t=e.getBoundingClientRect().top+(e.querySelector(`.preview-stepper-wrap`)?.offsetHeight??0)+24,n=0;S.current.forEach((e,r)=>{e&&e.getBoundingClientRect().top<=t&&(n=r)}),v(e=>e===n?e:n)}(0,s.useEffect)(()=>{let e=b.current,t=x.current[_];if(!e||!t)return;let n=t.offsetLeft-(e.clientWidth-t.offsetWidth)/2,r=Math.max(0,e.scrollWidth-e.clientWidth),i=Math.min(Math.max(0,n),r);typeof e.scrollTo==`function`?e.scrollTo({left:i,behavior:`smooth`}):e.scrollLeft=i},[_,C.length]);function k(){return C.length?(0,u.jsx)(`div`,{ref:b,className:`preview-stepper-wrap`,"aria-label":`Preview sections`,children:(0,u.jsx)(`div`,{className:`preview-stepper`,children:C.map((e,t)=>(0,u.jsxs)(`div`,{className:`preview-stepper__segment`,children:[(0,u.jsxs)(`button`,{type:`button`,className:`preview-stepper__item`,ref:e=>{x.current[t]=e},onClick:()=>D(t),"aria-current":_===t?`step`:void 0,title:`Go to ${E(e,t)}`,children:[(0,u.jsx)(`span`,{className:[`preview-stepper__circle`,t<_?`preview-stepper__circle--done`:``,t===_?`preview-stepper__circle--active`:``].filter(Boolean).join(` `),children:t+1}),(0,u.jsx)(`span`,{className:[`preview-stepper__label`,t===_?`preview-stepper__label--active`:``].filter(Boolean).join(` `),children:E(e,t)})]}),t<C.length-1&&(0,u.jsx)(`span`,{className:[`preview-stepper__line`,t<_?`preview-stepper__line--done`:``].filter(Boolean).join(` `),"aria-hidden":`true`})]},e.name??e.id??t))})}):null}let A=(0,u.jsxs)(`div`,{className:`preview-modal-header`,children:[(0,u.jsx)(`span`,{className:`preview-modal-module`,children:t.toUpperCase()}),(0,u.jsx)(`span`,{className:`preview-modal-title`,children:t?` Details`:`Preview`})]}),j=(0,u.jsx)(`div`,{className:`wizard-footer preview-scroll-footer`,children:(0,u.jsx)(`div`,{className:`wizard-footer-nav`,children:(0,u.jsx)(c.Button,{onClick:T,children:`Close`})})});function M(){return!t||!i?(0,u.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:`Preview id is missing.`}):l?(0,u.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:(0,u.jsx)(c.Spin,{size:`small`})}):p?(0,u.jsx)(`div`,{className:`job-preview-content job-preview-status job-preview-error`,children:p}):C.length?(0,u.jsx)(`div`,{className:`preview-section-list`,children:C.map((e,t)=>(0,u.jsxs)(`section`,{ref:e=>{S.current[t]=e},className:`preview-section-card`,"data-section-index":t,children:[(0,u.jsxs)(`div`,{className:`preview-section-card__header`,children:[(0,u.jsx)(`span`,{className:`preview-section-card__number`,children:t+1}),(0,u.jsx)(`span`,{className:`preview-section-card__title`,children:E(e,t)})]}),(0,u.jsx)(`div`,{className:`preview-section-card__body`,children:e.fields?.length>0?(0,u.jsx)(pA,{fields:e.fields,centralDocuments:h,recordValueMap:w}):(0,u.jsx)(iA,{type:`secondary`,children:`No fields in this group.`})})]},e.name??e.id??t))}):(0,u.jsx)(`div`,{className:`job-preview-content job-preview-status`,children:`No form groups found.`})}return(0,u.jsx)(c.Modal,{centered:!0,className:`wizard-modal preview-modal preview-scroll-modal`,footer:j,open:!0,title:A,width:`min(900px, calc(100vw - 32px))`,onCancel:T,mask:{closable:!1},children:(0,u.jsxs)(`div`,{ref:y,className:`wizard-body preview-scroll-body`,onScroll:O,children:[!l&&!p&&C.length>0&&k(),r&&(0,u.jsx)(fA,{record:r}),M()]})})}var{Text:hA}=c.Typography;function gA({moduleName:e=`candidate`,backPath:t=``}){let n=(0,f.useNavigate)(),r=(0,f.useLocation)(),i=(0,f.useParams)().id,a=!!r.state?.background,[o,d]=(0,s.useState)(null),p=(0,s.useCallback)(()=>{n(a?-1:t||`/${e}s`)},[a,n,t,e]),m=o?.name||o?.fullName||o?.candidateName||[o?.firstName,o?.lastName].filter(Boolean).join(` `)||`Details`,h=(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`baseline`,gap:12,paddingRight:32},children:[(0,u.jsx)(`span`,{style:{fontWeight:600},children:m}),i&&(0,u.jsxs)(f.Link,{to:`/${e}s/detailview/${i}`,style:{fontSize:13,fontWeight:400,whiteSpace:`nowrap`},children:[(0,u.jsx)(l.ExportOutlined,{}),` Open full page`]})]});return(0,u.jsx)(c.Modal,{open:!0,title:h,onCancel:p,footer:null,width:`92vw`,style:{top:24,maxWidth:1400},styles:{body:{maxHeight:`85vh`,overflow:`auto`,padding:0}},destroyOnHidden:!0,children:i?(0,u.jsx)(Yp,{moduleName:e,id:i,onHeaderData:d}):(0,u.jsx)(`div`,{style:{padding:24},children:(0,u.jsx)(hA,{type:`secondary`,children:`No record id.`})})})}gA.propTypes={moduleName:p.default.string,backPath:p.default.string};var{Text:_A}=c.Typography,{TextArea:vA}=c.Input,yA=[{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 bA(e){switch(e.type){case`select`:return(0,u.jsx)(c.Select,{placeholder:e.placeholder,options:e.options,style:{width:`100%`}});case`textarea`:return(0,u.jsx)(vA,{rows:3,placeholder:e.placeholder});case`number`:return(0,u.jsx)(c.InputNumber,{placeholder:e.placeholder,style:{width:`100%`}});default:return(0,u.jsx)(c.Input,{type:e.inputType||`text`,placeholder:e.placeholder})}}function xA({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,u.jsxs)(`div`,{className:`wizard-review-content`,children:[r.map(e=>(0,u.jsxs)(`div`,{className:`wizard-review-section`,children:[(0,u.jsx)(_A,{className:`wizard-review-section-title`,children:e.title}),(0,u.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,u.jsxs)(`div`,{className:`wizard-review-row`,children:[(0,u.jsx)(`span`,{className:`wizard-review-label`,children:e.label}),(0,u.jsx)(`span`,{className:`wizard-review-separator`,children:`:`}),(0,u.jsx)(`span`,{className:`wizard-review-value`,children:r})]},e.name)})})]},e.key)),(0,u.jsxs)(`div`,{className:`wizard-review-confirm-note`,children:[(0,u.jsx)(l.CheckCircleOutlined,{className:`wizard-review-confirm-icon`}),(0,u.jsx)(_A,{type:`secondary`,children:`Please review the information above before submitting.`})]})]}):(0,u.jsx)(`div`,{className:`wizard-review-empty`,children:(0,u.jsx)(_A,{type:`secondary`,children:`No data entered yet.`})})}function SA(){let[e]=c.Form.useForm(),t=(0,f.useNavigate)(),{title:n=`Wizard`,moduleName:r=``,steps:i=yA,onSubmit:a}=(0,f.useLocation)().state??{},[o,l]=(0,s.useState)(0),d=i[o],p=o===i.length-1,m=o===0;function h(){t(-1)}function g(){let t=(d.fields||[]).map(e=>e.name);e.validateFields(t.length>0?t:void 0).then(()=>{l(e=>e+1)})}function _(){l(e=>e-1)}function v(){let n=e.getFieldsValue();typeof a==`function`&&a(n),t(-1)}let y=i.map((e,t)=>({title:e.title,description:e.description,status:t<o?`finish`:t===o?`process`:`wait`})),b=r?`${n} — ${r}`:n;return(0,u.jsxs)(c.Modal,{open:!0,title:b,footer:(0,u.jsxs)(`div`,{className:`wizard-footer`,children:[(0,u.jsx)(c.Button,{onClick:h,children:`Cancel`}),(0,u.jsxs)(`div`,{className:`wizard-footer-nav`,children:[!m&&(0,u.jsx)(c.Button,{onClick:_,children:`Back`}),p?(0,u.jsx)(c.Button,{type:`primary`,onClick:v,children:`Submit`}):(0,u.jsx)(c.Button,{type:`primary`,onClick:g,children:`Next`})]})]}),onCancel:h,width:`min(680px, calc(100vw - 32px))`,centered:!0,className:`wizard-modal`,children:[(0,u.jsx)(`div`,{className:`wizard-steps-container`,children:(0,u.jsx)(c.Steps,{current:o,items:y,size:`small`,className:`wizard-steps`})}),(0,u.jsx)(`div`,{className:`wizard-body`,children:(0,u.jsxs)(c.Form,{form:e,layout:`vertical`,children:[i.filter(e=>!e.isReview).map((e,t)=>(0,u.jsx)(`div`,{style:{display:t===o?`block`:`none`},children:(0,u.jsx)(c.Row,{gutter:16,children:(e.fields||[]).map(e=>(0,u.jsx)(c.Col,{span:e.span||24,children:(0,u.jsx)(c.Form.Item,{name:e.name,label:e.label,rules:[...e.required?[{required:!0,message:`${e.label} is required`}]:[],...e.rules||[]],children:bA(e)})},e.name))})},e.key)),d.isReview&&(0,u.jsx)(xA,{steps:i,form:e})]})})]})}function CA({titleText:e,titleIcon:t}){let n=t===`delete`;return(0,u.jsxs)(`span`,{className:`dynamic-popup__header`,children:[(0,u.jsx)(`span`,{className:`dynamic-popup__header-icon-box${n?` dynamic-popup__header-icon-box--danger`:``}`,children:n?(0,u.jsx)(l.DeleteOutlined,{}):(0,u.jsx)(l.AppstoreOutlined,{})}),(0,u.jsx)(`span`,{className:`dynamic-popup__header-label`,children:e})]})}function wA({note:e,description:t,showSelectedCount:r,count:i,itemLabel:a,bodyText:o,deleteError:s}){return(0,u.jsxs)(u.Fragment,{children:[e&&(0,u.jsx)(n.Zn,{variant:`body`,color:`secondary`,className:`dynamic-popup__note`,children:e}),t&&(0,u.jsx)(n.Zn,{variant:`body`,className:`dynamic-popup__description`,children:t}),r&&i>0&&(0,u.jsxs)(n.Zn,{variant:`body`,className:`dynamic-popup__selected-count`,children:[`Changing status for `,(0,u.jsx)(`strong`,{children:i}),` selected `,a,`.`]}),o&&(0,u.jsx)(n.Zn,{variant:`body`,children:o}),s&&(0,u.jsx)(n.Zn,{variant:`caption`,color:`danger`,className:`dynamic-popup__error`,children:s})]})}function TA({footerNote:e}){return e?(0,u.jsx)(n.Zn,{variant:`caption`,color:`secondary`,className:`dynamic-popup__footer-note`,children:e}):null}function EA(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t?.[n]??``).trim()}function DA(e){return String(e).replace(/\(\s*\)/g,``).replace(/\s+/g,` `).replace(/(^|\s)([-–—·|])(?=\s*\2)/g,``).replace(/^[\s\-–—·|]+/,``).replace(/[\s\-–—·|]+$/,``).trim()}function OA(e){if(!e)return!1;let t=new Date(e).getTime();return Number.isNaN(t)||t<=0?!1:t<=Date.now()+864e5}function kA(e){if(!OA(e))return``;let t=new Date(e),n=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date,i=Math.round((n(r)-n(t))/864e5);if(i<=0)return`Today`;if(i===1)return`Yesterday`;if(i<=30)return`${i} days ago`;let a=(r.getFullYear()-t.getFullYear())*12+(r.getMonth()-t.getMonth());if(r.getDate()<t.getDate()&&--a,a=Math.max(1,a),a<12)return`${a} month${a===1?``:`s`} ago`;let o=Math.floor(a/12);return`${o} year${o===1?``:`s`} ago`}function AA(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 jA(e){let t=Array.isArray(e?.submissionHistory)?e.submissionHistory:[],n=[e?.lastSubmittedAt,e?.submittedAt,...t.map(e=>e?.submittedAt)].filter(Boolean);return n.length?n.reduce((e,t)=>new Date(t)>new Date(e)?t:e):null}function MA(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:kA(AA(e))}:e,o=(i?DA(EA(i,a)):null)||(n?e?.[n]:null)||e?.name||e?.fullName||e?.candidateName||e?.title||e?.displayName||e?.text||e?.applicantReferenceId||e?.applicantRefrenceId||String(Object.values(e||{})[0]??``),s=(r?e?.[r]:null)??e?.id??e?._id??e?.applicantReferenceId??e?.applicantRefrenceId??String(Object.values(e||{})[0]??``),c=e?.disabled===!0||e?.disable===!0,l=String(e?.optionNote??``).trim(),u={label:l?`${String(o)} — ${l}`:String(o),value:String(s),_raw:e};if(c&&(u.disabled=!0),l&&(u.title=l),e?.isSubmitted===!0||e?.alreadySubmitted===!0){u.alreadySubmitted=!0,u.existingSubmissionId=String(e?.existingSubmissionId??e?.jobSubmissionId??e?.submissionId??``);let t=e?.submittedAt||jA(e);t&&(u.submittedAt=t)}if(e?.isFromSubmission===!0&&e?.submissionId){u.isFromSubmission=!0,u.priorSubmissionId=String(e.submissionId);let t=e?.lastSubmittedAt||jA(e);t&&(u.priorSubmittedAt=t)}return u}function NA(e,t){return(t?.[e.optionsKey]??e.defaultOptions??[]).map(t=>MA(t,e))}function PA(e={}){return{selectedIds:[],selectedRecords:[],moduleName:``,removedIds:[],...e}}var FA=`DD MMM YYYY`,IA=`DD MMM YYYY, h:mm A`;function LA(e,t){if(e==null||e===``)return``;let n=(0,d.default)(e);return n.isValid()?t===`relative`?kA(e)||(OA(e)?n.format(FA):`Not updated`):OA(e)?n.format(FA):``:String(e)}function RA(e,t){return e?String(e).includes(`{`)?DA(EA(e,t)):String(t?.[e]??e).trim():``}function zA(e){if(e?.alreadySubmitted){let t=e?.submittedAt?(0,d.default)(e.submittedAt):null;return{tone:`blocked`,tooltip:t?.isValid()?`Already submitted to this job on ${t.format(IA)}`:`Already submitted to this job — a candidate can only be submitted once per job`}}if(e?.isFromSubmission){let t=e?.priorSubmittedAt?(0,d.default)(e.priorSubmittedAt):null;return{tone:`history`,tooltip:t?.isValid()?`Previously submitted on ${t.format(IA)} — this form will prefill from it`:`Submitted to another job before — this form will prefill from it`}}return null}function BA(e,t){return e?.alreadySubmitted||!e?.disabled?``:String(t?.message??e?.title??``).trim()}function VA({meta:e}){return(0,u.jsx)(`div`,{className:`dynamic-popup__option-dates`,children:e.map(e=>(0,u.jsxs)(s.Fragment,{children:[(0,u.jsx)(`span`,{className:`dynamic-popup__option-date-label`,children:e.label}),(0,u.jsx)(`span`,{className:`dynamic-popup__option-date-value`,children:e.text})]},e.label))})}function HA({option:e,layout:t}){let n=e?._raw??e??{},r=RA(t.id,n),i=RA(t.title,n)||String(e?.label??``),a=RA(t.subtitle,n),o=RA(t.titleAccent?.key,n),s=RA(t.titleAccent?.toneKey,n),d=t.titleAccent?.prefix??``,f=(t.meta??[]).map(e=>({label:e.label,text:LA(n?.[e.key],e.type)||e.emptyText||``})).filter(e=>e.text),p=BA(e,n),m=zA(e);return(0,u.jsxs)(`div`,{className:`dynamic-popup__option`,children:[(0,u.jsx)(`span`,{className:`dynamic-popup__option-tick${m?` dynamic-popup__option-tick--${m.tone}`:``}`,children:m&&(0,u.jsx)(c.Tooltip,{title:m.tooltip,placement:`topLeft`,children:(0,u.jsx)(l.CheckCircleFilled,{"aria-label":m.tooltip})})}),(0,u.jsxs)(`div`,{className:`dynamic-popup__option-main`,children:[(0,u.jsxs)(`div`,{className:`dynamic-popup__option-head`,children:[r&&(0,u.jsx)(`span`,{className:`dynamic-popup__option-id`,children:r}),(0,u.jsxs)(`span`,{className:`dynamic-popup__option-title`,children:[(0,u.jsx)(`span`,{className:`dynamic-popup__option-title-text`,children:i}),o&&(0,u.jsx)(`span`,{className:`dynamic-popup__option-title-accent${s?` dynamic-popup__option-title-accent--${s}`:``}`,children:`${d}${o}`})]}),p&&(0,u.jsx)(`span`,{className:`dynamic-popup__option-flag`,children:p})]}),a&&(0,u.jsx)(`div`,{className:`dynamic-popup__option-sub`,children:a})]}),e?.alreadySubmitted?(0,u.jsx)(`span`,{className:`dynamic-popup__option-onjob`,children:`On this job`}):f.length>0&&(0,u.jsx)(VA,{meta:f})]})}var{Text:UA}=c.Typography,{TextArea:WA}=c.Input,GA=[{label:`$`,value:`$`},{label:`EUR`,value:`EUR`},{label:`GBP`,value:`GBP`},{label:`INR`,value:`INR`}],KA=[{label:`Hourly`,value:`Hourly`},{label:`Daily`,value:`Daily`},{label:`Weekly`,value:`Weekly`},{label:`Monthly`,value:`Monthly`},{label:`Yearly`,value:`Yearly`}];function qA(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 JA({field:e,value:t,onChange:n}){return(0,u.jsx)(c.Input,{value:t,onChange:n,placeholder:e.placeholder,maxLength:e.maxLength,prefix:(0,u.jsx)(l.CrownOutlined,{})})}function YA({field:e,value:t,onChange:n}){return(0,u.jsx)(WA,{value:t,onChange:n,rows:e.rows??5,placeholder:e.placeholder})}function XA({field:e,options:t,value:n,onChange:r}){let i=qA(t);return(0,u.jsx)(c.Select,{showSearch:!0,value:n,onChange:r,options:i,placeholder:e.placeholder,className:`dynamic-popup__field-select`,optionFilterProp:`label`,optionRender:QA,prefix:(0,u.jsx)(l.CrownOutlined,{})})}function ZA({field:e,options:t,value:n,onChange:r}){let i=qA(t);return(0,u.jsx)(c.Select,{mode:`multiple`,showSearch:!0,value:n,onChange:r,options:i,placeholder:e.placeholder,className:`dynamic-popup__field-select`,optionFilterProp:`label`,optionRender:QA,prefix:(0,u.jsx)(l.CrownOutlined,{})})}function QA(e){let t=e?.data??e;return!t?.assigned&&!t?.assignedTag?e?.label:(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8},children:[(0,u.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e?.label}),(0,u.jsx)(c.Tag,{color:`default`,style:{marginInlineEnd:0},children:t.assignedTag??`Assigned`})]})}var $A=3;function ej({field:e,options:t,onSearch:n,searchLoading:r=!1,value:i,onChange:a,popupContext:o}){let d=qA(t),f=e.optionLayout,p=new Map(d.map(e=>[String(e?.value??``),e])),m=e.multiSelect||e.multiple||e.mode===`multiple`?`multiple`:e.mode,h=m===`multiple`||m===`tags`,g=e.searchMinLength??$A,[_,v]=(0,s.useState)(``),y=(0,s.useRef)(null),b=(0,s.useRef)(!1);async function x(t,n){let r=Array.isArray(t)?Array.isArray(n)?n:t.map(e=>p.get(String(e??``))).filter(Boolean):n??p.get(String(t??``));(typeof e.onSelectGuard!=`function`||await e.onSelectGuard({value:t,option:r,field:e,popupContext:o,confirm:c.Modal.confirm})!==!1)&&a?.(t)}function S(e){v(e),b.current=!1,n?.(e)}function C(e){e.key===`Enter`&&r&&n&&!h&&_.trim()&&(b.current=!0,e.preventDefault())}(0,s.useEffect)(()=>{if(r||!b.current)return;b.current=!1;let e=d.find(e=>e&&!e.disabled);e&&Promise.resolve(x(e.value,e)).finally(()=>y.current?.blur())},[r]);let w=!!n&&_.trim().length>0&&_.trim().length<g,T=(0,u.jsxs)(`div`,{className:`dynamic-popup__search-status`,role:`status`,"aria-live":`polite`,style:{display:`flex`,alignItems:`center`,gap:8,padding:`10px 12px`,color:`#8c8c8c`},children:[(0,u.jsx)(c.Spin,{size:`small`}),(0,u.jsx)(`span`,{children:_.trim().length>=g?`Searching "${_.trim()}"…`:`Loading…`})]}),E=e.notFoundContent??null;return n&&r?E=T:n&&E===null&&_.trim().length>=g&&(E=(0,u.jsx)(`div`,{style:{padding:`10px 12px`,color:`#8c8c8c`},children:`No matches found`})),(0,u.jsx)(c.Select,{ref:y,mode:m,showSearch:!0,filterOption:!1,notFoundContent:E,loading:!!n&&r,value:i,onChange:x,options:d,placeholder:e.placeholder,onSearch:n?S:void 0,onKeyDown:C,popupRender:n?e=>(0,u.jsxs)(u.Fragment,{children:[w&&!r?(0,u.jsx)(`div`,{style:{padding:`6px 12px`,fontSize:12,color:`#8c8c8c`},children:`Type at least ${g} characters to search — showing recent`}):null,r?T:e]}):void 0,className:`dynamic-popup__field-select${f?` dynamic-popup__field-select--rich`:``}`,popupClassName:f?`dynamic-popup__option-dropdown`:void 0,listHeight:f?340:void 0,optionLabelProp:`label`,optionRender:f?e=>(0,u.jsx)(HA,{option:e?.data??e,layout:f}):void 0,prefix:(0,u.jsx)(l.CrownOutlined,{})})}function tj({field:e,mentionOpts:t,onMentionSearch:n,value:r,onChange:i}){let a=Number(e.maxLength)>0?Number(e.maxLength):void 0,o=String(r??``).length;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Mentions,{value:r,onChange:i,rows:e.rows??5,placeholder:e.placeholder,prefix:`@`,options:t,onSearch:n,maxLength:a,className:`dynamic-popup__mention-textarea`}),a?(0,u.jsxs)(`div`,{className:`dynamic-popup__char-count`,style:{textAlign:`right`,fontSize:12,marginTop:4,color:o>a*.9?`#b45309`:`#8c8c8c`},children:[o,` / `,a]}):null]})}function nj({field:e={},value:t={},onChange:n}){let r=t.period??`Hourly`,i=t.isRange??!1;function a(e){n?.({...t,...e})}(0,s.useEffect)(()=>{let e={};t.currency??(e.currency=`$`),t.period??(e.period=`Hourly`),Object.keys(e).length&&n?.({...t,...e})},[]);let o=Number(i?t.maxAmount:t.amount),l=i&&t.minAmount!=null&&t.maxAmount!=null&&Number(t.maxAmount)<=Number(t.minAmount),d=e.rateCeiling!=null&&Number.isFinite(o)&&o>Number(e.rateCeiling);return(0,u.jsxs)(`div`,{children:[(0,u.jsxs)(c.Space.Compact,{style:{width:`100%`},children:[i?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.InputNumber,{controls:!1,placeholder:`From`,value:t.minAmount,onChange:e=>a({minAmount:e}),style:{flex:1}}),(0,u.jsx)(c.InputNumber,{controls:!1,placeholder:`To`,value:t.maxAmount,onChange:e=>a({maxAmount:e}),style:{flex:1}})]}):(0,u.jsx)(c.InputNumber,{controls:!1,placeholder:`0`,value:t.amount,onChange:e=>a({amount:e}),style:{flex:2}}),(0,u.jsx)(c.Select,{value:t.currency??`$`,options:GA,onChange:e=>a({currency:e}),style:{width:80}}),(0,u.jsx)(c.Select,{value:r,options:KA,onChange:e=>a({period:e}),style:{width:110}})]}),(l||d)&&(0,u.jsxs)(`div`,{style:{marginTop:4},children:[l&&(0,u.jsx)(UA,{type:`danger`,style:{fontSize:12,display:`block`},children:`To rate must be greater than From rate.`}),d&&(0,u.jsxs)(UA,{type:`danger`,style:{fontSize:12,display:`block`},children:[`Rate must not exceed the client rate (`,e.rateCeiling,`).`]})]}),(0,u.jsxs)(c.Space,{size:`small`,style:{marginTop:8},children:[(0,u.jsx)(c.Switch,{checked:i,onChange:e=>a({isRange:e})}),(0,u.jsx)(`span`,{children:`Range`})]})]})}function rj({field:e,value:t,onChange:n}){return(0,u.jsx)(c.DatePicker,{value:t,onChange:n,placeholder:e.placeholder??`Select date`,style:{width:`100%`},format:`YYYY-MM-DD`})}function ij({field:e,checked:t,onChange:n}){return(0,u.jsx)(c.Checkbox,{checked:t,onChange:n,children:e.checkboxLabel})}function aj({field:e,value:t,onChange:n}){return(0,u.jsx)(c.InputNumber,{value:t,onChange:n,min:e.min,max:e.max,placeholder:e.placeholder,style:{width:`100%`}})}function oj({options:e,value:t,onChange:n}){return(0,u.jsx)(c.Radio.Group,{value:t,onChange:n,options:e})}var sj={input:JA,text:JA,textarea:YA,select:XA,"multi-select":ZA,"search-select":ej,"mention-textarea":tj,"candidate-rate":nj,"priority-checkbox":ij,"date-picker":rj,number:aj,radio:oj};function cj(e){return e===`priority-checkbox`?{valuePropName:`checked`}:{}}var lj=new Set([`input`,`text`,`textarea`,`mention-textarea`]);function uj({form:e,fields:t,initialValues:r,dynamicOptions:i,popupContext:a,extraData:o,removedIds:l,setRemovedIds:d,onRemoveAssigned:f,showAlreadyAssigned:p,onValuesChange:m,getSearchHandler:h,searchLoading:g={},getMentionSearchHandler:_,mentionOptions:v}){let[y,b]=(0,s.useState)([]),x=(o?.recruitersData??[]).filter(e=>{let t=String(e?.user_id??e?.id??e?.userId??``);return t&&!l.includes(t)}),S=p&&o,C=new Set(p?x.map(e=>String(e?.user_id??e?.id??e?.userId??``).trim()).filter(Boolean):[]),w=e=>C.size===0||!Array.isArray(e)?e:e.map(e=>{let t=String((e&&typeof e==`object`?e.value??e.id:e)??``).trim();return!C.has(t)||!e||typeof e!=`object`?e:{...e,disabled:!0,assigned:!0,assignedTag:`Assigned`,title:e.title??`Already assigned to this job`}});return!t.length&&!S?null:(0,u.jsxs)(u.Fragment,{children:[S&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`dynamic-popup__already-assigned`,children:[(0,u.jsx)(n.Zn,{variant:`caption`,color:`secondary`,children:`Already Assigned People`}),(0,u.jsx)(`div`,{style:{marginTop:6,display:`flex`,flexWrap:`wrap`,gap:6},children:x.length===0?(0,u.jsx)(n.Zn,{variant:`caption`,color:`secondary`,children:`No one is currently assigned to this job.`}):x.map(e=>{let t=String(e?.user_id??e?.id??e?.userId??``),n=e?.name??e?.user_name??e?.userName??e?.email??`Assigned user`,r=y.includes(t);return(0,u.jsxs)(c.Tag,{closable:!r,onClose:async n=>{if(n.preventDefault(),!(!t||r)){b(e=>Array.from(new Set([...e,t])));try{typeof f==`function`&&await f({id:t,recruiter:e}),d(e=>Array.from(new Set([...e,t]))),c.message.success(`User unassigned successfully`)}catch(e){c.message.error(e?.message??`Failed to unassign user`)}finally{b(e=>e.filter(e=>e!==t))}}},children:[r&&(0,u.jsx)(c.Spin,{size:`small`,style:{marginRight:6}}),n]},t||n)})})]}),(0,u.jsx)(c.Divider,{style:{margin:`12px 0`}})]}),t.length>0&&(0,u.jsx)(c.Form,{form:e,layout:`vertical`,initialValues:r,onValuesChange:(e,t)=>m(t),children:dj(t).map(e=>fj(e,e=>{let t=w(i[e.name]??NA(e,a)),r=h(e),o=_(e),s=v[e.name]??[],l=cj(e.type),d=sj[e.type],f=[];return e.required&&f.push({required:!0,message:`${e.label||`This field`} is required`}),typeof e.validator==`function`&&f.push({validator:(t,n)=>{let r=e.validator(n,a);return r?Promise.reject(Error(r)):Promise.resolve()}}),lj.has(e.type)&&f.push(n.On({label:e.label,field:e.name,type:e.type})),(0,u.jsx)(c.Form.Item,{name:e.name,label:e.label,rules:f,...l,children:d?(0,u.jsx)(d,{field:e,options:t,onSearch:r,searchLoading:!!g[e.name],mentionOpts:s,onMentionSearch:o,popupContext:a}):null},e.name)}))})]})}function dj(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 fj(e,t){return e.length===1?t(e[0]):(0,u.jsx)(`div`,{style:{display:`flex`,gap:8,alignItems:`flex-start`},children:e.map((e,n)=>(0,u.jsx)(`div`,{style:{flex:n===0?2:1,minWidth:0},children:t(e)},e.name))},`row-${e.map(e=>e.name).join(`-`)}`)}function pj(e){return[`select`,`multi-select`,`search-select`,`radio`].includes(e?.type)&&e?.dataSource===`master`&&e?.masterName}function mj(e){let t=e?.data??e;return Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.items)?t.items:Array.isArray(t?.rows)?t.rows:Array.isArray(t?.records)?t.records:[]}function hj(e){let t=String(e?.masterName??``).trim().toLowerCase();return t===`clientsubmissions`||t===`clientsubmissionstatus`}function gj(e){if(e==null)return null;if(typeof e==`string`){let t=e.trim();return t?{label:t,value:t,_raw:{name:t}}:null}let t=String(e?.name??e?.clientSubmissionStatusText??e?.label??e?.text??``).trim();if(!t)return null;let n=Number(e?.id??e?.uniqueId??e?.clientSubmissionStatusId??e?.value??0)||0;return{label:t,value:t,_raw:{...e,...n>0?{id:n,uniqueId:n}:{},name:t,type:String(e?.type??e?.clientSubmissionStatusType??``).trim(),isInitialStatus:e?.isInitialStatus===!0,isTerminalStatus:e?.isTerminalStatus===!0,allowedNextStatusIds:Array.isArray(e?.allowedNextStatusIds)?e.allowedNextStatusIds.map(Number).filter(e=>Number.isInteger(e)&&e>0):[]}}}function _j(e,t){return hj(t)?gj(e):MA(e,t)}function vj(e){let t=e?.clientSubmissionStatus,n=Number((t&&typeof t==`object`?t?.clientSubmissionStatusId??t?.id??t?.uniqueId:void 0)??e?.clientSubmissionStatusId??e?.clientStatusId??e?.[`clientSubmissionStatus.clientSubmissionStatusId`]??0)||0,r=t&&typeof t==`object`?t?.clientSubmissionStatusText??t?.name??t?.text??t?.label:t;return{id:n,text:String(r??e?.clientSubmissionStatusText??e?.clientStatus??e?.clientStatusText??e?.[`clientSubmissionStatus.clientSubmissionStatusText`]??``).trim()}}function yj(e){let t=Number(e?.id??0)||0,n=String(e?.text??``).trim();return n&&n.toLowerCase()===`not submitted`?!0:t<=0&&!n}function bj(e){return Number(e?._raw?.id??e?._raw?.uniqueId??0)||0}function xj(e){let t=e?._raw?.allowedNextStatusIds;return Array.isArray(t)?t.map(Number).filter(e=>Number.isInteger(e)&&e>0):[]}function Sj(e){let t=e?.data??e;return t?Array.isArray(t)?t[0]??null:t?.record&&typeof t.record==`object`?t.record:t?.data&&typeof t.data==`object`&&!Array.isArray(t.data)?t.data:typeof t==`object`?t:null:null}function Cj(e){return(Array.isArray(e?.selectedRecords)?e.selectedRecords.filter(Boolean):[]).some(e=>!yj(vj(e)))?!0:!yj(vj(e??{}))}async function wj(e,n){if(Cj(e))return e;let r=e?.selectedIds?.[0]??e?.selectedRecords?.[0]?._id??e?.selectedRecords?.[0]?.id;if(!r)return e;let i=String(e?.moduleName??`submissions`).trim()||`submissions`,a=new URLSearchParams({module:i,id:String(r)});n&&a.set(`app_id`,n);try{let r=Sj(await t.o(t.x,`/module-data-detail?${a.toString()}`,{headers:n?{"X-App-Id":n}:void 0}));if(!r)return e;let i=Array.isArray(e?.selectedRecords)?e.selectedRecords:[];return{...e,selectedRecords:i.length?i.map((e,t)=>t===0?{...e,...r}:e):[r]}}catch(t){return console.warn(`[DynamicPopup] Could not load selected submission detail for client status transition:`,t),e}}function Tj(e,t){if(!Array.isArray(e)||!e.length)return[];if(!e.some(e=>e?._raw?.isInitialStatus===!0||e?._raw?.isTerminalStatus===!0||Array.isArray(e?._raw?.allowedNextStatusIds)))return e;let n=Array.isArray(t?.selectedRecords)?t.selectedRecords.filter(Boolean):[],r={clientSubmissionStatus:t?.clientSubmissionStatus,clientSubmissionStatusId:t?.clientSubmissionStatusId,clientSubmissionStatusText:t?.clientSubmissionStatusText,clientStatus:t?.clientStatus,clientStatusId:t?.clientStatusId,clientStatusText:t?.clientStatusText,"clientSubmissionStatus.clientSubmissionStatusId":t?.[`clientSubmissionStatus.clientSubmissionStatusId`],"clientSubmissionStatus.clientSubmissionStatusText":t?.[`clientSubmissionStatus.clientSubmissionStatusText`]},i=n.length?n:[r];return e.filter(t=>i.every(n=>{let i=vj(n);if(yj(i)){let e=vj(r);yj(e)||(i=e)}if(yj(i))return t?._raw?.isInitialStatus===!0;let a=e.find(e=>{let t=bj(e),n=String(e?.label??``).trim();return i.id>0&&t===i.id||i.text&&n.toLowerCase()===i.text.toLowerCase()});return!a||a?._raw?.isTerminalStatus===!0?!1:xj(a).includes(bj(t))}))}function Ej({open:e,config:n,api:r,fields:i,popupContext:a,formValues:o}){let[c,l]=(0,s.useState)({}),[u,d]=(0,s.useState)(null);return(0,s.useEffect)(()=>{e||(l({}),d(null))},[e]),(0,s.useEffect)(()=>{if(!e||!n||!r.getOptions)return;let t=new AbortController;return i.forEach(e=>{!e.fetchOptionsKey||e.fetchOptionsParamKey||Promise.resolve(r.getOptions(e,void 0,a)).then(n=>{t.signal.aborted||l(t=>({...t,[e.name]:n}))}).catch(n=>{t.signal.aborted||console.error(`[DynamicPopup] Failed to load options for field "${e.name}":`,n)})}),()=>t.abort()},[e,r,n,i,a]),(0,s.useEffect)(()=>{if(!e||!n)return;let r=i.filter(pj);if(!r.length)return;let o=new AbortController;return r.forEach(e=>{let n=new URLSearchParams({masterName:e.masterName,offset:`0`,limit:String(e.limit??50)}),r=String(t.b??``).trim();r&&n.set(`app_id`,r),t.o(t.x,`/masters/dropdown?${n.toString()}`,{headers:r?{"X-App-Id":r}:void 0}).then(async t=>{if(o.signal.aborted)return;let n=mj(t).map(t=>_j(t,e)).filter(Boolean),i=a;if(hj(e)&&(i=await wj(a,r)),o.signal.aborted)return;let s=hj(e)?Tj(n,i):n;l(t=>({...t,[e.name]:s}))}).catch(t=>{o.signal.aborted||console.error(`[DynamicPopup] Failed to load master options for field "${e.name}":`,t)})}),()=>o.abort()},[e,n,i,a]),(0,s.useEffect)(()=>{if(!e||!n||!r.getOptions)return;let t=i.filter(e=>e.fetchOptionsKey&&e.fetchOptionsParamKey);if(!t.length)return;let s=new AbortController;return t.forEach(e=>{let t=o[e.fetchOptionsParamKey]??a[e.fetchOptionsParamKey],n={[e.fetchOptionsParamKey]:t};Promise.resolve(r.getOptions(e,n,a)).then(t=>{s.signal.aborted||l(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,r,n,i,o,a]),(0,s.useEffect)(()=>{if(!e||!n||!r.loadExtraData)return;let t=new AbortController;return Promise.resolve(r.loadExtraData(a)).then(e=>{t.signal.aborted||d(e)}).catch(e=>{t.signal.aborted||(console.error(`[DynamicPopup] Failed to load extra data:`,e),d(null))}),()=>t.abort()},[e,r,n,a]),{dynamicOptions:c,setDynamicOptions:l,extraData:u}}var Dj=400,Oj=3,kj=Object.freeze({});function Aj({api:e,open:t,fields:n=[],popupContext:r,setDynamicOptions:i,getFieldValue:a}){let[o,c]=(0,s.useState)({}),[l,u]=(0,s.useState)({}),d=(0,s.useCallback)((e,t)=>{u(n=>!!n[e]===t?n:{...n,[e]:t})},[]),f=(0,s.useRef)({}),p=(0,s.useRef)({}),m=(0,s.useRef)({}),h=(0,s.useRef)({}),g=(0,s.useRef)({}),_=(0,s.useCallback)((t,n)=>{let o=e.searchOptions??e.searchFetcher;if(typeof o!=`function`)return;p.current[t.name]?.abort();let s=new AbortController;return p.current[t.name]=s,h.current[t.name]=n,g.current[t.name]=!0,d(t.name,!0),Promise.resolve(o(t,n,r)).then(e=>{if(s.signal.aborted)return;let n=(Array.isArray(e)?e:e?.items??e?.list??[]).map(e=>MA(e,t)),o=t.initialOptionKey?r[t.initialOptionKey]:null,c=Array.isArray(o)?o:o?[o]:[],l=new Set(n.map(e=>e.value)),u=c.filter(e=>!l.has(e.value)),f=a?.(t.name),p=new Set((Array.isArray(f)?f:[f]).filter(e=>e!=null&&e!==``).map(String));i(e=>{let r=p.size?(e[t.name]??[]).filter(e=>p.has(String(e?.value))&&!l.has(e?.value)&&!u.some(t=>t.value===e?.value)):[];return{...e,[t.name]:[...u,...n,...r]}}),g.current[t.name]=!1,d(t.name,!1)}).catch(e=>{s.signal.aborted||(g.current[t.name]=!1,d(t.name,!1),console.error(`[DynamicPopup] Search failed for field "${t.name}":`,e))}),s},[e,r,i,a,d]),v=n.filter(e=>(e.searchFetchKey||e.searchFetcher)&&e.preloadOptions!==!1),y=v.map(e=>e.name).join(`|`),b=(0,s.useRef)({runSearch:_,preloadFields:v});(0,s.useEffect)(()=>{b.current={runSearch:_,preloadFields:v}}),(0,s.useEffect)(()=>{if(!t||!y)return;let{runSearch:e,preloadFields:n}=b.current,r=n.map(t=>e(t,``)).filter(Boolean);return()=>{r.forEach(e=>e.abort()),u({})}},[t,y]);function x(t){if(!t.searchFetchKey&&!t.searchFetcher||typeof(e.searchOptions??e.searchFetcher)!=`function`)return;let n=t.searchMinLength??Oj;return e=>{clearTimeout(f.current[t.name]);let r=String(e??``).trim(),i=r.length<n?``:r;if(i===``&&h.current[t.name]===``){d(t.name,!!g.current[t.name]);return}d(t.name,!0),f.current[t.name]=setTimeout(()=>{_(t,i)},Dj)}}function S(t){let n=e.getMentionOptions??e.mentionFetcher;if(typeof n==`function`)return e=>{m.current[t.name]?.abort();let i=new AbortController;m.current[t.name]=i,Promise.resolve(n(t,e,r)).then(e=>{if(i.signal.aborted)return;let n=Array.isArray(e)?e:e?.items??e?.list??[];c(e=>({...e,[t.name]:n.map(e=>({value:e.user_name??e.userName??e.username??String(e),label:e.user_name??e.userName??e.username??String(e)}))}))}).catch(e=>{i.signal.aborted||console.error(`[DynamicPopup] Mention search failed for field "${t.name}":`,e)})}}return{mentionOptions:o,searchLoading:t?l:kj,getSearchHandler:x,getMentionSearchHandler:S}}function jj({form:e,config:t,api:n,popupContext:r,resolvedIds:i,dynamicOptions:a,extraData:o,removedIds:l,removalOnlySubmit:u=!1,fields:d,onClose:f,onSubmit:p}){let[m,h]=(0,s.useState)(!1),[g,_]=(0,s.useState)(null);async function v(e){let t={resolvedIds:i,dynamicOptions:a,extraData:o,removedIds:l};if(typeof n.submit==`function`)return n.submit(e,r,t);if(typeof p==`function`)return p(e,r,t)}function y(){if(t){if(!d.length){if(t.mode===`delete`&&typeof n.deleteItems==`function`){h(!0),_(null),Promise.resolve(n.deleteItems(i,r)).then(()=>{c.message.success(t.successMessage||`Deleted successfully`),f({success:!0})}).catch(e=>{let t=e?.message||`Delete failed. Please try again.`;_(t),h(!1),c.message.error(t)});return}if(typeof n.onOk==`function`){h(!0),Promise.resolve(n.onOk(r)).then(()=>f({success:!0})).catch(e=>{let t=e?.message||`Failed. Please try again.`;c.message.error(t),h(!1)});return}if(typeof n.submit==`function`){h(!0),Promise.resolve(v({})).then(e=>{e?.navigated||(c.message.success(t.successMessage||`Saved successfully`),f({success:!0}))}).catch(e=>{c.message.error(e?.message||`Failed. Please try again.`)}).finally(()=>h(!1));return}f();return}if(u){h(!0),Promise.resolve(v(e.getFieldsValue())).then(e=>{e?.navigated||(c.message.success(t.successMessage||`Saved successfully`),f({success:!0}))}).catch(e=>{c.message.error(e?.message||`Failed. Please try again.`)}).finally(()=>h(!1));return}e.validateFields().then(async e=>{h(!0);try{if((await v(e))?.navigated)return;c.message.success(t.successMessage||`Saved successfully`),f({success:!0})}catch(e){c.message.error(e?.message||`Failed. Please try again.`)}finally{h(!1)}}).catch(()=>{})}}function b(){h(!1),_(null)}return{handleOk:y,confirming:m,deleteError:g,resetSubmitState:b}}function Mj(e){return!!(e.multiSelect||e.multiple||e.mode===`multiple`)}function Nj({open:e=!0,config:t,context:n={},onClose:r,onSubmit:i,api:a={}}){let[o]=c.Form.useForm(),[l,f]=(0,s.useState)({}),[p,m]=(0,s.useState)([]),h=c.Form.useWatch([],o,{preserve:!0})??{},g=(0,s.useMemo)(()=>PA(n),[n]),{selectedIds:_=[],selectedRecords:v=[],moduleName:y=``}=g,b=(0,s.useMemo)(()=>_.map((e,t)=>{let n=v[t];return n?.id??n?._id??e}),[_,v]),x=(0,s.useMemo)(()=>t?typeof t.getFields==`function`?t.getFields(g):t.fields??[]:[],[t,g]),S=(0,s.useMemo)(()=>{let e={};return x.forEach(t=>{if(t.initialOptionKey){let n=g[t.initialOptionKey],r=Array.isArray(n)?n:n?[n]:[];if(!r.length)return;e[t.name]=Mj(t)?r.map(e=>e.value):r[0].value;return}let n=g[t.initialValueKey];!t.initialValueKey||n===void 0||(e[t.name]=t.type===`date-picker`?(0,d.default)(n):n)}),e},[x,g]),{dynamicOptions:C,setDynamicOptions:w,extraData:T}=Ej({open:e,config:t,api:a,fields:x,popupContext:g,formValues:l}),{mentionOptions:E,searchLoading:D,getSearchHandler:O,getMentionSearchHandler:k}=Aj({api:a,open:e,fields:x,popupContext:g,setDynamicOptions:w,getFieldValue:(0,s.useCallback)(e=>o.getFieldValue(e),[o])});(0,s.useEffect)(()=>{if(!e)return;let t={};x.forEach(e=>{if(!e.initialOptionKey)return;let n=g[e.initialOptionKey],r=Array.isArray(n)?n:n?[n]:[];r.length&&(t[e.name]=r)}),Object.keys(t).length&&w(e=>({...e,...t}))},[e,x,g]);function A(e){typeof r==`function`&&r(e)}let j=x.filter(e=>e.required),M=j.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)}),N=(g.removedIds??[]).length,P=p.length>N,F=j.some(e=>{let t=h[e.name];return!(t==null||t===``||Array.isArray(t)&&t.length===0)}),{handleOk:I,confirming:L,deleteError:R,resetSubmitState:z}=jj({form:o,config:t,api:a,popupContext:g,resolvedIds:b,dynamicOptions:C,extraData:T,removedIds:p,removalOnlySubmit:!!t?.allowRemovalOnlySubmit&&P&&!F,fields:x,onClose:A,onSubmit:i});(0,s.useEffect)(()=>{e&&(o.resetFields(),f(S??{}),m(g.removedIds??[]),z())},[e,S]);let B=!!t?.autoSubmitWhenNoFields&&x.length===0;(0,s.useEffect)(()=>{!e||!B||I()},[e,B]);let V=_.length,H=String(y).replace(/s$/i,``),ee=V===1?H:y,te=v[0]??{},ne=t?.getTitleText?t.getTitleText(V,ee,te,g):t?.title,re=V===1?te.jobTitle??te.title??te.name??te.fullName??te.candidateName??null:null,ie=t?.getBodyText?t.getBodyText(V,H,ee,re,g):t?.bodyText??null,ae=typeof t?.getNote==`function`?t.getNote(g):t?.note,oe=t?.disabledUntilFilled&&!M&&!P;if(!t||!e||B)return null;let se=t.component;return se?(0,u.jsx)(c.Modal,{open:e,title:t.title||t.getTitleText?(0,u.jsx)(CA,{titleText:ne,titleIcon:t.titleIcon}):null,footer:null,width:t.width??760,centered:!0,maskClosable:!1,onCancel:()=>A(),className:`dynamic-popup${t.className?` ${t.className}`:``}`,children:(0,u.jsx)(se,{context:g,selectedIds:b,selectedRecords:v,moduleName:y,onClose:A})}):(0,u.jsxs)(c.Modal,{open:e,title:(0,u.jsx)(CA,{titleText:ne,titleIcon:t.titleIcon}),okText:t.okText||`OK`,cancelText:t.cancelText??`Cancel`,onOk:I,onCancel:()=>A(),okButtonProps:{danger:t.okButtonDanger,disabled:oe,loading:L},cancelButtonProps:{disabled:L},closable:!L,maskClosable:!1,width:t.width??480,centered:!0,className:`dynamic-popup${t.className?` ${t.className}`:``}`,children:[(0,u.jsx)(wA,{note:ae,description:t.description,showSelectedCount:t.showSelectedCount,count:V,itemLabel:ee,bodyText:ie,deleteError:R}),(0,u.jsx)(TA,{footerNote:t.footerNote}),(0,u.jsx)(uj,{form:o,fields:x,initialValues:S,dynamicOptions:C,popupContext:g,extraData:T,removedIds:p,setRemovedIds:m,onRemoveAssigned:a.removeAssignedUser?e=>a.removeAssignedUser(e,g):void 0,showAlreadyAssigned:t.showAlreadyAssigned,onValuesChange:f,getSearchHandler:O,searchLoading:D,getMentionSearchHandler:k,mentionOptions:E})]})}var Pj={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:[]},Fj={deleteItems:async(e,t)=>{await ae(t.moduleName,e)}},Ij=new Map;async function Lj(e){return e?(Ij.has(e)||Ij.set(e,o.r({module:e}).catch(t=>(Ij.delete(e),console.warn(`[in-progress gate] could not read ${e} form groups:`,t),[]))),Ij.get(e)):[]}function Rj(e=[],t){return e.some(e=>{let r=n.F(e,t);return r&&r.severity!==`allow`})}async function zj({targetModule:e,sourceModule:t,recordId:r,region:i}={}){let a={severity:`allow`,message:``,group:null};if(!e||!t||!r)return a;let s=i??n.fr().region;try{let i=await Lj(e);if(!Rj(i,s))return a;let c=await o.r({module:t,id:r}),l={};for(let e of c){let t=e?.payloadKey||e?.name;t&&Array.isArray(e?.rows)&&(l[t]=e.rows)}return n.z(i,s,l)}catch(e){return console.warn(`[in-progress gate] check skipped:`,e),a}}var Bj=`Already submitted`,Vj=`submissions`,Hj=`candidates`,Uj=864e5,Wj=90,Gj=`This candidate was created or last updated more than 90 days ago. Only candidates created or updated within the last 90 days can be selected. Please update this candidate first.`,Kj=[`createdAt`,`createdDate`,`dateCreated`,`created_on`,`createdOn`],qj=[`updatedAt`,`updatedDate`,`lastUpdatedAt`,`lastUpdatedDate`,`modifiedAt`,`modifiedDate`];function Jj(e,t){for(let n of t){let t=e?.[n];if(!t)continue;let r=new Date(t);if(!Number.isNaN(r.getTime()))return r}return null}function Yj(e){return Jj(e,Kj)}function Xj(e){return Jj(e,qj)}function Zj(e){if(!(e instanceof Date)||Number.isNaN(e.getTime()))return null;let t=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();return Math.max(0,Math.floor((t(new Date)-t(e))/Uj))}function Qj(e){return e===null?``:e<=14?`green`:e<=89?`yellow`:`red`}function $j(e,t=Wj){if(!e)return!1;let n=Date.now()-t*Uj,r=Yj(e),i=Xj(e),a=r&&r.getTime()>=n,o=i&&i.getTime()>=n;return!a&&!o}var eM=6e4;function tM(e){let t=Yj(e),n=qj.map(t=>e?.[t]).find(e=>OA(e)),r=n?new Date(n?.$date??n):null;return r&&!Number.isNaN(r.getTime())&&(!t||r.getTime()-t.getTime()>eM)?r:t}function nM(e){let t=tM(e);if(!t||!OA(t))return{createdAgo:``,createdAgoTone:``};let n=kA(t);return n?{createdAgo:n,createdAgoTone:Qj(Zj(t))}:{createdAgo:``,createdAgoTone:``}}function rM(e){for(let t of[`applicantRefrenceId`,`applicantReferanceId`,`applicantReferenceId`]){let n=e?.[t];if(typeof n==`string`&&n.trim())return n.trim()}return``}function iM(e){return{...e,applicantRefrenceId:rM(e),...nM(e),isStaleCandidate:$j(e)}}function aM(e){return String(e?.applicantId??e?._id??e?.id??``)}var oM=null;async function sM(){return oM||=n.fi(Hj).then(e=>e?.strategies?.duplicateCheck?.editRoute??``).catch(()=>``),oM}async function cM(e){let t=aM(e);if(!t)return``;let n=await sM();return n?n.replace(/:(_?id)\b/g,encodeURIComponent(t)):``}async function lM({option:e,popupContext:t,confirm:n}){let r=e?._raw??e??{},i=aM(r);if(i){let e=await zj({targetModule:Vj,sourceModule:Hj,recordId:i});if(e.severity===`block`)return new Promise(t=>{n({title:`This candidate cannot be submitted`,content:e.message,okText:`Pick someone else`,cancelText:`Close`,onOk:()=>t(!1),onCancel:()=>t(!1)})})}if(!$j(r))return!0;let a=t?.navigate;return!a||!i?!1:new Promise(e=>{n({title:`Candidate update required`,content:Gj,okText:`OK`,cancelText:`Cancel`,onOk:async()=>{let t=await cM(r);t&&a(t),e(!1)},onCancel:()=>e(!1)})})}function uM(e,t,n){return{...e,label:`${e.label} - ${Bj}`,disabled:!0,title:`${Bj}${t?` (submission ${t})`:``}`,alreadySubmitted:!0,existingSubmissionId:t||``,...n?{submittedAt:n}:{}}}var dM={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 Te({searchQuery:t,candidateId:r})}catch{a=!1;let e=await Zn({searchQuery:t,candidateId:r});i=Array.isArray(e?.data)?e.data:[]}let o=i.map(e=>({label:[e.jobReferenceId??e.clientJobReferenceId,e.jobTitle].filter(Boolean).join(` - `)||String(e._id??``),value:e._id??``,_raw:e}));if(a)return o.map(e=>{if(e._raw?.isSubmitted||e._raw?.alreadySubmitted)return uM(e,e._raw?.jobSubmissionId||``,e._raw?.submittedAt||``);if(e._raw?.disable){let t=String(e._raw?.message??``).trim();return{...e,disabled:!0,label:t?`${e.label} - ${t}`:e.label,title:t}}return e});let s=await De({applicantId:r,jobIds:o.map(e=>e.value)}).catch(()=>new Map);return o.map(e=>{let t=s.get(String(e.value));return t?uM(e,t.submissionId,t.submittedAt):e})}if(e.searchFetchKey===`quickSubmitCandidates`){let e=n.selectedRecords?.[0]??{},r=n.jobId??e.jobId??e.id??e._id??n.selectedIds?.[0],i,a=new Map;try{i=await Ee({search:t,jobId:r})}catch{let e=await hs({isFromSubmission:n.isFromSubmission,jobId:r,submissionId:n.submissionId,search:t});i=Array.isArray(e)?e:[],a=await De({jobId:r,applicantIds:i.map(aM)}).catch(()=>new Map)}return i.map(e=>iM(e)).map(e=>{let t=a.get(aM(e));if(!(t||e?.isSubmitted===!0||e?.alreadySubmitted===!0))return e;let n=t?.submissionId||e?.jobSubmissionId||``,r=t?.submittedAt||e?.submittedAt||``;return{...e,disabled:!0,optionNote:Bj,isSubmitted:!0,alreadySubmitted:!0,existingSubmissionId:n,...r?{submittedAt:r}:{}}})}return[]},submit:async(e,t,n)=>{let{navigate:r,selectedRecords:i=[],selectedIds:a=[],moduleName:o}=t,s=i[0]??{},c,l;t.jobId?(c=t.jobId,l=s.id??s._id??a[0]??``):o===`candidate`?(c=e.jobId??``,l=s.id??s._id??a[0]??``):(c=s.jobId??s.id??s._id??a[0]??``,l=e.candidate??``);let u=n?.dynamicOptions?.candidate?.find(e=>aM(e?._raw)===String(l)),d=n?.dynamicOptions?.jobId?.find(e=>String(e?.value)===String(c)),f=u?._raw?.isSubmitted||u?._raw?.alreadySubmitted||d?.alreadySubmitted||d?._raw?.isSubmitted||d?._raw?.alreadySubmitted;if(!c||!l)throw Error(`Select both a job and a candidate to quick submit.`);if($j(u?._raw))throw Error(Gj);let p=await zj({targetModule:Vj,sourceModule:Hj,recordId:l});if(p.severity===`block`)throw Error(p.message);let m=f,h=u?._raw?.existingSubmissionId||u?._raw?.jobSubmissionId||d?.existingSubmissionId||d?._raw?.jobSubmissionId||``;try{let e=await we({jobId:c,applicantId:l});m||=!!e?.exists,h=e?.submissionId||h}catch(e){throw Error(`Could not verify existing submissions (${e?.message??`request failed`}). Please try again.`,{cause:e})}if(m)throw Error(`This candidate is already submitted for this job${h?` (submission ${h})`:``}.`);let g=new URLSearchParams;l&&g.set(`candidateId`,l);let _=u?.priorSubmissionId||u?._raw?.submissionId||d?.priorSubmissionId||d?._raw?.submissionId||``;_?(g.set(`submissionId`,String(_)),g.set(`isFromSubmission`,`true`)):g.set(`isFromSubmission`,`false`);let v=fs(ms({jobId:c,applicantId:l}).catch(()=>[]));return r(`/submission-create/${c}?${g.toString()}`,{state:{relevantSkillsToken:v}}),{navigated:!0}}},fM={title:`Submit`,okText:`Submit`,width:640,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getNote:e=>e.moduleName===`candidate`?`Note: Select a job to submit this candidate.`:`Note: Select a candidate to submit for this job`,getFields:e=>e.jobId?[]:e.moduleName===`candidate`?[{name:`jobId`,label:`Job list`,type:`search-select`,required:!0,placeholder:`Search Job ID / job name - or pick a recent job`,searchFetchKey:`quickSubmitJobList`,optionLayout:{id:`{jobReferenceId}`,title:`{jobTitle}`,subtitle:`{clientJobReferenceId}`,meta:[{label:`Created`,key:`createdAt`,type:`date`},{label:`Updated`,key:`updatedAt`,type:`relative`}]}}]:[{name:`candidate`,label:`Candidate`,type:`search-select`,required:!0,placeholder:`Search candidate name / email - or pick a recent candidate`,optionsKey:`candidateOptions`,searchFetchKey:`quickSubmitCandidates`,labelTemplate:`{applicantRefrenceId} - {firstName} {lastName} - {createdAgo}`,valueKey:`applicantId`,optionLayout:{id:`{applicantRefrenceId}`,title:`{firstName} {lastName}`,titleAccent:{key:`createdAgo`,toneKey:`createdAgoTone`,prefix:` - `},subtitle:`{designation} - {email}`,meta:[{label:`Created`,key:`createdAt`,type:`date`},{label:`Updated`,key:`updatedAt`,type:`date`,emptyText:`Not updated`}]},onSelectGuard:lM}]},pM={title:`Add Notes & Share`,okText:`Save & Share`,width:480,fields:[{name:`notes`,label:`Notes`,type:`mention-textarea`,required:!0,rows:5,maxLength:2e3,placeholder:`Add your notes on the job. Use '@' to mention someone.`,mentionFetchKey:`mentionUsers`}]},mM=e=>e?.data??e;async function hM({relatedId:e,notes:n,title:r,notesFor:i}){return mM(await Nn(t.x,`/notes`,{method:`POST`,body:JSON.stringify({relatedId:e,notes:n,title:r,notesFor:i})}))}var gM={getMentionOptions:async(e,t)=>se(t),submit:async(e,t)=>{let n=Array.isArray(t.selectedIds)?t.selectedIds[0]:t.selectedIds;if(!n)throw Error(`Please select a record before adding a note.`);await hM({relatedId:String(n),notes:e.notes,notesFor:t.moduleName})}},_M={name:`jobId`,label:`Job Title / ID`,type:`search-select`,required:!0,placeholder:`Minimum 3 characters`,searchFetchKey:`tagToJobJobList`,multiSelect:!0,valueKey:`_id`,labelTemplate:`{jobReferenceId} - {jobTitle} — {jobRecruitmentStatus}`,initialOptionKey:`jobOption`},vM={name:`hiringStage`,label:`Hiring stage`,type:`select`,required:!0,optionsKey:`hiringStageOptions`,defaultOptions:[{label:`Shortlisted`,value:`shortlisted`},{label:`Pipeline`,value:`pipeline`}],initialValueKey:`hiringStage`},yM={title:`Tag to Jobs`,okText:`Tag`,width:480,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getFields:e=>e.jobId&&e.hiringStage?[]:[_M,vM]},bM=e=>e?.data??e;function xM(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 SM(e){return e?Array.isArray(e.data)?e.data.map(xM):e.stage&&Array.isArray(e.stage.data)?e.stage.data.map(xM):Array.isArray(e)?e.map(xM):[]:[]}async function CM(e=1,n=10){let r=await t.o(t.x,`/workflow/list/all?page=${e}&limit=${n}`),i=bM(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 wM(e,n){let r=bM(await t.o(t.x,`/workflow/${e}/stage/${n}`));return Array.isArray(r)?{data:r}:r}async function TM(e,n){if(!e||!n)return null;try{let r=new URLSearchParams({module:e,limit:`1`,offset:`0`,scope:`allJobs`,filters:JSON.stringify([{field:`_id`,op:`in`,values:[String(n)],operator:`and`}])}),i=bM(await t.o(t.x,`/module-data-list?${r}`));if(Array.isArray(i))return i[0]??null;if(i?.data&&Array.isArray(i.data))return i.data[0]??null;let a=i?.rows??i?.records??i?.items??i?.list;return Array.isArray(a)?a[0]??null:i??null}catch(t){return console.error(`[getModuleRecordById] failed: ${e}/${n}`,t),null}}async function EM(e){return bM(await t.o(t.T,`/source/workflow-instance`,{method:`POST`,body:JSON.stringify(e)}))}var DM={pipeline:`pipeline`,goodfited:`goodfited`,contacted:`contacted`,submitted:`submitted`,shortlisted:`shortlisted`,interviewinprogress:`interviewInprogress`,selected:`selected`};function OM(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 kM(e){let t=String(e??``).trim();return t?DM[t.toLowerCase()]??t:``}function AM(e,t){let n=OM(e,`candidateId`,`candidate_id`,`applicantId`,`applicantID`,`applicantReferenceId`,`applicantRefrenceId`,`_id`,`id`)??t;if(!n)return null;let r=(OM(e,`candidateName`,`candidate_name`,`fullName`,`name`)??[OM(e,`firstName`,`first_name`),OM(e,`lastName`,`last_name`)].filter(Boolean).join(` `))||void 0,i={candidateId:String(n),candidateName:r,phone:OM(e,`phone`,`phoneNumber`,`phone_number`,`mobile`,`mobileNumber`,`mobile_number`),source:OM(e,`source`,`sourceType`,`candidateSource`,`profileSource`),submittedAt:OM(e,`submittedAt`,`lastSubmittedAt`,`updatedAt`),remarks:OM(e,`remarks`,`comment`,`comments`,`notes`),assignedRecruiter:OM(e,`assignedRecruiter`,`recruiterName`,`ownerName`,`assignedToName`),screeningStatus:OM(e,`screeningStatus`,`screening.status`,`screeningResult`),screeningScore:OM(e,`screeningScore`,`screening.score`,`score`),assignedDate:OM(e,`assignedDate`,`assignedAt`,`createdAt`)};return Object.fromEntries(Object.entries(i).filter(([,e])=>e!=null&&e!==``))}var jM={searchOptions:async(e,t)=>e.searchFetchKey===`tagToJobJobList`?oe(t):[],submit:async(e,t)=>{let n=e.jobId??t.jobId,r=Array.isArray(n)?n:[n].filter(Boolean),i=kM(e.hiringStage??t.hiringStage),a=Array.isArray(t.selectedIds)?t.selectedIds:[],o=Array.isArray(t.selectedRecords)?t.selectedRecords:[],s=Math.max(a.length,o.length,1);for(let e of r)for(let t=0;t<s;t+=1){let n=a[t]?String(a[t]):``,r=AM(o[t]??{},n);await EM({jobId:e,module:`jobs`,currentStage:i,...r?{candidateDetails:r}:{}})}let c=await le({jobId:n,candidateIds:t.selectedIds,hiringStage:i,hiriringStatusChangeType:t.hiriringStatusChangeType||`tagToJobs`});if(c?.status===!1)throw Error(c?.error||`Could not update hiring stage`)}},MM={title:`Change Status`,okText:`Apply`,width:420,showSelectedCount:!0,fields:[{name:`status`,label:`New Status`,type:`select`,required:!0,placeholder:`Select a status`,dataSource:`master`,masterName:`clientSubmissions`,labelKey:`name`,valueKey:`name`,initialValueKey:`currentStatus`,defaultOptions:[{label:`Active`,value:`active`},{label:`Inactive`,value:`inactive`},{label:`Pending`,value:`pending`},{label:`Closed`,value:`closed`}]}]};function NM(e,t){let n=String(e??``).trim().toLowerCase();return(Array.isArray(t?.status)?t.status:[]).find(e=>String(e?.value??``).trim().toLowerCase()===n||String(e?.label??``).trim().toLowerCase()===n||String(e?._raw?.name??``).trim().toLowerCase()===n)??null}var PM={submit:async(e,t,n)=>{let r=NM(e.status,n?.dynamicOptions),i=r?._raw??{},a={clientSubmissionStatusText:String(i.name??r?.label??e.status??``).trim(),clientSubmissionStatusId:Number(i.id??i.uniqueId??0)||0,clientSubmissionStatusType:String(i.type??``).trim()};await ie(t.moduleName,t.selectedIds,a)}},FM={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:[]},IM={onOk:async e=>{await Oe({jobId:e.jobId??e.selectedIds[0],candidateIds:e.selectedIds})}},LM={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`}]},RM={getOptions:async e=>e.fetchOptionsKey===`candidateGroups`?ue():[],submit:async(e,t,{dynamicOptions:n})=>{let r=(n.groupId??[]).find(t=>String(t.value)===String(e.groupId));await de({candidateIds:t.selectedIds,groupId:e.groupId,groupName:r?.label??``})}},zM=[{title:`Name`,key:`name`,render:(e,t)=>t.name||`${t.first_name??``} ${t.last_name??``}`.trim()||t.user_name||`Assigned user`},{title:`Role`,dataIndex:`role_name`,key:`role`,render:e=>e||`-`},{title:`Reporting`,dataIndex:`reporting_name`,key:`reporting`,render:e=>e||`-`}];function BM({selectedIds:e,onClose:t}){let n=e?.[0],[r,i]=(0,s.useState)(!0),[a,o]=(0,s.useState)(!1),[d,f]=(0,s.useState)({assignedUsers:[],totalSubmissions:0,message:``}),[p,m]=(0,s.useState)([]);(0,s.useEffect)(()=>{let e=!1;return i(!0),Promise.all([fe(n).catch(t=>(e||c.message.error(t?.message??`Failed to load self-assign details`),{assignedUsers:[],totalSubmissions:0,message:``})),ge(n).catch(()=>({recruitersData:[]}))]).then(([t,n])=>{e||(f(t),m(Array.isArray(n?.recruitersData)?n.recruitersData:[]))}).finally(()=>{e||i(!1)}),()=>{e=!0}},[n]);let h=async()=>{o(!0);try{await G({jobIds:[n]}),c.message.success(`Job assigned successfully`),t?.({success:!0})}catch(e){c.message.error(e?.message??`Failed to assign job`)}finally{o(!1)}};if(r)return(0,u.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,u.jsx)(c.Spin,{size:`large`})});let g=p.map(e=>({user_id:e.recruiterId??e.id??e.user_id,name:e.name??``,role_name:e.role_name??e.roleName??``,reporting_name:e.reporting_name??e.reportingName??``})),_=new Map(g.map(e=>[String(e.user_id??``),e])),v=(d.assignedUsers?.length??0)>0?d.assignedUsers.map(e=>{let t=e.user_id??e.userId??e.recruiterId??e.id,n=_.get(String(t??``))??{};return{...e,user_id:t,name:n.name||e.name||``,role_name:n.role_name||e.role_name||e.roleName||``,reporting_name:n.reporting_name||e.reporting_name||e.reportingName||``}}):g,y=v.length>0;return(0,u.jsxs)(`div`,{className:`self-assign-popup-body`,children:[y?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`div`,{style:{fontWeight:700,marginBottom:8},children:`Team Members Allocated`}),(0,u.jsx)(c.Table,{columns:zM,dataSource:v,pagination:!1,rowKey:e=>e.user_id??`${e.first_name}-${e.last_name}`,size:`small`,className:`mb-3 no-header-bg`,scroll:{y:200}}),(0,u.jsxs)(`div`,{className:`warning-card`,style:{display:`flex`,alignItems:`center`,gap:8,marginTop:12},children:[(0,u.jsx)(l.ExclamationCircleFilled,{style:{color:`#faad14`,fontSize:18}}),(0,u.jsx)(`div`,{style:{fontSize:13},children:`These users are already assigned to this job. Do you still want to assign yourself as well?`})]})]}):(0,u.jsx)(`div`,{style:{padding:`8px 0`},children:d.message||`No one is currently assigned to this job. Do you want to assign yourself?`}),(0,u.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:12,marginTop:24},children:[(0,u.jsx)(c.Button,{size:`small`,onClick:()=>t?.(),disabled:a,children:`No`}),(0,u.jsx)(c.Button,{type:`primary`,size:`small`,onClick:h,loading:a,children:`Yes`})]})]})}BM.propTypes={selectedIds:p.default.array,onClose:p.default.func};var VM={title:`Self Assign`,width:480,className:`self-assign-modal`,component:BM},HM={submit:async()=>{}};function UM(e={}){let t=Array.isArray(e.jobPayDetails)?e.jobPayDetails[e.jobPayDetails.length-1]:e.jobPayDetails??e.clientBudget??{},n=Number(t.clientBudgetEnd),r=Number(t.clientBudgetStart);return Number.isFinite(n)&&n>0?n:Number.isFinite(r)&&r>0?r:null}var WM={getTitleText:(e,t,n)=>{let r=n?.jobTitle||n?.title||``;return r?`Assign - ${r}`:`Assign`},okText:`Assign`,width:520,disabledUntilFilled:!0,showAlreadyAssigned:!0,allowRemovalOnlySubmit:!0,getFields:e=>(UM(e?.selectedRecords?.[0]??{}),[{name:`assignToUserId`,label:`Assign to`,type:`multi-select`,required:!0,placeholder:`Select recruiter(s)`,fetchOptionsKey:`assignToUsers`}])},GM={getOptions:async(e,t,n)=>e.fetchOptionsKey===`assignToUsers`?me(n?.selectedIds?.[0]):[],loadExtraData:async e=>ge(e.selectedIds[0]),removeAssignedUser:async({id:e},t)=>_e({jobId:t.selectedIds[0],userId:e}),submit:async(e,t,{removedIds:n,extraData:r})=>{await ve({jobIds:t.selectedIds,userId:e.assignToUserId,removedIds:n,existingRecruiters:r?.recruitersData})}},KM={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`}]},qM={getMentionOptions:async(e,t)=>se(t),submit:async(e,t)=>{let n=e.targetDate?e.targetDate.toISOString():``;t.editingNoteId?await U(t.editingNoteId,{title:e.heading,targetDate:n,notes:e.comments}):await ce({relatedIds:t.selectedIds,module:t.moduleName,title:e.heading,targetDate:n,notes:e.comments}),window.dispatchEvent(new Event(`sticky-notes:refresh`))}},JM={title:`Move to Onboarding`,bodyText:`Are you sure you want to move this candidate to onboarding?`,okText:`Yes`,cancelText:`No`,width:420,successMessage:`Moved to onboarding successfully`,successNavigate:`/onboarding`,fields:[{name:`sendOnboardingEmail`,type:`priority-checkbox`,checkboxLabel:`Send Onboarding Email`}]},YM={submit:async(e,t)=>{await ye({submissionId:t.selectedRecords?.[0]?.submissionId,isMail:e.sendOnboardingEmail})}};function XM(e){return Array.isArray(e)?e[e.length-1]??{}:e&&typeof e==`object`?e:{}}var ZM={USD:`$`,INR:`₹`,EUR:`€`,GBP:`£`};function QM(e,t,n){let r=XM(e?.[t])[n];if(r!=null&&r!==``)return r;let i=e?.[`${t}.${n}`];return i!=null&&i!==``?i:void 0}function $M(e){let t=e.selectedRecords?.[0]??{},n=QM(t,`candidateRate`,`candidateAcceptedRate`)??QM(t,`candidateBudget`,`candidateBudgetStart`);if(n===void 0||Number(n)===0)return null;let r=QM(t,`candidateRate`,`candidateAcceptedCurrency`)??QM(t,`candidateBudget`,`candidateBudgetCurrency`);return{amount:n,symbol:QM(t,`candidateRate`,`candidateAcceptedCurrencySymbol`)??QM(t,`candidateBudget`,`candidateBudgetCurrencySymbol`)??ZM[String(r??``).toUpperCase()]??(r||`$`),unit:QM(t,`candidateRate`,`candidateAcceptedPayUnit`)??QM(t,`candidateBudget`,`candidateBudgetUnit`)??``}}var eN={title:`Approve Rate`,okText:`Approve`,width:520,className:`medium-modal`,successMessage:`Rate approved`,getBodyText:(e,t,n,r,i)=>{let a=$M(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=$M(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`}]}]},tN={submit:async(e,t)=>{let n=t.selectedIds[0];if(await be(n,{candidateProposedRate:e.candidateProposedRate,candidateProposedRateCurrency:e.candidateProposedRateCurrency,candidateProposedRateUnit:e.candidateProposedRateUnit,submitVia:e.submitVia}),e.submitVia===`VMS`)try{await xe(n)}catch{c.message.warning(`Approved. VMS notification could not be sent — use Send Mail to notify the client.`)}else c.message.info(`Approved — use Send Mail to notify the client.`)}};async function nN(e,n={}){let r=t.u();if(!r){let e=Error(`Authentication required`);throw e.status=401,e}let i=await fetch(`${t.D}${e}`,{...n,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${r}`,...n.headers}});if(i.status===401&&t.h(),!i.ok){let e=Error(`API ${i.status}: ${i.statusText}`);throw e.status=i.status,e}return i.json()}async function rN(e){let t=await nN(`/mail-form?${new URLSearchParams({submissionId:e,submissionType:`manager`}).toString()}`);return t.data??t}function iN(...e){return e.map(e=>e==null?``:String(e).trim()).find(Boolean)??``}var aN=(e,t)=>!!e&&e.toLowerCase()===iN(t).toLowerCase();function oN(e,t,n){let r=iN(t.submittedBy);return iN(aN(r,n)||aN(r,e.submitSource)||aN(r,e.supplierName)||aN(r,e.source)||aN(r,e.candidateSource)?``:r,e.recruitingUserName,e.recruitingUserEmail,e.signatureEmail)}function sN(e,t={}){let n=yy(e,t.employerName);return{client:t.clientName??e.clientName,role:t.jobTitle??e.jobTitle??e.designation,reqId:t.reqId??e.jobClientRefrenceId??e.mspReqId??e.submissionId,name:t.candidateName||[e.firstName,e.lastName].filter(Boolean).join(` `)||e.candidateFullName,location:t.jobLocation??e.city??e.currentLocation??e.jobLocation,vendor:n,submittedBy:oN(e,t,n),submittedAt:t.createdAt??e.createdAt,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function cN(e){return Array.isArray(e)?e[e.length-1]:e}function lN(e={}){let t=cN(e?.proposedRate)?.candidateProposedRate??e?.candidateProposedRate??e?.proposedRateValue,n=Number(t);return Number.isFinite(n)?n:0}function uN(e,t={}){let n=cN((e?.record?.job??e?.job??t?.job??{})?.jobPayDetails)??{},r=e?.record?.submission??t??{},i=cN(r?.clientBudget)??r?.clientBudget??{},a=n?.clientBudgetEnd??n?.clientBudgetStart??i?.clientBudgetEnd??i?.clientBudgetStart,o=Number(a);return Number.isFinite(o)?o:0}function dN(e={}){let t=String(e?.currencyRaw??``).trim().toUpperCase(),n=String(e?.currency??``).trim();return n&&!/^[A-Z]{3}$/i.test(n)?n:t===`USD`||n.toUpperCase()===`USD`?`$`:t===`INR`||n.toUpperCase()===`INR`?`₹`:t===`EUR`||n.toUpperCase()===`EUR`?`€`:t===`GBP`||n.toUpperCase()===`GBP`?`£`:n||t}function fN(e={}){return String(e?.rateUnit??`hr`).trim().replace(/^\/+/,``)||`hr`}function pN(e,t={}){let n=Number(e);return Number.isFinite(n)?`${dN(t)}${n}/${fN(t)}`:``}function mN(e,t,n){if(n==null||n===``)return String(e??``);let r=String(e??``),i=String(n),a=!1,o=RegExp(`(<(?:td|th)[^>]*>[\\s\\S]*?${t}[\\s\\S]*?</(?:td|th)>\\s*<(?:td|th)[^>]*>)([\\s\\S]*?)(</(?:td|th)>)`,`gi`);r=r.replace(o,(e,t,n,r)=>(a=!0,`${t}${i}${r}`));let s=RegExp(`(<(?:strong|b)[^>]*>\\s*${t}\\s*:?\\s*</(?:strong|b)>\\s*)([\\s\\S]*?)(?=</(?:li|p|div)>)`,`gi`);if(r=r.replace(s,(e,t)=>(a=!0,`${t}${i}`)),!a){let e=RegExp(`(${t}\\s*:?[ \\t]*)([^<\\r\\n]*)`,`gi`);r=r.replace(e,(e,t)=>`${t}${i}`)}return r}function hN(e,t,n,r,i){let a=Number(n?.proposedRate),o=Number.isFinite(a)?a:lN(t),s=Number(n?.clientJobRate),c=Number.isFinite(s)&&s>0?s:uN(r,i),l={proposedRate:o,jobBillRate:c},u=String(e??``).replace(/{{\.?((?:proposedRate)|(?:jobBillRate))}}/g,(e,t)=>{let n=l[t];return n==null?e:String(n)});return u=mN(u,`(?:Proposed\\s*Rate|Pay\\s*Rate)`,pN(o,n)),u=mN(u,`(?:Job\\s*)?Bill\\s*Rate`,pN(c,n)),u}function gN(e){let t=e?.$oid??e?._id?.$oid??e?._id??e?.id?.$oid??e?.id??e;if(t==null||typeof t==`object`)return``;let n=String(t).trim();return/^[a-f\d]{24}$/i.test(n)?n:``}function _N(...e){for(let t of e){let e=[t?.jobId,t?.JobId,t?.job_id,t?.jobDetails?._id,t?.jobDetails?.id,t?.job?._id,t?.job?.id,t?.submission?.jobId,t?.submission?.JobId,t?.submission?.job_id,t?.submission?.jobDetails?._id,t?.submission?.jobDetails?.id,t?.submission?.job?._id,t?.submission?.job?.id,t?.recordMeta?.jobId,t?.recordMeta?.JobId,t?.recordMeta?.job_id,t?.submission?.recordMeta?.jobId,t?.submission?.recordMeta?.JobId,t?.submission?.recordMeta?.job_id].map(gN).find(Boolean);if(e)return e}return``}function vN(e){if(!e?.referralId)return{};let t=Number(e.referralRate??e.referalRate??0)||0,n=String(e.referralType??e.referalType??`RECURRING`).trim()||`RECURRING`,r=e.referralId??e.referalId;return{referralId:r,referalId:r,referralRate:t,referalRate:t,referralType:n,referalType:n,referralEnabled:!0,referalEnabled:!0,isReferralApplicable:!0,referralDetails:{referralId:r,referalId:r,referralRate:t,referalRate:t,referralType:n,referalType:n,referralEnabled:!0,referalEnabled:!0,isReferralApplicable:!0}}}function yN(e=``){return String(e??``).replace(/map\[[^\]]*(?:resume|document|attachment|file)[^\]]*\]/gi,``).replace(/<p>\s*<\/p>/gi,``).replace(/(?:<br\s*\/?>\s*){3,}/gi,`<br><br>`).trim()}function bN(...e){for(let t of e){let e=[t?.candidateId,t?.applicantId,t?.candidate?._id,t?.candidate?.id,t?.submission?.candidateId,t?.submission?.applicantId,t?.recordMeta?.candidateId,t?.recordMeta?.applicantId].map(gN).find(Boolean);if(e)return e}return``}async function xN(e){let t=e?.fileUrl??e?.downloadUrl??e?.url;if(!t)return null;let n=await fetch(t);if(!n.ok)throw Error(`Unable to load ${e?.fileName||`resume`}`);let r=await n.blob(),i=e?.fileName??e?.uploadedFileName??e?.originalName??e?.uniqueName??`resume`;return new File([r],i,{type:e?.contentType||r.type||`application/octet-stream`})}async function SN(e,r,i){let a=[],o=await n.Un(`submissions`,e,`resume`).catch(()=>({data:[]}));a.push(...o?.data??[]);let s=bN(r?.record?.submission,i,r?.record);if(!s){let n=await t.o(t.x,`/module/list?module=submissions&id=${encodeURIComponent(e)}`).catch(()=>({})),r=n?.data??n??{};s=bN((Array.isArray(r?.data)?r.data:Array.isArray(r)?r:[])[0])}if(s){let e=await n.Un(`candidates`,s,`resume`).catch(()=>({data:[]}));a.push(...e?.data??[])}let c=(await Promise.all(a.map(xN))).filter(Boolean),l=new Set;return c.filter(e=>{let t=`${e.name}:${e.size}:${e.type}`;return!l.has(t)&&(l.add(t),!0)})}function CN(e={}){return{to:(e.to??e.To??[]).map(e=>e.email??e.Email??e).filter(Boolean).join(`, `),cc:(e.cc??e.Cc??[]).map(e=>e.email??e.Email??e).filter(Boolean).join(`, `),bcc:(e.bcc??e.Bcc??[]).map(e=>e.email??e.Email??e).filter(Boolean).join(`, `),subject:e.subject??e.Subject??``,contents:yN(e.content?.value??e.Content?.Value??e.contents??e.body??``)}}function wN({context:e,selectedIds:t,selectedRecords:n,moduleName:r,onClose:i}){let a=n?.[0]??{},o=t?.[0]??Zv(a),[l,d]=(0,s.useState)(null),[f,p]=(0,s.useState)(!0),[m,h]=(0,s.useState)([]),[g,_]=(0,s.useState)(!1),[v,y]=(0,s.useState)(`vms`),[b,x]=(0,s.useState)(null),[S,C]=(0,s.useState)(null),[w,T]=(0,s.useState)(!1),[E,D]=(0,s.useState)(!1),[O,k]=(0,s.useState)(!1),[A,j]=(0,s.useState)(!1),[M,N]=(0,s.useState)({to:``,cc:``,bcc:``,subject:``,contents:``,attachments:[],showCc:!1,showBcc:!1});(0,s.useEffect)(()=>{let e=!1;return Gy(o,a).then(t=>{e||d(t)}).catch(t=>{e||(c.message.error(t?.message??`Unable to load finance details`),d({record:{submission:a},lookups:{},display:{}}))}).finally(()=>{e||p(!1)}),()=>{e=!0}},[o]),(0,s.useEffect)(()=>{let e=!1;return eb().then(t=>{e||h(t)}).catch(()=>{}),()=>{e=!0}},[]);let P=async()=>{if(b){if(v===`mail`){_(!1),D(!0),k(!0);try{let[e,t]=await Promise.all([rN(o).then(CN),SN(o,l,a).catch(e=>(console.warn(`Unable to resolve resume attachment:`,e),[]))]),n=l?.record?.submission??a;N({to:hN(e.to,n,b,l,a),cc:hN(e.cc,n,b,l,a),bcc:hN(e.bcc,n,b,l,a),subject:hN(e.subject,n,b,l,a),contents:hN(e.contents,n,b,l,a),attachments:t,showCc:!!e.cc,showBcc:!!e.bcc})}catch(e){c.message.error(e?.message??`Unable to prepare approval mail`)}finally{k(!1)}return}T(!0);try{await be(o,{candidateProposedRate:b.proposedRate,candidateProposedRateCurrency:b.currencyRaw??b.currency,candidateProposedRateUnit:b.rateUnit,submitVia:`VMS`,...vN(S)}),c.message.success(`Submission approved`),_(!1),x(null),C(null),i?.({success:!0})}catch(e){c.message.error(e?.message??`Unable to approve submission`)}finally{T(!1)}}},F=String(M.contents??``).replace(/<[^>]*>/g,` `).replace(/ /gi,` `).trim(),I=/{{\s*\.?[\w.]+\s*}}/.test(`${M.subject??``} ${M.contents??``}`),L=``;O||(sk(M.to).length===0?L=`Add at least one recipient in To.`:dk(M.to)?dk(M.cc)?dk(M.bcc)?String(M.subject??``).trim()?F?I&&(L=`The message still contains unfilled placeholders ({{…}}). Fill them in before sending.`):L=`The message body is empty.`:L=`Enter a subject.`:L=`One or more Bcc addresses are not valid e-mail addresses.`:L=`One or more Cc addresses are not valid e-mail addresses.`:L=`One or more To addresses are not valid e-mail addresses.`);let R=!O&&!L,z=async()=>{if(!b||!R||A)return;j(!0);let e={candidateProposedRate:b.proposedRate,candidateProposedRateCurrency:b.currencyRaw??b.currency,candidateProposedRateUnit:b.rateUnit};try{await be(o,{...e,submitVia:`VMS`,...vN(S)});let t=_N(l?.record,a);if(!t)c.message.warning(`Submission approved, but job details were not available to send mail`);else try{await Tn({jobId:t,toMail:sk(M.to),ccMail:sk(M.cc),bccMail:sk(M.bcc),subject:M.subject,contents:M.contents,attachments:M.attachments??[]}),c.message.success(`Approval mail sent and submission approved`)}catch(e){c.message.warning(e?.message?`Submission approved, but mail was not sent: ${e.message}`:`Submission approved, but mail was not sent`)}D(!1),x(null),C(null),i?.({success:!0})}catch(e){c.message.error(e?.message??`Unable to send approval mail`)}finally{j(!1)}},B=(0,s.useMemo)(()=>({submissionApprove:async({computed:e,referral:t})=>{x(e),C(t??null),y(`vms`),_(!0)},submissionReject:async()=>{e?.navigate?.(`/popup/reject`,{replace:!0,state:{background:e?.background??null,selectedIds:t,selectedRecords:n,moduleName:r}})}}),[e,t,n,r]);return f||!l?(0,u.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,u.jsx)(c.Spin,{size:`large`})}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Py,{type:Tv,record:l.record,lookups:l.lookups,identity:sN(a,l.display),referralOptions:m,currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:B,onClose:()=>i?.(),variant:`popup`}),(0,u.jsx)(c.Modal,{title:`Choose approval method`,open:g,okText:`Approve`,confirmLoading:w,onOk:P,onCancel:()=>{w||(_(!1),x(null),C(null))},children:(0,u.jsxs)(c.Radio.Group,{value:v,onChange:e=>y(e.target.value),style:{display:`grid`,gap:12},children:[(0,u.jsx)(c.Radio,{value:`vms`,children:`Via VMS`}),(0,u.jsx)(c.Radio,{value:`mail`,children:`Via Mail`})]})}),(0,u.jsx)(c.Drawer,{open:E,placement:`right`,onClose:()=>{A||D(!1)},closable:!1,rootClassName:`mail-popup`,width:620,maskClosable:!1,footer:(0,u.jsxs)(`div`,{className:`mail-popup__footer`,children:[L&&(0,u.jsx)(`span`,{role:`alert`,style:{color:`var(--color-error, #cf1322)`,marginRight:`auto`,fontSize:13},children:L}),(0,u.jsx)(c.Button,{onClick:()=>D(!1),disabled:A,children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,loading:A,disabled:!R,onClick:z,children:`Send`})]}),children:O?(0,u.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,u.jsx)(c.Spin,{size:`large`})}):(0,u.jsx)(Dk,{value:M,onChange:N,moduleName:`submissions`,ready:!O,title:`Submit Via Mail`,contextRecords:[l.record?.submission??a],requiredTo:!0,requiredSubject:!0,requiredBody:!0})})]})}wN.propTypes={context:p.default.object,selectedIds:p.default.array,selectedRecords:p.default.array,moduleName:p.default.string,onClose:p.default.func};var TN={title:`Manager Approve`,width:780,className:`fa-modal manager-approve-modal`,component:wN},EN={submit:async()=>{}};function DN(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 ON(e){return String(e??``).toLowerCase().replace(/\b\w/g,e=>e.toUpperCase())}function kN({selectedIds:e,selectedRecords:t,onClose:r}){let i=t?.[0]??{},a=e?.[0]??Zv(i),[o,l]=(0,s.useState)(null),[d,f]=(0,s.useState)(``),[p,m]=(0,s.useState)(!0);(0,s.useEffect)(()=>{let e=!1;return m(!0),Promise.all([Gy(a,i),n.In(`submission`,a).catch(()=>[])]).then(([t,n])=>{if(e)return;let r=DN(n);f(Zv(t?.meta?.workforceEngagementId??i?.onboarding?.workforceEngagementId??i?.workforceEngagementId));let a=t?.meta?.rejectReasonComments||r?.activityComments||``;l({...t,record:{...t.record,submission:{...t.record.submission,cfoRejectionReason:a?ON(a):``,cfoRejectedAt:t?.meta?.rejectedAt??r?.activityTime??null}}})}).catch(t=>{e||(c.message.error(t?.message??`Unable to load finance details`),l({record:{submission:i},lookups:{},display:{}}))}).finally(()=>{e||m(!1)}),()=>{e=!0}},[a]);let h=(0,s.useMemo)(()=>({submissionReapproveSend:async({computed:e})=>{await Se(d,{submissionId:a,billRate:e.proposedRate,payRate:e.employerRate,currency:e.currencyRaw??e.currency,rateUnit:e.rateUnit,vmsPercent:e.clientVmsPercent}),await be(a,{candidateProposedRate:e.proposedRate,candidateProposedRateCurrency:e.currencyRaw??e.currency,candidateProposedRateUnit:e.rateUnit,submitVia:`Mail`,context:`resend`}),c.message.success(`Re-approved and sent for CFO approval`),r?.({success:!0})}}),[a,d,r]);return p||!o?(0,u.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,padding:48},children:(0,u.jsx)(c.Spin,{size:`large`})}):(0,u.jsx)(Py,{type:kv,record:o.record,lookups:o.lookups,identity:sN(i,o.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:h,onClose:()=>r?.(),variant:`popup`})}kN.propTypes={selectedIds:p.default.array,selectedRecords:p.default.array,onClose:p.default.func};var AN={title:`Re-Approve`,width:780,className:`fa-modal manager-approve-modal`,component:kN},jN={submit:async()=>{}},MN=[{id:1,name:`Re-Submission`},{id:2,name:`Candidate doesn't fit into the profile`},{id:3,name:`Incomplete candidate details - (Re-Submission)`}],NN={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:MN.map(e=>({label:e.name,value:e.id}))},{name:`rejectReasonComments`,label:`Comments`,type:`textarea`,required:!0,rows:4}]},PN={submit:async(e,t)=>{let n=MN.find(t=>String(t.id)===String(e.rejectReason));await Ce({submissionId:t.selectedIds[0],rejectReasonId:e.rejectReason,rejectReason:n?.name??``,rejectReasonComments:e.rejectReasonComments})}},FN={delete:Pj,"quick-submit":fM,"add-notes":pM,"tag-to-job":yM,"change-status":MM,"remove-from-shortlist":FM,"add-to-groups":LM,"self-assign":VM,"others-assign":WM,"sticky-notes":KM,"move-to-onboarding":JM,"approve-rate":eN,"manager-approve":TN,"manager-reapprove":AN,reject:NN},IN={delete:Fj,"quick-submit":dM,"add-notes":gM,"tag-to-job":jM,"change-status":PM,"remove-from-shortlist":IM,"add-to-groups":RM,"self-assign":HM,"others-assign":GM,"sticky-notes":qM,"move-to-onboarding":YM,"approve-rate":tN,"manager-approve":EN,"manager-reapprove":jN,reject:PN};function LN(e){let t=e?.data??e;return Array.isArray(t)?t:t?.data??t?.rows??t?.records??t?.items??t?.list??[]}function RN(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 zN(e){let t=String(RN(e,`isDeleted`,`deleted`)).toLowerCase(),n=String(RN(e,`assignmentStatus`,`status`)).toLowerCase();return t!==`true`&&t!==`1`&&![`removed`,`inactive`,`deleted`].includes(n)}function BN(e){let t=RN(e,`candidateName`,`candidate_name`,`fullName`,`name`);return t?String(t):[RN(e,`firstName`,`first_name`),RN(e,`lastName`,`last_name`)].filter(Boolean).join(` `)||`Unnamed candidate`}function VN(e){return String(RN(e,`candidateId`,`candidate_id`,`candidate._id`,`candidate.id`))}function HN(e){return String(RN(e,`workforceEngagementId`,`engagementId`,`_id`,`id`))}function UN(e){return String(RN(e,`batchName`,`name`,`title`,`batch_name`))}function WN({open:e=!0,context:r={},onClose:i}){let[a,o]=(0,s.useState)([]),[l,d]=(0,s.useState)([]),[f,p]=(0,s.useState)(``),[m,h]=(0,s.useState)(!0),[g,_]=(0,s.useState)(!1),[v,y]=(0,s.useState)(``),[b,x]=(0,s.useState)(new Map),S=String(r.selectedIds?.[0]??r.selectedRecords?.[0]?._id??r.selectedRecords?.[0]?.id??r.batchId??``);(0,s.useEffect)(()=>{if(!e)return;let t=!1;return Promise.resolve().then(()=>(t||h(!0),Promise.all([n.Kn(`onboarding`,200,0),n.Kn(`batchCandidates`,1e3,0).catch(()=>[])]))).then(([e,n])=>{t||(o(LN(e)),x(new Map(LN(n).filter(zN).map(e=>[String(RN(e,`candidateId`,`candidate_id`)),e]).filter(([e])=>e))))}).catch(e=>{t||y(e.message||`Unable to load onboarding candidates`)}).finally(()=>{t||h(!1)}),()=>{t=!0}},[e]);let C=(0,s.useMemo)(()=>{let e=f.trim().toLowerCase();return e?a.filter(t=>[BN(t),RN(t,`email`,`candidateEmail`,`candidate_email`),RN(t,`status`,`onboardingStatus`,`onboarding_status`)].some(t=>String(t).toLowerCase().includes(e))):a},[a,f]);async function w(){if(!S){y(`Select a batch before adding candidates`);return}let e=a.filter(e=>l.includes(HN(e)));if(!e.length)return;let o=e.map(e=>({record:e,assignment:b.get(VN(e))})).filter(e=>e.assignment);if(o.length){let e=o.map(({record:e})=>BN(e)).join(`, `);y(`${e} ${o.length===1?`is`:`are`} already added to a batch. Each candidate can be added to only one batch.`);return}_(!0),y(``);try{let{userId:a}=t.s(),o=UN(r.selectedRecords?.[0])||UN(r);await Promise.all(e.map(e=>n.Or(`batchCandidates`,{schemaVersion:1,batchId:S,batchName:o,candidateId:VN(e),workforceEngagementId:HN(e),source:`ONBOARDING`,assignmentStatus:`ASSIGNED`,assignedAt:new Date().toISOString(),assignedBy:a??0,isDeleted:!1}))),c.message.success(`${e.length} candidate${e.length===1?``:`s`} added to the batch`),i?.({refresh:!0})}catch(e){y(e.message||`Unable to add candidates to the batch`)}finally{_(!1)}}return(0,u.jsxs)(c.Modal,{open:e,title:`Add Candidate to Batch`,okText:`Add`,onOk:w,onCancel:()=>i?.(),okButtonProps:{disabled:l.length===0||!S,loading:g},cancelButtonProps:{disabled:g},closable:!g,maskClosable:!1,width:760,centered:!0,children:[v&&(0,u.jsx)(c.Alert,{type:`error`,showIcon:!0,message:v,style:{marginBottom:12}}),(0,u.jsx)(c.Input.Search,{allowClear:!0,placeholder:`Search onboarding candidates`,value:f,onChange:e=>p(e.target.value),style:{marginBottom:12}}),(0,u.jsx)(c.Table,{rowKey:e=>HN(e),columns:[{title:`Candidate`,key:`candidate`,render:(e,t)=>BN(t)},{title:`Email`,key:`email`,render:(e,t)=>RN(t,`email`,`candidateEmail`,`candidate_email`)||`—`},{title:`Onboarding status`,key:`status`,render:(e,t)=>RN(t,`status`,`onboardingStatus`,`onboarding_status`)||`—`}],dataSource:C,loading:m,size:`small`,pagination:{pageSize:10,showSizeChanger:!1},rowSelection:{selectedRowKeys:l,onChange:d,getCheckboxProps:e=>{let t=b.get(VN(e));return{disabled:!VN(e)||!HN(e)||!!t,title:t?`Candidate is already added to a batch`:void 0}}},locale:{emptyText:m?`Loading candidates…`:`No onboarding candidates found`}})]})}var GN={text:`input`,string:`input`,textarea:`textarea`,date:`date-picker`,datepicker:`date-picker`,multiselect:`multi-select`,lookup:`search-select`};function KN(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:GN[String(e.type??`text`).toLowerCase()]??e.type??`input`,required:e.required??e.req===1,options:(e.options??[]).map(e=>({label:e.label??e.name??e.value,value:e.value??e.id??e.label}))}))),n=qN(e.successNavigate);return{title:e.label,fields:t,...n?{successNavigate:n}:{}}}function qN(e){let t=String(e??``).trim();return!t||!t.startsWith(`/`)||t.startsWith(`//`)||/^[a-z][a-z0-9+.-]*:/i.test(t)?null:t}function JN(e,t=[]){if(!e||!Array.isArray(t)||!t.length)return e;let n=new Map(t.filter(e=>e?.name).map(e=>[String(e.name),e]));return n.size?{...e,fields:(e.fields??[]).map(r=>{let i=n.get(String(r.name))??n.get(String(r.label))??(n.size===1&&(e.fields??[]).length===1?t[0]:null);if(!i)return r;let{name:a,...o}=i;return{...r,...o}})}:e}function YN({apiMap:e={},extraConfigs:r={}}){let i=(0,s.useMemo)(()=>({...IN,...e}),[e]),a=(0,s.useMemo)(()=>{let e={...FN};return Object.entries(r).forEach(([t,n])=>{e[t]={...e[t]??{},...n}}),e},[r]),{popupKey:o}=(0,f.useParams)(),c=(0,f.useNavigate)(),{state:l={}}=(0,f.useLocation)(),[d,p]=(0,s.useState)({key:``,config:null});(0,s.useEffect)(()=>{let e=!1;if(!o||!l.moduleName)return;let t=`${l.moduleName}:${o}`;return n.ei(l.moduleName,`popup`,o).then(n=>{e||p({key:t,config:KN(n[0])})}).catch(()=>{e||p({key:t,config:null})}),()=>{e=!0}},[o,l.moduleName]);let m=(0,s.useMemo)(()=>{let e=a[o],t=`${l.moduleName}:${o}`,n=d.key===t?d.config:null;return JN(n?{...e,...n}:e,l.popupAction?.popupFieldOverrides)},[d,a,o,l.moduleName,l.popupAction?.popupFieldOverrides]),h=(0,s.useMemo)(()=>({selectedIds:l.selectedIds??[],selectedRecords:l.selectedRecords??[],moduleName:l.moduleName??``,navigate:c,background:l.background??null,...l.popupContext??{}}),[c,l.selectedIds,l.selectedRecords,l.moduleName,l.popupContext,l.background]),g=(0,s.useMemo)(()=>{let e=l.popupAction;return e?.apiPath?{submit:(n,r)=>{let i=String(e.apiMethod||`POST`).toUpperCase();return t.o(t.x,e.apiPath.startsWith(`/`)?e.apiPath:`/${e.apiPath}`,{method:i,body:[`GET`,`DELETE`].includes(i)?void 0:JSON.stringify({...n,selectedIds:r.selectedIds,selectedRecords:r.selectedRecords,moduleName:r.moduleName})})}}:{}},[l.popupAction]),_=e=>{let t=l.background;if(e?.success&&m?.successNavigate){c(m.successNavigate,{replace:!0,state:{refreshTimestamp:Date.now()}});return}if(e?.success&&t?.pathname){c(`${t.pathname}${t.search??``}`,{replace:!0,state:{...t.state??{},refreshTimestamp:Date.now()}});return}c(-1)};return o===`add-batch-candidate`?(0,u.jsx)(WN,{open:!0,context:h,onClose:_}):(0,u.jsx)(Nj,{open:!0,config:m,context:h,onClose:_,api:{...i[o]??{},...g}})}var XN={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`}]},ZN={getVendorList:({jobId:e,limit:t,offset:n,type:r})=>bn({jobId:e,limit:t,offset:n,sortBy:`new`,type:r}),getMailDetails:e=>xn(e),submit:({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})=>Tn({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})},QN=XN.vendorColumns.map(e=>({...e,render:e=>e||`-`}));function $N(){let e=(0,f.useNavigate)(),t=(0,f.useLocation)(),{selectedIds:n=[],selectedRecords:r=[],recipients:i=[],subject:a=``,onSend:o,moduleName:d=``,popupAction:p={}}=t.state??{},m=n[0]??r[0]?._id??r[0]?.id,[h,g]=(0,s.useState)({to:i.join(`, `),cc:``,bcc:``,subject:a,contents:``,showCc:!1,showBcc:!1}),[_,v]=(0,s.useState)(!m),[y,b]=(0,s.useState)(XN.defaultTab),[x,S]=(0,s.useState)(``),[C,w]=(0,s.useState)([]),[T,E]=(0,s.useState)(0),[D,O]=(0,s.useState)(0),[k,A]=(0,s.useState)(0),[j,M]=(0,s.useState)(1),[N,P]=(0,s.useState)(XN.defaultPageSize),[F,I]=(0,s.useState)(!1),[L,R]=(0,s.useState)([]);(0,s.useEffect)(()=>{if(!m)return;let e=!1;I(!0);let t=x?100:N,n=x?0:(j-1)*N;return ZN.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,s.useEffect)(()=>{m&&ZN.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,s.useMemo)(()=>L.map(e=>C.find(t=>t.vendorId===e)?.vendorEmail??``).filter(Boolean),[L,C]),B=(0,s.useMemo)(()=>({...h,bcc:[...new Set([...sk(h.bcc),...z])].join(`, `),showBcc:h.showBcc||z.length>0}),[h,z]);function V(e){let t=new Set(z);g({...e,bcc:sk(e.bcc).filter(e=>!t.has(e)).join(`, `)})}let H=(sk(B.to).length||sk(B.bcc).length)&&dk(B.to)&&dk(B.cc)&&dk(B.bcc)&&B.subject.trim(),ee=e=>e===`myVendor`?T:D;function te(){e(-1)}function ne(){H&&ZN.submit({jobId:m,toMail:sk(B.to),ccMail:sk(B.cc),bccMail:sk(B.bcc),subject:B.subject,contents:B.contents}).then(t=>{t?.status===!0?(c.message.success(t?.data||`Mail sent successfully.`),typeof o==`function`&&o({...B,message:B.contents,selectedIds:n}),e(-1)):c.message.error(t?.message||t?.data||`Failed to send mail. Please try again.`)}).catch(e=>{c.message.error(e?.message||`Failed to send mail. Please try again.`)})}let re=(0,s.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,u.jsx)(c.Drawer,{open:!0,placement:`right`,onClose:te,closable:!1,rootClassName:`vendor-share`,width:`95%`,footer:(0,u.jsxs)(`div`,{className:`vendor-share__footer`,children:[(0,u.jsx)(c.Button,{onClick:te,children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,disabled:!H,onClick:ne,children:`Send`})]}),children:(0,u.jsxs)(`div`,{className:`vendor-share__body`,children:[(0,u.jsxs)(`div`,{className:`vendor-share__left`,children:[(0,u.jsxs)(`div`,{className:`vendor-share__vendor-header`,children:[(0,u.jsxs)(`div`,{className:`vendor-share__vendor-header-row`,children:[(0,u.jsx)(c.Button,{type:`text`,icon:(0,u.jsx)(l.CloseOutlined,{}),onClick:te,size:`small`,style:{marginRight:8}}),(0,u.jsx)(`span`,{className:`dynamic-popup__header-icon-box`,children:(0,u.jsx)(l.TeamOutlined,{})}),(0,u.jsx)(`span`,{className:`dynamic-popup__header-label`,children:`Vendor List`}),(0,u.jsxs)(`div`,{className:`vendor-share__vendor-search`,children:[(0,u.jsx)(l.SearchOutlined,{className:`vendor-share__search-icon`}),(0,u.jsx)(c.Input,{variant:`borderless`,placeholder:`Search vendor`,value:x,onChange:e=>{S(e.target.value),M(1)},className:`vendor-share__search-input`})]})]}),(0,u.jsx)(`div`,{className:`vendor-share__vendor-tabs`,children:XN.vendorTabs.map(e=>(0,u.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,` (`,ee(e.key),`)`]},e.key))})]}),(0,u.jsx)(`div`,{className:`vendor-share__vendor-table-wrapper`,children:(0,u.jsx)(c.Table,{rowKey:e=>e.vendorId,columns:QN,dataSource:re,loading:F,pagination:!1,size:`small`,rowSelection:{selectedRowKeys:L,onChange:e=>{e.length>XN.maxVendorSelect||R(e)}},scroll:{y:`calc(100vh - 340px)`}})}),(0,u.jsx)(`div`,{className:`vendor-share__vendor-footer`,children:(0,u.jsx)(Be,{current:j,pageSize:N,total:k,onChange:e=>M(e),onPageSizeChange:e=>P(e)})})]}),(0,u.jsx)(`div`,{className:`vendor-share__right`,children:(0,u.jsx)(Dk,{value:B,onChange:V,moduleName:d,defaultTemplateId:p.defaultTemplateId??t.state?.defaultTemplateId??``,ready:_,contextRecords:r,title:`Share`,hint:`Select vendors or add email addresses`,bccHint:`Vendor emails are added automatically`,afterBcc:L.length>0?(0,u.jsxs)(`div`,{className:`vendor-share__selected-count`,children:[L.length,` / `,XN.maxVendorSelect,` Vendors selected`]}):null})})]})})}var eP={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].*$/},tP={SINGLE_FILE_COUNT:1,MULTI_FILE_COUNT:5,MAX_FILE_SIZE:2,ALLOWED_FILE_TYPES:[`image/jpeg`,`image/png`,`application/pdf`]},nP={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 ${tP.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.`},rP={FIRST_NAME_MIN:3,FIRST_NAME_MAX:30},iP={REMARKS_MIN:10,REMARKS_MAX:250},aP={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)}`}},oP={required:(e=`Field`)=>({required:!0,message:nP.REQUIRED(e)}),email:()=>({pattern:eP.EMAIL,message:nP.INVALID_EMAIL}),phone:()=>({pattern:eP.PHONE,message:nP.INVALID_PHONE}),password:()=>({pattern:eP.PASSWORD,message:nP.INVALID_PASSWORD}),alphabets:()=>({pattern:eP.ALPHABETS,message:nP.INVALID_ALPHABETS}),alphanumeric:()=>({pattern:eP.ALPHANUMERIC,message:nP.INVALID_ALPHANUMERIC}),number:()=>({pattern:eP.NUMBER,message:nP.INVALID_NUMBER}),url:()=>({pattern:eP.URL,message:nP.INVALID_URL}),candidateId:(e=`ID`)=>({pattern:eP.CANDIDATE_ID,message:nP.INVALID_CANDIDATE_ID(e)}),remarks:()=>({pattern:eP.REMARKS,message:nP.INVALID_REMARKS,REMARKS_MIN:`Remarks must be at least ${iP.REMARKS_MIN} characters.`,REMARKS_MAX:`Remarks must not exceed ${iP.REMARKS_MAX} characters.`}),designation:()=>({pattern:eP.DESIGNATION,message:nP.INVALID_DESIGNATION}),dob:(e=!0)=>({validator:(t,n)=>{if(!n)return e?Promise.reject(Error(`Date of Birth is required.`)):Promise.resolve();if(!eP.DOB.test(n))return Promise.reject(Error(nP.INVALID_DOB));let r=(0,d.default)(n,`MM/DD/YYYY`,!0);if(!r.isValid())return Promise.reject(Error(nP.INVALID_DOB));let i=(0,d.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:eP.LINKEDIN,message:nP.INVALID_LINKEDIN}),companyName:()=>({pattern:eP.COMPANY_NAME,message:nP.INVALID_COMPANY_NAME}),firstName:()=>({pattern:eP.FIRST_NAME,message:nP.INVALID_FIRST_NAME,FIRST_NAME_MIN:`First Name must be at least ${rP.FIRST_NAME_MIN} characters.`,FIRST_NAME_MAX:`First Name must not exceed ${rP.FIRST_NAME_MAX} characters.`}),firstNameMinLength:()=>({min:rP.FIRST_NAME_MIN,message:nP.FIRST_NAME_MIN}),firstNameMaxLength:()=>({max:rP.FIRST_NAME_MAX,message:nP.FIRST_NAME_MAX}),remarksMinLength:()=>({min:iP.REMARKS_MIN,message:nP.REMARKS_MIN}),remarksMaxLength:()=>({max:iP.REMARKS_MAX,message:nP.REMARKS_MAX}),fullName:()=>({pattern:eP.FULL_NAME,message:nP.INVALID_FULL_NAME}),noSpaces:()=>({pattern:eP.NO_SPACES,message:nP.NO_SPACES_ALLOWED}),startsWithCapital:()=>({pattern:eP.STARTS_WITH_CAPITAL,message:nP.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<=tP.MAX_FILE_SIZE))return c.message.error(nP.INVALID_FILE_SIZE),Promise.reject(Error(nP.INVALID_FILE_SIZE));if(!tP.ALLOWED_FILE_TYPES.includes(t.type))return Promise.reject(Error(nP.INVALID_FILE_TYPE))}return Promise.resolve()}}),singleFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>tP.SINGLE_FILE_COUNT)return Promise.reject(Error(nP.SINGLE_FILE_ONLY));let n=t[0];return n.size/1024/1024<tP.MAX_FILE_SIZE?tP.ALLOWED_FILE_TYPES.includes(n.type)?Promise.resolve():Promise.reject(Error(nP.INVALID_FILE_TYPE)):Promise.reject(Error(nP.INVALID_FILE_SIZE))}}),multiFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>tP.MULTI_FILE_COUNT)return Promise.reject(Error(nP.INVALID_FILE_COUNT));for(let e of t){if(!(e.size/1024/1024<tP.MAX_FILE_SIZE))return Promise.reject(Error(nP.INVALID_FILE_SIZE));if(!tP.ALLOWED_FILE_TYPES.includes(e.type))return Promise.reject(Error(nP.INVALID_FILE_TYPE))}return Promise.resolve()}})},sP={beforeUpload:e=>[`image/jpeg`,`image/png`,`application/pdf`].includes(e.type)?e.size/1024/1024<=2?!1:(c.message.error(`File upload must be 2 MB below.`),c.Upload.LIST_IGNORE):(c.message.error(`Only JPG, PNG and PDF files are allowed.`),c.Upload.LIST_IGNORE)},cP=()=>{let[e]=c.Form.useForm();return(0,u.jsx)(`div`,{style:{padding:24},children:(0,u.jsxs)(c.Form,{form:e,layout:`vertical`,onFinish:e=>{console.log(`Form Values:`,e)},autoComplete:`off`,children:[(0,u.jsxs)(c.Row,{gutter:16,children:[(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Email`,name:`email`,rules:[oP.required(`Email`),oP.email()],children:(0,u.jsx)(c.Input,{})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Phone Number`,name:`phone`,rules:[oP.required(`Phone Number`),oP.phone()],validateTrigger:[`onBlur`,`onChange`],children:(0,u.jsx)(c.Input,{maxLength:10,onChange:t=>{e.setFieldsValue({phone:aP.phoneFormatter(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Password`,name:`password`,rules:[oP.required(`Password`),oP.password()],children:(0,u.jsx)(c.Input.Password,{})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Full Name`,name:`fullName`,rules:[oP.required(`Full Name`),oP.alphabets(),oP.firstNameMinLength(),oP.firstNameMaxLength()],children:(0,u.jsx)(c.Input,{onChange:t=>{e.setFieldsValue({fullName:aP.firstNameFormatter(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Username`,name:`username`,rules:[oP.required(`Username`),oP.alphanumeric()],children:(0,u.jsx)(c.Input,{onChange:t=>{e.setFieldsValue({username:aP.removeExtraSpaces(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Website URL`,name:`website`,rules:[oP.required(`Website URL`),oP.url()],children:(0,u.jsx)(c.Input,{onChange:t=>{e.setFieldsValue({website:aP.removeExtraSpaces(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`MSP Req ID`,name:`mspreqID`,rules:[oP.required(`MSP Req ID`),oP.candidateId(`MSP Req ID`)],children:(0,u.jsx)(c.Input,{onChange:t=>{e.setFieldsValue({mspreqID:aP.removeExtraSpaces(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Candidate ID`,name:`candidateId`,rules:[oP.required(`Candidate ID`),oP.candidateId(`Candidate ID`)],children:(0,u.jsx)(c.Input,{onChange:t=>{e.setFieldsValue({candidateId:aP.removeExtraSpaces(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:24,children:(0,u.jsx)(c.Form.Item,{label:`Remarks`,name:`remarks`,rules:[oP.required(`Remarks`),oP.remarks(),oP.remarksMinLength(),oP.remarksMaxLength()],children:(0,u.jsx)(c.Input.TextArea,{rows:4})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Designation`,name:`designation`,rules:[oP.required(`Designation`),oP.designation()],children:(0,u.jsx)(c.Input,{})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Date of Birth`,name:`dob`,rules:[oP.dob()],children:(0,u.jsx)(c.Input,{placeholder:`MM/DD/YYYY`,maxLength:10,onChange:t=>{e.setFieldsValue({dob:aP.dobFormatter(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Company Name`,name:`companyName`,rules:[oP.required(`Company Name`),oP.companyName()],children:(0,u.jsx)(c.Input,{})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{name:`contractType`,label:`Contract Type`,children:(0,u.jsxs)(c.Select,{showSearch:!0,allowClear:!0,filterOption:(e,t)=>(t?.label??``).toLowerCase().includes(e.toLowerCase()),children:[(0,u.jsx)(c.Select.Option,{value:`C2C`,label:`C2C`,children:`C2C`}),(0,u.jsx)(c.Select.Option,{value:`W2-Contract`,label:`W2-Contract`,children:`W2-Contract`}),(0,u.jsx)(c.Select.Option,{value:`W2-Fulltime`,label:`W2-Fulltime`,children:`W2-Fulltime`}),(0,u.jsx)(c.Select.Option,{value:`1099`,label:`1099`,children:`1099`})]})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{name:`candidateProposedRateCurrency`,label:`Currency`,children:(0,u.jsxs)(c.Select,{showSearch:!0,allowClear:!0,children:[(0,u.jsx)(c.Select.Option,{value:`$`,children:`$`}),(0,u.jsx)(c.Select.Option,{value:`₹`,children:`₹`}),(0,u.jsx)(c.Select.Option,{value:`€`,children:`€`}),(0,u.jsx)(c.Select.Option,{value:`zł`,children:`zł`}),(0,u.jsx)(c.Select.Option,{value:`£`,children:`£`}),(0,u.jsx)(c.Select.Option,{value:`kr`,children:`kr`}),(0,u.jsx)(c.Select.Option,{value:`Fr`,children:`Fr`}),(0,u.jsx)(c.Select.Option,{value:`kr`,children:`kr`})]})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Resume new`,name:`resume`,children:(0,u.jsx)(c.Upload,{beforeUpload:sP.beforeUpload,maxCount:1,children:(0,u.jsx)(c.Button,{children:`Upload Resume`})})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Documents`,name:`documents`,valuePropName:`fileList`,getValueFromEvent:e=>e?.fileList,rules:[oP.multiFileUpload()],children:(0,u.jsx)(c.Upload,{multiple:!0,beforeUpload:sP.beforeUpload,children:(0,u.jsx)(c.Button,{children:`Upload Documents`})})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Upload File`,name:`file`,valuePropName:`fileList`,getValueFromEvent:e=>e?.fileList,rules:[oP.fileUpload()],children:(0,u.jsx)(c.Upload,{beforeUpload:sP.beforeUpload,maxCount:1,children:(0,u.jsx)(c.Button,{children:`Upload`})})})})]}),(0,u.jsx)(c.Row,{children:(0,u.jsx)(c.Form.List,{name:`users`,children:(e,{add:t,remove:n})=>(0,u.jsxs)(u.Fragment,{children:[e.map(({key:e,name:t,...r})=>(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{required:!0,...r,rules:[{required:!0,message:`First name is requried`}],name:[t,`first`],children:(0,u.jsx)(c.Input,{placeholder:`First Name`})})}),(0,u.jsx)(c.Col,{span:11,children:(0,u.jsx)(c.Form.Item,{...r,required:!0,name:[t,`last`],children:(0,u.jsx)(c.Input,{placeholder:`Last Name`})})}),(0,u.jsx)(c.Col,{span:1,children:(0,u.jsx)(l.MinusCircleOutlined,{onClick:()=>n(t)})})]})),(0,u.jsx)(c.Form.Item,{children:(0,u.jsx)(c.Button,{type:`dashed`,onClick:()=>t(),block:!0,icon:(0,u.jsx)(l.PlusOutlined,{}),children:`Add field`})})]})})}),(0,u.jsxs)(c.Form.Item,{children:[(0,u.jsx)(c.Button,{type:`primary`,htmlType:`submit`,children:`Submit`}),(0,u.jsx)(c.Button,{style:{marginLeft:10},onClick:()=>e.resetFields(),children:`Reset`})]})]})})};function lP({region:e,onExit:t}){if(!e||e.isHome)return null;let n=e.label?.trim()||e.key;return(0,u.jsxs)(`div`,{role:`status`,"aria-live":`polite`,style:{position:`sticky`,top:0,zIndex:1e3,display:`flex`,alignItems:`center`,gap:12,padding:`10px 16px`,background:`linear-gradient(90deg, #7c2d12 0%, #9a3412 100%)`,color:`#fff`,fontSize:14,fontWeight:600,boxShadow:`0 2px 8px rgba(0,0,0,.25)`,borderBottom:`2px solid #fdba74`},children:[(0,u.jsx)(l.GlobalOutlined,{style:{fontSize:16,flexShrink:0}}),(0,u.jsxs)(`span`,{style:{flex:1,minWidth:0},children:[`You are administering`,` `,(0,u.jsx)(`span`,{style:{background:`rgba(255,255,255,.18)`,padding:`2px 8px`,borderRadius:4,letterSpacing:`.02em`},children:n}),` — `,`changes here affect that region only, not your own.`]}),t&&(0,u.jsxs)(`button`,{type:`button`,onClick:t,style:{display:`inline-flex`,alignItems:`center`,gap:6,background:`rgba(255,255,255,.15)`,border:`1px solid rgba(255,255,255,.45)`,color:`#fff`,borderRadius:4,padding:`4px 12px`,fontSize:13,fontWeight:600,cursor:`pointer`,flexShrink:0},children:[(0,u.jsx)(l.SwapOutlined,{}),`Back to my region`]})]})}lP.propTypes={region:p.default.shape({key:p.default.string,label:p.default.string,isHome:p.default.bool}),onExit:p.default.func},lP.defaultProps={region:null,onExit:void 0};function uP(e){return(0,u.jsx)(fx,{children:(0,u.jsx)($O,{...e})})}var{Text:dP}=c.Typography,fP=[{label:`Total Jobs`,value:1697,icon:`fileText`},{label:`Active Jobs`,value:1685,icon:`checkCircle`},{label:`My Jobs`,value:600,icon:`user`}],pP={fileText:(0,u.jsx)(l.FileTextOutlined,{}),checkCircle:(0,u.jsx)(l.CheckCircleOutlined,{}),user:(0,u.jsx)(l.UserOutlined,{}),filter:(0,u.jsx)(l.FilterOutlined,{})};function mP({stats:e=fP}){return(0,u.jsx)(c.Card,{children:(0,u.jsx)(c.Row,{gutter:[12,12],children:e.map(e=>(0,u.jsx)(c.Col,{xs:24,sm:24,md:8,lg:8,xl:8,children:(0,u.jsxs)(c.Card,{className:`stats-inner-card`,children:[(0,u.jsxs)(c.Space,{align:`center`,children:[pP[e.icon]??pP.fileText,(0,u.jsx)(dP,{children:e.label})]}),(0,u.jsx)(c.Statistic,{value:e.value})]})},e.label))})})}var{Text:hP}=c.Typography;function gP(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 _P(e){return{...e,key:e.USER_ID??e.user_id??e.userId??e.id??e._id,_name:gP(e),_email:e.email??e.EMAIL??e.user_email??``,_role:e.role_name??e.roleName??e.ROLE_NAME??``,_rawRef:e}}function vP(){let[e,t]=(0,s.useState)([]),[r,i]=(0,s.useState)(0),[a,o]=(0,s.useState)(!1),[d,f]=(0,s.useState)(1),[p,m]=(0,s.useState)(10),[h,g]=(0,s.useState)(``),_=(0,s.useCallback)(async({offset:e,limit:r,searchQuery:a}={})=>{o(!0);try{let o=await n.qr({offset:e,limit:r,searchQuery:a??``}),s=(o.users??[]).map(_P);t(s),i(o.total??s.length)}catch{c.message.error(`Failed to load users`)}finally{o(!1)}},[]);return(0,s.useEffect)(()=>{queueMicrotask(()=>{_({offset:(d-1)*p,limit:p,searchQuery:h})})},[_,d,p,h]),(0,u.jsx)(Z,{icon:(0,u.jsx)(l.TeamOutlined,{}),title:`Users`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,u.jsx)(kh,{listName:`Users`,dataSource:e,fields:[{label:`Name`,value:`_name`,width:220,render:(e,t)=>(0,u.jsxs)(`div`,{children:[(0,u.jsx)(hP,{strong:!0,style:{fontSize:13},children:e}),t._email&&(0,u.jsx)(`div`,{style:{fontSize:11,color:`var(--color-text-muted)`},children:t._email})]})},{label:`Role`,value:`_role`,width:180}],loading:a,total:r,current:d,pageSize:p,onPageChange:e=>f(e),onPageSizeChange:e=>{m(e),f(1)},onSearch:e=>{g(e),f(1)}})})}var{Text:yP}=c.Typography,bP=[{key:`job`,label:`Jobs`},{key:`candidate`,label:`Candidates`},{key:`submissions`,label:`Submissions`}],xP=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`}];function SP({field:e,index:t,onToggle:n,onReorder:r}){let i=(0,s.useRef)(null),[a,o]=(0,s.useState)(!1),[d,f]=(0,s.useState)(!1);function p(e){i.current=t,e.dataTransfer.effectAllowed=`move`,f(!0)}function m(){f(!1),o(!1)}function h(e){e.preventDefault(),o(!0)}function g(){o(!1)}function _(e){e.preventDefault(),o(!1),i.current!==null&&i.current!==t&&r(i.current,t),i.current=null}return(0,u.jsxs)(`div`,{draggable:!0,onDragStart:p,onDragEnd:m,onDragOver:h,onDragLeave:g,onDrop:_,className:`uss-field-row with-edit${a?` drag-over`:``}${d?` dragging`:``}`,children:[(0,u.jsx)(`span`,{className:`uss-drag-handle`,children:(0,u.jsx)(l.HolderOutlined,{})}),(0,u.jsxs)(`span`,{className:`uss-field-name`,children:[e.fieldName,(0,u.jsx)(`span`,{className:`uss-field-key`,children:e.fieldKey})]}),(0,u.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,u.jsx)(c.Switch,{size:`small`,checked:e.isVisible,onChange:e=>n(t,`isVisible`,e)})}),(0,u.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,u.jsx)(c.Switch,{size:`small`,checked:!!e.isEditable,onChange:e=>n(t,`isEditable`,e)})}),(0,u.jsx)(`span`,{className:`uss-toggle-cell`,children:(0,u.jsx)(c.Switch,{size:`small`,checked:!!e.ismandatory,onChange:e=>n(t,`ismandatory`,e)})})]})}function CP({team:e,configType:t}){let[r,i]=(0,s.useState)({}),[a,o]=(0,s.useState)(!1),[l,d]=(0,s.useState)({}),[f,p]=(0,s.useState)(`job`);(0,s.useEffect)(()=>{e&&(o(!0),n.Si(e,t).then(i).catch(()=>c.message.error(`Failed to load field config`)).finally(()=>o(!1)))},[e,t]);let m=r[f]??[];function h(e,t){i(n=>({...n,[e]:typeof t==`function`?t(n[e]??[]):t}))}function g(e,t,n){h(f,r=>r.map((r,i)=>i===e?{...r,[t]:n}:r))}function _(e,t){h(f,n=>{let r=[...n],[i]=r.splice(e,1);return r.splice(t,0,i),r.map((e,t)=>({...e,order:t}))})}async function v(){let r=f;d(e=>({...e,[r]:!0}));try{await n.Xi(e,r,m,t),c.message.success(`Saved`)}catch{c.message.error(`Save failed`)}finally{d(e=>({...e,[r]:!1}))}}return(0,u.jsxs)(c.Spin,{spinning:a,children:[(0,u.jsx)(c.Tabs,{size:`small`,activeKey:f,onChange:p,items:bP.map(e=>({key:e.key,label:e.label}))}),(0,u.jsxs)(`div`,{className:`uss-field-header with-edit`,children:[(0,u.jsx)(`span`,{}),(0,u.jsx)(`span`,{children:`Field`}),(0,u.jsx)(`span`,{style:{textAlign:`center`},children:`Visible`}),(0,u.jsx)(`span`,{style:{textAlign:`center`},children:`Editable`}),(0,u.jsx)(`span`,{style:{textAlign:`center`},children:`Mandatory`})]}),(0,u.jsxs)(`div`,{className:`uss-field-list`,children:[m.length===0&&!a&&(0,u.jsx)(`div`,{className:`uss-empty`,children:`No fields found.`}),m.map((e,t)=>(0,u.jsx)(SP,{field:e,index:t,onToggle:g,onReorder:_},e.fieldKey??t))]}),(0,u.jsx)(`div`,{className:`uss-modal-footer`,children:(0,u.jsxs)(c.Button,{type:`primary`,size:`small`,loading:l[f],onClick:v,children:[`Save `,bP.find(e=>e.key===f)?.label]})})]})}function wP(){let[e,t]=(0,s.useState)(null),[r,i]=(0,s.useState)(!1),[a,o]=(0,s.useState)(!1),[d,f]=(0,s.useState)(`listView`),[p,m]=(0,s.useState)([]),[h,g]=(0,s.useState)(0),[_,v]=(0,s.useState)(!1),[y,b]=(0,s.useState)(``),[x,S]=(0,s.useState)(!1),C=(0,s.useCallback)(async()=>{v(!0);try{let e=await n.Kr();m(e.teams),g(e.total)}catch{c.message.error(`Failed to load teams`)}finally{v(!1)}},[]);(0,s.useEffect)(()=>{C()},[C]);function w(e){t(e),f(`listView`),i(!0)}function T(e){t(e),b(e.teamName??``),o(!0)}async function E(){if(!y.trim()){c.message.warning(`Team name is required`);return}S(!0);try{await n.Yi(e,{teamName:y.trim(),managerId:e.managerId,memberIds:e.memberIds}),c.message.success(`Team updated`),o(!1),C()}catch{c.message.error(`Failed to update team`)}finally{S(!1)}}return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Z,{icon:(0,u.jsx)(l.TeamOutlined,{}),title:`Teams`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,u.jsx)(kh,{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,u.jsxs)(`div`,{style:{display:`flex`,gap:4},children:[(0,u.jsx)(c.Button,{size:`small`,type:`link`,onClick:()=>T(t),children:`Edit`}),(0,u.jsx)(c.Button,{size:`small`,type:`link`,onClick:()=>w(t),children:`Configure`})]})}],loading:_,total:h})}),(0,u.jsx)(c.Modal,{open:a,onCancel:()=>o(!1),title:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(l.TeamOutlined,{style:{color:`var(--color-brand)`,marginRight:6}}),`Edit Team`]}),width:420,footer:null,destroyOnClose:!0,children:(0,u.jsxs)(`div`,{className:`uss-edit-team-body`,style:{paddingTop:12},children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`div`,{className:`uss-edit-team-label`,children:`Team Name`}),(0,u.jsx)(c.Input,{value:y,onChange:e=>b(e.target.value),onPressEnter:E,placeholder:`Enter team name`})]}),(0,u.jsxs)(`div`,{className:`uss-modal-footer`,children:[(0,u.jsx)(c.Button,{onClick:()=>o(!1),children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,loading:x,onClick:E,children:`Save`})]})]})}),(0,u.jsxs)(c.Modal,{className:`uss-modal`,open:r,onCancel:()=>i(!1),title:(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,u.jsx)(l.TeamOutlined,{style:{color:`var(--color-brand)`}}),(0,u.jsxs)(`span`,{children:[`Configure: `,e?.teamName]})]}),width:720,footer:null,destroyOnClose:!0,children:[(0,u.jsx)(`div`,{style:{marginBottom:12},children:(0,u.jsx)(`div`,{className:`uss-config-toggle`,children:xP.map(e=>(0,u.jsx)(`button`,{className:`uss-config-btn${d===e.key?` active`:``}`,onClick:()=>f(e.key),children:e.label},e.key))})}),e&&(0,u.jsx)(CP,{team:e,configType:d},`${e?.teamId}-${d}`)]})]})}var TP=[`view`,`add`,`edit`,`delete`],EP={view:`View`,add:`Add`,edit:`Edit`,delete:`Delete`,sourcing:`Sourcing`,assign:`Assign`,share:`Share`,change_status:`Status`,my_jobs:`My Jobs`,all_jobs:`All Jobs`,po_msa:`PO MSA`,reApprove:`ReApprove`,sendApprove:`Send Approve`};function DP(e){return EP[e]??e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function OP(e){let t=TP.filter(t=>e.includes(t)),n=e.filter(e=>!TP.includes(e)).sort();return[...t,...n]}function kP(e){let t=new Set;return Object.values(e).forEach(({permissions:e})=>Object.keys(e??{}).forEach(e=>t.add(e))),OP([...t])}function AP(e){let t=0,n=0;return Object.entries(e).forEach(([e,{permissions:r}])=>{Object.entries(r??{}).forEach(([r,{value:i}])=>{wS(e,r)&&(n++,i===`1`&&t++)})}),{enabled:t,total:n}}function jP(e={}){if(!e||typeof e!=`object`)return e;let t=Object.keys(e).find(e=>String(e).trim().toLowerCase()===`onboarding`);if(!t)return e;let n=e[t]??{},r={...n.permissions??{}};for(let e of[`sendApprove`,`reApprove`])Object.keys(r).some(t=>t.toLowerCase()===e.toLowerCase())||(r[e]={id:0,value:`0`});return{...e,[t]:{...n,permissions:r}}}function MP({value:e,onSave:t,className:n}){let[r,i]=(0,s.useState)(!1),[a,o]=(0,s.useState)(e);(0,s.useEffect)(()=>{o(e)},[e]);function c(){i(!1);let n=a.trim();n&&n!==e?t(n):o(e)}return r?(0,u.jsx)(`input`,{autoFocus:!0,className:`perm-inline-input${n?` ${n}`:``}`,value:a,style:{width:Math.max(48,a.length*8)},onChange:e=>o(e.target.value),onBlur:c,onKeyDown:t=>{t.key===`Enter`&&c(),t.key===`Escape`&&(i(!1),o(e)),t.stopPropagation()},onClick:e=>e.stopPropagation()}):(0,u.jsxs)(`span`,{className:`perm-editable-name${n?` ${n}`:``}`,onDoubleClick:e=>{e.stopPropagation(),i(!0)},children:[e,(0,u.jsx)(l.EditOutlined,{className:`perm-name-edit-icon`})]})}function NP({entry:e,label:t,onToggle:n,onLabelSave:r}){let[i,a]=(0,s.useState)(!1),[o,d]=(0,s.useState)(t),f=e?.value===`1`,p=!!e;(0,s.useEffect)(()=>{d(t)},[t]);function m(){a(!1);let e=o.trim();e&&e!==t?r(e):d(t)}return(0,u.jsx)(c.Tooltip,{title:p?f?`Click to disable`:`Click to enable`:`Not applicable for this module`,children:(0,u.jsxs)(`div`,{className:`perm-action-pill${f?` on`:``}${p?``:` na`}`,onClick:()=>{!i&&p&&n()},children:[(0,u.jsx)(`span`,{className:`perm-action-pill-dot${f?` on`:``}`}),i?(0,u.jsx)(`input`,{autoFocus:!0,className:`perm-pill-input`,value:o,style:{width:Math.max(36,o.length*7)},onChange:e=>d(e.target.value),onBlur:m,onKeyDown:e=>{e.key===`Enter`&&m(),e.key===`Escape`&&(a(!1),d(t)),e.stopPropagation()},onClick:e=>e.stopPropagation()}):(0,u.jsx)(`span`,{className:`perm-action-pill-label`,onDoubleClick:e=>{e.stopPropagation(),a(!0)},children:t}),f&&!i&&(0,u.jsx)(l.CheckOutlined,{className:`perm-action-pill-check`})]})})}function PP({menuName:e,menuData:t,permKeys:n,onChange:r,displayName:i,actionLabels:a,onModuleLabelSave:o,onActionLabelSave:s}){let c=t?.permissions??{},l=n.filter(t=>wS(e,t)),d=l.filter(e=>c[e]?.value===`1`).length,f=l.filter(e=>c[e]).length,p=f>0&&d===f;return(0,u.jsxs)(`div`,{className:`perm-module-card${p?` all-on`:d>0&&!p?` some-on`:``}`,children:[(0,u.jsxs)(`div`,{className:`perm-module-card-header`,children:[(0,u.jsx)(MP,{value:i,onSave:t=>o(e,t),className:`perm-module-card-name`}),f>0&&(0,u.jsxs)(`span`,{className:`perm-module-card-badge${d>0?` active`:``}`,children:[d,`/`,f]})]}),(0,u.jsx)(`div`,{className:`perm-module-card-body`,children:l.map(t=>(0,u.jsx)(NP,{entry:c[t],label:a[t]??DP(t),onToggle:()=>r(e,t),onLabelSave:e=>s(t,e)},t))})]})}function FP({role:e,moduleLabels:t={},actionLabels:r={},onModuleLabelSave:i=()=>{},onActionLabelSave:a=()=>{}}){let[o,d]=(0,s.useState)({}),[f,p]=(0,s.useState)({}),[m,h]=(0,s.useState)(!1),[g,_]=(0,s.useState)(!1),[v,y]=(0,s.useState)(!1),b=n._i(e);(0,s.useEffect)(()=>{b&&(h(!0),y(!1),n.bi(b).then(e=>{let t=jP(e);d(t),p(t)}).catch(()=>c.message.error(`Failed to load permissions`)).finally(()=>h(!1)))},[b]);function x(e,t){y(!0),p(n=>{let r=n[e]??{menuId:o[e]?.menuId??0,permissions:{}},i=r.permissions?.[t]??{id:0,value:`0`};return{...n,[e]:{...r,permissions:{...r.permissions,[t]:{...i,value:i.value===`1`?`0`:`1`}}}}})}async function S(){_(!0);try{await n.qi(b,f),d(f),y(!1),c.message.success(`Permissions saved`)}catch(e){c.message.error(e?.message||`Save failed`)}finally{_(!1)}}let C=(0,s.useMemo)(()=>Object.keys(f).sort(),[f]),w=(0,s.useMemo)(()=>kP(f),[f]),{enabled:T,total:E}=(0,s.useMemo)(()=>AP(f),[f]);return(0,u.jsxs)(c.Spin,{spinning:m,children:[(0,u.jsxs)(`div`,{className:`perm-panel-header`,children:[(0,u.jsxs)(`div`,{className:`perm-panel-title`,children:[(0,u.jsx)(l.LockOutlined,{style:{color:`var(--color-brand)`,marginRight:6}}),(0,u.jsx)(`span`,{children:e?.roleName}),!m&&E>0&&(0,u.jsxs)(c.Tag,{color:`blue`,style:{marginLeft:8,fontSize:11},children:[T,`/`,E,` enabled`]})]}),(0,u.jsx)(c.Button,{type:`primary`,size:`small`,icon:(0,u.jsx)(l.UnlockOutlined,{}),loading:g,disabled:!v,onClick:S,children:`Save Changes`})]}),(0,u.jsxs)(`div`,{className:`perm-hint`,children:[(0,u.jsx)(l.InfoCircleOutlined,{className:`perm-hint-icon`}),(0,u.jsxs)(`span`,{children:[`Click a pill to toggle. `,(0,u.jsx)(`strong`,{children:`Double-click`}),` a module name or action label to rename it — labels are saved locally.`]})]}),C.length===0&&!m?(0,u.jsx)(`div`,{className:`perm-empty`,children:`No permission entries found for this role.`}):(0,u.jsx)(`div`,{className:`perm-cards-grid`,children:C.map(e=>(0,u.jsx)(PP,{menuName:e,menuData:f[e],permKeys:w,onChange:x,displayName:t[e]??e,actionLabels:r,onModuleLabelSave:i,onActionLabelSave:a},e))})]})}var{Text:IP}=c.Typography,LP=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`}];function RP(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function zP(e){return String(e||``).trim().toLowerCase()}function BP(e){return e?.key||e?.collectionName||e?.value||``}function VP(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=BP(e);if(!t)return;let o=zP(e.key||t),s=zP(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||RP(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=zP(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:RP(t),value:t,disabled:!1}))}),n}function HP(){let[e,t]=(0,s.useState)(null),[r,i]=(0,s.useState)(!1),[a,o]=(0,s.useState)(`listView`),[d,f]=(0,s.useState)([]),[p,m]=(0,s.useState)(0),[h,g]=(0,s.useState)(!1),[_,v]=(0,s.useState)([]),[y,b]=(0,s.useState)([]),[x,S]=(0,s.useState)(!1),[C,w]=(0,s.useState)(!1),T=(0,s.useMemo)(()=>_.filter(e=>!e.disabled),[_]),E=!x&&T.length===0,D=(0,s.useCallback)(async()=>{g(!0);try{let e=await n.Gr();f(e.roles),m(e.total)}catch{c.message.error(`Failed to load roles`)}finally{g(!1)}},[]),O=(0,s.useCallback)(async()=>{S(!0);try{let[e,t]=await Promise.all([n.ri(),n.Yr()]),r=VP(e.modules,t),i=new Set(r.filter(e=>!e.disabled).map(e=>e.value));v(r),b(e=>e.filter(e=>i.has(e)))}catch{c.message.error(`Failed to load seed status`)}finally{S(!1)}},[]);(0,s.useEffect)(()=>{D()},[D]),(0,s.useEffect)(()=>{O()},[O]);async function k(){if(y.length===0){c.message.warning(E?`All modules already seeded.`:`Select at least one module to seed.`);return}w(!0);try{await n.Li(y),c.message.success(`Role field config seeded`),b([]),await O()}catch(e){c.message.error(e?.message||`Seed failed`)}finally{w(!1)}}function A(e,n=`listView`){t(e),o(n),i(!0)}return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.AppstoreOutlined,{}),title:`Field Config Seed`,style:{marginBottom:12},children:[(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12,flexWrap:`wrap`},children:[(0,u.jsx)(`div`,{style:{minWidth:320,flex:1},children:(0,u.jsx)(c.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,u.jsx)(c.Button,{type:`primary`,loading:C,disabled:x||y.length===0,onClick:k,children:`Seed Field Config`})]}),(0,u.jsx)(IP,{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,u.jsx)(Z,{icon:(0,u.jsx)(l.SafetyOutlined,{}),title:`Roles`,style:{marginBottom:0},bodyStyle:{padding:0},children:(0,u.jsx)(kh,{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,u.jsxs)(c.Space,{size:2,children:[(0,u.jsx)(c.Button,{size:`small`,type:`link`,onClick:()=>A(t),children:`Configure`}),(0,u.jsx)(c.Button,{size:`small`,type:`link`,icon:(0,u.jsx)(l.LockOutlined,{}),onClick:()=>A(t,`permissions`),children:`Permissions`})]})}],loading:h,total:p})}),(0,u.jsxs)(c.Modal,{className:`uss-modal`,open:r,onCancel:()=>i(!1),title:(0,u.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,u.jsx)(l.SafetyOutlined,{style:{color:`var(--color-brand)`}}),(0,u.jsxs)(`span`,{children:[`Configure: `,e?.roleName]})]}),width:720,footer:null,destroyOnClose:!0,children:[(0,u.jsx)(`div`,{style:{marginBottom:12},children:(0,u.jsx)(`div`,{className:`uss-config-toggle`,children:LP.map(e=>(0,u.jsx)(`button`,{className:`uss-config-btn${a===e.key?` active`:``}`,onClick:()=>o(e.key),children:e.label},e.key))})}),e&&(a===`permissions`?(0,u.jsx)(FP,{role:e},e?.roleId):(0,u.jsx)(VS,{role:e,configType:a},`${e?.roleId}-${a}`))]})]})}var UP=`perm-module-labels`,WP=`perm-action-labels`;function GP(e){try{return JSON.parse(localStorage.getItem(e)??`{}`)}catch{return{}}}function KP(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function qP({label:e,onSave:t,onDelete:n,loading:r}){let[i,a]=(0,s.useState)(!1),[o,d]=(0,s.useState)(e);function f(){a(!1);let n=o.trim();n&&n!==e?t(n):d(e)}return(0,u.jsxs)(`div`,{className:`perm-manage-row`,children:[i?(0,u.jsx)(`input`,{autoFocus:!0,className:`perm-inline-input`,value:o,style:{flex:1,minWidth:0},onChange:e=>d(e.target.value),onBlur:f,onKeyDown:t=>{t.key===`Enter`&&f(),t.key===`Escape`&&(a(!1),d(e))}}):(0,u.jsx)(`span`,{className:`perm-manage-row-label`,children:e}),(0,u.jsxs)(`div`,{className:`perm-manage-row-actions`,children:[(0,u.jsx)(c.Button,{type:`text`,size:`small`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>{d(e),a(!0)},loading:r}),(0,u.jsx)(c.Popconfirm,{title:`Delete this item?`,onConfirm:n,okText:`Delete`,cancelText:`Cancel`,okType:`danger`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,icon:(0,u.jsx)(l.DeleteOutlined,{}),danger:!0})})]})]})}function JP({open:e,onClose:t}){let[r,i]=(0,s.useState)(`modules`),[a,o]=(0,s.useState)([]),[d,f]=(0,s.useState)(!1),[p,m]=(0,s.useState)(``),[h,g]=(0,s.useState)(!1),[_,v]=(0,s.useState)([]),[y,b]=(0,s.useState)(!1),[x,S]=(0,s.useState)(``),[C,w]=(0,s.useState)(``),[T,E]=(0,s.useState)(!1);(0,s.useEffect)(()=>{e&&(D(),O())},[e]);async function D(){f(!0);try{o(await n.ui())}catch{c.message.error(`Failed to load modules`)}finally{f(!1)}}async function O(){b(!0);try{v(await n.li())}catch{c.message.error(`Failed to load actions`)}finally{b(!1)}}async function k(){let e=p.trim();if(!e){c.message.warning(`Enter a module name`);return}g(!0);try{let t=await n.Er({menuName:e});o(e=>[...e,t]),m(``),c.message.success(`Module added`)}catch{c.message.error(`Failed to add module`)}finally{g(!1)}}async function A(e,t){try{await n.Ui(e,{menuName:t}),o(n=>n.map(n=>n.MENUID===e?{...n,MENUNAME:t}:n))}catch{c.message.error(`Failed to update module`)}}async function j(e){try{await n.Fr(e),o(t=>t.filter(t=>t.MENUID!==e)),c.message.success(`Module deleted`)}catch{c.message.error(`Failed to delete module`)}}async function M(){let e=x.trim(),t=C.trim().toLowerCase().replace(/\s+/g,`_`);if(!e||!t){c.message.warning(`Enter both name and key`);return}E(!0);try{let r=await n.Tr({permissionName:e,permissionKey:t});v(e=>[...e,r]),S(``),w(``),c.message.success(`Action added`)}catch(e){c.message.error(e?.message?.includes(`409`)||e?.status===409?`Permission key already exists`:`Failed to add action`)}finally{E(!1)}}async function N(e,t){try{await n.Hi(e,{permissionName:t}),v(n=>n.map(n=>n.permissionId===e?{...n,permissionName:t}:n))}catch{c.message.error(`Failed to update action`)}}async function P(e){try{await n.Pr(e),v(t=>t.filter(t=>t.permissionId!==e)),c.message.success(`Action deleted`)}catch{c.message.error(`Failed to delete action`)}}let F=[{key:`modules`,label:`Modules`,children:(0,u.jsxs)(c.Spin,{spinning:d,children:[(0,u.jsxs)(`div`,{className:`perm-manage-add-row`,children:[(0,u.jsx)(c.Input,{placeholder:`Module name`,value:p,onChange:e=>m(e.target.value),onPressEnter:k,style:{flex:1},size:`small`}),(0,u.jsx)(c.Button,{type:`primary`,size:`small`,icon:(0,u.jsx)(l.PlusOutlined,{}),loading:h,onClick:k,children:`Add`})]}),(0,u.jsxs)(`div`,{className:`perm-manage-list`,children:[a.length===0&&!d&&(0,u.jsx)(`div`,{className:`perm-empty`,style:{paddingTop:24},children:`No modules found`}),a.map(e=>(0,u.jsx)(qP,{label:e.MENUNAME,onSave:t=>A(e.MENUID,t),onDelete:()=>j(e.MENUID)},e.MENUID))]})]})},{key:`actions`,label:`Actions`,children:(0,u.jsxs)(c.Spin,{spinning:y,children:[(0,u.jsxs)(`div`,{className:`perm-manage-add-row`,children:[(0,u.jsx)(c.Input,{placeholder:`Action name (e.g. Approve)`,value:x,onChange:e=>S(e.target.value),style:{flex:1},size:`small`}),(0,u.jsx)(c.Input,{placeholder:`Key (e.g. approve)`,value:C,onChange:e=>w(e.target.value),onPressEnter:M,style:{width:140},size:`small`}),(0,u.jsx)(c.Button,{type:`primary`,size:`small`,icon:(0,u.jsx)(l.PlusOutlined,{}),loading:T,onClick:M,children:`Add`})]}),(0,u.jsxs)(`div`,{className:`perm-manage-list`,children:[_.length===0&&!y&&(0,u.jsx)(`div`,{className:`perm-empty`,style:{paddingTop:24},children:`No actions found`}),_.map(e=>(0,u.jsx)(qP,{label:`${e.permissionName} (${e.permissionKey})`,onSave:t=>N(e.permissionId,t),onDelete:()=>P(e.permissionId)},e.permissionId))]})]})}];return(0,u.jsx)(c.Modal,{open:e,onCancel:t,title:(0,u.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,u.jsx)(l.SettingOutlined,{style:{color:`var(--color-brand)`}}),`Manage Modules & Actions`]}),width:520,footer:null,destroyOnClose:!0,children:(0,u.jsx)(c.Tabs,{activeKey:r,onChange:i,size:`small`,items:F})})}function YP(){let[e,t]=(0,s.useState)([]),[r,i]=(0,s.useState)(!1),[a,o]=(0,s.useState)(null),[d,f]=(0,s.useState)(``),[p,m]=(0,s.useState)(!1),[h,g]=(0,s.useState)(()=>GP(UP)),[_,v]=(0,s.useState)(()=>GP(WP)),y=(0,s.useCallback)((e,t)=>{g(n=>{let r={...n,[e]:t};return KP(UP,r),r})},[]),b=(0,s.useCallback)((e,t)=>{v(n=>{let r={...n,[e]:t};return KP(WP,r),r})},[]);function x(){g({}),v({}),KP(UP,{}),KP(WP,{}),c.message.success(`Labels reset to defaults`)}let S=(0,s.useCallback)(async()=>{i(!0);try{let{roles:e}=await n.Gr();t(e),e.length>0&&o(e[0])}catch{c.message.error(`Failed to load roles`)}finally{i(!1)}},[]);(0,s.useEffect)(()=>{S()},[S]);let C=(0,s.useMemo)(()=>{let t=d.trim().toLowerCase();return t?e.filter(e=>e.roleName.toLowerCase().includes(t)):e},[e,d]),w=Object.keys(h).length>0||Object.keys(_).length>0;return(0,u.jsxs)(`div`,{className:`perm-page`,children:[(0,u.jsxs)(Z,{className:`perm-left-card`,icon:(0,u.jsx)(l.SafetyOutlined,{}),title:`Roles`,bodyStyle:{padding:0},children:[(0,u.jsx)(`div`,{className:`perm-role-search`,children:(0,u.jsx)(c.Input,{prefix:(0,u.jsx)(l.SearchOutlined,{}),placeholder:`Search roles…`,allowClear:!0,size:`small`,value:d,onChange:e=>f(e.target.value)})}),(0,u.jsx)(c.Spin,{spinning:r,children:(0,u.jsxs)(`div`,{className:`perm-role-list`,children:[C.length===0&&!r&&(0,u.jsx)(`div`,{className:`perm-role-empty`,children:`No roles found`}),C.map(e=>{let t=a?.roleId===e.roleId,n=e.description&&e.description!==`N/A`?e.description:e.roleType===0?`Default role`:`Custom role`;return(0,u.jsxs)(`div`,{className:`perm-role-item${t?` active`:``}`,onClick:()=>o(e),children:[(0,u.jsx)(`div`,{className:`perm-role-item-name`,children:e.roleName}),(0,u.jsx)(`div`,{className:`perm-role-item-desc`,children:n})]},e.roleId)})]})})]}),(0,u.jsx)(Z,{className:`perm-right-card`,icon:(0,u.jsx)(l.LockOutlined,{}),title:`Module Permissions`,extra:(0,u.jsxs)(`span`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[w&&(0,u.jsx)(`button`,{className:`perm-reset-btn`,onClick:x,children:`Reset labels`}),(0,u.jsx)(c.Button,{size:`small`,icon:(0,u.jsx)(l.SettingOutlined,{}),onClick:()=>m(!0),children:`Manage`})]}),bodyStyle:{padding:`12px 16px`},children:a?(0,u.jsx)(FP,{role:a,moduleLabels:h,actionLabels:_,onModuleLabelSave:y,onActionLabelSave:b},a.roleId):(0,u.jsx)(`div`,{className:`perm-empty`,children:`Select a role from the left to manage its permissions.`})}),(0,u.jsx)(JP,{open:p,onClose:()=>m(!1)})]})}var{Title:XP,Text:ZP}=c.Typography,QP=[{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 $P({items:e=QP}){return(0,u.jsx)(c.Card,{className:`onboarding-card`,title:(0,u.jsx)(XP,{level:5,children:`Onboarding`}),extra:(0,u.jsx)(c.Button,{type:`link`,children:`View all`}),children:(0,u.jsx)(c.Row,{gutter:[12,12],children:e.map(e=>(0,u.jsx)(c.Col,{xs:12,sm:6,md:6,lg:12,xl:12,children:(0,u.jsxs)(`div`,{className:`onboarding-item ${e.color}`,children:[(0,u.jsx)(ZP,{className:`onboarding-item-label`,children:e.label}),(0,u.jsx)(c.Statistic,{value:e.value,className:`onboarding-stat`}),(0,u.jsx)(`div`,{className:`onboarding-item-footer`,children:(0,u.jsx)(ZP,{className:`onboarding-item-sub`,children:e.sub})})]})},e.label))})})}var{Text:eF,Title:tF}=c.Typography,nF=[{group:`Dashboard`,items:[{id:`dashboard`,label:`Admin Dashboard`,icon:(0,u.jsx)(l.DashboardOutlined,{})}]},{group:`Settings`,items:[{id:`org`,label:`Organization`,icon:(0,u.jsx)(l.BankOutlined,{}),heading:`Organization Settings`,desc:`Manage your company profile and location details`,cards:[{label:`Company Information`,icon:(0,u.jsx)(l.BankOutlined,{}),desc:`Manage company profile, address and business details.`},{label:`Location`,icon:(0,u.jsx)(l.BuildOutlined,{}),desc:`Manage office locations, branches and regions.`}]},{id:`users`,label:`Users`,icon:(0,u.jsx)(l.UserOutlined,{}),heading:`Users`,desc:`Manage platform users and configure their field views.`,component:`users`},{id:`teams`,label:`Teams`,icon:(0,u.jsx)(l.TeamOutlined,{}),heading:`Teams`,desc:`Organize users into teams and configure field visibility per team.`,component:`teams`},{id:`roles`,label:`Roles`,icon:(0,u.jsx)(l.SafetyOutlined,{}),heading:`Roles`,desc:`Control permissions and configure field visibility per role.`,component:`roles`},{id:`permissions`,label:`Permissions`,icon:(0,u.jsx)(l.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,u.jsx)(l.FileTextOutlined,{}),heading:`Templates`,desc:`Email and signature templates for communications`,component:`templates`},{id:`ai-services`,label:`AI Services`,icon:(0,u.jsx)(l.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,u.jsx)(l.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,u.jsx)(l.BankOutlined,{}),heading:`Clients`,desc:`Manage client accounts and settings`,cards:[{label:`Clients`,icon:(0,u.jsx)(l.BankOutlined,{}),desc:`Manage client companies and account details.`}]}]},{group:`Forms`,items:[{id:`form-groups`,label:`Form Groups`,icon:(0,u.jsx)(l.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,u.jsx)(l.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,u.jsx)(l.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,u.jsx)(l.AppstoreOutlined,{}),heading:`Jobs Master`,desc:`Configure job sources and status types`,cards:[{label:`Sources`,icon:(0,u.jsx)(l.AppstoreOutlined,{}),desc:`Manage job source master values.`},{label:`Job Status`,icon:(0,u.jsx)(l.CheckCircleOutlined,{}),desc:`Configure job workflow status.`}]},{id:`candidates`,label:`Candidates`,icon:(0,u.jsx)(l.UserOutlined,{}),heading:`Candidates Master`,desc:`Skills, sources and work authorization settings`,cards:[{label:`Sources`,icon:(0,u.jsx)(l.AppstoreOutlined,{}),desc:`Manage candidate source values.`},{label:`Skills`,icon:(0,u.jsx)(l.SettingOutlined,{}),desc:`Manage skill master data.`},{label:`Work Authorization`,icon:(0,u.jsx)(l.SafetyOutlined,{}),desc:`Manage visa and authorization types.`}]},{id:`submissions`,label:`Submissions`,icon:(0,u.jsx)(l.FileTextOutlined,{}),heading:`Submissions Master`,desc:`Rejection reasons and submission status configuration`,cards:[{label:`Rejection Reasons`,icon:(0,u.jsx)(l.FileTextOutlined,{}),desc:`Manage common rejection reasons.`},{label:`Client Submission Status`,icon:(0,u.jsx)(l.CheckCircleOutlined,{}),desc:`Manage client submission statuses.`}]},{id:`clientmaster`,label:`Client Master`,icon:(0,u.jsx)(l.BankOutlined,{}),heading:`Client Master`,desc:`Payment terms, client types and contact types`,cards:[{label:`Payment Terms`,icon:(0,u.jsx)(l.FileTextOutlined,{}),desc:`Manage billing and payment terms.`},{label:`Client Type`,icon:(0,u.jsx)(l.AppstoreOutlined,{}),desc:`Classify client business types.`},{label:`Client Contact Type`,icon:(0,u.jsx)(l.TeamOutlined,{}),desc:`Manage client contact categories.`}]}]}],rF=[{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}],iF=[{name:`Tcs`,jobs:14,candidates:86},{name:`Empasis`,jobs:9,candidates:64},{name:`NovaSystems`,jobs:7,candidates:51},{name:`Brightwave`,jobs:5,candidates:38}],aF=[{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 oF(){return(0,u.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:16},children:[(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.DashboardOutlined,{}),title:`Admin Dashboard`,children:[(0,u.jsx)(`div`,{className:`admin-accent-bar`}),(0,u.jsx)(tF,{level:5,children:`Admin Dashboard`}),(0,u.jsx)(eF,{type:`secondary`,children:`Overview of jobs, candidates, onboarding and recent activity`})]}),(0,u.jsx)(`div`,{className:`admin-dashboard-stats`,children:(0,u.jsx)(mP,{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,u.jsxs)(`div`,{className:`admin-dashboard-mid-row`,children:[(0,u.jsx)($P,{}),(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.AppstoreOutlined,{}),title:`Candidate Pipeline`,children:[(0,u.jsx)(eF,{type:`secondary`,style:{fontSize:12},children:`By stage (892 total)`}),(0,u.jsx)(`div`,{className:`admin-pipeline-bar`,children:rF.map(e=>(0,u.jsx)(`div`,{className:`admin-pipeline-seg`,style:{width:`${e.pct}%`,background:e.color}},e.label))}),(0,u.jsx)(`div`,{className:`admin-pipeline-legend`,children:rF.map(e=>(0,u.jsxs)(`div`,{className:`admin-pipeline-legend-item`,children:[(0,u.jsx)(`span`,{className:`admin-pipeline-dot`,style:{background:e.color}}),e.label,` `,e.count]},e.label))}),(0,u.jsx)(`div`,{className:`admin-divider`}),(0,u.jsx)(eF,{strong:!0,style:{fontSize:12},children:`Submission status`}),(0,u.jsxs)(`div`,{className:`admin-sub-status-list`,style:{marginTop:6},children:[(0,u.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,u.jsx)(eF,{style:{fontSize:13},children:`Pending client review`}),(0,u.jsx)(`span`,{className:`admin-badge warn`,children:`312`})]}),(0,u.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,u.jsx)(eF,{style:{fontSize:13},children:`Client approved`}),(0,u.jsx)(`span`,{className:`admin-badge success`,children:`248`})]}),(0,u.jsxs)(`div`,{className:`admin-sub-status-item`,children:[(0,u.jsx)(eF,{style:{fontSize:13},children:`Rejected`}),(0,u.jsx)(`span`,{className:`admin-badge danger`,children:`89`})]})]})]})]}),(0,u.jsxs)(`div`,{className:`admin-dashboard-bottom-row`,children:[(0,u.jsx)(Z,{icon:(0,u.jsx)(l.BankOutlined,{}),title:`Top Clients`,extra:(0,u.jsx)(c.Button,{type:`link`,size:`small`,children:`View all`}),children:iF.map(e=>(0,u.jsxs)(`div`,{className:`admin-client-row`,children:[(0,u.jsxs)(`div`,{className:`admin-client-left`,children:[(0,u.jsx)(`div`,{className:`admin-client-icon`,children:(0,u.jsx)(l.BankOutlined,{})}),(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`div`,{className:`admin-client-name`,children:e.name}),(0,u.jsxs)(`div`,{className:`admin-client-sub`,children:[e.jobs,` open jobs`]})]})]}),(0,u.jsxs)(`div`,{className:`admin-client-right`,children:[(0,u.jsx)(`div`,{className:`admin-client-val`,children:e.candidates}),(0,u.jsx)(`div`,{className:`admin-client-sub`,children:`candidates`})]})]},e.name))}),(0,u.jsx)(Z,{icon:(0,u.jsx)(l.BellOutlined,{}),title:`Recent Activity`,children:aF.map((e,t)=>(0,u.jsxs)(`div`,{className:`admin-activity-row`,children:[(0,u.jsx)(`div`,{className:`admin-activity-dot`,style:{background:e.color}}),(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`div`,{className:`admin-activity-text`,children:e.text}),(0,u.jsx)(`div`,{className:`admin-activity-time`,children:e.time})]})]},t))})]}),(0,u.jsx)(Z,{icon:(0,u.jsx)(l.SettingOutlined,{}),title:`Admin Configuration Overview`,extra:(0,u.jsx)(c.Button,{type:`link`,size:`small`,children:`Manage`}),children:(0,u.jsxs)(c.Row,{gutter:[24,0],children:[(0,u.jsxs)(c.Col,{span:8,children:[(0,u.jsx)(eF,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`Settings`}),[[`Organization`,2],[`User Settings`,4],[`Templates`,2]].map(([e,t])=>(0,u.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,u.jsx)(eF,{style:{fontSize:12},children:e}),(0,u.jsxs)(`span`,{className:`admin-badge info`,children:[t,` items`]})]},e))]}),(0,u.jsxs)(c.Col,{span:8,children:[(0,u.jsx)(eF,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`Master`}),[[`Jobs`,2],[`Candidates`,3],[`Submissions`,2]].map(([e,t])=>(0,u.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,u.jsx)(eF,{style:{fontSize:12},children:e}),(0,u.jsxs)(`span`,{className:`admin-badge info`,children:[t,` items`]})]},e))]}),(0,u.jsxs)(c.Col,{span:8,children:[(0,u.jsx)(eF,{type:`secondary`,style:{fontSize:12,fontWeight:500},children:`System`}),[[`Total Groups`,4],[`Total Modules`,9],[`Config Items`,19]].map(([e,t])=>(0,u.jsxs)(`div`,{className:`admin-cfg-overview-row`,children:[(0,u.jsx)(eF,{style:{fontSize:12},children:e}),(0,u.jsx)(eF,{strong:!0,style:{fontSize:12},children:t})]},e))]})]})})]})}function sF({activeSection:e,activeGroup:t,filteredCards:n,searchText:r,setSearchText:i,allItems:a,handleNav:o}){return(0,u.jsxs)(c.Row,{gutter:[16,16],children:[(0,u.jsx)(c.Col,{span:24,children:(0,u.jsxs)(Z,{icon:e?.icon,title:e?.heading,extra:(0,u.jsx)(c.Input,{className:`admin-search`,prefix:(0,u.jsx)(l.SearchOutlined,{}),placeholder:`Search settings…`,allowClear:!0,value:r,onChange:e=>i(e.target.value)}),children:[(0,u.jsx)(`div`,{className:`admin-accent-bar`}),(0,u.jsx)(tF,{level:5,children:e?.heading}),(0,u.jsx)(eF,{type:`secondary`,children:e?.desc})]})}),(0,u.jsx)(c.Col,{xs:24,xl:16,style:{alignSelf:`flex-start`},children:(0,u.jsx)(Z,{icon:(0,u.jsx)(l.AppstoreOutlined,{}),title:`Configuration Items`,extra:(0,u.jsxs)(eF,{type:`secondary`,children:[n.length,` item`,n.length===1?``:`s`]}),children:(0,u.jsx)(c.Row,{gutter:[14,14],children:n.length>0?n.map(e=>(0,u.jsx)(c.Col,{xs:24,sm:12,xl:8,children:(0,u.jsxs)(`div`,{className:`admin-config-item`,children:[(0,u.jsx)(`div`,{className:`admin-config-top-bar`}),(0,u.jsxs)(`div`,{className:`admin-config-body`,children:[(0,u.jsx)(`div`,{className:`admin-config-icon`,children:e.icon}),(0,u.jsxs)(`div`,{className:`admin-config-text`,children:[(0,u.jsx)(`span`,{className:`admin-config-label`,children:e.label}),(0,u.jsx)(`span`,{className:`admin-config-desc`,children:e.desc})]})]}),(0,u.jsx)(`div`,{className:`admin-config-divider`}),(0,u.jsx)(c.Button,{type:`link`,size:`small`,className:`admin-config-manage`,icon:(0,u.jsx)(l.RightOutlined,{}),iconPosition:`end`,children:`Manage`})]})},e.label)):(0,u.jsx)(c.Col,{span:24,children:(0,u.jsx)(`div`,{className:`admin-config-empty`,children:(0,u.jsx)(c.Empty,{description:`No settings found`,image:c.Empty.PRESENTED_IMAGE_SIMPLE})})})})})}),(0,u.jsx)(c.Col,{xs:24,xl:8,style:{alignSelf:`flex-start`},children:(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.FileTextOutlined,{}),title:`Section Overview`,children:[(0,u.jsx)(`div`,{className:`admin-overview-list`,children:nF.filter(e=>e.group!==`Dashboard`).map(e=>{let n=e.group===t?.group;return(0,u.jsxs)(`div`,{className:`admin-overview-item${n?` active`:``}`,onClick:()=>{let t=e.items[0];t&&o(t.id)},children:[(0,u.jsxs)(`div`,{className:`admin-overview-left`,children:[(0,u.jsx)(`div`,{className:`admin-overview-icon`,children:e.items[0]?.icon}),(0,u.jsxs)(`div`,{className:`admin-overview-text`,children:[(0,u.jsx)(`span`,{className:`admin-overview-name`,children:e.group}),(0,u.jsxs)(`span`,{className:`admin-overview-sub`,children:[e.items.length,` module`,e.items.length===1?``:`s`]})]})]}),(0,u.jsx)(`span`,{className:`admin-overview-count${n?` active`:``}`,children:e.items.length})]},e.group)})}),(0,u.jsxs)(`div`,{className:`admin-overview-footer`,children:[(0,u.jsx)(`span`,{className:`admin-overview-footer-label`,children:`Total configuration items`}),(0,u.jsx)(`span`,{className:`admin-overview-footer-value`,children:a.filter(e=>e.cards).reduce((e,t)=>e+t.cards.length,0)})]})]})})]})}function cF(){let[e,t]=(0,s.useState)(`dashboard`),[n,r]=(0,s.useState)(``),i=(0,s.useMemo)(()=>nF.flatMap(e=>e.items),[]),a=(0,s.useMemo)(()=>i.find(t=>t.id===e),[i,e]),o=(0,s.useMemo)(()=>nF.find(t=>t.items.some(t=>t.id===e)),[e]),d=(0,s.useMemo)(()=>{if(!a?.cards)return[];let e=n.trim().toLowerCase();return e?a.cards.filter(t=>t.label.toLowerCase().includes(e)||t.desc.toLowerCase().includes(e)):a.cards},[a,n]),f=(0,s.useMemo)(()=>nF.map(e=>({key:e.group,type:`group`,label:e.group,children:e.items.map(e=>({key:e.id,icon:e.icon,label:e.label}))})),[]),p=e=>{t(e),r(``)};return e===`dashboard`||a?.heading,(0,u.jsxs)(`main`,{className:`admin-page`,children:[(0,u.jsx)(`div`,{className:`admin-breadcrumb`,children:(0,u.jsx)(c.Breadcrumb,{items:[{title:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(l.HomeOutlined,{}),` Home`]})},{title:`Admin`}]})}),(0,u.jsxs)(c.Row,{gutter:[16,16],className:`admin-wrapper`,children:[(0,u.jsx)(c.Col,{xs:24,lg:6,xl:5,children:(0,u.jsxs)(Z,{title:`Admin Console`,icon:(0,u.jsx)(l.SettingOutlined,{}),children:[(0,u.jsxs)(`div`,{className:`admin-sidebar-banner`,children:[(0,u.jsx)(`span`,{className:`admin-sidebar-banner-title`,children:`Admin Panel`}),(0,u.jsx)(`span`,{className:`admin-sidebar-banner-sub`,children:`Configuration Center`}),(0,u.jsxs)(c.Row,{gutter:[8,0],children:[(0,u.jsx)(c.Col,{span:12,children:(0,u.jsxs)(`div`,{className:`admin-sidebar-pill`,children:[(0,u.jsx)(`span`,{className:`admin-sidebar-pill-label`,children:`Groups`}),(0,u.jsx)(`span`,{className:`admin-sidebar-pill-value`,children:nF.length})]})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsxs)(`div`,{className:`admin-sidebar-pill`,children:[(0,u.jsx)(`span`,{className:`admin-sidebar-pill-label`,children:`Modules`}),(0,u.jsx)(`span`,{className:`admin-sidebar-pill-value`,children:i.length})]})})]})]}),(0,u.jsx)(c.Menu,{mode:`inline`,selectedKeys:[e],items:f,onClick:({key:e})=>p(e),className:`admin-sidebar-menu`})]})}),(0,u.jsx)(c.Col,{xs:24,lg:18,xl:19,children:e===`dashboard`?(0,u.jsx)(oF,{}):a?.component===`form-groups`?(0,u.jsx)(qw,{}):a?.component===`detail-groups`?(0,u.jsx)(kT,{}):a?.component===`row-actions`?(0,u.jsx)(yE,{}):a?.component===`users`?(0,u.jsx)(vP,{}):a?.component===`teams`?(0,u.jsx)(wP,{}):a?.component===`roles`?(0,u.jsx)(HP,{}):a?.component===`permissions`?(0,u.jsx)(YP,{}):a?.component===`templates`?(0,u.jsx)(jE,{}):a?.component===`ai-services`?(0,u.jsx)(RE,{}):a?.component===`bgc-integration`?(0,u.jsx)(WE,{}):(0,u.jsx)(sF,{activeSection:a,activeGroup:o,filteredCards:d,searchText:n,setSearchText:r,allItems:i,handleNav:p})})]})]})}var{Title:lF}=c.Typography;function uF(){let e=(0,f.useNavigate)(),{state:t}=(0,f.useLocation)(),n=t?.moduleName||`stickyNotes`,r=t?.title||`Sticky Notes`,i={...t?.request,params:{...t?.request?.params,limit:200,offset:0}};return(0,u.jsxs)(`div`,{children:[(0,u.jsx)(c.Button,{type:`text`,icon:(0,u.jsx)(l.ArrowLeftOutlined,{}),onClick:()=>e(-1),style:{marginBottom:12},children:`Back`}),(0,u.jsx)(Bt,{moduleName:n,title:r,columns:4,request:i,viewAll:!1})]})}var{Text:dF,Title:fF}=c.Typography,pF=10485760,mF=`/templates/test_cases_flow_template.base64.txt`,hF=`test_cases_flow_template.xlsx`,gF=`module | subModule | step_order | description | actions | key | value | expected | scenario`,_F={idle:0,module_set:1,encoding:1,validating:2,preview:3,inserting:3,done:4,error:1},vF=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Bulk upload`,href:`/bulk-upload`}];function yF(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 bF(e){return e.filter(e=>e.row_status===`valid`).map(e=>{let t={...e};return delete t.row_status,delete t.errors,t})}function xF(e){return e.flatMap(e=>(e.errors??[]).map(t=>({id:e.id,...t})))}function SF({errors:e}){return(0,u.jsx)(`div`,{className:`bulk-tooltip-errors`,children:(e??[]).map((e,t)=>(0,u.jsx)(`div`,{children:e.message},`${e.field}-${t}`))})}function CF({errors:e,expanded:t,onToggle:n,onSummaryClick:r}){return e.length===0?null:(0,u.jsxs)(`div`,{className:`bulk-error-banner`,children:[(0,u.jsxs)(`div`,{className:`bulk-error-summary`,children:[(0,u.jsxs)(`button`,{type:`button`,className:`bulk-error-summary-main`,onClick:r,"aria-label":`Scroll to first invalid row`,children:[(0,u.jsx)(l.ExclamationCircleOutlined,{className:`bulk-error-icon`}),(0,u.jsxs)(`span`,{children:[e.length,` validation error(s) found`]})]}),(0,u.jsx)(c.Button,{type:`link`,onClick:n,"aria-expanded":t,children:t?`Hide Errors`:`View Errors`})]}),t&&(0,u.jsx)(`div`,{className:`bulk-error-list`,role:`region`,"aria-label":`Validation error details`,children:e.map((e,t)=>(0,u.jsxs)(`div`,{className:`bulk-error-line`,children:[(0,u.jsxs)(`span`,{className:`bulk-row-chip`,children:[`Row `,e.id]}),(0,u.jsx)(`span`,{children:e.message})]},`${e.id}-${e.field}-${t}`))})]})}function wF({rows:e,view:t,onViewChange:n,onConfirm:r,onReset:i,saving:a,firstInvalidRowId:o,firstInvalidRowRef:s}){let d=e.filter(e=>e.row_status===`invalid`),f=t===`errors`?d:e,p=d.length>0||a;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(c.Row,{justify:`space-between`,align:`middle`,gutter:[16,16],className:`bulk-table-toolbar`,children:[(0,u.jsx)(c.Col,{children:(0,u.jsxs)(c.Space.Compact,{children:[(0,u.jsx)(c.Button,{type:t===`all`?`primary`:`default`,onClick:()=>n(`all`),children:`All rows`}),(0,u.jsx)(c.Button,{type:t===`errors`?`primary`:`default`,onClick:()=>n(`errors`),children:`Errors only`})]})}),(0,u.jsx)(c.Col,{children:(0,u.jsxs)(dF,{type:`secondary`,children:[e.length,` row(s)`]})})]}),(0,u.jsx)(`div`,{className:`bulk-table-wrap`,children:(0,u.jsxs)(`table`,{className:`bulk-preview-table`,children:[(0,u.jsx)(`thead`,{children:(0,u.jsxs)(`tr`,{children:[(0,u.jsx)(`th`,{className:`bulk-col-row`,children:`Row`}),(0,u.jsx)(`th`,{className:`bulk-col-flow`,children:`Submodule`}),(0,u.jsx)(`th`,{className:`bulk-col-description`,children:`Description`}),(0,u.jsx)(`th`,{className:`bulk-col-keyword`,children:`Action`}),(0,u.jsx)(`th`,{className:`bulk-col-target`,children:`Key`}),(0,u.jsx)(`th`,{className:`bulk-col-status`,children:`Status`}),(0,u.jsx)(`th`,{className:`bulk-col-error`,children:`Error`})]})}),(0,u.jsx)(`tbody`,{children:f.map(e=>{let t=e.errors??[],n=e.row_status===`invalid`;return(0,u.jsxs)(`tr`,{ref:n&&e.id===o?s:null,className:n?`bulk-row-invalid`:``,children:[(0,u.jsx)(`td`,{children:e.id}),(0,u.jsx)(`td`,{title:e.submodule,children:e.submodule}),(0,u.jsx)(`td`,{title:e.description,children:e.description?e.description:(0,u.jsx)(`span`,{className:`bulk-empty-text`,children:`-empty-`})}),(0,u.jsx)(`td`,{children:(0,u.jsx)(`code`,{className:`bulk-code-chip`,children:e.actions})}),(0,u.jsx)(`td`,{title:e.key,children:e.key}),(0,u.jsx)(`td`,{children:n?(0,u.jsx)(c.Tag,{color:`red`,children:`Error`}):(0,u.jsx)(c.Tag,{color:`green`,children:`Valid`})}),(0,u.jsx)(`td`,{children:n?(0,u.jsx)(c.Tooltip,{title:(0,u.jsx)(SF,{errors:t}),placement:`left`,children:(0,u.jsxs)(`button`,{type:`button`,className:`bulk-error-info`,"aria-label":`View ${t.length} error(s) for row ${e.id}`,children:[(0,u.jsx)(l.InfoCircleOutlined,{}),(0,u.jsx)(c.Badge,{count:t.length,size:`small`})]})}):(0,u.jsx)(`span`,{className:`bulk-error-none`,children:`-`})})]},`${e.id}-${e.step_order}`)})})]})}),(0,u.jsxs)(c.Space,{className:`bulk-actions`,children:[(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:i,children:`Reset`}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.SaveOutlined,{}),loading:a,disabled:p,onClick:r,children:d.length>0?`Fix ${d.length} error(s) to proceed`:`Save to database`})]})]})}function TF(){let e=(0,f.useNavigate)(),r=(0,s.useMemo)(()=>t.l(),[]),i=(0,s.useRef)(null),a=(0,s.useRef)(null),[o,d]=(0,s.useState)([]),[p,m]=(0,s.useState)(``),[h,g]=(0,s.useState)(`idle`),[_,v]=(0,s.useState)(!1),[y,b]=(0,s.useState)(null),[x,S]=(0,s.useState)([]),[C,w]=(0,s.useState)(`all`),[T,E]=(0,s.useState)(null),[D,O]=(0,s.useState)(null),[k,A]=(0,s.useState)(!1),j=o.map(e=>({value:e.modulename,label:e.modulename})),M=xF(x),N=h===`encoding`||h===`validating`,P=!!p&&!N,F=_F[h]??0,I=x.find(e=>e.row_status===`invalid`)?.id,L=(0,s.useCallback)(()=>{m(``),g(`idle`),v(!1),b(null),S([]),w(`all`),E(null),O(null),i.current&&(i.current.value=``)},[]);(0,s.useEffect)(()=>{async function e(){try{let e=await kx({project:r?.name??``,activeOnly:!0});d(e?.items??[])}catch(e){console.error(e),c.message.error(`Unable to load modules.`)}}e()},[r?.name]);let R=e=>{m(e??``),S([]),O(null),E(null),b(null),A(!1),g(e?`module_set`:`idle`)},z=async e=>{if(!e||!P)return;let t=e.name.split(`.`).pop()?.toLowerCase();if(![`xlsx`,`csv`].includes(t)){g(`module_set`),E({message:`Invalid file type. Please upload an Excel .xlsx or CSV .csv file.`});return}if(e.size>pF){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 yF(e);g(`validating`);let i=await wx({filename:e.name,project:r?.name??``,module:p,file_base64:n,file_type:t});S(i?.rows??[]),w(`all`),g(`preview`)}catch(e){console.error(e),E(e.payload??{code:`NETWORK_ERROR`,message:e.message||`Could not reach the server.`}),g(`error`)}},B=async()=>{try{let e=await fetch(mF);if(!e.ok)throw Error(`Template file not found (${e.status})`);let t=(await e.text()).trim(),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);let i=new Blob([r],{type:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=hF,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(a),c.message.success(`Sample template downloaded.`)}catch(e){console.error(e),c.message.error(`Unable to download sample template.`)}},V=async()=>{g(`inserting`),E(null);try{let t=await Tx({project:r?.name??``,module:p,uploaded_by:localStorage.getItem(`user_Email`)??``,rows:bF(x)});O(t),g(`done`),c.message.success(`Bulk upload saved. Redirecting to view test cases...`),window.setTimeout(()=>e(`/viewTestCase`),900)}catch(e){console.error(e),E(e.payload??{code:`NETWORK_ERROR`,message:e.message||`Could not reach the server.`}),g(`preview`)}},H=(0,s.useCallback)(()=>{a.current?.scrollIntoView({behavior:`smooth`,block:`center`})},[]),ee=[`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,u.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,u.jsxs)(c.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,u.jsx)(c.Col,{children:(0,u.jsx)(n.s,{items:vF})}),r?.name&&(0,u.jsx)(c.Col,{children:(0,u.jsx)(dF,{strong:!0,children:r.name})})]}),(0,u.jsxs)(`div`,{className:`zt-page zt-page-wide bulk-page`,children:[(0,u.jsxs)(`div`,{className:`bulk-header`,children:[(0,u.jsx)(fF,{level:3,children:`Bulk upload test cases`}),(0,u.jsxs)(c.Space,{direction:`vertical`,size:4,children:[(0,u.jsx)(dF,{type:`secondary`,children:gF}),(0,u.jsx)(dF,{type:`secondary`,children:`Use the sample template for the required columns. Uploaded rows are saved as Active by default.`})]})]}),(0,u.jsx)(`div`,{className:`bulk-stepbar`,children:[`Select`,`Upload`,`Validate`,`Save`].map((e,t)=>(0,u.jsxs)(`span`,{className:t<F?`bulk-step-active`:``,children:[t+1,` `,e]},e))}),(0,u.jsx)(c.Card,{className:`v1-card zt-fall`,title:`1. Module selector`,children:(0,u.jsx)(c.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,u.jsxs)(c.Card,{className:`v1-card zt-fall`,title:`2. File upload`,extra:(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.DownloadOutlined,{}),onClick:B,children:`Download Sample Template`}),children:[(0,u.jsx)(c.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,u.jsxs)(`button`,{type:`button`,className:ee,disabled:!P,onClick:()=>i.current?.click(),onDragOver:e=>{e.preventDefault(),P&&v(!0)},onDragLeave:()=>v(!1),onDrop:e=>{e.preventDefault(),v(!1),z(e.dataTransfer.files?.[0])},children:[(0,u.jsx)(l.CloudUploadOutlined,{className:`bulk-upload-icon`}),y?(0,u.jsxs)(`span`,{className:`bulk-file-chip`,children:[y.name,` - `,Math.ceil(y.size/1024),` KB`]}):(0,u.jsx)(`span`,{children:`Drag & drop here, or click to browse`})]}),(0,u.jsx)(`input`,{ref:i,hidden:!0,type:`file`,accept:`.xlsx,.csv`,onChange:e=>z(e.target.files?.[0])}),N&&(0,u.jsx)(c.Progress,{percent:h===`encoding`?45:82,showInfo:!1,size:`small`}),T&&h!==`preview`&&(0,u.jsx)(c.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`})]}),x.length>0&&(0,u.jsxs)(c.Card,{className:`v1-card zt-fall`,title:`3. Validation result`,children:[(0,u.jsx)(CF,{errors:M,expanded:k,onToggle:()=>A(e=>!e),onSummaryClick:H}),T&&h===`preview`&&(0,u.jsx)(c.Alert,{type:`error`,showIcon:!0,message:T.message,className:`bulk-inline-alert`}),(0,u.jsx)(wF,{rows:x,view:C,onViewChange:w,onConfirm:V,onReset:L,saving:h===`inserting`,firstInvalidRowId:I,firstInvalidRowRef:a})]}),D&&h===`done`&&(0,u.jsxs)(c.Card,{className:`v1-card zt-fall`,title:`4. Upload complete`,children:[(0,u.jsxs)(c.Row,{gutter:[16,16],className:`bulk-metrics`,children:[(0,u.jsx)(c.Col,{xs:24,md:8,children:(0,u.jsxs)(`div`,{children:[(0,u.jsx)(dF,{children:`Total`}),(0,u.jsx)(`strong`,{children:x.length})]})}),(0,u.jsx)(c.Col,{xs:24,md:8,children:(0,u.jsxs)(`div`,{children:[(0,u.jsx)(dF,{children:`Inserted`}),(0,u.jsx)(`strong`,{children:D.inserted??0})]})}),(0,u.jsx)(c.Col,{xs:24,md:8,children:(0,u.jsxs)(`div`,{children:[(0,u.jsx)(dF,{children:`Failed`}),(0,u.jsx)(`strong`,{children:D.failed??0})]})})]}),(0,u.jsx)(c.Alert,{type:`success`,showIcon:!0,icon:(0,u.jsx)(l.CheckCircleOutlined,{}),message:`${D.inserted??0} test cases saved to database - module: ${p}`,className:`bulk-inline-alert`}),(0,u.jsx)(c.Button,{icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:L,children:`Upload another file`})]})]})]})}var EF=[{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:DF}=c.Typography,OF=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}],kF={tags:`regression`,active:1},AF={module:{dbName:`Modules`,formField:`module`,label:`Module`}};function jF(e=[]){return e.map(e=>({value:e,label:e}))}function MF(e=``){return String(e??``).trim()}function NF(e=``){return MF(e).toLowerCase()}function PF(e=[]){let t=new Map;return e.forEach(e=>{let n=MF(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function FF(e=[],t,n){let r=MF(t).toLowerCase(),i=MF(n).toLowerCase();return e.reduce((e,t)=>{let n=MF(t?.module).toLowerCase(),a=MF(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 IF({icon:e,title:t}){return(0,u.jsxs)(c.Space,{size:10,align:`center`,children:[(0,u.jsx)(`div`,{className:`v1-section-icon-box`,children:e}),(0,u.jsx)(DF,{strong:!0,className:`v1-section-label`,children:t})]})}function LF(){let[e]=c.Form.useForm(),[t]=c.Form.useForm(),[r,i]=(0,s.useState)([]),[a,o]=(0,s.useState)([]),[d,p]=(0,s.useState)([]),[m,h]=(0,s.useState)(!1),[g,_]=(0,s.useState)(!1),[v,y]=(0,s.useState)({open:!1,typeKey:`module`}),[b,x]=(0,s.useState)(!1),[S,C]=(0,s.useState)(!1),[w,T]=(0,s.useState)(!1),E=(0,f.useNavigate)(),D=AF[v.typeKey],O=(0,s.useMemo)(()=>jF(r),[r]),k=c.Form.useWatch(`module`,e),A=c.Form.useWatch(`flow`,e),j=!!MF(k),M=!!MF(A),N=!j,P=!j||!M,F=(e,t=[])=>{e===`module`&&i(t)},I=async()=>{h(!0);try{let e=await yx(AF.module.dbName);i(e?.items??[])}catch(e){console.error(`Unable to load testing options:`,e),c.message.error(`Unable to load testing options.`)}finally{h(!1)}},L=(0,s.useCallback)(async t=>{let n=MF(t);if(o([]),p([]),e.setFieldsValue({step_order:void 0}),n){_(!0);try{let e=await Cx({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];o(t),p(PF(t))}catch(e){console.error(`Unable to load flows:`,e),c.message.error(`Unable to load flows.`)}finally{_(!1)}}},[e]),R=(0,s.useCallback)(async(t,n,r)=>{let i=MF(t),a=MF(n);if(!i||!a){e.setFieldsValue({step_order:void 0});return}C(!0);try{e.setFieldsValue({step_order:FF(r,i,a)})}catch(e){console.error(`Unable to load step order:`,e),c.message.error(`Unable to load step order.`)}finally{C(!1)}},[e]);(0,s.useEffect)(()=>{Promise.resolve().then(I)},[]),(0,s.useEffect)(()=>{Promise.resolve().then(()=>L(k))},[L,k]),(0,s.useEffect)(()=>{Promise.resolve().then(()=>R(k,A,a))},[a,R,A,k]);let z=async t=>{let n={module:MF(t.module),flow:MF(t.flow),step_order:Number(t.step_order),description:MF(t.description),keyword:NF(t.keyword),target:MF(t.target),value:MF(t.value),expected:MF(t.expected),tags:t.tags?MF(t.tags):kF.tags,active:Number(t.active)};T(!0);try{await Sx(n),c.message.success(`Test case details saved successfully.`),e.resetFields(),o([]),p([])}catch(e){console.error(`Unable to save test case:`,e),c.message.error(`Unable to save test case.`)}finally{T(!1)}},B=(t,n)=>{e.setFieldsValue({[t]:MF(n)})},V=t=>{e.setFieldsValue({module:MF(t),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:kF.tags,value:void 0,expected:void 0})},H=t=>{e.setFieldsValue({flow:MF(t),step_order:void 0})},ee=e=>{let n=AF[e];y({open:!0,typeKey:e}),t.setFieldsValue({name:``,type:n.label})},te=()=>{y(e=>({...e,open:!1})),t.resetFields()},ne=async()=>{try{let n=MF((await t.validateFields()).name),r=await bx({name:n,type:D.dbName});F(v.typeKey,r?.items??[]),e.setFieldsValue({[D.formField]:n}),c.message.success(`${D.label} added successfully.`),te()}catch(e){if(e?.errorFields)return;console.error(`Unable to save testing option:`,e),c.message.error(`Unable to add ${D.label.toLowerCase()}.`)}finally{x(!1)}};return(0,u.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,u.jsxs)(c.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,u.jsx)(c.Col,{children:(0,u.jsx)(n.s,{items:OF})}),(0,u.jsx)(c.Col,{children:(0,u.jsx)(c.Button,{type:`link`,onClick:()=>E(`/zinnext-home`),children:`View Table`})})]}),(0,u.jsx)(`div`,{className:`v1-page`,children:(0,u.jsxs)(`div`,{className:`v1-page-inner`,children:[(0,u.jsx)(`div`,{className:`v1-page-header`,children:(0,u.jsxs)(c.Space,{align:`center`,size:10,children:[(0,u.jsx)(l.ProfileOutlined,{className:`v1-outer-icon`}),(0,u.jsx)(`div`,{children:(0,u.jsx)(DF,{strong:!0,style:{fontSize:16},children:`Add Test Case`})})]})}),(0,u.jsx)(Z,{children:(0,u.jsxs)(c.Form,{form:e,className:`v1-form`,layout:`vertical`,colon:!1,requiredMark:(e,{required:t})=>(0,u.jsxs)(u.Fragment,{children:[e,t&&(0,u.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),initialValues:kF,onFinish:z,autoComplete:`off`,children:[(0,u.jsx)(c.Card,{className:`v1-card`,title:(0,u.jsx)(IF,{icon:(0,u.jsx)(l.FileTextOutlined,{}),title:`Test Case Details`}),extra:(0,u.jsx)(DF,{type:`secondary`,className:`v1-card-subtitle`,children:`Module, flow, step order and execution data`}),children:(0,u.jsxs)(c.Row,{gutter:[24,0],children:[(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsxs)(c.Space.Compact,{style:{width:`100%`},children:[(0,u.jsx)(c.Form.Item,{label:`Module`,name:`module`,style:{flex:1},children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,loading:m,optionFilterProp:`label`,placeholder:`Select module`,options:O,onChange:V})}),(0,u.jsx)(c.Button,{"aria-label":`Add module`,icon:(0,u.jsx)(l.PlusOutlined,{}),style:{marginTop:30},onClick:()=>ee(`module`)})]})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Flow`,name:`flow`,children:(0,u.jsx)(c.AutoComplete,{maxLength:100,allowClear:!0,disabled:N,options:d,placeholder:g?`Loading flows`:`Enter flow`,onChange:H,filterOption:(e,t)=>t?.value?.toLowerCase().includes(e.toLowerCase())})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Step Order`,name:`step_order`,validateTrigger:[`onBlur`,`onChange`],children:(0,u.jsx)(c.Input,{maxLength:10,disabled:!0,placeholder:S?`Loading step order`:`Step order`})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Action`,name:`keyword`,children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,disabled:P,optionFilterProp:`label`,placeholder:`Select action`,options:EF,onChange:t=>e.setFieldsValue({keyword:NF(t)})})})}),(0,u.jsx)(c.Col,{xs:24,children:(0,u.jsx)(c.Form.Item,{label:`Description`,name:`description`,children:(0,u.jsx)(c.Input.TextArea,{rows:3,maxLength:255,disabled:P,placeholder:`Enter description`,showCount:!0,onBlur:e=>B(`description`,e.target.value)})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Key`,name:`target`,children:(0,u.jsx)(c.Input,{maxLength:255,disabled:P,placeholder:`Enter target`,onBlur:e=>B(`target`,e.target.value)})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Tags`,name:`tags`,children:(0,u.jsx)(c.Input,{maxLength:200,disabled:P,placeholder:`Enter tags`,prefix:(0,u.jsx)(l.TagsOutlined,{className:`v1-input-icon`}),onBlur:e=>B(`tags`,e.target.value)})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Value`,name:`value`,children:(0,u.jsx)(c.Input.TextArea,{rows:4,disabled:P,placeholder:`Enter value`,onBlur:e=>B(`value`,e.target.value)})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Expected`,name:`expected`,children:(0,u.jsx)(c.Input.TextArea,{rows:4,disabled:P,placeholder:`Enter expected result`,onBlur:e=>B(`expected`,e.target.value)})})})]})}),(0,u.jsx)(`div`,{className:`v1-form-actions`,children:(0,u.jsx)(c.Form.Item,{children:(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(c.Button,{type:`primary`,htmlType:`submit`,loading:w,disabled:P,children:`Submit`}),(0,u.jsx)(c.Button,{onClick:()=>{e.resetFields(),o([]),p([])},children:`Reset`})]})})})]})}),(0,u.jsx)(c.Modal,{title:`Add ${D.label}`,open:v.open,confirmLoading:b,okText:`Add`,onCancel:te,onOk:()=>{x(!0),ne()},destroyOnHidden:!0,children:(0,u.jsxs)(c.Form,{form:t,layout:`vertical`,colon:!1,className:`v1-form`,requiredMark:(e,{required:t})=>(0,u.jsxs)(u.Fragment,{children:[e,t&&(0,u.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),children:[(0,u.jsx)(c.Form.Item,{label:`Name`,name:`name`,children:(0,u.jsx)(c.Input,{maxLength:100,placeholder:`Enter ${D.label.toLowerCase()} name`,onBlur:e=>{t.setFieldsValue({name:MF(e.target.value)})}})}),(0,u.jsx)(c.Form.Item,{label:`Type`,name:`type`,children:(0,u.jsx)(c.Input,{disabled:!0})})]})})]})})]})}var{Text:RF}=c.Typography,zF=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`}];function BF(e=``){return String(e??``).trim()}function VF(e=[],t){return e.map(e=>({value:e.id,label:e[t]}))}var HF=[{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,u.jsx)(c.Tag,{color:`green`,children:`Positive`}):(0,u.jsx)(c.Tag,{color:`red`,children:`Negative`})}],UF={key:!1,value:!1,expected:!1};function WF(e,t){return t?e[t]??UF:UF}function GF(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function KF(){let[e]=c.Form.useForm(),r=(0,f.useNavigate)(),[i]=(0,f.useSearchParams)(),a=i.get(`edit`),o=!!a,d=(0,s.useMemo)(()=>t.l(),[]),[p,m]=(0,s.useState)([]),[h,g]=(0,s.useState)([]),[_,v]=(0,s.useState)([]),[y,b]=(0,s.useState)(EF),[x,S]=(0,s.useState)({}),[C,w]=(0,s.useState)(!1),[T,E]=(0,s.useState)(!1),[D,O]=(0,s.useState)(!1),[k,A]=(0,s.useState)(!1),[j,M]=(0,s.useState)(!1),N=c.Form.useWatch(`module`,e),P=c.Form.useWatch(`submodule`,e),F=c.Form.useWatch(`actions`,e),I=!!N,L=!!P,R=(0,s.useMemo)(()=>WF(x,F),[x,F]),z=(0,s.useMemo)(()=>VF(p,`modulename`),[p]),B=(0,s.useMemo)(()=>VF(h,`submodulename`),[h]),V=(0,s.useMemo)(()=>p.find(e=>e.id===N)?.modulename??``,[p,N]),H=(0,s.useMemo)(()=>h.find(e=>e.id===P)?.submodulename??``,[P,h]),ee=(0,s.useCallback)(async()=>{try{let e=await xx();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),c.message.error(`Unable to load action validation rules.`)}},[]),te=(0,s.useCallback)(async e=>{if(!e){m([]);return}w(!0);try{let t=await kx({project:e,activeOnly:!0});m(t?.items??[])}catch(e){console.error(`Unable to load modules:`,e),c.message.error(`Unable to load modules.`)}finally{w(!1)}},[]),ne=(0,s.useCallback)(async(e,t)=>{if(!e||!t){g([]);return}E(!0);try{let n=await Mx({project:e,module:t,activeOnly:!0});g(n?.items??[])}catch(e){console.error(`Unable to load submodules:`,e),c.message.error(`Unable to load submodules.`)}finally{E(!1)}},[]),re=(0,s.useCallback)(async(t,n,r,i=``)=>{if(!t||!n||!r){v([]),e.setFieldsValue({step_order:void 0});return}O(!0);try{let[a,o]=await Promise.all([Fx({product_parent_ID:t,module_parent_ID:n,submodule_parent_ID:r,actions:i,limit:1e3}),Rx({product_parent_ID:t,module_parent_ID:n,submodule_parent_ID:r})]);v(a?.items??[]),e.setFieldsValue({step_order:o?.step_order??1})}catch(e){console.error(`Unable to load flows:`,e),c.message.error(`Unable to load flows.`)}finally{O(!1)}},[e]),ie=(0,s.useCallback)(async(e=``)=>{if(!(!d?.id||!N||!P)){O(!0);try{let t=await Fx({product_parent_ID:d.id,module_parent_ID:N,submodule_parent_ID:P,actions:e,limit:1e3});v(t?.items??[])}catch(e){console.error(`Unable to load action flows:`,e),c.message.error(`Unable to load action steps.`)}finally{O(!1)}}},[d?.id,N,P]),ae=(0,s.useCallback)(async()=>{if(!(!a||!d?.name)){M(!0);try{let t=await Lx(a);await ne(d.name,t.module);let n=await Fx({product_parent_ID:t.product_parent_ID,module_parent_ID:t.module_parent_ID,submodule_parent_ID:t.submodule_parent_ID,limit:1e3});v(n?.items??[]),e.setFieldsValue({module:t.module_parent_ID,submodule:t.submodule_parent_ID,step_order:t.step_order,actions:t.actions,key:t.key,value:t.value,expected:t.expected,description:t.description,scenario:t.scenario===1,active:Number(t.active)!==0})}catch(e){console.error(`Unable to load test flow:`,e),c.message.error(`Unable to load test flow for edit.`),r(`/viewTestCase`)}finally{M(!1)}}},[a,e,ne,r,d?.name]);return(0,s.useEffect)(()=>{if(!d){r(`/select-project`,{replace:!0});return}Promise.resolve().then(async()=>{await ee(),await te(d.name),a&&await ae()})},[d,r,ee,te,a,ae]),d?(0,u.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,u.jsxs)(c.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,u.jsx)(c.Col,{children:(0,u.jsx)(n.s,{items:zF})}),(0,u.jsx)(c.Col,{children:(0,u.jsxs)(c.Space,{size:6,className:`zt-section-title`,children:[(0,u.jsx)(l.ProjectOutlined,{}),(0,u.jsx)(RF,{strong:!0,children:d.name})]})})]}),(0,u.jsx)(`div`,{className:`zt-page`,children:(0,u.jsxs)(c.Form,{form:e,layout:`vertical`,colon:!1,className:`v1-form`,initialValues:{scenario:!0,active:!0},onFinish:async t=>{let n={product_parent_ID:Number(d?.id),module_parent_ID:Number(t.module),submodule_parent_ID:Number(t.submodule),description:BF(t.description),actions:BF(t.actions),key:BF(t.key),value:BF(t.value),expected:BF(t.expected),scenario:+!!t.scenario,active:+!!t.active};A(!0);try{if(o){await zx(a,{...n,step_order:Number(t.step_order)}),c.message.success(`Test case updated successfully.`),r(`/viewTestCase`);return}await Ix(n),c.message.success(`Step saved (#${t.step_order}).`),e.setFieldsValue({actions:void 0,key:void 0,value:void 0,expected:void 0,description:void 0}),await re(n.product_parent_ID,n.module_parent_ID,n.submodule_parent_ID)}catch(e){console.error(`Unable to save test case:`,e),c.message.error(o?`Unable to update test case.`:`Unable to save step.`)}finally{A(!1)}},autoComplete:`off`,disabled:j,children:[(0,u.jsx)(c.Card,{className:`v1-card zt-fall`,title:(0,u.jsxs)(c.Space,{size:8,className:`zt-section-title`,children:[(0,u.jsx)(`span`,{className:`zt-step-tag`,children:`1`}),(0,u.jsx)(`span`,{children:`Module & Submodule`})]}),children:(0,u.jsxs)(c.Row,{gutter:[24,0],align:`bottom`,children:[(0,u.jsx)(c.Col,{xs:24,md:6,children:(0,u.jsx)(c.Form.Item,{label:`Module`,name:`module`,children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,loading:C,placeholder:`Select module`,options:z,onChange:t=>{let n=p.find(e=>e.id===t)?.modulename??``;e.setFieldsValue({module:t,submodule:void 0,step_order:void 0,actions:void 0,key:void 0,value:void 0,expected:void 0}),GF(e,[`actions`,`key`,`value`,`expected`]),g([]),v([]),ne(d?.name,n)}})})}),(0,u.jsx)(c.Col,{xs:24,md:6,children:(0,u.jsx)(c.Form.Item,{label:`Submodule`,name:`submodule`,children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,disabled:!I,loading:T,placeholder:I?`Select submodule`:`Select module first`,options:B,onChange:t=>{e.setFieldsValue({submodule:t,actions:void 0,key:void 0,value:void 0,expected:void 0}),GF(e,[`actions`,`key`,`value`,`expected`]),re(d?.id,N,t)}})})}),(0,u.jsx)(c.Col,{xs:24,md:6,children:(0,u.jsx)(c.Form.Item,{label:`Scenario`,name:`scenario`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{disabled:!L,checkedChildren:`Positive`,unCheckedChildren:`Negative`})})}),(0,u.jsx)(c.Col,{xs:24,md:6,children:(0,u.jsx)(c.Form.Item,{label:`Active`,name:`active`,valuePropName:`checked`,children:(0,u.jsx)(c.Switch,{checkedChildren:`Active`,unCheckedChildren:`Inactive`})})})]})}),L&&(0,u.jsxs)(c.Card,{className:`v1-card zt-fall`,title:(0,u.jsxs)(c.Space,{size:8,className:`zt-section-title`,children:[(0,u.jsx)(`span`,{className:`zt-step-tag`,children:`2`}),(0,u.jsx)(l.FileTextOutlined,{}),(0,u.jsx)(`span`,{children:`Step Details`})]}),extra:(0,u.jsxs)(RF,{type:`secondary`,children:[V,` / `,H]}),children:[(0,u.jsxs)(c.Row,{gutter:[24,0],children:[(0,u.jsx)(c.Col,{xs:24,md:6,children:(0,u.jsx)(c.Form.Item,{label:`Step Order`,name:`step_order`,children:(0,u.jsx)(c.Input,{disabled:!0,placeholder:D?`Loading…`:`Auto`})})}),(0,u.jsx)(c.Col,{xs:24,md:18,children:(0,u.jsx)(c.Form.Item,{label:`Action`,name:`actions`,rules:[{required:!0,message:`Mandatory Field`}],children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,optionFilterProp:`label`,placeholder:`Select action`,options:y,onChange:t=>{let n=WF(x,t);e.setFieldsValue({actions:t,key:n.key?e.getFieldValue(`key`):void 0,value:n.value?e.getFieldValue(`value`):void 0,expected:n.expected?e.getFieldValue(`expected`):void 0}),GF(e,[`key`,`value`,`expected`]),ie(t||``)}})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Key`,name:`key`,rules:[{required:R.key,message:`Key is required for this action`}],children:(0,u.jsx)(c.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,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Value`,name:`value`,rules:[{required:R.value,message:`Value is required for this action`}],children:(0,u.jsx)(c.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,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Expected`,name:`expected`,rules:[{required:R.expected,message:`Expected result is required for this action`}],children:(0,u.jsx)(c.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,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Description`,name:`description`,children:(0,u.jsx)(c.Input.TextArea,{rows:2,maxLength:255,showCount:!0,placeholder:`Enter description`})})})]}),(0,u.jsxs)(c.Space,{className:`zt-actions`,children:[(0,u.jsx)(c.Button,{onClick:()=>{if(o){r(`/viewTestCase`);return}e.resetFields(),g([]),v([]),E(!1),O(!1)},children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,htmlType:`submit`,loading:k||j,children:o?`Update Test Case`:`Save & Continue`})]})]},`${N}-${P}`),L&&(0,u.jsx)(c.Card,{className:`v1-card zt-fall`,title:(0,u.jsxs)(c.Space,{size:6,className:`zt-section-title`,children:[(0,u.jsx)(l.TableOutlined,{}),(0,u.jsx)(`span`,{children:`Added Steps`})]}),extra:(0,u.jsx)(c.Tag,{children:F?`${_.length} ${F} step(s)`:`${_.length} step(s)`}),children:(0,u.jsx)(kh,{listName:`Added Steps`,loading:D,fields:HF,dataSource:_,current:1,pageSize:Math.max(_.length,1),total:_.length,rowSelection:!1,className:`zt-list-plain zt-list-static`})})]})})]}):null}var{Text:qF}=c.Typography,JF=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`}];function YF(){let e=(0,f.useNavigate)(),r=(0,s.useMemo)(()=>t.l(),[]),[i,a]=(0,s.useState)([]),[o,d]=(0,s.useState)({}),[p,m]=(0,s.useState)(!1),[h,g]=(0,s.useState)(!1),[_,v]=(0,s.useState)(``),[y,b]=(0,s.useState)(!1),[x,S]=(0,s.useState)(1),[C,w]=(0,s.useState)(10),T=(0,s.useCallback)(async e=>{if(!e){a([]);return}m(!0);try{let[t,n]=await Promise.all([kx({project:e}),Mx({project:e})]);a(t?.items??[]);let r={};(n?.items??[]).forEach(e=>{let t=e.modulename;r[t]=(r[t]??0)+1}),d(r)}catch(e){console.error(e),c.message.error(`Unable to load modules.`)}finally{m(!1)}},[]);(0,s.useEffect)(()=>{if(!r){e(`/select-project`,{replace:!0});return}Promise.resolve().then(()=>T(r.name))},[r,e,T]);let E=async(e,t)=>{try{await jx(e.id,+!!t),a(n=>n.map(n=>n.id===e.id?{...n,active:+!!t}:n)),c.message.success(`Module ${t?`activated`:`deactivated`}.`)}catch(e){console.error(e),c.message.error(`Unable to update module status.`)}},D=async()=>{let e=_.trim();if(!e){c.message.warning(`Enter a module name.`);return}b(!0);try{await Ax({project:r.name,modulename:e}),c.message.success(`Module added.`),g(!1),v(``),S(1),T(r.name)}catch(e){console.error(e),c.message.error(`Unable to add module (maybe it already exists).`)}finally{b(!1)}},O=t=>{e(`/test-cases/zinnext/submodules?module=${encodeURIComponent(t.modulename)}`)};return r?(0,u.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,u.jsxs)(c.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,u.jsx)(c.Col,{children:(0,u.jsx)(n.s,{items:JF})}),(0,u.jsx)(c.Col,{children:(0,u.jsx)(c.Button,{type:`link`,onClick:()=>e(`/addTestCase`),children:`Back to Form`})})]}),(0,u.jsxs)(`div`,{className:`zt-page`,children:[(0,u.jsx)(c.Card,{className:`v1-card zt-bar`,children:(0,u.jsxs)(c.Row,{gutter:[16,16],align:`middle`,justify:`space-between`,children:[(0,u.jsx)(c.Col,{children:(0,u.jsxs)(c.Space,{size:6,className:`zt-section-title`,children:[(0,u.jsx)(l.ProjectOutlined,{}),(0,u.jsx)(`span`,{children:`Project:`}),(0,u.jsx)(qF,{strong:!0,children:r.name})]})}),(0,u.jsx)(c.Col,{children:(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>g(!0),children:`Add Module`})})]})}),(0,u.jsx)(c.Card,{className:`v1-card zt-fall`,title:(0,u.jsxs)(c.Space,{size:6,className:`zt-section-title`,children:[(0,u.jsx)(l.AppstoreOutlined,{}),(0,u.jsx)(`span`,{children:`Modules`})]}),children:(0,u.jsx)(kh,{listName:`Modules`,loading:p,fields:[{label:`Module`,value:`modulename`},{label:`Submodules`,value:`submoduleCount`,width:140,render:(e,t)=>(0,u.jsxs)(c.Button,{type:`link`,className:`zt-count-link`,onClick:()=>O(t),children:[o[t.modulename]??0,` submodule(s)`]})},{label:`Active`,value:`active`,width:120,render:(e,t)=>(0,u.jsx)(c.Switch,{checked:e===1,checkedChildren:`On`,unCheckedChildren:`Off`,onChange:e=>E(t,e)})}],dataSource:i,current:x,pageSize:C,total:i.length,onPageChange:S,onPageSizeChange:e=>{S(1),w(e)},rowSelection:!1,className:`zt-list-plain`})})]}),(0,u.jsx)(c.Modal,{title:`Add Module`,open:h,confirmLoading:y,okText:`Add`,onOk:D,onCancel:()=>{g(!1),v(``)},destroyOnHidden:!0,children:(0,u.jsxs)(c.Space,{direction:`vertical`,className:`zt-modal-stack`,children:[(0,u.jsxs)(qF,{type:`secondary`,children:[`Project: `,(0,u.jsx)(`b`,{children:r.name})]}),(0,u.jsx)(c.Input,{placeholder:`Enter module name`,maxLength:100,value:_,onChange:e=>v(e.target.value),onPressEnter:D})]})})]}):null}var{Text:XF}=c.Typography,ZF=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`},{label:`Manage Submodules`,href:`/test-cases/zinnext/submodules`}];function QF(){let e=(0,f.useNavigate)(),[r]=(0,f.useSearchParams)(),i=(0,s.useMemo)(()=>t.l(),[]),a=r.get(`module`)??``,[o,d]=(0,s.useState)([]),[p,m]=(0,s.useState)(!1),[h,g]=(0,s.useState)(!1),[_,v]=(0,s.useState)(``),[y,b]=(0,s.useState)(!1),[x,S]=(0,s.useState)(1),[C,w]=(0,s.useState)(10),T=(0,s.useCallback)(async(e,t)=>{if(!e||!t){d([]);return}m(!0);try{let n=await Mx({project:e,module:t});d(n?.items??[])}catch(e){console.error(e),c.message.error(`Unable to load submodules.`)}finally{m(!1)}},[]);(0,s.useEffect)(()=>{if(!i){e(`/select-project`,{replace:!0});return}if(!a){e(`/manageModules`,{replace:!0});return}Promise.resolve().then(()=>T(i.name,a))},[i,a,e,T]);let E=async(e,t)=>{try{await Px(e.id,+!!t),d(n=>n.map(n=>n.id===e.id?{...n,active:+!!t}:n)),c.message.success(`Submodule ${t?`activated`:`deactivated`}.`)}catch(e){console.error(e),c.message.error(`Unable to update submodule status.`)}},D=async()=>{let e=_.trim();if(!e){c.message.warning(`Enter a submodule name.`);return}b(!0);try{await Nx({project:i.name,modulename:a,submodulename:e}),c.message.success(`Submodule added.`),g(!1),v(``),S(1),T(i.name,a)}catch(e){console.error(e),c.message.error(`Unable to add submodule (maybe it already exists).`)}finally{b(!1)}};return!i||!a?null:(0,u.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,u.jsxs)(c.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,u.jsx)(c.Col,{children:(0,u.jsx)(n.s,{items:ZF})}),(0,u.jsx)(c.Col,{children:(0,u.jsx)(c.Button,{type:`link`,onClick:()=>e(`/manageModules`),children:`Back to Modules`})})]}),(0,u.jsxs)(`div`,{className:`zt-page`,children:[(0,u.jsx)(c.Card,{className:`v1-card zt-bar`,children:(0,u.jsxs)(c.Row,{gutter:[16,16],align:`middle`,justify:`space-between`,children:[(0,u.jsx)(c.Col,{children:(0,u.jsxs)(c.Space,{size:16,wrap:!0,className:`zt-section-title`,children:[(0,u.jsxs)(c.Space,{size:6,children:[(0,u.jsx)(l.ProjectOutlined,{}),(0,u.jsx)(`span`,{children:`Project:`}),(0,u.jsx)(XF,{strong:!0,children:i.name})]}),(0,u.jsxs)(c.Space,{size:6,children:[(0,u.jsx)(l.AppstoreOutlined,{}),(0,u.jsx)(`span`,{children:`Module:`}),(0,u.jsx)(XF,{strong:!0,children:a})]})]})}),(0,u.jsx)(c.Col,{children:(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:()=>g(!0),children:`Add Submodule`})})]})}),(0,u.jsx)(c.Card,{className:`v1-card zt-fall`,title:(0,u.jsxs)(c.Space,{size:6,className:`zt-section-title`,children:[(0,u.jsx)(l.AppstoreOutlined,{}),(0,u.jsx)(`span`,{children:`Submodules`})]}),children:(0,u.jsx)(kh,{listName:`Submodules`,loading:p,fields:[{label:`Submodule`,value:`submodulename`},{label:`Active`,value:`active`,width:120,render:(e,t)=>(0,u.jsx)(c.Switch,{checked:e===1,checkedChildren:`On`,unCheckedChildren:`Off`,onChange:e=>E(t,e)})}],dataSource:o,current:x,pageSize:C,total:o.length,onPageChange:S,onPageSizeChange:e=>{S(1),w(e)},rowSelection:!1,className:`zt-list-plain`})})]}),(0,u.jsx)(c.Modal,{title:`Add Submodule`,open:h,confirmLoading:y,okText:`Add`,onOk:D,onCancel:()=>{g(!1),v(``)},destroyOnHidden:!0,children:(0,u.jsxs)(c.Space,{direction:`vertical`,className:`zt-modal-stack`,children:[(0,u.jsxs)(XF,{type:`secondary`,children:[`Project: `,(0,u.jsx)(`b`,{children:i.name}),` \xA0|\xA0 Module: `,(0,u.jsx)(`b`,{children:a})]}),(0,u.jsx)(c.Input,{placeholder:`Enter submodule name`,maxLength:100,value:_,onChange:e=>v(e.target.value),onPressEnter:D})]})})]})}var{Text:$F}=c.Typography,eI=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Table`,href:`/viewTestCase`}];function tI(){let e=(0,f.useNavigate)(),[r,i]=(0,s.useState)([]),[a,o]=(0,s.useState)(0),[d,p]=(0,s.useState)(!1),m=(0,s.useMemo)(()=>t.l(),[]),[h,g]=(0,s.useState)(``),[_,v]=(0,s.useState)(1),[y,b]=(0,s.useState)(20),[x,S]=(0,s.useState)(null),C=(0,s.useCallback)(async(e={})=>{p(!0);try{let t=await Fx({product_parent_ID:e.project??m?.id??``,search:e.search??h??``,limit:e.pageSize??y,offset:((e.page??_)-1)*(e.pageSize??y)});i(t?.items??[]),o(t?.total??0)}catch(e){console.error(e),c.message.error(`Unable to load test flows.`)}finally{p(!1)}},[m?.id,h,_,y]),w=e=>{c.Modal.confirm({title:`Delete Test Case`,icon:(0,u.jsx)(l.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 Bx(e.id),c.message.success(`Test case deleted successfully.`);let t=r.length===1&&_>1?_-1:_;v(t),await C({page:t})}catch(e){throw console.error(`Unable to delete test flow:`,e),c.message.error(`Unable to delete test case.`),e}finally{S(null)}}})};return(0,s.useEffect)(()=>{Promise.resolve().then(()=>{if(!m?.id){e(`/select-project`,{replace:!0});return}C({page:1})})},[]),(0,u.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,u.jsxs)(c.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,u.jsx)(c.Col,{children:(0,u.jsx)(n.s,{items:eI})}),(0,u.jsx)(c.Col,{children:(0,u.jsx)(c.Button,{type:`link`,onClick:()=>e(`/addTestCase`),children:`Back to Form`})})]}),(0,u.jsx)(`div`,{className:`zt-page zt-page-wide`,children:(0,u.jsxs)(c.Card,{className:`v1-card`,title:(0,u.jsxs)(c.Space,{size:6,className:`zt-section-title`,children:[(0,u.jsx)(l.TableOutlined,{}),(0,u.jsx)(`span`,{children:`Test Flows`})]}),extra:(0,u.jsxs)($F,{type:`secondary`,children:[a,` row(s)`]}),children:[(0,u.jsxs)(c.Space,{wrap:!0,className:`zt-toolbar`,children:[(0,u.jsx)(c.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,u.jsx)(c.Button,{icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:()=>C(),children:`Refresh`})]}),(0,u.jsx)(kh,{listName:`Test Flows`,loading:d,fields:[{label:`Actions`,value:`rowActions`,width:112,fixed:`left`,sorter:!1,render:(t,n)=>(0,u.jsxs)(c.Space,{size:4,className:`zt-row-actions`,children:[(0,u.jsx)(c.Tooltip,{title:`Edit`,children:(0,u.jsx)(c.Button,{type:`text`,size:`small`,icon:(0,u.jsx)(l.EditOutlined,{}),onClick:()=>e(`/addTestCase?edit=${n.id}`)})}),(0,u.jsx)(c.Tooltip,{title:`Delete`,children:(0,u.jsx)(c.Button,{danger:!0,type:`text`,size:`small`,icon:(0,u.jsx)(l.DeleteOutlined,{}),loading:x===n.id,onClick:()=>w(n)})})]})},{label:`ID`,value:`id`,width:70,fixed:`left`},{label:`Project`,value:`project`,width:130},{label:`Module`,value:`module`,width:130},{label:`Submodule`,value:`submodule`,width:140},{label:`Step`,value:`step_order`,width:70},{label:`Action`,value:`actions`,width:140},{label:`Key`,value:`key`,width:160,ellipsis:!0},{label:`Value`,value:`value`,width:200,ellipsis:!0},{label:`Expected`,value:`expected`,width:180,ellipsis:!0},{label:`Description`,value:`description`,width:180,ellipsis:!0},{label:`Scenario`,value:`scenario`,width:110,render:e=>e===1?(0,u.jsx)(c.Tag,{color:`green`,children:`Positive`}):(0,u.jsx)(c.Tag,{color:`red`,children:`Negative`})},{label:`Active`,value:`active`,width:90,render:e=>e===1?(0,u.jsx)(c.Tag,{color:`blue`,children:`Active`}):(0,u.jsx)(c.Tag,{children:`Inactive`})}],dataSource:r,current:_,pageSize:y,total:a,onPageChange:e=>{v(e),C({page:e})},onPageSizeChange:e=>{v(1),b(e),C({page:1,pageSize:e})},rowSelection:!1,className:`zt-list-plain`})]})})]})}var nI=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}];function rI(){return(0,u.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,u.jsx)(n.s,{items:nI}),(0,u.jsx)(ls,{moduleName:`test-flows`,rowKey:`id`})]})}var{Text:iI}=c.Typography,aI=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}],oI={tags:`regression`,active:1},sI={module:{dbName:`Modules`,formField:`module`,label:`Module`}},cI={key:!1,value:!1,expected:!1};function lI(e,t){return t?e[t]??cI:cI}function uI(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function dI(e=[]){return e.map(e=>({value:e,label:e}))}function fI(e=``){return String(e??``).trim()}function pI(e=[]){let t=new Map;return e.forEach(e=>{let n=fI(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function mI(e=[],t,n){let r=fI(t).toLowerCase(),i=fI(n).toLowerCase();return e.reduce((e,t)=>{let n=fI(t?.module).toLowerCase(),a=fI(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 hI({icon:e,title:t}){return(0,u.jsxs)(c.Space,{size:10,align:`center`,children:[(0,u.jsx)(`div`,{className:`v1-section-icon-box`,children:e}),(0,u.jsx)(iI,{strong:!0,className:`v1-section-label`,children:t})]})}function gI(){let[e]=c.Form.useForm(),[t]=c.Form.useForm(),[r,i]=(0,s.useState)([]),[a,o]=(0,s.useState)([]),[d,p]=(0,s.useState)([]),[m,h]=(0,s.useState)(EF),[g,_]=(0,s.useState)({}),[v,y]=(0,s.useState)(!1),[b,x]=(0,s.useState)(!1),[S,C]=(0,s.useState)({open:!1,typeKey:`module`}),[w,T]=(0,s.useState)(!1),[E,D]=(0,s.useState)(!1),[O,k]=(0,s.useState)(!1),A=(0,f.useNavigate)(),j=sI[S.typeKey],M=(0,s.useMemo)(()=>dI(r),[r]),N=c.Form.useWatch(`module`,e),P=c.Form.useWatch(`flow`,e),F=c.Form.useWatch(`keyword`,e),I=!!fI(N),L=!!fI(P),R=!I,z=!I||!L,B=(0,s.useMemo)(()=>lI(g,F),[g,F]),V=(e,t=[])=>{e===`module`&&i(t)},H=async()=>{y(!0);try{let e=await yx(sI.module.dbName);i(e?.items??[])}catch(e){console.error(`Unable to load testing options:`,e),c.message.error(`Unable to load testing options.`)}finally{y(!1)}},ee=async()=>{try{let e=await xx();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),c.message.error(`Unable to load action validation rules.`)}},te=(0,s.useCallback)(async t=>{let n=fI(t);if(o([]),p([]),e.setFieldsValue({step_order:void 0}),n){x(!0);try{let e=await Dx({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];o(t),p(pI(t))}catch(e){console.error(`Unable to load flows:`,e),c.message.error(`Unable to load flows.`)}finally{x(!1)}}},[e]),ne=(0,s.useCallback)(async(t,n,r)=>{let i=fI(t),a=fI(n);if(!i||!a){e.setFieldsValue({step_order:void 0});return}D(!0);try{e.setFieldsValue({step_order:mI(r,i,a)})}catch(e){console.error(`Unable to load step order:`,e),c.message.error(`Unable to load step order.`)}finally{D(!1)}},[e]);(0,s.useEffect)(()=>{Promise.resolve().then(async()=>{await Promise.all([H(),ee()])})},[]),(0,s.useEffect)(()=>{Promise.resolve().then(()=>te(N))},[te,N]),(0,s.useEffect)(()=>{Promise.resolve().then(()=>ne(N,P,a))},[a,ne,P,N]);let re=async t=>{let n={module:fI(t.module),flow:fI(t.flow),step_order:Number(t.step_order),description:fI(t.description),keyword:fI(t.keyword),target:fI(t.target),value:fI(t.value),expected:fI(t.expected),tags:t.tags?fI(t.tags):oI.tags,active:Number(t.active)};k(!0);try{await Ex(n),c.message.success(`LMS case details saved successfully.`),e.resetFields(),o([]),p([])}catch(e){console.error(`Unable to save LMS case:`,e),c.message.error(`Unable to save LMS case.`)}finally{k(!1)}},ie=(t,n)=>{e.setFieldsValue({[t]:fI(n)})},ae=t=>{e.setFieldsValue({module:fI(t),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:oI.tags,value:void 0,expected:void 0}),uI(e,[`keyword`,`target`,`value`,`expected`])},oe=t=>{e.setFieldsValue({flow:fI(t),step_order:void 0,keyword:void 0,target:void 0,value:void 0,expected:void 0}),uI(e,[`keyword`,`target`,`value`,`expected`])},se=t=>{let n=lI(g,t);e.setFieldsValue({keyword:fI(t),target:n.key?e.getFieldValue(`target`):void 0,value:n.value?e.getFieldValue(`value`):void 0,expected:n.expected?e.getFieldValue(`expected`):void 0}),uI(e,[`target`,`value`,`expected`])},ce=e=>{let n=sI[e];C({open:!0,typeKey:e}),t.setFieldsValue({name:``,type:n.label})},U=()=>{C(e=>({...e,open:!1})),t.resetFields()},W=async()=>{try{let n=fI((await t.validateFields()).name),r=await bx({name:n,type:j.dbName});V(S.typeKey,r?.items??[]),e.setFieldsValue({[j.formField]:n}),c.message.success(`${j.label} added successfully.`),U()}catch(e){if(e?.errorFields)return;console.error(`Unable to save testing option:`,e),c.message.error(`Unable to add ${j.label.toLowerCase()}.`)}finally{T(!1)}};return(0,u.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,u.jsxs)(c.Row,{align:`middle`,justify:`space-between`,className:`breadcrumb-action-wrapper`,children:[(0,u.jsx)(c.Col,{children:(0,u.jsx)(n.s,{items:aI})}),(0,u.jsx)(c.Col,{children:(0,u.jsx)(c.Button,{type:`link`,onClick:()=>A(`/lms-home`),children:`View Table`})})]}),(0,u.jsx)(`div`,{className:`v1-page`,children:(0,u.jsxs)(`div`,{className:`v1-page-inner`,children:[(0,u.jsx)(`div`,{className:`v1-page-header`,children:(0,u.jsxs)(c.Space,{align:`center`,size:10,children:[(0,u.jsx)(l.ProfileOutlined,{className:`v1-outer-icon`}),(0,u.jsx)(`div`,{children:(0,u.jsx)(iI,{strong:!0,style:{fontSize:16},children:`Add LMS Case`})})]})}),(0,u.jsx)(Z,{children:(0,u.jsxs)(c.Form,{form:e,className:`v1-form`,layout:`vertical`,colon:!1,requiredMark:(e,{required:t})=>(0,u.jsxs)(u.Fragment,{children:[e,t&&(0,u.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),initialValues:oI,onFinish:re,autoComplete:`off`,children:[(0,u.jsx)(c.Card,{className:`v1-card`,title:(0,u.jsx)(hI,{icon:(0,u.jsx)(l.FileTextOutlined,{}),title:`LMS Case Details`}),extra:(0,u.jsx)(iI,{type:`secondary`,className:`v1-card-subtitle`,children:`Module, flow, step order and execution data`}),children:(0,u.jsxs)(c.Row,{gutter:[24,0],children:[(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsxs)(c.Space.Compact,{style:{width:`100%`},children:[(0,u.jsx)(c.Form.Item,{label:`Module`,name:`module`,style:{flex:1},children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,loading:v,optionFilterProp:`label`,placeholder:`Select module`,options:M,onChange:ae})}),(0,u.jsx)(c.Button,{"aria-label":`Add module`,icon:(0,u.jsx)(l.PlusOutlined,{}),style:{marginTop:30},onClick:()=>ce(`module`)})]})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Flow`,name:`flow`,children:(0,u.jsx)(c.AutoComplete,{maxLength:100,allowClear:!0,disabled:R,options:d,placeholder:b?`Loading flows`:`Enter flow`,onChange:oe,filterOption:(e,t)=>t?.value?.toLowerCase().includes(e.toLowerCase())})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Step Order`,name:`step_order`,validateTrigger:[`onBlur`,`onChange`],children:(0,u.jsx)(c.Input,{maxLength:10,disabled:!0,placeholder:E?`Loading step order`:`Step order`})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Action`,name:`keyword`,children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,disabled:z,optionFilterProp:`label`,placeholder:`Select action`,options:m,onChange:se})})}),(0,u.jsx)(c.Col,{xs:24,children:(0,u.jsx)(c.Form.Item,{label:`Description`,name:`description`,children:(0,u.jsx)(c.Input.TextArea,{rows:3,maxLength:255,disabled:z,placeholder:`Enter description`,showCount:!0,onBlur:e=>ie(`description`,e.target.value)})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Key`,name:`target`,rules:[{required:B.key,message:`Key is required for this action`}],children:(0,u.jsx)(c.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=>ie(`target`,e.target.value)})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Tags`,name:`tags`,children:(0,u.jsx)(c.Input,{maxLength:200,disabled:z,placeholder:`Enter tags`,prefix:(0,u.jsx)(l.TagsOutlined,{className:`v1-input-icon`}),onBlur:e=>ie(`tags`,e.target.value)})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Value`,name:`value`,rules:[{required:B.value,message:`Value is required for this action`}],children:(0,u.jsx)(c.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=>ie(`value`,e.target.value)})})}),(0,u.jsx)(c.Col,{xs:24,md:12,children:(0,u.jsx)(c.Form.Item,{label:`Expected`,name:`expected`,rules:[{required:B.expected,message:`Expected result is required for this action`}],children:(0,u.jsx)(c.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=>ie(`expected`,e.target.value)})})})]})}),(0,u.jsx)(`div`,{className:`v1-form-actions`,children:(0,u.jsx)(c.Form.Item,{children:(0,u.jsxs)(c.Space,{children:[(0,u.jsx)(c.Button,{type:`primary`,htmlType:`submit`,loading:O,disabled:z,children:`Submit`}),(0,u.jsx)(c.Button,{onClick:()=>{e.resetFields(),o([]),p([])},children:`Reset`})]})})})]})}),(0,u.jsx)(c.Modal,{title:`Add ${j.label}`,open:S.open,confirmLoading:w,okText:`Add`,onCancel:U,onOk:()=>{T(!0),W()},destroyOnHidden:!0,children:(0,u.jsxs)(c.Form,{form:t,layout:`vertical`,colon:!1,className:`v1-form`,requiredMark:(e,{required:t})=>(0,u.jsxs)(u.Fragment,{children:[e,t&&(0,u.jsx)(`span`,{className:`v1-required-mark`,children:` *`})]}),children:[(0,u.jsx)(c.Form.Item,{label:`Name`,name:`name`,children:(0,u.jsx)(c.Input,{maxLength:100,placeholder:`Enter ${j.label.toLowerCase()} name`,onBlur:e=>{t.setFieldsValue({name:fI(e.target.value)})}})}),(0,u.jsx)(c.Form.Item,{label:`Type`,name:`type`,children:(0,u.jsx)(c.Input,{disabled:!0})})]})})]})})]})}var _I=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}];function vI(){return(0,u.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,u.jsx)(n.s,{items:_I}),(0,u.jsx)(ls,{moduleName:`lms-flows`,rowKey:`id`})]})}var yI=[`referenceId`,`ReferenceId`,`candidateId`,`CandidateId`,`entityId`,`EntityId`,`id`,`Id`,`_id`];function bI(e=yI){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 xI(e,t=yI){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 SI=bI();function CI(e){return typeof e==`function`?e:typeof e==`string`?bI([e]):Array.isArray(e)?bI(e):SI}function wI(e,t,n){return!t||typeof t!=`object`?e:{...t,...e,id:e?.id??t?.id??n}}function TI(e,t,n={}){return{status:`success`,total:t,data:{data:e,...n}}}var EI=[`fields`,`fieldConfig`,`tabs`,`tabField`,`actionRules`,`actions`,`columnActions`];function DI(e){let t=e?.data??e,n={};for(let r of EI){let i=e?.[r]??t?.[r];i==null||Array.isArray(i)&&i.length===0||(n[r]=i)}return n}var OI=e=>String(e??``).replace(/[^a-zA-Z0-9]/g,``).toLowerCase();function kI(e,t,n){let r=(Array.isArray(n)?n:[n]).map(OI).filter(Boolean),i=r.length?e.findIndex(e=>r.includes(OI(e?.value))||r.includes(OI(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 AI=(e,t)=>gi(e,t).rows,jI=(e,t)=>{let{rows:n,total:r}=gi(e,t);return{rows:n,total:r}};function MI(e,t){return function(n,r,i,a={}){return e(t??n,r,i,a)}}function NI(e){return!e||typeof e!=`object`||typeof(e.fetchByKeys??e.fetch??e.function)!=`function`?null:{...e,fetchByKeys:typeof e.fetchByKeys==`function`?e.fetchByKeys:null,fetch:typeof e.fetch==`function`?e.fetch:null,function:typeof e.function==`function`?e.function:null,extractRows:typeof e.extractRows==`function`?e.extractRows:AI,mergeRow:typeof e.mergeRow==`function`?e.mergeRow:wI,fetchById:typeof e.fetchById==`function`?e.fetchById:null}}function PI({fetchSecondaryByKeys:e,fetchSecondary:t,extractSecondaryRows:n,fetchSecondaryById:r,secondaryKey:i,mergeRow:a,secondaryFetchLimit:o}){return!e&&!t&&!r?[]:[NI({key:i,fetchByKeys:e?(t,n,r)=>e(t,n,r):null,function:t?({moduleName:e,options:n})=>t(e,o,0,n):null,extractRows:n,fetchById:r,mergeRow:a})].filter(Boolean)}function FI(e){if(typeof e==`function`)return t=>{let n=e(t);return n==null||n===``?[]:[String(n)]};let t=typeof e==`string`?[e]:Array.isArray(e)&&e.length?e:yI;return e=>xI(e,t)}function II(e,t){let n=new Map;return e.forEach(e=>{for(let r of t(e))n.has(r)||n.set(r,e)}),n}function LI({moduleName:e,limit:t,offset:n,options:r,keys:i,primaryResponse:a,primaryRows:o,pageRows:s,total:c,source:l}){return{moduleName:e,limit:t,offset:n,options:r,keys:i,primaryResponse:a,primaryRows:o,pageRows:s,total:c,source:l}}async function RI(e,t){if(typeof e.args==`function`){let n=e.args(t);return(e.fetch??e.function??e.fetchByKeys)(...Array.isArray(n)?n:[n])}if(Array.isArray(e.args))return(e.fetch??e.function??e.fetchByKeys)(...e.args);if(e.fetchByKeys&&Array.isArray(t.keys))return e.fetchByKeys(t.moduleName,t.keys,t.options,t);let n=e.fetch??e.function;return typeof n==`function`?n(t):null}function zI({fetchPrimaryPage:e,extractPrimaryPage:t=jI,fetchSecondaryByKeys:n,joinSources:r=[],fetchPrimary:i,extractPrimaryRows:a=AI,fetchSecondary:o,extractSecondaryRows:s=AI,fetchSecondaryById:c,primaryKey:l,secondaryKey:u,mergeRow:d=wI,secondaryFetchLimit:f=200,extraFields:p=[],extraFieldsAfter:m}){let h=Array.isArray(r)&&r.length?r.map(NI).filter(Boolean):PI({fetchSecondaryByKeys:n,fetchSecondary:o,extractSecondaryRows:s,fetchSecondaryById:c,secondaryKey:u,mergeRow:d,secondaryFetchLimit:f}),g=0;async function _(e,t,n,r){if(!e.fetchById||!r)return null;try{let i=await e.fetchById(n,r);return i&&t(i).includes(String(r))?i:null}catch(e){return console.error(`[mergedListApi] per-id join lookup failed for "${r}"`,e),null}}async function v(e,t,n,r,i){if(!n)return e;let a=t.extractRows(n,r)??[],o=CI(t.primaryKey??l),s=FI(t.key),c=II(a,s);return Promise.all(e.map(async e=>{let n=o(e),a=c.get(n)??(i()?null:await _(t,s,r,n));return t.mergeRow(e,a,n)}))}async function y(e,t,n,r){let i=e;for(let e of t)i=await v(i,e.source,e.response,n,r);return i}function b(e,t,n){let r={};for(let e of n){if(!e)continue;let t=DI(e);for(let e of Object.keys(t))r[e]??(r[e]=t[e])}return p.length&&(r.fields=kI(r.fields??[],p,m)),TI(e,t,r)}async function x({moduleName:e,limit:t,offset:n,options:r,primaryResponse:i,primaryRows:a,pageRows:o,total:s}){return Promise.all(h.map(async c=>{try{let u=CI(c.primaryKey??l),d=[...new Set(o.map(u).filter(Boolean))];return c.fetchByKeys&&d.length===0?{source:c,response:null}:{source:c,response:await RI(c,LI({moduleName:e,limit:t,offset:n,options:r,keys:d,primaryResponse:i,primaryRows:a,pageRows:o,total:s,source:c}))}}catch(e){return console.error(`[mergedListApi] join fetch failed — rendering page without that join`,e),{source:c,response:null}}}))}async function S(n,r,i,a,o){let s=await e(n,r,i,a),c=t(s,n)??{},l=Array.isArray(c.rows)?c.rows:[],u=Number.isFinite(Number(c.total))?Number(c.total):l.length,d=await x({moduleName:n,limit:r,offset:i,options:a,primaryResponse:s,primaryRows:l,pageRows:l,total:u});return b(await y(l,d,n,o),u,[s,...d.map(e=>e.response)])}async function C(e,t,n,r,o){let s=await i(e,t,n,r),c=a(s,e)??[],l=c.length,u=c.slice(n,n+t),d=await x({moduleName:e,limit:t,offset:n,options:r,primaryResponse:s,primaryRows:c,pageRows:u,total:l});return b(await y(u,d,e,o),l,[s,...d.map(e=>e.response)])}return async function(t,n=10,r=0,i={}){let a=++g,o=()=>a!==g;return e?S(t,n,r,i,o):C(t,n,r,i,o)}}function BI(e,t,n={}){return zI({fetchPrimary:()=>wM(e,t),extractPrimaryRows:SM,fetchSecondary:Vn,fetchSecondaryById:TM,secondaryFetchLimit:n.moduleFetchLimit??200})}function VI(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 HI(e){let t=Array.isArray(e?.stages)?e.stages:[];if(!t.length)return e;let n={};for(let e of t){let t=VI(e?.stageName);t&&(n[t]=Number(e?.count)||0)}return{...n,...e}}var UI=e=>{let t=Number(e?.targetSubmission??e?.targetSubmissions);return Number.isFinite(t)&&t>0?t:null};function WI({submittedCountField:e=`submittedCount`,progressField:t=`targetSubmissionProgress`}={}){return function(n,r,i){let a=wI(n,r,i),o=UI(a);return o!=null&&(a[t]=`${Number(a?.[e])||0} of ${o}`),a}}function GI(e={}){let t=WI();return zI({primaryKey:`_id`,extraFields:e.extraFields,extraFieldsAfter:e.extraFieldsAfter,fetchPrimaryPage:Vn,joinSources:[{key:`entityId`,fetchByKeys:(e,t,n,r)=>{let i=Math.max(1,Number(r?.limit)||10);return CM(Math.floor((Number(r?.offset)||0)/i)+1,i)},extractRows:e=>(e?.items??[]).map(HI),mergeRow:(e,n,r)=>{let i=t(e,n,r);return n?._id&&(i.workflowId=n._id),i}}]})}async function KI(e,t=10,n=0,r={},i={}){return gi(await GI(i)(e,t,n,r),e)}async function qI(e,t,n,r=10,i=0,a={}){return gi(await BI(e,t)(n,r,i,a),n)}typeof window<`u`&&(window.__CORE_THEME_BUILD__=`2026-09-22T20:23:00.228Z`);var JI=uP,YI=Ux(cF),XI=Ux(uF),ZI=Ux(TF),QI=Ux(LF),$I=Ux(KF),eL=Ux(YF),tL=Ux(QF),nL=Ux(tI),rL=Ux(rI),iL=Ux(gI),aL=Ux(vI);exports.ADMIN_API_URL=t.v,exports.ADMIN_APP_ID=t.y,exports.APP_ID=t.b,exports.AUTH_URL=t.x,exports.ActivityNotesCard=fl,exports.ActivityTab=tl,exports.AddBatchCandidatePopup=WN,exports.AddFormV1=Rc,exports.AdminDashboard=uP,exports.AdminDashboardContent=$O,exports.AdminPage=JI,exports.AppAlert=zc,exports.AppButton=n.Ot,exports.AppShell=fx,exports.ApprovalActionBar=yv,exports.AssigneeAvatars=pl,exports.AuthGuard=ix,exports.BILLING_STATUS_FLOW=Bf,exports.BOOLEAN_API_KEYS=a_,exports.BOOLEAN_PARSEABLE_API_KEYS=Wh,exports.BULK_UPLOAD_DEFAULT_ACCEPT=ml,exports.BULK_UPLOAD_DEFAULT_MAX_SIZE_MB=hl,exports.Breadcrumb=n.s,exports.BulkUploadPage=ZI,exports.BulkUploadPanel=Cl,exports.CANDIDATES_URL=t.S,exports.CONTRACT_C2C=Uv,exports.CONTRACT_W2=Hv,exports.CORE_URL=t.C,exports.CURRENCY_SYMBOLS=Vu,exports.CalendarCard=j,exports.CoreThemeAdminApp=rk,exports.CoreThemeAdminRoutes=nk,exports.CustomPagination=Be,exports.DEFAULT_HOURS_POLICY=V_,exports.DEFAULT_RESULTS_VIEW=t_,exports.DETAIL_VIEW_MODE_OPTIONS=n.gr,exports.DETAIL_VIEW_MODE_VALUES=n._r,exports.DETAIL_VIEW_POPUP_PATH=n.vr,exports.DayLogModal=dv,exports.DescriptionBlock=Il,exports.DetailHeaderCard=Hp,exports.DetailViewPage=Yp,exports.DetailViewPopup=gA,exports.DetailViewV1=Rd,exports.DocumentViewer=r.t,exports.DynamicCards=Bt,exports.DynamicPopup=Nj,exports.DynamicPopupRoute=YN,exports.DynamicTabs=F,exports.EditFormV1=sh,exports.FIELD_TYPE_REGISTRY=Tg,exports.FINANCE_APPROVAL_CONFIG=Pv,exports.FINANCE_TYPE_CFO=Dv,exports.FINANCE_TYPE_ONBOARDING_MANAGER=Ev,exports.FINANCE_TYPE_ONBOARDING_MANAGER_REAPPROVE=Av,exports.FINANCE_TYPE_ONLY_FINANCE=Ov,exports.FINANCE_TYPE_SUBMISSION_MANAGER=Tv,exports.FINANCE_TYPE_SUBMISSION_MANAGER_REAPPROVE=kv,exports.FileListCard=tb,exports.FinanceApprovalPanel=Py,exports.FinanceAvatar=xp,exports.FinanceBadge=Tp,exports.FinanceDayCell=xv,exports.FinanceDivider=pp,exports.FinanceEmployeeCell=Sp,exports.FinanceEmptyState=up,exports.FinanceEquation=mp,exports.FinanceHistoryTimeline=vp,exports.FinanceHoursGrid=lp,exports.FinanceKpiRow=cp,exports.FinanceLine=fp,exports.FinanceListToolbar=B_,exports.FinanceMarginBadge=Ep,exports.FinanceMoneyCell=wp,exports.FinanceRecordsTable=kp,exports.FinanceRowChevron=Dp,exports.FinanceSection=dp,exports.FinanceStatusPill=sp,exports.FinanceTextCell=Cp,exports.FinanceTimesheetAnalysis=Cv,exports.FinanceWorkflowSteps=hp,exports.GATEWAY_URL=t.w,exports.GLOBAL_DEFAULT_FIELDS=tO,exports.HOURS_MESSAGES=H_,exports.Header=jb,exports.HierarchyUserFilter=Gt,exports.JOBS_URL=t.T,exports.LegacyAdminPage=YI,exports.ListView=ls,exports.LmsHomePage=aL,exports.LmsTestForm=iL,exports.Login=px,exports.MailPopup=rA,exports.ManageModules=eL,exports.ManageSubmodules=tL,exports.ModuleRowActions=gh,exports.NotesPanel=vv,exports.NotesTab=dl,exports.OPEN_AS_OPTIONS=Kg,exports.PAYROLL_STATUS_FLOW=Vf,exports.PLATFORM_SCOPES=QD,exports.POPUP_CONFIGS=FN,exports.PYOPS_URL=t.E,exports.ParamCardView=Ch,exports.ParamListView=kh,exports.PeriodBadgeTag=ev,exports.PlatformSection=EO,exports.PreviewPopup=mA,exports.ProjectSelect=Hx,exports.ProofUploadPreview=_v,exports.QuickLogBar=mv,exports.QuickLogSelectionBar=fv,exports.RESULTS_VIEW_OPTIONS=e_,exports.RegionBanner=lP,exports.RejectionReasonModal=pv,exports.SUBMISSIONS_URL=t.D,exports.SearchBuilderV1=j_,exports.Sidebar=ex,exports.StatusBadge=N_,exports.StatusBadgeTag=$_,exports.StickyNotesFullPage=XI,exports.StylishDynamicTabs=F_,exports.TemplateEditor=L_,exports.TestForm=QI,exports.TestingHomePage=rL,exports.TimelineGroups=qc,exports.TimesheetDayCell=cv,exports.TipTapEditor=n.Xn,exports.UserForm=cP,exports.VendorShareDrawer=$N,exports.ViewSummaryWidget=Hi,exports.WizardPopup=SA,exports.ZINNEXT_URL=t.O,exports.ZinnextTableView=nL,exports.ZinnextTestForm=$I,exports.appNow=n.er,exports.applyIntegrationStatus=n.Sr,exports.approveSubmission=be,exports.buildAcceptAttr=bl,exports.buildBooleanRequest=u_,exports.buildCsv=tp,exports.buildDailyRows=Yf,exports.buildDayGradient=ov,exports.buildRateHistoryEntries=my,exports.buildWeeklyRollup=Qf,exports.clearSelectedProject=t.i,exports.colors=n.$n,exports.computeFinance=oy,exports.computeHoursPolicy=J_,exports.computeMarginBand=$f,exports.conditionMatches=n.f,exports.configureCoreTheme=t.k,exports.configuredFieldLabel=n.p,exports.createAllWorkflowsListFetcher=GI,exports.createMergedListFetcher=zI,exports.createModuleListFetchAdapter=MI,exports.createWorkflowStageListFetcher=BI,exports.currencySymbol=Hu,exports.deactivateRegion=VD,exports.defaultMergeRow=wI,exports.deleteIntegrationConfig=n.Nr,exports.deriveDayStats=Jf,exports.describeCapacity=X_,exports.downloadCsv=ap,exports.evaluateShowIfWith=n.m,exports.findEmployerRow=ey,exports.flattenGroups=Qv,exports.formatAmount=Ju,exports.formatApp=n.tr,exports.formatAppDateTime=n.nr,exports.formatFileSize=yl,exports.formatFinanceMoney=hy,exports.formatHours=jf,exports.formatMoney=Yu,exports.formatPercent=Nf,exports.formatRate=Xu,exports.getActivity=n.In,exports.getAllWorkflowsModuleList=KI,exports.getAppTimeZone=n.rr,exports.getApprovalDate=Lf,exports.getBgcIntegrationConfig=n.Zr,exports.getBgcIntegrationSummary=n.Qr,exports.getBillingActionStates=Hf,exports.getBooleanEligibleTypes=jg,exports.getCurrentRoleName=t.c,exports.getDetailDisplayDefaults=n.fr,exports.getFieldLabel=rp,exports.getFieldType=Dg,exports.getFileExtension=vl,exports.getFinanceApprovalConfig=zv,exports.getFormGroupsRaw=Wy,exports.getGlobalAiServices=nO,exports.getGlobalDefaults=$D,exports.getIntegrationConfig=n.ii,exports.getIntegrationConfigs=n.ai,exports.getIntegrationSummary=n.oi,exports.getModuleConfig=Ie,exports.getModuleDataDetail=n.Rn,exports.getPayrollActionStates=Uf,exports.getPeriodBadgeConfig=Re,exports.getRegionDetailDefaults=JD,exports.getSearchPopup=Ug,exports.getSelectedProject=t.l,exports.getStoredToken=t.u,exports.getStoredUser=t.d,exports.getUserRoles=t.f,exports.getVMSApprove=xe,exports.getValueStyle=ip,exports.getWorkflowStageModuleList=qI,exports.getWorkflowSteps=Wf,exports.grantPlatformAccess=UD,exports.hasPlatformAccess=GD,exports.humanizeEvent=If,Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Ps}}),exports.indexFieldConfig=np,exports.initialsOf=Pf,exports.insertTokenAtCursor=Jh,exports.isBooleanEligible=Og,exports.isBooleanParsable=Kh,exports.isTester=t.p,exports.listPlatformAccess=HD,exports.listPlatformAudit=qD,exports.listPlatformUsers=KD,exports.listRegionRoles=ZD,exports.listRegionUsers=XD,exports.listRegions=zD,exports.loadDetailDefaults=n.pr,exports.logout=t.h,exports.marginIncludesReferral=Vv,exports.matchLocationTax=ay,Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return _m}}),exports.normalizeContract=ny,exports.normalizeDetailViewMode=n.yr,Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return wl}}),exports.rateUnitLabel=Wu,exports.rateUnitShort=Ku,exports.readActionButtons=Xg,exports.reconcileHours=Y_,exports.regionPath=RD,exports.registerFieldType=Eg,exports.registerSearchPopup=Hg,exports.rejectSubmission=Ce,exports.requiredWhenActive=n.c,exports.requiredWhenRule=n.l,exports.resolveActivityMeta=Qc,exports.resolveAndCompute=sy,exports.resolveDayKind=K_,exports.resolveFinanceInputs=iy,exports.resolveMergeKey=SI,exports.resolveMergedListKey=SI,exports.resolveOpenAs=Jg,exports.resolveRejectionReason=Bv,exports.resolveResultsSearchPlaceholder=i_,exports.resolveResultsView=r_,exports.resolveSubmissionFinance=Gy,exports.revokePlatformAccess=WD,exports.runDetailViewOpen=n.br,exports.saveBgcIntegrationConfig=n.ki,exports.saveGlobalAiServices=rO,exports.saveGlobalDefaults=eO,exports.saveIntegrationConfig=n.Mi,exports.saveRegion=BD,exports.saveRegionDetailDefaults=YD,exports.setSelectedProject=t._,exports.showIfConditions=n.g,exports.stageCountKey=VI,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return mx}}),exports.testIntegrationConnection=n.zi,exports.toApp=n.ar,exports.toNumber=qu,exports.tzLabel=n.or,exports.tzShortLabel=n.sr,exports.unregisterSearchPopup=Wg,exports.useDropdownFields=nr,exports.useDropdownValues=Ui,exports.useEditForm=ib,exports.useFieldConfig=rr,exports.useFilterFields=ir,exports.useMenuPermission=pr,exports.useModuleActions=lh,exports.useRecordRefresh=Kp,exports.useTabRows=rb,exports.validateBooleanQuery=qh,exports.validateBulkFile=xl,exports.withAdminAppId=t.A,exports.withAppId=t.j,exports.withAuthGuard=Ux;
|
|
8
8
|
//# sourceMappingURL=index.cjs.map
|