@realtek/core-theme-live 0.0.395 → 0.0.396
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 +1445 -1437
- 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??ew),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}:{},...$C(e.confirmMessages)?{confirmMessages:$C(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=bC(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=ZC(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||aw.has(t)||(r[t]=n));return r})}function iw({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.Qr(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 aw=new Set(`label.field.type.show.req.edit.order.formatter.validations.showOnAdd.addRow.minRows.maxRows.initialRows.addLabel.subFields.placeholder.hidePlaceholder.combineKey.combineLabel.combineRole.combineToggleLabel.combineToggleTarget.combineWidth.combineWrap.combineSpan.defaultOnEdit.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(`.`)),ow=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.minRows.maxRows.initialRows.requireOne.requireValidatedField.requireValidatedFieldMessage.submitDisabledMessage.requireAnyOf.requireAnyOfMessage.allowInProgress.inProgressMessage.orderBy.orderByEnabled.levelRule.levelRuleEnabled.regionRules.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 sw(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,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,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:XC(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:KC(e.payloadTemplate),transformRule:KC(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:Np(e.verifyLockedWhenFields).join(`, `),verifyLockedLabel:e.verifyLockedLabel??``,validations:(e.validations??[]).map(t=>({type:t.type,value:t.type===`unique`?rC(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 cw(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 lw(){let[e,t]=(0,s.useState)({});return(0,s.useEffect)(()=>{let e=!1;return n.ri().then(n=>{e||t(n??{})}).catch(()=>{}),()=>{e=!0}},[]),(0,s.useMemo)(()=>t=>e[String(t??``).trim().toLowerCase()]??``,[e])}function uw({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?[...EC,...DC]:EC})}),(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:AC})}),(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=kC.includes(t)&&Ch.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:OC})}),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`})})]}):kC.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:jC})}),(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:wC})}),(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:MC})}),(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:CC})})]})]}):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.Dt})}),(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:NC})}),(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:PC})}),[`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:JC})}),(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:YC.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:YC.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.Tt({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.Et({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:EC,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:NC})}),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.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=LC.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:IC,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=LC.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:IC,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=LC.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:IC,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=LC.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:IC,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)(xC,{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)(xC,{type:`secondary`,style:{fontSize:12,width:220},children:`clear this field`}):(0,u.jsx)(iw,{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:RC,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:zC,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:BC,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,`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.It})}),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:LS})}),(0,u.jsx)(c.Form.Item,{noStyle:!0,shouldUpdate:(e,t)=>e?.fields?.[r]?.requiredWhenOperator!==t?.fields?.[r]?.requiredWhenOperator,children:({getFieldValue:e})=>zS(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=HC(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=FC.filter(e=>s===`date`?e.dateOnly||e.value===`required`||e.value===`unique`:!e.dateOnly).map(e=>({label:e.label,value:e.value})),h=a===BS,g=t([...y,r])??{},_=ZS(g),b=[...y,r,`validations`,n,`value`],x=h?rC(t(b),g):null,S=h?fC({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,rC(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=$S(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:VS,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:HS,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:GS,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)=>sC(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(iC()),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 dw({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=lw();(0,s.useEffect)(()=>{if(!e||!g)return;let t=!1;return n.ii(g).then(e=>{t||C(n.gi(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.ai(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(`, `),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,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(sw)}):(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,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=QC(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:rw(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},t=e(r.historyLabels);Object.keys(t).length&&(o.historyLabels=t);let n=e(r.historyLabelFrom);Object.keys(n).length&&(o.historyLabelFrom=n);let i=e(r.historyAmountFields);Object.keys(i).length&&(o.historyAmountFields=i);let a=e(r.historyCurrencyFields);Object.keys(a).length&&(o.historyCurrencyFields=a);let c=e(r.historyUnitFields);Object.keys(c).length&&(o.historyUnitFields=c),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)}if(r.orderByEnabled&&(o.orderBy=r.orderBy??tw),r.levelRuleEnabled&&(o.levelRule=r.levelRule??nw),r.regionRules&&(o.regionRules=r.regionRules),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 l=(r.formActions??[]).filter(e=>String(e?.label??``).trim());l.length&&(o.formActions=l.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 u={};if((r.submitMsgAddSuccess||``).trim()&&(u.addSuccess=r.submitMsgAddSuccess.trim()),(r.submitMsgEditSuccess||``).trim()&&(u.editSuccess=r.submitMsgEditSuccess.trim()),(r.submitMsgAddError||``).trim()&&(u.addError=r.submitMsgAddError.trim()),(r.submitMsgEditError||``).trim()&&(u.editError=r.submitMsgEditError.trim()),r.submitMsgSuppress&&(u.suppress=!0),Object.keys(u).length&&(o.submitMessages=u),t)for(let[e,n]of Object.entries(t))n!=null&&n!==``&&(e in o||ow.has(e)||(o[e]=n));f?(await f(o,t),c.message.success(t?`Group updated`:`Group created`)):t?(await n.Ai(t.id,o),c.message.success(`Group updated`)):(await n.pr(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=cw(t,n,e(`hierarchyParent`),e(`hierarchyLinkField`),i);return o?(0,u.jsx)(xC,{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`})})]})]}),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,{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)(xC,{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})=>uw({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 fw({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)(xC,{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)(xC,{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:VC[t.type]??`default`,style:{cursor:`default`,fontFamily:`monospace`,fontSize:10},children:[t.type,a===``?``:`(${a})`]})},n)})]})]},e.field)})}),rowExpandable:()=>!0}})}function pw({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=lw();async function w(e){if(!(!e||x.current[e])){v(!0);try{let t=await n.ai(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:Ig(t),detailViewOpenMode:n.lr(t.detailViewOpenMode),resultsSearchPlaceholder:t.resultsSearchPlaceholder??``,actionButtonEnabled:t.actionButtonEnabled??!1,actionButtonLabel:t.actionButtonLabel??``,actionButtonUrl:t.actionButtonUrl??``,actionButtonTarget:t.actionButtonTarget??`_self`,actionButtonOpenAs:Dg({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(sw)}))}),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=>QC(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:rw(e.fields??[]),...e.infoEnabled&&e.infoText?{infoEnabled:!0,infoText:e.infoText}:{}}))};t?(await n.ji(t.id,{...t,...i}),c.message.success(`Custom form updated`)):(await n.mr(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:Ng})}),(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.or})}),(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:Tg})})]})]})})]}),(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})=>uw({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 mw({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.Wr().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.Sr(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)(xC,{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)(pw,{open:o,editingForm:f,moduleOptions:e,onClose:()=>{d(!1),p(null)},onSaved:()=>{d(!1),p(null),m()}})]})}function hw(){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=UC(e),A=e.map(e=>({value:e.key,label:e.label}));(0,s.useEffect)(()=>{n.Br().then(e=>{let n=CS(e).map(({value:e,label:t})=>({key:e,label:t}));t(n);let r=UC(n);o(WC(r)),F(`all`,r)}).catch(()=>t([])).finally(()=>i(!1))},[]),(0,s.useEffect)(()=>{n.Mr({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.Nr(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.br(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.Ai(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(SC[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.Nr(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 U(e){O(JSON.parse(JSON.stringify(e))),c.message.success(`Copied settings from ${e.label||e.name}`)}async function ie(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.Ai(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 ae(){v(null),o(WC(k)),I(d),d!==`all`&&I(`all`)}let oe=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)(fw,{groups:i,onEdit:z,onDelete:H,onCopy:U,onPaste:ie,canPaste:!!D,onReorder:e===`all`?void 0:ee})})]})}}),se=d===`all`?A[0]?.value??`jobs`:d,W=k.find(e=>e.key===se)?.label??se,ce=[{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)(xC,{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:oe,size:`middle`,className:`fg-tabs`})})}),(0,u.jsx)(dw,{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.Ai(t.id,e,re(e.module)):n.pr(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,{}),` `,W,` Add Form Preview`]}),classNames:{body:`fg-preview-body`},destroyOnClose:!0,children:(0,u.jsx)(Cc,{moduleName:se,clientId:C.clientId,region:C.region,cancelPath:`/${se}`,onSubmit:async()=>c.message.info(`Preview only. No record was created.`),breadcrumbItems:[{label:`Admin`},{label:`Form Groups`},{label:`${W} Preview`}]},`${se}-${C.clientId}-${C.region}`)})]})},{key:`custom`,label:`Custom Form`,children:(0,u.jsx)(Z,{children:(0,u.jsx)(mw,{moduleOptions:A})})},{key:`defaultFields`,label:`Default Fields`,children:(0,u.jsx)(yC,{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)(xC,{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:ce,size:`middle`,className:`fg-top-tabs`,tabBarStyle:{padding:`0 16px`,margin:0},destroyInactiveTabPane:!1})}),(0,u.jsx)(hC,{open:!!_,scope:`formGroups`,action:_?.action,title:_?.title,description:_?.description,confirmLabel:_?.confirmLabel,danger:_?.danger,onCancel:()=>v(null),onVerified:ae})]})}var gw=`databaseFields`,_w=`__detail_database_fields__`;function vw(e){return e?.detailOnlySource===!0||e?.id===`__detail_database_fields__`}function yw(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 bw(e,t){let n=Array.isArray(e)?e:[],r=yw(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:_w,name:gw,label:`Database Fields`,order:i+1,hideGroupInForm:!0,detailOnlySource:!0,fields:r}]}function xw(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 Sw(e){return Object.entries(e??[]).map(([e,t])=>({name:String(e).trim(),label:String(t??``).trim()})).filter(e=>e.name&&e.label)}var Cw=`2026-08-06T13:33:00.000Z`,{Text:Q}=c.Typography,ww,Tw=new Map;function Ew(){return ww||=n.zr().catch(e=>{throw ww=void 0,e}),ww}function Dw(e){return Tw.has(e)||Tw.set(e,n.Ur(e).catch(t=>{throw Tw.delete(e),t})),Tw.get(e)}var Ow={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.`}},kw=[{label:`Default`,value:`default`},{label:`Title Case On`,value:`on`},{label:`Off (raw text)`,value:`off`}],Aw=e=>e===!0?`on`:e===!1?`off`:`default`,jw=e=>e===`on`||e!==`off`&&void 0,Mw=e=>e===!0||e===1||e===`1`;function Nw(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 Pw(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 zS(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 Fw(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 Iw(e){return Number(e?.show??1)===0}function Lw(e,t){let n=[];return{nextGroups:(e??[]).map(e=>{if(vw(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 Rw({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 zw({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=zS(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:LS,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 Bw({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 Ew().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 Dw(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)(Rw,{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:kw,value:Aw(d.capitalize),onChange:e=>y(`capitalize`,jw(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)(zw,{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.Yt}),(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:Au[T]??Au.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.Jt})]}),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.Xt})]}),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 Vw(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 Hw(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 Uw({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:Vw(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:Hw(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)(Rw,{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:kw,value:Aw(o.capitalize),onChange:e=>f(`capitalize`,jw(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 Ww({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)(_d,{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 Gw=[{label:`Common (no region profile)`,value:``},{label:`United States (US)`,value:`US`},{label:`United Kingdom (UK)`,value:`UK`},{label:`India (IND)`,value:`IND`}],Kw=[{key:`default`,label:`Any value`,placeholder:Au.default},{key:`group`,label:`Empty group`,placeholder:`No <group name> added`},{key:`document`,label:`Document`,placeholder:Au.document},{key:`date`,label:`Date`,placeholder:Au.date},{key:`phone`,label:`Phone`,placeholder:Au.phone},{key:`email`,label:`Email`,placeholder:Au.email},{key:`link`,label:`Link`,placeholder:Au.link},{key:`skills`,label:`Skills/tags`,placeholder:Au.skills}];function qw(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),t}function Jw({open:e,onClose:t}){let[r,i]=(0,s.useState)(()=>({...n.nr()})),[a,o]=(0,s.useState)(!1);(0,s.useEffect)(()=>{if(!e)return;let t=!1;return n.Kr().then(e=>{t||i(t=>({...t,...qw(e)}))}).catch(()=>{}),()=>{t=!0}},[e]);let d=(e,t)=>i(n=>({...n,[e]:t})),f=(0,s.useMemo)(()=>n.Yn(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:[]};await n.xi(e),n.er(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.$n}),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.$n.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.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:Gw,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.Zn({...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.qn(Cw,{...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.Qn(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:Kw.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.or,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 Yw(){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)([]),[U,ie]=(0,s.useState)(``),[ae,oe]=(0,s.useState)(``),[se,W]=(0,s.useState)({});function ce(e){B(Ow[e])}async function G(e,t,r,i){if(vw(e))return;let a=d;f(n=>n.map(n=>n.id===e.id?{...n,[t]:r}:n)),W(n=>({...n,[`${e.id}:${t}`]:!0}));try{await n.Ai(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{W(n=>{let r={...n};return delete r[`${e.id}:${t}`],r})}}async function le(e,t,r){if(vw(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.Ai(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 ue=(e,t)=>G(e,`hideGroup`,t,{on:`Group hidden from add/edit forms and the detail view`,off:`Group is visible again`}),de=(e,t)=>G(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)=>G(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.Mr({limit:200}).then(re).catch(()=>re([]))},[]),(0,s.useEffect)(()=>{n.Br().then(e=>{let n=CS(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.Nr(a,{clientId:U}).catch(e=>{if(e?.status===404)return[];throw e}),n.Gr(a,{clientId:U})]);if(e)return;let i=r.sourceFields??[],o=xw(bw(t,i),r.groups??[]),s=o.groups;oe(r.clientId??``),S(i),w(o.labels),f(s),m(Nw(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,U]);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])=>Pw(e,t)).filter(Boolean),{nextGroups:t,changed:r}=Lw(d,_);await n.bi({module:a,fields:e,merges:Fw(y),sourceFields:x,groups:Sw(C),clientId:U}),r.length&&(f(t),m(Nw(t)),g(t.map(e=>({value:e.name,label:e.label??e.name})))),oe(U),c.message.success(U?`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 K(e){v(t=>({...t,[j.key]:{...e,field:j.key}})),M(null)}function q(e){v(t=>{let n={...t};return delete n[e],n})}function _e(e){b(t=>{let n=[...t];return N.index===null?n.push(e):n[N.index]=e,n}),P(null)}function ve(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 ye=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:`—`})},be=[{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}}),vw(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)=>vw(t)?(0,u.jsx)(Q,{type:`secondary`,children:`—`}):(0,u.jsx)(c.Tooltip,{title:Mw(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:Mw(t.hideGroup),loading:!!se[`${t.id}:hideGroup`],onChange:e=>ue(t,e)})})},{title:`Show Condition`,key:`ignoreShowIfInDetail`,width:130,align:`center`,render:(e,t)=>{if(vw(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:Mw(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:Mw(t.ignoreShowIfInDetail),loading:!!se[`${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)=>Mw(t.addRow)?(0,u.jsx)(c.Input,{size:`small`,defaultValue:t.emptyText??``,placeholder:`No ${String(t.label??t.name??``).toLowerCase()} added`,onBlur:e=>le(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)=>vw(t)?(0,u.jsx)(Q,{type:`secondary`,children:`—`}):(0,u.jsx)(c.Tooltip,{title:Mw(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:Mw(t.hideGroupInDetail),loading:!!se[`${t.id}:hideGroupInDetail`],onChange:e=>de(t,e)})})}],xe=e=>{let t=e.fields??[],n=vw(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??Iw(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,`)`]}),uC(t)&&(0,u.jsx)(c.Tooltip,{title:(()=>{let e=dC(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:ye(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=>ve(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:()=>q(t.field)})})]})]},t.field)})}):(0,u.jsx)(Q,{type:`secondary`,style:{fontSize:12},children:`No fields in this group.`})},Se=(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]),Ce=[{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))})})]})}],we=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:()=>ce(`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:()=>ce(`save`)},{key:`restore`,label:`Restore saved default`,icon:(0,u.jsx)(l.CloudDownloadOutlined,{}),onClick:()=>ce(`restore`)},{type:`divider`},{key:`reset`,label:`Reset all detail settings`,icon:(0,u.jsx)(l.ReloadOutlined,{}),danger:!0,onClick:()=>ce(`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:U||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=>ie(e??``)}),(0,u.jsx)(c.Button,{size:`small`,icon:(0,u.jsx)(l.ReloadOutlined,{}),onClick:()=>H(e=>e+1),children:`Reload`})]})]}),U&&!ae&&!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:we.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:Se,columns:be,pagination:!1,size:`small`,className:`fg-table`,expandable:{expandedRowRender:xe,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:Ce,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)(Bw,{open:!!j,fieldMeta:j,value:j?{...j.lookupDefaults,..._[j.key]??{}}:null,moduleFieldOptions:me,onClose:()=>M(null),onSave:K},j?.key??`field-closed`),(0,u.jsx)(Uw,{open:!!N,merge:N?.merge,fieldOptions:me,groupOptions:h,onClose:()=>P(null),onSave:_e},N?`merge-${N.index??`new`}`:`merge-closed`),(0,u.jsx)(Jw,{open:L,onClose:()=>R(!1)}),(0,u.jsx)(Ww,{open:F,module:a,onClose:()=>I(!1)}),(0,u.jsx)(hC,{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.Ar({module:a,clientId:U,otp:e}):void 0})]})}var Xw=`/admin/email-templates`,Zw=`/email-templates`;function Qw(e){return e?.data??e}async function $w({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=Qw(await t.o(t.x,`${Xw}?${s}`))??{};return{items:Array.isArray(c.items)?c.items:[],totalCount:Number(c.totalCount??0)}}async function eT(e){return Qw(await t.o(t.x,`${Xw}/${encodeURIComponent(e)}`))}async function tT(e){return t.o(t.x,Xw,{method:`POST`,body:JSON.stringify(e)})}async function nT(e,n){return t.o(t.x,`${Xw}/${encodeURIComponent(e)}`,{method:`PUT`,body:JSON.stringify(n)})}async function rT(e){return t.o(t.x,`${Xw}/${encodeURIComponent(e)}`,{method:`DELETE`})}async function iT({module:e=``,action:n=``}={}){let r=new URLSearchParams;e&&r.set(`module`,e),n&&r.set(`action`,n);let i=r.toString()?`?${r}`:``,a=Qw(await t.o(t.x,`${Zw}${i}`));return Array.isArray(a)?a:[]}async function aT(e){return Qw(await t.o(t.x,`${Zw}/${encodeURIComponent(e)}`))}async function oT(){let e=Qw(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 sT({offset:e=0,limit:n=20,search:r=``}={}){let i=new URLSearchParams({offset:String(e),limit:String(n),sortBy:`new`,searchValue:r}),a=Qw(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 cT(e){return Qw(await t.o(t.x,`/signature/editPreview?signatureId=${encodeURIComponent(e)}`))}async function lT(e){return t.o(t.x,`/signature/add`,{method:`POST`,body:JSON.stringify(e)})}async function uT(e){return t.o(t.x,`/signature/edit`,{method:`PUT`,body:JSON.stringify(e)})}async function dT(e){return t.o(t.x,`/signature/delete?signatureId=${encodeURIComponent(e)}`,{method:`DELETE`})}async function fT(e,n){return t.o(t.x,`/signature/statusUpdate?signatureId=${encodeURIComponent(e)}&status=${n}`,{method:`PUT`})}var pT={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:mT}=c.Typography,hT=[{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)`}],gT=[{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)`}],_T=[`GET`,`POST`,`PUT`,`DELETE`],vT=[`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`],yT={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`},bT={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},xT=[{value:`notEmpty`,label:`is set (not empty)`},{value:`eq`,label:`equals`},{value:`ne`,label:`not equals`},{value:`isEmpty`,label:`is empty`}];function ST(){return`action_${Date.now()}`}function CT({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({...yT,...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??bT.recipientSource,mailRecipientFields:t?.mailConfig?.recipientFields??bT.recipientFields,mailRecipientMode:t?.mailConfig?.recipientMode??bT.recipientMode,mailRemoveDuplicateRecipients:t?.mailConfig?.removeDuplicateRecipients??bT.removeDuplicateRecipients,mailJobIdSource:t?.mailConfig?.jobIdSource??bT.jobIdSource,mailJobIdField:t?.mailConfig?.jobIdField??bT.jobIdField,mailJobIdReadOnly:t?.mailConfig?.jobIdReadOnly??bT.jobIdReadOnly,mailAutoFetchJobContent:t?.mailConfig?.autoFetchJobContent??bT.autoFetchJobContent,mailRequiredTo:t?.mailConfig?.requiredTo??bT.requiredTo,mailRequiredJobId:t?.mailConfig?.requiredJobId??a,mailRequiredSubject:t?.mailConfig?.requiredSubject??bT.requiredSubject,mailRequiredBody:t?.mailConfig?.requiredBody??bT.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||bT.recipientSource,recipientFields:(n.mailRecipientFields??bT.recipientFields).map(e=>String(e??``).trim()).filter(Boolean),recipientMode:n.mailRecipientMode||bT.recipientMode,removeDuplicateRecipients:n.mailRemoveDuplicateRecipients!==!1,jobIdSource:n.mailJobIdSource||bT.jobIdSource,jobIdField:String(n.mailJobIdField??bT.jobIdField).trim()||bT.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=[...vT.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:yT,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:hT,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:gT})})]}),_===`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:_T.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:_T.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:xT})}),(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 wT(){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.ei().then(e=>{let n=CS(e);t(n),i(e=>e||n[0]?.value||``)}).catch(()=>{t([])})},[]),(0,s.useEffect)(()=>{Promise.all([n.ei().catch(()=>[]),n.$r().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.di(r);o(e)}catch(e){S(e.message)}finally{v(!1)}}},[r]);(0,s.useEffect)(()=>{queueMicrotask(()=>{z()})},[z]),(0,s.useEffect)(()=>{Promise.all([n.Wr(r,`popup`).catch(()=>[]),iT({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.Ri(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.yr({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.kr(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,{...yT,...e,_localKey:ST()}];return{...t,children:r}}):T?p.map(t=>t.key===T.key?{...t,...e}:t):[...p,{...yT,...e,_localKey:ST()}];try{if(d)await n.Ri(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.yr({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()}},U=(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)},ie=(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 ae(e){M(pT[e])}function oe(){M(null),z()}let se=(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]),W=[{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:()=>ie(t._actionIndex,-1),children:`↑`}),(0,u.jsx)(c.Button,{size:`small`,type:`text`,disabled:t._actionIndex===p.length-1,onClick:()=>ie(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)(mT,{strong:!0,children:t.label||t.key}),(0,u.jsx)(mT,{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)(mT,{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)(mT,{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)(mT,{type:`secondary`,children:t.permission||`All permitted roles`}),t.permissionKey&&(0,u.jsx)(mT,{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:()=>U(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,{})})})})]})}],ce=e=>[{title:`Action`,key:`identity`,width:210,render:(e,t)=>(0,u.jsxs)(`div`,{className:`admin-config-primary-cell`,children:[(0,u.jsx)(mT,{strong:!0,children:t.label||t.key}),(0,u.jsx)(mT,{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)(mT,{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)(mT,{type:`secondary`,children:t.permission||`All permitted roles`}),t.permissionKey&&(0,u.jsx)(mT,{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:()=>U(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:()=>ae(`save`)},{key:`restore`,label:`Restore saved default`,icon:(0,u.jsx)(l.CloudDownloadOutlined,{}),onClick:()=>ae(`restore`)},{type:`divider`},{key:`reset`,label:`Reset all actions`,icon:(0,u.jsx)(l.ReloadOutlined,{}),danger:!0,onClick:()=>ae(`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)(mT,{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)(mT,{strong:!0,children:`Configuration context`}),(0,u.jsx)(mT,{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)(mT,{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)(mT,{type:`warning`,children:`Unsaved changes`})]}),(0,u.jsx)(c.Spin,{spinning:_,children:(0,u.jsx)(c.Table,{dataSource:se.map((e,t)=>({...e,_actionIndex:p.indexOf(e),_rowKey:e.key||e._localKey||t})),rowKey:`_rowKey`,columns:W,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:ce(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)(CT,{open:C,initial:T,isChild:!!H,moduleName:r,popupForms:D,templateOptions:k,permissionModules:F,permissionActions:L,onClose:()=>w(!1),onSave:re}),(0,u.jsx)(hC,{open:!!j,scope:`rowActions`,action:j?.action,title:j?.title,description:j?.description,confirmLabel:j?.confirmLabel,danger:j?.danger,onCancel:()=>M(null),onVerified:oe})]})}var{Text:TT,Title:ET}=c.Typography,DT=[{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`}],OT=[{value:`{currentUserId}`,label:`{currentUserId} — the signed-in user`}],kT=[{value:`myJobs`,label:`My Jobs`},{value:`allJobs`,label:`All Jobs`}],AT=[`eq`,`ne`,`contains`,`includes`,`notIncludes`],jT=`scope`,MT=`fieldEq`,NT=[{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}],PT=()=>({field:``,operator:`eq`,value:``,compareField:``}),FT=()=>({name:``,description:``,conditions:[PT()],blockedActions:[],disabledActions:[],allowedActions:[],isActive:!0});function IT(e){return DT.find(t=>t.value===e)?.label??e}function LT(e){return e.operator===jT?`scope = ${e.value}`:e.operator===MT?`${e.field} = field:${e.compareField}`:[`isEmpty`,`notEmpty`].includes(e.operator)?`${e.field} ${IT(e.operator)}`:`${e.field} ${IT(e.operator)} "${e.value}"`}function RT(){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)(FT()),[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.jr().then(n=>{if(e)return;let r=CS(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.ti(e).then(e=>f(Array.isArray(e)?e:[])).catch(()=>f([])).finally(()=>m(!1))}function A(e){n.ai(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.di(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(FT()),g(!0)}function N(e){v(e),b({name:e.name??``,description:e.description??``,conditions:e.conditions?.length?e.conditions.map(e=>({...e})):[PT()],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.Pi(_.id,y),c.message.success(`Rule updated`)):(await n._r({...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.Er(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 NT)await n._r({...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,PT()]}))}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)(ET,{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)(TT,{strong:!0,children:e}),t.description?(0,u.jsx)(`div`,{children:(0,u.jsx)(TT,{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:LT(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)(TT,{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:DT,value:e.operator,style:{width:140},onChange:e=>L(t,{operator:e,value:``,compareField:``})})}),e.operator!==jT&&(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)(TT,{type:`secondary`,style:{fontSize:11},children:[`Field from the record (e.g. `,(0,u.jsx)(`code`,{children:`jobRecruitmentStatus`}),`, `,(0,u.jsx)(`code`,{children:`recruiters`}),`)`]})]}),AT.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:OT,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)(TT,{type:`secondary`,style:{fontSize:11},children:[`Type a literal, or pick `,(0,u.jsx)(`code`,{children:`{currentUserId}`}),` for the signed-in user.`]})]}),e.operator===jT&&(0,u.jsxs)(c.Form.Item,{label:`Scope Value`,style:{marginBottom:0,minWidth:140},children:[(0,u.jsx)(c.Select,{options:kT,value:e.value||void 0,style:{width:150},placeholder:`Select scope`,onChange:e=>L(t,{value:e})}),(0,u.jsx)(TT,{type:`secondary`,style:{fontSize:11},children:`Current view tab (myJobs / allJobs)`})]}),e.operator===MT&&(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)(TT,{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)(TT,{type:`secondary`,style:{fontSize:11},children:[`Preview: `,(0,u.jsx)(`code`,{style:{color:`#1677ff`},children:LT(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)(TT,{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)(TT,{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)(TT,{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)(TT,{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)(TT,{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)(TT,{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 zT(){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)(wT,{})},{key:`rules`,label:`Visibility rules`,icon:(0,u.jsx)(l.ApartmentOutlined,{}),children:(0,u.jsx)(RT,{})}]})}var{Text:BT}=c.Typography,VT={name:``,module:``,action:``,clientId:``,description:``,toMail:[],ccMail:[],bccMail:[],subject:``,body:``,isActive:!0},HT=e=>e?._id??e?.id;function UT(e){return String(e??``).trim().replace(/^{{\s*/,``).replace(/\s*}}$/,``).trim().replace(/^\./,``).trim()}function WT(...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 GT=[{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 KT(e){return String(e??``).trim().toLowerCase().replace(/[^a-z0-9]/g,``).replace(/s$/,``)===`submission`}function qT({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.di(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.ai(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:UT(r),value:UT(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(!KT(t))return r;let i=new Set(GT.map(e=>e.key)),a=GT.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?eT(t):Promise.resolve(VT)).then(e=>{if(n)return;let t={...VT,...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=UT(t.key);r[n]={moduleName:e.moduleName,value:UT(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=WT(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 nT(t,a):await tT(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:VT,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.Vn,{value:d,onChange:f,placeholder:`Write the reusable email body…`})}),(0,u.jsxs)(`div`,{className:`template-placeholder-panel`,children:[(0,u.jsx)(BT,{strong:!0,children:`All module placeholders`}),(0,u.jsx)(BT,{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)(BT,{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 JT(){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),$w({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.Br(),n.Mr({limit:200})]).then(([e,t])=>{v(CS(e).map(({value:e,label:t})=>({key:e,label:t}))),b(t)}).catch(()=>{})},[]);async function D(e,n){let r=HT(e);try{await nT(r,{...e,isActive:n}),t(e=>e.map(e=>HT(e)===r?{...e,isActive:n}:e))}catch(e){c.message.error(e?.message||`Could not update status`)}}async function O(e){try{await rT(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)(BT,{strong:!0,ellipsis:{tooltip:t.name},children:t.name}),(0,u.jsx)(BT,{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)(BT,{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(HT(t)),w(!0)}})}),(0,u.jsx)(c.Popconfirm,{title:`Delete this template?`,onConfirm:()=>O(HT(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)(BT,{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:HT,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)(qT,{open:C,templateId:x,modules:T,clients:A,onClose:()=>w(!1),onSaved:()=>{w(!1),E()}})]})}function YT({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?cT(t):Promise.resolve(null),oT()]).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=WT(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 uT(r):await lT(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.Vn,{value:l,onChange:d,placeholder:`Create the reusable signature…`})}),(0,u.jsxs)(`div`,{className:`template-placeholder-panel`,children:[(0,u.jsx)(BT,{strong:!0,children:`Signature placeholders`}),(0,u.jsx)(BT,{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)(BT,{type:`secondary`,children:`Loading placeholders…`}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{style:{marginTop:10},children:[(0,u.jsx)(BT,{strong:!0,children:`User details`}),C(x)]}),(0,u.jsxs)(`div`,{style:{marginTop:10},children:[(0,u.jsx)(BT,{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 XT(){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),sT({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 fT(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 dT(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)(BT,{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)(BT,{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)(YT,{open:g,signatureId:v,onClose:()=>_(!1),onSaved:()=>{_(!1),b()}})]})}function ZT(){return(0,u.jsx)(c.Tabs,{defaultActiveKey:`email`,className:`admin-config-tabs`,items:[{key:`email`,label:`Email templates`,children:(0,u.jsx)(JT,{})},{key:`signature`,label:`Signatures`,children:(0,u.jsx)(XT,{})}]})}var QT=new Set([`169.254.169.254`,`169.254.170.2`,`metadata.google.internal`,`100.100.100.200`,`192.0.0.192`]);function $T(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(QT.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 eE(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:tE}=c.Typography,nE={serviceKey:``,label:``,baseUrl:``,authHeader:``,authValue:``,providerApiKey:``,enabled:!0};function rE({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({...nE,...t,authValue:``,providerApiKey:``})},[e,t,a]);let _=m&&m.forUrl===g?m:null,v=eE(g);async function y(){let e=a.getFieldsValue(),t=$T(e.baseUrl);if(t){h({reachable:!1,detail:t,forUrl:e.baseUrl});return}p(!0);try{h({...await n.Oi(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.vi(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:nE,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=$T(t);return n?Promise.reject(Error(n)):Promise.resolve()}}],extra:v?(0,u.jsx)(tE,{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)(tE,{type:`secondary`,children:[`Checked from the server in `,_.latencyMs,`ms`]})]})}):(0,u.jsx)(tE,{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)(tE,{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 iE(){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.Pr().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.vi({...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.xr(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)(tE,{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)(tE,{strong:!0,children:t.label||t.serviceKey}),(0,u.jsx)(tE,{type:`secondary`,code:!0,children:t.serviceKey})]})},{title:`Base URL`,dataIndex:`baseUrl`,key:`baseUrl`,ellipsis:!0,render:e=>(0,u.jsx)(tE,{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)(tE,{type:`success`,children:`Configured`}):(0,u.jsx)(tE,{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)(rE,{open:a,service:d,onClose:()=>o(!1),onSaved:()=>{o(!1),p()}})]})}var{Text:aE}=c.Typography,oE={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:``}]},sE=[{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 cE(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 lE({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({...oE,...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=cE(await a.validateFields());d(!0),await n.Si(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.ki(cE({...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:oE,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:sE})}),_?(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)(aE,{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)(aE,{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 uE(){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.Yr().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.Cr(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)(aE,{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)(aE,{strong:!0,children:t.label}),(0,u.jsx)(aE,{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)(lE,{open:a,integration:d,onClose:()=>o(!1),onSaved:()=>{o(!1),p()}})]})}var{Text:$}=c.Typography;function dE({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 fE({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 pE(e){return Object.entries(e??{}).map(([e,t])=>({key:e,value:String(t??``)}))}function mE(e){let t={};for(let n of e??[])n.key?.trim()&&(t[n.key.trim()]=n.value??``);return t}function hE(e){return Object.entries(e??{}).map(([e,t])=>({key:e,value:typeof t==`string`?t:JSON.stringify(t)}))}function gE(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 _E({open:e,rule:t,onClose:n,onSave:r}){let[i,a]=(0,s.useState)(()=>({sourceModule:``,sourceIdField:``,required:!1,...t??{},fieldMapRows:pE(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:mE(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)(dE,{rows:i.fieldMapRows??[],onChange:e=>o(`fieldMapRows`,e),keyPlaceholder:`jobTitle`,valuePlaceholder:`jobTitle`})]})]})})}function vE({open:e,rule:t,onClose:n,onSave:r}){let[i,a]=(0,s.useState)(()=>({sourceField:``,targetField:``,sourceCollection:``,idField:``,idOutputKey:``,stampNow:``,...t??{},fieldMapRows:pE(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:mE(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)(dE,{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 yE({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:pE(t?.staticFields),arrayFieldNameRows:pE(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:mE(e),arrayFieldNames:mE(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)(dE,{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)(dE,{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 bE({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 xE({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:hE(t?.extraFilter),pullRows:hE(t?.pull),pushRows:hE(t?.push),setRows:hE(t?.set),setIfNonBlankRows:hE(t?.setIfNonBlank),insertIfMissingRows:hE(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:gE(e),pull:l?{}:gE(t),push:l?{}:gE(n),set:l?{}:gE(r),setIfNonBlank:l?{}:gE(o),insertIfMissing:l?gE(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)(fE,{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)(fE,{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)(fE,{rows:a.pullRows??[],onChange:e=>d(`pullRows`,e),keyPlaceholder:`submitted`,valuePlaceholder:`{"candidateId":"{{applicantId}}"}`})},{key:`push`,label:`Push`,children:(0,u.jsx)(fE,{rows:a.pushRows??[],onChange:e=>d(`pushRows`,e),keyPlaceholder:`submitted`,valuePlaceholder:`{"status":"{{submissionStatus}}"}`})},{key:`set`,label:`Set`,children:(0,u.jsx)(fE,{rows:a.setRows??[],onChange:e=>d(`setRows`,e),keyPlaceholder:`hiringProgressJobStatus`,valuePlaceholder:`"unread"`})},{key:`setIfNonBlank`,label:`Set if non-blank`,children:(0,u.jsx)(fE,{rows:a.setIfNonBlankRows??[],onChange:e=>d(`setIfNonBlankRows`,e),keyPlaceholder:`resume.location`,valuePlaceholder:`{{resume.location}}`})}]})]})})}function SE({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 CE={assignmentSource:null,sequence:null,duplicateCheck:null,fileVersioning:null,denormalizations:[],arrayEnrichments:[],fileFieldMaps:[],sanitizeFields:[],defaults:{},hierarchyExpands:[],relatedUpdates:[],notify:null,cacheInvalidate:[]};function wE(){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)(CE),[_,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.Br().then(e=>{let n=CS(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.ni(a);if(e)return;let r=t.gateway??{storage:`mongo`};f(r),m(r.storage||`mongo`),g({...CE,...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.Ci(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)(SE,{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)(SE,{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)(SE,{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)(fE,{rows:hE(h.defaults),onChange:e=>P(`defaults`,gE(e)),keyPlaceholder:`internalSubmissionStatus.internalSubmissionStatusText`,valuePlaceholder:`"Under Evaluation"`})]}),(0,u.jsx)(SE,{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)(SE,{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)(_E,{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)(vE,{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)(yE,{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)(bE,{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)(xE,{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:TE}=c.Typography,EE=[`beforeCreate`,`afterCreate`,`beforeUpdate`,`afterUpdate`,`beforeDelete`,`afterDelete`],DE=[`sanitizeFields`,`generateSequence`,`duplicateCheck`,`copyFields`,`arrayEnrich`,`setDefaults`,`resolve`,`updateRelated`,`notify`,`invalidateCache`,`webhook`,`linkDocuments`,`captureFileUrls`],OE={linkDocuments:{text:`Share one record’s uploaded files with another, without making a second copy. Used so a submission shows the candidate’s résumé and paperwork, and anything uploaded during the submission appears on the candidate too. Both records get the list of document ids written onto them.`,sample:{sourceModule:`candidates`,sourceIdField:`applicantId`,targetModule:`submissions`,linkField:`documentIds`,fieldNames:[],backLink:!0}},captureFileUrls:{text:`File a document that was generated elsewhere and handed to us as a link — a formatted résumé or an attestation PDF — so it sits with every other attachment instead of being a loose field on the record.`,sample:{linkField:`documentIds`,files:[{urlField:`resumeUrl`,nameField:`resumeFileName`,fieldName:`formattedResume`,defaultName:`Formatted Resume.pdf`},{urlField:`attestationUrl`,nameField:`attestationFileName`,fieldName:`attestation`,defaultName:`Attestation.pdf`}]}}};function kE(e){return JSON.stringify(e??{},null,2)}function AE({action:e,onChange:t,onRemove:n}){let[r,i]=(0,s.useState)(()=>kE(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:DE.map(e=>({value:e})),onChange:n=>{let r=e.config&&Object.keys(e.config).length>0,i=OE[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})]}),OE[e.type]&&(0,u.jsx)(`p`,{style:{margin:`8px 0 0`,fontSize:12,color:`#64748b`,lineHeight:1.5},children:OE[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 jE({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)(()=>kE(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)(TE,{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)(TE,{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)(TE,{type:`secondary`,style:{fontSize:12},children:`Event`}),(0,u.jsx)(c.Select,{size:`small`,style:{width:`100%`},value:a.event,options:EE.map(e=>({value:e})),onChange:e=>h(`event`,e)})]}),(0,u.jsxs)(`div`,{style:{width:90},children:[(0,u.jsx)(TE,{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)(TE,{style:{fontSize:13},children:`Active`})]}),(0,u.jsxs)(`div`,{style:{marginTop:12},children:[(0,u.jsxs)(TE,{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)(TE,{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)(AE,{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)(TE,{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 ME(){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.mi(`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.Br().then(e=>i(CS(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.Ti(`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.Or(`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.Ti(`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)(TE,{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)(TE,{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)(jE,{open:!!p,doc:p?.doc,moduleOptions:r,onClose:()=>m(null),onSave:b},p?p.doc?.key??`new`:`closed`)]})}var{Text:NE}=c.Typography,PE=e=>e?._id??e?.id,FE=`masters`;function IE(){return{tenantId:localStorage.getItem(`tenantId`)||``,businessId:localStorage.getItem(`businessId`)||``,businessUnitId:localStorage.getItem(`businessUnitId`)||``}}function LE(e){return e&&typeof e==`object`?e.$oid??e.oid??e.id??``:e??``}function RE(e,t){return t.map(t=>LE(e?.[t])).find(e=>e!=null&&e!==``)??``}function zE(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(RE(e,n));return!r||r===String(t)})}function BE(e){return Array.isArray(e?.masterFeeds)?e.masterFeeds:[]}function VE(e){return e.reduce((e,t)=>Math.max(e,Number(t?.uniqueId)||0),0)+1}function HE(e){return Array.isArray(e?.taxHistory)?e.taxHistory:[]}function UE(e){let t=e?.taxValue;if(t!=null&&t!==``)return Number(t);let n=HE(e).at(-1),r=n?.taxValue??n?.value;return r!=null&&r!==``?Number(r):void 0}function WE(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 GE(e){let t=HE(e).at(-1);return t?.updatedAt??t?.timestamp??e?.updatedAt}function KE({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:UE(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.Zr(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.Fi(`locations`,PE(t),o):await n.vr(`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 qE({record:e}){let t=[...HE(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)(NE,{type:`secondary`,style:{fontSize:12},children:WE(e.updatedAt??e.timestamp)}),t===0&&(0,u.jsx)(NE,{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 JE(){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.pi(`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.Dr(`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:PE,columns:[{title:`Location`,dataIndex:`name`,key:`name`},{title:`Tax`,key:`taxValue`,width:100,render:(e,t)=>{let n=UE(t);return Number.isFinite(n)?(0,u.jsxs)(c.Tag,{color:`blue`,children:[n,`%`]}):`—`}},{title:`Tax updated`,key:`taxUpdatedAt`,render:(e,t)=>WE(GE(t))},{title:`Created`,key:`createdAt`,responsive:[`lg`],render:(e,t)=>WE(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(PE(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)(qE,{record:e}),rowExpandable:e=>HE(e).length>0},locale:{emptyText:`No locations yet. Click "New location" to add one.`}})}),(0,u.jsx)(KE,{open:a,record:d,onClose:()=>o(!1),onSaved:()=>{o(!1),p()}})]})}function YE({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=BE(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=IE(),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.Fi(FE,PE(t),l):await n.vr(FE,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:VE(a.getFieldValue(`masterFeeds`)??[]),name:``,type:`neutral`,status:!0,isdeleted:!1,...h?{isInitialStatus:!1,isTerminalStatus:!1,allowedNextStatusIds:[]}:{}}),children:`Add feed value`})]})})]})})}function XE(){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=IE();i(!0),n.pi(FE,{limit:500}).then(({items:n})=>{let r=n.filter(t=>zE(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.Dr(FE,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:PE,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:BE(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)=>BE(t).filter(e=>!e.isdeleted).length},{title:`Updated`,key:`updatedAt`,responsive:[`lg`],render:(e,t)=>WE(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(PE(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)(YE,{open:a,record:d,onClose:()=>o(!1),onSaved:()=>{o(!1),h()}})]})}function ZE(){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)(NE,{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)(XE,{}),(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)(NE,{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)(JE,{})]})}var{Text:QE,Title:$E}=c.Typography;function eD(){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 Kx())}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 Jx(d.menu_id,e):await qx(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 Yx(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)($E,{level:4,children:`Menus`}),(0,u.jsx)(QE,{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 tD=`/admin/global`;function nD(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 rD(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 iD(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 aD({includeInactive:e=!1,signal:n}={}){let r=await t.o(t.x,`${tD}/regions${rD({includeInactive:e||void 0})}`,{signal:n}),i=r?.data??r;return Array.isArray(i)?i:[]}async function oD(e,{allowEmpty:n=!1,signal:r}={}){return t.o(t.x,`${tD}/regions${rD({allowEmpty:n||void 0})}`,{method:`POST`,body:JSON.stringify(e),signal:r})}async function sD(e,{signal:n}={}){return t.o(t.x,`${tD}/regions/${encodeURIComponent(e)}`,{method:`DELETE`,signal:n})}async function cD({signal:e}={}){let n=await t.o(t.x,`${tD}/platform-access`,{signal:e}),r=n?.data??n;return Array.isArray(r)?r:[]}async function lD(e,{signal:n}={}){return t.o(t.x,`${tD}/platform-access`,{method:`POST`,body:JSON.stringify(e),signal:n})}async function uD(e,{signal:n}={}){return t.o(t.x,`${tD}/platform-access/${encodeURIComponent(e)}`,{method:`DELETE`,signal:n})}async function dD({signal:e}={}){try{return await aD({signal:e}),!0}catch(e){if(e?.name===`AbortError`)throw e;return!1}}async function fD({search:e,regionKey:n,limit:r=25,offset:i=0,signal:a}={}){return nD(await t.o(t.x,`${tD}/users${rD({search:e,regionKey:n,limit:r,offset:i})}`,{signal:a}))}async function pD({regionKey:e,action:n,limit:r=50,offset:i=0,signal:a}={}){return nD(await t.o(t.x,`${tD}/audit${rD({regionKey:e,action:n,limit:r,offset:i})}`,{signal:a}))}async function mD(e,{signal:n}={}){let r=await t.o(t.x,iD(e,`/detail-defaults`),{signal:n});return r?.data??r??{}}async function hD(e,n,{signal:r}={}){return t.o(t.x,iD(e,`/detail-defaults`),{method:`POST`,body:JSON.stringify(n),signal:r})}async function gD(e,{signal:n}={}){return nD(await t.o(t.x,iD(e,`/users`),{signal:n}))}async function _D(e,{signal:n}={}){return nD(await t.o(t.x,iD(e,`/roles`),{signal:n}))}var vD=[{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 yD({signal:e}={}){let n=await t.o(t.x,`${tD}/defaults`,{signal:e}),r=n?.data??n??{};return{regions:r.regions??[],common:r.common??{}}}async function bD(e,{regionKeys:n,signal:r}={}){return t.o(t.x,`${tD}/defaults`,{method:`PUT`,body:JSON.stringify({values:e,regionKeys:n??[]}),signal:r})}var xD=[{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 SD({serviceKey:e=`pyOps`,signal:n}={}){let r=await t.o(t.x,`${tD}/ai-services${rD({serviceKey:e})}`,{signal:n}),i=r?.data??r??{};return{serviceKey:i.serviceKey??e,regions:i.regions??[],missingRegions:i.missingRegions??[],consistent:!!i.consistent}}async function CD(e,{regionKeys:n,signal:r}={}){return t.o(t.x,`${tD}/ai-services`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,regionKeys:n??[]}),signal:r})}var{Text:wD}=c.Typography;function TD({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 yD({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 bD(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)(wD,{strong:!0,children:e}),(0,u.jsx)(wD,{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)(wD,{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)(wD,{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=xD.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)(wD,{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)(wD,{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)(wD,{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{Text:ED,Paragraph:DD}=c.Typography;function OD({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 SD({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 CD(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)(DD,{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)(ED,{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)(ED,{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)(ED,{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)(ED,{type:`secondary`,children:`None`})}],dataSource:o,pagination:!1,locale:{emptyText:e.length?`No regions returned`:`No regions configured`}})]})}var{Text:kD,Title:AD}=c.Typography;function jD(){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 aD({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)(AD,{level:4,style:{margin:0},children:[(0,u.jsx)(l.SafetyCertificateOutlined,{}),` Platform`]}),(0,u.jsx)(kD,{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)(kD,{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)(MD,{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)(TD,{regions:n})},{key:`ai-services`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.ApiOutlined,{}),` AI Services`]}),children:(0,u.jsx)(OD,{regions:n})},{key:`users`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.TeamOutlined,{}),` All Users`]}),children:(0,u.jsx)(ID,{regions:n})},{key:`access`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.KeyOutlined,{}),` Access`]}),children:(0,u.jsx)(LD,{})},{key:`audit`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.AuditOutlined,{}),` Audit`]}),children:(0,u.jsx)(RD,{regions:n})}]})]})}function MD({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)(kD,{type:`secondary`,children:`Users`})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(kD,{strong:!0,children:e.userCount??`—`})})]}),(0,u.jsxs)(c.Row,{children:[(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(kD,{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)(kD,{type:`secondary`,children:`none`})})})]}),(0,u.jsxs)(c.Row,{children:[(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(kD,{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)(kD,{type:`secondary`,style:{fontSize:11,wordBreak:`break-all`},children:e.tenantId})]})})},e.key))}),(0,u.jsx)(ND,{region:r,onClose:()=>i(null),onSaved:n}),(0,u.jsx)(FD,{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)(kD,{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)(ND,{region:r,onClose:()=>i(null),onSaved:n})]})}function ND({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 oD(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:`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 sD(e.key),c.message.success(`Region deactivated`),n?.(),t()}}),children:`Deactivate region`})]})}var PD=[{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 FD({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),mD(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 hD(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:PD.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 ID({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 fD({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 LD(){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 cD())}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 uD(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 lD(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:vD,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 RD({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),pD({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)(kD,{type:`secondary`,children:`platform`})},{title:`Route`,dataIndex:`route`,key:`route`,render:e=>(0,u.jsx)(kD,{type:`secondary`,style:{fontSize:12},children:e})}],dataSource:t,pagination:{current:f,pageSize:50,total:r,showSizeChanger:!1,onChange:p}})]})}var{Content:zD,Header:BD,Sider:VD}=c.Layout,{Text:HD,Title:UD}=c.Typography;function WD(e){return String(e??``).trim().replace(/[\s_-]+/g,` `).toUpperCase()}function GD(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function KD(e){return String(e||``).trim().toLowerCase()}function qD(e){return e?.key||e?.collectionName||e?.value||``}function JD(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=qD(e);if(!t)return;let o=KD(e.key||t),s=KD(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||GD(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=KD(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:GD(t),value:t,disabled:!1}))}),n}function YD(e){return WD(e?.user_type_name??e?.userTypeName??e?.name)===`SUPER ADMIN`}function XD(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 ZD(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 QD(e){return String(e.menuKey??e.menuName??e.menuId).trim().toLowerCase()}var $D=[{permissionId:null,permissionKey:`my_jobs`,permissionName:`My Jobs`},{permissionId:null,permissionKey:`all_jobs`,permissionName:`All Jobs`},{permissionId:null,permissionKey:`sendApprove`,permissionName:`Send Approve`}];function eO(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 $D.forEach(e=>{r.has(e.permissionKey.toLowerCase())||n.push(e)}),n}function tO(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 nO({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=QD(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)(UD,{level:4,children:e}),(0,u.jsx)(HD,{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)(HD,{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=>eS(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:tO(e)})},e.key))})}],dataSource:f,pagination:!1,scroll:{y:420}}):(0,u.jsx)(c.Empty,{description:`Select a record to customize permissions`})]})}function rO({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),[U,ie]=(0,s.useState)([]),[ae,oe]=(0,s.useState)(!1),[se,W]=(0,s.useState)(!1),[ce,G]=(0,s.useState)(null),[le,ue]=(0,s.useState)(!1),[de,fe]=(0,s.useState)(null),[pe,me]=(0,s.useState)(`listView`),[he,ge]=(0,s.useState)([]),[K,q]=(0,s.useState)([]),[_e,ve]=(0,s.useState)(!1),[ye,be]=(0,s.useState)(!1),xe=t.d(),Se=(0,s.useMemo)(()=>he.filter(e=>!e.disabled),[he]),Ce=!_e&&Se.length===0,we=(0,s.useCallback)(async()=>{ve(!0);try{let[e,t]=await Promise.all([n.qr(),n.zr()]),r=JD(e.modules,t),i=new Set(r.filter(e=>!e.disabled).map(e=>e.value));ge(r),q(e=>e.filter(e=>i.has(e)))}catch{c.message.error(`Failed to load seed status`)}finally{ve(!1)}},[]);(0,s.useEffect)(()=>{we()},[we]);async function Te(){if(K.length===0){c.message.warning(Ce?`All modules already seeded.`:`Select at least one module to seed.`);return}be(!0);try{await n.Di(K),c.message.success(`User type field config seeded`),q([]),await we()}catch(e){c.message.error(e?.message||`Seed failed`)}finally{be(!1)}}async function Ee(){f(!0);try{let[e,t,n]=await Promise.allSettled([Hx(),Kx(),Xx()]),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`?eO(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(()=>{Ee()})},[]);let De=(0,s.useCallback)(async()=>{O(!0);try{let{users:e,total:t}=await Lx({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)(()=>{De()},[De]),(0,s.useEffect)(()=>{queueMicrotask(()=>{if(!F){R([]);return}m(!0),Zx(F).then(e=>{let t=ZD(e??[]),n=new Map(t.map(e=>[`${QD(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 Oe=(0,s.useMemo)(()=>k.find(e=>e.user_type_id===F),[F,k]),ke=(0,s.useMemo)(()=>k.reduce((e,t)=>({...e,[t.user_type_id]:t.user_type_name}),{}),[k]),Ae=(0,s.useMemo)(()=>_.reduce((e,t)=>({...e,[t.user_id]:XD(t)}),{}),[_]),je=(0,s.useMemo)(()=>k.filter(e=>!YD(e)),[k]),Me=(0,s.useMemo)(()=>_.filter(e=>!YD({user_type_id:e.user_type_id,user_type_name:ke[e.user_type_id]})),[ke,_]);(0,s.useEffect)(()=>{if(!z){ie([]);return}let e=Number(r.getFieldValue(`user_type_id`)??0);if(!e){ie([]);return}let t=!1;return oe(!0),Rx(e).then(e=>{t||ie(e.filter(e=>!V||e.user_id!==V.user_id))}).catch(e=>{t||(c.message.error(e.message||`Unable to load reporting users`),ie([]))}).finally(()=>{t||oe(!1)}),()=>{t=!0}},[V,r,z]);let Ne=(0,s.useMemo)(()=>{let e=U.map(e=>({label:XD(e),value:e.user_id})),t=Number(V?.reporting_id??V?.reportingId??0);return!t||e.some(e=>Number(e.value)===t)?e:[{label:V?.reportingName??V?.reporting_name??Ae[t]??`User ${t}`,value:t},...e]},[V,U,Ae]),Pe=(0,s.useMemo)(()=>{let e=je.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:ke[t]??V.userType??V.roleName??(t>0?`Type ${t}`:`Unassigned`),value:t},...e]},[V,je,ke]);k.length,j.length;let Fe=[{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)(hw,{})},{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)(Yw,{})},{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)(zT,{})},{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)(ZT,{})},{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)(iE,{})},{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)(uE,{})},{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)(wE,{})},{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)(ME,{})},{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)(ZE,{})}],[Ie,Le]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=new AbortController;return dD({signal:e.signal}).then(Le).catch(()=>Le(!1)),()=>e.abort()},[]);let Re=[...Ie?[{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 ze(e,t){R(n=>n.map(n=>n.key===e?{...n,accessValue:t}:n))}async function Be(){g(!0);try{await Qx(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:xe?.userId??null}))),c.message.success(`Role permissions updated`)}catch(e){c.message.error(e.message||`Unable to save role permissions`)}finally{g(!1)}}function Ve(){H(null),r.resetFields(),r.setFieldsValue({status:`ACTIVE`,user_type_id:je[0]?.user_type_id,reporting_id:0}),B(!0)}function He(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 Ue(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:xe?.userId??null,created_by:xe?.userId??null};t.password||delete t.password,V?(await Bx(V.user_id,t),c.message.success(`User updated`)):(await zx(t),c.message.success(`User created`)),B(!1),H(null),await De()}catch(e){c.message.error(e.message||`Unable to save user`)}finally{te(!1)}}async function J(e){re(e);try{await Vx(e),c.message.success(`User deleted`),await De()}catch(e){c.message.error(e.message||`Unable to delete user`)}finally{re(null)}}function Y(e,t){me(`listView`),fe({kind:e,record:t}),e===`role`&&I(t.user_type_id)}function X(e,t){R(n=>{let r=[...new Set(n.map(QD))],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(QD(e))-o.get(QD(t)))})}function We(){G(null),i.resetFields(),i.setFieldsValue({status:`ACTIVE`}),W(!0)}function Ge(e){G(e),W(!0),i.setFieldsValue(e)}async function Ke(e){ue(!0);try{let t=xe?.userId??null,n=!!ce,r=n?await Wx(ce.user_type_id,{...e,updated_by:t}):await Ux({...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.`),W(!1),await Ee(),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{ue(!1)}}async function qe(e){try{await Gx(e),c.message.success(`Role deleted`),await Ee()}catch(e){c.message.error(e.message||`Unable to delete role`)}}return(0,u.jsxs)(c.Layout,{className:`admin-shell`,children:[(0,u.jsx)(VD,{width:248,className:`admin-sider`,children:(0,u.jsxs)(`div`,{className:`admin-sidebar-nav`,children:[(0,u.jsx)(HD,{className:`admin-sidebar-title`,children:`Admin Menu`}),(0,u.jsx)(c.Menu,{theme:`dark`,mode:`inline`,selectedKeys:[a],onClick:({key:e})=>o(e),items:Re})]})}),(0,u.jsx)(c.Layout,{children:(0,u.jsxs)(zD,{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)(UD,{level:4,children:`Users`}),(0,u.jsx)(HD,{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:Ve,children:`Add`})]}),(0,u.jsx)(ch,{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)=>ke[e]||t?.userType||t?.user_type||(Number(e)>0?`Type ${e}`:`—`)},{label:`Reporting Manager`,value:`reporting_id`,width:180,render:(e,t)=>Ae[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:()=>He(t)}),(0,u.jsx)(c.Popconfirm,{title:`Delete user?`,description:`This removes the user from the auth database.`,okText:`Delete`,okButtonProps:{danger:!0},onConfirm:()=>J(t.user_id),children:(0,u.jsx)(c.Button,{danger:!0,"aria-label":`Delete user`,icon:(0,u.jsx)(l.DeleteOutlined,{}),loading:ne===t.user_id,size:`small`})})]})}],dataSource:Me.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:K,options:he,placeholder:Ce?`All modules already seeded`:`Select modules or collections to seed`,disabled:_e||ye||Ce,loading:_e,onChange:q,style:{width:`100%`}})}),(0,u.jsx)(c.Button,{type:`primary`,loading:ye,disabled:_e||K.length===0,onClick:Te,children:`Seed Field Config`})]}),(0,u.jsx)(HD,{type:`secondary`,style:{display:`block`,marginTop:8,fontSize:12},children:Ce?`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)(UD,{level:4,children:`User Types`}),(0,u.jsx)(HD,{type:`secondary`,children:`Role level permissions are inherited by users.`})]}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:We,children:`Add Role`})]}),(0,u.jsx)(ch,{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:()=>Y(`role`,t),children:`Config`}),(0,u.jsx)(c.Button,{"aria-label":`Edit role`,disabled:!n,icon:(0,u.jsx)(l.EditOutlined,{}),size:`small`,onClick:()=>Ge(t)}),n&&!YD(t)&&(0,u.jsx)(c.Popconfirm,{title:`Delete role?`,onConfirm:()=>qe(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)(eD,{})},{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)(UD,{level:4,children:`Configuration Center`}),(0,u.jsx)(HD,{type:`secondary`,children:`CORE-THEME admin modules embedded into the admin dashboard.`})]}),(0,u.jsxs)(c.Tag,{color:`blue`,children:[Fe.length,` configurations`]})]}),(0,u.jsx)(c.Tabs,{className:`admin-config-tabs`,defaultActiveKey:`form-groups`,tabPosition:`left`,items:Fe.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)(UD,{level:4,children:e.title}),(0,u.jsx)(HD,{type:`secondary`,children:e.description})]})}),(0,u.jsx)(`div`,{className:`admin-config-panel-body`,children:e.component})]})}))})]})},...Ie?[{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)(jD,{})})}]:[],{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)(UD,{level:4,children:`Integrations`}),(0,u.jsx)(HD,{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)(uE,{})})})]})}]})}),(0,u.jsxs)(c.Modal,{className:`uss-modal`,title:`Configure User Type: ${de?.record?.user_type_name??``}`,open:!!de,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))}),de&&pe===`permissions`?(0,u.jsx)(nO,{title:`Role Permissions`,description:`Configure menu permissions for this user type`,selectedName:Oe?.user_type_name,loading:p,saving:h,rows:L,onChange:ze,onMove:X,onSave:Be}):de&&pe===`actions`?(0,u.jsx)(IS,{role:{...de.record,roleId:de.record.user_type_id,roleName:de.record.user_type_name}},`${de.record?.user_type_id}-actions`):de&&pe===`form`?(0,u.jsx)(OS,{role:{...de.record,roleId:de.record.user_type_id,roleName:de.record.user_type_name}},`${de.record?.user_type_id}-form`):de?(0,u.jsx)(_S,{role:{...de.record,roleId:de.record.user_type_id,roleName:de.record.user_type_name},configType:pe},`${de.record?.user_type_id}-${pe}`):null]}),(0,u.jsx)(c.Modal,{className:`admin-role-modal`,title:ce?`Edit User Type`:`Create User Type`,open:se,onCancel:()=>W(!1),onOk:()=>i.submit(),okText:ce?`Save`:`Next`,confirmLoading:le,destroyOnHidden:!0,width:900,children:(0,u.jsxs)(c.Form,{form:i,layout:`vertical`,onFinish:Ke,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`,children:(0,u.jsx)(c.Select,{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:Ue,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:()=>{ie([]),queueMicrotask(()=>{let e=Number(r.getFieldValue(`user_type_id`)??0);e&&(oe(!0),Rx(e).then(e=>{ie(e.filter(e=>!V||e.user_id!==V.user_id))}).catch(e=>{c.message.error(e.message||`Unable to load reporting users`),ie([])}).finally(()=>{oe(!1)}))})},options:Pe})})]}),(0,u.jsx)(c.Form.Item,{label:`Reporting Manager`,name:`reporting_id`,children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,loading:ae,placeholder:`Select reporting manager`,optionFilterProp:`label`,options:[{label:`None`,value:0},...Ne]})}),(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 iO=rO;function aO(e,t){return String(e||t).replace(/\/\*$/,``).replace(/\/+$/,``)||t}function oO({loginPath:e=`/login`,adminPath:t=`/admin`,fallbackPath:n=`/`}){let r=(0,f.useNavigate)(),i=aO(e,`/login`),a=aO(t,`/admin`),o=`${a}/*`;return(0,u.jsxs)(f.Routes,{children:[(0,u.jsx)(f.Route,{path:i,element:(0,u.jsx)(Ub,{defaultRedirectPath:a,onLogin:()=>r(a,{replace:!0})})}),(0,u.jsx)(f.Route,{path:o,element:(0,u.jsx)(Pb,{loginPath:i,children:(0,u.jsx)(Hb,{children:(0,u.jsx)(iO,{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 sO(e){return(0,u.jsx)(f.BrowserRouter,{children:(0,u.jsx)(oO,{...e})})}var cO=/[<>]/;function lO(e){return Array.isArray(e)?e.map(String).map(e=>e.trim()).filter(Boolean):String(e??``).split(`,`).map(e=>e.trim()).filter(Boolean)}function uO(e){return Array.isArray(e)?e.some(e=>cO.test(String(e??``))):cO.test(String(e??``))}function dO(e){return lO(e).every(e=>!cO.test(e)&&/^[^,\s@<>]+@[^,\s@<>]+\.[^\s@<>]{2,}$/.test(e))}var{Text:fO}=c.Typography,pO=new Set([`file`,`document`,`attachment`]),mO=`To, CC and BCC cannot contain < or > characters.`;function hO(e){return pO.has(String(e?.type??``).trim().toLowerCase())}function gO(e){return String(e??``).trim().toLowerCase().replace(/[^a-z0-9]/g,``)}function _O(e){return e?typeof e==`string`?e:String(typeof e==`object`?e?._id??e?.id??e?.$oid??``:e):``}function vO(e,t,n){if(!e)return``;let r=gO(t),i=gO(n);if(!r||r===i||r.replace(/s$/,``)===i.replace(/s$/,``))return _O(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=_O(SO(e,t));if(n)return n}return``}async function yO(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 bO(e,t,r){if(!t)return[];let i=[];(e?.placeholders??[]).forEach(e=>{(e?.holders??[]).filter(hO).forEach(a=>{let o=vO(t,e?.moduleName,r);o&&i.push((async()=>{let t=await n.Pn(e.moduleName,o,a.value);return Promise.all((t?.data??[]).map(yO))})())})});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 xO(e,t){return[...new Set([...lO(e),...lO(t)])].join(`, `)}function SO(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 CO(e,t,n){if(!n)return String(e??``);let r=new Map;return(t??[]).forEach(e=>(e.holders??[]).forEach(e=>{r.set(e.key,hO(e)?``:SO(n,e.value,e.arrayMode))})),String(e??``).replace(/{{\.?([\w.]+)}}/g,(e,t)=>{let n=r.get(t);return n==null?e:String(n)})}function wO(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 TO({value:e,onChange:t,defaultTemplateId:r=``,ready:i=!0,title:a=`Mail`,hint:o,bccHint:d,afterBcc:f,beforeFields:p,className:m=``,contextRecords:h=[],moduleName:g=``,requiredTo:_=!1,requiredSubject:v=!1,requiredBody:y=!1}){let b=(0,s.useRef)(``),x=n=>t?.({...e,...n});function S(e){uO(String(e?.nativeEvent?.data??e?.data??``))&&(e.preventDefault(),c.message.warning(mO))}function C(e){uO(String(e?.clipboardData?.getData?.(`text`)??``))&&(e.preventDefault(),c.message.warning(mO))}function w(e,t){if(uO(t)){c.message.warning(mO);return}x({[e]:(Array.isArray(t)?t:lO(t)).join(`, `)})}function T(e){let t=wO(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 E(t,n=!1){if(t)try{let r=await aT(t),i=h[0],a=await bO(r,i,g);x({to:xO(e.to,(r?.toMail??[]).map(e=>CO(e,r?.placeholders,i))),cc:xO(e.cc,(r?.ccMail??[]).map(e=>CO(e,r?.placeholders,i))),bcc:xO(e.bcc,(r?.bccMail??[]).map(e=>CO(e,r?.placeholders,i))),subject:CO(r?.subject,r?.placeholders,i),contents:CO(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)(()=>{!i||!r||b.current===r||(b.current=r,E(r,!0))},[r,i]),(0,u.jsxs)(`div`,{className:`common-mail-composer ${m}`.trim(),onWheelCapture:T,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:a}),o&&(0,u.jsx)(fO,{type:`secondary`,className:`mail-popup__header-hint`,children:o})]})]})}),(0,u.jsxs)(`div`,{className:`mail-popup__body`,children:[p&&(0,u.jsxs)(u.Fragment,{children:[p,(0,u.jsx)(c.Divider,{})]}),(0,u.jsxs)(`div`,{className:`mail-popup__field-row`,onBeforeInputCapture:S,onPasteCapture:C,children:[(0,u.jsxs)(fO,{type:`secondary`,className:`mail-popup__field-label`,children:[`To Mail`,_&&(0,u.jsx)(`span`,{className:`mail-popup__required-mark`,"aria-hidden":`true`,children:`*`})]}),(0,u.jsx)(c.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`],value:lO(e.to),onChange:e=>w(`to`,e),onInputKeyDown:e=>{(e.key===`<`||e.key===`>`)&&(e.preventDefault(),c.message.warning(mO))},variant:`borderless`,className:`mail-popup__recipient-select`,placeholder:`Add email addresses`,"aria-required":_}),(0,u.jsxs)(`div`,{className:`mail-popup__cc-bcc-actions`,children:[!e.showCc&&(0,u.jsx)(`span`,{className:`mail-popup__cc-bcc-link`,onClick:()=>x({showCc:!0}),children:`Cc`}),!e.showBcc&&(0,u.jsx)(`span`,{className:`mail-popup__cc-bcc-link`,onClick:()=>x({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:S,onPasteCapture:C,children:[(0,u.jsx)(fO,{type:`secondary`,className:`mail-popup__field-label`,children:`Cc`}),(0,u.jsx)(c.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`],value:lO(e.cc),onChange:e=>w(`cc`,e),onInputKeyDown:e=>{(e.key===`<`||e.key===`>`)&&(e.preventDefault(),c.message.warning(mO))},variant:`borderless`,className:`mail-popup__recipient-select`})]}),(0,u.jsx)(c.Divider,{})]}),e.showBcc&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`mail-popup__field-row`,onBeforeInputCapture:S,onPasteCapture:C,children:[(0,u.jsx)(fO,{type:`secondary`,className:`mail-popup__field-label`,children:`Bcc`}),(0,u.jsx)(c.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`],value:lO(e.bcc),onChange:e=>w(`bcc`,e),onInputKeyDown:e=>{(e.key===`<`||e.key===`>`)&&(e.preventDefault(),c.message.warning(mO))},variant:`borderless`,className:`mail-popup__recipient-select`,placeholder:d})]}),f,(0,u.jsx)(c.Divider,{})]}),(0,u.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,u.jsxs)(fO,{type:`secondary`,className:`mail-popup__field-label`,children:[`Subject`,v&&(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=>x({subject:e.target.value}),placeholder:`Enter subject`,className:`mail-popup__field-input`,"aria-required":v})]}),(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)(fO,{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)(fO,{type:`secondary`,className:`mail-popup__message-label`,children:[`Body`,y&&(0,u.jsx)(`span`,{className:`mail-popup__required-mark`,"aria-hidden":`true`,children:`*`})]}),(0,u.jsx)(n.Vn,{value:e.contents,onChange:e=>x({contents:e})})]})]})]})}var EO=new Set([`true`,`1`,`yes`,`y`,`on`]),DO=[`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 OO(e,t=!1){return e==null||e===``?t:e===!0||e===!1?e:typeof e==`number`?e===1:typeof e==`string`?EO.has(e.trim().toLowerCase()):t}function kO(e){return String(e??``).trim().toLowerCase().replace(/[^a-z0-9]/g,``)}function AO(e){return[`candidate`,`candidates`,`sourcecandidate`,`sourcecandidates`].includes(kO(e))}function jO(e,t){if(!(!e||!t))return String(t).split(`.`).reduce((e,t)=>e?.[t],e)}function MO(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)]:DO}function NO({popupAction:e={},state:t={},moduleName:n=``}={}){let r=e.mailConfig??t.mailConfig,i=OO(e.requireJobId)||OO(t.requireJobId)||AO(n);if(!r||typeof r!=`object`)return{configured:!1,jobBased:i,recipientSource:`selectedRecords`,recipientFields:MO({},e,t),recipientMode:`allSelected`,removeDuplicateRecipients:!0,jobIdSource:`context`,jobIdField:`jobId`,jobIdReadOnly:!1,autoFetchJobContent:!0,requiredTo:!0,requiredJobId:i,requiredSubject:!0,requiredBody:!0};let a=OO(r.jobBased,i);return{configured:!0,jobBased:a,recipientSource:[`selectedRecords`,`manual`].includes(r.recipientSource)?r.recipientSource:`selectedRecords`,recipientFields:MO(r,e,t),recipientMode:r.recipientMode===`firstSelected`?`firstSelected`:`allSelected`,removeDuplicateRecipients:OO(r.removeDuplicateRecipients,!0),jobIdSource:[`context`,`selectedRecord`,`manual`].includes(r.jobIdSource)?r.jobIdSource:`context`,jobIdField:String(r.jobIdField??`jobId`).trim()||`jobId`,jobIdReadOnly:OO(r.jobIdReadOnly,!1),autoFetchJobContent:OO(r.autoFetchJobContent,a),requiredTo:OO(r.requiredTo,!0),requiredJobId:OO(r.requiredJobId,a),requiredSubject:OO(r.requiredSubject,!0),requiredBody:OO(r.requiredBody,!0)}}function PO(e=[],t=`allSelected`){let n=Array.isArray(e)?e.filter(Boolean):[];return t===`firstSelected`?n.slice(0,1):n}function FO(e,t={},n=[]){let r=e?.jobIdSource??`context`,i=e?.jobIdField||`jobId`;if(r===`manual`)return``;let a=(e,t=i)=>{let n=[jO(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:IO}=c.Typography,LO=/^[a-fA-F0-9]{24}$/,RO=new Set([`file`,`document`,`attachment`]);function zO(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 BO(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 VO(e,t,r=[]){let i=String(e??``);if(!i||!r.length||!t)return{contents:i,attachments:[]};let a=(await n.ai(t).catch(()=>[])).filter(e=>RO.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(!LO.test(r))continue;let i=await n.Pn(t,r,a).catch(()=>({data:[]})),s=await Promise.all((i?.data??[]).map(BO));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 HO(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 UO(e){let t=HO(e,`jobReferenceId`,`clientJobId`,`jobCode`,`reqId`,`jobId`),n=HO(e,`jobTitle`,`title`,`name`),r=HO(e,`jobRecruitmentStatus`,`recruitmentStatus`,`jobStatus`,`status`),i=[t,n].filter(Boolean).join(` - `)||String(HO(e,`_id`,`id`)??`Job`);return r?`${i} — ${r}`:i}function WO(e){let t=HO(e,`_id`,`id`,`jobId`);if(!t)return null;let n=e?.disable===!0||e?.disabled===!0,r=HO(e,`jobRecruitmentStatus`,`recruitmentStatus`,`jobStatus`,`status`),i=String(e?.message??r??``).trim();return{value:String(t),label:UO(e),disabled:n,title:n&&i?i:void 0,raw:e}}function GO(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 KO(e){return LO.test(String(e??``))?UO({...GO(await Yn({module:`jobs`,id:e,view:`detail`})),_id:e}):``}function qO(e=[],t=[]){let n=[...new Set(t.filter(Boolean))];return e.flatMap(e=>n.map(t=>HO(e,t))).flatMap(e=>Array.isArray(e)?e:[e]).flatMap(lO)}function JO(e){let t=HO(e,`jobId`,`job_id`,`job._id`,`job.id`,`jobs._id`,`jobs.id`);return typeof t==`object`?HO(t,`_id`,`id`,`$oid`):t}function YO(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 XO(e,t=!0){let n=e.flatMap(lO);return(t?[...new Set(n)]:n).join(`, `)}function ZO(){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)(()=>NO({popupAction:d,state:t,moduleName:l}),[l,d,t]),m=(0,s.useMemo)(()=>PO(r,p.recipientMode),[p.recipientMode,r]),h=(0,s.useMemo)(()=>p.recipientMode===`firstSelected`?n.slice(0,1):n,[p.recipientMode,n]),g=h.join(`|`),_=(0,s.useMemo)(()=>{let e=p.recipientSource===`selectedRecords`?qO(m,p.recipientFields):[];return XO([...i,...e],p.removeDuplicateRecipients)},[p.recipientFields,p.recipientSource,p.removeDuplicateRecipients,m,i]),v=String(FO(p,t,r)??``).trim(),y=String(JO(r[0])??``).trim(),b=v||(p.configured?``:y),x=n[0]??r[0]?._id??r[0]?.id??``,S=p.jobBased||p.requiredJobId?b:String(b||(p.configured?``:x)||``),C=p.jobIdReadOnly&&p.jobIdSource!==`manual`&&LO.test(b),w=p.jobBased||p.requiredJobId,[T,E]=(0,s.useState)(b),[D,O]=(0,s.useState)(S),[k,A]=(0,s.useState)(``),[j,M]=(0,s.useState)({to:_,cc:``,bcc:``,subject:a,contents:``,attachments:[],showCc:!1,showBcc:!1}),N=p.autoFetchJobContent&&LO.test(S),[P,F]=(0,s.useState)(!N),[I,L]=(0,s.useState)(!1),[R,z]=(0,s.useState)([]),[B,V]=(0,s.useState)(!1),[H,ee]=(0,s.useState)(!1),te=(0,s.useRef)(!1),ne=(0,s.useRef)(``),re=(0,s.useRef)(0);(0,s.useEffect)(()=>{if(p.recipientSource!==`selectedRecords`||!AO(l)||te.current||lO(j.to).length>0||h.length===0||ne.current===g)return;let e=!1;return ne.current=g,Sn(h).then(t=>{if(e)return;let n=qO(PO(t,p.recipientMode),p.recipientFields);n.length&&M(e=>lO(e.to).length>0?e:{...e,to:XO(n,p.removeDuplicateRecipients)})}).catch(t=>{e||c.message.error(t?.message||`Could not load candidate emails`)}),()=>{e=!0}},[j.to,p.recipientFields,p.recipientMode,p.recipientSource,p.removeDuplicateRecipients,l,h,g]),(0,s.useEffect)(()=>{if(!p.autoFetchJobContent||!D){F(!0),L(!1);return}if(!LO.test(D)){F(!p.requiredJobId);return}let e=++re.current,t=!1;async function n(){F(!1),L(!0),M(e=>({...e,contents:``}));try{let[n,i]=await Promise.all([xn(D),C?KO(D).catch(()=>``):Promise.resolve(``)]),o=YO(n),s=await VO(o.contents||``,l,r),u=s.contents;if(u.trim())try{u=await Cn(u,o.subject||a)}catch(n){!t&&e===re.current&&c.message.warning(n?.message||`Mail content formatting failed. Showing original content.`)}if(t||e!==re.current)return;i&&A(i),M(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===re.current&&p.requiredJobId&&c.message.error(n?.message||`Could not load mail template for this Job ID`)}finally{!t&&e===re.current&&(F(!0),L(!1))}}return n(),()=>{t=!0}},[D,p.autoFetchJobContent,p.configured,p.requiredJobId]);function U(e=T){let t=String(e??``).trim();if(!LO.test(t)){O(``),A(``),t&&c.message.warning(`Enter a valid 24-character Job ID`);return}if(t===D){O(``),queueMicrotask(()=>O(t));return}O(t)}function ie(e,t){if(t?.disabled)return;if(!e){O(``),E(``),A(``);return}let n=t?.label??``;E(String(n||(e??``))),A(n?String(n):``),U(e)}function oe(e){let t=String(e??``).trim();if(E(t),t.length<3){z([]);return}V(!0),ae(t).then(e=>{let t=(Array.isArray(e)?e:[]).map(WO).filter(Boolean);z(t)}).catch(e=>c.message.error(e?.message||`Unable to search jobs`)).finally(()=>V(!1))}let se=lO(j.to).length>0,W=P&&(!p.requiredJobId||LO.test(D))&&(!p.requiredTo||se)&&dO(j.to)&&dO(j.cc)&&dO(j.bcc)&&(!p.requiredSubject||j.subject.trim().length>0)&&(!p.requiredBody||zO(j.contents));async function ce(){if(!(!W||H)){ee(!0);try{await wn({jobId:D,toMail:lO(j.to),ccMail:lO(j.cc),bccMail:lO(j.bcc),subject:j.subject,contents:j.contents,attachments:j.attachments??[]}),c.message.success(`Mail sent successfully`),typeof o==`function`&&o({...j,message:j.contents,selectedIds:n}),e(-1)}catch(e){c.message.error(e?.message||`Failed to send mail`)}finally{ee(!1)}}}function G(e){e?.to!==j.to&&(te.current=!0),M(e)}let le=w?(0,u.jsxs)(`div`,{className:`mail-popup__job-row`,children:[(0,u.jsxs)(IO,{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:`*`})]}),C?(0,u.jsx)(c.Input,{value:k||D,readOnly:!0,className:`mail-popup__job-input`,"aria-required":p.requiredJobId}):(0,u.jsx)(c.Select,{showSearch:!0,allowClear:!0,filterOption:!1,value:D||void 0,searchValue:T,onSearch:oe,onChange:ie,onClear:()=>{O(``),E(``),z([])},placeholder:`Minimum 3 characters`,notFoundContent:B||I?(0,u.jsx)(c.Spin,{size:`small`}):null,options:R,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:H,disabled:!W,onClick:ce,children:`Send`})]}),children:(0,u.jsx)(c.Spin,{spinning:I,description:`Loading mail content...`,size:`large`,children:(0,u.jsx)(TO,{value:j,onChange:G,moduleName:l,defaultTemplateId:p.autoFetchJobContent?``:d.defaultTemplateId??t.defaultTemplateId??``,ready:P,contextRecords:r,requiredTo:p.requiredTo,requiredSubject:p.requiredSubject,requiredBody:p.requiredBody,beforeFields:le})})})}var{Text:QO}=c.Typography,$O=e=>e===!0||e===1||e===`1`;function ek(e){return e?e.trim().split(/\s+/).slice(0,2).map(e=>e[0].toUpperCase()).join(``):`?`}function tk(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 nk(e){return e?e.email??e.emailId??e.emailAddress??``:``}function rk(e){return e?e.status?e.status:e.stage?e.stage:typeof e.isActive==`boolean`?e.isActive?`Active`:`Inactive`:``:``}function ik(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 ak(e){let t=tu(e);return[...e].filter(e=>!$O(e.hideGroup)&&!$O(e.hideGroupInDetail)).filter(e=>nu(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||$O(e.show))&&nu(e,t)).map(e=>({...e,label:iu(e,t)})).sort((e,t)=>Number(e.order??0)-Number(t.order??0))})).filter(e=>e.fields.length)}function ok({record:e}){let t=tk(e),n=nk(e),r=rk(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:ek(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 sk({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=ik(e,t),a=r.value,o=r.renderType===`document`?n.Qt(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)(ed,{field:r,record:i})})]},r.field??r.label)})}),(0,u.jsx)(r.t,{documents:a,open:d,onClose:()=>f(!1),initialIndex:c})]})}function ck(){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)(()=>ak(a),[a]),w=(0,s.useMemo)(()=>tu(a),[a]);(0,s.useEffect)(()=>{if(!t||!i)return;let e=!1;return Promise.all([Yn({module:t,id:i,view:`detail`}),n.Pn(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)(sk,{fields:e.fields,centralDocuments:h,recordValueMap:w}):(0,u.jsx)(QO,{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)(ok,{record:r}),M()]})})}var{Text:lk}=c.Typography;function uk({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)(Op,{moduleName:e,id:i,onHeaderData:d}):(0,u.jsx)(`div`,{style:{padding:24},children:(0,u.jsx)(lk,{type:`secondary`,children:`No record id.`})})})}uk.propTypes={moduleName:p.default.string,backPath:p.default.string};var{Text:dk}=c.Typography,{TextArea:fk}=c.Input,pk=[{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 mk(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)(fk,{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 hk({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)(dk,{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)(dk,{type:`secondary`,children:`Please review the information above before submitting.`})]})]}):(0,u.jsx)(`div`,{className:`wizard-review-empty`,children:(0,u.jsx)(dk,{type:`secondary`,children:`No data entered yet.`})})}function gk(){let[e]=c.Form.useForm(),t=(0,f.useNavigate)(),{title:n=`Wizard`,moduleName:r=``,steps:i=pk,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:mk(e)})},e.name))})},e.key)),d.isReview&&(0,u.jsx)(hk,{steps:i,form:e})]})})]})}function _k({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 vk({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.Hn,{variant:`body`,color:`secondary`,className:`dynamic-popup__note`,children:e}),t&&(0,u.jsx)(n.Hn,{variant:`body`,className:`dynamic-popup__description`,children:t}),r&&i>0&&(0,u.jsxs)(n.Hn,{variant:`body`,className:`dynamic-popup__selected-count`,children:[`Changing status for `,(0,u.jsx)(`strong`,{children:i}),` selected `,a,`.`]}),o&&(0,u.jsx)(n.Hn,{variant:`body`,children:o}),s&&(0,u.jsx)(n.Hn,{variant:`caption`,color:`danger`,className:`dynamic-popup__error`,children:s})]})}function yk({footerNote:e}){return e?(0,u.jsx)(n.Hn,{variant:`caption`,color:`secondary`,className:`dynamic-popup__footer-note`,children:e}):null}function bk(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t?.[n]??``).trim()}function xk(e){return String(e).replace(/\(\s*\)/g,``).replace(/\s+/g,` `).replace(/(^|\s)([-–—·|])(?=\s*\2)/g,``).replace(/^[\s\-–—·|]+/,``).replace(/[\s\-–—·|]+$/,``).trim()}function Sk(e){if(!e)return!1;let t=new Date(e).getTime();return Number.isNaN(t)||t<=0?!1:t<=Date.now()+864e5}function Ck(e){if(!Sk(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 wk(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 Tk(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 Ek(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:Ck(wk(e))}:e,o=(i?xk(bk(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||Tk(e);t&&(u.submittedAt=t)}if(e?.isFromSubmission===!0&&e?.submissionId){u.isFromSubmission=!0,u.priorSubmissionId=String(e.submissionId);let t=e?.lastSubmittedAt||Tk(e);t&&(u.priorSubmittedAt=t)}return u}function Dk(e,t){return(t?.[e.optionsKey]??e.defaultOptions??[]).map(t=>Ek(t,e))}function Ok(e={}){return{selectedIds:[],selectedRecords:[],moduleName:``,removedIds:[],...e}}var kk=`DD MMM YYYY`,Ak=`DD MMM YYYY, h:mm A`;function jk(e,t){if(e==null||e===``)return``;let n=(0,d.default)(e);return n.isValid()?t===`relative`?Ck(e)||(Sk(e)?n.format(kk):`Not updated`):Sk(e)?n.format(kk):``:String(e)}function Mk(e,t){return e?String(e).includes(`{`)?xk(bk(e,t)):String(t?.[e]??e).trim():``}function Nk(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(Ak)}`:`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(Ak)} — this form will prefill from it`:`Submitted to another job before — this form will prefill from it`}}return null}function Pk(e,t){return e?.alreadySubmitted||!e?.disabled?``:String(t?.message??e?.title??``).trim()}function Fk({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 Ik({option:e,layout:t}){let n=e?._raw??e??{},r=Mk(t.id,n),i=Mk(t.title,n)||String(e?.label??``),a=Mk(t.subtitle,n),o=Mk(t.titleAccent?.key,n),s=Mk(t.titleAccent?.toneKey,n),d=t.titleAccent?.prefix??``,f=(t.meta??[]).map(e=>({label:e.label,text:jk(n?.[e.key],e.type)})).filter(e=>e.text),p=Pk(e,n),m=Nk(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)(Fk,{meta:f})]})}var{Text:Lk}=c.Typography,{TextArea:Rk}=c.Input,zk=[{label:`$`,value:`$`},{label:`EUR`,value:`EUR`},{label:`GBP`,value:`GBP`},{label:`INR`,value:`INR`}],Bk=[{label:`Hourly`,value:`Hourly`},{label:`Daily`,value:`Daily`},{label:`Weekly`,value:`Weekly`},{label:`Monthly`,value:`Monthly`},{label:`Yearly`,value:`Yearly`}];function Vk(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 Hk({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 Uk({field:e,value:t,onChange:n}){return(0,u.jsx)(Rk,{value:t,onChange:n,rows:e.rows??5,placeholder:e.placeholder})}function Wk({field:e,options:t,value:n,onChange:r}){let i=Vk(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:Kk,prefix:(0,u.jsx)(l.CrownOutlined,{})})}function Gk({field:e,options:t,value:n,onChange:r}){let i=Vk(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:Kk,prefix:(0,u.jsx)(l.CrownOutlined,{})})}function Kk(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`})]})}function qk({field:e,options:t,onSearch:n,value:r,onChange:i,popupContext:a}){let o=Vk(t),s=e.optionLayout,d=new Map(o.map(e=>[String(e?.value??``),e])),f=e.multiSelect||e.multiple||e.mode===`multiple`?`multiple`:e.mode;async function p(t,n){let r=Array.isArray(t)?Array.isArray(n)?n:t.map(e=>d.get(String(e??``))).filter(Boolean):n??d.get(String(t??``));(typeof e.onSelectGuard!=`function`||await e.onSelectGuard({value:t,option:r,field:e,popupContext:a,confirm:c.Modal.confirm})!==!1)&&i?.(t)}return(0,u.jsx)(c.Select,{mode:f,showSearch:!0,filterOption:!1,notFoundContent:e.notFoundContent??null,value:r,onChange:p,options:o,placeholder:e.placeholder,onSearch:n,className:`dynamic-popup__field-select${s?` dynamic-popup__field-select--rich`:``}`,popupClassName:s?`dynamic-popup__option-dropdown`:void 0,listHeight:s?340:void 0,optionLabelProp:`label`,optionRender:s?e=>(0,u.jsx)(Ik,{option:e?.data??e,layout:s}):void 0,prefix:(0,u.jsx)(l.CrownOutlined,{})})}function Jk({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 Yk({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:zk,onChange:e=>a({currency:e}),style:{width:80}}),(0,u.jsx)(c.Select,{value:r,options:Bk,onChange:e=>a({period:e}),style:{width:110}})]}),(l||d)&&(0,u.jsxs)(`div`,{style:{marginTop:4},children:[l&&(0,u.jsx)(Lk,{type:`danger`,style:{fontSize:12,display:`block`},children:`To rate must be greater than From rate.`}),d&&(0,u.jsxs)(Lk,{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 Xk({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 Zk({field:e,checked:t,onChange:n}){return(0,u.jsx)(c.Checkbox,{checked:t,onChange:n,children:e.checkboxLabel})}function Qk({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 $k({options:e,value:t,onChange:n}){return(0,u.jsx)(c.Radio.Group,{value:t,onChange:n,options:e})}var eA={input:Hk,text:Hk,textarea:Uk,select:Wk,"multi-select":Gk,"search-select":qk,"mention-textarea":Jk,"candidate-rate":Yk,"priority-checkbox":Zk,"date-picker":Xk,number:Qk,radio:$k};function tA(e){return e===`priority-checkbox`?{valuePropName:`checked`}:{}}var nA=new Set([`input`,`text`,`textarea`,`mention-textarea`]);function rA({form:e,fields:t,initialValues:r,dynamicOptions:i,popupContext:a,extraData:o,removedIds:l,setRemovedIds:d,onRemoveAssigned:f,showAlreadyAssigned:p,onValuesChange:m,getSearchHandler:h,getMentionSearchHandler:g,mentionOptions:_}){let[v,y]=(0,s.useState)([]),b=(o?.recruitersData??[]).filter(e=>{let t=String(e?.user_id??e?.id??e?.userId??``);return t&&!l.includes(t)}),x=p&&o,S=new Set(p?b.map(e=>String(e?.user_id??e?.id??e?.userId??``).trim()).filter(Boolean):[]),C=e=>S.size===0||!Array.isArray(e)?e:e.map(e=>{let t=String((e&&typeof e==`object`?e.value??e.id:e)??``).trim();return!S.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&&!x?null:(0,u.jsxs)(u.Fragment,{children:[x&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`dynamic-popup__already-assigned`,children:[(0,u.jsx)(n.Hn,{variant:`caption`,color:`secondary`,children:`Already Assigned People`}),(0,u.jsx)(`div`,{style:{marginTop:6,display:`flex`,flexWrap:`wrap`,gap:6},children:b.length===0?(0,u.jsx)(n.Hn,{variant:`caption`,color:`secondary`,children:`No one is currently assigned to this job.`}):b.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=v.includes(t);return(0,u.jsxs)(c.Tag,{closable:!r,onClose:async n=>{if(n.preventDefault(),!(!t||r)){y(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{y(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:iA(t).map(e=>aA(e,e=>{let t=C(i[e.name]??Dk(e,a)),r=h(e),o=g(e),s=_[e.name]??[],l=tA(e.type),d=eA[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()}}),nA.has(e.type)&&f.push(n.xn({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,mentionOpts:s,onMentionSearch:o,popupContext:a}):null},e.name)}))})]})}function iA(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 aA(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 oA(e){return[`select`,`multi-select`,`search-select`,`radio`].includes(e?.type)&&e?.dataSource===`master`&&e?.masterName}function sA(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 cA(e){let t=String(e?.masterName??``).trim().toLowerCase();return t===`clientsubmissions`||t===`clientsubmissionstatus`}function lA(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 uA(e,t){return cA(t)?lA(e):Ek(e,t)}function dA(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 fA(e){let t=Number(e?.id??0)||0,n=String(e?.text??``).trim();return n&&n.toLowerCase()===`not submitted`?!0:t<=0&&!n}function pA(e){return Number(e?._raw?.id??e?._raw?.uniqueId??0)||0}function mA(e){let t=e?._raw?.allowedNextStatusIds;return Array.isArray(t)?t.map(Number).filter(e=>Number.isInteger(e)&&e>0):[]}function hA(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 gA(e){return(Array.isArray(e?.selectedRecords)?e.selectedRecords.filter(Boolean):[]).some(e=>!fA(dA(e)))?!0:!fA(dA(e??{}))}async function _A(e,n){if(gA(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=hA(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 vA(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=dA(n);if(fA(i)){let e=dA(r);fA(e)||(i=e)}if(fA(i))return t?._raw?.isInitialStatus===!0;let a=e.find(e=>{let t=pA(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:mA(a).includes(pA(t))}))}function yA({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(oA);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=sA(t).map(t=>uA(t,e)).filter(Boolean),i=a;if(cA(e)&&(i=await _A(a,r)),o.signal.aborted)return;let s=cA(e)?vA(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 bA=500,xA=3;function SA({api:e,open:t,fields:n=[],popupContext:r,setDynamicOptions:i}){let[a,o]=(0,s.useState)({}),c=(0,s.useRef)({}),l=(0,s.useRef)({}),u=(0,s.useRef)({}),d=(0,s.useCallback)((t,n)=>{let a=e.searchOptions??e.searchFetcher;if(typeof a!=`function`)return;l.current[t.name]?.abort();let o=new AbortController;return l.current[t.name]=o,Promise.resolve(a(t,n,r)).then(e=>{if(o.signal.aborted)return;let n=Array.isArray(e)?e:e?.items??e?.list??[];i(e=>({...e,[t.name]:n.map(e=>Ek(e,t))}))}).catch(e=>{o.signal.aborted||console.error(`[DynamicPopup] Search failed for field "${t.name}":`,e)}),o},[e,r,i]),f=n.filter(e=>(e.searchFetchKey||e.searchFetcher)&&e.preloadOptions!==!1),p=f.map(e=>e.name).join(`|`),m=(0,s.useRef)({runSearch:d,preloadFields:f});(0,s.useEffect)(()=>{m.current={runSearch:d,preloadFields:f}}),(0,s.useEffect)(()=>{if(!t||!p)return;let{runSearch:e,preloadFields:n}=m.current,r=n.map(t=>e(t,``)).filter(Boolean);return()=>r.forEach(e=>e.abort())},[t,p]);function h(t){if(!t.searchFetchKey&&!t.searchFetcher||typeof(e.searchOptions??e.searchFetcher)!=`function`)return;let n=t.searchMinLength??xA;return e=>{clearTimeout(c.current[t.name]);let r=e.length<n?``:e;c.current[t.name]=setTimeout(()=>{d(t,r)},bA)}}function g(t){let n=e.getMentionOptions??e.mentionFetcher;if(typeof n==`function`)return e=>{u.current[t.name]?.abort();let i=new AbortController;u.current[t.name]=i,Promise.resolve(n(t,e,r)).then(e=>{if(i.signal.aborted)return;let n=Array.isArray(e)?e:e?.items??e?.list??[];o(e=>({...e,[t.name]:n.map(e=>({value:e.user_name??e.userName??e.username??String(e),label:e.user_name??e.userName??e.username??String(e)}))}))}).catch(e=>{i.signal.aborted||console.error(`[DynamicPopup] Mention search failed for field "${t.name}":`,e)})}}return{mentionOptions:a,getSearchHandler:h,getMentionSearchHandler:g}}function CA({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 wA({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)(()=>Ok(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=>{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}=yA({open:e,config:t,api:a,fields:x,popupContext:g,formValues:l}),{mentionOptions:E,getSearchHandler:D,getMentionSearchHandler:O}=SA({api:a,open:e,fields:x,popupContext:g,setDynamicOptions:w});function k(e){typeof r==`function`&&r(e)}let A=x.filter(e=>e.required),j=A.every(e=>{let t=h[e.name];return!(t==null||t===``||Array.isArray(t)&&t.length===0||typeof t==`object`&&!Array.isArray(t)&&Object.keys(t).length===0)}),M=(g.removedIds??[]).length,N=p.length>M,P=A.some(e=>{let t=h[e.name];return!(t==null||t===``||Array.isArray(t)&&t.length===0)}),{handleOk:F,confirming:I,deleteError:L,resetSubmitState:R}=CA({form:o,config:t,api:a,popupContext:g,resolvedIds:b,dynamicOptions:C,extraData:T,removedIds:p,removalOnlySubmit:!!t?.allowRemovalOnlySubmit&&N&&!P,fields:x,onClose:k,onSubmit:i});(0,s.useEffect)(()=>{e&&(o.resetFields(),f(S??{}),m(g.removedIds??[]),R())},[e,S]);let z=!!t?.autoSubmitWhenNoFields&&x.length===0;(0,s.useEffect)(()=>{!e||!z||F()},[e,z]);let B=_.length,V=String(y).replace(/s$/i,``),H=B===1?V:y,ee=v[0]??{},te=t?.getTitleText?t.getTitleText(B,H,ee,g):t?.title,ne=B===1?ee.jobTitle??ee.title??ee.name??ee.fullName??ee.candidateName??null:null,re=t?.getBodyText?t.getBodyText(B,V,H,ne,g):t?.bodyText??null,U=typeof t?.getNote==`function`?t.getNote(g):t?.note,ie=t?.disabledUntilFilled&&!j&&!N;if(!t||!e||z)return null;let ae=t.component;return ae?(0,u.jsx)(c.Modal,{open:e,title:t.title||t.getTitleText?(0,u.jsx)(_k,{titleText:te,titleIcon:t.titleIcon}):null,footer:null,width:t.width??760,centered:!0,maskClosable:!1,onCancel:()=>k(),className:`dynamic-popup${t.className?` ${t.className}`:``}`,children:(0,u.jsx)(ae,{context:g,selectedIds:b,selectedRecords:v,moduleName:y,onClose:k})}):(0,u.jsxs)(c.Modal,{open:e,title:(0,u.jsx)(_k,{titleText:te,titleIcon:t.titleIcon}),okText:t.okText||`OK`,cancelText:t.cancelText??`Cancel`,onOk:F,onCancel:()=>k(),okButtonProps:{danger:t.okButtonDanger,disabled:ie,loading:I},cancelButtonProps:{disabled:I},closable:!I,maskClosable:!1,width:t.width??480,centered:!0,className:`dynamic-popup${t.className?` ${t.className}`:``}`,children:[(0,u.jsx)(vk,{note:U,description:t.description,showSelectedCount:t.showSelectedCount,count:B,itemLabel:H,bodyText:re,deleteError:L}),(0,u.jsx)(yk,{footerNote:t.footerNote}),(0,u.jsx)(rA,{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:D,getMentionSearchHandler:O,mentionOptions:E})]})}var TA={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:[]},EA={deleteItems:async(e,t)=>{await ie(t.moduleName,e)}},DA=new Map;async function OA(e){return e?(DA.has(e)||DA.set(e,o.r({module:e}).catch(t=>(DA.delete(e),console.warn(`[in-progress gate] could not read ${e} form groups:`,t),[]))),DA.get(e)):[]}function kA(e=[],t){return e.some(e=>{let r=n.F(e,t);return r&&r.severity!==`allow`})}async function AA({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.nr().region;try{let i=await OA(e);if(!kA(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 jA=`Already submitted`,MA=`submissions`,NA=`candidates`,PA=864e5,FA=90,IA=`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.`,LA=[`createdAt`,`createdDate`,`dateCreated`,`created_on`,`createdOn`],RA=[`updatedAt`,`updatedDate`,`lastUpdatedAt`,`lastUpdatedDate`,`modifiedAt`,`modifiedDate`];function zA(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 BA(e){return zA(e,LA)}function VA(e){return zA(e,RA)}function HA(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))/PA))}function UA(e){return e===null?``:e<=14?`green`:e<=89?`yellow`:`red`}function WA(e,t=FA){if(!e)return!1;let n=Date.now()-t*PA,r=BA(e),i=VA(e),a=r&&r.getTime()>=n,o=i&&i.getTime()>=n;return!a&&!o}function GA(e){let t=BA(e);if(!t)return{createdAgo:``,createdAgoTone:``};let n=Ck(t);return n?{createdAgo:n,createdAgoTone:UA(HA(t))}:{createdAgo:``,createdAgoTone:``}}function KA(e){return{...e,...GA(e),isStaleCandidate:WA(e)}}function qA(e){return String(e?.applicantId??e?._id??e?.id??``)}var JA=null;async function YA(){return JA||=n.ni(NA).then(e=>e?.strategies?.duplicateCheck?.editRoute??``).catch(()=>``),JA}async function XA(e){let t=qA(e);if(!t)return``;let n=await YA();return n?n.replace(/:(_?id)\b/g,encodeURIComponent(t)):``}async function ZA({option:e,popupContext:t,confirm:n}){let r=e?._raw??e??{},i=qA(r);if(i){let e=await AA({targetModule:MA,sourceModule:NA,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(!WA(r))return!0;let a=t?.navigate;return!a||!i?!1:new Promise(e=>{n({title:`Candidate update required`,content:IA,okText:`OK`,cancelText:`Cancel`,onOk:async()=>{let t=await XA(r);t&&a(t),e(!1)},onCancel:()=>e(!1)})})}function QA(e,t,n){return{...e,label:`${e.label} - ${jA}`,disabled:!0,title:`${jA}${t?` (submission ${t})`:``}`,alreadySubmitted:!0,existingSubmissionId:t||``,...n?{submittedAt:n}:{}}}var $A={searchOptions:async(e,t,n)=>{if(e.searchFetchKey===`quickSubmitJobList`){let e=n.selectedRecords?.[0]??{},r=e.id??e._id??n.selectedIds?.[0],i,a=!0;try{i=await Ee({searchQuery:t,candidateId:r})}catch{a=!1;let e=await Xn({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 QA(e,e._raw?.jobSubmissionId||``,e._raw?.submittedAt||``);if(e._raw?.disable){let t=String(e._raw?.message??``).trim();return{...e,disabled:!0,label:t?`${e.label} - ${t}`:e.label,title:t}}return e});let s=await Oe({applicantId:r,jobIds:o.map(e=>e.value)}).catch(()=>new Map);return o.map(e=>{let t=s.get(String(e.value));return t?QA(e,t.submissionId,t.submittedAt):e})}if(e.searchFetchKey===`quickSubmitCandidates`){let e=n.selectedRecords?.[0]??{},r=n.jobId??e.jobId??e.id??e._id??n.selectedIds?.[0],i,a=new Map;try{i=await De({search:t,jobId:r})}catch{let e=await ns({isFromSubmission:n.isFromSubmission,jobId:r,submissionId:n.submissionId,search:t});i=Array.isArray(e)?e:[],a=await Oe({jobId:r,applicantIds:i.map(qA)}).catch(()=>new Map)}return i.map(e=>KA(e)).map(e=>{let t=a.get(qA(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:jA,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=>qA(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(WA(u?._raw))throw Error(IA);let p=await AA({targetModule:MA,sourceModule:NA,recordId:l});if(p.severity===`block`)throw Error(p.message);let m=f,h=u?._raw?.existingSubmissionId||u?._raw?.jobSubmissionId||d?.existingSubmissionId||d?._raw?.jobSubmissionId||``;try{let e=await Te({jobId:c,applicantId:l});m||=!!e?.exists,h=e?.submissionId||h}catch(e){throw Error(`Could not verify existing submissions (${e?.message??`request failed`}). Please try again.`,{cause:e})}if(m)throw Error(`This candidate is already submitted for this job${h?` (submission ${h})`:``}.`);let g=new URLSearchParams;l&&g.set(`candidateId`,l);let _=u?.priorSubmissionId||u?._raw?.submissionId||d?.priorSubmissionId||d?._raw?.submissionId||``;_?(g.set(`submissionId`,String(_)),g.set(`isFromSubmission`,`true`)):g.set(`isFromSubmission`,`false`);let v=$o(ts({jobId:c,applicantId:l}).catch(()=>[]));return r(`/submission-create/${c}?${g.toString()}`,{state:{relevantSkillsToken:v}}),{navigated:!0}}},ej={title:`Submit`,okText:`Submit`,width:640,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getNote:e=>e.moduleName===`candidate`?`Note: Select a job to submit this candidate.`:`Note: Select a candidate to submit for this job`,getFields:e=>e.jobId?[]:e.moduleName===`candidate`?[{name:`jobId`,label:`Job list`,type:`search-select`,required:!0,placeholder:`Search Job ID / job name - or pick a recent job`,searchFetchKey:`quickSubmitJobList`,optionLayout:{id:`{jobReferenceId}`,title:`{jobTitle}`,subtitle:`{clientJobReferenceId}`,meta:[{label:`Created`,key:`createdAt`,type:`date`},{label:`Updated`,key:`updatedAt`,type:`relative`}]}}]:[{name:`candidate`,label:`Candidate`,type:`search-select`,required:!0,placeholder:`Search candidate name / email - or pick a recent candidate`,optionsKey:`candidateOptions`,searchFetchKey:`quickSubmitCandidates`,labelTemplate:`{applicantRefrenceId} - {firstName} {lastName} - {createdAgo}`,valueKey:`applicantId`,optionLayout:{id:`{applicantRefrenceId}`,title:`{firstName} {lastName}`,titleAccent:{key:`createdAgo`,toneKey:`createdAgoTone`,prefix:` - `},subtitle:`{designation} - {email}`,meta:[{label:`Created`,key:`createdAt`,type:`date`},{label:`Updated`,key:`updatedAt`,type:`relative`}]},onSelectGuard:ZA}]},tj={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`}]},nj=e=>e?.data??e;async function rj({relatedId:e,notes:n,title:r,notesFor:i}){return nj(await Mn(t.x,`/notes`,{method:`POST`,body:JSON.stringify({relatedId:e,notes:n,title:r,notesFor:i})}))}var ij={getMentionOptions:async(e,t)=>oe(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 rj({relatedId:String(n),notes:e.notes,notesFor:t.moduleName})}},aj={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}`},oj={name:`hiringStage`,label:`Hiring stage`,type:`select`,required:!0,optionsKey:`hiringStageOptions`,defaultOptions:[{label:`Shortlisted`,value:`shortlisted`},{label:`Pipeline`,value:`pipeline`}],initialValueKey:`hiringStage`},sj={title:`Tag to Jobs`,okText:`Tag`,width:480,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getFields:e=>e.jobId&&e.hiringStage?[]:e.jobId?[oj]:[aj,oj]},cj=e=>e?.data??e;function lj(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 uj(e){return e?Array.isArray(e.data)?e.data.map(lj):e.stage&&Array.isArray(e.stage.data)?e.stage.data.map(lj):Array.isArray(e)?e.map(lj):[]:[]}async function dj(e=1,n=10){let r=await t.o(t.x,`/workflow/list/all?page=${e}&limit=${n}`),i=cj(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 fj(e,n){let r=cj(await t.o(t.x,`/workflow/${e}/stage/${n}`));return Array.isArray(r)?{data:r}:r}async function pj(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=cj(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 mj(e){return cj(await t.o(t.T,`/source/workflow-instance`,{method:`POST`,body:JSON.stringify(e)}))}var hj={pipeline:`pipeline`,goodfited:`goodfited`,contacted:`contacted`,submitted:`submitted`,shortlisted:`shortlisted`,interviewinprogress:`interviewInprogress`,selected:`selected`};function gj(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 _j(e){let t=String(e??``).trim();return t?hj[t.toLowerCase()]??t:``}function vj(e,t){let n=gj(e,`candidateId`,`candidate_id`,`applicantId`,`applicantID`,`applicantReferenceId`,`applicantRefrenceId`,`_id`,`id`)??t;if(!n)return null;let r=(gj(e,`candidateName`,`candidate_name`,`fullName`,`name`)??[gj(e,`firstName`,`first_name`),gj(e,`lastName`,`last_name`)].filter(Boolean).join(` `))||void 0,i={candidateId:String(n),candidateName:r,phone:gj(e,`phone`,`phoneNumber`,`phone_number`,`mobile`,`mobileNumber`,`mobile_number`),source:gj(e,`source`,`sourceType`,`candidateSource`,`profileSource`),submittedAt:gj(e,`submittedAt`,`lastSubmittedAt`,`updatedAt`),remarks:gj(e,`remarks`,`comment`,`comments`,`notes`),assignedRecruiter:gj(e,`assignedRecruiter`,`recruiterName`,`ownerName`,`assignedToName`),screeningStatus:gj(e,`screeningStatus`,`screening.status`,`screeningResult`),screeningScore:gj(e,`screeningScore`,`screening.score`,`score`),assignedDate:gj(e,`assignedDate`,`assignedAt`,`createdAt`)};return Object.fromEntries(Object.entries(i).filter(([,e])=>e!=null&&e!==``))}var yj={searchOptions:async(e,t)=>e.searchFetchKey===`tagToJobJobList`?ae(t):[],submit:async(e,t)=>{let n=e.jobId??t.jobId,r=Array.isArray(n)?n:[n].filter(Boolean),i=_j(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=vj(o[t]??{},n);await mj({jobId:e,module:`jobs`,currentStage:i,...r?{candidateDetails:r}:{}})}await G({jobId:n,candidateIds:t.selectedIds,hiringStage:i})}},bj={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 xj(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 Sj={submit:async(e,t,n)=>{let r=xj(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 U(t.moduleName,t.selectedIds,a)}},Cj={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:[]},wj={onOk:async e=>{await ke({jobId:e.jobId??e.selectedIds[0],candidateIds:e.selectedIds})}},Tj={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`}]},Ej={getOptions:async e=>e.fetchOptionsKey===`candidateGroups`?le():[],submit:async(e,t,{dynamicOptions:n})=>{let r=(n.groupId??[]).find(t=>String(t.value)===String(e.groupId));await ue({candidateIds:t.selectedIds,groupId:e.groupId,groupName:r?.label??``})}},Dj=[{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 Oj({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 de({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:Dj,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`})]})]})}Oj.propTypes={selectedIds:p.default.array,onClose:p.default.func};var kj={title:`Self Assign`,width:480,className:`self-assign-modal`,component:Oj},Aj={submit:async()=>{}};function jj(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 Mj={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=>(jj(e?.selectedRecords?.[0]??{}),[{name:`assignToUserId`,label:`Assign to`,type:`multi-select`,required:!0,placeholder:`Select recruiter(s)`,fetchOptionsKey:`assignToUsers`}])},Nj={getOptions:async(e,t,n)=>e.fetchOptionsKey===`assignToUsers`?me(n?.selectedIds?.[0]):[],loadExtraData:async e=>ge(e.selectedIds[0]),removeAssignedUser:async({id:e},t)=>K({jobId:t.selectedIds[0],userId:e}),submit:async(e,t,{removedIds:n,extraData:r})=>{await ye({jobIds:t.selectedIds,userId:e.assignToUserId,removedIds:n,existingRecruiters:r?.recruitersData})}},Pj={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`}]},Fj={getMentionOptions:async(e,t)=>oe(t),submit:async(e,t)=>{let n=e.targetDate?e.targetDate.toISOString():``;t.editingNoteId?await W(t.editingNoteId,{title:e.heading,targetDate:n,notes:e.comments}):await se({relatedIds:t.selectedIds,module:t.moduleName,title:e.heading,targetDate:n,notes:e.comments}),window.dispatchEvent(new Event(`sticky-notes:refresh`))}},Ij={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`}]},Lj={submit:async(e,t)=>{await be({submissionId:t.selectedRecords?.[0]?.submissionId,isMail:e.sendOnboardingEmail})}};function Rj(e){return Array.isArray(e)?e[e.length-1]??{}:e&&typeof e==`object`?e:{}}var zj={USD:`$`,INR:`₹`,EUR:`€`,GBP:`£`};function Bj(e,t,n){let r=Rj(e?.[t])[n];if(r!=null&&r!==``)return r;let i=e?.[`${t}.${n}`];return i!=null&&i!==``?i:void 0}function Vj(e){let t=e.selectedRecords?.[0]??{},n=Bj(t,`candidateRate`,`candidateAcceptedRate`)??Bj(t,`candidateBudget`,`candidateBudgetStart`);if(n===void 0||Number(n)===0)return null;let r=Bj(t,`candidateRate`,`candidateAcceptedCurrency`)??Bj(t,`candidateBudget`,`candidateBudgetCurrency`);return{amount:n,symbol:Bj(t,`candidateRate`,`candidateAcceptedCurrencySymbol`)??Bj(t,`candidateBudget`,`candidateBudgetCurrencySymbol`)??zj[String(r??``).toUpperCase()]??(r||`$`),unit:Bj(t,`candidateRate`,`candidateAcceptedPayUnit`)??Bj(t,`candidateBudget`,`candidateBudgetUnit`)??``}}var Hj={title:`Approve Rate`,okText:`Approve`,width:520,className:`medium-modal`,successMessage:`Rate approved`,getBodyText:(e,t,n,r,i)=>{let a=Vj(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=Vj(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`}]}]},Uj={submit:async(e,t)=>{let n=t.selectedIds[0];if(await xe(n,{candidateProposedRate:e.candidateProposedRate,candidateProposedRateCurrency:e.candidateProposedRateCurrency,candidateProposedRateUnit:e.candidateProposedRateUnit,submitVia:e.submitVia}),e.submitVia===`VMS`)try{await Se(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 Wj(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 Gj(e){let t=await Wj(`/mail-form?${new URLSearchParams({submissionId:e,submissionType:`manager`}).toString()}`);return t.data??t}function Kj(...e){return e.map(e=>e==null?``:String(e).trim()).find(Boolean)??``}var qj=(e,t)=>!!e&&e.toLowerCase()===Kj(t).toLowerCase();function Jj(e,t,n){let r=Kj(t.submittedBy);return Kj(qj(r,n)||qj(r,e.submitSource)||qj(r,e.supplierName)||qj(r,e.source)||qj(r,e.candidateSource)?``:r,e.signatureEmail)}function Yj(e,t={}){let n=Kj(t.employerName,Yv(e),e.supplierName)||void 0;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:Jj(e,t,n),submittedAt:t.createdAt??e.createdAt,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function Xj(e){return Array.isArray(e)?e[e.length-1]:e}function Zj(e={}){let t=Xj(e?.proposedRate)?.candidateProposedRate??e?.candidateProposedRate??e?.proposedRateValue,n=Number(t);return Number.isFinite(n)?n:0}function Qj(e,t={}){let n=Xj((e?.record?.job??e?.job??t?.job??{})?.jobPayDetails)??{},r=e?.record?.submission??t??{},i=Xj(r?.clientBudget)??r?.clientBudget??{},a=n?.clientBudgetEnd??n?.clientBudgetStart??i?.clientBudgetEnd??i?.clientBudgetStart,o=Number(a);return Number.isFinite(o)?o:0}function $j(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 eM(e={}){return String(e?.rateUnit??`hr`).trim().replace(/^\/+/,``)||`hr`}function tM(e,t={}){let n=Number(e);return Number.isFinite(n)?`${$j(t)}${n}/${eM(t)}`:``}function nM(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 rM(e,t,n,r,i){let a=Number(n?.proposedRate),o=Number.isFinite(a)?a:Zj(t),s=Number(n?.clientJobRate),c=Number.isFinite(s)&&s>0?s:Qj(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=nM(u,`(?:Proposed\\s*Rate|Pay\\s*Rate)`,tM(o,n)),u=nM(u,`(?:Job\\s*)?Bill\\s*Rate`,tM(c,n)),u}function iM(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 aM(...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(iM).find(Boolean);if(e)return e}return``}function oM(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 sM(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 cM(...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(iM).find(Boolean);if(e)return e}return``}async function lM(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 uM(e,r,i){let a=[],o=await n.Pn(`submissions`,e,`resume`).catch(()=>({data:[]}));a.push(...o?.data??[]);let s=cM(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=cM((Array.isArray(r?.data)?r.data:Array.isArray(r)?r:[])[0])}if(s){let e=await n.Pn(`candidates`,s,`resume`).catch(()=>({data:[]}));a.push(...e?.data??[])}let c=(await Promise.all(a.map(lM))).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 dM(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:sM(e.content?.value??e.Content?.Value??e.contents??e.body??``)}}function fM({context:e,selectedIds:t,selectedRecords:n,moduleName:r,onClose:i}){let a=n?.[0]??{},o=t?.[0]??Av(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 by(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 ky().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([Gj(o).then(dM),uM(o,l,a).catch(e=>(console.warn(`Unable to resolve resume attachment:`,e),[]))]),n=l?.record?.submission??a;N({to:rM(e.to,n,b,l,a),cc:rM(e.cc,n,b,l,a),bcc:rM(e.bcc,n,b,l,a),subject:rM(e.subject,n,b,l,a),contents:rM(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 xe(o,{candidateProposedRate:b.proposedRate,candidateProposedRateCurrency:b.currencyRaw??b.currency,candidateProposedRateUnit:b.rateUnit,submitVia:`VMS`,...oM(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=!O&&lO(M.to).length>0&&dO(M.to)&&dO(M.cc)&&dO(M.bcc)&&M.subject.trim()&&M.contents.trim(),I=async()=>{if(!b||!F||A)return;j(!0);let e={candidateProposedRate:b.proposedRate,candidateProposedRateCurrency:b.currencyRaw??b.currency,candidateProposedRateUnit:b.rateUnit};try{await xe(o,{...e,submitVia:`VMS`,...oM(S)});let t=aM(l?.record,a);if(!t)c.message.warning(`Submission approved, but job details were not available to send mail`);else try{await wn({jobId:t,toMail:lO(M.to),ccMail:lO(M.cc),bccMail:lO(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)}},L=(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)(ly,{type:iv,record:l.record,lookups:l.lookups,identity:Yj(a,l.display),referralOptions:m,currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:L,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:[(0,u.jsx)(c.Button,{onClick:()=>D(!1),disabled:A,children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,loading:A,disabled:!F,onClick:I,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)(TO,{value:M,onChange:N,moduleName:`submissions`,ready:!O,title:`Submit Via Mail`,contextRecords:[l.record?.submission??a]})})]})}fM.propTypes={context:p.default.object,selectedIds:p.default.array,selectedRecords:p.default.array,moduleName:p.default.string,onClose:p.default.func};var pM={title:`Manager Approve`,width:780,className:`fa-modal manager-approve-modal`,component:fM},mM={submit:async()=>{}};function hM(...e){return e.map(e=>e==null?``:String(e).trim()).find(Boolean)??``}var gM=(e,t)=>!!e&&e.toLowerCase()===hM(t).toLowerCase();function _M(e,t,n){let r=hM(t.submittedBy);return hM(gM(r,n)||gM(r,e.submitSource)||gM(r,e.supplierName)||gM(r,e.source)||gM(r,e.candidateSource)?``:r,e.signatureEmail)}function vM(e,t={}){let n=t.employerName??e.supplierName??e.submitSource;return{client:t.clientName??e.clientName,role:t.jobTitle??e.jobTitle??e.designation,reqId:t.reqId??e.jobClientRefrenceId??e.mspReqId??e.submissionId,name:t.candidateName||[e.firstName,e.lastName].filter(Boolean).join(` `)||e.candidateFullName,location:t.jobLocation??e.city??e.currentLocation??e.jobLocation,vendor:n,submittedBy:_M(e,t,n),submittedAt:t.createdAt??e.createdAt,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function yM(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 bM(e){return String(e??``).toLowerCase().replace(/\b\w/g,e=>e.toUpperCase())}function xM({selectedIds:e,selectedRecords:t,onClose:r}){let i=t?.[0]??{},a=e?.[0]??Av(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([by(a,i),n.Dn(`submission`,a).catch(()=>[])]).then(([t,n])=>{if(e)return;let r=yM(n);f(Av(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?bM(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 Ce(d,{submissionId:a,billRate:e.proposedRate,payRate:e.employerRate,currency:e.currencyRaw??e.currency,rateUnit:e.rateUnit,vmsPercent:e.clientVmsPercent}),await xe(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)(ly,{type:cv,record:o.record,lookups:o.lookups,identity:vM(i,o.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:h,onClose:()=>r?.(),variant:`popup`})}xM.propTypes={selectedIds:p.default.array,selectedRecords:p.default.array,onClose:p.default.func};var SM={title:`Re-Approve`,width:780,className:`fa-modal manager-approve-modal`,component:xM},CM={submit:async()=>{}},wM=[{id:1,name:`Re-Submission`},{id:2,name:`Candidate doesn't fit into the profile`},{id:3,name:`Incomplete candidate details - (Re-Submission)`}],TM={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:wM.map(e=>({label:e.name,value:e.id}))},{name:`rejectReasonComments`,label:`Comments`,type:`textarea`,required:!0,rows:4}]},EM={submit:async(e,t)=>{let n=wM.find(t=>String(t.id)===String(e.rejectReason));await we({submissionId:t.selectedIds[0],rejectReasonId:e.rejectReason,rejectReason:n?.name??``,rejectReasonComments:e.rejectReasonComments})}},DM={delete:TA,"quick-submit":ej,"add-notes":tj,"tag-to-job":sj,"change-status":bj,"remove-from-shortlist":Cj,"add-to-groups":Tj,"self-assign":kj,"others-assign":Mj,"sticky-notes":Pj,"move-to-onboarding":Ij,"approve-rate":Hj,"manager-approve":pM,"manager-reapprove":SM,reject:TM},OM={delete:EA,"quick-submit":$A,"add-notes":ij,"tag-to-job":yj,"change-status":Sj,"remove-from-shortlist":wj,"add-to-groups":Ej,"self-assign":Aj,"others-assign":Nj,"sticky-notes":Fj,"move-to-onboarding":Lj,"approve-rate":Uj,"manager-approve":mM,"manager-reapprove":CM,reject:EM};function kM(e){let t=e?.data??e;return Array.isArray(t)?t:t?.data??t?.rows??t?.records??t?.items??t?.list??[]}function AM(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 jM(e){let t=String(AM(e,`isDeleted`,`deleted`)).toLowerCase(),n=String(AM(e,`assignmentStatus`,`status`)).toLowerCase();return t!==`true`&&t!==`1`&&![`removed`,`inactive`,`deleted`].includes(n)}function MM(e){let t=AM(e,`candidateName`,`candidate_name`,`fullName`,`name`);return t?String(t):[AM(e,`firstName`,`first_name`),AM(e,`lastName`,`last_name`)].filter(Boolean).join(` `)||`Unnamed candidate`}function NM(e){return String(AM(e,`candidateId`,`candidate_id`,`candidate._id`,`candidate.id`))}function PM(e){return String(AM(e,`workforceEngagementId`,`engagementId`,`_id`,`id`))}function FM(e){return String(AM(e,`batchName`,`name`,`title`,`batch_name`))}function IM({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.Ln(`onboarding`,200,0),n.Ln(`batchCandidates`,1e3,0).catch(()=>[])]))).then(([e,n])=>{t||(o(kM(e)),x(new Map(kM(n).filter(jM).map(e=>[String(AM(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=>[MM(t),AM(t,`email`,`candidateEmail`,`candidate_email`),AM(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(PM(e)));if(!e.length)return;let o=e.map(e=>({record:e,assignment:b.get(NM(e))})).filter(e=>e.assignment);if(o.length){let e=o.map(({record:e})=>MM(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=FM(r.selectedRecords?.[0])||FM(r);await Promise.all(e.map(e=>n.vr(`batchCandidates`,{schemaVersion:1,batchId:S,batchName:o,candidateId:NM(e),workforceEngagementId:PM(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=>PM(e),columns:[{title:`Candidate`,key:`candidate`,render:(e,t)=>MM(t)},{title:`Email`,key:`email`,render:(e,t)=>AM(t,`email`,`candidateEmail`,`candidate_email`)||`—`},{title:`Onboarding status`,key:`status`,render:(e,t)=>AM(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(NM(e));return{disabled:!NM(e)||!PM(e)||!!t,title:t?`Candidate is already added to a batch`:void 0}}},locale:{emptyText:m?`Loading candidates…`:`No onboarding candidates found`}})]})}var LM={text:`input`,string:`input`,textarea:`textarea`,date:`date-picker`,datepicker:`date-picker`,multiselect:`multi-select`,lookup:`search-select`};function RM(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:LM[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=zM(e.successNavigate);return{title:e.label,fields:t,...n?{successNavigate:n}:{}}}function zM(e){let t=String(e??``).trim();return!t||!t.startsWith(`/`)||t.startsWith(`//`)||/^[a-z][a-z0-9+.-]*:/i.test(t)?null:t}function BM(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 VM({apiMap:e={},extraConfigs:r={}}){let i=(0,s.useMemo)(()=>({...OM,...e}),[e]),a=(0,s.useMemo)(()=>{let e={...DM};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.Wr(l.moduleName,`popup`,o).then(n=>{e||p({key:t,config:RM(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 BM(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)(IM,{open:!0,context:h,onClose:_}):(0,u.jsx)(wA,{open:!0,config:m,context:h,onClose:_,api:{...i[o]??{},...g}})}var HM={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`}]},UM={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})=>wn({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})},WM=HM.vendorColumns.map(e=>({...e,render:e=>e||`-`}));function GM(){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)(HM.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)(HM.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 UM.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&&UM.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([...lO(h.bcc),...z])].join(`, `),showBcc:h.showBcc||z.length>0}),[h,z]);function V(e){let t=new Set(z);g({...e,bcc:lO(e.bcc).filter(e=>!t.has(e)).join(`, `)})}let H=(lO(B.to).length||lO(B.bcc).length)&&dO(B.to)&&dO(B.cc)&&dO(B.bcc)&&B.subject.trim(),ee=e=>e===`myVendor`?T:D;function te(){e(-1)}function ne(){H&&UM.submit({jobId:m,toMail:lO(B.to),ccMail:lO(B.cc),bccMail:lO(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:HM.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:WM,dataSource:re,loading:F,pagination:!1,size:`small`,rowSelection:{selectedRowKeys:L,onChange:e=>{e.length>HM.maxVendorSelect||R(e)}},scroll:{y:`calc(100vh - 340px)`}})}),(0,u.jsx)(`div`,{className:`vendor-share__vendor-footer`,children:(0,u.jsx)(Ve,{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)(TO,{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,` / `,HM.maxVendorSelect,` Vendors selected`]}):null})})]})})}var KM={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].*$/},qM={SINGLE_FILE_COUNT:1,MULTI_FILE_COUNT:5,MAX_FILE_SIZE:2,ALLOWED_FILE_TYPES:[`image/jpeg`,`image/png`,`application/pdf`]},JM={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 ${qM.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.`},YM={FIRST_NAME_MIN:3,FIRST_NAME_MAX:30},XM={REMARKS_MIN:10,REMARKS_MAX:250},ZM={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)}`}},QM={required:(e=`Field`)=>({required:!0,message:JM.REQUIRED(e)}),email:()=>({pattern:KM.EMAIL,message:JM.INVALID_EMAIL}),phone:()=>({pattern:KM.PHONE,message:JM.INVALID_PHONE}),password:()=>({pattern:KM.PASSWORD,message:JM.INVALID_PASSWORD}),alphabets:()=>({pattern:KM.ALPHABETS,message:JM.INVALID_ALPHABETS}),alphanumeric:()=>({pattern:KM.ALPHANUMERIC,message:JM.INVALID_ALPHANUMERIC}),number:()=>({pattern:KM.NUMBER,message:JM.INVALID_NUMBER}),url:()=>({pattern:KM.URL,message:JM.INVALID_URL}),candidateId:(e=`ID`)=>({pattern:KM.CANDIDATE_ID,message:JM.INVALID_CANDIDATE_ID(e)}),remarks:()=>({pattern:KM.REMARKS,message:JM.INVALID_REMARKS,REMARKS_MIN:`Remarks must be at least ${XM.REMARKS_MIN} characters.`,REMARKS_MAX:`Remarks must not exceed ${XM.REMARKS_MAX} characters.`}),designation:()=>({pattern:KM.DESIGNATION,message:JM.INVALID_DESIGNATION}),dob:(e=!0)=>({validator:(t,n)=>{if(!n)return e?Promise.reject(Error(`Date of Birth is required.`)):Promise.resolve();if(!KM.DOB.test(n))return Promise.reject(Error(JM.INVALID_DOB));let r=(0,d.default)(n,`MM/DD/YYYY`,!0);if(!r.isValid())return Promise.reject(Error(JM.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:KM.LINKEDIN,message:JM.INVALID_LINKEDIN}),companyName:()=>({pattern:KM.COMPANY_NAME,message:JM.INVALID_COMPANY_NAME}),firstName:()=>({pattern:KM.FIRST_NAME,message:JM.INVALID_FIRST_NAME,FIRST_NAME_MIN:`First Name must be at least ${YM.FIRST_NAME_MIN} characters.`,FIRST_NAME_MAX:`First Name must not exceed ${YM.FIRST_NAME_MAX} characters.`}),firstNameMinLength:()=>({min:YM.FIRST_NAME_MIN,message:JM.FIRST_NAME_MIN}),firstNameMaxLength:()=>({max:YM.FIRST_NAME_MAX,message:JM.FIRST_NAME_MAX}),remarksMinLength:()=>({min:XM.REMARKS_MIN,message:JM.REMARKS_MIN}),remarksMaxLength:()=>({max:XM.REMARKS_MAX,message:JM.REMARKS_MAX}),fullName:()=>({pattern:KM.FULL_NAME,message:JM.INVALID_FULL_NAME}),noSpaces:()=>({pattern:KM.NO_SPACES,message:JM.NO_SPACES_ALLOWED}),startsWithCapital:()=>({pattern:KM.STARTS_WITH_CAPITAL,message:JM.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<=qM.MAX_FILE_SIZE))return c.message.error(JM.INVALID_FILE_SIZE),Promise.reject(Error(JM.INVALID_FILE_SIZE));if(!qM.ALLOWED_FILE_TYPES.includes(t.type))return Promise.reject(Error(JM.INVALID_FILE_TYPE))}return Promise.resolve()}}),singleFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>qM.SINGLE_FILE_COUNT)return Promise.reject(Error(JM.SINGLE_FILE_ONLY));let n=t[0];return n.size/1024/1024<qM.MAX_FILE_SIZE?qM.ALLOWED_FILE_TYPES.includes(n.type)?Promise.resolve():Promise.reject(Error(JM.INVALID_FILE_TYPE)):Promise.reject(Error(JM.INVALID_FILE_SIZE))}}),multiFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>qM.MULTI_FILE_COUNT)return Promise.reject(Error(JM.INVALID_FILE_COUNT));for(let e of t){if(!(e.size/1024/1024<qM.MAX_FILE_SIZE))return Promise.reject(Error(JM.INVALID_FILE_SIZE));if(!qM.ALLOWED_FILE_TYPES.includes(e.type))return Promise.reject(Error(JM.INVALID_FILE_TYPE))}return Promise.resolve()}})},$M={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)},eN=()=>{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:[QM.required(`Email`),QM.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:[QM.required(`Phone Number`),QM.phone()],validateTrigger:[`onBlur`,`onChange`],children:(0,u.jsx)(c.Input,{maxLength:10,onChange:t=>{e.setFieldsValue({phone:ZM.phoneFormatter(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Password`,name:`password`,rules:[QM.required(`Password`),QM.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:[QM.required(`Full Name`),QM.alphabets(),QM.firstNameMinLength(),QM.firstNameMaxLength()],children:(0,u.jsx)(c.Input,{onChange:t=>{e.setFieldsValue({fullName:ZM.firstNameFormatter(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Username`,name:`username`,rules:[QM.required(`Username`),QM.alphanumeric()],children:(0,u.jsx)(c.Input,{onChange:t=>{e.setFieldsValue({username:ZM.removeExtraSpaces(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Website URL`,name:`website`,rules:[QM.required(`Website URL`),QM.url()],children:(0,u.jsx)(c.Input,{onChange:t=>{e.setFieldsValue({website:ZM.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:[QM.required(`MSP Req ID`),QM.candidateId(`MSP Req ID`)],children:(0,u.jsx)(c.Input,{onChange:t=>{e.setFieldsValue({mspreqID:ZM.removeExtraSpaces(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Candidate ID`,name:`candidateId`,rules:[QM.required(`Candidate ID`),QM.candidateId(`Candidate ID`)],children:(0,u.jsx)(c.Input,{onChange:t=>{e.setFieldsValue({candidateId:ZM.removeExtraSpaces(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:24,children:(0,u.jsx)(c.Form.Item,{label:`Remarks`,name:`remarks`,rules:[QM.required(`Remarks`),QM.remarks(),QM.remarksMinLength(),QM.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:[QM.required(`Designation`),QM.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:[QM.dob()],children:(0,u.jsx)(c.Input,{placeholder:`MM/DD/YYYY`,maxLength:10,onChange:t=>{e.setFieldsValue({dob:ZM.dobFormatter(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Company Name`,name:`companyName`,rules:[QM.required(`Company Name`),QM.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:$M.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:[QM.multiFileUpload()],children:(0,u.jsx)(c.Upload,{multiple:!0,beforeUpload:$M.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:[QM.fileUpload()],children:(0,u.jsx)(c.Upload,{beforeUpload:$M.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 tN({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`]})]})}tN.propTypes={region:p.default.shape({key:p.default.string,label:p.default.string,isHome:p.default.bool}),onExit:p.default.func},tN.defaultProps={region:null,onExit:void 0};function nN(e){return(0,u.jsx)(Hb,{children:(0,u.jsx)(rO,{...e})})}var{Text:rN}=c.Typography,iN=[{label:`Total Jobs`,value:1697,icon:`fileText`},{label:`Active Jobs`,value:1685,icon:`checkCircle`},{label:`My Jobs`,value:600,icon:`user`}],aN={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 oN({stats:e=iN}){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:[aN[e.icon]??aN.fileText,(0,u.jsx)(rN,{children:e.label})]}),(0,u.jsx)(c.Statistic,{value:e.value})]})},e.label))})})}var{Text:sN}=c.Typography;function cN(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 lN(e){return{...e,key:e.USER_ID??e.user_id??e.userId??e.id??e._id,_name:cN(e),_email:e.email??e.EMAIL??e.user_email??``,_role:e.role_name??e.roleName??e.ROLE_NAME??``,_rawRef:e}}function uN(){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.Lr({offset:e,limit:r,searchQuery:a??``}),s=(o.users??[]).map(lN);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)(ch,{listName:`Users`,dataSource:e,fields:[{label:`Name`,value:`_name`,width:220,render:(e,t)=>(0,u.jsxs)(`div`,{children:[(0,u.jsx)(sN,{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:dN}=c.Typography,fN=[{key:`job`,label:`Jobs`},{key:`candidate`,label:`Candidates`},{key:`submissions`,label:`Submissions`}],pN=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`}];function mN({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 hN({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.fi(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.Bi(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:fN.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)(mN,{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 `,fN.find(e=>e.key===f)?.label]})})]})}function gN(){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.Ir();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.zi(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)(ch,{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:pN.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)(hN,{team:e,configType:d},`${e?.teamId}-${d}`)]})]})}var _N=[`view`,`add`,`edit`,`delete`],vN={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 yN(e){return vN[e]??e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function bN(e){let t=_N.filter(t=>e.includes(t)),n=e.filter(e=>!_N.includes(e)).sort();return[...t,...n]}function xN(e){let t=new Set;return Object.values(e).forEach(({permissions:e})=>Object.keys(e??{}).forEach(e=>t.add(e))),bN([...t])}function SN(e){let t=0,n=0;return Object.entries(e).forEach(([e,{permissions:r}])=>{Object.entries(r??{}).forEach(([r,{value:i}])=>{eS(e,r)&&(n++,i===`1`&&t++)})}),{enabled:t,total:n}}function CN(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 wN({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 TN({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 EN({menuName:e,menuData:t,permKeys:n,onChange:r,displayName:i,actionLabels:a,onModuleLabelSave:o,onActionLabelSave:s}){let c=t?.permissions??{},l=n.filter(t=>eS(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)(wN,{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)(TN,{entry:c[t],label:a[t]??yN(t),onToggle:()=>r(e,t),onLabelSave:e=>s(t,e)},t))})]})}function DN({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.si(e);(0,s.useEffect)(()=>{b&&(h(!0),y(!1),n.ui(b).then(e=>{let t=CN(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.Li(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)(()=>xN(f),[f]),{enabled:T,total:E}=(0,s.useMemo)(()=>SN(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)(EN,{menuName:e,menuData:f[e],permKeys:w,onChange:x,displayName:t[e]??e,actionLabels:r,onModuleLabelSave:i,onActionLabelSave:a},e))})]})}var{Text:ON}=c.Typography,kN=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`}];function AN(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function jN(e){return String(e||``).trim().toLowerCase()}function MN(e){return e?.key||e?.collectionName||e?.value||``}function NN(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=MN(e);if(!t)return;let o=jN(e.key||t),s=jN(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||AN(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=jN(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:AN(t),value:t,disabled:!1}))}),n}function PN(){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.Fr();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.qr(),n.zr()]),r=NN(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.Di(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)(ON,{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)(ch,{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:kN.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)(DN,{role:e},e?.roleId):(0,u.jsx)(_S,{role:e,configType:a},`${e?.roleId}-${a}`))]})]})}var FN=`perm-module-labels`,IN=`perm-action-labels`;function LN(e){try{return JSON.parse(localStorage.getItem(e)??`{}`)}catch{return{}}}function RN(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function zN({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 BN({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.ei())}catch{c.message.error(`Failed to load modules`)}finally{f(!1)}}async function O(){b(!0);try{v(await n.$r())}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.gr({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.Ni(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.Tr(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.hr({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.Mi(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.wr(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)(zN,{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)(zN,{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 VN(){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)(()=>LN(FN)),[_,v]=(0,s.useState)(()=>LN(IN)),y=(0,s.useCallback)((e,t)=>{g(n=>{let r={...n,[e]:t};return RN(FN,r),r})},[]),b=(0,s.useCallback)((e,t)=>{v(n=>{let r={...n,[e]:t};return RN(IN,r),r})},[]);function x(){g({}),v({}),RN(FN,{}),RN(IN,{}),c.message.success(`Labels reset to defaults`)}let S=(0,s.useCallback)(async()=>{i(!0);try{let{roles:e}=await n.Fr();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)(DN,{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)(BN,{open:p,onClose:()=>m(!1)})]})}var{Title:HN,Text:UN}=c.Typography,WN=[{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 GN({items:e=WN}){return(0,u.jsx)(c.Card,{className:`onboarding-card`,title:(0,u.jsx)(HN,{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)(UN,{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)(UN,{className:`onboarding-item-sub`,children:e.sub})})]})},e.label))})})}var{Text:KN,Title:qN}=c.Typography,JN=[{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.`}]}]}],YN=[{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}],XN=[{name:`Tcs`,jobs:14,candidates:86},{name:`Empasis`,jobs:9,candidates:64},{name:`NovaSystems`,jobs:7,candidates:51},{name:`Brightwave`,jobs:5,candidates:38}],ZN=[{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 QN(){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)(qN,{level:5,children:`Admin Dashboard`}),(0,u.jsx)(KN,{type:`secondary`,children:`Overview of jobs, candidates, onboarding and recent activity`})]}),(0,u.jsx)(`div`,{className:`admin-dashboard-stats`,children:(0,u.jsx)(oN,{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)(GN,{}),(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.AppstoreOutlined,{}),title:`Candidate Pipeline`,children:[(0,u.jsx)(KN,{type:`secondary`,style:{fontSize:12},children:`By stage (892 total)`}),(0,u.jsx)(`div`,{className:`admin-pipeline-bar`,children:YN.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:YN.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)(KN,{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)(KN,{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)(KN,{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)(KN,{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:XN.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:ZN.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)(KN,{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)(KN,{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)(KN,{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)(KN,{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)(KN,{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)(KN,{style:{fontSize:12},children:e}),(0,u.jsx)(KN,{strong:!0,style:{fontSize:12},children:t})]},e))]})]})})]})}function $N({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)(qN,{level:5,children:e?.heading}),(0,u.jsx)(KN,{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)(KN,{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:JN.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 eP(){let[e,t]=(0,s.useState)(`dashboard`),[n,r]=(0,s.useState)(``),i=(0,s.useMemo)(()=>JN.flatMap(e=>e.items),[]),a=(0,s.useMemo)(()=>i.find(t=>t.id===e),[i,e]),o=(0,s.useMemo)(()=>JN.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)(()=>JN.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:JN.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)(QN,{}):a?.component===`form-groups`?(0,u.jsx)(hw,{}):a?.component===`detail-groups`?(0,u.jsx)(Yw,{}):a?.component===`row-actions`?(0,u.jsx)(zT,{}):a?.component===`users`?(0,u.jsx)(uN,{}):a?.component===`teams`?(0,u.jsx)(gN,{}):a?.component===`roles`?(0,u.jsx)(PN,{}):a?.component===`permissions`?(0,u.jsx)(VN,{}):a?.component===`templates`?(0,u.jsx)(ZT,{}):a?.component===`ai-services`?(0,u.jsx)(iE,{}):a?.component===`bgc-integration`?(0,u.jsx)(uE,{}):(0,u.jsx)($N,{activeSection:a,activeGroup:o,filteredCards:d,searchText:n,setSearchText:r,allItems:i,handleNav:p})})]})]})}var{Title:tP}=c.Typography;function nP(){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:rP,Title:iP}=c.Typography,aP=10485760,oP=`/templates/test_cases_flow_template.base64.txt`,sP=`test_cases_flow_template.xlsx`,cP=`module | subModule | step_order | description | actions | key | value | expected | scenario`,lP={idle:0,module_set:1,encoding:1,validating:2,preview:3,inserting:3,done:4,error:1},uP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Bulk upload`,href:`/bulk-upload`}];function dP(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 fP(e){return e.filter(e=>e.row_status===`valid`).map(e=>{let t={...e};return delete t.row_status,delete t.errors,t})}function pP(e){return e.flatMap(e=>(e.errors??[]).map(t=>({id:e.id,...t})))}function mP({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 hP({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 gP({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)(rP,{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)(mP,{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 _P(){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=pP(x),N=h===`encoding`||h===`validating`,P=!!p&&!N,F=lP[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 ax({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>aP){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 dP(e);g(`validating`);let i=await ex({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(oP);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=sP,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:fP(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:uP})}),r?.name&&(0,u.jsx)(c.Col,{children:(0,u.jsx)(rP,{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)(iP,{level:3,children:`Bulk upload test cases`}),(0,u.jsxs)(c.Space,{direction:`vertical`,size:4,children:[(0,u.jsx)(rP,{type:`secondary`,children:cP}),(0,u.jsx)(rP,{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)(hP,{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)(gP,{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)(rP,{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)(rP,{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)(rP,{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 vP=[{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:yP}=c.Typography,bP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}],xP={tags:`regression`,active:1},SP={module:{dbName:`Modules`,formField:`module`,label:`Module`}};function CP(e=[]){return e.map(e=>({value:e,label:e}))}function wP(e=``){return String(e??``).trim()}function TP(e=``){return wP(e).toLowerCase()}function EP(e=[]){let t=new Map;return e.forEach(e=>{let n=wP(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function DP(e=[],t,n){let r=wP(t).toLowerCase(),i=wP(n).toLowerCase();return e.reduce((e,t)=>{let n=wP(t?.module).toLowerCase(),a=wP(t?.flow).toLowerCase();if(n!==r||a!==i)return e;let o=Number(t?.step_order)||0;return Math.max(e,o)},0)+1}function OP({icon:e,title:t}){return(0,u.jsxs)(c.Space,{size:10,align:`center`,children:[(0,u.jsx)(`div`,{className:`v1-section-icon-box`,children:e}),(0,u.jsx)(yP,{strong:!0,className:`v1-section-label`,children:t})]})}function kP(){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=SP[v.typeKey],O=(0,s.useMemo)(()=>CP(r),[r]),k=c.Form.useWatch(`module`,e),A=c.Form.useWatch(`flow`,e),j=!!wP(k),M=!!wP(A),N=!j,P=!j||!M,F=(e,t=[])=>{e===`module`&&i(t)},I=async()=>{h(!0);try{let e=await Yb(SP.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=wP(t);if(o([]),p([]),e.setFieldsValue({step_order:void 0}),n){_(!0);try{let e=await $b({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];o(t),p(EP(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=wP(t),a=wP(n);if(!i||!a){e.setFieldsValue({step_order:void 0});return}C(!0);try{e.setFieldsValue({step_order:DP(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:wP(t.module),flow:wP(t.flow),step_order:Number(t.step_order),description:wP(t.description),keyword:TP(t.keyword),target:wP(t.target),value:wP(t.value),expected:wP(t.expected),tags:t.tags?wP(t.tags):xP.tags,active:Number(t.active)};T(!0);try{await Qb(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]:wP(n)})},V=t=>{e.setFieldsValue({module:wP(t),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:xP.tags,value:void 0,expected:void 0})},H=t=>{e.setFieldsValue({flow:wP(t),step_order:void 0})},ee=e=>{let n=SP[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=wP((await t.validateFields()).name),r=await Xb({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:bP})}),(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)(yP,{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:xP,onFinish:z,autoComplete:`off`,children:[(0,u.jsx)(c.Card,{className:`v1-card`,title:(0,u.jsx)(OP,{icon:(0,u.jsx)(l.FileTextOutlined,{}),title:`Test Case Details`}),extra:(0,u.jsx)(yP,{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:vP,onChange:t=>e.setFieldsValue({keyword:TP(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:wP(e.target.value)})}})}),(0,u.jsx)(c.Form.Item,{label:`Type`,name:`type`,children:(0,u.jsx)(c.Input,{disabled:!0})})]})})]})})]})}var{Text:AP}=c.Typography,jP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`}];function MP(e=``){return String(e??``).trim()}function NP(e=[],t){return e.map(e=>({value:e.id,label:e[t]}))}var PP=[{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`})}],FP={key:!1,value:!1,expected:!1};function IP(e,t){return t?e[t]??FP:FP}function LP(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function RP(){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)(vP),[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)(()=>IP(x,F),[x,F]),z=(0,s.useMemo)(()=>NP(p,`modulename`),[p]),B=(0,s.useMemo)(()=>NP(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 Zb();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 ax({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 cx({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([dx({product_parent_ID:t,module_parent_ID:n,submodule_parent_ID:r,actions:i,limit:1e3}),mx({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]),U=(0,s.useCallback)(async(e=``)=>{if(!(!d?.id||!N||!P)){O(!0);try{let t=await dx({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]),ie=(0,s.useCallback)(async()=>{if(!(!a||!d?.name)){M(!0);try{let t=await px(a);await ne(d.name,t.module);let n=await dx({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 ie()})},[d,r,ee,te,a,ie]),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:jP})}),(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)(AP,{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:MP(t.description),actions:MP(t.actions),key:MP(t.key),value:MP(t.value),expected:MP(t.expected),scenario:+!!t.scenario,active:+!!t.active};A(!0);try{if(o){await hx(a,{...n,step_order:Number(t.step_order)}),c.message.success(`Test case updated successfully.`),r(`/viewTestCase`);return}await fx(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}),LP(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}),LP(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)(AP,{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=IP(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}),LP(e,[`key`,`value`,`expected`]),U(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)(ch,{listName:`Added Steps`,loading:D,fields:PP,dataSource:_,current:1,pageSize:Math.max(_.length,1),total:_.length,rowSelection:!1,className:`zt-list-plain zt-list-static`})})]})})]}):null}var{Text:zP}=c.Typography,BP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`}];function VP(){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([ax({project:e}),cx({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 sx(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 ox({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:BP})}),(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)(zP,{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)(ch,{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)(zP,{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:HP}=c.Typography,UP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`},{label:`Manage Submodules`,href:`/test-cases/zinnext/submodules`}];function WP(){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 cx({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 ux(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 lx({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:UP})}),(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)(HP,{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)(HP,{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)(ch,{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)(HP,{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:GP}=c.Typography,KP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Table`,href:`/viewTestCase`}];function qP(){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 dx({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 gx(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:KP})}),(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)(GP,{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)(ch,{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 JP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}];function YP(){return(0,u.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,u.jsx)(n.s,{items:JP}),(0,u.jsx)(Xo,{moduleName:`test-flows`,rowKey:`id`})]})}var{Text:XP}=c.Typography,ZP=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}],QP={tags:`regression`,active:1},$P={module:{dbName:`Modules`,formField:`module`,label:`Module`}},eF={key:!1,value:!1,expected:!1};function tF(e,t){return t?e[t]??eF:eF}function nF(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function rF(e=[]){return e.map(e=>({value:e,label:e}))}function iF(e=``){return String(e??``).trim()}function aF(e=[]){let t=new Map;return e.forEach(e=>{let n=iF(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function oF(e=[],t,n){let r=iF(t).toLowerCase(),i=iF(n).toLowerCase();return e.reduce((e,t)=>{let n=iF(t?.module).toLowerCase(),a=iF(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 sF({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)(XP,{strong:!0,className:`v1-section-label`,children:t})]})}function cF(){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)(vP),[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=$P[S.typeKey],M=(0,s.useMemo)(()=>rF(r),[r]),N=c.Form.useWatch(`module`,e),P=c.Form.useWatch(`flow`,e),F=c.Form.useWatch(`keyword`,e),I=!!iF(N),L=!!iF(P),R=!I,z=!I||!L,B=(0,s.useMemo)(()=>tF(g,F),[g,F]),V=(e,t=[])=>{e===`module`&&i(t)},H=async()=>{y(!0);try{let e=await Yb($P.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 Zb();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=iF(t);if(o([]),p([]),e.setFieldsValue({step_order:void 0}),n){x(!0);try{let e=await rx({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];o(t),p(aF(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=iF(t),a=iF(n);if(!i||!a){e.setFieldsValue({step_order:void 0});return}D(!0);try{e.setFieldsValue({step_order:oF(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:iF(t.module),flow:iF(t.flow),step_order:Number(t.step_order),description:iF(t.description),keyword:iF(t.keyword),target:iF(t.target),value:iF(t.value),expected:iF(t.expected),tags:t.tags?iF(t.tags):QP.tags,active:Number(t.active)};k(!0);try{await nx(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)}},U=(t,n)=>{e.setFieldsValue({[t]:iF(n)})},ie=t=>{e.setFieldsValue({module:iF(t),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:QP.tags,value:void 0,expected:void 0}),nF(e,[`keyword`,`target`,`value`,`expected`])},ae=t=>{e.setFieldsValue({flow:iF(t),step_order:void 0,keyword:void 0,target:void 0,value:void 0,expected:void 0}),nF(e,[`keyword`,`target`,`value`,`expected`])},oe=t=>{let n=tF(g,t);e.setFieldsValue({keyword:iF(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}),nF(e,[`target`,`value`,`expected`])},se=e=>{let n=$P[e];C({open:!0,typeKey:e}),t.setFieldsValue({name:``,type:n.label})},W=()=>{C(e=>({...e,open:!1})),t.resetFields()},ce=async()=>{try{let n=iF((await t.validateFields()).name),r=await Xb({name:n,type:j.dbName});V(S.typeKey,r?.items??[]),e.setFieldsValue({[j.formField]:n}),c.message.success(`${j.label} added successfully.`),W()}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:ZP})}),(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)(XP,{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:QP,onFinish:re,autoComplete:`off`,children:[(0,u.jsx)(c.Card,{className:`v1-card`,title:(0,u.jsx)(sF,{icon:(0,u.jsx)(l.FileTextOutlined,{}),title:`LMS Case Details`}),extra:(0,u.jsx)(XP,{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:ie})}),(0,u.jsx)(c.Button,{"aria-label":`Add module`,icon:(0,u.jsx)(l.PlusOutlined,{}),style:{marginTop:30},onClick:()=>se(`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:ae,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:oe})})}),(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=>U(`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=>U(`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=>U(`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=>U(`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=>U(`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:W,onOk:()=>{T(!0),ce()},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:iF(e.target.value)})}})}),(0,u.jsx)(c.Form.Item,{label:`Type`,name:`type`,children:(0,u.jsx)(c.Input,{disabled:!0})})]})})]})})]})}var lF=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}];function uF(){return(0,u.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,u.jsx)(n.s,{items:lF}),(0,u.jsx)(Xo,{moduleName:`lms-flows`,rowKey:`id`})]})}var dF=[`referenceId`,`ReferenceId`,`candidateId`,`CandidateId`,`entityId`,`EntityId`,`id`,`Id`,`_id`];function fF(e=dF){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 pF(e,t=dF){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 mF=fF();function hF(e){return typeof e==`function`?e:typeof e==`string`?fF([e]):Array.isArray(e)?fF(e):mF}function gF(e,t,n){return!t||typeof t!=`object`?e:{...t,...e,id:e?.id??t?.id??n}}function _F(e,t,n={}){return{status:`success`,total:t,data:{data:e,...n}}}var vF=[`fields`,`fieldConfig`,`tabs`,`tabField`,`actionRules`,`actions`,`columnActions`];function yF(e){let t=e?.data??e,n={};for(let r of vF){let i=e?.[r]??t?.[r];i==null||Array.isArray(i)&&i.length===0||(n[r]=i)}return n}var bF=e=>String(e??``).replace(/[^a-zA-Z0-9]/g,``).toLowerCase();function xF(e,t,n){let r=(Array.isArray(n)?n:[n]).map(bF).filter(Boolean),i=r.length?e.findIndex(e=>r.includes(bF(e?.value))||r.includes(bF(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 SF=(e,t)=>mi(e,t).rows,CF=(e,t)=>{let{rows:n,total:r}=mi(e,t);return{rows:n,total:r}};function wF(e,t){return function(n,r,i,a={}){return e(t??n,r,i,a)}}function TF(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:SF,mergeRow:typeof e.mergeRow==`function`?e.mergeRow:gF,fetchById:typeof e.fetchById==`function`?e.fetchById:null}}function EF({fetchSecondaryByKeys:e,fetchSecondary:t,extractSecondaryRows:n,fetchSecondaryById:r,secondaryKey:i,mergeRow:a,secondaryFetchLimit:o}){return!e&&!t&&!r?[]:[TF({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 DF(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:dF;return e=>pF(e,t)}function OF(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 kF({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 AF(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 jF({fetchPrimaryPage:e,extractPrimaryPage:t=CF,fetchSecondaryByKeys:n,joinSources:r=[],fetchPrimary:i,extractPrimaryRows:a=SF,fetchSecondary:o,extractSecondaryRows:s=SF,fetchSecondaryById:c,primaryKey:l,secondaryKey:u,mergeRow:d=gF,secondaryFetchLimit:f=200,extraFields:p=[],extraFieldsAfter:m}){let h=Array.isArray(r)&&r.length?r.map(TF).filter(Boolean):EF({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=hF(t.primaryKey??l),s=DF(t.key),c=OF(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=yF(e);for(let e of Object.keys(t))r[e]??(r[e]=t[e])}return p.length&&(r.fields=xF(r.fields??[],p,m)),_F(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=hF(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 AF(c,kF({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 MF(e,t,n={}){return jF({fetchPrimary:()=>fj(e,t),extractPrimaryRows:uj,fetchSecondary:Bn,fetchSecondaryById:pj,secondaryFetchLimit:n.moduleFetchLimit??200})}function NF(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 PF(e){let t=Array.isArray(e?.stages)?e.stages:[];if(!t.length)return e;let n={};for(let e of t){let t=NF(e?.stageName);t&&(n[t]=Number(e?.count)||0)}return{...n,...e}}var FF=e=>{let t=Number(e?.targetSubmission??e?.targetSubmissions);return Number.isFinite(t)&&t>0?t:null};function IF({submittedCountField:e=`submittedCount`,progressField:t=`targetSubmissionProgress`}={}){return function(n,r,i){let a=gF(n,r,i),o=FF(a);return o!=null&&(a[t]=`${Number(a?.[e])||0} of ${o}`),a}}function LF(e={}){let t=IF();return jF({primaryKey:`_id`,extraFields:e.extraFields,extraFieldsAfter:e.extraFieldsAfter,fetchPrimaryPage:Bn,joinSources:[{key:`entityId`,fetchByKeys:(e,t,n,r)=>{let i=Math.max(1,Number(r?.limit)||10);return dj(Math.floor((Number(r?.offset)||0)/i)+1,i)},extractRows:e=>(e?.items??[]).map(PF),mergeRow:(e,n,r)=>{let i=t(e,n,r);return n?._id&&(i.workflowId=n._id),i}}]})}async function RF(e,t=10,n=0,r={},i={}){return mi(await LF(i)(e,t,n,r),e)}async function zF(e,t,n,r=10,i=0,a={}){return mi(await MF(e,t)(n,r,i,a),n)}typeof window<`u`&&(window.__CORE_THEME_BUILD__=`2026-09-10T17:25:20.866Z`);var BF=nN,VF=yx(eP),HF=yx(nP),UF=yx(_P),WF=yx(kP),GF=yx(RP),KF=yx(VP),qF=yx(WP),JF=yx(qP),YF=yx(YP),XF=yx(cF),ZF=yx(uF);exports.ADMIN_API_URL=t.v,exports.ADMIN_APP_ID=t.y,exports.APP_ID=t.b,exports.AUTH_URL=t.x,exports.ActivityNotesCard=Zc,exports.ActivityTab=Bc,exports.AddBatchCandidatePopup=IM,exports.AddFormV1=Cc,exports.AdminDashboard=nN,exports.AdminDashboardContent=rO,exports.AdminPage=BF,exports.AppAlert=wc,exports.AppButton=n.Ct,exports.AppShell=Hb,exports.ApprovalActionBar=Q_,exports.AssigneeAvatars=Qc,exports.AuthGuard=Pb,exports.BILLING_STATUS_FLOW=yf,exports.BOOLEAN_API_KEYS=Rg,exports.BOOLEAN_PARSEABLE_API_KEYS=Ch,exports.BULK_UPLOAD_DEFAULT_ACCEPT=$c,exports.BULK_UPLOAD_DEFAULT_MAX_SIZE_MB=el,exports.Breadcrumb=n.s,exports.BulkUploadPage=UF,exports.BulkUploadPanel=cl,exports.CANDIDATES_URL=t.S,exports.CONTRACT_C2C=Sv,exports.CONTRACT_W2=xv,exports.CORE_URL=t.C,exports.CURRENCY_SYMBOLS=bu,exports.CalendarCard=j,exports.CoreThemeAdminApp=sO,exports.CoreThemeAdminRoutes=oO,exports.CustomPagination=Ve,exports.DEFAULT_HOURS_POLICY=b_,exports.DEFAULT_RESULTS_VIEW=Pg,exports.DETAIL_VIEW_MODE_OPTIONS=n.or,exports.DETAIL_VIEW_MODE_VALUES=n.sr,exports.DETAIL_VIEW_POPUP_PATH=n.cr,exports.DayLogModal=W_,exports.DescriptionBlock=xl,exports.DetailHeaderCard=xp,exports.DetailViewPage=Op,exports.DetailViewPopup=uk,exports.DetailViewV1=_d,exports.DocumentViewer=r.t,exports.DynamicCards=Bt,exports.DynamicPopup=wA,exports.DynamicPopupRoute=VM,exports.DynamicTabs=F,exports.EditFormV1=Bm,exports.FIELD_TYPE_REGISTRY=ig,exports.FINANCE_APPROVAL_CONFIG=pv,exports.FINANCE_TYPE_CFO=ov,exports.FINANCE_TYPE_ONBOARDING_MANAGER=av,exports.FINANCE_TYPE_ONBOARDING_MANAGER_REAPPROVE=lv,exports.FINANCE_TYPE_ONLY_FINANCE=sv,exports.FINANCE_TYPE_SUBMISSION_MANAGER=iv,exports.FINANCE_TYPE_SUBMISSION_MANAGER_REAPPROVE=cv,exports.FileListCard=Ay,exports.FinanceApprovalPanel=ly,exports.FinanceAvatar=ep,exports.FinanceBadge=ip,exports.FinanceDayCell=ev,exports.FinanceDivider=Kf,exports.FinanceEmployeeCell=tp,exports.FinanceEmptyState=Uf,exports.FinanceEquation=qf,exports.FinanceHistoryTimeline=Zf,exports.FinanceHoursGrid=Hf,exports.FinanceKpiRow=Vf,exports.FinanceLine=Gf,exports.FinanceListToolbar=y_,exports.FinanceMarginBadge=ap,exports.FinanceMoneyCell=rp,exports.FinanceRecordsTable=cp,exports.FinanceRowChevron=op,exports.FinanceSection=Wf,exports.FinanceStatusPill=Bf,exports.FinanceTextCell=np,exports.FinanceTimesheetAnalysis=nv,exports.FinanceWorkflowSteps=Jf,exports.GATEWAY_URL=t.w,exports.GLOBAL_DEFAULT_FIELDS=xD,exports.HOURS_MESSAGES=x_,exports.Header=sb,exports.HierarchyUserFilter=Gt,exports.JOBS_URL=t.T,exports.LegacyAdminPage=VF,exports.ListView=Xo,exports.LmsHomePage=ZF,exports.LmsTestForm=XF,exports.Login=Ub,exports.MailPopup=ZO,exports.ManageModules=KF,exports.ManageSubmodules=qF,exports.ModuleRowActions=Ym,exports.NotesPanel=Z_,exports.NotesTab=Xc,exports.OPEN_AS_OPTIONS=Tg,exports.PAYROLL_STATUS_FLOW=bf,exports.PLATFORM_SCOPES=vD,exports.POPUP_CONFIGS=DM,exports.PYOPS_URL=t.E,exports.ParamCardView=nh,exports.ParamListView=ch,exports.PeriodBadgeTag=N_,exports.PlatformSection=jD,exports.PreviewPopup=ck,exports.ProjectSelect=vx,exports.ProofUploadPreview=X_,exports.QuickLogBar=q_,exports.QuickLogSelectionBar=G_,exports.RESULTS_VIEW_OPTIONS=Ng,exports.RegionBanner=tN,exports.RejectionReasonModal=K_,exports.SUBMISSIONS_URL=t.D,exports.SearchBuilderV1=u_,exports.Sidebar=Ab,exports.StatusBadge=f_,exports.StatusBadgeTag=M_,exports.StickyNotesFullPage=HF,exports.StylishDynamicTabs=m_,exports.TemplateEditor=g_,exports.TestForm=WF,exports.TestingHomePage=YF,exports.TimelineGroups=Mc,exports.TimesheetDayCell=V_,exports.TipTapEditor=n.Vn,exports.UserForm=eN,exports.VendorShareDrawer=GM,exports.ViewSummaryWidget=Bi,exports.WizardPopup=gk,exports.ZINNEXT_URL=t.O,exports.ZinnextTableView=JF,exports.ZinnextTestForm=GF,exports.appNow=n.Gn,exports.applyIntegrationStatus=n.fr,exports.approveSubmission=xe,exports.buildAcceptAttr=al,exports.buildBooleanRequest=Ug,exports.buildCsv=Pf,exports.buildDailyRows=Of,exports.buildDayGradient=z_,exports.buildRateHistoryEntries=qv,exports.buildWeeklyRollup=jf,exports.clearSelectedProject=t.i,exports.colors=n.Wn,exports.computeFinance=zv,exports.computeHoursPolicy=D_,exports.computeMarginBand=Mf,exports.conditionMatches=n.f,exports.configureCoreTheme=t.k,exports.configuredFieldLabel=n.p,exports.createAllWorkflowsListFetcher=LF,exports.createMergedListFetcher=jF,exports.createModuleListFetchAdapter=wF,exports.createWorkflowStageListFetcher=MF,exports.currencySymbol=xu,exports.deactivateRegion=sD,exports.defaultMergeRow=gF,exports.deleteIntegrationConfig=n.Cr,exports.deriveDayStats=Df,exports.describeCapacity=k_,exports.downloadCsv=Rf,exports.evaluateShowIfWith=n.m,exports.findEmployerRow=Nv,exports.flattenGroups=jv,exports.formatAmount=Du,exports.formatApp=n.Kn,exports.formatAppDateTime=n.qn,exports.formatFileSize=il,exports.formatFinanceMoney=Jv,exports.formatHours=uf,exports.formatMoney=Ou,exports.formatPercent=ff,exports.formatRate=ku,exports.getActivity=n.Dn,exports.getAllWorkflowsModuleList=RF,exports.getAppTimeZone=n.Jn,exports.getApprovalDate=gf,exports.getBgcIntegrationConfig=n.Vr,exports.getBgcIntegrationSummary=n.Hr,exports.getBillingActionStates=xf,exports.getBooleanEligibleTypes=ug,exports.getCurrentRoleName=t.c,exports.getDetailDisplayDefaults=n.nr,exports.getFieldLabel=If,exports.getFieldType=og,exports.getFileExtension=rl,exports.getFinanceApprovalConfig=vv,exports.getFormGroupsRaw=yy,exports.getGlobalAiServices=SD,exports.getGlobalDefaults=yD,exports.getIntegrationConfig=n.Jr,exports.getIntegrationConfigs=n.Yr,exports.getIntegrationSummary=n.Xr,exports.getModuleConfig=Le,exports.getModuleDataDetail=n.kn,exports.getPayrollActionStates=Sf,exports.getPeriodBadgeConfig=ze,exports.getRegionDetailDefaults=mD,exports.getSearchPopup=Sg,exports.getSelectedProject=t.l,exports.getStoredToken=t.u,exports.getStoredUser=t.d,exports.getUserRoles=t.f,exports.getVMSApprove=Se,exports.getValueStyle=Lf,exports.getWorkflowStageModuleList=zF,exports.getWorkflowSteps=Cf,exports.grantPlatformAccess=lD,exports.hasPlatformAccess=dD,exports.humanizeEvent=hf,Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return xs}}),exports.indexFieldConfig=Ff,exports.initialsOf=pf,exports.insertTokenAtCursor=Dh,exports.isBooleanEligible=sg,exports.isBooleanParsable=Th,exports.isTester=t.p,exports.listPlatformAccess=cD,exports.listPlatformAudit=pD,exports.listPlatformUsers=fD,exports.listRegionRoles=_D,exports.listRegionUsers=gD,exports.listRegions=aD,exports.loadDetailDefaults=n.rr,exports.logout=t.h,exports.marginIncludesReferral=bv,exports.matchLocationTax=Rv,Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Xp}}),exports.normalizeContract=Fv,exports.normalizeDetailViewMode=n.lr,Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return ll}}),exports.rateUnitLabel=Cu,exports.rateUnitShort=Tu,exports.readActionButtons=kg,exports.reconcileHours=O_,exports.regionPath=iD,exports.registerFieldType=ag,exports.registerSearchPopup=xg,exports.rejectSubmission=we,exports.requiredWhenActive=n.c,exports.requiredWhenRule=n.l,exports.resolveActivityMeta=Lc,exports.resolveAndCompute=Bv,exports.resolveDayKind=T_,exports.resolveFinanceInputs=Lv,exports.resolveMergeKey=mF,exports.resolveMergedListKey=mF,exports.resolveOpenAs=Dg,exports.resolveRejectionReason=yv,exports.resolveResultsSearchPlaceholder=Lg,exports.resolveResultsView=Ig,exports.resolveSubmissionFinance=by,exports.revokePlatformAccess=uD,exports.runDetailViewOpen=n.ur,exports.saveBgcIntegrationConfig=n.yi,exports.saveGlobalAiServices=CD,exports.saveGlobalDefaults=bD,exports.saveIntegrationConfig=n.Si,exports.saveRegion=oD,exports.saveRegionDetailDefaults=hD,exports.setSelectedProject=t._,exports.showIfConditions=n.g,exports.stageCountKey=NF,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Wb}}),exports.testIntegrationConnection=n.ki,exports.toApp=n.Xn,exports.toNumber=Eu,exports.tzLabel=n.Zn,exports.tzShortLabel=n.Qn,exports.unregisterSearchPopup=Cg,exports.useDropdownFields=tr,exports.useDropdownValues=Vi,exports.useEditForm=Ny,exports.useFieldConfig=nr,exports.useFilterFields=rr,exports.useMenuPermission=fr,exports.useModuleActions=Hm,exports.useRecordRefresh=Tp,exports.useTabRows=My,exports.validateBooleanQuery=Eh,exports.validateBulkFile=ol,exports.withAdminAppId=t.A,exports.withAppId=t.j,exports.withAuthGuard=yx;
|
|
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 jE({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)(()=>kE(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)(TE,{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)(TE,{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)(TE,{type:`secondary`,style:{fontSize:12},children:`Event`}),(0,u.jsx)(c.Select,{size:`small`,style:{width:`100%`},value:a.event,options:EE.map(e=>({value:e})),onChange:e=>h(`event`,e)})]}),(0,u.jsxs)(`div`,{style:{width:90},children:[(0,u.jsx)(TE,{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)(TE,{style:{fontSize:13},children:`Active`})]}),(0,u.jsxs)(`div`,{style:{marginTop:12},children:[(0,u.jsxs)(TE,{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)(TE,{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)(AE,{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)(TE,{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 ME(){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.mi(`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.Br().then(e=>i(CS(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.Ti(`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.Or(`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.Ti(`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)(TE,{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)(TE,{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)(jE,{open:!!p,doc:p?.doc,moduleOptions:r,onClose:()=>m(null),onSave:b},p?p.doc?.key??`new`:`closed`)]})}var{Text:NE}=c.Typography,PE=e=>e?._id??e?.id,FE=`masters`;function IE(){return{tenantId:localStorage.getItem(`tenantId`)||``,businessId:localStorage.getItem(`businessId`)||``,businessUnitId:localStorage.getItem(`businessUnitId`)||``}}function LE(e){return e&&typeof e==`object`?e.$oid??e.oid??e.id??``:e??``}function RE(e,t){return t.map(t=>LE(e?.[t])).find(e=>e!=null&&e!==``)??``}function zE(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(RE(e,n));return!r||r===String(t)})}function BE(e){return Array.isArray(e?.masterFeeds)?e.masterFeeds:[]}function VE(e){return e.reduce((e,t)=>Math.max(e,Number(t?.uniqueId)||0),0)+1}function HE(e){return Array.isArray(e?.taxHistory)?e.taxHistory:[]}function UE(e){let t=e?.taxValue;if(t!=null&&t!==``)return Number(t);let n=HE(e).at(-1),r=n?.taxValue??n?.value;return r!=null&&r!==``?Number(r):void 0}function WE(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 GE(e){let t=HE(e).at(-1);return t?.updatedAt??t?.timestamp??e?.updatedAt}function KE({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:UE(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.Zr(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.Fi(`locations`,PE(t),o):await n.vr(`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 qE({record:e}){let t=[...HE(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)(NE,{type:`secondary`,style:{fontSize:12},children:WE(e.updatedAt??e.timestamp)}),t===0&&(0,u.jsx)(NE,{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 JE(){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.pi(`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.Dr(`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:PE,columns:[{title:`Location`,dataIndex:`name`,key:`name`},{title:`Tax`,key:`taxValue`,width:100,render:(e,t)=>{let n=UE(t);return Number.isFinite(n)?(0,u.jsxs)(c.Tag,{color:`blue`,children:[n,`%`]}):`—`}},{title:`Tax updated`,key:`taxUpdatedAt`,render:(e,t)=>WE(GE(t))},{title:`Created`,key:`createdAt`,responsive:[`lg`],render:(e,t)=>WE(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(PE(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)(qE,{record:e}),rowExpandable:e=>HE(e).length>0},locale:{emptyText:`No locations yet. Click "New location" to add one.`}})}),(0,u.jsx)(KE,{open:a,record:d,onClose:()=>o(!1),onSaved:()=>{o(!1),p()}})]})}function YE({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=BE(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=IE(),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.Fi(FE,PE(t),l):await n.vr(FE,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:VE(a.getFieldValue(`masterFeeds`)??[]),name:``,type:`neutral`,status:!0,isdeleted:!1,...h?{isInitialStatus:!1,isTerminalStatus:!1,allowedNextStatusIds:[]}:{}}),children:`Add feed value`})]})})]})})}function XE(){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=IE();i(!0),n.pi(FE,{limit:500}).then(({items:n})=>{let r=n.filter(t=>zE(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.Dr(FE,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:PE,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:BE(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)=>BE(t).filter(e=>!e.isdeleted).length},{title:`Updated`,key:`updatedAt`,responsive:[`lg`],render:(e,t)=>WE(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(PE(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)(YE,{open:a,record:d,onClose:()=>o(!1),onSaved:()=>{o(!1),h()}})]})}function ZE(){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)(NE,{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)(XE,{}),(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)(NE,{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)(JE,{})]})}var{Text:QE,Title:$E}=c.Typography;function eD(){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 Kx())}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 Jx(d.menu_id,e):await qx(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 Yx(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)($E,{level:4,children:`Menus`}),(0,u.jsx)(QE,{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 tD=`/admin/global`;function nD(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 rD(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 iD(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 aD({includeInactive:e=!1,signal:n}={}){let r=await t.o(t.x,`${tD}/regions${rD({includeInactive:e||void 0})}`,{signal:n}),i=r?.data??r;return Array.isArray(i)?i:[]}async function oD(e,{allowEmpty:n=!1,signal:r}={}){return t.o(t.x,`${tD}/regions${rD({allowEmpty:n||void 0})}`,{method:`POST`,body:JSON.stringify(e),signal:r})}async function sD(e,{signal:n}={}){return t.o(t.x,`${tD}/regions/${encodeURIComponent(e)}`,{method:`DELETE`,signal:n})}async function cD({signal:e}={}){let n=await t.o(t.x,`${tD}/platform-access`,{signal:e}),r=n?.data??n;return Array.isArray(r)?r:[]}async function lD(e,{signal:n}={}){return t.o(t.x,`${tD}/platform-access`,{method:`POST`,body:JSON.stringify(e),signal:n})}async function uD(e,{signal:n}={}){return t.o(t.x,`${tD}/platform-access/${encodeURIComponent(e)}`,{method:`DELETE`,signal:n})}async function dD({signal:e}={}){try{return await aD({signal:e}),!0}catch(e){if(e?.name===`AbortError`)throw e;return!1}}async function fD({search:e,regionKey:n,limit:r=25,offset:i=0,signal:a}={}){return nD(await t.o(t.x,`${tD}/users${rD({search:e,regionKey:n,limit:r,offset:i})}`,{signal:a}))}async function pD({regionKey:e,action:n,limit:r=50,offset:i=0,signal:a}={}){return nD(await t.o(t.x,`${tD}/audit${rD({regionKey:e,action:n,limit:r,offset:i})}`,{signal:a}))}async function mD(e,{signal:n}={}){let r=await t.o(t.x,iD(e,`/detail-defaults`),{signal:n});return r?.data??r??{}}async function hD(e,n,{signal:r}={}){return t.o(t.x,iD(e,`/detail-defaults`),{method:`POST`,body:JSON.stringify(n),signal:r})}async function gD(e,{signal:n}={}){return nD(await t.o(t.x,iD(e,`/users`),{signal:n}))}async function _D(e,{signal:n}={}){return nD(await t.o(t.x,iD(e,`/roles`),{signal:n}))}var vD=[{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 yD({signal:e}={}){let n=await t.o(t.x,`${tD}/defaults`,{signal:e}),r=n?.data??n??{};return{regions:r.regions??[],common:r.common??{}}}async function bD(e,{regionKeys:n,signal:r}={}){return t.o(t.x,`${tD}/defaults`,{method:`PUT`,body:JSON.stringify({values:e,regionKeys:n??[]}),signal:r})}var xD=[{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 SD({serviceKey:e=`pyOps`,signal:n}={}){let r=await t.o(t.x,`${tD}/ai-services${rD({serviceKey:e})}`,{signal:n}),i=r?.data??r??{};return{serviceKey:i.serviceKey??e,regions:i.regions??[],missingRegions:i.missingRegions??[],consistent:!!i.consistent}}async function CD(e,{regionKeys:n,signal:r}={}){return t.o(t.x,`${tD}/ai-services`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,regionKeys:n??[]}),signal:r})}var{Text:wD}=c.Typography;function TD({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 yD({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 bD(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)(wD,{strong:!0,children:e}),(0,u.jsx)(wD,{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)(wD,{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)(wD,{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=xD.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)(wD,{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)(wD,{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)(wD,{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{Text:ED,Paragraph:DD}=c.Typography;function OD({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 SD({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 CD(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)(DD,{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)(ED,{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)(ED,{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)(ED,{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)(ED,{type:`secondary`,children:`None`})}],dataSource:o,pagination:!1,locale:{emptyText:e.length?`No regions returned`:`No regions configured`}})]})}var{Text:kD,Title:AD}=c.Typography;function jD(){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 aD({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)(AD,{level:4,style:{margin:0},children:[(0,u.jsx)(l.SafetyCertificateOutlined,{}),` Platform`]}),(0,u.jsx)(kD,{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)(kD,{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)(MD,{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)(TD,{regions:n})},{key:`ai-services`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.ApiOutlined,{}),` AI Services`]}),children:(0,u.jsx)(OD,{regions:n})},{key:`users`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.TeamOutlined,{}),` All Users`]}),children:(0,u.jsx)(ID,{regions:n})},{key:`access`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.KeyOutlined,{}),` Access`]}),children:(0,u.jsx)(LD,{})},{key:`audit`,label:(0,u.jsxs)(`span`,{children:[(0,u.jsx)(l.AuditOutlined,{}),` Audit`]}),children:(0,u.jsx)(RD,{regions:n})}]})]})}function MD({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)(kD,{type:`secondary`,children:`Users`})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(kD,{strong:!0,children:e.userCount??`—`})})]}),(0,u.jsxs)(c.Row,{children:[(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(kD,{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)(kD,{type:`secondary`,children:`none`})})})]}),(0,u.jsxs)(c.Row,{children:[(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(kD,{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)(kD,{type:`secondary`,style:{fontSize:11,wordBreak:`break-all`},children:e.tenantId})]})})},e.key))}),(0,u.jsx)(ND,{region:r,onClose:()=>i(null),onSaved:n}),(0,u.jsx)(FD,{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)(kD,{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)(ND,{region:r,onClose:()=>i(null),onSaved:n})]})}function ND({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 oD(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:`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 sD(e.key),c.message.success(`Region deactivated`),n?.(),t()}}),children:`Deactivate region`})]})}var PD=[{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 FD({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),mD(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 hD(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:PD.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 ID({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 fD({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 LD(){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 cD())}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 uD(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 lD(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:vD,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 RD({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),pD({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)(kD,{type:`secondary`,children:`platform`})},{title:`Route`,dataIndex:`route`,key:`route`,render:e=>(0,u.jsx)(kD,{type:`secondary`,style:{fontSize:12},children:e})}],dataSource:t,pagination:{current:f,pageSize:50,total:r,showSizeChanger:!1,onChange:p}})]})}var{Content:zD,Header:BD,Sider:VD}=c.Layout,{Text:HD,Title:UD}=c.Typography;function WD(e){return String(e??``).trim().replace(/[\s_-]+/g,` `).toUpperCase()}function GD(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function KD(e){return String(e||``).trim().toLowerCase()}function qD(e){return e?.key||e?.collectionName||e?.value||``}function JD(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=qD(e);if(!t)return;let o=KD(e.key||t),s=KD(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||GD(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=KD(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:GD(t),value:t,disabled:!1}))}),n}function YD(e){return WD(e?.user_type_name??e?.userTypeName??e?.name)===`SUPER ADMIN`}function XD(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 ZD(e){let t=new Set;return e.reduce((e,n)=>{let r=XD(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 QD(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 $D(e){return String(e.menuKey??e.menuName??e.menuId).trim().toLowerCase()}var eO=[{permissionId:null,permissionKey:`my_jobs`,permissionName:`My Jobs`},{permissionId:null,permissionKey:`all_jobs`,permissionName:`All Jobs`},{permissionId:null,permissionKey:`sendApprove`,permissionName:`Send Approve`}];function tO(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 eO.forEach(e=>{r.has(e.permissionKey.toLowerCase())||n.push(e)}),n}function nO(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 rO({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=$D(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)(UD,{level:4,children:e}),(0,u.jsx)(HD,{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)(HD,{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=>eS(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:nO(e)})},e.key))})}],dataSource:f,pagination:!1,scroll:{y:420}}):(0,u.jsx)(c.Empty,{description:`Select a record to customize permissions`})]})}function iO({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),[U,ie]=(0,s.useState)([]),[ae,oe]=(0,s.useState)(!1),[se,W]=(0,s.useState)(!1),[ce,G]=(0,s.useState)(null),[le,ue]=(0,s.useState)(!1),[de,fe]=(0,s.useState)(null),[pe,me]=(0,s.useState)(`listView`),[he,ge]=(0,s.useState)([]),[K,q]=(0,s.useState)([]),[_e,ve]=(0,s.useState)(!1),[ye,be]=(0,s.useState)(!1),xe=t.d(),Se=(0,s.useMemo)(()=>he.filter(e=>!e.disabled),[he]),Ce=!_e&&Se.length===0,we=(0,s.useCallback)(async()=>{ve(!0);try{let[e,t]=await Promise.all([n.qr(),n.zr()]),r=JD(e.modules,t),i=new Set(r.filter(e=>!e.disabled).map(e=>e.value));ge(r),q(e=>e.filter(e=>i.has(e)))}catch{c.message.error(`Failed to load seed status`)}finally{ve(!1)}},[]);(0,s.useEffect)(()=>{we()},[we]);async function Te(){if(K.length===0){c.message.warning(Ce?`All modules already seeded.`:`Select at least one module to seed.`);return}be(!0);try{await n.Di(K),c.message.success(`User type field config seeded`),q([]),await we()}catch(e){c.message.error(e?.message||`Seed failed`)}finally{be(!1)}}async function Ee(){f(!0);try{let[e,t,n]=await Promise.allSettled([Hx(),Kx(),Xx()]),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`?tO(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(()=>{Ee()})},[]);let De=(0,s.useCallback)(async()=>{O(!0);try{let{users:e,total:t}=await Lx({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)(()=>{De()},[De]),(0,s.useEffect)(()=>{queueMicrotask(()=>{if(!F){R([]);return}m(!0),Zx(F).then(e=>{let t=QD(e??[]),n=new Map(t.map(e=>[`${$D(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 Oe=(0,s.useMemo)(()=>k.find(e=>e.user_type_id===F),[F,k]),ke=(0,s.useMemo)(()=>k.reduce((e,t)=>({...e,[t.user_type_id]:t.user_type_name}),{}),[k]),Ae=(0,s.useMemo)(()=>_.reduce((e,t)=>({...e,[t.user_id]:XD(t)}),{}),[_]),je=(0,s.useMemo)(()=>k.filter(e=>!YD(e)),[k]),Me=(0,s.useMemo)(()=>_.filter(e=>!YD({user_type_id:e.user_type_id,user_type_name:ke[e.user_type_id]})),[ke,_]);(0,s.useEffect)(()=>{if(!z){ie([]);return}let e=Number(r.getFieldValue(`user_type_id`)??0);if(!e){ie([]);return}let t=!1;return oe(!0),Rx(e).then(e=>{t||ie(e.filter(e=>!V||e.user_id!==V.user_id))}).catch(e=>{t||(c.message.error(e.message||`Unable to load reporting users`),ie([]))}).finally(()=>{t||oe(!1)}),()=>{t=!0}},[V,r,z]);let Ne=(0,s.useMemo)(()=>{let e=ZD(U),t=Number(V?.reporting_id??V?.reportingId??0);return!t||e.some(e=>Number(e.value)===t)?e:[{label:V?.reportingName??V?.reporting_name??Ae[t]??`User ${t}`,value:t},...e]},[V,U,Ae]),Pe=(0,s.useMemo)(()=>{let e=je.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:ke[t]??V.userType??V.roleName??(t>0?`Type ${t}`:`Unassigned`),value:t},...e]},[V,je,ke]);k.length,j.length;let Fe=[{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)(hw,{})},{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)(Yw,{})},{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)(zT,{})},{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)(ZT,{})},{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)(iE,{})},{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)(uE,{})},{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)(wE,{})},{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)(ME,{})},{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)(ZE,{})}],[Ie,Le]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=new AbortController;return dD({signal:e.signal}).then(Le).catch(()=>Le(!1)),()=>e.abort()},[]);let Re=[...Ie?[{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 ze(e,t){R(n=>n.map(n=>n.key===e?{...n,accessValue:t}:n))}async function Be(){g(!0);try{await Qx(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:xe?.userId??null}))),c.message.success(`Role permissions updated`)}catch(e){c.message.error(e.message||`Unable to save role permissions`)}finally{g(!1)}}function Ve(){H(null),r.resetFields(),r.setFieldsValue({status:`ACTIVE`,user_type_id:je[0]?.user_type_id,reporting_id:0}),B(!0)}function He(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 Ue(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:xe?.userId??null,created_by:xe?.userId??null};t.password||delete t.password,V?(await Bx(V.user_id,t),c.message.success(`User updated`)):(await zx(t),c.message.success(`User created`)),B(!1),H(null),await De()}catch(e){c.message.error(e.message||`Unable to save user`)}finally{te(!1)}}async function J(e){re(e);try{await Vx(e),c.message.success(`User deleted`),await De()}catch(e){c.message.error(e.message||`Unable to delete user`)}finally{re(null)}}function Y(e,t){me(`listView`),fe({kind:e,record:t}),e===`role`&&I(t.user_type_id)}function X(e,t){R(n=>{let r=[...new Set(n.map($D))],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($D(e))-o.get($D(t)))})}function We(){G(null),i.resetFields(),i.setFieldsValue({status:`ACTIVE`}),W(!0)}function Ge(e){G(e),W(!0),i.setFieldsValue(e)}async function Ke(e){ue(!0);try{let t=xe?.userId??null,n=!!ce,r=n?await Wx(ce.user_type_id,{...e,updated_by:t}):await Ux({...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.`),W(!1),await Ee(),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{ue(!1)}}async function qe(e){try{await Gx(e),c.message.success(`Role deleted`),await Ee()}catch(e){c.message.error(e.message||`Unable to delete role`)}}return(0,u.jsxs)(c.Layout,{className:`admin-shell`,children:[(0,u.jsx)(VD,{width:248,className:`admin-sider`,children:(0,u.jsxs)(`div`,{className:`admin-sidebar-nav`,children:[(0,u.jsx)(HD,{className:`admin-sidebar-title`,children:`Admin Menu`}),(0,u.jsx)(c.Menu,{theme:`dark`,mode:`inline`,selectedKeys:[a],onClick:({key:e})=>o(e),items:Re})]})}),(0,u.jsx)(c.Layout,{children:(0,u.jsxs)(zD,{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)(UD,{level:4,children:`Users`}),(0,u.jsx)(HD,{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:Ve,children:`Add`})]}),(0,u.jsx)(ch,{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)=>ke[e]||t?.userType||t?.user_type||(Number(e)>0?`Type ${e}`:`—`)},{label:`Reporting Manager`,value:`reporting_id`,width:180,render:(e,t)=>Ae[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:()=>He(t)}),(0,u.jsx)(c.Popconfirm,{title:`Delete user?`,description:`This removes the user from the auth database.`,okText:`Delete`,okButtonProps:{danger:!0},onConfirm:()=>J(t.user_id),children:(0,u.jsx)(c.Button,{danger:!0,"aria-label":`Delete user`,icon:(0,u.jsx)(l.DeleteOutlined,{}),loading:ne===t.user_id,size:`small`})})]})}],dataSource:Me.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:K,options:he,placeholder:Ce?`All modules already seeded`:`Select modules or collections to seed`,disabled:_e||ye||Ce,loading:_e,onChange:q,style:{width:`100%`}})}),(0,u.jsx)(c.Button,{type:`primary`,loading:ye,disabled:_e||K.length===0,onClick:Te,children:`Seed Field Config`})]}),(0,u.jsx)(HD,{type:`secondary`,style:{display:`block`,marginTop:8,fontSize:12},children:Ce?`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)(UD,{level:4,children:`User Types`}),(0,u.jsx)(HD,{type:`secondary`,children:`Role level permissions are inherited by users.`})]}),(0,u.jsx)(c.Button,{type:`primary`,icon:(0,u.jsx)(l.PlusOutlined,{}),onClick:We,children:`Add Role`})]}),(0,u.jsx)(ch,{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:()=>Y(`role`,t),children:`Config`}),(0,u.jsx)(c.Button,{"aria-label":`Edit role`,disabled:!n,icon:(0,u.jsx)(l.EditOutlined,{}),size:`small`,onClick:()=>Ge(t)}),n&&!YD(t)&&(0,u.jsx)(c.Popconfirm,{title:`Delete role?`,onConfirm:()=>qe(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)(eD,{})},{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)(UD,{level:4,children:`Configuration Center`}),(0,u.jsx)(HD,{type:`secondary`,children:`CORE-THEME admin modules embedded into the admin dashboard.`})]}),(0,u.jsxs)(c.Tag,{color:`blue`,children:[Fe.length,` configurations`]})]}),(0,u.jsx)(c.Tabs,{className:`admin-config-tabs`,defaultActiveKey:`form-groups`,tabPosition:`left`,items:Fe.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)(UD,{level:4,children:e.title}),(0,u.jsx)(HD,{type:`secondary`,children:e.description})]})}),(0,u.jsx)(`div`,{className:`admin-config-panel-body`,children:e.component})]})}))})]})},...Ie?[{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)(jD,{})})}]:[],{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)(UD,{level:4,children:`Integrations`}),(0,u.jsx)(HD,{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)(uE,{})})})]})}]})}),(0,u.jsxs)(c.Modal,{className:`uss-modal`,title:`Configure User Type: ${de?.record?.user_type_name??``}`,open:!!de,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))}),de&&pe===`permissions`?(0,u.jsx)(rO,{title:`Role Permissions`,description:`Configure menu permissions for this user type`,selectedName:Oe?.user_type_name,loading:p,saving:h,rows:L,onChange:ze,onMove:X,onSave:Be}):de&&pe===`actions`?(0,u.jsx)(IS,{role:{...de.record,roleId:de.record.user_type_id,roleName:de.record.user_type_name}},`${de.record?.user_type_id}-actions`):de&&pe===`form`?(0,u.jsx)(OS,{role:{...de.record,roleId:de.record.user_type_id,roleName:de.record.user_type_name}},`${de.record?.user_type_id}-form`):de?(0,u.jsx)(_S,{role:{...de.record,roleId:de.record.user_type_id,roleName:de.record.user_type_name},configType:pe},`${de.record?.user_type_id}-${pe}`):null]}),(0,u.jsx)(c.Modal,{className:`admin-role-modal`,title:ce?`Edit User Type`:`Create User Type`,open:se,onCancel:()=>W(!1),onOk:()=>i.submit(),okText:ce?`Save`:`Next`,confirmLoading:le,destroyOnHidden:!0,width:900,children:(0,u.jsxs)(c.Form,{form:i,layout:`vertical`,onFinish:Ke,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`,children:(0,u.jsx)(c.Select,{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:Ue,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:()=>{ie([]),queueMicrotask(()=>{let e=Number(r.getFieldValue(`user_type_id`)??0);e&&(oe(!0),Rx(e).then(e=>{ie(e.filter(e=>!V||e.user_id!==V.user_id))}).catch(e=>{c.message.error(e.message||`Unable to load reporting users`),ie([])}).finally(()=>{oe(!1)}))})},options:Pe})})]}),(0,u.jsx)(c.Form.Item,{label:`Reporting Manager`,name:`reporting_id`,children:(0,u.jsx)(c.Select,{allowClear:!0,showSearch:!0,loading:ae,placeholder:`Select reporting manager`,optionFilterProp:`label`,options:[{label:`None`,value:0},...Ne]})}),(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 aO=iO;function oO(e,t){return String(e||t).replace(/\/\*$/,``).replace(/\/+$/,``)||t}function sO({loginPath:e=`/login`,adminPath:t=`/admin`,fallbackPath:n=`/`}){let r=(0,f.useNavigate)(),i=oO(e,`/login`),a=oO(t,`/admin`),o=`${a}/*`;return(0,u.jsxs)(f.Routes,{children:[(0,u.jsx)(f.Route,{path:i,element:(0,u.jsx)(Ub,{defaultRedirectPath:a,onLogin:()=>r(a,{replace:!0})})}),(0,u.jsx)(f.Route,{path:o,element:(0,u.jsx)(Pb,{loginPath:i,children:(0,u.jsx)(Hb,{children:(0,u.jsx)(aO,{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 cO(e){return(0,u.jsx)(f.BrowserRouter,{children:(0,u.jsx)(sO,{...e})})}var lO=/[<>]/;function uO(e){return Array.isArray(e)?e.map(String).map(e=>e.trim()).filter(Boolean):String(e??``).split(`,`).map(e=>e.trim()).filter(Boolean)}function dO(e){return Array.isArray(e)?e.some(e=>lO.test(String(e??``))):lO.test(String(e??``))}function fO(e){return uO(e).every(e=>!lO.test(e)&&/^[^,\s@<>]+@[^,\s@<>]+\.[^\s@<>]{2,}$/.test(e))}var{Text:pO}=c.Typography,mO=new Set([`file`,`document`,`attachment`]),hO=`To, CC and BCC cannot contain < or > characters.`,gO=`Add email ID separated by commas`;function _O(e){return mO.has(String(e?.type??``).trim().toLowerCase())}function vO(e){return String(e??``).trim().toLowerCase().replace(/[^a-z0-9]/g,``)}function yO(e){return e?typeof e==`string`?e:String(typeof e==`object`?e?._id??e?.id??e?.$oid??``:e):``}function bO(e,t,n){if(!e)return``;let r=vO(t),i=vO(n);if(!r||r===i||r.replace(/s$/,``)===i.replace(/s$/,``))return yO(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=yO(wO(e,t));if(n)return n}return``}async function xO(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 SO(e,t,r){if(!t)return[];let i=[];(e?.placeholders??[]).forEach(e=>{(e?.holders??[]).filter(_O).forEach(a=>{let o=bO(t,e?.moduleName,r);o&&i.push((async()=>{let t=await n.Pn(e.moduleName,o,a.value);return Promise.all((t?.data??[]).map(xO))})())})});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 CO(e,t){return[...new Set([...uO(e),...uO(t)])].join(`, `)}function wO(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 TO(e,t,n){if(!n)return String(e??``);let r=new Map;return(t??[]).forEach(e=>(e.holders??[]).forEach(e=>{r.set(e.key,_O(e)?``:wO(n,e.value,e.arrayMode))})),String(e??``).replace(/{{\.?([\w.]+)}}/g,(e,t)=>{let n=r.get(t);return n==null?e:String(n)})}function EO(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 DO({value:e,onChange:t,defaultTemplateId:r=``,ready:i=!0,title:a=`Mail`,hint:o,bccHint:d,afterBcc:f,beforeFields:p,className:m=``,contextRecords:h=[],moduleName:g=``,requiredTo:_=!1,requiredSubject:v=!1,requiredBody:y=!1}){let b=(0,s.useRef)(``),x=n=>t?.({...e,...n});function S(e){dO(String(e?.nativeEvent?.data??e?.data??``))&&(e.preventDefault(),c.message.warning(hO))}function C(e){dO(String(e?.clipboardData?.getData?.(`text`)??``))&&(e.preventDefault(),c.message.warning(hO))}function w(e,t){if(dO(t)){c.message.warning(hO);return}x({[e]:(Array.isArray(t)?t:uO(t)).join(`, `)})}function T(e){let t=EO(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 E(t,n=!1){if(t)try{let r=await aT(t),i=h[0],a=await SO(r,i,g);x({to:CO(e.to,(r?.toMail??[]).map(e=>TO(e,r?.placeholders,i))),cc:CO(e.cc,(r?.ccMail??[]).map(e=>TO(e,r?.placeholders,i))),bcc:CO(e.bcc,(r?.bccMail??[]).map(e=>TO(e,r?.placeholders,i))),subject:TO(r?.subject,r?.placeholders,i),contents:TO(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)(()=>{!i||!r||b.current===r||(b.current=r,E(r,!0))},[r,i]),(0,u.jsxs)(`div`,{className:`common-mail-composer ${m}`.trim(),onWheelCapture:T,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:a}),o&&(0,u.jsx)(pO,{type:`secondary`,className:`mail-popup__header-hint`,children:o})]})]})}),(0,u.jsxs)(`div`,{className:`mail-popup__body`,children:[p&&(0,u.jsxs)(u.Fragment,{children:[p,(0,u.jsx)(c.Divider,{})]}),(0,u.jsxs)(`div`,{className:`mail-popup__field-row`,onBeforeInputCapture:S,onPasteCapture:C,children:[(0,u.jsxs)(pO,{type:`secondary`,className:`mail-popup__field-label`,children:[`To Mail`,_&&(0,u.jsx)(`span`,{className:`mail-popup__required-mark`,"aria-hidden":`true`,children:`*`})]}),(0,u.jsx)(c.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`],value:uO(e.to),onChange:e=>w(`to`,e),onInputKeyDown:e=>{(e.key===`<`||e.key===`>`)&&(e.preventDefault(),c.message.warning(hO))},variant:`borderless`,className:`mail-popup__recipient-select`,placeholder:gO,"aria-required":_}),(0,u.jsxs)(`div`,{className:`mail-popup__cc-bcc-actions`,children:[!e.showCc&&(0,u.jsx)(`span`,{className:`mail-popup__cc-bcc-link`,onClick:()=>x({showCc:!0}),children:`Cc`}),!e.showBcc&&(0,u.jsx)(`span`,{className:`mail-popup__cc-bcc-link`,onClick:()=>x({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:S,onPasteCapture:C,children:[(0,u.jsx)(pO,{type:`secondary`,className:`mail-popup__field-label`,children:`Cc`}),(0,u.jsx)(c.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`],value:uO(e.cc),onChange:e=>w(`cc`,e),onInputKeyDown:e=>{(e.key===`<`||e.key===`>`)&&(e.preventDefault(),c.message.warning(hO))},variant:`borderless`,className:`mail-popup__recipient-select`,placeholder:gO})]}),(0,u.jsx)(c.Divider,{})]}),e.showBcc&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`mail-popup__field-row`,onBeforeInputCapture:S,onPasteCapture:C,children:[(0,u.jsx)(pO,{type:`secondary`,className:`mail-popup__field-label`,children:`Bcc`}),(0,u.jsx)(c.Select,{mode:`tags`,open:!1,tokenSeparators:[`,`],value:uO(e.bcc),onChange:e=>w(`bcc`,e),onInputKeyDown:e=>{(e.key===`<`||e.key===`>`)&&(e.preventDefault(),c.message.warning(hO))},variant:`borderless`,className:`mail-popup__recipient-select`,placeholder:d||gO})]}),f,(0,u.jsx)(c.Divider,{})]}),(0,u.jsxs)(`div`,{className:`mail-popup__field-row`,children:[(0,u.jsxs)(pO,{type:`secondary`,className:`mail-popup__field-label`,children:[`Subject`,v&&(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=>x({subject:e.target.value}),placeholder:`Enter subject`,className:`mail-popup__field-input`,"aria-required":v})]}),(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)(pO,{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)(pO,{type:`secondary`,className:`mail-popup__message-label`,children:[`Body`,y&&(0,u.jsx)(`span`,{className:`mail-popup__required-mark`,"aria-hidden":`true`,children:`*`})]}),(0,u.jsx)(n.Vn,{value:e.contents,onChange:e=>x({contents:e})})]})]})]})}var OO=new Set([`true`,`1`,`yes`,`y`,`on`]),kO=[`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 AO(e,t=!1){return e==null||e===``?t:e===!0||e===!1?e:typeof e==`number`?e===1:typeof e==`string`?OO.has(e.trim().toLowerCase()):t}function jO(e){return String(e??``).trim().toLowerCase().replace(/[^a-z0-9]/g,``)}function MO(e){return[`candidate`,`candidates`,`sourcecandidate`,`sourcecandidates`].includes(jO(e))}function NO(e,t){if(!(!e||!t))return String(t).split(`.`).reduce((e,t)=>e?.[t],e)}function PO(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)]:kO}function FO({popupAction:e={},state:t={},moduleName:n=``}={}){let r=e.mailConfig??t.mailConfig,i=AO(e.requireJobId)||AO(t.requireJobId)||MO(n);if(!r||typeof r!=`object`)return{configured:!1,jobBased:i,recipientSource:`selectedRecords`,recipientFields:PO({},e,t),recipientMode:`allSelected`,removeDuplicateRecipients:!0,jobIdSource:`context`,jobIdField:`jobId`,jobIdReadOnly:!1,autoFetchJobContent:!0,requiredTo:!0,requiredJobId:i,requiredSubject:!0,requiredBody:!0};let a=AO(r.jobBased,i);return{configured:!0,jobBased:a,recipientSource:[`selectedRecords`,`manual`].includes(r.recipientSource)?r.recipientSource:`selectedRecords`,recipientFields:PO(r,e,t),recipientMode:r.recipientMode===`firstSelected`?`firstSelected`:`allSelected`,removeDuplicateRecipients:AO(r.removeDuplicateRecipients,!0),jobIdSource:[`context`,`selectedRecord`,`manual`].includes(r.jobIdSource)?r.jobIdSource:`context`,jobIdField:String(r.jobIdField??`jobId`).trim()||`jobId`,jobIdReadOnly:AO(r.jobIdReadOnly,!1),autoFetchJobContent:AO(r.autoFetchJobContent,a),requiredTo:AO(r.requiredTo,!0),requiredJobId:AO(r.requiredJobId,a),requiredSubject:AO(r.requiredSubject,!0),requiredBody:AO(r.requiredBody,!0)}}function IO(e=[],t=`allSelected`){let n=Array.isArray(e)?e.filter(Boolean):[];return t===`firstSelected`?n.slice(0,1):n}function LO(e,t={},n=[]){let r=e?.jobIdSource??`context`,i=e?.jobIdField||`jobId`;if(r===`manual`)return``;let a=(e,t=i)=>{let n=[NO(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:RO}=c.Typography,zO=/^[a-fA-F0-9]{24}$/,BO=new Set([`file`,`document`,`attachment`]);function VO(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 HO(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 UO(e,t,r=[]){let i=String(e??``);if(!i||!r.length||!t)return{contents:i,attachments:[]};let a=(await n.ai(t).catch(()=>[])).filter(e=>BO.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(!zO.test(r))continue;let i=await n.Pn(t,r,a).catch(()=>({data:[]})),s=await Promise.all((i?.data??[]).map(HO));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 WO(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 GO(e){let t=WO(e,`jobReferenceId`,`clientJobId`,`jobCode`,`reqId`,`jobId`),n=WO(e,`jobTitle`,`title`,`name`),r=WO(e,`jobRecruitmentStatus`,`recruitmentStatus`,`jobStatus`,`status`),i=[t,n].filter(Boolean).join(` - `)||String(WO(e,`_id`,`id`)??`Job`);return r?`${i} — ${r}`:i}function KO(e){let t=WO(e,`_id`,`id`,`jobId`);if(!t)return null;let n=e?.disable===!0||e?.disabled===!0,r=WO(e,`jobRecruitmentStatus`,`recruitmentStatus`,`jobStatus`,`status`),i=String(e?.message??r??``).trim();return{value:String(t),label:GO(e),disabled:n,title:n&&i?i:void 0,raw:e}}function qO(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 JO(e){return zO.test(String(e??``))?GO({...qO(await Yn({module:`jobs`,id:e,view:`detail`})),_id:e}):``}function YO(e=[],t=[]){let n=[...new Set(t.filter(Boolean))];return e.flatMap(e=>n.map(t=>WO(e,t))).flatMap(e=>Array.isArray(e)?e:[e]).flatMap(uO)}function XO(e){let t=WO(e,`jobId`,`job_id`,`job._id`,`job.id`,`jobs._id`,`jobs.id`);return typeof t==`object`?WO(t,`_id`,`id`,`$oid`):t}function ZO(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 QO(e,t=!0){let n=e.flatMap(uO);return(t?[...new Set(n)]:n).join(`, `)}function $O(){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)(()=>FO({popupAction:d,state:t,moduleName:l}),[l,d,t]),m=(0,s.useMemo)(()=>IO(r,p.recipientMode),[p.recipientMode,r]),h=(0,s.useMemo)(()=>p.recipientMode===`firstSelected`?n.slice(0,1):n,[p.recipientMode,n]),g=h.join(`|`),_=(0,s.useMemo)(()=>{let e=p.recipientSource===`selectedRecords`?YO(m,p.recipientFields):[];return QO([...i,...e],p.removeDuplicateRecipients)},[p.recipientFields,p.recipientSource,p.removeDuplicateRecipients,m,i]),v=String(LO(p,t,r)??``).trim(),y=String(XO(r[0])??``).trim(),b=v||(p.configured?``:y),x=n[0]??r[0]?._id??r[0]?.id??``,S=p.jobBased||p.requiredJobId?b:String(b||(p.configured?``:x)||``),C=p.jobIdReadOnly&&p.jobIdSource!==`manual`&&zO.test(b),w=p.jobBased||p.requiredJobId,[T,E]=(0,s.useState)(b),[D,O]=(0,s.useState)(S),[k,A]=(0,s.useState)(``),[j,M]=(0,s.useState)({to:_,cc:``,bcc:``,subject:a,contents:``,attachments:[],showCc:!1,showBcc:!1}),N=p.autoFetchJobContent&&zO.test(S),[P,F]=(0,s.useState)(!N),[I,L]=(0,s.useState)(!1),[R,z]=(0,s.useState)([]),[B,V]=(0,s.useState)(!1),[H,ee]=(0,s.useState)(!1),te=(0,s.useRef)(!1),ne=(0,s.useRef)(``),re=(0,s.useRef)(0);(0,s.useEffect)(()=>{if(p.recipientSource!==`selectedRecords`||!MO(l)||te.current||uO(j.to).length>0||h.length===0||ne.current===g)return;let e=!1;return ne.current=g,Sn(h).then(t=>{if(e)return;let n=YO(IO(t,p.recipientMode),p.recipientFields);n.length&&M(e=>uO(e.to).length>0?e:{...e,to:QO(n,p.removeDuplicateRecipients)})}).catch(t=>{e||c.message.error(t?.message||`Could not load candidate emails`)}),()=>{e=!0}},[j.to,p.recipientFields,p.recipientMode,p.recipientSource,p.removeDuplicateRecipients,l,h,g]),(0,s.useEffect)(()=>{if(!p.autoFetchJobContent||!D){F(!0),L(!1);return}if(!zO.test(D)){F(!p.requiredJobId);return}let e=++re.current,t=!1;async function n(){F(!1),L(!0),M(e=>({...e,contents:``}));try{let[n,i]=await Promise.all([xn(D),C?JO(D).catch(()=>``):Promise.resolve(``)]),o=ZO(n),s=await UO(o.contents||``,l,r),u=s.contents;if(u.trim())try{u=await Cn(u,o.subject||a)}catch(n){!t&&e===re.current&&c.message.warning(n?.message||`Mail content formatting failed. Showing original content.`)}if(t||e!==re.current)return;i&&A(i),M(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===re.current&&p.requiredJobId&&c.message.error(n?.message||`Could not load mail template for this Job ID`)}finally{!t&&e===re.current&&(F(!0),L(!1))}}return n(),()=>{t=!0}},[D,p.autoFetchJobContent,p.configured,p.requiredJobId]);function U(e=T){let t=String(e??``).trim();if(!zO.test(t)){O(``),A(``),t&&c.message.warning(`Enter a valid 24-character Job ID`);return}if(t===D){O(``),queueMicrotask(()=>O(t));return}O(t)}function ie(e,t){if(t?.disabled)return;if(!e){O(``),E(``),A(``);return}let n=t?.label??``;E(String(n||(e??``))),A(n?String(n):``),U(e)}function oe(e){let t=String(e??``).trim();if(E(t),t.length<3){z([]);return}V(!0),ae(t).then(e=>{let t=(Array.isArray(e)?e:[]).map(KO).filter(Boolean);z(t)}).catch(e=>c.message.error(e?.message||`Unable to search jobs`)).finally(()=>V(!1))}let se=uO(j.to).length>0,W=P&&(!p.requiredJobId||zO.test(D))&&(!p.requiredTo||se)&&fO(j.to)&&fO(j.cc)&&fO(j.bcc)&&(!p.requiredSubject||j.subject.trim().length>0)&&(!p.requiredBody||VO(j.contents));async function ce(){if(!(!W||H)){ee(!0);try{await wn({jobId:D,toMail:uO(j.to),ccMail:uO(j.cc),bccMail:uO(j.bcc),subject:j.subject,contents:j.contents,attachments:j.attachments??[]}),c.message.success(`Mail sent successfully`),typeof o==`function`&&o({...j,message:j.contents,selectedIds:n}),e(-1)}catch(e){c.message.error(e?.message||`Failed to send mail`)}finally{ee(!1)}}}function G(e){e?.to!==j.to&&(te.current=!0),M(e)}let le=w?(0,u.jsxs)(`div`,{className:`mail-popup__job-row`,children:[(0,u.jsxs)(RO,{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:`*`})]}),C?(0,u.jsx)(c.Input,{value:k||D,readOnly:!0,className:`mail-popup__job-input`,"aria-required":p.requiredJobId}):(0,u.jsx)(c.Select,{showSearch:!0,allowClear:!0,filterOption:!1,value:D||void 0,searchValue:T,onSearch:oe,onChange:ie,onClear:()=>{O(``),E(``),z([])},placeholder:`Minimum 3 characters`,notFoundContent:B||I?(0,u.jsx)(c.Spin,{size:`small`}):null,options:R,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:H,disabled:!W,onClick:ce,children:`Send`})]}),children:(0,u.jsx)(c.Spin,{spinning:I,description:`Loading mail content...`,size:`large`,children:(0,u.jsx)(DO,{value:j,onChange:G,moduleName:l,defaultTemplateId:p.autoFetchJobContent?``:d.defaultTemplateId??t.defaultTemplateId??``,ready:P,contextRecords:r,requiredTo:p.requiredTo,requiredSubject:p.requiredSubject,requiredBody:p.requiredBody,beforeFields:le})})})}var{Text:ek}=c.Typography,tk=e=>e===!0||e===1||e===`1`;function nk(e){return e?e.trim().split(/\s+/).slice(0,2).map(e=>e[0].toUpperCase()).join(``):`?`}function rk(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 ik(e){return e?e.email??e.emailId??e.emailAddress??``:``}function ak(e){return e?e.status?e.status:e.stage?e.stage:typeof e.isActive==`boolean`?e.isActive?`Active`:`Inactive`:``:``}function ok(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 sk(e){let t=tu(e);return[...e].filter(e=>!tk(e.hideGroup)&&!tk(e.hideGroupInDetail)).filter(e=>nu(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||tk(e.show))&&nu(e,t)).map(e=>({...e,label:iu(e,t)})).sort((e,t)=>Number(e.order??0)-Number(t.order??0))})).filter(e=>e.fields.length)}function ck({record:e}){let t=rk(e),n=ik(e),r=ak(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:nk(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 lk({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=ok(e,t),a=r.value,o=r.renderType===`document`?n.Qt(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)(ed,{field:r,record:i})})]},r.field??r.label)})}),(0,u.jsx)(r.t,{documents:a,open:d,onClose:()=>f(!1),initialIndex:c})]})}function uk(){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)(()=>sk(a),[a]),w=(0,s.useMemo)(()=>tu(a),[a]);(0,s.useEffect)(()=>{if(!t||!i)return;let e=!1;return Promise.all([Yn({module:t,id:i,view:`detail`}),n.Pn(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)(lk,{fields:e.fields,centralDocuments:h,recordValueMap:w}):(0,u.jsx)(ek,{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)(ck,{record:r}),M()]})})}var{Text:dk}=c.Typography;function fk({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)(Op,{moduleName:e,id:i,onHeaderData:d}):(0,u.jsx)(`div`,{style:{padding:24},children:(0,u.jsx)(dk,{type:`secondary`,children:`No record id.`})})})}fk.propTypes={moduleName:p.default.string,backPath:p.default.string};var{Text:pk}=c.Typography,{TextArea:mk}=c.Input,hk=[{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 gk(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)(mk,{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 _k({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)(pk,{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)(pk,{type:`secondary`,children:`Please review the information above before submitting.`})]})]}):(0,u.jsx)(`div`,{className:`wizard-review-empty`,children:(0,u.jsx)(pk,{type:`secondary`,children:`No data entered yet.`})})}function vk(){let[e]=c.Form.useForm(),t=(0,f.useNavigate)(),{title:n=`Wizard`,moduleName:r=``,steps:i=hk,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:gk(e)})},e.name))})},e.key)),d.isReview&&(0,u.jsx)(_k,{steps:i,form:e})]})})]})}function yk({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 bk({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.Hn,{variant:`body`,color:`secondary`,className:`dynamic-popup__note`,children:e}),t&&(0,u.jsx)(n.Hn,{variant:`body`,className:`dynamic-popup__description`,children:t}),r&&i>0&&(0,u.jsxs)(n.Hn,{variant:`body`,className:`dynamic-popup__selected-count`,children:[`Changing status for `,(0,u.jsx)(`strong`,{children:i}),` selected `,a,`.`]}),o&&(0,u.jsx)(n.Hn,{variant:`body`,children:o}),s&&(0,u.jsx)(n.Hn,{variant:`caption`,color:`danger`,className:`dynamic-popup__error`,children:s})]})}function xk({footerNote:e}){return e?(0,u.jsx)(n.Hn,{variant:`caption`,color:`secondary`,className:`dynamic-popup__footer-note`,children:e}):null}function Sk(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>t?.[n]??``).trim()}function Ck(e){return String(e).replace(/\(\s*\)/g,``).replace(/\s+/g,` `).replace(/(^|\s)([-–—·|])(?=\s*\2)/g,``).replace(/^[\s\-–—·|]+/,``).replace(/[\s\-–—·|]+$/,``).trim()}function wk(e){if(!e)return!1;let t=new Date(e).getTime();return Number.isNaN(t)||t<=0?!1:t<=Date.now()+864e5}function Tk(e){if(!wk(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 Ek(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 Dk(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 Ok(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:Tk(Ek(e))}:e,o=(i?Ck(Sk(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||Dk(e);t&&(u.submittedAt=t)}if(e?.isFromSubmission===!0&&e?.submissionId){u.isFromSubmission=!0,u.priorSubmissionId=String(e.submissionId);let t=e?.lastSubmittedAt||Dk(e);t&&(u.priorSubmittedAt=t)}return u}function kk(e,t){return(t?.[e.optionsKey]??e.defaultOptions??[]).map(t=>Ok(t,e))}function Ak(e={}){return{selectedIds:[],selectedRecords:[],moduleName:``,removedIds:[],...e}}var jk=`DD MMM YYYY`,Mk=`DD MMM YYYY, h:mm A`;function Nk(e,t){if(e==null||e===``)return``;let n=(0,d.default)(e);return n.isValid()?t===`relative`?Tk(e)||(wk(e)?n.format(jk):`Not updated`):wk(e)?n.format(jk):``:String(e)}function Pk(e,t){return e?String(e).includes(`{`)?Ck(Sk(e,t)):String(t?.[e]??e).trim():``}function Fk(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(Mk)}`:`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(Mk)} — this form will prefill from it`:`Submitted to another job before — this form will prefill from it`}}return null}function Ik(e,t){return e?.alreadySubmitted||!e?.disabled?``:String(t?.message??e?.title??``).trim()}function Lk({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 Rk({option:e,layout:t}){let n=e?._raw??e??{},r=Pk(t.id,n),i=Pk(t.title,n)||String(e?.label??``),a=Pk(t.subtitle,n),o=Pk(t.titleAccent?.key,n),s=Pk(t.titleAccent?.toneKey,n),d=t.titleAccent?.prefix??``,f=(t.meta??[]).map(e=>({label:e.label,text:Nk(n?.[e.key],e.type)})).filter(e=>e.text),p=Ik(e,n),m=Fk(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)(Lk,{meta:f})]})}var{Text:zk}=c.Typography,{TextArea:Bk}=c.Input,Vk=[{label:`$`,value:`$`},{label:`EUR`,value:`EUR`},{label:`GBP`,value:`GBP`},{label:`INR`,value:`INR`}],Hk=[{label:`Hourly`,value:`Hourly`},{label:`Daily`,value:`Daily`},{label:`Weekly`,value:`Weekly`},{label:`Monthly`,value:`Monthly`},{label:`Yearly`,value:`Yearly`}];function Uk(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 Wk({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 Gk({field:e,value:t,onChange:n}){return(0,u.jsx)(Bk,{value:t,onChange:n,rows:e.rows??5,placeholder:e.placeholder})}function Kk({field:e,options:t,value:n,onChange:r}){let i=Uk(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:Jk,prefix:(0,u.jsx)(l.CrownOutlined,{})})}function qk({field:e,options:t,value:n,onChange:r}){let i=Uk(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:Jk,prefix:(0,u.jsx)(l.CrownOutlined,{})})}function Jk(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`})]})}function Yk({field:e,options:t,onSearch:n,value:r,onChange:i,popupContext:a}){let o=Uk(t),s=e.optionLayout,d=new Map(o.map(e=>[String(e?.value??``),e])),f=e.multiSelect||e.multiple||e.mode===`multiple`?`multiple`:e.mode;async function p(t,n){let r=Array.isArray(t)?Array.isArray(n)?n:t.map(e=>d.get(String(e??``))).filter(Boolean):n??d.get(String(t??``));(typeof e.onSelectGuard!=`function`||await e.onSelectGuard({value:t,option:r,field:e,popupContext:a,confirm:c.Modal.confirm})!==!1)&&i?.(t)}return(0,u.jsx)(c.Select,{mode:f,showSearch:!0,filterOption:!1,notFoundContent:e.notFoundContent??null,value:r,onChange:p,options:o,placeholder:e.placeholder,onSearch:n,className:`dynamic-popup__field-select${s?` dynamic-popup__field-select--rich`:``}`,popupClassName:s?`dynamic-popup__option-dropdown`:void 0,listHeight:s?340:void 0,optionLabelProp:`label`,optionRender:s?e=>(0,u.jsx)(Rk,{option:e?.data??e,layout:s}):void 0,prefix:(0,u.jsx)(l.CrownOutlined,{})})}function Xk({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 Zk({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:Vk,onChange:e=>a({currency:e}),style:{width:80}}),(0,u.jsx)(c.Select,{value:r,options:Hk,onChange:e=>a({period:e}),style:{width:110}})]}),(l||d)&&(0,u.jsxs)(`div`,{style:{marginTop:4},children:[l&&(0,u.jsx)(zk,{type:`danger`,style:{fontSize:12,display:`block`},children:`To rate must be greater than From rate.`}),d&&(0,u.jsxs)(zk,{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 Qk({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 $k({field:e,checked:t,onChange:n}){return(0,u.jsx)(c.Checkbox,{checked:t,onChange:n,children:e.checkboxLabel})}function eA({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 tA({options:e,value:t,onChange:n}){return(0,u.jsx)(c.Radio.Group,{value:t,onChange:n,options:e})}var nA={input:Wk,text:Wk,textarea:Gk,select:Kk,"multi-select":qk,"search-select":Yk,"mention-textarea":Xk,"candidate-rate":Zk,"priority-checkbox":$k,"date-picker":Qk,number:eA,radio:tA};function rA(e){return e===`priority-checkbox`?{valuePropName:`checked`}:{}}var iA=new Set([`input`,`text`,`textarea`,`mention-textarea`]);function aA({form:e,fields:t,initialValues:r,dynamicOptions:i,popupContext:a,extraData:o,removedIds:l,setRemovedIds:d,onRemoveAssigned:f,showAlreadyAssigned:p,onValuesChange:m,getSearchHandler:h,getMentionSearchHandler:g,mentionOptions:_}){let[v,y]=(0,s.useState)([]),b=(o?.recruitersData??[]).filter(e=>{let t=String(e?.user_id??e?.id??e?.userId??``);return t&&!l.includes(t)}),x=p&&o,S=new Set(p?b.map(e=>String(e?.user_id??e?.id??e?.userId??``).trim()).filter(Boolean):[]),C=e=>S.size===0||!Array.isArray(e)?e:e.map(e=>{let t=String((e&&typeof e==`object`?e.value??e.id:e)??``).trim();return!S.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&&!x?null:(0,u.jsxs)(u.Fragment,{children:[x&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`dynamic-popup__already-assigned`,children:[(0,u.jsx)(n.Hn,{variant:`caption`,color:`secondary`,children:`Already Assigned People`}),(0,u.jsx)(`div`,{style:{marginTop:6,display:`flex`,flexWrap:`wrap`,gap:6},children:b.length===0?(0,u.jsx)(n.Hn,{variant:`caption`,color:`secondary`,children:`No one is currently assigned to this job.`}):b.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=v.includes(t);return(0,u.jsxs)(c.Tag,{closable:!r,onClose:async n=>{if(n.preventDefault(),!(!t||r)){y(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{y(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:oA(t).map(e=>sA(e,e=>{let t=C(i[e.name]??kk(e,a)),r=h(e),o=g(e),s=_[e.name]??[],l=rA(e.type),d=nA[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()}}),iA.has(e.type)&&f.push(n.xn({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,mentionOpts:s,onMentionSearch:o,popupContext:a}):null},e.name)}))})]})}function oA(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 sA(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 cA(e){return[`select`,`multi-select`,`search-select`,`radio`].includes(e?.type)&&e?.dataSource===`master`&&e?.masterName}function lA(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 uA(e){let t=String(e?.masterName??``).trim().toLowerCase();return t===`clientsubmissions`||t===`clientsubmissionstatus`}function dA(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 fA(e,t){return uA(t)?dA(e):Ok(e,t)}function pA(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 mA(e){let t=Number(e?.id??0)||0,n=String(e?.text??``).trim();return n&&n.toLowerCase()===`not submitted`?!0:t<=0&&!n}function hA(e){return Number(e?._raw?.id??e?._raw?.uniqueId??0)||0}function gA(e){let t=e?._raw?.allowedNextStatusIds;return Array.isArray(t)?t.map(Number).filter(e=>Number.isInteger(e)&&e>0):[]}function _A(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 vA(e){return(Array.isArray(e?.selectedRecords)?e.selectedRecords.filter(Boolean):[]).some(e=>!mA(pA(e)))?!0:!mA(pA(e??{}))}async function yA(e,n){if(vA(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=_A(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 bA(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=pA(n);if(mA(i)){let e=pA(r);mA(e)||(i=e)}if(mA(i))return t?._raw?.isInitialStatus===!0;let a=e.find(e=>{let t=hA(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:gA(a).includes(hA(t))}))}function xA({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(cA);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=lA(t).map(t=>fA(t,e)).filter(Boolean),i=a;if(uA(e)&&(i=await yA(a,r)),o.signal.aborted)return;let s=uA(e)?bA(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 SA=500,CA=3;function wA({api:e,open:t,fields:n=[],popupContext:r,setDynamicOptions:i}){let[a,o]=(0,s.useState)({}),c=(0,s.useRef)({}),l=(0,s.useRef)({}),u=(0,s.useRef)({}),d=(0,s.useCallback)((t,n)=>{let a=e.searchOptions??e.searchFetcher;if(typeof a!=`function`)return;l.current[t.name]?.abort();let o=new AbortController;return l.current[t.name]=o,Promise.resolve(a(t,n,r)).then(e=>{if(o.signal.aborted)return;let n=Array.isArray(e)?e:e?.items??e?.list??[];i(e=>({...e,[t.name]:n.map(e=>Ok(e,t))}))}).catch(e=>{o.signal.aborted||console.error(`[DynamicPopup] Search failed for field "${t.name}":`,e)}),o},[e,r,i]),f=n.filter(e=>(e.searchFetchKey||e.searchFetcher)&&e.preloadOptions!==!1),p=f.map(e=>e.name).join(`|`),m=(0,s.useRef)({runSearch:d,preloadFields:f});(0,s.useEffect)(()=>{m.current={runSearch:d,preloadFields:f}}),(0,s.useEffect)(()=>{if(!t||!p)return;let{runSearch:e,preloadFields:n}=m.current,r=n.map(t=>e(t,``)).filter(Boolean);return()=>r.forEach(e=>e.abort())},[t,p]);function h(t){if(!t.searchFetchKey&&!t.searchFetcher||typeof(e.searchOptions??e.searchFetcher)!=`function`)return;let n=t.searchMinLength??CA;return e=>{clearTimeout(c.current[t.name]);let r=e.length<n?``:e;c.current[t.name]=setTimeout(()=>{d(t,r)},SA)}}function g(t){let n=e.getMentionOptions??e.mentionFetcher;if(typeof n==`function`)return e=>{u.current[t.name]?.abort();let i=new AbortController;u.current[t.name]=i,Promise.resolve(n(t,e,r)).then(e=>{if(i.signal.aborted)return;let n=Array.isArray(e)?e:e?.items??e?.list??[];o(e=>({...e,[t.name]:n.map(e=>({value:e.user_name??e.userName??e.username??String(e),label:e.user_name??e.userName??e.username??String(e)}))}))}).catch(e=>{i.signal.aborted||console.error(`[DynamicPopup] Mention search failed for field "${t.name}":`,e)})}}return{mentionOptions:a,getSearchHandler:h,getMentionSearchHandler:g}}function TA({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 EA({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)(()=>Ak(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=>{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}=xA({open:e,config:t,api:a,fields:x,popupContext:g,formValues:l}),{mentionOptions:E,getSearchHandler:D,getMentionSearchHandler:O}=wA({api:a,open:e,fields:x,popupContext:g,setDynamicOptions:w});function k(e){typeof r==`function`&&r(e)}let A=x.filter(e=>e.required),j=A.every(e=>{let t=h[e.name];return!(t==null||t===``||Array.isArray(t)&&t.length===0||typeof t==`object`&&!Array.isArray(t)&&Object.keys(t).length===0)}),M=(g.removedIds??[]).length,N=p.length>M,P=A.some(e=>{let t=h[e.name];return!(t==null||t===``||Array.isArray(t)&&t.length===0)}),{handleOk:F,confirming:I,deleteError:L,resetSubmitState:R}=TA({form:o,config:t,api:a,popupContext:g,resolvedIds:b,dynamicOptions:C,extraData:T,removedIds:p,removalOnlySubmit:!!t?.allowRemovalOnlySubmit&&N&&!P,fields:x,onClose:k,onSubmit:i});(0,s.useEffect)(()=>{e&&(o.resetFields(),f(S??{}),m(g.removedIds??[]),R())},[e,S]);let z=!!t?.autoSubmitWhenNoFields&&x.length===0;(0,s.useEffect)(()=>{!e||!z||F()},[e,z]);let B=_.length,V=String(y).replace(/s$/i,``),H=B===1?V:y,ee=v[0]??{},te=t?.getTitleText?t.getTitleText(B,H,ee,g):t?.title,ne=B===1?ee.jobTitle??ee.title??ee.name??ee.fullName??ee.candidateName??null:null,re=t?.getBodyText?t.getBodyText(B,V,H,ne,g):t?.bodyText??null,U=typeof t?.getNote==`function`?t.getNote(g):t?.note,ie=t?.disabledUntilFilled&&!j&&!N;if(!t||!e||z)return null;let ae=t.component;return ae?(0,u.jsx)(c.Modal,{open:e,title:t.title||t.getTitleText?(0,u.jsx)(yk,{titleText:te,titleIcon:t.titleIcon}):null,footer:null,width:t.width??760,centered:!0,maskClosable:!1,onCancel:()=>k(),className:`dynamic-popup${t.className?` ${t.className}`:``}`,children:(0,u.jsx)(ae,{context:g,selectedIds:b,selectedRecords:v,moduleName:y,onClose:k})}):(0,u.jsxs)(c.Modal,{open:e,title:(0,u.jsx)(yk,{titleText:te,titleIcon:t.titleIcon}),okText:t.okText||`OK`,cancelText:t.cancelText??`Cancel`,onOk:F,onCancel:()=>k(),okButtonProps:{danger:t.okButtonDanger,disabled:ie,loading:I},cancelButtonProps:{disabled:I},closable:!I,maskClosable:!1,width:t.width??480,centered:!0,className:`dynamic-popup${t.className?` ${t.className}`:``}`,children:[(0,u.jsx)(bk,{note:U,description:t.description,showSelectedCount:t.showSelectedCount,count:B,itemLabel:H,bodyText:re,deleteError:L}),(0,u.jsx)(xk,{footerNote:t.footerNote}),(0,u.jsx)(aA,{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:D,getMentionSearchHandler:O,mentionOptions:E})]})}var DA={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:[]},OA={deleteItems:async(e,t)=>{await ie(t.moduleName,e)}},kA=new Map;async function AA(e){return e?(kA.has(e)||kA.set(e,o.r({module:e}).catch(t=>(kA.delete(e),console.warn(`[in-progress gate] could not read ${e} form groups:`,t),[]))),kA.get(e)):[]}function jA(e=[],t){return e.some(e=>{let r=n.F(e,t);return r&&r.severity!==`allow`})}async function MA({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.nr().region;try{let i=await AA(e);if(!jA(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 NA=`Already submitted`,PA=`submissions`,FA=`candidates`,IA=864e5,LA=90,RA=`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.`,zA=[`createdAt`,`createdDate`,`dateCreated`,`created_on`,`createdOn`],BA=[`updatedAt`,`updatedDate`,`lastUpdatedAt`,`lastUpdatedDate`,`modifiedAt`,`modifiedDate`];function VA(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 HA(e){return VA(e,zA)}function UA(e){return VA(e,BA)}function WA(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))/IA))}function GA(e){return e===null?``:e<=14?`green`:e<=89?`yellow`:`red`}function KA(e,t=LA){if(!e)return!1;let n=Date.now()-t*IA,r=HA(e),i=UA(e),a=r&&r.getTime()>=n,o=i&&i.getTime()>=n;return!a&&!o}function qA(e){let t=HA(e);if(!t)return{createdAgo:``,createdAgoTone:``};let n=Tk(t);return n?{createdAgo:n,createdAgoTone:GA(WA(t))}:{createdAgo:``,createdAgoTone:``}}function JA(e){return{...e,...qA(e),isStaleCandidate:KA(e)}}function YA(e){return String(e?.applicantId??e?._id??e?.id??``)}var XA=null;async function ZA(){return XA||=n.ni(FA).then(e=>e?.strategies?.duplicateCheck?.editRoute??``).catch(()=>``),XA}async function QA(e){let t=YA(e);if(!t)return``;let n=await ZA();return n?n.replace(/:(_?id)\b/g,encodeURIComponent(t)):``}async function $A({option:e,popupContext:t,confirm:n}){let r=e?._raw??e??{},i=YA(r);if(i){let e=await MA({targetModule:PA,sourceModule:FA,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(!KA(r))return!0;let a=t?.navigate;return!a||!i?!1:new Promise(e=>{n({title:`Candidate update required`,content:RA,okText:`OK`,cancelText:`Cancel`,onOk:async()=>{let t=await QA(r);t&&a(t),e(!1)},onCancel:()=>e(!1)})})}function ej(e,t,n){return{...e,label:`${e.label} - ${NA}`,disabled:!0,title:`${NA}${t?` (submission ${t})`:``}`,alreadySubmitted:!0,existingSubmissionId:t||``,...n?{submittedAt:n}:{}}}var tj={searchOptions:async(e,t,n)=>{if(e.searchFetchKey===`quickSubmitJobList`){let e=n.selectedRecords?.[0]??{},r=e.id??e._id??n.selectedIds?.[0],i,a=!0;try{i=await Ee({searchQuery:t,candidateId:r})}catch{a=!1;let e=await Xn({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 ej(e,e._raw?.jobSubmissionId||``,e._raw?.submittedAt||``);if(e._raw?.disable){let t=String(e._raw?.message??``).trim();return{...e,disabled:!0,label:t?`${e.label} - ${t}`:e.label,title:t}}return e});let s=await Oe({applicantId:r,jobIds:o.map(e=>e.value)}).catch(()=>new Map);return o.map(e=>{let t=s.get(String(e.value));return t?ej(e,t.submissionId,t.submittedAt):e})}if(e.searchFetchKey===`quickSubmitCandidates`){let e=n.selectedRecords?.[0]??{},r=n.jobId??e.jobId??e.id??e._id??n.selectedIds?.[0],i,a=new Map;try{i=await De({search:t,jobId:r})}catch{let e=await ns({isFromSubmission:n.isFromSubmission,jobId:r,submissionId:n.submissionId,search:t});i=Array.isArray(e)?e:[],a=await Oe({jobId:r,applicantIds:i.map(YA)}).catch(()=>new Map)}return i.map(e=>JA(e)).map(e=>{let t=a.get(YA(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:NA,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=>YA(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(KA(u?._raw))throw Error(RA);let p=await MA({targetModule:PA,sourceModule:FA,recordId:l});if(p.severity===`block`)throw Error(p.message);let m=f,h=u?._raw?.existingSubmissionId||u?._raw?.jobSubmissionId||d?.existingSubmissionId||d?._raw?.jobSubmissionId||``;try{let e=await Te({jobId:c,applicantId:l});m||=!!e?.exists,h=e?.submissionId||h}catch(e){throw Error(`Could not verify existing submissions (${e?.message??`request failed`}). Please try again.`,{cause:e})}if(m)throw Error(`This candidate is already submitted for this job${h?` (submission ${h})`:``}.`);let g=new URLSearchParams;l&&g.set(`candidateId`,l);let _=u?.priorSubmissionId||u?._raw?.submissionId||d?.priorSubmissionId||d?._raw?.submissionId||``;_?(g.set(`submissionId`,String(_)),g.set(`isFromSubmission`,`true`)):g.set(`isFromSubmission`,`false`);let v=$o(ts({jobId:c,applicantId:l}).catch(()=>[]));return r(`/submission-create/${c}?${g.toString()}`,{state:{relevantSkillsToken:v}}),{navigated:!0}}},nj={title:`Submit`,okText:`Submit`,width:640,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getNote:e=>e.moduleName===`candidate`?`Note: Select a job to submit this candidate.`:`Note: Select a candidate to submit for this job`,getFields:e=>e.jobId?[]:e.moduleName===`candidate`?[{name:`jobId`,label:`Job list`,type:`search-select`,required:!0,placeholder:`Search Job ID / job name - or pick a recent job`,searchFetchKey:`quickSubmitJobList`,optionLayout:{id:`{jobReferenceId}`,title:`{jobTitle}`,subtitle:`{clientJobReferenceId}`,meta:[{label:`Created`,key:`createdAt`,type:`date`},{label:`Updated`,key:`updatedAt`,type:`relative`}]}}]:[{name:`candidate`,label:`Candidate`,type:`search-select`,required:!0,placeholder:`Search candidate name / email - or pick a recent candidate`,optionsKey:`candidateOptions`,searchFetchKey:`quickSubmitCandidates`,labelTemplate:`{applicantRefrenceId} - {firstName} {lastName} - {createdAgo}`,valueKey:`applicantId`,optionLayout:{id:`{applicantRefrenceId}`,title:`{firstName} {lastName}`,titleAccent:{key:`createdAgo`,toneKey:`createdAgoTone`,prefix:` - `},subtitle:`{designation} - {email}`,meta:[{label:`Created`,key:`createdAt`,type:`date`},{label:`Updated`,key:`updatedAt`,type:`relative`}]},onSelectGuard:$A}]},rj={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`}]},ij=e=>e?.data??e;async function aj({relatedId:e,notes:n,title:r,notesFor:i}){return ij(await Mn(t.x,`/notes`,{method:`POST`,body:JSON.stringify({relatedId:e,notes:n,title:r,notesFor:i})}))}var oj={getMentionOptions:async(e,t)=>oe(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 aj({relatedId:String(n),notes:e.notes,notesFor:t.moduleName})}},sj={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}`},cj={name:`hiringStage`,label:`Hiring stage`,type:`select`,required:!0,optionsKey:`hiringStageOptions`,defaultOptions:[{label:`Shortlisted`,value:`shortlisted`},{label:`Pipeline`,value:`pipeline`}],initialValueKey:`hiringStage`},lj={title:`Tag to Jobs`,okText:`Tag`,width:480,disabledUntilFilled:!0,autoSubmitWhenNoFields:!0,getFields:e=>e.jobId&&e.hiringStage?[]:e.jobId?[cj]:[sj,cj]},uj=e=>e?.data??e;function dj(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 fj(e){return e?Array.isArray(e.data)?e.data.map(dj):e.stage&&Array.isArray(e.stage.data)?e.stage.data.map(dj):Array.isArray(e)?e.map(dj):[]:[]}async function pj(e=1,n=10){let r=await t.o(t.x,`/workflow/list/all?page=${e}&limit=${n}`),i=uj(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 mj(e,n){let r=uj(await t.o(t.x,`/workflow/${e}/stage/${n}`));return Array.isArray(r)?{data:r}:r}async function hj(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=uj(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 gj(e){return uj(await t.o(t.T,`/source/workflow-instance`,{method:`POST`,body:JSON.stringify(e)}))}var _j={pipeline:`pipeline`,goodfited:`goodfited`,contacted:`contacted`,submitted:`submitted`,shortlisted:`shortlisted`,interviewinprogress:`interviewInprogress`,selected:`selected`};function vj(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 yj(e){let t=String(e??``).trim();return t?_j[t.toLowerCase()]??t:``}function bj(e,t){let n=vj(e,`candidateId`,`candidate_id`,`applicantId`,`applicantID`,`applicantReferenceId`,`applicantRefrenceId`,`_id`,`id`)??t;if(!n)return null;let r=(vj(e,`candidateName`,`candidate_name`,`fullName`,`name`)??[vj(e,`firstName`,`first_name`),vj(e,`lastName`,`last_name`)].filter(Boolean).join(` `))||void 0,i={candidateId:String(n),candidateName:r,phone:vj(e,`phone`,`phoneNumber`,`phone_number`,`mobile`,`mobileNumber`,`mobile_number`),source:vj(e,`source`,`sourceType`,`candidateSource`,`profileSource`),submittedAt:vj(e,`submittedAt`,`lastSubmittedAt`,`updatedAt`),remarks:vj(e,`remarks`,`comment`,`comments`,`notes`),assignedRecruiter:vj(e,`assignedRecruiter`,`recruiterName`,`ownerName`,`assignedToName`),screeningStatus:vj(e,`screeningStatus`,`screening.status`,`screeningResult`),screeningScore:vj(e,`screeningScore`,`screening.score`,`score`),assignedDate:vj(e,`assignedDate`,`assignedAt`,`createdAt`)};return Object.fromEntries(Object.entries(i).filter(([,e])=>e!=null&&e!==``))}var xj={searchOptions:async(e,t)=>e.searchFetchKey===`tagToJobJobList`?ae(t):[],submit:async(e,t)=>{let n=e.jobId??t.jobId,r=Array.isArray(n)?n:[n].filter(Boolean),i=yj(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=bj(o[t]??{},n);await gj({jobId:e,module:`jobs`,currentStage:i,...r?{candidateDetails:r}:{}})}await G({jobId:n,candidateIds:t.selectedIds,hiringStage:i})}},Sj={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 Cj(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 wj={submit:async(e,t,n)=>{let r=Cj(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 U(t.moduleName,t.selectedIds,a)}},Tj={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:[]},Ej={onOk:async e=>{await ke({jobId:e.jobId??e.selectedIds[0],candidateIds:e.selectedIds})}},Dj={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`}]},Oj={getOptions:async e=>e.fetchOptionsKey===`candidateGroups`?le():[],submit:async(e,t,{dynamicOptions:n})=>{let r=(n.groupId??[]).find(t=>String(t.value)===String(e.groupId));await ue({candidateIds:t.selectedIds,groupId:e.groupId,groupName:r?.label??``})}},kj=[{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 Aj({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 de({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:kj,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`})]})]})}Aj.propTypes={selectedIds:p.default.array,onClose:p.default.func};var jj={title:`Self Assign`,width:480,className:`self-assign-modal`,component:Aj},Mj={submit:async()=>{}};function Nj(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 Pj={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=>(Nj(e?.selectedRecords?.[0]??{}),[{name:`assignToUserId`,label:`Assign to`,type:`multi-select`,required:!0,placeholder:`Select recruiter(s)`,fetchOptionsKey:`assignToUsers`}])},Fj={getOptions:async(e,t,n)=>e.fetchOptionsKey===`assignToUsers`?me(n?.selectedIds?.[0]):[],loadExtraData:async e=>ge(e.selectedIds[0]),removeAssignedUser:async({id:e},t)=>K({jobId:t.selectedIds[0],userId:e}),submit:async(e,t,{removedIds:n,extraData:r})=>{await ye({jobIds:t.selectedIds,userId:e.assignToUserId,removedIds:n,existingRecruiters:r?.recruitersData})}},Ij={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`}]},Lj={getMentionOptions:async(e,t)=>oe(t),submit:async(e,t)=>{let n=e.targetDate?e.targetDate.toISOString():``;t.editingNoteId?await W(t.editingNoteId,{title:e.heading,targetDate:n,notes:e.comments}):await se({relatedIds:t.selectedIds,module:t.moduleName,title:e.heading,targetDate:n,notes:e.comments}),window.dispatchEvent(new Event(`sticky-notes:refresh`))}},Rj={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`}]},zj={submit:async(e,t)=>{await be({submissionId:t.selectedRecords?.[0]?.submissionId,isMail:e.sendOnboardingEmail})}};function Bj(e){return Array.isArray(e)?e[e.length-1]??{}:e&&typeof e==`object`?e:{}}var Vj={USD:`$`,INR:`₹`,EUR:`€`,GBP:`£`};function Hj(e,t,n){let r=Bj(e?.[t])[n];if(r!=null&&r!==``)return r;let i=e?.[`${t}.${n}`];return i!=null&&i!==``?i:void 0}function Uj(e){let t=e.selectedRecords?.[0]??{},n=Hj(t,`candidateRate`,`candidateAcceptedRate`)??Hj(t,`candidateBudget`,`candidateBudgetStart`);if(n===void 0||Number(n)===0)return null;let r=Hj(t,`candidateRate`,`candidateAcceptedCurrency`)??Hj(t,`candidateBudget`,`candidateBudgetCurrency`);return{amount:n,symbol:Hj(t,`candidateRate`,`candidateAcceptedCurrencySymbol`)??Hj(t,`candidateBudget`,`candidateBudgetCurrencySymbol`)??Vj[String(r??``).toUpperCase()]??(r||`$`),unit:Hj(t,`candidateRate`,`candidateAcceptedPayUnit`)??Hj(t,`candidateBudget`,`candidateBudgetUnit`)??``}}var Wj={title:`Approve Rate`,okText:`Approve`,width:520,className:`medium-modal`,successMessage:`Rate approved`,getBodyText:(e,t,n,r,i)=>{let a=Uj(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=Uj(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`}]}]},Gj={submit:async(e,t)=>{let n=t.selectedIds[0];if(await xe(n,{candidateProposedRate:e.candidateProposedRate,candidateProposedRateCurrency:e.candidateProposedRateCurrency,candidateProposedRateUnit:e.candidateProposedRateUnit,submitVia:e.submitVia}),e.submitVia===`VMS`)try{await Se(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 Kj(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 qj(e){let t=await Kj(`/mail-form?${new URLSearchParams({submissionId:e,submissionType:`manager`}).toString()}`);return t.data??t}function Jj(...e){return e.map(e=>e==null?``:String(e).trim()).find(Boolean)??``}var Yj=(e,t)=>!!e&&e.toLowerCase()===Jj(t).toLowerCase();function Xj(e,t,n){let r=Jj(t.submittedBy);return Jj(Yj(r,n)||Yj(r,e.submitSource)||Yj(r,e.supplierName)||Yj(r,e.source)||Yj(r,e.candidateSource)?``:r,e.signatureEmail)}function Zj(e,t={}){let n=Jj(t.employerName,Yv(e),e.supplierName)||void 0;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:Xj(e,t,n),submittedAt:t.createdAt??e.createdAt,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function Qj(e){return Array.isArray(e)?e[e.length-1]:e}function $j(e={}){let t=Qj(e?.proposedRate)?.candidateProposedRate??e?.candidateProposedRate??e?.proposedRateValue,n=Number(t);return Number.isFinite(n)?n:0}function eM(e,t={}){let n=Qj((e?.record?.job??e?.job??t?.job??{})?.jobPayDetails)??{},r=e?.record?.submission??t??{},i=Qj(r?.clientBudget)??r?.clientBudget??{},a=n?.clientBudgetEnd??n?.clientBudgetStart??i?.clientBudgetEnd??i?.clientBudgetStart,o=Number(a);return Number.isFinite(o)?o:0}function tM(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 nM(e={}){return String(e?.rateUnit??`hr`).trim().replace(/^\/+/,``)||`hr`}function rM(e,t={}){let n=Number(e);return Number.isFinite(n)?`${tM(t)}${n}/${nM(t)}`:``}function iM(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 aM(e,t,n,r,i){let a=Number(n?.proposedRate),o=Number.isFinite(a)?a:$j(t),s=Number(n?.clientJobRate),c=Number.isFinite(s)&&s>0?s:eM(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=iM(u,`(?:Proposed\\s*Rate|Pay\\s*Rate)`,rM(o,n)),u=iM(u,`(?:Job\\s*)?Bill\\s*Rate`,rM(c,n)),u}function oM(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 sM(...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(oM).find(Boolean);if(e)return e}return``}function cM(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 lM(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 uM(...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(oM).find(Boolean);if(e)return e}return``}async function dM(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 fM(e,r,i){let a=[],o=await n.Pn(`submissions`,e,`resume`).catch(()=>({data:[]}));a.push(...o?.data??[]);let s=uM(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=uM((Array.isArray(r?.data)?r.data:Array.isArray(r)?r:[])[0])}if(s){let e=await n.Pn(`candidates`,s,`resume`).catch(()=>({data:[]}));a.push(...e?.data??[])}let c=(await Promise.all(a.map(dM))).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 pM(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:lM(e.content?.value??e.Content?.Value??e.contents??e.body??``)}}function mM({context:e,selectedIds:t,selectedRecords:n,moduleName:r,onClose:i}){let a=n?.[0]??{},o=t?.[0]??Av(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 by(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 ky().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([qj(o).then(pM),fM(o,l,a).catch(e=>(console.warn(`Unable to resolve resume attachment:`,e),[]))]),n=l?.record?.submission??a;N({to:aM(e.to,n,b,l,a),cc:aM(e.cc,n,b,l,a),bcc:aM(e.bcc,n,b,l,a),subject:aM(e.subject,n,b,l,a),contents:aM(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 xe(o,{candidateProposedRate:b.proposedRate,candidateProposedRateCurrency:b.currencyRaw??b.currency,candidateProposedRateUnit:b.rateUnit,submitVia:`VMS`,...cM(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=!O&&uO(M.to).length>0&&fO(M.to)&&fO(M.cc)&&fO(M.bcc)&&M.subject.trim()&&M.contents.trim(),I=async()=>{if(!b||!F||A)return;j(!0);let e={candidateProposedRate:b.proposedRate,candidateProposedRateCurrency:b.currencyRaw??b.currency,candidateProposedRateUnit:b.rateUnit};try{await xe(o,{...e,submitVia:`VMS`,...cM(S)});let t=sM(l?.record,a);if(!t)c.message.warning(`Submission approved, but job details were not available to send mail`);else try{await wn({jobId:t,toMail:uO(M.to),ccMail:uO(M.cc),bccMail:uO(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)}},L=(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)(ly,{type:iv,record:l.record,lookups:l.lookups,identity:Zj(a,l.display),referralOptions:m,currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:L,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:[(0,u.jsx)(c.Button,{onClick:()=>D(!1),disabled:A,children:`Cancel`}),(0,u.jsx)(c.Button,{type:`primary`,loading:A,disabled:!F,onClick:I,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)(DO,{value:M,onChange:N,moduleName:`submissions`,ready:!O,title:`Submit Via Mail`,contextRecords:[l.record?.submission??a]})})]})}mM.propTypes={context:p.default.object,selectedIds:p.default.array,selectedRecords:p.default.array,moduleName:p.default.string,onClose:p.default.func};var hM={title:`Manager Approve`,width:780,className:`fa-modal manager-approve-modal`,component:mM},gM={submit:async()=>{}};function _M(...e){return e.map(e=>e==null?``:String(e).trim()).find(Boolean)??``}var vM=(e,t)=>!!e&&e.toLowerCase()===_M(t).toLowerCase();function yM(e,t,n){let r=_M(t.submittedBy);return _M(vM(r,n)||vM(r,e.submitSource)||vM(r,e.supplierName)||vM(r,e.source)||vM(r,e.candidateSource)?``:r,e.signatureEmail)}function bM(e,t={}){let n=t.employerName??e.supplierName??e.submitSource;return{client:t.clientName??e.clientName,role:t.jobTitle??e.jobTitle??e.designation,reqId:t.reqId??e.jobClientRefrenceId??e.mspReqId??e.submissionId,name:t.candidateName||[e.firstName,e.lastName].filter(Boolean).join(` `)||e.candidateFullName,location:t.jobLocation??e.city??e.currentLocation??e.jobLocation,vendor:n,submittedBy:yM(e,t,n),submittedAt:t.createdAt??e.createdAt,email:t.email??e.email,employerLocation:t.employerLocation,employerName:t.employerName}}function xM(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 SM(e){return String(e??``).toLowerCase().replace(/\b\w/g,e=>e.toUpperCase())}function CM({selectedIds:e,selectedRecords:t,onClose:r}){let i=t?.[0]??{},a=e?.[0]??Av(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([by(a,i),n.Dn(`submission`,a).catch(()=>[])]).then(([t,n])=>{if(e)return;let r=xM(n);f(Av(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?SM(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 Ce(d,{submissionId:a,billRate:e.proposedRate,payRate:e.employerRate,currency:e.currencyRaw??e.currency,rateUnit:e.rateUnit,vmsPercent:e.clientVmsPercent}),await xe(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)(ly,{type:cv,record:o.record,lookups:o.lookups,identity:bM(i,o.display),currentUserId:typeof localStorage<`u`?localStorage.getItem(`userId`)??void 0:void 0,actions:h,onClose:()=>r?.(),variant:`popup`})}CM.propTypes={selectedIds:p.default.array,selectedRecords:p.default.array,onClose:p.default.func};var wM={title:`Re-Approve`,width:780,className:`fa-modal manager-approve-modal`,component:CM},TM={submit:async()=>{}},EM=[{id:1,name:`Re-Submission`},{id:2,name:`Candidate doesn't fit into the profile`},{id:3,name:`Incomplete candidate details - (Re-Submission)`}],DM={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:EM.map(e=>({label:e.name,value:e.id}))},{name:`rejectReasonComments`,label:`Comments`,type:`textarea`,required:!0,rows:4}]},OM={submit:async(e,t)=>{let n=EM.find(t=>String(t.id)===String(e.rejectReason));await we({submissionId:t.selectedIds[0],rejectReasonId:e.rejectReason,rejectReason:n?.name??``,rejectReasonComments:e.rejectReasonComments})}},kM={delete:DA,"quick-submit":nj,"add-notes":rj,"tag-to-job":lj,"change-status":Sj,"remove-from-shortlist":Tj,"add-to-groups":Dj,"self-assign":jj,"others-assign":Pj,"sticky-notes":Ij,"move-to-onboarding":Rj,"approve-rate":Wj,"manager-approve":hM,"manager-reapprove":wM,reject:DM},AM={delete:OA,"quick-submit":tj,"add-notes":oj,"tag-to-job":xj,"change-status":wj,"remove-from-shortlist":Ej,"add-to-groups":Oj,"self-assign":Mj,"others-assign":Fj,"sticky-notes":Lj,"move-to-onboarding":zj,"approve-rate":Gj,"manager-approve":gM,"manager-reapprove":TM,reject:OM};function jM(e){let t=e?.data??e;return Array.isArray(t)?t:t?.data??t?.rows??t?.records??t?.items??t?.list??[]}function MM(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 NM(e){let t=String(MM(e,`isDeleted`,`deleted`)).toLowerCase(),n=String(MM(e,`assignmentStatus`,`status`)).toLowerCase();return t!==`true`&&t!==`1`&&![`removed`,`inactive`,`deleted`].includes(n)}function PM(e){let t=MM(e,`candidateName`,`candidate_name`,`fullName`,`name`);return t?String(t):[MM(e,`firstName`,`first_name`),MM(e,`lastName`,`last_name`)].filter(Boolean).join(` `)||`Unnamed candidate`}function FM(e){return String(MM(e,`candidateId`,`candidate_id`,`candidate._id`,`candidate.id`))}function IM(e){return String(MM(e,`workforceEngagementId`,`engagementId`,`_id`,`id`))}function LM(e){return String(MM(e,`batchName`,`name`,`title`,`batch_name`))}function RM({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.Ln(`onboarding`,200,0),n.Ln(`batchCandidates`,1e3,0).catch(()=>[])]))).then(([e,n])=>{t||(o(jM(e)),x(new Map(jM(n).filter(NM).map(e=>[String(MM(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=>[PM(t),MM(t,`email`,`candidateEmail`,`candidate_email`),MM(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(IM(e)));if(!e.length)return;let o=e.map(e=>({record:e,assignment:b.get(FM(e))})).filter(e=>e.assignment);if(o.length){let e=o.map(({record:e})=>PM(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=LM(r.selectedRecords?.[0])||LM(r);await Promise.all(e.map(e=>n.vr(`batchCandidates`,{schemaVersion:1,batchId:S,batchName:o,candidateId:FM(e),workforceEngagementId:IM(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=>IM(e),columns:[{title:`Candidate`,key:`candidate`,render:(e,t)=>PM(t)},{title:`Email`,key:`email`,render:(e,t)=>MM(t,`email`,`candidateEmail`,`candidate_email`)||`—`},{title:`Onboarding status`,key:`status`,render:(e,t)=>MM(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(FM(e));return{disabled:!FM(e)||!IM(e)||!!t,title:t?`Candidate is already added to a batch`:void 0}}},locale:{emptyText:m?`Loading candidates…`:`No onboarding candidates found`}})]})}var zM={text:`input`,string:`input`,textarea:`textarea`,date:`date-picker`,datepicker:`date-picker`,multiselect:`multi-select`,lookup:`search-select`};function BM(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:zM[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=VM(e.successNavigate);return{title:e.label,fields:t,...n?{successNavigate:n}:{}}}function VM(e){let t=String(e??``).trim();return!t||!t.startsWith(`/`)||t.startsWith(`//`)||/^[a-z][a-z0-9+.-]*:/i.test(t)?null:t}function HM(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 UM({apiMap:e={},extraConfigs:r={}}){let i=(0,s.useMemo)(()=>({...AM,...e}),[e]),a=(0,s.useMemo)(()=>{let e={...kM};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.Wr(l.moduleName,`popup`,o).then(n=>{e||p({key:t,config:BM(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 HM(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)(RM,{open:!0,context:h,onClose:_}):(0,u.jsx)(EA,{open:!0,config:m,context:h,onClose:_,api:{...i[o]??{},...g}})}var WM={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`}]},GM={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})=>wn({jobId:e,toMail:t,ccMail:n,bccMail:r,subject:i,contents:a})},KM=WM.vendorColumns.map(e=>({...e,render:e=>e||`-`}));function qM(){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)(WM.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)(WM.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 GM.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&&GM.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([...uO(h.bcc),...z])].join(`, `),showBcc:h.showBcc||z.length>0}),[h,z]);function V(e){let t=new Set(z);g({...e,bcc:uO(e.bcc).filter(e=>!t.has(e)).join(`, `)})}let H=(uO(B.to).length||uO(B.bcc).length)&&fO(B.to)&&fO(B.cc)&&fO(B.bcc)&&B.subject.trim(),ee=e=>e===`myVendor`?T:D;function te(){e(-1)}function ne(){H&&GM.submit({jobId:m,toMail:uO(B.to),ccMail:uO(B.cc),bccMail:uO(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:WM.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:KM,dataSource:re,loading:F,pagination:!1,size:`small`,rowSelection:{selectedRowKeys:L,onChange:e=>{e.length>WM.maxVendorSelect||R(e)}},scroll:{y:`calc(100vh - 340px)`}})}),(0,u.jsx)(`div`,{className:`vendor-share__vendor-footer`,children:(0,u.jsx)(Ve,{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)(DO,{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,` / `,WM.maxVendorSelect,` Vendors selected`]}):null})})]})})}var JM={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].*$/},YM={SINGLE_FILE_COUNT:1,MULTI_FILE_COUNT:5,MAX_FILE_SIZE:2,ALLOWED_FILE_TYPES:[`image/jpeg`,`image/png`,`application/pdf`]},XM={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 ${YM.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.`},ZM={FIRST_NAME_MIN:3,FIRST_NAME_MAX:30},QM={REMARKS_MIN:10,REMARKS_MAX:250},$M={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)}`}},eN={required:(e=`Field`)=>({required:!0,message:XM.REQUIRED(e)}),email:()=>({pattern:JM.EMAIL,message:XM.INVALID_EMAIL}),phone:()=>({pattern:JM.PHONE,message:XM.INVALID_PHONE}),password:()=>({pattern:JM.PASSWORD,message:XM.INVALID_PASSWORD}),alphabets:()=>({pattern:JM.ALPHABETS,message:XM.INVALID_ALPHABETS}),alphanumeric:()=>({pattern:JM.ALPHANUMERIC,message:XM.INVALID_ALPHANUMERIC}),number:()=>({pattern:JM.NUMBER,message:XM.INVALID_NUMBER}),url:()=>({pattern:JM.URL,message:XM.INVALID_URL}),candidateId:(e=`ID`)=>({pattern:JM.CANDIDATE_ID,message:XM.INVALID_CANDIDATE_ID(e)}),remarks:()=>({pattern:JM.REMARKS,message:XM.INVALID_REMARKS,REMARKS_MIN:`Remarks must be at least ${QM.REMARKS_MIN} characters.`,REMARKS_MAX:`Remarks must not exceed ${QM.REMARKS_MAX} characters.`}),designation:()=>({pattern:JM.DESIGNATION,message:XM.INVALID_DESIGNATION}),dob:(e=!0)=>({validator:(t,n)=>{if(!n)return e?Promise.reject(Error(`Date of Birth is required.`)):Promise.resolve();if(!JM.DOB.test(n))return Promise.reject(Error(XM.INVALID_DOB));let r=(0,d.default)(n,`MM/DD/YYYY`,!0);if(!r.isValid())return Promise.reject(Error(XM.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:JM.LINKEDIN,message:XM.INVALID_LINKEDIN}),companyName:()=>({pattern:JM.COMPANY_NAME,message:XM.INVALID_COMPANY_NAME}),firstName:()=>({pattern:JM.FIRST_NAME,message:XM.INVALID_FIRST_NAME,FIRST_NAME_MIN:`First Name must be at least ${ZM.FIRST_NAME_MIN} characters.`,FIRST_NAME_MAX:`First Name must not exceed ${ZM.FIRST_NAME_MAX} characters.`}),firstNameMinLength:()=>({min:ZM.FIRST_NAME_MIN,message:XM.FIRST_NAME_MIN}),firstNameMaxLength:()=>({max:ZM.FIRST_NAME_MAX,message:XM.FIRST_NAME_MAX}),remarksMinLength:()=>({min:QM.REMARKS_MIN,message:XM.REMARKS_MIN}),remarksMaxLength:()=>({max:QM.REMARKS_MAX,message:XM.REMARKS_MAX}),fullName:()=>({pattern:JM.FULL_NAME,message:XM.INVALID_FULL_NAME}),noSpaces:()=>({pattern:JM.NO_SPACES,message:XM.NO_SPACES_ALLOWED}),startsWithCapital:()=>({pattern:JM.STARTS_WITH_CAPITAL,message:XM.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<=YM.MAX_FILE_SIZE))return c.message.error(XM.INVALID_FILE_SIZE),Promise.reject(Error(XM.INVALID_FILE_SIZE));if(!YM.ALLOWED_FILE_TYPES.includes(t.type))return Promise.reject(Error(XM.INVALID_FILE_TYPE))}return Promise.resolve()}}),singleFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>YM.SINGLE_FILE_COUNT)return Promise.reject(Error(XM.SINGLE_FILE_ONLY));let n=t[0];return n.size/1024/1024<YM.MAX_FILE_SIZE?YM.ALLOWED_FILE_TYPES.includes(n.type)?Promise.resolve():Promise.reject(Error(XM.INVALID_FILE_TYPE)):Promise.reject(Error(XM.INVALID_FILE_SIZE))}}),multiFileUpload:()=>({validator:(e,t)=>{if(!t||t.length===0)return Promise.resolve();if(t.length>YM.MULTI_FILE_COUNT)return Promise.reject(Error(XM.INVALID_FILE_COUNT));for(let e of t){if(!(e.size/1024/1024<YM.MAX_FILE_SIZE))return Promise.reject(Error(XM.INVALID_FILE_SIZE));if(!YM.ALLOWED_FILE_TYPES.includes(e.type))return Promise.reject(Error(XM.INVALID_FILE_TYPE))}return Promise.resolve()}})},tN={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)},nN=()=>{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:[eN.required(`Email`),eN.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:[eN.required(`Phone Number`),eN.phone()],validateTrigger:[`onBlur`,`onChange`],children:(0,u.jsx)(c.Input,{maxLength:10,onChange:t=>{e.setFieldsValue({phone:$M.phoneFormatter(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Password`,name:`password`,rules:[eN.required(`Password`),eN.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:[eN.required(`Full Name`),eN.alphabets(),eN.firstNameMinLength(),eN.firstNameMaxLength()],children:(0,u.jsx)(c.Input,{onChange:t=>{e.setFieldsValue({fullName:$M.firstNameFormatter(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Username`,name:`username`,rules:[eN.required(`Username`),eN.alphanumeric()],children:(0,u.jsx)(c.Input,{onChange:t=>{e.setFieldsValue({username:$M.removeExtraSpaces(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Website URL`,name:`website`,rules:[eN.required(`Website URL`),eN.url()],children:(0,u.jsx)(c.Input,{onChange:t=>{e.setFieldsValue({website:$M.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:[eN.required(`MSP Req ID`),eN.candidateId(`MSP Req ID`)],children:(0,u.jsx)(c.Input,{onChange:t=>{e.setFieldsValue({mspreqID:$M.removeExtraSpaces(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Candidate ID`,name:`candidateId`,rules:[eN.required(`Candidate ID`),eN.candidateId(`Candidate ID`)],children:(0,u.jsx)(c.Input,{onChange:t=>{e.setFieldsValue({candidateId:$M.removeExtraSpaces(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:24,children:(0,u.jsx)(c.Form.Item,{label:`Remarks`,name:`remarks`,rules:[eN.required(`Remarks`),eN.remarks(),eN.remarksMinLength(),eN.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:[eN.required(`Designation`),eN.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:[eN.dob()],children:(0,u.jsx)(c.Input,{placeholder:`MM/DD/YYYY`,maxLength:10,onChange:t=>{e.setFieldsValue({dob:$M.dobFormatter(t.target.value)})}})})}),(0,u.jsx)(c.Col,{span:12,children:(0,u.jsx)(c.Form.Item,{label:`Company Name`,name:`companyName`,rules:[eN.required(`Company Name`),eN.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:tN.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:[eN.multiFileUpload()],children:(0,u.jsx)(c.Upload,{multiple:!0,beforeUpload:tN.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:[eN.fileUpload()],children:(0,u.jsx)(c.Upload,{beforeUpload:tN.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 rN({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`]})]})}rN.propTypes={region:p.default.shape({key:p.default.string,label:p.default.string,isHome:p.default.bool}),onExit:p.default.func},rN.defaultProps={region:null,onExit:void 0};function iN(e){return(0,u.jsx)(Hb,{children:(0,u.jsx)(iO,{...e})})}var{Text:aN}=c.Typography,oN=[{label:`Total Jobs`,value:1697,icon:`fileText`},{label:`Active Jobs`,value:1685,icon:`checkCircle`},{label:`My Jobs`,value:600,icon:`user`}],sN={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 cN({stats:e=oN}){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:[sN[e.icon]??sN.fileText,(0,u.jsx)(aN,{children:e.label})]}),(0,u.jsx)(c.Statistic,{value:e.value})]})},e.label))})})}var{Text:lN}=c.Typography;function uN(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 dN(e){return{...e,key:e.USER_ID??e.user_id??e.userId??e.id??e._id,_name:uN(e),_email:e.email??e.EMAIL??e.user_email??``,_role:e.role_name??e.roleName??e.ROLE_NAME??``,_rawRef:e}}function fN(){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.Lr({offset:e,limit:r,searchQuery:a??``}),s=(o.users??[]).map(dN);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)(ch,{listName:`Users`,dataSource:e,fields:[{label:`Name`,value:`_name`,width:220,render:(e,t)=>(0,u.jsxs)(`div`,{children:[(0,u.jsx)(lN,{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:pN}=c.Typography,mN=[{key:`job`,label:`Jobs`},{key:`candidate`,label:`Candidates`},{key:`submissions`,label:`Submissions`}],hN=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`}];function gN({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 _N({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.fi(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.Bi(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:mN.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)(gN,{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 `,mN.find(e=>e.key===f)?.label]})})]})}function vN(){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.Ir();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.zi(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)(ch,{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:hN.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)(_N,{team:e,configType:d},`${e?.teamId}-${d}`)]})]})}var yN=[`view`,`add`,`edit`,`delete`],bN={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 xN(e){return bN[e]??e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function SN(e){let t=yN.filter(t=>e.includes(t)),n=e.filter(e=>!yN.includes(e)).sort();return[...t,...n]}function CN(e){let t=new Set;return Object.values(e).forEach(({permissions:e})=>Object.keys(e??{}).forEach(e=>t.add(e))),SN([...t])}function wN(e){let t=0,n=0;return Object.entries(e).forEach(([e,{permissions:r}])=>{Object.entries(r??{}).forEach(([r,{value:i}])=>{eS(e,r)&&(n++,i===`1`&&t++)})}),{enabled:t,total:n}}function TN(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 EN({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 DN({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 ON({menuName:e,menuData:t,permKeys:n,onChange:r,displayName:i,actionLabels:a,onModuleLabelSave:o,onActionLabelSave:s}){let c=t?.permissions??{},l=n.filter(t=>eS(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)(EN,{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)(DN,{entry:c[t],label:a[t]??xN(t),onToggle:()=>r(e,t),onLabelSave:e=>s(t,e)},t))})]})}function kN({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.si(e);(0,s.useEffect)(()=>{b&&(h(!0),y(!1),n.ui(b).then(e=>{let t=TN(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.Li(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)(()=>CN(f),[f]),{enabled:T,total:E}=(0,s.useMemo)(()=>wN(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)(ON,{menuName:e,menuData:f[e],permKeys:w,onChange:x,displayName:t[e]??e,actionLabels:r,onModuleLabelSave:i,onActionLabelSave:a},e))})]})}var{Text:AN}=c.Typography,jN=[{key:`listView`,label:`List View`},{key:`filter`,label:`Filter`},{key:`form`,label:`Form`},{key:`permissions`,label:`Permissions`}];function MN(e){return String(e||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}function NN(e){return String(e||``).trim().toLowerCase()}function PN(e){return e?.key||e?.collectionName||e?.value||``}function FN(e=[],t=[]){let n=[],r=new Set,i=new Set,a=new Set;return e.forEach(e=>{let t=PN(e);if(!t)return;let o=NN(e.key||t),s=NN(e.collectionName);e.seeded&&(i.add(o),s&&i.add(s)),s&&a.add(s),r.add(t),n.push({label:e.label||MN(t),value:t,disabled:!!e.seeded})}),t.forEach(e=>{let t=String(e||``).trim();if(!t||r.has(t))return;let o=NN(t);a.has(o)||i.has(o)||(r.add(t),n.push({label:MN(t),value:t,disabled:!1}))}),n}function IN(){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.Fr();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.qr(),n.zr()]),r=FN(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.Di(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)(AN,{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)(ch,{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:jN.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)(kN,{role:e},e?.roleId):(0,u.jsx)(_S,{role:e,configType:a},`${e?.roleId}-${a}`))]})]})}var LN=`perm-module-labels`,RN=`perm-action-labels`;function zN(e){try{return JSON.parse(localStorage.getItem(e)??`{}`)}catch{return{}}}function BN(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function VN({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 HN({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.ei())}catch{c.message.error(`Failed to load modules`)}finally{f(!1)}}async function O(){b(!0);try{v(await n.$r())}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.gr({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.Ni(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.Tr(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.hr({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.Mi(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.wr(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)(VN,{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)(VN,{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 UN(){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)(()=>zN(LN)),[_,v]=(0,s.useState)(()=>zN(RN)),y=(0,s.useCallback)((e,t)=>{g(n=>{let r={...n,[e]:t};return BN(LN,r),r})},[]),b=(0,s.useCallback)((e,t)=>{v(n=>{let r={...n,[e]:t};return BN(RN,r),r})},[]);function x(){g({}),v({}),BN(LN,{}),BN(RN,{}),c.message.success(`Labels reset to defaults`)}let S=(0,s.useCallback)(async()=>{i(!0);try{let{roles:e}=await n.Fr();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)(kN,{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)(HN,{open:p,onClose:()=>m(!1)})]})}var{Title:WN,Text:GN}=c.Typography,KN=[{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 qN({items:e=KN}){return(0,u.jsx)(c.Card,{className:`onboarding-card`,title:(0,u.jsx)(WN,{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)(GN,{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)(GN,{className:`onboarding-item-sub`,children:e.sub})})]})},e.label))})})}var{Text:JN,Title:YN}=c.Typography,XN=[{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.`}]}]}],ZN=[{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}],QN=[{name:`Tcs`,jobs:14,candidates:86},{name:`Empasis`,jobs:9,candidates:64},{name:`NovaSystems`,jobs:7,candidates:51},{name:`Brightwave`,jobs:5,candidates:38}],$N=[{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 eP(){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)(YN,{level:5,children:`Admin Dashboard`}),(0,u.jsx)(JN,{type:`secondary`,children:`Overview of jobs, candidates, onboarding and recent activity`})]}),(0,u.jsx)(`div`,{className:`admin-dashboard-stats`,children:(0,u.jsx)(cN,{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)(qN,{}),(0,u.jsxs)(Z,{icon:(0,u.jsx)(l.AppstoreOutlined,{}),title:`Candidate Pipeline`,children:[(0,u.jsx)(JN,{type:`secondary`,style:{fontSize:12},children:`By stage (892 total)`}),(0,u.jsx)(`div`,{className:`admin-pipeline-bar`,children:ZN.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:ZN.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)(JN,{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)(JN,{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)(JN,{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)(JN,{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:QN.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:$N.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)(JN,{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)(JN,{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)(JN,{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)(JN,{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)(JN,{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)(JN,{style:{fontSize:12},children:e}),(0,u.jsx)(JN,{strong:!0,style:{fontSize:12},children:t})]},e))]})]})})]})}function tP({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)(YN,{level:5,children:e?.heading}),(0,u.jsx)(JN,{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)(JN,{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:XN.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 nP(){let[e,t]=(0,s.useState)(`dashboard`),[n,r]=(0,s.useState)(``),i=(0,s.useMemo)(()=>XN.flatMap(e=>e.items),[]),a=(0,s.useMemo)(()=>i.find(t=>t.id===e),[i,e]),o=(0,s.useMemo)(()=>XN.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)(()=>XN.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:XN.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)(eP,{}):a?.component===`form-groups`?(0,u.jsx)(hw,{}):a?.component===`detail-groups`?(0,u.jsx)(Yw,{}):a?.component===`row-actions`?(0,u.jsx)(zT,{}):a?.component===`users`?(0,u.jsx)(fN,{}):a?.component===`teams`?(0,u.jsx)(vN,{}):a?.component===`roles`?(0,u.jsx)(IN,{}):a?.component===`permissions`?(0,u.jsx)(UN,{}):a?.component===`templates`?(0,u.jsx)(ZT,{}):a?.component===`ai-services`?(0,u.jsx)(iE,{}):a?.component===`bgc-integration`?(0,u.jsx)(uE,{}):(0,u.jsx)(tP,{activeSection:a,activeGroup:o,filteredCards:d,searchText:n,setSearchText:r,allItems:i,handleNav:p})})]})]})}var{Title:rP}=c.Typography;function iP(){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:aP,Title:oP}=c.Typography,sP=10485760,cP=`/templates/test_cases_flow_template.base64.txt`,lP=`test_cases_flow_template.xlsx`,uP=`module | subModule | step_order | description | actions | key | value | expected | scenario`,dP={idle:0,module_set:1,encoding:1,validating:2,preview:3,inserting:3,done:4,error:1},fP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Bulk upload`,href:`/bulk-upload`}];function pP(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 mP(e){return e.filter(e=>e.row_status===`valid`).map(e=>{let t={...e};return delete t.row_status,delete t.errors,t})}function hP(e){return e.flatMap(e=>(e.errors??[]).map(t=>({id:e.id,...t})))}function gP({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 _P({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 vP({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)(aP,{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)(gP,{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 yP(){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=hP(x),N=h===`encoding`||h===`validating`,P=!!p&&!N,F=dP[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 ax({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>sP){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 pP(e);g(`validating`);let i=await ex({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(cP);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=lP,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:mP(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:fP})}),r?.name&&(0,u.jsx)(c.Col,{children:(0,u.jsx)(aP,{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)(oP,{level:3,children:`Bulk upload test cases`}),(0,u.jsxs)(c.Space,{direction:`vertical`,size:4,children:[(0,u.jsx)(aP,{type:`secondary`,children:uP}),(0,u.jsx)(aP,{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)(_P,{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)(vP,{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)(aP,{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)(aP,{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)(aP,{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 bP=[{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:xP}=c.Typography,SP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}],CP={tags:`regression`,active:1},wP={module:{dbName:`Modules`,formField:`module`,label:`Module`}};function TP(e=[]){return e.map(e=>({value:e,label:e}))}function EP(e=``){return String(e??``).trim()}function DP(e=``){return EP(e).toLowerCase()}function OP(e=[]){let t=new Map;return e.forEach(e=>{let n=EP(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function kP(e=[],t,n){let r=EP(t).toLowerCase(),i=EP(n).toLowerCase();return e.reduce((e,t)=>{let n=EP(t?.module).toLowerCase(),a=EP(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 AP({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)(xP,{strong:!0,className:`v1-section-label`,children:t})]})}function jP(){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=wP[v.typeKey],O=(0,s.useMemo)(()=>TP(r),[r]),k=c.Form.useWatch(`module`,e),A=c.Form.useWatch(`flow`,e),j=!!EP(k),M=!!EP(A),N=!j,P=!j||!M,F=(e,t=[])=>{e===`module`&&i(t)},I=async()=>{h(!0);try{let e=await Yb(wP.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=EP(t);if(o([]),p([]),e.setFieldsValue({step_order:void 0}),n){_(!0);try{let e=await $b({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];o(t),p(OP(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=EP(t),a=EP(n);if(!i||!a){e.setFieldsValue({step_order:void 0});return}C(!0);try{e.setFieldsValue({step_order:kP(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:EP(t.module),flow:EP(t.flow),step_order:Number(t.step_order),description:EP(t.description),keyword:DP(t.keyword),target:EP(t.target),value:EP(t.value),expected:EP(t.expected),tags:t.tags?EP(t.tags):CP.tags,active:Number(t.active)};T(!0);try{await Qb(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]:EP(n)})},V=t=>{e.setFieldsValue({module:EP(t),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:CP.tags,value:void 0,expected:void 0})},H=t=>{e.setFieldsValue({flow:EP(t),step_order:void 0})},ee=e=>{let n=wP[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=EP((await t.validateFields()).name),r=await Xb({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:SP})}),(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)(xP,{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:CP,onFinish:z,autoComplete:`off`,children:[(0,u.jsx)(c.Card,{className:`v1-card`,title:(0,u.jsx)(AP,{icon:(0,u.jsx)(l.FileTextOutlined,{}),title:`Test Case Details`}),extra:(0,u.jsx)(xP,{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:bP,onChange:t=>e.setFieldsValue({keyword:DP(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:EP(e.target.value)})}})}),(0,u.jsx)(c.Form.Item,{label:`Type`,name:`type`,children:(0,u.jsx)(c.Input,{disabled:!0})})]})})]})})]})}var{Text:MP}=c.Typography,NP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`}];function PP(e=``){return String(e??``).trim()}function FP(e=[],t){return e.map(e=>({value:e.id,label:e[t]}))}var IP=[{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`})}],LP={key:!1,value:!1,expected:!1};function RP(e,t){return t?e[t]??LP:LP}function zP(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function BP(){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)(bP),[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)(()=>RP(x,F),[x,F]),z=(0,s.useMemo)(()=>FP(p,`modulename`),[p]),B=(0,s.useMemo)(()=>FP(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 Zb();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 ax({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 cx({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([dx({product_parent_ID:t,module_parent_ID:n,submodule_parent_ID:r,actions:i,limit:1e3}),mx({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]),U=(0,s.useCallback)(async(e=``)=>{if(!(!d?.id||!N||!P)){O(!0);try{let t=await dx({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]),ie=(0,s.useCallback)(async()=>{if(!(!a||!d?.name)){M(!0);try{let t=await px(a);await ne(d.name,t.module);let n=await dx({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 ie()})},[d,r,ee,te,a,ie]),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:NP})}),(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)(MP,{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:PP(t.description),actions:PP(t.actions),key:PP(t.key),value:PP(t.value),expected:PP(t.expected),scenario:+!!t.scenario,active:+!!t.active};A(!0);try{if(o){await hx(a,{...n,step_order:Number(t.step_order)}),c.message.success(`Test case updated successfully.`),r(`/viewTestCase`);return}await fx(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}),zP(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}),zP(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)(MP,{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=RP(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}),zP(e,[`key`,`value`,`expected`]),U(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)(ch,{listName:`Added Steps`,loading:D,fields:IP,dataSource:_,current:1,pageSize:Math.max(_.length,1),total:_.length,rowSelection:!1,className:`zt-list-plain zt-list-static`})})]})})]}):null}var{Text:VP}=c.Typography,HP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`}];function UP(){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([ax({project:e}),cx({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 sx(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 ox({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:HP})}),(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)(VP,{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)(ch,{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)(VP,{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:WP}=c.Typography,GP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Manage Modules`,href:`/manageModules`},{label:`Manage Submodules`,href:`/test-cases/zinnext/submodules`}];function KP(){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 cx({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 ux(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 lx({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:GP})}),(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)(WP,{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)(WP,{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)(ch,{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)(WP,{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:qP}=c.Typography,JP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/addTestCase`},{label:`Table`,href:`/viewTestCase`}];function YP(){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 dx({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 gx(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:JP})}),(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)(qP,{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)(ch,{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 XP=[{label:`Home`,href:`/`},{label:`Test Cases`,href:`/test-cases`}];function ZP(){return(0,u.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,u.jsx)(n.s,{items:XP}),(0,u.jsx)(Xo,{moduleName:`test-flows`,rowKey:`id`})]})}var{Text:QP}=c.Typography,$P=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}],eF={tags:`regression`,active:1},tF={module:{dbName:`Modules`,formField:`module`,label:`Module`}},nF={key:!1,value:!1,expected:!1};function rF(e,t){return t?e[t]??nF:nF}function iF(e,t){e.setFields(t.map(e=>({name:e,errors:[]})))}function aF(e=[]){return e.map(e=>({value:e,label:e}))}function oF(e=``){return String(e??``).trim()}function sF(e=[]){let t=new Map;return e.forEach(e=>{let n=oF(e?.flow),r=n.toLowerCase();n&&!t.has(r)&&t.set(r,n)}),Array.from(t.values()).map(e=>({value:e,label:e}))}function cF(e=[],t,n){let r=oF(t).toLowerCase(),i=oF(n).toLowerCase();return e.reduce((e,t)=>{let n=oF(t?.module).toLowerCase(),a=oF(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 lF({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)(QP,{strong:!0,className:`v1-section-label`,children:t})]})}function uF(){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)(bP),[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=tF[S.typeKey],M=(0,s.useMemo)(()=>aF(r),[r]),N=c.Form.useWatch(`module`,e),P=c.Form.useWatch(`flow`,e),F=c.Form.useWatch(`keyword`,e),I=!!oF(N),L=!!oF(P),R=!I,z=!I||!L,B=(0,s.useMemo)(()=>rF(g,F),[g,F]),V=(e,t=[])=>{e===`module`&&i(t)},H=async()=>{y(!0);try{let e=await Yb(tF.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 Zb();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=oF(t);if(o([]),p([]),e.setFieldsValue({step_order:void 0}),n){x(!0);try{let e=await rx({limit:1e4,offset:0,module:n}),t=Array.isArray(e?.items)?e.items:[];o(t),p(sF(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=oF(t),a=oF(n);if(!i||!a){e.setFieldsValue({step_order:void 0});return}D(!0);try{e.setFieldsValue({step_order:cF(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:oF(t.module),flow:oF(t.flow),step_order:Number(t.step_order),description:oF(t.description),keyword:oF(t.keyword),target:oF(t.target),value:oF(t.value),expected:oF(t.expected),tags:t.tags?oF(t.tags):eF.tags,active:Number(t.active)};k(!0);try{await nx(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)}},U=(t,n)=>{e.setFieldsValue({[t]:oF(n)})},ie=t=>{e.setFieldsValue({module:oF(t),flow:void 0,step_order:void 0,keyword:void 0,description:void 0,target:void 0,tags:eF.tags,value:void 0,expected:void 0}),iF(e,[`keyword`,`target`,`value`,`expected`])},ae=t=>{e.setFieldsValue({flow:oF(t),step_order:void 0,keyword:void 0,target:void 0,value:void 0,expected:void 0}),iF(e,[`keyword`,`target`,`value`,`expected`])},oe=t=>{let n=rF(g,t);e.setFieldsValue({keyword:oF(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}),iF(e,[`target`,`value`,`expected`])},se=e=>{let n=tF[e];C({open:!0,typeKey:e}),t.setFieldsValue({name:``,type:n.label})},W=()=>{C(e=>({...e,open:!1})),t.resetFields()},ce=async()=>{try{let n=oF((await t.validateFields()).name),r=await Xb({name:n,type:j.dbName});V(S.typeKey,r?.items??[]),e.setFieldsValue({[j.formField]:n}),c.message.success(`${j.label} added successfully.`),W()}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:$P})}),(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)(QP,{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:eF,onFinish:re,autoComplete:`off`,children:[(0,u.jsx)(c.Card,{className:`v1-card`,title:(0,u.jsx)(lF,{icon:(0,u.jsx)(l.FileTextOutlined,{}),title:`LMS Case Details`}),extra:(0,u.jsx)(QP,{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:ie})}),(0,u.jsx)(c.Button,{"aria-label":`Add module`,icon:(0,u.jsx)(l.PlusOutlined,{}),style:{marginTop:30},onClick:()=>se(`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:ae,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:oe})})}),(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=>U(`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=>U(`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=>U(`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=>U(`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=>U(`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:W,onOk:()=>{T(!0),ce()},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:oF(e.target.value)})}})}),(0,u.jsx)(c.Form.Item,{label:`Type`,name:`type`,children:(0,u.jsx)(c.Input,{disabled:!0})})]})})]})})]})}var dF=[{label:`Home`,href:`/`},{label:`LMS Cases`,href:`/lms-cases`}];function fF(){return(0,u.jsxs)(`main`,{className:`jobs-list-page`,children:[(0,u.jsx)(n.s,{items:dF}),(0,u.jsx)(Xo,{moduleName:`lms-flows`,rowKey:`id`})]})}var pF=[`referenceId`,`ReferenceId`,`candidateId`,`CandidateId`,`entityId`,`EntityId`,`id`,`Id`,`_id`];function mF(e=pF){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 hF(e,t=pF){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 gF=mF();function _F(e){return typeof e==`function`?e:typeof e==`string`?mF([e]):Array.isArray(e)?mF(e):gF}function vF(e,t,n){return!t||typeof t!=`object`?e:{...t,...e,id:e?.id??t?.id??n}}function yF(e,t,n={}){return{status:`success`,total:t,data:{data:e,...n}}}var bF=[`fields`,`fieldConfig`,`tabs`,`tabField`,`actionRules`,`actions`,`columnActions`];function xF(e){let t=e?.data??e,n={};for(let r of bF){let i=e?.[r]??t?.[r];i==null||Array.isArray(i)&&i.length===0||(n[r]=i)}return n}var SF=e=>String(e??``).replace(/[^a-zA-Z0-9]/g,``).toLowerCase();function CF(e,t,n){let r=(Array.isArray(n)?n:[n]).map(SF).filter(Boolean),i=r.length?e.findIndex(e=>r.includes(SF(e?.value))||r.includes(SF(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 wF=(e,t)=>mi(e,t).rows,TF=(e,t)=>{let{rows:n,total:r}=mi(e,t);return{rows:n,total:r}};function EF(e,t){return function(n,r,i,a={}){return e(t??n,r,i,a)}}function DF(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:wF,mergeRow:typeof e.mergeRow==`function`?e.mergeRow:vF,fetchById:typeof e.fetchById==`function`?e.fetchById:null}}function OF({fetchSecondaryByKeys:e,fetchSecondary:t,extractSecondaryRows:n,fetchSecondaryById:r,secondaryKey:i,mergeRow:a,secondaryFetchLimit:o}){return!e&&!t&&!r?[]:[DF({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 kF(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:pF;return e=>hF(e,t)}function AF(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 jF({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 MF(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 NF({fetchPrimaryPage:e,extractPrimaryPage:t=TF,fetchSecondaryByKeys:n,joinSources:r=[],fetchPrimary:i,extractPrimaryRows:a=wF,fetchSecondary:o,extractSecondaryRows:s=wF,fetchSecondaryById:c,primaryKey:l,secondaryKey:u,mergeRow:d=vF,secondaryFetchLimit:f=200,extraFields:p=[],extraFieldsAfter:m}){let h=Array.isArray(r)&&r.length?r.map(DF).filter(Boolean):OF({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=_F(t.primaryKey??l),s=kF(t.key),c=AF(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=xF(e);for(let e of Object.keys(t))r[e]??(r[e]=t[e])}return p.length&&(r.fields=CF(r.fields??[],p,m)),yF(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=_F(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 MF(c,jF({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 PF(e,t,n={}){return NF({fetchPrimary:()=>mj(e,t),extractPrimaryRows:fj,fetchSecondary:Bn,fetchSecondaryById:hj,secondaryFetchLimit:n.moduleFetchLimit??200})}function FF(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 IF(e){let t=Array.isArray(e?.stages)?e.stages:[];if(!t.length)return e;let n={};for(let e of t){let t=FF(e?.stageName);t&&(n[t]=Number(e?.count)||0)}return{...n,...e}}var LF=e=>{let t=Number(e?.targetSubmission??e?.targetSubmissions);return Number.isFinite(t)&&t>0?t:null};function RF({submittedCountField:e=`submittedCount`,progressField:t=`targetSubmissionProgress`}={}){return function(n,r,i){let a=vF(n,r,i),o=LF(a);return o!=null&&(a[t]=`${Number(a?.[e])||0} of ${o}`),a}}function zF(e={}){let t=RF();return NF({primaryKey:`_id`,extraFields:e.extraFields,extraFieldsAfter:e.extraFieldsAfter,fetchPrimaryPage:Bn,joinSources:[{key:`entityId`,fetchByKeys:(e,t,n,r)=>{let i=Math.max(1,Number(r?.limit)||10);return pj(Math.floor((Number(r?.offset)||0)/i)+1,i)},extractRows:e=>(e?.items??[]).map(IF),mergeRow:(e,n,r)=>{let i=t(e,n,r);return n?._id&&(i.workflowId=n._id),i}}]})}async function BF(e,t=10,n=0,r={},i={}){return mi(await zF(i)(e,t,n,r),e)}async function VF(e,t,n,r=10,i=0,a={}){return mi(await PF(e,t)(n,r,i,a),n)}typeof window<`u`&&(window.__CORE_THEME_BUILD__=`2026-09-11T10:35:31.286Z`);var HF=iN,UF=yx(nP),WF=yx(iP),GF=yx(yP),KF=yx(jP),qF=yx(BP),JF=yx(UP),YF=yx(KP),XF=yx(YP),ZF=yx(ZP),QF=yx(uF),$F=yx(fF);exports.ADMIN_API_URL=t.v,exports.ADMIN_APP_ID=t.y,exports.APP_ID=t.b,exports.AUTH_URL=t.x,exports.ActivityNotesCard=Zc,exports.ActivityTab=Bc,exports.AddBatchCandidatePopup=RM,exports.AddFormV1=Cc,exports.AdminDashboard=iN,exports.AdminDashboardContent=iO,exports.AdminPage=HF,exports.AppAlert=wc,exports.AppButton=n.Ct,exports.AppShell=Hb,exports.ApprovalActionBar=Q_,exports.AssigneeAvatars=Qc,exports.AuthGuard=Pb,exports.BILLING_STATUS_FLOW=yf,exports.BOOLEAN_API_KEYS=Rg,exports.BOOLEAN_PARSEABLE_API_KEYS=Ch,exports.BULK_UPLOAD_DEFAULT_ACCEPT=$c,exports.BULK_UPLOAD_DEFAULT_MAX_SIZE_MB=el,exports.Breadcrumb=n.s,exports.BulkUploadPage=GF,exports.BulkUploadPanel=cl,exports.CANDIDATES_URL=t.S,exports.CONTRACT_C2C=Sv,exports.CONTRACT_W2=xv,exports.CORE_URL=t.C,exports.CURRENCY_SYMBOLS=bu,exports.CalendarCard=j,exports.CoreThemeAdminApp=cO,exports.CoreThemeAdminRoutes=sO,exports.CustomPagination=Ve,exports.DEFAULT_HOURS_POLICY=b_,exports.DEFAULT_RESULTS_VIEW=Pg,exports.DETAIL_VIEW_MODE_OPTIONS=n.or,exports.DETAIL_VIEW_MODE_VALUES=n.sr,exports.DETAIL_VIEW_POPUP_PATH=n.cr,exports.DayLogModal=W_,exports.DescriptionBlock=xl,exports.DetailHeaderCard=xp,exports.DetailViewPage=Op,exports.DetailViewPopup=fk,exports.DetailViewV1=_d,exports.DocumentViewer=r.t,exports.DynamicCards=Bt,exports.DynamicPopup=EA,exports.DynamicPopupRoute=UM,exports.DynamicTabs=F,exports.EditFormV1=Bm,exports.FIELD_TYPE_REGISTRY=ig,exports.FINANCE_APPROVAL_CONFIG=pv,exports.FINANCE_TYPE_CFO=ov,exports.FINANCE_TYPE_ONBOARDING_MANAGER=av,exports.FINANCE_TYPE_ONBOARDING_MANAGER_REAPPROVE=lv,exports.FINANCE_TYPE_ONLY_FINANCE=sv,exports.FINANCE_TYPE_SUBMISSION_MANAGER=iv,exports.FINANCE_TYPE_SUBMISSION_MANAGER_REAPPROVE=cv,exports.FileListCard=Ay,exports.FinanceApprovalPanel=ly,exports.FinanceAvatar=ep,exports.FinanceBadge=ip,exports.FinanceDayCell=ev,exports.FinanceDivider=Kf,exports.FinanceEmployeeCell=tp,exports.FinanceEmptyState=Uf,exports.FinanceEquation=qf,exports.FinanceHistoryTimeline=Zf,exports.FinanceHoursGrid=Hf,exports.FinanceKpiRow=Vf,exports.FinanceLine=Gf,exports.FinanceListToolbar=y_,exports.FinanceMarginBadge=ap,exports.FinanceMoneyCell=rp,exports.FinanceRecordsTable=cp,exports.FinanceRowChevron=op,exports.FinanceSection=Wf,exports.FinanceStatusPill=Bf,exports.FinanceTextCell=np,exports.FinanceTimesheetAnalysis=nv,exports.FinanceWorkflowSteps=Jf,exports.GATEWAY_URL=t.w,exports.GLOBAL_DEFAULT_FIELDS=xD,exports.HOURS_MESSAGES=x_,exports.Header=sb,exports.HierarchyUserFilter=Gt,exports.JOBS_URL=t.T,exports.LegacyAdminPage=UF,exports.ListView=Xo,exports.LmsHomePage=$F,exports.LmsTestForm=QF,exports.Login=Ub,exports.MailPopup=$O,exports.ManageModules=JF,exports.ManageSubmodules=YF,exports.ModuleRowActions=Ym,exports.NotesPanel=Z_,exports.NotesTab=Xc,exports.OPEN_AS_OPTIONS=Tg,exports.PAYROLL_STATUS_FLOW=bf,exports.PLATFORM_SCOPES=vD,exports.POPUP_CONFIGS=kM,exports.PYOPS_URL=t.E,exports.ParamCardView=nh,exports.ParamListView=ch,exports.PeriodBadgeTag=N_,exports.PlatformSection=jD,exports.PreviewPopup=uk,exports.ProjectSelect=vx,exports.ProofUploadPreview=X_,exports.QuickLogBar=q_,exports.QuickLogSelectionBar=G_,exports.RESULTS_VIEW_OPTIONS=Ng,exports.RegionBanner=rN,exports.RejectionReasonModal=K_,exports.SUBMISSIONS_URL=t.D,exports.SearchBuilderV1=u_,exports.Sidebar=Ab,exports.StatusBadge=f_,exports.StatusBadgeTag=M_,exports.StickyNotesFullPage=WF,exports.StylishDynamicTabs=m_,exports.TemplateEditor=g_,exports.TestForm=KF,exports.TestingHomePage=ZF,exports.TimelineGroups=Mc,exports.TimesheetDayCell=V_,exports.TipTapEditor=n.Vn,exports.UserForm=nN,exports.VendorShareDrawer=qM,exports.ViewSummaryWidget=Bi,exports.WizardPopup=vk,exports.ZINNEXT_URL=t.O,exports.ZinnextTableView=XF,exports.ZinnextTestForm=qF,exports.appNow=n.Gn,exports.applyIntegrationStatus=n.fr,exports.approveSubmission=xe,exports.buildAcceptAttr=al,exports.buildBooleanRequest=Ug,exports.buildCsv=Pf,exports.buildDailyRows=Of,exports.buildDayGradient=z_,exports.buildRateHistoryEntries=qv,exports.buildWeeklyRollup=jf,exports.clearSelectedProject=t.i,exports.colors=n.Wn,exports.computeFinance=zv,exports.computeHoursPolicy=D_,exports.computeMarginBand=Mf,exports.conditionMatches=n.f,exports.configureCoreTheme=t.k,exports.configuredFieldLabel=n.p,exports.createAllWorkflowsListFetcher=zF,exports.createMergedListFetcher=NF,exports.createModuleListFetchAdapter=EF,exports.createWorkflowStageListFetcher=PF,exports.currencySymbol=xu,exports.deactivateRegion=sD,exports.defaultMergeRow=vF,exports.deleteIntegrationConfig=n.Cr,exports.deriveDayStats=Df,exports.describeCapacity=k_,exports.downloadCsv=Rf,exports.evaluateShowIfWith=n.m,exports.findEmployerRow=Nv,exports.flattenGroups=jv,exports.formatAmount=Du,exports.formatApp=n.Kn,exports.formatAppDateTime=n.qn,exports.formatFileSize=il,exports.formatFinanceMoney=Jv,exports.formatHours=uf,exports.formatMoney=Ou,exports.formatPercent=ff,exports.formatRate=ku,exports.getActivity=n.Dn,exports.getAllWorkflowsModuleList=BF,exports.getAppTimeZone=n.Jn,exports.getApprovalDate=gf,exports.getBgcIntegrationConfig=n.Vr,exports.getBgcIntegrationSummary=n.Hr,exports.getBillingActionStates=xf,exports.getBooleanEligibleTypes=ug,exports.getCurrentRoleName=t.c,exports.getDetailDisplayDefaults=n.nr,exports.getFieldLabel=If,exports.getFieldType=og,exports.getFileExtension=rl,exports.getFinanceApprovalConfig=vv,exports.getFormGroupsRaw=yy,exports.getGlobalAiServices=SD,exports.getGlobalDefaults=yD,exports.getIntegrationConfig=n.Jr,exports.getIntegrationConfigs=n.Yr,exports.getIntegrationSummary=n.Xr,exports.getModuleConfig=Le,exports.getModuleDataDetail=n.kn,exports.getPayrollActionStates=Sf,exports.getPeriodBadgeConfig=ze,exports.getRegionDetailDefaults=mD,exports.getSearchPopup=Sg,exports.getSelectedProject=t.l,exports.getStoredToken=t.u,exports.getStoredUser=t.d,exports.getUserRoles=t.f,exports.getVMSApprove=Se,exports.getValueStyle=Lf,exports.getWorkflowStageModuleList=VF,exports.getWorkflowSteps=Cf,exports.grantPlatformAccess=lD,exports.hasPlatformAccess=dD,exports.humanizeEvent=hf,Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return xs}}),exports.indexFieldConfig=Ff,exports.initialsOf=pf,exports.insertTokenAtCursor=Dh,exports.isBooleanEligible=sg,exports.isBooleanParsable=Th,exports.isTester=t.p,exports.listPlatformAccess=cD,exports.listPlatformAudit=pD,exports.listPlatformUsers=fD,exports.listRegionRoles=_D,exports.listRegionUsers=gD,exports.listRegions=aD,exports.loadDetailDefaults=n.rr,exports.logout=t.h,exports.marginIncludesReferral=bv,exports.matchLocationTax=Rv,Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Xp}}),exports.normalizeContract=Fv,exports.normalizeDetailViewMode=n.lr,Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return ll}}),exports.rateUnitLabel=Cu,exports.rateUnitShort=Tu,exports.readActionButtons=kg,exports.reconcileHours=O_,exports.regionPath=iD,exports.registerFieldType=ag,exports.registerSearchPopup=xg,exports.rejectSubmission=we,exports.requiredWhenActive=n.c,exports.requiredWhenRule=n.l,exports.resolveActivityMeta=Lc,exports.resolveAndCompute=Bv,exports.resolveDayKind=T_,exports.resolveFinanceInputs=Lv,exports.resolveMergeKey=gF,exports.resolveMergedListKey=gF,exports.resolveOpenAs=Dg,exports.resolveRejectionReason=yv,exports.resolveResultsSearchPlaceholder=Lg,exports.resolveResultsView=Ig,exports.resolveSubmissionFinance=by,exports.revokePlatformAccess=uD,exports.runDetailViewOpen=n.ur,exports.saveBgcIntegrationConfig=n.yi,exports.saveGlobalAiServices=CD,exports.saveGlobalDefaults=bD,exports.saveIntegrationConfig=n.Si,exports.saveRegion=oD,exports.saveRegionDetailDefaults=hD,exports.setSelectedProject=t._,exports.showIfConditions=n.g,exports.stageCountKey=FF,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Wb}}),exports.testIntegrationConnection=n.ki,exports.toApp=n.Xn,exports.toNumber=Eu,exports.tzLabel=n.Zn,exports.tzShortLabel=n.Qn,exports.unregisterSearchPopup=Cg,exports.useDropdownFields=tr,exports.useDropdownValues=Vi,exports.useEditForm=Ny,exports.useFieldConfig=nr,exports.useFilterFields=rr,exports.useMenuPermission=fr,exports.useModuleActions=Hm,exports.useRecordRefresh=Tp,exports.useTabRows=My,exports.validateBooleanQuery=Eh,exports.validateBulkFile=ol,exports.withAdminAppId=t.A,exports.withAppId=t.j,exports.withAuthGuard=yx;
|
|
8
8
|
//# sourceMappingURL=index.cjs.map
|