ubk.erp.webpack 1.2.9 → 1.3.1
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/README.md +107 -3
- package/dist/Api/api.d.ts +48 -0
- package/dist/Layout/ExpenseDashboard/AddExpense/AddExpense.d.ts +5 -0
- package/dist/Layout/ExpenseDashboard/AddExpense/AddExpenseEdit.d.ts +5 -0
- package/dist/Layout/ExpenseDashboard/AddExpense/index.d.ts +1 -0
- package/dist/Layout/ExpenseDashboard/ExpenseHead/ExpenseHead.d.ts +5 -0
- package/dist/Layout/ExpenseDashboard/ExpenseHead/ExpenseHeadEdit.d.ts +5 -0
- package/dist/Layout/ExpenseDashboard/ExpenseHead/index.d.ts +1 -0
- package/dist/Layout/ExpenseDashboard/SearchExpense/SearchExpense.d.ts +5 -0
- package/dist/Layout/ExpenseDashboard/SearchExpense/index.d.ts +1 -0
- package/dist/Layout/ExpenseDashboard/index.d.ts +3 -0
- package/dist/Layout/IncomeDashboard/AddIncome/AddIncome.d.ts +5 -0
- package/dist/Layout/IncomeDashboard/AddIncome/AddIncomeEdit.d.ts +5 -0
- package/dist/Layout/IncomeDashboard/AddIncome/index.d.ts +1 -0
- package/dist/Layout/IncomeDashboard/IncomeHead/IncomeHead.d.ts +5 -0
- package/dist/Layout/IncomeDashboard/IncomeHead/IncomeHeadEdit.d.ts +5 -0
- package/dist/Layout/IncomeDashboard/IncomeHead/index.d.ts +1 -0
- package/dist/Layout/IncomeDashboard/SearchIncome/SearchIncome.d.ts +5 -0
- package/dist/Layout/IncomeDashboard/SearchIncome/index.d.ts +1 -0
- package/dist/Layout/IncomeDashboard/index.d.ts +3 -0
- package/dist/Layout/StudentInformation/AssignStudentSubject/AssignStudentSubject.d.ts +5 -0
- package/dist/Layout/StudentInformation/AssignStudentSubject/index.d.ts +1 -0
- package/dist/Layout/StudentInformation/BulkUpload/BulkUpload.d.ts +5 -0
- package/dist/Layout/StudentInformation/BulkUpload/index.d.ts +1 -0
- package/dist/Layout/StudentInformation/MedicalReport/MedicalReport.d.ts +5 -0
- package/dist/Layout/StudentInformation/MedicalReport/index.d.ts +1 -0
- package/dist/Layout/StudentInformation/StudentLoginCredential/StudentLoginCredential.d.ts +5 -0
- package/dist/Layout/StudentInformation/StudentLoginCredential/index.d.ts +1 -0
- package/dist/Layout/StudentInformation/index.d.ts +4 -0
- package/dist/Layout/Transport/BulkUpload/index.d.ts +5 -0
- package/dist/index.cjs +13 -13
- package/dist/index.d.ts +11 -0
- package/dist/index.js +11598 -8812
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("antd"),G=require("swr"),_=require("react-hot-toast"),i=require("react"),rt=require("swr/mutation"),ee=require("@ant-design/icons"),ae=require("dayjs"),il=require("react-dom/server"),xa=require("react-to-print"),to=require("react-select"),ao=require("react-barcode"),ol=()=>e.jsxs(n.Card,{style:{borderRadius:16},children:[e.jsx(n.Typography.Title,{level:3,style:{marginTop:0},children:"UBK ERP"}),e.jsx(n.Typography.Paragraph,{style:{marginBottom:0},children:"Welcome to your webpack-powered ERP system."})]}),E=({width:t,height:a,display:s,justifyContent:r,alignItems:o,flexDirection:l,gap:d,style:c,children:g,...f})=>{const u={width:t,height:a,display:s,justifyContent:r,alignItems:o,flexDirection:l,gap:d,...c};return e.jsx("div",{style:u,...f,children:g})},De=({variant:t,fontWeight:a,style:s,children:r,...o})=>{const l=a==="bold"?700:a==="light"?300:a;return t==="h1"?e.jsx(n.Typography.Title,{level:1,style:{fontWeight:l,...s},...o,children:r}):t==="h2"?e.jsx(n.Typography.Title,{level:2,style:{fontWeight:l,...s},...o,children:r}):t==="h3"?e.jsx(n.Typography.Title,{level:3,style:{fontWeight:l,...s},...o,children:r}):t==="h4"?e.jsx(n.Typography.Title,{level:4,style:{fontWeight:l,...s},...o,children:r}):t==="h5"?e.jsx(n.Typography.Title,{level:5,style:{fontWeight:l,...s},...o,children:r}):e.jsx(n.Typography.Text,{style:{fontWeight:l,...s},...o,children:r})};function no({title:t="",icon:a="",path:s="",onClick:r}){const o=()=>{if(r){r(s);return}typeof window<"u"&&typeof s=="string"&&s.length>0&&window.location.assign(s)};return e.jsxs(n.Card,{hoverable:!0,onClick:o,style:{borderRadius:12,overflow:"hidden",boxShadow:"0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.10)"},bodyStyle:{padding:0,cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"stretch"},children:[e.jsx(E,{width:"100%",display:"flex",justifyContent:"center",alignItems:"center",style:{padding:"10px 12px",minHeight:80},children:e.jsx("img",{src:a,alt:"",style:{width:45,height:50,objectFit:"contain"}})}),e.jsx(E,{style:{padding:"0 12px"},children:e.jsx(n.Divider,{style:{margin:0,minWidth:0}})}),e.jsx(E,{style:{padding:"10px 10px",display:"flex",justifyContent:"center",alignItems:"center",minHeight:35},children:e.jsx(De,{variant:"button",fontWeight:"bold",style:{fontSize:12},children:t})})]})}function so(t,a){return function(){return t.apply(a,arguments)}}const{toString:ll}=Object.prototype,{getPrototypeOf:Hn}=Object,{iterator:Kn,toStringTag:ro}=Symbol,Gn=(t=>a=>{const s=ll.call(a);return t[s]||(t[s]=s.slice(8,-1).toLowerCase())})(Object.create(null)),_t=t=>(t=t.toLowerCase(),a=>Gn(a)===t),Jn=t=>a=>typeof a===t,{isArray:ba}=Array,ha=Jn("undefined");function Wa(t){return t!==null&&!ha(t)&&t.constructor!==null&&!ha(t.constructor)&&dt(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const io=_t("ArrayBuffer");function dl(t){let a;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?a=ArrayBuffer.isView(t):a=t&&t.buffer&&io(t.buffer),a}const cl=Jn("string"),dt=Jn("function"),oo=Jn("number"),Ha=t=>t!==null&&typeof t=="object",ul=t=>t===!0||t===!1,Dn=t=>{if(Gn(t)!=="object")return!1;const a=Hn(t);return(a===null||a===Object.prototype||Object.getPrototypeOf(a)===null)&&!(ro in t)&&!(Kn in t)},pl=t=>{if(!Ha(t)||Wa(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},ml=_t("Date"),fl=_t("File"),hl=t=>!!(t&&typeof t.uri<"u"),yl=t=>t&&typeof t.getParts<"u",gl=_t("Blob"),xl=_t("FileList"),bl=t=>Ha(t)&&dt(t.pipe);function jl(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const pr=jl(),mr=typeof pr.FormData<"u"?pr.FormData:void 0,Sl=t=>{if(!t)return!1;if(mr&&t instanceof mr)return!0;const a=Hn(t);if(!a||a===Object.prototype||!dt(t.append))return!1;const s=Gn(t);return s==="formdata"||s==="object"&&dt(t.toString)&&t.toString()==="[object FormData]"},vl=_t("URLSearchParams"),[wl,_l,Cl,Al]=["ReadableStream","Request","Response","Headers"].map(_t),Tl=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Ka(t,a,{allOwnKeys:s=!1}={}){if(t===null||typeof t>"u")return;let r,o;if(typeof t!="object"&&(t=[t]),ba(t))for(r=0,o=t.length;r<o;r++)a.call(null,t[r],r,t);else{if(Wa(t))return;const l=s?Object.getOwnPropertyNames(t):Object.keys(t),d=l.length;let c;for(r=0;r<d;r++)c=l[r],a.call(null,t[c],c,t)}}function lo(t,a){if(Wa(t))return null;a=a.toLowerCase();const s=Object.keys(t);let r=s.length,o;for(;r-- >0;)if(o=s[r],a===o.toLowerCase())return o;return null}const Wt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,co=t=>!ha(t)&&t!==Wt;function Bs(){const{caseless:t,skipUndefined:a}=co(this)&&this||{},s={},r=(o,l)=>{if(l==="__proto__"||l==="constructor"||l==="prototype")return;const d=t&&lo(s,l)||l;Dn(s[d])&&Dn(o)?s[d]=Bs(s[d],o):Dn(o)?s[d]=Bs({},o):ba(o)?s[d]=o.slice():(!a||!ha(o))&&(s[d]=o)};for(let o=0,l=arguments.length;o<l;o++)arguments[o]&&Ka(arguments[o],r);return s}const Dl=(t,a,s,{allOwnKeys:r}={})=>(Ka(a,(o,l)=>{s&&dt(o)?Object.defineProperty(t,l,{value:so(o,s),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,l,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),t),Rl=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),Il=(t,a,s,r)=>{t.prototype=Object.create(a.prototype,r),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:a.prototype}),s&&Object.assign(t.prototype,s)},kl=(t,a,s,r)=>{let o,l,d;const c={};if(a=a||{},t==null)return a;do{for(o=Object.getOwnPropertyNames(t),l=o.length;l-- >0;)d=o[l],(!r||r(d,t,a))&&!c[d]&&(a[d]=t[d],c[d]=!0);t=s!==!1&&Hn(t)}while(t&&(!s||s(t,a))&&t!==Object.prototype);return a},Pl=(t,a,s)=>{t=String(t),(s===void 0||s>t.length)&&(s=t.length),s-=a.length;const r=t.indexOf(a,s);return r!==-1&&r===s},Ol=t=>{if(!t)return null;if(ba(t))return t;let a=t.length;if(!oo(a))return null;const s=new Array(a);for(;a-- >0;)s[a]=t[a];return s},Ml=(t=>a=>t&&a instanceof t)(typeof Uint8Array<"u"&&Hn(Uint8Array)),El=(t,a)=>{const r=(t&&t[Kn]).call(t);let o;for(;(o=r.next())&&!o.done;){const l=o.value;a.call(t,l[0],l[1])}},Fl=(t,a)=>{let s;const r=[];for(;(s=t.exec(a))!==null;)r.push(s);return r},$l=_t("HTMLFormElement"),Ul=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(s,r,o){return r.toUpperCase()+o}),fr=(({hasOwnProperty:t})=>(a,s)=>t.call(a,s))(Object.prototype),Nl=_t("RegExp"),uo=(t,a)=>{const s=Object.getOwnPropertyDescriptors(t),r={};Ka(s,(o,l)=>{let d;(d=a(o,l,t))!==!1&&(r[l]=d||o)}),Object.defineProperties(t,r)},Bl=t=>{uo(t,(a,s)=>{if(dt(t)&&["arguments","caller","callee"].indexOf(s)!==-1)return!1;const r=t[s];if(dt(r)){if(a.enumerable=!1,"writable"in a){a.writable=!1;return}a.set||(a.set=()=>{throw Error("Can not rewrite read-only method '"+s+"'")})}})},Ll=(t,a)=>{const s={},r=o=>{o.forEach(l=>{s[l]=!0})};return ba(t)?r(t):r(String(t).split(a)),s},ql=()=>{},zl=(t,a)=>t!=null&&Number.isFinite(t=+t)?t:a;function Yl(t){return!!(t&&dt(t.append)&&t[ro]==="FormData"&&t[Kn])}const Vl=t=>{const a=new Array(10),s=(r,o)=>{if(Ha(r)){if(a.indexOf(r)>=0)return;if(Wa(r))return r;if(!("toJSON"in r)){a[o]=r;const l=ba(r)?[]:{};return Ka(r,(d,c)=>{const g=s(d,o+1);!ha(g)&&(l[c]=g)}),a[o]=void 0,l}}return r};return s(t,0)},Wl=_t("AsyncFunction"),Hl=t=>t&&(Ha(t)||dt(t))&&dt(t.then)&&dt(t.catch),po=((t,a)=>t?setImmediate:a?((s,r)=>(Wt.addEventListener("message",({source:o,data:l})=>{o===Wt&&l===s&&r.length&&r.shift()()},!1),o=>{r.push(o),Wt.postMessage(s,"*")}))(`axios@${Math.random()}`,[]):s=>setTimeout(s))(typeof setImmediate=="function",dt(Wt.postMessage)),Kl=typeof queueMicrotask<"u"?queueMicrotask.bind(Wt):typeof process<"u"&&process.nextTick||po,Gl=t=>t!=null&&dt(t[Kn]),X={isArray:ba,isArrayBuffer:io,isBuffer:Wa,isFormData:Sl,isArrayBufferView:dl,isString:cl,isNumber:oo,isBoolean:ul,isObject:Ha,isPlainObject:Dn,isEmptyObject:pl,isReadableStream:wl,isRequest:_l,isResponse:Cl,isHeaders:Al,isUndefined:ha,isDate:ml,isFile:fl,isReactNativeBlob:hl,isReactNative:yl,isBlob:gl,isRegExp:Nl,isFunction:dt,isStream:bl,isURLSearchParams:vl,isTypedArray:Ml,isFileList:xl,forEach:Ka,merge:Bs,extend:Dl,trim:Tl,stripBOM:Rl,inherits:Il,toFlatObject:kl,kindOf:Gn,kindOfTest:_t,endsWith:Pl,toArray:Ol,forEachEntry:El,matchAll:Fl,isHTMLForm:$l,hasOwnProperty:fr,hasOwnProp:fr,reduceDescriptors:uo,freezeMethods:Bl,toObjectSet:Ll,toCamelCase:Ul,noop:ql,toFiniteNumber:zl,findKey:lo,global:Wt,isContextDefined:co,isSpecCompliantForm:Yl,toJSONObject:Vl,isAsyncFn:Wl,isThenable:Hl,setImmediate:po,asap:Kl,isIterable:Gl};let Ce=class mo extends Error{static from(a,s,r,o,l,d){const c=new mo(a.message,s||a.code,r,o,l);return c.cause=a,c.name=a.name,a.status!=null&&c.status==null&&(c.status=a.status),d&&Object.assign(c,d),c}constructor(a,s,r,o,l){super(a),Object.defineProperty(this,"message",{value:a,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,s&&(this.code=s),r&&(this.config=r),o&&(this.request=o),l&&(this.response=l,this.status=l.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:X.toJSONObject(this.config),code:this.code,status:this.status}}};Ce.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";Ce.ERR_BAD_OPTION="ERR_BAD_OPTION";Ce.ECONNABORTED="ECONNABORTED";Ce.ETIMEDOUT="ETIMEDOUT";Ce.ERR_NETWORK="ERR_NETWORK";Ce.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";Ce.ERR_DEPRECATED="ERR_DEPRECATED";Ce.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";Ce.ERR_BAD_REQUEST="ERR_BAD_REQUEST";Ce.ERR_CANCELED="ERR_CANCELED";Ce.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";Ce.ERR_INVALID_URL="ERR_INVALID_URL";Ce.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const Jl=null;function Ls(t){return X.isPlainObject(t)||X.isArray(t)}function fo(t){return X.endsWith(t,"[]")?t.slice(0,-2):t}function cs(t,a,s){return t?t.concat(a).map(function(o,l){return o=fo(o),!s&&l?"["+o+"]":o}).join(s?".":""):a}function Ql(t){return X.isArray(t)&&!t.some(Ls)}const Xl=X.toFlatObject(X,{},null,function(a){return/^is[A-Z]/.test(a)});function Qn(t,a,s){if(!X.isObject(t))throw new TypeError("target must be an object");a=a||new FormData,s=X.toFlatObject(s,{metaTokens:!0,dots:!1,indexes:!1},!1,function(x,T){return!X.isUndefined(T[x])});const r=s.metaTokens,o=s.visitor||p,l=s.dots,d=s.indexes,c=s.Blob||typeof Blob<"u"&&Blob,g=s.maxDepth===void 0?100:s.maxDepth,f=c&&X.isSpecCompliantForm(a);if(!X.isFunction(o))throw new TypeError("visitor must be a function");function u(m){if(m===null)return"";if(X.isDate(m))return m.toISOString();if(X.isBoolean(m))return m.toString();if(!f&&X.isBlob(m))throw new Ce("Blob is not supported. Use a Buffer instead.");return X.isArrayBuffer(m)||X.isTypedArray(m)?f&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function p(m,x,T){let D=m;if(X.isReactNative(a)&&X.isReactNativeBlob(m))return a.append(cs(T,x,l),u(m)),!1;if(m&&!T&&typeof m=="object"){if(X.endsWith(x,"{}"))x=r?x:x.slice(0,-2),m=JSON.stringify(m);else if(X.isArray(m)&&Ql(m)||(X.isFileList(m)||X.endsWith(x,"[]"))&&(D=X.toArray(m)))return x=fo(x),D.forEach(function(C,j){!(X.isUndefined(C)||C===null)&&a.append(d===!0?cs([x],j,l):d===null?x:x+"[]",u(C))}),!1}return Ls(m)?!0:(a.append(cs(T,x,l),u(m)),!1)}const w=[],v=Object.assign(Xl,{defaultVisitor:p,convertValue:u,isVisitable:Ls});function y(m,x,T=0){if(!X.isUndefined(m)){if(T>g)throw new Ce("Object is too deeply nested ("+T+" levels). Max depth: "+g,Ce.ERR_FORM_DATA_DEPTH_EXCEEDED);if(w.indexOf(m)!==-1)throw Error("Circular reference detected in "+x.join("."));w.push(m),X.forEach(m,function(k,C){(!(X.isUndefined(k)||k===null)&&o.call(a,k,X.isString(C)?C.trim():C,x,v))===!0&&y(k,x?x.concat(C):[C],T+1)}),w.pop()}}if(!X.isObject(t))throw new TypeError("data must be an object");return y(t),a}function hr(t){const a={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(t).replace(/[!'()~]|%20/g,function(r){return a[r]})}function Ws(t,a){this._pairs=[],t&&Qn(t,this,a)}const ho=Ws.prototype;ho.append=function(a,s){this._pairs.push([a,s])};ho.toString=function(a){const s=a?function(r){return a.call(this,r,hr)}:hr;return this._pairs.map(function(o){return s(o[0])+"="+s(o[1])},"").join("&")};function Zl(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function yo(t,a,s){if(!a)return t;const r=s&&s.encode||Zl,o=X.isFunction(s)?{serialize:s}:s,l=o&&o.serialize;let d;if(l?d=l(a,o):d=X.isURLSearchParams(a)?a.toString():new Ws(a,o).toString(r),d){const c=t.indexOf("#");c!==-1&&(t=t.slice(0,c)),t+=(t.indexOf("?")===-1?"?":"&")+d}return t}class yr{constructor(){this.handlers=[]}use(a,s,r){return this.handlers.push({fulfilled:a,rejected:s,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(a){this.handlers[a]&&(this.handlers[a]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(a){X.forEach(this.handlers,function(r){r!==null&&a(r)})}}const Hs={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},ed=typeof URLSearchParams<"u"?URLSearchParams:Ws,td=typeof FormData<"u"?FormData:null,ad=typeof Blob<"u"?Blob:null,nd={isBrowser:!0,classes:{URLSearchParams:ed,FormData:td,Blob:ad},protocols:["http","https","file","blob","url","data"]},Ks=typeof window<"u"&&typeof document<"u",qs=typeof navigator=="object"&&navigator||void 0,sd=Ks&&(!qs||["ReactNative","NativeScript","NS"].indexOf(qs.product)<0),rd=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",id=Ks&&window.location.href||"http://localhost",od=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ks,hasStandardBrowserEnv:sd,hasStandardBrowserWebWorkerEnv:rd,navigator:qs,origin:id},Symbol.toStringTag,{value:"Module"})),tt={...od,...nd};function ld(t,a){return Qn(t,new tt.classes.URLSearchParams,{visitor:function(s,r,o,l){return tt.isNode&&X.isBuffer(s)?(this.append(r,s.toString("base64")),!1):l.defaultVisitor.apply(this,arguments)},...a})}function dd(t){return X.matchAll(/\w+|\[(\w*)]/g,t).map(a=>a[0]==="[]"?"":a[1]||a[0])}function cd(t){const a={},s=Object.keys(t);let r;const o=s.length;let l;for(r=0;r<o;r++)l=s[r],a[l]=t[l];return a}function go(t){function a(s,r,o,l){let d=s[l++];if(d==="__proto__")return!0;const c=Number.isFinite(+d),g=l>=s.length;return d=!d&&X.isArray(o)?o.length:d,g?(X.hasOwnProp(o,d)?o[d]=X.isArray(o[d])?o[d].concat(r):[o[d],r]:o[d]=r,!c):((!o[d]||!X.isObject(o[d]))&&(o[d]=[]),a(s,r,o[d],l)&&X.isArray(o[d])&&(o[d]=cd(o[d])),!c)}if(X.isFormData(t)&&X.isFunction(t.entries)){const s={};return X.forEachEntry(t,(r,o)=>{a(dd(r),o,s,0)}),s}return null}const ea=(t,a)=>t!=null&&X.hasOwnProp(t,a)?t[a]:void 0;function ud(t,a,s){if(X.isString(t))try{return(a||JSON.parse)(t),X.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(s||JSON.stringify)(t)}const Ga={transitional:Hs,adapter:["xhr","http","fetch"],transformRequest:[function(a,s){const r=s.getContentType()||"",o=r.indexOf("application/json")>-1,l=X.isObject(a);if(l&&X.isHTMLForm(a)&&(a=new FormData(a)),X.isFormData(a))return o?JSON.stringify(go(a)):a;if(X.isArrayBuffer(a)||X.isBuffer(a)||X.isStream(a)||X.isFile(a)||X.isBlob(a)||X.isReadableStream(a))return a;if(X.isArrayBufferView(a))return a.buffer;if(X.isURLSearchParams(a))return s.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),a.toString();let c;if(l){const g=ea(this,"formSerializer");if(r.indexOf("application/x-www-form-urlencoded")>-1)return ld(a,g).toString();if((c=X.isFileList(a))||r.indexOf("multipart/form-data")>-1){const f=ea(this,"env"),u=f&&f.FormData;return Qn(c?{"files[]":a}:a,u&&new u,g)}}return l||o?(s.setContentType("application/json",!1),ud(a)):a}],transformResponse:[function(a){const s=ea(this,"transitional")||Ga.transitional,r=s&&s.forcedJSONParsing,o=ea(this,"responseType"),l=o==="json";if(X.isResponse(a)||X.isReadableStream(a))return a;if(a&&X.isString(a)&&(r&&!o||l)){const c=!(s&&s.silentJSONParsing)&&l;try{return JSON.parse(a,ea(this,"parseReviver"))}catch(g){if(c)throw g.name==="SyntaxError"?Ce.from(g,Ce.ERR_BAD_RESPONSE,this,null,ea(this,"response")):g}}return a}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:tt.classes.FormData,Blob:tt.classes.Blob},validateStatus:function(a){return a>=200&&a<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};X.forEach(["delete","get","head","post","put","patch"],t=>{Ga.headers[t]={}});const pd=X.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),md=t=>{const a={};let s,r,o;return t&&t.split(`
|
|
2
|
-
`).forEach(function(d){o=d.indexOf(":"),s=d.substring(0,o).trim().toLowerCase(),
|
|
3
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(a){return a instanceof this?a:new this(a)}static concat(a,...s){const r=new this(a);return s.forEach(o=>r.set(o)),r}static accessor(a){const r=(this[gr]=this[gr]={accessors:{}}).accessors,o=this.prototype;function l(d){const c=wa(d);r[c]||(jd(o,d),r[c]=!0)}return X.isArray(a)?a.forEach(l):l(a),this}};ct.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);X.reduceDescriptors(ct.prototype,({value:t},a)=>{let s=a[0].toUpperCase()+a.slice(1);return{get:()=>t,set(r){this[s]=r}}});X.freezeMethods(ct);function ps(t,a){const s=this||Ga,r=a||s,o=ct.from(r.headers);let l=r.data;return X.forEach(t,function(c){l=c.call(s,l,o.normalize(),a?a.status:void 0)}),o.normalize(),l}function xo(t){return!!(t&&t.__CANCEL__)}let Ja=class extends Ce{constructor(a,s,r){super(a??"canceled",Ce.ERR_CANCELED,s,r),this.name="CanceledError",this.__CANCEL__=!0}};function bo(t,a,s){const r=s.config.validateStatus;!s.status||!r||r(s.status)?t(s):a(new Ce("Request failed with status code "+s.status,[Ce.ERR_BAD_REQUEST,Ce.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s))}function Sd(t){const a=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return a&&a[1]||""}function vd(t,a){t=t||10;const s=new Array(t),r=new Array(t);let o=0,l=0,d;return a=a!==void 0?a:1e3,function(g){const f=Date.now(),u=r[l];d||(d=f),s[o]=g,r[o]=f;let p=l,w=0;for(;p!==o;)w+=s[p++],p=p%t;if(o=(o+1)%t,o===l&&(l=(l+1)%t),f-d<a)return;const v=u&&f-u;return v?Math.round(w*1e3/v):void 0}}function wd(t,a){let s=0,r=1e3/a,o,l;const d=(f,u=Date.now())=>{s=u,o=null,l&&(clearTimeout(l),l=null),t(...f)};return[(...f)=>{const u=Date.now(),p=u-s;p>=r?d(f,u):(o=f,l||(l=setTimeout(()=>{l=null,d(o)},r-p)))},()=>o&&d(o)]}const Vn=(t,a,s=3)=>{let r=0;const o=vd(50,250);return wd(l=>{const d=l.loaded,c=l.lengthComputable?l.total:void 0,g=c!=null?Math.min(d,c):d,f=Math.max(0,g-r),u=o(f);r=Math.max(r,g);const p={loaded:g,total:c,progress:c?g/c:void 0,bytes:f,rate:u||void 0,estimated:u&&c?(c-g)/u:void 0,event:l,lengthComputable:c!=null,[a?"download":"upload"]:!0};t(p)},s)},xr=(t,a)=>{const s=t!=null;return[r=>a[0]({lengthComputable:s,total:t,loaded:r}),a[1]]},br=t=>(...a)=>X.asap(()=>t(...a)),_d=tt.hasStandardBrowserEnv?((t,a)=>s=>(s=new URL(s,tt.origin),t.protocol===s.protocol&&t.host===s.host&&(a||t.port===s.port)))(new URL(tt.origin),tt.navigator&&/(msie|trident)/i.test(tt.navigator.userAgent)):()=>!0,Cd=tt.hasStandardBrowserEnv?{write(t,a,s,r,o,l,d){if(typeof document>"u")return;const c=[`${t}=${encodeURIComponent(a)}`];X.isNumber(s)&&c.push(`expires=${new Date(s).toUTCString()}`),X.isString(r)&&c.push(`path=${r}`),X.isString(o)&&c.push(`domain=${o}`),l===!0&&c.push("secure"),X.isString(d)&&c.push(`SameSite=${d}`),document.cookie=c.join("; ")},read(t){if(typeof document>"u")return null;const a=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return a?decodeURIComponent(a[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Ad(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function Td(t,a){return a?t.replace(/\/?\/$/,"")+"/"+a.replace(/^\/+/,""):t}function jo(t,a,s){let r=!Ad(a);return t&&(r||s===!1)?Td(t,a):a}const jr=t=>t instanceof ct?{...t}:t;function Jt(t,a){a=a||{};const s=Object.create(null);Object.defineProperty(s,"hasOwnProperty",{value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(f,u,p,w){return X.isPlainObject(f)&&X.isPlainObject(u)?X.merge.call({caseless:w},f,u):X.isPlainObject(u)?X.merge({},u):X.isArray(u)?u.slice():u}function o(f,u,p,w){if(X.isUndefined(u)){if(!X.isUndefined(f))return r(void 0,f,p,w)}else return r(f,u,p,w)}function l(f,u){if(!X.isUndefined(u))return r(void 0,u)}function d(f,u){if(X.isUndefined(u)){if(!X.isUndefined(f))return r(void 0,f)}else return r(void 0,u)}function c(f,u,p){if(X.hasOwnProp(a,p))return r(f,u);if(X.hasOwnProp(t,p))return r(void 0,f)}const g={url:l,method:l,data:l,baseURL:d,transformRequest:d,transformResponse:d,paramsSerializer:d,timeout:d,timeoutMessage:d,withCredentials:d,withXSRFToken:d,adapter:d,responseType:d,xsrfCookieName:d,xsrfHeaderName:d,onUploadProgress:d,onDownloadProgress:d,decompress:d,maxContentLength:d,maxBodyLength:d,beforeRedirect:d,transport:d,httpAgent:d,httpsAgent:d,cancelToken:d,socketPath:d,allowedSocketPaths:d,responseEncoding:d,validateStatus:c,headers:(f,u,p)=>o(jr(f),jr(u),p,!0)};return X.forEach(Object.keys({...t,...a}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;const p=X.hasOwnProp(g,u)?g[u]:o,w=X.hasOwnProp(t,u)?t[u]:void 0,v=X.hasOwnProp(a,u)?a[u]:void 0,y=p(w,v,u);X.isUndefined(y)&&p!==c||(s[u]=y)}),s}const So=t=>{const a=Jt({},t),s=w=>X.hasOwnProp(a,w)?a[w]:void 0,r=s("data");let o=s("withXSRFToken");const l=s("xsrfHeaderName"),d=s("xsrfCookieName");let c=s("headers");const g=s("auth"),f=s("baseURL"),u=s("allowAbsoluteUrls"),p=s("url");if(a.headers=c=ct.from(c),a.url=yo(jo(f,p,u),t.params,t.paramsSerializer),g&&c.set("Authorization","Basic "+btoa((g.username||"")+":"+(g.password?unescape(encodeURIComponent(g.password)):""))),X.isFormData(r)){if(tt.hasStandardBrowserEnv||tt.hasStandardBrowserWebWorkerEnv)c.setContentType(void 0);else if(X.isFunction(r.getHeaders)){const w=r.getHeaders(),v=["content-type","content-length"];Object.entries(w).forEach(([y,m])=>{v.includes(y.toLowerCase())&&c.set(y,m)})}}if(tt.hasStandardBrowserEnv&&(X.isFunction(o)&&(o=o(a)),o===!0||o==null&&_d(a.url))){const v=l&&d&&Cd.read(d);v&&c.set(l,v)}return a},Dd=typeof XMLHttpRequest<"u",Rd=Dd&&function(t){return new Promise(function(s,r){const o=So(t);let l=o.data;const d=ct.from(o.headers).normalize();let{responseType:c,onUploadProgress:g,onDownloadProgress:f}=o,u,p,w,v,y;function m(){v&&v(),y&&y(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function T(){if(!x)return;const k=ct.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),j={data:!c||c==="text"||c==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:k,config:t,request:x};bo(function(S){s(S),m()},function(S){r(S),m()},j),x=null}"onloadend"in x?x.onloadend=T:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(T)},x.onabort=function(){x&&(r(new Ce("Request aborted",Ce.ECONNABORTED,t,x)),x=null)},x.onerror=function(C){const j=C&&C.message?C.message:"Network Error",h=new Ce(j,Ce.ERR_NETWORK,t,x);h.event=C||null,r(h),x=null},x.ontimeout=function(){let C=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const j=o.transitional||Hs;o.timeoutErrorMessage&&(C=o.timeoutErrorMessage),r(new Ce(C,j.clarifyTimeoutError?Ce.ETIMEDOUT:Ce.ECONNABORTED,t,x)),x=null},l===void 0&&d.setContentType(null),"setRequestHeader"in x&&X.forEach(d.toJSON(),function(C,j){x.setRequestHeader(j,C)}),X.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),c&&c!=="json"&&(x.responseType=o.responseType),f&&([w,y]=Vn(f,!0),x.addEventListener("progress",w)),g&&x.upload&&([p,v]=Vn(g),x.upload.addEventListener("progress",p),x.upload.addEventListener("loadend",v)),(o.cancelToken||o.signal)&&(u=k=>{x&&(r(!k||k.type?new Ja(null,t,x):k),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const D=Sd(o.url);if(D&&tt.protocols.indexOf(D)===-1){r(new Ce("Unsupported protocol "+D+":",Ce.ERR_BAD_REQUEST,t));return}x.send(l||null)})},Id=(t,a)=>{const{length:s}=t=t?t.filter(Boolean):[];if(a||s){let r=new AbortController,o;const l=function(f){if(!o){o=!0,c();const u=f instanceof Error?f:this.reason;r.abort(u instanceof Ce?u:new Ja(u instanceof Error?u.message:u))}};let d=a&&setTimeout(()=>{d=null,l(new Ce(`timeout of ${a}ms exceeded`,Ce.ETIMEDOUT))},a);const c=()=>{t&&(d&&clearTimeout(d),d=null,t.forEach(f=>{f.unsubscribe?f.unsubscribe(l):f.removeEventListener("abort",l)}),t=null)};t.forEach(f=>f.addEventListener("abort",l));const{signal:g}=r;return g.unsubscribe=()=>X.asap(c),g}},kd=function*(t,a){let s=t.byteLength;if(s<a){yield t;return}let r=0,o;for(;r<s;)o=r+a,yield t.slice(r,o),r=o},Pd=async function*(t,a){for await(const s of Od(t))yield*kd(s,a)},Od=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const a=t.getReader();try{for(;;){const{done:s,value:r}=await a.read();if(s)break;yield r}}finally{await a.cancel()}},Sr=(t,a,s,r)=>{const o=Pd(t,a);let l=0,d,c=g=>{d||(d=!0,r&&r(g))};return new ReadableStream({async pull(g){try{const{done:f,value:u}=await o.next();if(f){c(),g.close();return}let p=u.byteLength;if(s){let w=l+=p;s(w)}g.enqueue(new Uint8Array(u))}catch(f){throw c(f),f}},cancel(g){return c(g),o.return()}},{highWaterMark:2})},vr=64*1024,{isFunction:cn}=X,Md=(({Request:t,Response:a})=>({Request:t,Response:a}))(X.global),{ReadableStream:wr,TextEncoder:_r}=X.global,Cr=(t,...a)=>{try{return!!t(...a)}catch{return!1}},Ed=t=>{t=X.merge.call({skipUndefined:!0},Md,t);const{fetch:a,Request:s,Response:r}=t,o=a?cn(a):typeof fetch=="function",l=cn(s),d=cn(r);if(!o)return!1;const c=o&&cn(wr),g=o&&(typeof _r=="function"?(y=>m=>y.encode(m))(new _r):async y=>new Uint8Array(await new s(y).arrayBuffer())),f=l&&c&&Cr(()=>{let y=!1;const m=new s(tt.origin,{body:new wr,method:"POST",get duplex(){return y=!0,"half"}}),x=m.headers.has("Content-Type");return m.body!=null&&m.body.cancel(),y&&!x}),u=d&&c&&Cr(()=>X.isReadableStream(new r("").body)),p={stream:u&&(y=>y.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(y=>{!p[y]&&(p[y]=(m,x)=>{let T=m&&m[y];if(T)return T.call(m);throw new Ce(`Response type '${y}' is not supported`,Ce.ERR_NOT_SUPPORT,x)})});const w=async y=>{if(y==null)return 0;if(X.isBlob(y))return y.size;if(X.isSpecCompliantForm(y))return(await new s(tt.origin,{method:"POST",body:y}).arrayBuffer()).byteLength;if(X.isArrayBufferView(y)||X.isArrayBuffer(y))return y.byteLength;if(X.isURLSearchParams(y)&&(y=y+""),X.isString(y))return(await g(y)).byteLength},v=async(y,m)=>{const x=X.toFiniteNumber(y.getContentLength());return x??w(m)};return async y=>{let{url:m,method:x,data:T,signal:D,cancelToken:k,timeout:C,onDownloadProgress:j,onUploadProgress:h,responseType:S,headers:A,withCredentials:R="same-origin",fetchOptions:q}=So(y),U=a||fetch;S=S?(S+"").toLowerCase():"text";let b=Id([D,k&&k.toAbortSignal()],C),O=null;const M=b&&b.unsubscribe&&(()=>{b.unsubscribe()});let $;try{if(h&&f&&x!=="get"&&x!=="head"&&($=await v(A,T))!==0){let I=new s(m,{method:"POST",body:T,duplex:"half"}),B;if(X.isFormData(T)&&(B=I.headers.get("content-type"))&&A.setContentType(B),I.body){const[L,H]=xr($,Vn(br(h)));T=Sr(I.body,vr,L,H)}}X.isString(R)||(R=R?"include":"omit");const F=l&&"credentials"in s.prototype;if(X.isFormData(T)){const I=A.getContentType();I&&/^multipart\/form-data/i.test(I)&&!/boundary=/i.test(I)&&A.delete("content-type")}const N={...q,signal:b,method:x.toUpperCase(),headers:A.normalize().toJSON(),body:T,duplex:"half",credentials:F?R:void 0};O=l&&new s(m,N);let V=await(l?U(O,q):U(m,N));const z=u&&(S==="stream"||S==="response");if(u&&(j||z&&M)){const I={};["status","statusText","headers"].forEach(se=>{I[se]=V[se]});const B=X.toFiniteNumber(V.headers.get("content-length")),[L,H]=j&&xr(B,Vn(br(j),!0))||[];V=new r(Sr(V.body,vr,L,()=>{H&&H(),M&&M()}),I)}S=S||"text";let P=await p[X.findKey(p,S)||"text"](V,y);return!z&&M&&M(),await new Promise((I,B)=>{bo(I,B,{data:P,headers:ct.from(V.headers),status:V.status,statusText:V.statusText,config:y,request:O})})}catch(F){throw M&&M(),F&&F.name==="TypeError"&&/Load failed|fetch/i.test(F.message)?Object.assign(new Ce("Network Error",Ce.ERR_NETWORK,y,O,F&&F.response),{cause:F.cause||F}):Ce.from(F,F&&F.code,y,O,F&&F.response)}}},Fd=new Map,vo=t=>{let a=t&&t.env||{};const{fetch:s,Request:r,Response:o}=a,l=[r,o,s];let d=l.length,c=d,g,f,u=Fd;for(;c--;)g=l[c],f=u.get(g),f===void 0&&u.set(g,f=c?new Map:Ed(a)),u=f;return f};vo();const Gs={http:Jl,xhr:Rd,fetch:{get:vo}};X.forEach(Gs,(t,a)=>{if(t){try{Object.defineProperty(t,"name",{value:a})}catch{}Object.defineProperty(t,"adapterName",{value:a})}});const Ar=t=>`- ${t}`,$d=t=>X.isFunction(t)||t===null||t===!1;function Ud(t,a){t=X.isArray(t)?t:[t];const{length:s}=t;let r,o;const l={};for(let d=0;d<s;d++){r=t[d];let c;if(o=r,!$d(r)&&(o=Gs[(c=String(r)).toLowerCase()],o===void 0))throw new Ce(`Unknown adapter '${c}'`);if(o&&(X.isFunction(o)||(o=o.get(a))))break;l[c||"#"+d]=o}if(!o){const d=Object.entries(l).map(([g,f])=>`adapter ${g} `+(f===!1?"is not supported by the environment":"is not available in the build"));let c=s?d.length>1?`since :
|
|
4
|
-
`+d.map(
|
|
5
|
-
`):" "+
|
|
6
|
-
`);return d===-1?"":o.stack.slice(d+1)})();try{if(!
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("antd"),W=require("swr"),v=require("react-hot-toast"),r=require("react"),tt=require("swr/mutation"),ee=require("@ant-design/icons"),te=require("dayjs"),vl=require("react-dom/server"),xa=require("react-to-print"),po=require("react-select"),mo=require("react-barcode"),_l=()=>e.jsxs(n.Card,{style:{borderRadius:16},children:[e.jsx(n.Typography.Title,{level:3,style:{marginTop:0},children:"UBK ERP"}),e.jsx(n.Typography.Paragraph,{style:{marginBottom:0},children:"Welcome to your webpack-powered ERP system."})]}),C=({width:t,height:a,display:s,justifyContent:i,alignItems:o,flexDirection:l,gap:d,style:c,children:g,...h})=>{const u={width:t,height:a,display:s,justifyContent:i,alignItems:o,flexDirection:l,gap:d,...c};return e.jsx("div",{style:u,...h,children:g})},ge=({variant:t,fontWeight:a,style:s,children:i,...o})=>{const l=a==="bold"?700:a==="light"?300:a;return t==="h1"?e.jsx(n.Typography.Title,{level:1,style:{fontWeight:l,...s},...o,children:i}):t==="h2"?e.jsx(n.Typography.Title,{level:2,style:{fontWeight:l,...s},...o,children:i}):t==="h3"?e.jsx(n.Typography.Title,{level:3,style:{fontWeight:l,...s},...o,children:i}):t==="h4"?e.jsx(n.Typography.Title,{level:4,style:{fontWeight:l,...s},...o,children:i}):t==="h5"?e.jsx(n.Typography.Title,{level:5,style:{fontWeight:l,...s},...o,children:i}):e.jsx(n.Typography.Text,{style:{fontWeight:l,...s},...o,children:i})};function ho({title:t="",icon:a="",path:s="",onClick:i}){const o=()=>{if(i){i(s);return}typeof window<"u"&&typeof s=="string"&&s.length>0&&window.location.assign(s)};return e.jsxs(n.Card,{hoverable:!0,onClick:o,style:{borderRadius:12,overflow:"hidden",boxShadow:"0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.10)"},bodyStyle:{padding:0,cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"stretch"},children:[e.jsx(C,{width:"100%",display:"flex",justifyContent:"center",alignItems:"center",style:{padding:"10px 12px",minHeight:80},children:e.jsx("img",{src:a,alt:"",style:{width:45,height:50,objectFit:"contain"}})}),e.jsx(C,{style:{padding:"0 12px"},children:e.jsx(n.Divider,{style:{margin:0,minWidth:0}})}),e.jsx(C,{style:{padding:"10px 10px",display:"flex",justifyContent:"center",alignItems:"center",minHeight:35},children:e.jsx(ge,{variant:"button",fontWeight:"bold",style:{fontSize:12},children:t})})]})}function fo(t,a){return function(){return t.apply(a,arguments)}}const{toString:Cl}=Object.prototype,{getPrototypeOf:Jn}=Object,{iterator:Qn,toStringTag:yo}=Symbol,Xn=(t=>a=>{const s=Cl.call(a);return t[s]||(t[s]=s.slice(8,-1).toLowerCase())})(Object.create(null)),Ct=t=>(t=t.toLowerCase(),a=>Xn(a)===t),Zn=t=>a=>typeof a===t,{isArray:ba}=Array,fa=Zn("undefined");function Wa(t){return t!==null&&!fa(t)&&t.constructor!==null&&!fa(t.constructor)&&ut(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const go=Ct("ArrayBuffer");function Al(t){let a;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?a=ArrayBuffer.isView(t):a=t&&t.buffer&&go(t.buffer),a}const Dl=Zn("string"),ut=Zn("function"),xo=Zn("number"),Ha=t=>t!==null&&typeof t=="object",Tl=t=>t===!0||t===!1,kn=t=>{if(Xn(t)!=="object")return!1;const a=Jn(t);return(a===null||a===Object.prototype||Object.getPrototypeOf(a)===null)&&!(yo in t)&&!(Qn in t)},Rl=t=>{if(!Ha(t)||Wa(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},Il=Ct("Date"),kl=Ct("File"),Pl=t=>!!(t&&typeof t.uri<"u"),Ol=t=>t&&typeof t.getParts<"u",Ml=Ct("Blob"),El=Ct("FileList"),Fl=t=>Ha(t)&&ut(t.pipe);function Ul(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const yr=Ul(),gr=typeof yr.FormData<"u"?yr.FormData:void 0,$l=t=>{if(!t)return!1;if(gr&&t instanceof gr)return!0;const a=Jn(t);if(!a||a===Object.prototype||!ut(t.append))return!1;const s=Xn(t);return s==="formdata"||s==="object"&&ut(t.toString)&&t.toString()==="[object FormData]"},Nl=Ct("URLSearchParams"),[Ll,Bl,ql,zl]=["ReadableStream","Request","Response","Headers"].map(Ct),Yl=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Ka(t,a,{allOwnKeys:s=!1}={}){if(t===null||typeof t>"u")return;let i,o;if(typeof t!="object"&&(t=[t]),ba(t))for(i=0,o=t.length;i<o;i++)a.call(null,t[i],i,t);else{if(Wa(t))return;const l=s?Object.getOwnPropertyNames(t):Object.keys(t),d=l.length;let c;for(i=0;i<d;i++)c=l[i],a.call(null,t[c],c,t)}}function bo(t,a){if(Wa(t))return null;a=a.toLowerCase();const s=Object.keys(t);let i=s.length,o;for(;i-- >0;)if(o=s[i],a===o.toLowerCase())return o;return null}const Ht=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,jo=t=>!fa(t)&&t!==Ht;function zs(){const{caseless:t,skipUndefined:a}=jo(this)&&this||{},s={},i=(o,l)=>{if(l==="__proto__"||l==="constructor"||l==="prototype")return;const d=t&&bo(s,l)||l;kn(s[d])&&kn(o)?s[d]=zs(s[d],o):kn(o)?s[d]=zs({},o):ba(o)?s[d]=o.slice():(!a||!fa(o))&&(s[d]=o)};for(let o=0,l=arguments.length;o<l;o++)arguments[o]&&Ka(arguments[o],i);return s}const Vl=(t,a,s,{allOwnKeys:i}={})=>(Ka(a,(o,l)=>{s&&ut(o)?Object.defineProperty(t,l,{value:fo(o,s),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,l,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:i}),t),Wl=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),Hl=(t,a,s,i)=>{t.prototype=Object.create(a.prototype,i),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:a.prototype}),s&&Object.assign(t.prototype,s)},Kl=(t,a,s,i)=>{let o,l,d;const c={};if(a=a||{},t==null)return a;do{for(o=Object.getOwnPropertyNames(t),l=o.length;l-- >0;)d=o[l],(!i||i(d,t,a))&&!c[d]&&(a[d]=t[d],c[d]=!0);t=s!==!1&&Jn(t)}while(t&&(!s||s(t,a))&&t!==Object.prototype);return a},Gl=(t,a,s)=>{t=String(t),(s===void 0||s>t.length)&&(s=t.length),s-=a.length;const i=t.indexOf(a,s);return i!==-1&&i===s},Jl=t=>{if(!t)return null;if(ba(t))return t;let a=t.length;if(!xo(a))return null;const s=new Array(a);for(;a-- >0;)s[a]=t[a];return s},Ql=(t=>a=>t&&a instanceof t)(typeof Uint8Array<"u"&&Jn(Uint8Array)),Xl=(t,a)=>{const i=(t&&t[Qn]).call(t);let o;for(;(o=i.next())&&!o.done;){const l=o.value;a.call(t,l[0],l[1])}},Zl=(t,a)=>{let s;const i=[];for(;(s=t.exec(a))!==null;)i.push(s);return i},ed=Ct("HTMLFormElement"),td=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(s,i,o){return i.toUpperCase()+o}),xr=(({hasOwnProperty:t})=>(a,s)=>t.call(a,s))(Object.prototype),ad=Ct("RegExp"),So=(t,a)=>{const s=Object.getOwnPropertyDescriptors(t),i={};Ka(s,(o,l)=>{let d;(d=a(o,l,t))!==!1&&(i[l]=d||o)}),Object.defineProperties(t,i)},nd=t=>{So(t,(a,s)=>{if(ut(t)&&["arguments","caller","callee"].indexOf(s)!==-1)return!1;const i=t[s];if(ut(i)){if(a.enumerable=!1,"writable"in a){a.writable=!1;return}a.set||(a.set=()=>{throw Error("Can not rewrite read-only method '"+s+"'")})}})},sd=(t,a)=>{const s={},i=o=>{o.forEach(l=>{s[l]=!0})};return ba(t)?i(t):i(String(t).split(a)),s},rd=()=>{},id=(t,a)=>t!=null&&Number.isFinite(t=+t)?t:a;function od(t){return!!(t&&ut(t.append)&&t[yo]==="FormData"&&t[Qn])}const ld=t=>{const a=new Array(10),s=(i,o)=>{if(Ha(i)){if(a.indexOf(i)>=0)return;if(Wa(i))return i;if(!("toJSON"in i)){a[o]=i;const l=ba(i)?[]:{};return Ka(i,(d,c)=>{const g=s(d,o+1);!fa(g)&&(l[c]=g)}),a[o]=void 0,l}}return i};return s(t,0)},dd=Ct("AsyncFunction"),cd=t=>t&&(Ha(t)||ut(t))&&ut(t.then)&&ut(t.catch),wo=((t,a)=>t?setImmediate:a?((s,i)=>(Ht.addEventListener("message",({source:o,data:l})=>{o===Ht&&l===s&&i.length&&i.shift()()},!1),o=>{i.push(o),Ht.postMessage(s,"*")}))(`axios@${Math.random()}`,[]):s=>setTimeout(s))(typeof setImmediate=="function",ut(Ht.postMessage)),ud=typeof queueMicrotask<"u"?queueMicrotask.bind(Ht):typeof process<"u"&&process.nextTick||wo,pd=t=>t!=null&&ut(t[Qn]),Z={isArray:ba,isArrayBuffer:go,isBuffer:Wa,isFormData:$l,isArrayBufferView:Al,isString:Dl,isNumber:xo,isBoolean:Tl,isObject:Ha,isPlainObject:kn,isEmptyObject:Rl,isReadableStream:Ll,isRequest:Bl,isResponse:ql,isHeaders:zl,isUndefined:fa,isDate:Il,isFile:kl,isReactNativeBlob:Pl,isReactNative:Ol,isBlob:Ml,isRegExp:ad,isFunction:ut,isStream:Fl,isURLSearchParams:Nl,isTypedArray:Ql,isFileList:El,forEach:Ka,merge:zs,extend:Vl,trim:Yl,stripBOM:Wl,inherits:Hl,toFlatObject:Kl,kindOf:Xn,kindOfTest:Ct,endsWith:Gl,toArray:Jl,forEachEntry:Xl,matchAll:Zl,isHTMLForm:ed,hasOwnProperty:xr,hasOwnProp:xr,reduceDescriptors:So,freezeMethods:nd,toObjectSet:sd,toCamelCase:td,noop:rd,toFiniteNumber:id,findKey:bo,global:Ht,isContextDefined:jo,isSpecCompliantForm:od,toJSONObject:ld,isAsyncFn:dd,isThenable:cd,setImmediate:wo,asap:ud,isIterable:pd};let Ae=class vo extends Error{static from(a,s,i,o,l,d){const c=new vo(a.message,s||a.code,i,o,l);return c.cause=a,c.name=a.name,a.status!=null&&c.status==null&&(c.status=a.status),d&&Object.assign(c,d),c}constructor(a,s,i,o,l){super(a),Object.defineProperty(this,"message",{value:a,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,s&&(this.code=s),i&&(this.config=i),o&&(this.request=o),l&&(this.response=l,this.status=l.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Z.toJSONObject(this.config),code:this.code,status:this.status}}};Ae.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";Ae.ERR_BAD_OPTION="ERR_BAD_OPTION";Ae.ECONNABORTED="ECONNABORTED";Ae.ETIMEDOUT="ETIMEDOUT";Ae.ERR_NETWORK="ERR_NETWORK";Ae.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";Ae.ERR_DEPRECATED="ERR_DEPRECATED";Ae.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";Ae.ERR_BAD_REQUEST="ERR_BAD_REQUEST";Ae.ERR_CANCELED="ERR_CANCELED";Ae.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";Ae.ERR_INVALID_URL="ERR_INVALID_URL";Ae.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const md=null;function Ys(t){return Z.isPlainObject(t)||Z.isArray(t)}function _o(t){return Z.endsWith(t,"[]")?t.slice(0,-2):t}function ms(t,a,s){return t?t.concat(a).map(function(o,l){return o=_o(o),!s&&l?"["+o+"]":o}).join(s?".":""):a}function hd(t){return Z.isArray(t)&&!t.some(Ys)}const fd=Z.toFlatObject(Z,{},null,function(a){return/^is[A-Z]/.test(a)});function es(t,a,s){if(!Z.isObject(t))throw new TypeError("target must be an object");a=a||new FormData,s=Z.toFlatObject(s,{metaTokens:!0,dots:!1,indexes:!1},!1,function(j,D){return!Z.isUndefined(D[j])});const i=s.metaTokens,o=s.visitor||p,l=s.dots,d=s.indexes,c=s.Blob||typeof Blob<"u"&&Blob,g=s.maxDepth===void 0?100:s.maxDepth,h=c&&Z.isSpecCompliantForm(a);if(!Z.isFunction(o))throw new TypeError("visitor must be a function");function u(m){if(m===null)return"";if(Z.isDate(m))return m.toISOString();if(Z.isBoolean(m))return m.toString();if(!h&&Z.isBlob(m))throw new Ae("Blob is not supported. Use a Buffer instead.");return Z.isArrayBuffer(m)||Z.isTypedArray(m)?h&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function p(m,j,D){let R=m;if(Z.isReactNative(a)&&Z.isReactNativeBlob(m))return a.append(ms(D,j,l),u(m)),!1;if(m&&!D&&typeof m=="object"){if(Z.endsWith(j,"{}"))j=i?j:j.slice(0,-2),m=JSON.stringify(m);else if(Z.isArray(m)&&hd(m)||(Z.isFileList(m)||Z.endsWith(j,"[]"))&&(R=Z.toArray(m)))return j=_o(j),R.forEach(function(S,x){!(Z.isUndefined(S)||S===null)&&a.append(d===!0?ms([j],x,l):d===null?j:j+"[]",u(S))}),!1}return Ys(m)?!0:(a.append(ms(D,j,l),u(m)),!1)}const A=[],w=Object.assign(fd,{defaultVisitor:p,convertValue:u,isVisitable:Ys});function b(m,j,D=0){if(!Z.isUndefined(m)){if(D>g)throw new Ae("Object is too deeply nested ("+D+" levels). Max depth: "+g,Ae.ERR_FORM_DATA_DEPTH_EXCEEDED);if(A.indexOf(m)!==-1)throw Error("Circular reference detected in "+j.join("."));A.push(m),Z.forEach(m,function(k,S){(!(Z.isUndefined(k)||k===null)&&o.call(a,k,Z.isString(S)?S.trim():S,j,w))===!0&&b(k,j?j.concat(S):[S],D+1)}),A.pop()}}if(!Z.isObject(t))throw new TypeError("data must be an object");return b(t),a}function br(t){const a={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(t).replace(/[!'()~]|%20/g,function(i){return a[i]})}function Js(t,a){this._pairs=[],t&&es(t,this,a)}const Co=Js.prototype;Co.append=function(a,s){this._pairs.push([a,s])};Co.toString=function(a){const s=a?function(i){return a.call(this,i,br)}:br;return this._pairs.map(function(o){return s(o[0])+"="+s(o[1])},"").join("&")};function yd(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Ao(t,a,s){if(!a)return t;const i=s&&s.encode||yd,o=Z.isFunction(s)?{serialize:s}:s,l=o&&o.serialize;let d;if(l?d=l(a,o):d=Z.isURLSearchParams(a)?a.toString():new Js(a,o).toString(i),d){const c=t.indexOf("#");c!==-1&&(t=t.slice(0,c)),t+=(t.indexOf("?")===-1?"?":"&")+d}return t}class jr{constructor(){this.handlers=[]}use(a,s,i){return this.handlers.push({fulfilled:a,rejected:s,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(a){this.handlers[a]&&(this.handlers[a]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(a){Z.forEach(this.handlers,function(i){i!==null&&a(i)})}}const Qs={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},gd=typeof URLSearchParams<"u"?URLSearchParams:Js,xd=typeof FormData<"u"?FormData:null,bd=typeof Blob<"u"?Blob:null,jd={isBrowser:!0,classes:{URLSearchParams:gd,FormData:xd,Blob:bd},protocols:["http","https","file","blob","url","data"]},Xs=typeof window<"u"&&typeof document<"u",Vs=typeof navigator=="object"&&navigator||void 0,Sd=Xs&&(!Vs||["ReactNative","NativeScript","NS"].indexOf(Vs.product)<0),wd=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",vd=Xs&&window.location.href||"http://localhost",_d=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Xs,hasStandardBrowserEnv:Sd,hasStandardBrowserWebWorkerEnv:wd,navigator:Vs,origin:vd},Symbol.toStringTag,{value:"Module"})),nt={..._d,...jd};function Cd(t,a){return es(t,new nt.classes.URLSearchParams,{visitor:function(s,i,o,l){return nt.isNode&&Z.isBuffer(s)?(this.append(i,s.toString("base64")),!1):l.defaultVisitor.apply(this,arguments)},...a})}function Ad(t){return Z.matchAll(/\w+|\[(\w*)]/g,t).map(a=>a[0]==="[]"?"":a[1]||a[0])}function Dd(t){const a={},s=Object.keys(t);let i;const o=s.length;let l;for(i=0;i<o;i++)l=s[i],a[l]=t[l];return a}function Do(t){function a(s,i,o,l){let d=s[l++];if(d==="__proto__")return!0;const c=Number.isFinite(+d),g=l>=s.length;return d=!d&&Z.isArray(o)?o.length:d,g?(Z.hasOwnProp(o,d)?o[d]=Z.isArray(o[d])?o[d].concat(i):[o[d],i]:o[d]=i,!c):((!o[d]||!Z.isObject(o[d]))&&(o[d]=[]),a(s,i,o[d],l)&&Z.isArray(o[d])&&(o[d]=Dd(o[d])),!c)}if(Z.isFormData(t)&&Z.isFunction(t.entries)){const s={};return Z.forEachEntry(t,(i,o)=>{a(Ad(i),o,s,0)}),s}return null}const ea=(t,a)=>t!=null&&Z.hasOwnProp(t,a)?t[a]:void 0;function Td(t,a,s){if(Z.isString(t))try{return(a||JSON.parse)(t),Z.trim(t)}catch(i){if(i.name!=="SyntaxError")throw i}return(s||JSON.stringify)(t)}const Ga={transitional:Qs,adapter:["xhr","http","fetch"],transformRequest:[function(a,s){const i=s.getContentType()||"",o=i.indexOf("application/json")>-1,l=Z.isObject(a);if(l&&Z.isHTMLForm(a)&&(a=new FormData(a)),Z.isFormData(a))return o?JSON.stringify(Do(a)):a;if(Z.isArrayBuffer(a)||Z.isBuffer(a)||Z.isStream(a)||Z.isFile(a)||Z.isBlob(a)||Z.isReadableStream(a))return a;if(Z.isArrayBufferView(a))return a.buffer;if(Z.isURLSearchParams(a))return s.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),a.toString();let c;if(l){const g=ea(this,"formSerializer");if(i.indexOf("application/x-www-form-urlencoded")>-1)return Cd(a,g).toString();if((c=Z.isFileList(a))||i.indexOf("multipart/form-data")>-1){const h=ea(this,"env"),u=h&&h.FormData;return es(c?{"files[]":a}:a,u&&new u,g)}}return l||o?(s.setContentType("application/json",!1),Td(a)):a}],transformResponse:[function(a){const s=ea(this,"transitional")||Ga.transitional,i=s&&s.forcedJSONParsing,o=ea(this,"responseType"),l=o==="json";if(Z.isResponse(a)||Z.isReadableStream(a))return a;if(a&&Z.isString(a)&&(i&&!o||l)){const c=!(s&&s.silentJSONParsing)&&l;try{return JSON.parse(a,ea(this,"parseReviver"))}catch(g){if(c)throw g.name==="SyntaxError"?Ae.from(g,Ae.ERR_BAD_RESPONSE,this,null,ea(this,"response")):g}}return a}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:nt.classes.FormData,Blob:nt.classes.Blob},validateStatus:function(a){return a>=200&&a<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Z.forEach(["delete","get","head","post","put","patch"],t=>{Ga.headers[t]={}});const Rd=Z.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Id=t=>{const a={};let s,i,o;return t&&t.split(`
|
|
2
|
+
`).forEach(function(d){o=d.indexOf(":"),s=d.substring(0,o).trim().toLowerCase(),i=d.substring(o+1).trim(),!(!s||a[s]&&Rd[s])&&(s==="set-cookie"?a[s]?a[s].push(i):a[s]=[i]:a[s]=a[s]?a[s]+", "+i:i)}),a},Sr=Symbol("internals"),kd=/[^\x09\x20-\x7E\x80-\xFF]/g;function Pd(t){let a=0,s=t.length;for(;a<s;){const i=t.charCodeAt(a);if(i!==9&&i!==32)break;a+=1}for(;s>a;){const i=t.charCodeAt(s-1);if(i!==9&&i!==32)break;s-=1}return a===0&&s===t.length?t:t.slice(a,s)}function va(t){return t&&String(t).trim().toLowerCase()}function Od(t){return Pd(t.replace(kd,""))}function Pn(t){return t===!1||t==null?t:Z.isArray(t)?t.map(Pn):Od(String(t))}function Md(t){const a=Object.create(null),s=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let i;for(;i=s.exec(t);)a[i[1]]=i[2];return a}const Ed=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function hs(t,a,s,i,o){if(Z.isFunction(i))return i.call(this,a,s);if(o&&(a=s),!!Z.isString(a)){if(Z.isString(i))return a.indexOf(i)!==-1;if(Z.isRegExp(i))return i.test(a)}}function Fd(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(a,s,i)=>s.toUpperCase()+i)}function Ud(t,a){const s=Z.toCamelCase(" "+a);["get","set","has"].forEach(i=>{Object.defineProperty(t,i+s,{value:function(o,l,d){return this[i].call(this,a,o,l,d)},configurable:!0})})}let pt=class{constructor(a){a&&this.set(a)}set(a,s,i){const o=this;function l(c,g,h){const u=va(g);if(!u)throw new Error("header name must be a non-empty string");const p=Z.findKey(o,u);(!p||o[p]===void 0||h===!0||h===void 0&&o[p]!==!1)&&(o[p||g]=Pn(c))}const d=(c,g)=>Z.forEach(c,(h,u)=>l(h,u,g));if(Z.isPlainObject(a)||a instanceof this.constructor)d(a,s);else if(Z.isString(a)&&(a=a.trim())&&!Ed(a))d(Id(a),s);else if(Z.isObject(a)&&Z.isIterable(a)){let c={},g,h;for(const u of a){if(!Z.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[h=u[0]]=(g=c[h])?Z.isArray(g)?[...g,u[1]]:[g,u[1]]:u[1]}d(c,s)}else a!=null&&l(s,a,i);return this}get(a,s){if(a=va(a),a){const i=Z.findKey(this,a);if(i){const o=this[i];if(!s)return o;if(s===!0)return Md(o);if(Z.isFunction(s))return s.call(this,o,i);if(Z.isRegExp(s))return s.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(a,s){if(a=va(a),a){const i=Z.findKey(this,a);return!!(i&&this[i]!==void 0&&(!s||hs(this,this[i],i,s)))}return!1}delete(a,s){const i=this;let o=!1;function l(d){if(d=va(d),d){const c=Z.findKey(i,d);c&&(!s||hs(i,i[c],c,s))&&(delete i[c],o=!0)}}return Z.isArray(a)?a.forEach(l):l(a),o}clear(a){const s=Object.keys(this);let i=s.length,o=!1;for(;i--;){const l=s[i];(!a||hs(this,this[l],l,a,!0))&&(delete this[l],o=!0)}return o}normalize(a){const s=this,i={};return Z.forEach(this,(o,l)=>{const d=Z.findKey(i,l);if(d){s[d]=Pn(o),delete s[l];return}const c=a?Fd(l):String(l).trim();c!==l&&delete s[l],s[c]=Pn(o),i[c]=!0}),this}concat(...a){return this.constructor.concat(this,...a)}toJSON(a){const s=Object.create(null);return Z.forEach(this,(i,o)=>{i!=null&&i!==!1&&(s[o]=a&&Z.isArray(i)?i.join(", "):i)}),s}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([a,s])=>a+": "+s).join(`
|
|
3
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(a){return a instanceof this?a:new this(a)}static concat(a,...s){const i=new this(a);return s.forEach(o=>i.set(o)),i}static accessor(a){const i=(this[Sr]=this[Sr]={accessors:{}}).accessors,o=this.prototype;function l(d){const c=va(d);i[c]||(Ud(o,d),i[c]=!0)}return Z.isArray(a)?a.forEach(l):l(a),this}};pt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Z.reduceDescriptors(pt.prototype,({value:t},a)=>{let s=a[0].toUpperCase()+a.slice(1);return{get:()=>t,set(i){this[s]=i}}});Z.freezeMethods(pt);function fs(t,a){const s=this||Ga,i=a||s,o=pt.from(i.headers);let l=i.data;return Z.forEach(t,function(c){l=c.call(s,l,o.normalize(),a?a.status:void 0)}),o.normalize(),l}function To(t){return!!(t&&t.__CANCEL__)}let Ja=class extends Ae{constructor(a,s,i){super(a??"canceled",Ae.ERR_CANCELED,s,i),this.name="CanceledError",this.__CANCEL__=!0}};function Ro(t,a,s){const i=s.config.validateStatus;!s.status||!i||i(s.status)?t(s):a(new Ae("Request failed with status code "+s.status,[Ae.ERR_BAD_REQUEST,Ae.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s))}function $d(t){const a=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return a&&a[1]||""}function Nd(t,a){t=t||10;const s=new Array(t),i=new Array(t);let o=0,l=0,d;return a=a!==void 0?a:1e3,function(g){const h=Date.now(),u=i[l];d||(d=h),s[o]=g,i[o]=h;let p=l,A=0;for(;p!==o;)A+=s[p++],p=p%t;if(o=(o+1)%t,o===l&&(l=(l+1)%t),h-d<a)return;const w=u&&h-u;return w?Math.round(A*1e3/w):void 0}}function Ld(t,a){let s=0,i=1e3/a,o,l;const d=(h,u=Date.now())=>{s=u,o=null,l&&(clearTimeout(l),l=null),t(...h)};return[(...h)=>{const u=Date.now(),p=u-s;p>=i?d(h,u):(o=h,l||(l=setTimeout(()=>{l=null,d(o)},i-p)))},()=>o&&d(o)]}const Kn=(t,a,s=3)=>{let i=0;const o=Nd(50,250);return Ld(l=>{const d=l.loaded,c=l.lengthComputable?l.total:void 0,g=c!=null?Math.min(d,c):d,h=Math.max(0,g-i),u=o(h);i=Math.max(i,g);const p={loaded:g,total:c,progress:c?g/c:void 0,bytes:h,rate:u||void 0,estimated:u&&c?(c-g)/u:void 0,event:l,lengthComputable:c!=null,[a?"download":"upload"]:!0};t(p)},s)},wr=(t,a)=>{const s=t!=null;return[i=>a[0]({lengthComputable:s,total:t,loaded:i}),a[1]]},vr=t=>(...a)=>Z.asap(()=>t(...a)),Bd=nt.hasStandardBrowserEnv?((t,a)=>s=>(s=new URL(s,nt.origin),t.protocol===s.protocol&&t.host===s.host&&(a||t.port===s.port)))(new URL(nt.origin),nt.navigator&&/(msie|trident)/i.test(nt.navigator.userAgent)):()=>!0,qd=nt.hasStandardBrowserEnv?{write(t,a,s,i,o,l,d){if(typeof document>"u")return;const c=[`${t}=${encodeURIComponent(a)}`];Z.isNumber(s)&&c.push(`expires=${new Date(s).toUTCString()}`),Z.isString(i)&&c.push(`path=${i}`),Z.isString(o)&&c.push(`domain=${o}`),l===!0&&c.push("secure"),Z.isString(d)&&c.push(`SameSite=${d}`),document.cookie=c.join("; ")},read(t){if(typeof document>"u")return null;const a=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return a?decodeURIComponent(a[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function zd(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function Yd(t,a){return a?t.replace(/\/?\/$/,"")+"/"+a.replace(/^\/+/,""):t}function Io(t,a,s){let i=!zd(a);return t&&(i||s===!1)?Yd(t,a):a}const _r=t=>t instanceof pt?{...t}:t;function Qt(t,a){a=a||{};const s=Object.create(null);Object.defineProperty(s,"hasOwnProperty",{value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function i(h,u,p,A){return Z.isPlainObject(h)&&Z.isPlainObject(u)?Z.merge.call({caseless:A},h,u):Z.isPlainObject(u)?Z.merge({},u):Z.isArray(u)?u.slice():u}function o(h,u,p,A){if(Z.isUndefined(u)){if(!Z.isUndefined(h))return i(void 0,h,p,A)}else return i(h,u,p,A)}function l(h,u){if(!Z.isUndefined(u))return i(void 0,u)}function d(h,u){if(Z.isUndefined(u)){if(!Z.isUndefined(h))return i(void 0,h)}else return i(void 0,u)}function c(h,u,p){if(Z.hasOwnProp(a,p))return i(h,u);if(Z.hasOwnProp(t,p))return i(void 0,h)}const g={url:l,method:l,data:l,baseURL:d,transformRequest:d,transformResponse:d,paramsSerializer:d,timeout:d,timeoutMessage:d,withCredentials:d,withXSRFToken:d,adapter:d,responseType:d,xsrfCookieName:d,xsrfHeaderName:d,onUploadProgress:d,onDownloadProgress:d,decompress:d,maxContentLength:d,maxBodyLength:d,beforeRedirect:d,transport:d,httpAgent:d,httpsAgent:d,cancelToken:d,socketPath:d,allowedSocketPaths:d,responseEncoding:d,validateStatus:c,headers:(h,u,p)=>o(_r(h),_r(u),p,!0)};return Z.forEach(Object.keys({...t,...a}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;const p=Z.hasOwnProp(g,u)?g[u]:o,A=Z.hasOwnProp(t,u)?t[u]:void 0,w=Z.hasOwnProp(a,u)?a[u]:void 0,b=p(A,w,u);Z.isUndefined(b)&&p!==c||(s[u]=b)}),s}const ko=t=>{const a=Qt({},t),s=A=>Z.hasOwnProp(a,A)?a[A]:void 0,i=s("data");let o=s("withXSRFToken");const l=s("xsrfHeaderName"),d=s("xsrfCookieName");let c=s("headers");const g=s("auth"),h=s("baseURL"),u=s("allowAbsoluteUrls"),p=s("url");if(a.headers=c=pt.from(c),a.url=Ao(Io(h,p,u),t.params,t.paramsSerializer),g&&c.set("Authorization","Basic "+btoa((g.username||"")+":"+(g.password?unescape(encodeURIComponent(g.password)):""))),Z.isFormData(i)){if(nt.hasStandardBrowserEnv||nt.hasStandardBrowserWebWorkerEnv)c.setContentType(void 0);else if(Z.isFunction(i.getHeaders)){const A=i.getHeaders(),w=["content-type","content-length"];Object.entries(A).forEach(([b,m])=>{w.includes(b.toLowerCase())&&c.set(b,m)})}}if(nt.hasStandardBrowserEnv&&(Z.isFunction(o)&&(o=o(a)),o===!0||o==null&&Bd(a.url))){const w=l&&d&&qd.read(d);w&&c.set(l,w)}return a},Vd=typeof XMLHttpRequest<"u",Wd=Vd&&function(t){return new Promise(function(s,i){const o=ko(t);let l=o.data;const d=pt.from(o.headers).normalize();let{responseType:c,onUploadProgress:g,onDownloadProgress:h}=o,u,p,A,w,b;function m(){w&&w(),b&&b(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let j=new XMLHttpRequest;j.open(o.method.toUpperCase(),o.url,!0),j.timeout=o.timeout;function D(){if(!j)return;const k=pt.from("getAllResponseHeaders"in j&&j.getAllResponseHeaders()),x={data:!c||c==="text"||c==="json"?j.responseText:j.response,status:j.status,statusText:j.statusText,headers:k,config:t,request:j};Ro(function(_){s(_),m()},function(_){i(_),m()},x),j=null}"onloadend"in j?j.onloadend=D:j.onreadystatechange=function(){!j||j.readyState!==4||j.status===0&&!(j.responseURL&&j.responseURL.indexOf("file:")===0)||setTimeout(D)},j.onabort=function(){j&&(i(new Ae("Request aborted",Ae.ECONNABORTED,t,j)),j=null)},j.onerror=function(S){const x=S&&S.message?S.message:"Network Error",f=new Ae(x,Ae.ERR_NETWORK,t,j);f.event=S||null,i(f),j=null},j.ontimeout=function(){let S=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const x=o.transitional||Qs;o.timeoutErrorMessage&&(S=o.timeoutErrorMessage),i(new Ae(S,x.clarifyTimeoutError?Ae.ETIMEDOUT:Ae.ECONNABORTED,t,j)),j=null},l===void 0&&d.setContentType(null),"setRequestHeader"in j&&Z.forEach(d.toJSON(),function(S,x){j.setRequestHeader(x,S)}),Z.isUndefined(o.withCredentials)||(j.withCredentials=!!o.withCredentials),c&&c!=="json"&&(j.responseType=o.responseType),h&&([A,b]=Kn(h,!0),j.addEventListener("progress",A)),g&&j.upload&&([p,w]=Kn(g),j.upload.addEventListener("progress",p),j.upload.addEventListener("loadend",w)),(o.cancelToken||o.signal)&&(u=k=>{j&&(i(!k||k.type?new Ja(null,t,j):k),j.abort(),j=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const R=$d(o.url);if(R&&nt.protocols.indexOf(R)===-1){i(new Ae("Unsupported protocol "+R+":",Ae.ERR_BAD_REQUEST,t));return}j.send(l||null)})},Hd=(t,a)=>{const{length:s}=t=t?t.filter(Boolean):[];if(a||s){let i=new AbortController,o;const l=function(h){if(!o){o=!0,c();const u=h instanceof Error?h:this.reason;i.abort(u instanceof Ae?u:new Ja(u instanceof Error?u.message:u))}};let d=a&&setTimeout(()=>{d=null,l(new Ae(`timeout of ${a}ms exceeded`,Ae.ETIMEDOUT))},a);const c=()=>{t&&(d&&clearTimeout(d),d=null,t.forEach(h=>{h.unsubscribe?h.unsubscribe(l):h.removeEventListener("abort",l)}),t=null)};t.forEach(h=>h.addEventListener("abort",l));const{signal:g}=i;return g.unsubscribe=()=>Z.asap(c),g}},Kd=function*(t,a){let s=t.byteLength;if(s<a){yield t;return}let i=0,o;for(;i<s;)o=i+a,yield t.slice(i,o),i=o},Gd=async function*(t,a){for await(const s of Jd(t))yield*Kd(s,a)},Jd=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const a=t.getReader();try{for(;;){const{done:s,value:i}=await a.read();if(s)break;yield i}}finally{await a.cancel()}},Cr=(t,a,s,i)=>{const o=Gd(t,a);let l=0,d,c=g=>{d||(d=!0,i&&i(g))};return new ReadableStream({async pull(g){try{const{done:h,value:u}=await o.next();if(h){c(),g.close();return}let p=u.byteLength;if(s){let A=l+=p;s(A)}g.enqueue(new Uint8Array(u))}catch(h){throw c(h),h}},cancel(g){return c(g),o.return()}},{highWaterMark:2})},Ar=64*1024,{isFunction:pn}=Z,Qd=(({Request:t,Response:a})=>({Request:t,Response:a}))(Z.global),{ReadableStream:Dr,TextEncoder:Tr}=Z.global,Rr=(t,...a)=>{try{return!!t(...a)}catch{return!1}},Xd=t=>{t=Z.merge.call({skipUndefined:!0},Qd,t);const{fetch:a,Request:s,Response:i}=t,o=a?pn(a):typeof fetch=="function",l=pn(s),d=pn(i);if(!o)return!1;const c=o&&pn(Dr),g=o&&(typeof Tr=="function"?(b=>m=>b.encode(m))(new Tr):async b=>new Uint8Array(await new s(b).arrayBuffer())),h=l&&c&&Rr(()=>{let b=!1;const m=new s(nt.origin,{body:new Dr,method:"POST",get duplex(){return b=!0,"half"}}),j=m.headers.has("Content-Type");return m.body!=null&&m.body.cancel(),b&&!j}),u=d&&c&&Rr(()=>Z.isReadableStream(new i("").body)),p={stream:u&&(b=>b.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(b=>{!p[b]&&(p[b]=(m,j)=>{let D=m&&m[b];if(D)return D.call(m);throw new Ae(`Response type '${b}' is not supported`,Ae.ERR_NOT_SUPPORT,j)})});const A=async b=>{if(b==null)return 0;if(Z.isBlob(b))return b.size;if(Z.isSpecCompliantForm(b))return(await new s(nt.origin,{method:"POST",body:b}).arrayBuffer()).byteLength;if(Z.isArrayBufferView(b)||Z.isArrayBuffer(b))return b.byteLength;if(Z.isURLSearchParams(b)&&(b=b+""),Z.isString(b))return(await g(b)).byteLength},w=async(b,m)=>{const j=Z.toFiniteNumber(b.getContentLength());return j??A(m)};return async b=>{let{url:m,method:j,data:D,signal:R,cancelToken:k,timeout:S,onDownloadProgress:x,onUploadProgress:f,responseType:_,headers:T,withCredentials:I="same-origin",fetchOptions:B}=ko(b),L=a||fetch;_=_?(_+"").toLowerCase():"text";let y=Hd([R,k&&k.toAbortSignal()],S),P=null;const O=y&&y.unsubscribe&&(()=>{y.unsubscribe()});let $;try{if(f&&h&&j!=="get"&&j!=="head"&&($=await w(T,D))!==0){let M=new s(m,{method:"POST",body:D,duplex:"half"}),F;if(Z.isFormData(D)&&(F=M.headers.get("content-type"))&&T.setContentType(F),M.body){const[q,H]=wr($,Kn(vr(f)));D=Cr(M.body,Ar,q,H)}}Z.isString(I)||(I=I?"include":"omit");const U=l&&"credentials"in s.prototype;if(Z.isFormData(D)){const M=T.getContentType();M&&/^multipart\/form-data/i.test(M)&&!/boundary=/i.test(M)&&T.delete("content-type")}const N={...B,signal:y,method:j.toUpperCase(),headers:T.normalize().toJSON(),body:D,duplex:"half",credentials:U?I:void 0};P=l&&new s(m,N);let V=await(l?L(P,B):L(m,N));const z=u&&(_==="stream"||_==="response");if(u&&(x||z&&O)){const M={};["status","statusText","headers"].forEach(re=>{M[re]=V[re]});const F=Z.toFiniteNumber(V.headers.get("content-length")),[q,H]=x&&wr(F,Kn(vr(x),!0))||[];V=new i(Cr(V.body,Ar,q,()=>{H&&H(),O&&O()}),M)}_=_||"text";let E=await p[Z.findKey(p,_)||"text"](V,b);return!z&&O&&O(),await new Promise((M,F)=>{Ro(M,F,{data:E,headers:pt.from(V.headers),status:V.status,statusText:V.statusText,config:b,request:P})})}catch(U){throw O&&O(),U&&U.name==="TypeError"&&/Load failed|fetch/i.test(U.message)?Object.assign(new Ae("Network Error",Ae.ERR_NETWORK,b,P,U&&U.response),{cause:U.cause||U}):Ae.from(U,U&&U.code,b,P,U&&U.response)}}},Zd=new Map,Po=t=>{let a=t&&t.env||{};const{fetch:s,Request:i,Response:o}=a,l=[i,o,s];let d=l.length,c=d,g,h,u=Zd;for(;c--;)g=l[c],h=u.get(g),h===void 0&&u.set(g,h=c?new Map:Xd(a)),u=h;return h};Po();const Zs={http:md,xhr:Wd,fetch:{get:Po}};Z.forEach(Zs,(t,a)=>{if(t){try{Object.defineProperty(t,"name",{value:a})}catch{}Object.defineProperty(t,"adapterName",{value:a})}});const Ir=t=>`- ${t}`,ec=t=>Z.isFunction(t)||t===null||t===!1;function tc(t,a){t=Z.isArray(t)?t:[t];const{length:s}=t;let i,o;const l={};for(let d=0;d<s;d++){i=t[d];let c;if(o=i,!ec(i)&&(o=Zs[(c=String(i)).toLowerCase()],o===void 0))throw new Ae(`Unknown adapter '${c}'`);if(o&&(Z.isFunction(o)||(o=o.get(a))))break;l[c||"#"+d]=o}if(!o){const d=Object.entries(l).map(([g,h])=>`adapter ${g} `+(h===!1?"is not supported by the environment":"is not available in the build"));let c=s?d.length>1?`since :
|
|
4
|
+
`+d.map(Ir).join(`
|
|
5
|
+
`):" "+Ir(d[0]):"as no adapter specified";throw new Ae("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return o}const Oo={getAdapter:tc,adapters:Zs};function ys(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Ja(null,t)}function kr(t){return ys(t),t.headers=pt.from(t.headers),t.data=fs.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),Oo.getAdapter(t.adapter||Ga.adapter,t)(t).then(function(i){return ys(t),i.data=fs.call(t,t.transformResponse,i),i.headers=pt.from(i.headers),i},function(i){return To(i)||(ys(t),i&&i.response&&(i.response.data=fs.call(t,t.transformResponse,i.response),i.response.headers=pt.from(i.response.headers))),Promise.reject(i)})}const Mo="1.15.2",ts={};["object","boolean","number","function","string","symbol"].forEach((t,a)=>{ts[t]=function(i){return typeof i===t||"a"+(a<1?"n ":" ")+t}});const Pr={};ts.transitional=function(a,s,i){function o(l,d){return"[Axios v"+Mo+"] Transitional option '"+l+"'"+d+(i?". "+i:"")}return(l,d,c)=>{if(a===!1)throw new Ae(o(d," has been removed"+(s?" in "+s:"")),Ae.ERR_DEPRECATED);return s&&!Pr[d]&&(Pr[d]=!0,console.warn(o(d," has been deprecated since v"+s+" and will be removed in the near future"))),a?a(l,d,c):!0}};ts.spelling=function(a){return(s,i)=>(console.warn(`${i} is likely a misspelling of ${a}`),!0)};function ac(t,a,s){if(typeof t!="object")throw new Ae("options must be an object",Ae.ERR_BAD_OPTION_VALUE);const i=Object.keys(t);let o=i.length;for(;o-- >0;){const l=i[o],d=Object.prototype.hasOwnProperty.call(a,l)?a[l]:void 0;if(d){const c=t[l],g=c===void 0||d(c,l,t);if(g!==!0)throw new Ae("option "+l+" must be "+g,Ae.ERR_BAD_OPTION_VALUE);continue}if(s!==!0)throw new Ae("Unknown option "+l,Ae.ERR_BAD_OPTION)}}const On={assertOptions:ac,validators:ts},jt=On.validators;let Kt=class{constructor(a){this.defaults=a||{},this.interceptors={request:new jr,response:new jr}}async request(a,s){try{return await this._request(a,s)}catch(i){if(i instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const l=(()=>{if(!o.stack)return"";const d=o.stack.indexOf(`
|
|
6
|
+
`);return d===-1?"":o.stack.slice(d+1)})();try{if(!i.stack)i.stack=l;else if(l){const d=l.indexOf(`
|
|
7
7
|
`),c=d===-1?-1:l.indexOf(`
|
|
8
|
-
`,d+1),g=c===-1?"":l.slice(c+1);String(
|
|
9
|
-
`+l)}}catch{}}throw r}}_request(a,s){typeof a=="string"?(s=s||{},s.url=a):s=a||{},s=Jt(this.defaults,s);const{transitional:r,paramsSerializer:o,headers:l}=s;r!==void 0&&In.assertOptions(r,{silentJSONParsing:xt.transitional(xt.boolean),forcedJSONParsing:xt.transitional(xt.boolean),clarifyTimeoutError:xt.transitional(xt.boolean),legacyInterceptorReqResOrdering:xt.transitional(xt.boolean)},!1),o!=null&&(X.isFunction(o)?s.paramsSerializer={serialize:o}:In.assertOptions(o,{encode:xt.function,serialize:xt.function},!0)),s.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?s.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:s.allowAbsoluteUrls=!0),In.assertOptions(s,{baseUrl:xt.spelling("baseURL"),withXsrfToken:xt.spelling("withXSRFToken")},!0),s.method=(s.method||this.defaults.method||"get").toLowerCase();let d=l&&X.merge(l.common,l[s.method]);l&&X.forEach(["delete","get","head","post","put","patch","common"],y=>{delete l[y]}),s.headers=ct.concat(d,l);const c=[];let g=!0;this.interceptors.request.forEach(function(m){if(typeof m.runWhen=="function"&&m.runWhen(s)===!1)return;g=g&&m.synchronous;const x=s.transitional||Hs;x&&x.legacyInterceptorReqResOrdering?c.unshift(m.fulfilled,m.rejected):c.push(m.fulfilled,m.rejected)});const f=[];this.interceptors.response.forEach(function(m){f.push(m.fulfilled,m.rejected)});let u,p=0,w;if(!g){const y=[Tr.bind(this),void 0];for(y.unshift(...c),y.push(...f),w=y.length,u=Promise.resolve(s);p<w;)u=u.then(y[p++],y[p++]);return u}w=c.length;let v=s;for(;p<w;){const y=c[p++],m=c[p++];try{v=y(v)}catch(x){m.call(this,x);break}}try{u=Tr.call(this,v)}catch(y){return Promise.reject(y)}for(p=0,w=f.length;p<w;)u=u.then(f[p++],f[p++]);return u}getUri(a){a=Jt(this.defaults,a);const s=jo(a.baseURL,a.url,a.allowAbsoluteUrls);return yo(s,a.params,a.paramsSerializer)}};X.forEach(["delete","get","head","options"],function(a){Ht.prototype[a]=function(s,r){return this.request(Jt(r||{},{method:a,url:s,data:(r||{}).data}))}});X.forEach(["post","put","patch"],function(a){function s(r){return function(l,d,c){return this.request(Jt(c||{},{method:a,headers:r?{"Content-Type":"multipart/form-data"}:{},url:l,data:d}))}}Ht.prototype[a]=s(),Ht.prototype[a+"Form"]=s(!0)});let Bd=class Co{constructor(a){if(typeof a!="function")throw new TypeError("executor must be a function.");let s;this.promise=new Promise(function(l){s=l});const r=this;this.promise.then(o=>{if(!r._listeners)return;let l=r._listeners.length;for(;l-- >0;)r._listeners[l](o);r._listeners=null}),this.promise.then=o=>{let l;const d=new Promise(c=>{r.subscribe(c),l=c}).then(o);return d.cancel=function(){r.unsubscribe(l)},d},a(function(l,d,c){r.reason||(r.reason=new Ja(l,d,c),s(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(a){if(this.reason){a(this.reason);return}this._listeners?this._listeners.push(a):this._listeners=[a]}unsubscribe(a){if(!this._listeners)return;const s=this._listeners.indexOf(a);s!==-1&&this._listeners.splice(s,1)}toAbortSignal(){const a=new AbortController,s=r=>{a.abort(r)};return this.subscribe(s),a.signal.unsubscribe=()=>this.unsubscribe(s),a.signal}static source(){let a;return{token:new Co(function(o){a=o}),cancel:a}}};function Ld(t){return function(s){return t.apply(null,s)}}function qd(t){return X.isObject(t)&&t.isAxiosError===!0}const zs={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(zs).forEach(([t,a])=>{zs[a]=t});function Ao(t){const a=new Ht(t),s=so(Ht.prototype.request,a);return X.extend(s,Ht.prototype,a,{allOwnKeys:!0}),X.extend(s,a,null,{allOwnKeys:!0}),s.create=function(o){return Ao(Jt(t,o))},s}const ze=Ao(Ga);ze.Axios=Ht;ze.CanceledError=Ja;ze.CancelToken=Bd;ze.isCancel=xo;ze.VERSION=_o;ze.toFormData=Qn;ze.AxiosError=Ce;ze.Cancel=ze.CanceledError;ze.all=function(a){return Promise.all(a)};ze.spread=Ld;ze.isAxiosError=qd;ze.mergeConfig=Jt;ze.AxiosHeaders=ct;ze.formToJSON=t=>go(X.isHTMLForm(t)?new FormData(t):t);ze.getAdapter=wo.getAdapter;ze.HttpStatusCode=zs;ze.default=ze;const{Axios:vg,AxiosError:wg,CanceledError:_g,isCancel:Cg,CancelToken:Ag,VERSION:Tg,all:Dg,Cancel:Rg,isAxiosError:Ig,spread:kg,toFormData:Pg,AxiosHeaders:Og,HttpStatusCode:Mg,formToJSON:Eg,getAdapter:Fg,mergeConfig:$g}=ze,zd=()=>new Promise(t=>setTimeout(()=>t(),800));let Ys=null;const Yd=t=>{Ys=t,Ct.defaults.baseURL=Js()},Js=()=>Ys||"https://npmapi.ubkerp.com/",Ct=ze.create({baseURL:Js()}),at=()=>Js(),Ne=async(t,a,s)=>{const r=await Ct.post(t,a,{headers:{Authorization:s}});if(console.log("ddddfdfdfd",r.data?.Status),r.data?.Status=="Success")return r?.data?.data||r?.data;throw new Error(r.data?.msg)},J=async(t,a)=>{try{let r=t;if(!t.includes("session_id")){const l=t.includes("?")?"&":"?";r=`${t}${l}session_id=1`}return(await Ct.get(r,{headers:{Authorization:a}})).data}catch(s){throw s.response?.status===401&&console.error("401 Unauthorized"),s}},Vd=async(t,a)=>{const s=await Ct.post(t,"",{headers:{Authorization:a}});if(s.data?.Status=="Success")return s?.data?.data||s?.data;throw new Error(s.data?.msg)},Zn=async(t,a,s)=>{try{const r=await Ct.post(t,a,{headers:{Authorization:s,"Content-Type":"application/json"}});return r.data?.Status==="Success"?r.data:(_.error(r.data?.msg||"Unable to issue library book",{duration:2e3}),!1)}catch(r){throw _.error(r.response?.data?.msg||r.response?.data?.message||"Request failed",{duration:2e3}),r}},za=async(t,a,s)=>{const r=a?.arg;return(await Ct.post(t,r,{headers:{Authorization:s}}))?.data},Kt=async(t,a,s)=>{const r=a?.arg,o=t.includes("?")?"&":"?";return(await Ct.get(t+o,{params:r,headers:{Authorization:s}}))?.data},Wd="api/branchapi/GeneralSettings/getsetting_allowances_dedectionBranch",Qs=async(t,a,s)=>{const r=a?.arg,o=t.includes("?")?"&":"?",l=await Ct.get(t+o,{params:r,headers:{Authorization:s}});if(console.log("ddddfdfdfd",l.data?.Status),l.data?.Status=="Success")return l?.data?.data||l?.data;throw new Error(l.data?.msg)},Qe=async(t,a,s)=>(await zd(),(await Ct.post(t,a,{headers:{Authorization:s}}))?.data),Qa=async(t,a,s)=>(await Ct.post(t,a,{headers:{Authorization:s}})).data,Ve=async(t,a,s)=>(await Ct.delete(`${t}/${a}`,{headers:{Authorization:s}})).data,Hd="api/report/LibraryRenewalReport/renewalHistory",Kd="api/report/LibraryRenewalReport/renewalFineReport",Gd="api/report/LibraryRenewalReport/currentlyRenewedBooks",Jd="api/report/LibraryRenewalReport/upcomingRenewalDue",Qd="api/report/LibraryRenewalReport/overdueRenewalReport",Xd="api/report/LibraryRenewalReport/renewalLimitReport",Zd="api/report/LibraryRenewalReport/renewalStatusReport",ec="api/report/LibraryRenewalReport/studentWiseReport",tc="api/report/LibraryRenewalReport/bookWiseReport",ac="api/report/LibraryRenewalReport/classWiseReport",nc="api/report/LibraryRenewalReport/staffWiseReport",sc="api/report/LibraryRenewalReport/renewalStatisticsByDate",rc="/sample_templates/route_upload.xlsx",ic="/sample_templates/student_transport_upload.xlsx",oc=({token:t,menu:a})=>{const{isLoading:s,data:r}=G(t?["api/sdk/Menus",t]:null,([l,d])=>Vd(l,d)),o=r?.find(l=>l.path===a)?.sub_menu??[];return console.log("menuData",r),e.jsx(n.Row,{gutter:[16,16],children:o?.map((l,d)=>l.dashboard_show==="YES"?e.jsx(n.Col,{xs:24,md:8,lg:8,children:e.jsx(E,{children:e.jsx(no,{icon:`${at()}icons/frontoffice/${l.icons}`,title:l.submenu_name,path:l.menu_key})})},`${d}office001`):null)})};function To(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Xe={},fs,Rr;function lc(){return Rr||(Rr=1,fs=function t(a,s){if(a===s)return!0;if(a&&s&&typeof a=="object"&&typeof s=="object"){if(a.constructor!==s.constructor)return!1;var r,o,l;if(Array.isArray(a)){if(r=a.length,r!=s.length)return!1;for(o=r;o--!==0;)if(!t(a[o],s[o]))return!1;return!0}if(a.constructor===RegExp)return a.source===s.source&&a.flags===s.flags;if(a.valueOf!==Object.prototype.valueOf)return a.valueOf()===s.valueOf();if(a.toString!==Object.prototype.toString)return a.toString()===s.toString();if(l=Object.keys(a),r=l.length,r!==Object.keys(s).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(s,l[o]))return!1;for(o=r;o--!==0;){var d=l[o];if(!t(a[d],s[d]))return!1}return!0}return a!==a&&s!==s}),fs}var un={exports:{}},pn={exports:{}},ke={};var Ir;function dc(){if(Ir)return ke;Ir=1;var t=typeof Symbol=="function"&&Symbol.for,a=t?Symbol.for("react.element"):60103,s=t?Symbol.for("react.portal"):60106,r=t?Symbol.for("react.fragment"):60107,o=t?Symbol.for("react.strict_mode"):60108,l=t?Symbol.for("react.profiler"):60114,d=t?Symbol.for("react.provider"):60109,c=t?Symbol.for("react.context"):60110,g=t?Symbol.for("react.async_mode"):60111,f=t?Symbol.for("react.concurrent_mode"):60111,u=t?Symbol.for("react.forward_ref"):60112,p=t?Symbol.for("react.suspense"):60113,w=t?Symbol.for("react.suspense_list"):60120,v=t?Symbol.for("react.memo"):60115,y=t?Symbol.for("react.lazy"):60116,m=t?Symbol.for("react.block"):60121,x=t?Symbol.for("react.fundamental"):60117,T=t?Symbol.for("react.responder"):60118,D=t?Symbol.for("react.scope"):60119;function k(j){if(typeof j=="object"&&j!==null){var h=j.$$typeof;switch(h){case a:switch(j=j.type,j){case g:case f:case r:case l:case o:case p:return j;default:switch(j=j&&j.$$typeof,j){case c:case u:case y:case v:case d:return j;default:return h}}case s:return h}}}function C(j){return k(j)===f}return ke.AsyncMode=g,ke.ConcurrentMode=f,ke.ContextConsumer=c,ke.ContextProvider=d,ke.Element=a,ke.ForwardRef=u,ke.Fragment=r,ke.Lazy=y,ke.Memo=v,ke.Portal=s,ke.Profiler=l,ke.StrictMode=o,ke.Suspense=p,ke.isAsyncMode=function(j){return C(j)||k(j)===g},ke.isConcurrentMode=C,ke.isContextConsumer=function(j){return k(j)===c},ke.isContextProvider=function(j){return k(j)===d},ke.isElement=function(j){return typeof j=="object"&&j!==null&&j.$$typeof===a},ke.isForwardRef=function(j){return k(j)===u},ke.isFragment=function(j){return k(j)===r},ke.isLazy=function(j){return k(j)===y},ke.isMemo=function(j){return k(j)===v},ke.isPortal=function(j){return k(j)===s},ke.isProfiler=function(j){return k(j)===l},ke.isStrictMode=function(j){return k(j)===o},ke.isSuspense=function(j){return k(j)===p},ke.isValidElementType=function(j){return typeof j=="string"||typeof j=="function"||j===r||j===f||j===l||j===o||j===p||j===w||typeof j=="object"&&j!==null&&(j.$$typeof===y||j.$$typeof===v||j.$$typeof===d||j.$$typeof===c||j.$$typeof===u||j.$$typeof===x||j.$$typeof===T||j.$$typeof===D||j.$$typeof===m)},ke.typeOf=k,ke}var Pe={};var kr;function cc(){return kr||(kr=1,process.env.NODE_ENV!=="production"&&(function(){var t=typeof Symbol=="function"&&Symbol.for,a=t?Symbol.for("react.element"):60103,s=t?Symbol.for("react.portal"):60106,r=t?Symbol.for("react.fragment"):60107,o=t?Symbol.for("react.strict_mode"):60108,l=t?Symbol.for("react.profiler"):60114,d=t?Symbol.for("react.provider"):60109,c=t?Symbol.for("react.context"):60110,g=t?Symbol.for("react.async_mode"):60111,f=t?Symbol.for("react.concurrent_mode"):60111,u=t?Symbol.for("react.forward_ref"):60112,p=t?Symbol.for("react.suspense"):60113,w=t?Symbol.for("react.suspense_list"):60120,v=t?Symbol.for("react.memo"):60115,y=t?Symbol.for("react.lazy"):60116,m=t?Symbol.for("react.block"):60121,x=t?Symbol.for("react.fundamental"):60117,T=t?Symbol.for("react.responder"):60118,D=t?Symbol.for("react.scope"):60119;function k(le){return typeof le=="string"||typeof le=="function"||le===r||le===f||le===l||le===o||le===p||le===w||typeof le=="object"&&le!==null&&(le.$$typeof===y||le.$$typeof===v||le.$$typeof===d||le.$$typeof===c||le.$$typeof===u||le.$$typeof===x||le.$$typeof===T||le.$$typeof===D||le.$$typeof===m)}function C(le){if(typeof le=="object"&&le!==null){var de=le.$$typeof;switch(de){case a:var Q=le.type;switch(Q){case g:case f:case r:case l:case o:case p:return Q;default:var ce=Q&&Q.$$typeof;switch(ce){case c:case u:case y:case v:case d:return ce;default:return de}}case s:return de}}}var j=g,h=f,S=c,A=d,R=a,q=u,U=r,b=y,O=v,M=s,$=l,F=o,N=p,V=!1;function z(le){return V||(V=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),P(le)||C(le)===g}function P(le){return C(le)===f}function I(le){return C(le)===c}function B(le){return C(le)===d}function L(le){return typeof le=="object"&&le!==null&&le.$$typeof===a}function H(le){return C(le)===u}function se(le){return C(le)===r}function W(le){return C(le)===y}function K(le){return C(le)===v}function te(le){return C(le)===s}function oe(le){return C(le)===l}function pe(le){return C(le)===o}function we(le){return C(le)===p}Pe.AsyncMode=j,Pe.ConcurrentMode=h,Pe.ContextConsumer=S,Pe.ContextProvider=A,Pe.Element=R,Pe.ForwardRef=q,Pe.Fragment=U,Pe.Lazy=b,Pe.Memo=O,Pe.Portal=M,Pe.Profiler=$,Pe.StrictMode=F,Pe.Suspense=N,Pe.isAsyncMode=z,Pe.isConcurrentMode=P,Pe.isContextConsumer=I,Pe.isContextProvider=B,Pe.isElement=L,Pe.isForwardRef=H,Pe.isFragment=se,Pe.isLazy=W,Pe.isMemo=K,Pe.isPortal=te,Pe.isProfiler=oe,Pe.isStrictMode=pe,Pe.isSuspense=we,Pe.isValidElementType=k,Pe.typeOf=C})()),Pe}var Pr;function Do(){return Pr||(Pr=1,process.env.NODE_ENV==="production"?pn.exports=dc():pn.exports=cc()),pn.exports}var hs,Or;function uc(){if(Or)return hs;Or=1;var t=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;function r(l){if(l==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(l)}function o(){try{if(!Object.assign)return!1;var l=new String("abc");if(l[5]="de",Object.getOwnPropertyNames(l)[0]==="5")return!1;for(var d={},c=0;c<10;c++)d["_"+String.fromCharCode(c)]=c;var g=Object.getOwnPropertyNames(d).map(function(u){return d[u]});if(g.join("")!=="0123456789")return!1;var f={};return"abcdefghijklmnopqrst".split("").forEach(function(u){f[u]=u}),Object.keys(Object.assign({},f)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return hs=o()?Object.assign:function(l,d){for(var c,g=r(l),f,u=1;u<arguments.length;u++){c=Object(arguments[u]);for(var p in c)a.call(c,p)&&(g[p]=c[p]);if(t){f=t(c);for(var w=0;w<f.length;w++)s.call(c,f[w])&&(g[f[w]]=c[f[w]])}}return g},hs}var ys,Mr;function Xs(){if(Mr)return ys;Mr=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return ys=t,ys}var gs,Er;function Ro(){return Er||(Er=1,gs=Function.call.bind(Object.prototype.hasOwnProperty)),gs}var xs,Fr;function pc(){if(Fr)return xs;Fr=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var a=Xs(),s={},r=Ro();t=function(l){var d="Warning: "+l;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function o(l,d,c,g,f){if(process.env.NODE_ENV!=="production"){for(var u in l)if(r(l,u)){var p;try{if(typeof l[u]!="function"){var w=Error((g||"React class")+": "+c+" type `"+u+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof l[u]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw w.name="Invariant Violation",w}p=l[u](d,u,g,c,null,a)}catch(y){p=y}if(p&&!(p instanceof Error)&&t((g||"React class")+": type specification of "+c+" `"+u+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof p+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),p instanceof Error&&!(p.message in s)){s[p.message]=!0;var v=f?f():"";t("Failed "+c+" type: "+p.message+(v??""))}}}}return o.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(s={})},xs=o,xs}var bs,$r;function mc(){if($r)return bs;$r=1;var t=Do(),a=uc(),s=Xs(),r=Ro(),o=pc(),l=function(){};process.env.NODE_ENV!=="production"&&(l=function(c){var g="Warning: "+c;typeof console<"u"&&console.error(g);try{throw new Error(g)}catch{}});function d(){return null}return bs=function(c,g){var f=typeof Symbol=="function"&&Symbol.iterator,u="@@iterator";function p(P){var I=P&&(f&&P[f]||P[u]);if(typeof I=="function")return I}var w="<<anonymous>>",v={array:T("array"),bigint:T("bigint"),bool:T("boolean"),func:T("function"),number:T("number"),object:T("object"),string:T("string"),symbol:T("symbol"),any:D(),arrayOf:k,element:C(),elementType:j(),instanceOf:h,node:q(),objectOf:A,oneOf:S,oneOfType:R,shape:b,exact:O};function y(P,I){return P===I?P!==0||1/P===1/I:P!==P&&I!==I}function m(P,I){this.message=P,this.data=I&&typeof I=="object"?I:{},this.stack=""}m.prototype=Error.prototype;function x(P){if(process.env.NODE_ENV!=="production")var I={},B=0;function L(se,W,K,te,oe,pe,we){if(te=te||w,pe=pe||K,we!==s){if(g){var le=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw le.name="Invariant Violation",le}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var de=te+":"+K;!I[de]&&B<3&&(l("You are manually calling a React.PropTypes validation function for the `"+pe+"` prop on `"+te+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),I[de]=!0,B++)}}return W[K]==null?se?W[K]===null?new m("The "+oe+" `"+pe+"` is marked as required "+("in `"+te+"`, but its value is `null`.")):new m("The "+oe+" `"+pe+"` is marked as required in "+("`"+te+"`, but its value is `undefined`.")):null:P(W,K,te,oe,pe)}var H=L.bind(null,!1);return H.isRequired=L.bind(null,!0),H}function T(P){function I(B,L,H,se,W,K){var te=B[L],oe=F(te);if(oe!==P){var pe=N(te);return new m("Invalid "+se+" `"+W+"` of type "+("`"+pe+"` supplied to `"+H+"`, expected ")+("`"+P+"`."),{expectedType:P})}return null}return x(I)}function D(){return x(d)}function k(P){function I(B,L,H,se,W){if(typeof P!="function")return new m("Property `"+W+"` of component `"+H+"` has invalid PropType notation inside arrayOf.");var K=B[L];if(!Array.isArray(K)){var te=F(K);return new m("Invalid "+se+" `"+W+"` of type "+("`"+te+"` supplied to `"+H+"`, expected an array."))}for(var oe=0;oe<K.length;oe++){var pe=P(K,oe,H,se,W+"["+oe+"]",s);if(pe instanceof Error)return pe}return null}return x(I)}function C(){function P(I,B,L,H,se){var W=I[B];if(!c(W)){var K=F(W);return new m("Invalid "+H+" `"+se+"` of type "+("`"+K+"` supplied to `"+L+"`, expected a single ReactElement."))}return null}return x(P)}function j(){function P(I,B,L,H,se){var W=I[B];if(!t.isValidElementType(W)){var K=F(W);return new m("Invalid "+H+" `"+se+"` of type "+("`"+K+"` supplied to `"+L+"`, expected a single ReactElement type."))}return null}return x(P)}function h(P){function I(B,L,H,se,W){if(!(B[L]instanceof P)){var K=P.name||w,te=z(B[L]);return new m("Invalid "+se+" `"+W+"` of type "+("`"+te+"` supplied to `"+H+"`, expected ")+("instance of `"+K+"`."))}return null}return x(I)}function S(P){if(!Array.isArray(P))return process.env.NODE_ENV!=="production"&&(arguments.length>1?l("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):l("Invalid argument supplied to oneOf, expected an array.")),d;function I(B,L,H,se,W){for(var K=B[L],te=0;te<P.length;te++)if(y(K,P[te]))return null;var oe=JSON.stringify(P,function(we,le){var de=N(le);return de==="symbol"?String(le):le});return new m("Invalid "+se+" `"+W+"` of value `"+String(K)+"` "+("supplied to `"+H+"`, expected one of "+oe+"."))}return x(I)}function A(P){function I(B,L,H,se,W){if(typeof P!="function")return new m("Property `"+W+"` of component `"+H+"` has invalid PropType notation inside objectOf.");var K=B[L],te=F(K);if(te!=="object")return new m("Invalid "+se+" `"+W+"` of type "+("`"+te+"` supplied to `"+H+"`, expected an object."));for(var oe in K)if(r(K,oe)){var pe=P(K,oe,H,se,W+"."+oe,s);if(pe instanceof Error)return pe}return null}return x(I)}function R(P){if(!Array.isArray(P))return process.env.NODE_ENV!=="production"&&l("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var I=0;I<P.length;I++){var B=P[I];if(typeof B!="function")return l("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+V(B)+" at index "+I+"."),d}function L(H,se,W,K,te){for(var oe=[],pe=0;pe<P.length;pe++){var we=P[pe],le=we(H,se,W,K,te,s);if(le==null)return null;le.data&&r(le.data,"expectedType")&&oe.push(le.data.expectedType)}var de=oe.length>0?", expected one of type ["+oe.join(", ")+"]":"";return new m("Invalid "+K+" `"+te+"` supplied to "+("`"+W+"`"+de+"."))}return x(L)}function q(){function P(I,B,L,H,se){return M(I[B])?null:new m("Invalid "+H+" `"+se+"` supplied to "+("`"+L+"`, expected a ReactNode."))}return x(P)}function U(P,I,B,L,H){return new m((P||"React class")+": "+I+" type `"+B+"."+L+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+H+"`.")}function b(P){function I(B,L,H,se,W){var K=B[L],te=F(K);if(te!=="object")return new m("Invalid "+se+" `"+W+"` of type `"+te+"` "+("supplied to `"+H+"`, expected `object`."));for(var oe in P){var pe=P[oe];if(typeof pe!="function")return U(H,se,W,oe,N(pe));var we=pe(K,oe,H,se,W+"."+oe,s);if(we)return we}return null}return x(I)}function O(P){function I(B,L,H,se,W){var K=B[L],te=F(K);if(te!=="object")return new m("Invalid "+se+" `"+W+"` of type `"+te+"` "+("supplied to `"+H+"`, expected `object`."));var oe=a({},B[L],P);for(var pe in oe){var we=P[pe];if(r(P,pe)&&typeof we!="function")return U(H,se,W,pe,N(we));if(!we)return new m("Invalid "+se+" `"+W+"` key `"+pe+"` supplied to `"+H+"`.\nBad object: "+JSON.stringify(B[L],null," ")+`
|
|
10
|
-
Valid keys: `+JSON.stringify(Object.keys(P),null," "));var le=we(K,pe,H,se,W+"."+pe,s);if(le)return le}return null}return x(I)}function M(P){switch(typeof P){case"number":case"string":case"undefined":return!0;case"boolean":return!P;case"object":if(Array.isArray(P))return P.every(M);if(P===null||c(P))return!0;var I=p(P);if(I){var B=I.call(P),L;if(I!==P.entries){for(;!(L=B.next()).done;)if(!M(L.value))return!1}else for(;!(L=B.next()).done;){var H=L.value;if(H&&!M(H[1]))return!1}}else return!1;return!0;default:return!1}}function $(P,I){return P==="symbol"?!0:I?I["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&I instanceof Symbol:!1}function F(P){var I=typeof P;return Array.isArray(P)?"array":P instanceof RegExp?"object":$(I,P)?"symbol":I}function N(P){if(typeof P>"u"||P===null)return""+P;var I=F(P);if(I==="object"){if(P instanceof Date)return"date";if(P instanceof RegExp)return"regexp"}return I}function V(P){var I=N(P);switch(I){case"array":case"object":return"an "+I;case"boolean":case"date":case"regexp":return"a "+I;default:return I}}function z(P){return!P.constructor||!P.constructor.name?w:P.constructor.name}return v.checkPropTypes=o,v.resetWarningCache=o.resetWarningCache,v.PropTypes=v,v},bs}var js,Ur;function fc(){if(Ur)return js;Ur=1;var t=Xs();function a(){}function s(){}return s.resetWarningCache=a,js=function(){function r(d,c,g,f,u,p){if(p!==t){var w=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw w.name="Invariant Violation",w}}r.isRequired=r;function o(){return r}var l={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:o,element:r,elementType:r,instanceOf:o,node:r,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:s,resetWarningCache:a};return l.PropTypes=l,l},js}var Nr;function Io(){if(Nr)return un.exports;if(Nr=1,process.env.NODE_ENV!=="production"){var t=Do(),a=!0;un.exports=mc()(t.isElement,a)}else un.exports=fc()();return un.exports}var Br;function hc(){if(Br)return Xe;Br=1;var t=Xe&&Xe.__extends||(function(){var v=function(y,m){return v=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,T){x.__proto__=T}||function(x,T){for(var D in T)Object.prototype.hasOwnProperty.call(T,D)&&(x[D]=T[D])},v(y,m)};return function(y,m){if(typeof m!="function"&&m!==null)throw new TypeError("Class extends value "+String(m)+" is not a constructor or null");v(y,m);function x(){this.constructor=y}y.prototype=m===null?Object.create(m):(x.prototype=m.prototype,new x)}})(),a=Xe&&Xe.__assign||function(){return a=Object.assign||function(v){for(var y,m=1,x=arguments.length;m<x;m++){y=arguments[m];for(var T in y)Object.prototype.hasOwnProperty.call(y,T)&&(v[T]=y[T])}return v},a.apply(this,arguments)},s=Xe&&Xe.__createBinding||(Object.create?(function(v,y,m,x){x===void 0&&(x=m);var T=Object.getOwnPropertyDescriptor(y,m);(!T||("get"in T?!y.__esModule:T.writable||T.configurable))&&(T={enumerable:!0,get:function(){return y[m]}}),Object.defineProperty(v,x,T)}):(function(v,y,m,x){x===void 0&&(x=m),v[x]=y[m]})),r=Xe&&Xe.__setModuleDefault||(Object.create?(function(v,y){Object.defineProperty(v,"default",{enumerable:!0,value:y})}):function(v,y){v.default=y}),o=Xe&&Xe.__importStar||function(v){if(v&&v.__esModule)return v;var y={};if(v!=null)for(var m in v)m!=="default"&&Object.prototype.hasOwnProperty.call(v,m)&&s(y,v,m);return r(y,v),y},l=Xe&&Xe.__rest||function(v,y){var m={};for(var x in v)Object.prototype.hasOwnProperty.call(v,x)&&y.indexOf(x)<0&&(m[x]=v[x]);if(v!=null&&typeof Object.getOwnPropertySymbols=="function")for(var T=0,x=Object.getOwnPropertySymbols(v);T<x.length;T++)y.indexOf(x[T])<0&&Object.prototype.propertyIsEnumerable.call(v,x[T])&&(m[x[T]]=v[x[T]]);return m},d=Xe&&Xe.__importDefault||function(v){return v&&v.__esModule?v:{default:v}};Object.defineProperty(Xe,"__esModule",{value:!0});var c=o(i),g=d(lc()),f=o(Io());function u(v){return v&&v.replace(/ |\u202F|\u00A0/g," ").replace(/<br \/>/g,"<br>")}function p(v){var y=document.createTextNode("");v.appendChild(y);var m=document.activeElement===v;if(y!==null&&y.nodeValue!==null&&m){var x=window.getSelection();if(x!==null){var T=document.createRange();T.setStart(y,y.nodeValue.length),T.collapse(!0),x.removeAllRanges(),x.addRange(T)}v instanceof HTMLElement&&v.focus()}}var w=(function(v){t(y,v);function y(){var m=v!==null&&v.apply(this,arguments)||this;return m.lastHtml=m.props.html,m.el=typeof m.props.innerRef=="function"?{current:null}:c.createRef(),m.getEl=function(){return(m.props.innerRef&&typeof m.props.innerRef!="function"?m.props.innerRef:m.el).current},m.emitChange=function(x){var T=m.getEl();if(T){var D=T.innerHTML;if(m.props.onChange&&D!==m.lastHtml){var k=Object.assign({},x,{target:{value:D}});m.props.onChange(k)}m.lastHtml=D}},m}return y.prototype.render=function(){var m=this,x=this.props,T=x.tagName,D=x.html,k=x.innerRef,C=l(x,["tagName","html","innerRef"]);return c.createElement(T||"div",a(a({},C),{ref:typeof k=="function"?function(j){k(j),m.el.current=j}:k||this.el,onInput:this.emitChange,onBlur:this.props.onBlur||this.emitChange,onKeyUp:this.props.onKeyUp||this.emitChange,onKeyDown:this.props.onKeyDown||this.emitChange,contentEditable:!this.props.disabled,dangerouslySetInnerHTML:{__html:D}}),this.props.children)},y.prototype.shouldComponentUpdate=function(m){var x=this.props,T=this.getEl();return!T||u(m.html)!==u(T.innerHTML)?!0:x.disabled!==m.disabled||x.tagName!==m.tagName||x.className!==m.className||x.innerRef!==m.innerRef||x.placeholder!==m.placeholder||!(0,g.default)(x.style,m.style)},y.prototype.componentDidUpdate=function(){var m=this.getEl();m&&(this.props.html!==m.innerHTML&&(m.innerHTML=this.props.html),this.lastHtml=this.props.html,p(m))},y.propTypes={html:f.string.isRequired,onChange:f.func,disabled:f.bool,tagName:f.string,className:f.string,style:f.object,innerRef:f.oneOfType([f.object,f.func])},y})(c.Component);return Xe.default=w,Xe}var yc=hc();const ko=To(yc),gc={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},xc={width:"100%",minHeight:40,padding:"8px 0",fontSize:"14px",color:"#222",background:"transparent",border:0,borderTop:0,borderLeft:0,borderRight:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",outline:"none",transition:"border-color 0.2s ease"},Y=i.forwardRef(({style:t,onFocus:a,onBlur:s,...r},o)=>{const[l,d]=i.useState(!1);return e.jsxs("div",{className:"",style:{width:"100%"},children:[r.label&&e.jsx("label",{className:"labelfont",style:gc,children:r.label}),e.jsx("input",{placeholder:r.placeholder||r.label,...r,ref:o,onFocus:c=>{d(!0),a?.(c)},onBlur:c=>{d(!1),s?.(c)},style:{...xc,borderBottom:`1px solid ${l?"#222":"#d9d9d9"}`,...t||{}}})]})}),Lr=[{value:"01",label:"January"},{value:"02",label:"February"},{value:"03",label:"March"},{value:"04",label:"April"},{value:"05",label:"May"},{value:"06",label:"June"},{value:"07",label:"July"},{value:"08",label:"August"},{value:"09",label:"September"},{value:"10",label:"October"},{value:"11",label:"November"},{value:"12",label:"December"}];function Zs(t){const a=ae().year(),s=[];for(let r=a;r>=a-t;r--)s.push({label:String(r),value:r});return s}function Ze(t){switch(t){case"late":return e.jsx("span",{className:"label label-late",children:"L"});case"present":return e.jsx("span",{className:"label label-success",children:"P"});case"absent":return e.jsx("span",{className:"label label-danger",children:"A"});case"P":return e.jsx("span",{className:"monthlyLabel label-success",children:"P"});case"A":return e.jsx("span",{className:"monthlyLabel label-danger",children:"A"});case"L":return e.jsx("span",{className:"monthlyLabel label-late",children:"L"});case"W":return e.jsx("span",{className:"monthlyLabel sunday",children:"W"});case"H":return e.jsx("span",{className:"monthlyLabel holiday",children:"H"});default:return e.jsx("span",{className:"label",children:t})}}function er(t){const a=ae().year(),s=ae().month();return t<a?Lr:Lr.slice(0,s+1)}function qr(t,a){switch(t){case"sunday":return e.jsx("span",{className:"monthlyLabel sunday",children:a});case"holiday":return e.jsx("span",{className:"monthlyLabel holiday",children:a});default:return e.jsx("span",{className:"monthlyLabel",children:a})}}function bc(){return[{label:"One Time (During Admission)",value:"one_time"},{label:"One Time",value:"one_time_without_admission"},{label:"Monthly",value:"monthly"},{label:"Quarterly",value:"quarterly"},{label:"Half Yearly",value:"half_yearly"},{label:"Yearly",value:"yearly"}]}const Po=t=>{switch(t){case"paid":return e.jsx("div",{style:{background:"#3cb371",color:"white",textAlign:"center"},children:"PAID"});case"due":return e.jsx("div",{style:{background:"red",color:"white",textAlign:"center"},children:"DUE"});case"partially_paid":return e.jsx("div",{style:{background:"#ff8d00",color:"white",textAlign:"center"},children:"Partially Paid"});case"Present":return e.jsx(n.Tag,{color:"success",children:"Present"});case"Absent":return e.jsx(n.Tag,{color:"error",children:"Absent"});case"NO Attendance":return e.jsx(n.Tag,{color:"error",children:"No Attendance"});case"one_time":return"ONETIME";case"monthly":return"MONTHLY";case"half_yearly":return"HALF YEARLY";case"quarterly":return"QUARTERLY";default:return""}},Tt=t=>{const a=JSON.parse(localStorage.getItem("genrall_settings"));return console.log("amount______",t),e.jsxs(e.Fragment,{children:[a?.currency_icon," ",Number(t||0).toLocaleString("en-IN")]})};var _a={},Ca={},mt={},Aa={},ta={},zr;function jc(){if(zr)return ta;zr=1;var t=ta&&ta.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(ta,"__esModule",{value:!0});const a=t(i),s=il,r=["string","number","boolean"];function o({header:l,body:d}){const c=a.default.createElement("tr",null,l.map(f=>a.default.createElement("th",{key:f},f))),g=d.map((f,u)=>Array.isArray(f)?a.default.createElement("tr",{key:u},f.map((p,w)=>a.default.createElement("th",{key:w}," ",p," "))):f!==null&&typeof f=="object"?a.default.createElement("tr",{key:u},Object.entries(f).map(([p,w],v)=>typeof w=="object"?(console.error(`typeof ${p} is incorrect, only accept ${r.join(", ")} `),a.default.createElement("th",{key:v})):a.default.createElement("th",{key:v},a.default.createElement(a.default.Fragment,null,w)))):(console.error(`
|
|
8
|
+
`,d+1),g=c===-1?"":l.slice(c+1);String(i.stack).endsWith(g)||(i.stack+=`
|
|
9
|
+
`+l)}}catch{}}throw i}}_request(a,s){typeof a=="string"?(s=s||{},s.url=a):s=a||{},s=Qt(this.defaults,s);const{transitional:i,paramsSerializer:o,headers:l}=s;i!==void 0&&On.assertOptions(i,{silentJSONParsing:jt.transitional(jt.boolean),forcedJSONParsing:jt.transitional(jt.boolean),clarifyTimeoutError:jt.transitional(jt.boolean),legacyInterceptorReqResOrdering:jt.transitional(jt.boolean)},!1),o!=null&&(Z.isFunction(o)?s.paramsSerializer={serialize:o}:On.assertOptions(o,{encode:jt.function,serialize:jt.function},!0)),s.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?s.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:s.allowAbsoluteUrls=!0),On.assertOptions(s,{baseUrl:jt.spelling("baseURL"),withXsrfToken:jt.spelling("withXSRFToken")},!0),s.method=(s.method||this.defaults.method||"get").toLowerCase();let d=l&&Z.merge(l.common,l[s.method]);l&&Z.forEach(["delete","get","head","post","put","patch","common"],b=>{delete l[b]}),s.headers=pt.concat(d,l);const c=[];let g=!0;this.interceptors.request.forEach(function(m){if(typeof m.runWhen=="function"&&m.runWhen(s)===!1)return;g=g&&m.synchronous;const j=s.transitional||Qs;j&&j.legacyInterceptorReqResOrdering?c.unshift(m.fulfilled,m.rejected):c.push(m.fulfilled,m.rejected)});const h=[];this.interceptors.response.forEach(function(m){h.push(m.fulfilled,m.rejected)});let u,p=0,A;if(!g){const b=[kr.bind(this),void 0];for(b.unshift(...c),b.push(...h),A=b.length,u=Promise.resolve(s);p<A;)u=u.then(b[p++],b[p++]);return u}A=c.length;let w=s;for(;p<A;){const b=c[p++],m=c[p++];try{w=b(w)}catch(j){m.call(this,j);break}}try{u=kr.call(this,w)}catch(b){return Promise.reject(b)}for(p=0,A=h.length;p<A;)u=u.then(h[p++],h[p++]);return u}getUri(a){a=Qt(this.defaults,a);const s=Io(a.baseURL,a.url,a.allowAbsoluteUrls);return Ao(s,a.params,a.paramsSerializer)}};Z.forEach(["delete","get","head","options"],function(a){Kt.prototype[a]=function(s,i){return this.request(Qt(i||{},{method:a,url:s,data:(i||{}).data}))}});Z.forEach(["post","put","patch"],function(a){function s(i){return function(l,d,c){return this.request(Qt(c||{},{method:a,headers:i?{"Content-Type":"multipart/form-data"}:{},url:l,data:d}))}}Kt.prototype[a]=s(),Kt.prototype[a+"Form"]=s(!0)});let nc=class Eo{constructor(a){if(typeof a!="function")throw new TypeError("executor must be a function.");let s;this.promise=new Promise(function(l){s=l});const i=this;this.promise.then(o=>{if(!i._listeners)return;let l=i._listeners.length;for(;l-- >0;)i._listeners[l](o);i._listeners=null}),this.promise.then=o=>{let l;const d=new Promise(c=>{i.subscribe(c),l=c}).then(o);return d.cancel=function(){i.unsubscribe(l)},d},a(function(l,d,c){i.reason||(i.reason=new Ja(l,d,c),s(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(a){if(this.reason){a(this.reason);return}this._listeners?this._listeners.push(a):this._listeners=[a]}unsubscribe(a){if(!this._listeners)return;const s=this._listeners.indexOf(a);s!==-1&&this._listeners.splice(s,1)}toAbortSignal(){const a=new AbortController,s=i=>{a.abort(i)};return this.subscribe(s),a.signal.unsubscribe=()=>this.unsubscribe(s),a.signal}static source(){let a;return{token:new Eo(function(o){a=o}),cancel:a}}};function sc(t){return function(s){return t.apply(null,s)}}function rc(t){return Z.isObject(t)&&t.isAxiosError===!0}const Ws={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Ws).forEach(([t,a])=>{Ws[a]=t});function Fo(t){const a=new Kt(t),s=fo(Kt.prototype.request,a);return Z.extend(s,Kt.prototype,a,{allOwnKeys:!0}),Z.extend(s,a,null,{allOwnKeys:!0}),s.create=function(o){return Fo(Qt(t,o))},s}const We=Fo(Ga);We.Axios=Kt;We.CanceledError=Ja;We.CancelToken=nc;We.isCancel=To;We.VERSION=Mo;We.toFormData=es;We.AxiosError=Ae;We.Cancel=We.CanceledError;We.all=function(a){return Promise.all(a)};We.spread=sc;We.isAxiosError=rc;We.mergeConfig=Qt;We.AxiosHeaders=pt;We.formToJSON=t=>Do(Z.isHTMLForm(t)?new FormData(t):t);We.getAdapter=Oo.getAdapter;We.HttpStatusCode=Ws;We.default=We;const{Axios:zx,AxiosError:Yx,CanceledError:Vx,isCancel:Wx,CancelToken:Hx,VERSION:Kx,all:Gx,Cancel:Jx,isAxiosError:Qx,spread:Xx,toFormData:Zx,AxiosHeaders:eb,HttpStatusCode:tb,formToJSON:ab,getAdapter:nb,mergeConfig:sb}=We,ic=()=>new Promise(t=>setTimeout(()=>t(),800));let Hs=null;const oc=t=>{Hs=t,rt.defaults.baseURL=er()},er=()=>Hs||"https://npmapi.ubkerp.com/",rt=We.create({baseURL:er()}),He=()=>er(),Ee=async(t,a,s)=>{const i=await rt.post(t,a,{headers:{Authorization:s}});if(console.log("ddddfdfdfd",i.data?.Status),i.data?.Status=="Success")return i?.data?.data||i?.data;throw new Error(i.data?.msg)},lc=async(t,a,s)=>{const i=a instanceof FormData;return(await rt.post(t,a,{headers:{Authorization:s,...i?{"Content-type":"multipart/form-data"}:{}}})).data},K=async(t,a)=>{try{let i=t;if(!t.includes("session_id")){const l=t.includes("?")?"&":"?";i=`${t}${l}session_id=1`}return(await rt.get(i,{headers:{Authorization:a}})).data}catch(s){throw s.response?.status===401&&console.error("401 Unauthorized"),s}},dc=async(t,a)=>{const s=await rt.post(t,"",{headers:{Authorization:a}});if(s.data?.Status=="Success")return s?.data?.data||s?.data;throw new Error(s.data?.msg)},as=async(t,a,s)=>{try{const i=await rt.post(t,a,{headers:{Authorization:s,"Content-Type":"application/json"}});return i.data?.Status==="Success"?i.data:(v.error(i.data?.msg||"Unable to issue library book",{duration:2e3}),!1)}catch(i){throw v.error(i.response?.data?.msg||i.response?.data?.message||"Request failed",{duration:2e3}),i}},za=async(t,a,s)=>{const i=a?.arg;return(await rt.post(t,i,{headers:{Authorization:s}}))?.data},Gt=async(t,a,s)=>{const i=a?.arg,o=t.includes("?")?"&":"?";return(await rt.get(t+o,{params:i,headers:{Authorization:s}}))?.data},cc="api/branchapi/GeneralSettings/getsetting_allowances_dedectionBranch",tr=async(t,a,s)=>{const i=a?.arg,o=t.includes("?")?"&":"?",l=await rt.get(t+o,{params:i,headers:{Authorization:s}});if(console.log("ddddfdfdfd",l.data?.Status),l.data?.Status=="Success")return l?.data?.data||l?.data;throw new Error(l.data?.msg)},Be=async(t,a,s)=>(await ic(),(await rt.post(t,a,{headers:{Authorization:s}}))?.data),Qa=async(t,a,s)=>(await rt.post(t,a,{headers:{Authorization:s}})).data,qe=async(t,a,s)=>(await rt.delete(`${t}/${a}`,{headers:{Authorization:s}})).data,uc="api/report/LibraryRenewalReport/renewalHistory",pc="api/report/LibraryRenewalReport/renewalFineReport",mc="api/report/LibraryRenewalReport/currentlyRenewedBooks",hc="api/report/LibraryRenewalReport/upcomingRenewalDue",fc="api/report/LibraryRenewalReport/overdueRenewalReport",yc="api/report/LibraryRenewalReport/renewalLimitReport",gc="api/report/LibraryRenewalReport/renewalStatusReport",xc="api/report/LibraryRenewalReport/studentWiseReport",bc="api/report/LibraryRenewalReport/bookWiseReport",jc="api/report/LibraryRenewalReport/classWiseReport",Sc="api/report/LibraryRenewalReport/staffWiseReport",wc="api/report/LibraryRenewalReport/renewalStatisticsByDate",vc="/sample_templates/route_upload.xlsx",Xa="api/branchapi/academy/classdropdownlist",Za="api/branchapi/academy/sectionoftheClass",_c="/sample_templates/student_transport_upload.xlsx",Cc="api/branchapi/income/incomeTableList",Ac="api/branchapi/income/addincome",Dc="api/branchapi/income/editincome",Tc="api/branchapi/income/deleteincome",Uo="api/branchapi/income/incomeheadDropdown",Rc="api/branchapi/income/incomeheadTableList",Ic="api/branchapi/income/addincomehead",kc="api/branchapi/income/editincomehead",Pc="api/branchapi/income/deleteincomehead",Oc="api/branchapi/income/incomeShowdata",Mc="api/branchapi/income/incomeheadShowdata",Ec="api/branchapi/income/searchincomebydates",Fc="api/branchapi/expense/expenseTableList",Uc="api/branchapi/expense/addexpense",$c="api/branchapi/expense/editexpense",Nc="api/branchapi/expense/deleteExpense",$o="api/branchapi/expense/expenseheadDropdown",Lc="api/branchapi/expense/expenseheadTableList",Bc="api/branchapi/expense/addexpensehead",qc="api/branchapi/expense/editexpensehead",zc="api/branchapi/expense/deleteexpensehead",Yc="api/branchapi/expense/expenseShowdata",Vc="api/branchapi/expense/expenseheadShowdata",Wc="api/branchapi/expense/searchexpensebydates",No="api/accounts/vendor/vendorlist",Hc="api/student/studentDetails/studentLoginCredentialList",Lo="/branchapi/student/studentlist",Bo="api/branchapi/student/studentsearchbyKeywords",qo="api/branchapi/student/studentsearchbyClassSection",Kc="/branchapi/student/addStudentMedicineDetails",Gc="/branchapi/student/StudentMedicineDetails",zo="/branchapi/academy/getstudentClasssubjectByStudentId",Jc="/branchapi/academy/removeAssignStudentSubject",Ks="/branchapi/feesCollection/extraCurricularActivitiesFess",Qc="/branchapi/academy/unAssigneStudentSubject",Xc="/branchapi/student/uploadstudentbyCSV",Zc="api/branchapi/academy/categorytableList",eu="api/branchapi/transport/downloadBulkTemplate",tu="api/branchapi/transport/validateBulkUpload",au="api/branchapi/transport/confirmBulkImport",nu="api/branchapi/transport/downloadBulkErrorReport",su=async({class_id:t,section_id:a}={},s)=>{const i=new URLSearchParams;t&&i.append("class_id",t),a&&i.append("section_id",a);const o=`${eu}${i.toString()?`?${i.toString()}`:""}`;return(await rt.get(o,{headers:{Authorization:s},responseType:"blob"})).data},ru=async(t,a)=>{const s=new FormData;return s.append("file",t),(await rt.post(tu,s,{headers:{Authorization:a,"Content-Type":"multipart/form-data"}})).data},iu=async(t,a,s="skip")=>(await rt.post(au,{rows:t,duplicate_action:s},{headers:{Authorization:a,"Content-Type":"application/json"}})).data,ou=async(t,a)=>(await rt.post(nu,{rows:t},{headers:{Authorization:a,"Content-Type":"application/json"},responseType:"blob"})).data,lu=({token:t,menu:a})=>{const{isLoading:s,data:i}=W(t?["api/sdk/Menus",t]:null,([l,d])=>dc(l,d)),o=i?.find(l=>l.path===a)?.sub_menu??[];return console.log("menuData",i),e.jsx(n.Row,{gutter:[16,16],children:o?.map((l,d)=>l.dashboard_show==="YES"?e.jsx(n.Col,{xs:24,md:8,lg:8,children:e.jsx(C,{children:e.jsx(ho,{icon:`${He()}icons/frontoffice/${l.icons}`,title:l.submenu_name,path:l.menu_key})})},`${d}office001`):null)})};function Yo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ze={},gs,Or;function du(){return Or||(Or=1,gs=function t(a,s){if(a===s)return!0;if(a&&s&&typeof a=="object"&&typeof s=="object"){if(a.constructor!==s.constructor)return!1;var i,o,l;if(Array.isArray(a)){if(i=a.length,i!=s.length)return!1;for(o=i;o--!==0;)if(!t(a[o],s[o]))return!1;return!0}if(a.constructor===RegExp)return a.source===s.source&&a.flags===s.flags;if(a.valueOf!==Object.prototype.valueOf)return a.valueOf()===s.valueOf();if(a.toString!==Object.prototype.toString)return a.toString()===s.toString();if(l=Object.keys(a),i=l.length,i!==Object.keys(s).length)return!1;for(o=i;o--!==0;)if(!Object.prototype.hasOwnProperty.call(s,l[o]))return!1;for(o=i;o--!==0;){var d=l[o];if(!t(a[d],s[d]))return!1}return!0}return a!==a&&s!==s}),gs}var mn={exports:{}},hn={exports:{}},Pe={};var Mr;function cu(){if(Mr)return Pe;Mr=1;var t=typeof Symbol=="function"&&Symbol.for,a=t?Symbol.for("react.element"):60103,s=t?Symbol.for("react.portal"):60106,i=t?Symbol.for("react.fragment"):60107,o=t?Symbol.for("react.strict_mode"):60108,l=t?Symbol.for("react.profiler"):60114,d=t?Symbol.for("react.provider"):60109,c=t?Symbol.for("react.context"):60110,g=t?Symbol.for("react.async_mode"):60111,h=t?Symbol.for("react.concurrent_mode"):60111,u=t?Symbol.for("react.forward_ref"):60112,p=t?Symbol.for("react.suspense"):60113,A=t?Symbol.for("react.suspense_list"):60120,w=t?Symbol.for("react.memo"):60115,b=t?Symbol.for("react.lazy"):60116,m=t?Symbol.for("react.block"):60121,j=t?Symbol.for("react.fundamental"):60117,D=t?Symbol.for("react.responder"):60118,R=t?Symbol.for("react.scope"):60119;function k(x){if(typeof x=="object"&&x!==null){var f=x.$$typeof;switch(f){case a:switch(x=x.type,x){case g:case h:case i:case l:case o:case p:return x;default:switch(x=x&&x.$$typeof,x){case c:case u:case b:case w:case d:return x;default:return f}}case s:return f}}}function S(x){return k(x)===h}return Pe.AsyncMode=g,Pe.ConcurrentMode=h,Pe.ContextConsumer=c,Pe.ContextProvider=d,Pe.Element=a,Pe.ForwardRef=u,Pe.Fragment=i,Pe.Lazy=b,Pe.Memo=w,Pe.Portal=s,Pe.Profiler=l,Pe.StrictMode=o,Pe.Suspense=p,Pe.isAsyncMode=function(x){return S(x)||k(x)===g},Pe.isConcurrentMode=S,Pe.isContextConsumer=function(x){return k(x)===c},Pe.isContextProvider=function(x){return k(x)===d},Pe.isElement=function(x){return typeof x=="object"&&x!==null&&x.$$typeof===a},Pe.isForwardRef=function(x){return k(x)===u},Pe.isFragment=function(x){return k(x)===i},Pe.isLazy=function(x){return k(x)===b},Pe.isMemo=function(x){return k(x)===w},Pe.isPortal=function(x){return k(x)===s},Pe.isProfiler=function(x){return k(x)===l},Pe.isStrictMode=function(x){return k(x)===o},Pe.isSuspense=function(x){return k(x)===p},Pe.isValidElementType=function(x){return typeof x=="string"||typeof x=="function"||x===i||x===h||x===l||x===o||x===p||x===A||typeof x=="object"&&x!==null&&(x.$$typeof===b||x.$$typeof===w||x.$$typeof===d||x.$$typeof===c||x.$$typeof===u||x.$$typeof===j||x.$$typeof===D||x.$$typeof===R||x.$$typeof===m)},Pe.typeOf=k,Pe}var Oe={};var Er;function uu(){return Er||(Er=1,process.env.NODE_ENV!=="production"&&(function(){var t=typeof Symbol=="function"&&Symbol.for,a=t?Symbol.for("react.element"):60103,s=t?Symbol.for("react.portal"):60106,i=t?Symbol.for("react.fragment"):60107,o=t?Symbol.for("react.strict_mode"):60108,l=t?Symbol.for("react.profiler"):60114,d=t?Symbol.for("react.provider"):60109,c=t?Symbol.for("react.context"):60110,g=t?Symbol.for("react.async_mode"):60111,h=t?Symbol.for("react.concurrent_mode"):60111,u=t?Symbol.for("react.forward_ref"):60112,p=t?Symbol.for("react.suspense"):60113,A=t?Symbol.for("react.suspense_list"):60120,w=t?Symbol.for("react.memo"):60115,b=t?Symbol.for("react.lazy"):60116,m=t?Symbol.for("react.block"):60121,j=t?Symbol.for("react.fundamental"):60117,D=t?Symbol.for("react.responder"):60118,R=t?Symbol.for("react.scope"):60119;function k(le){return typeof le=="string"||typeof le=="function"||le===i||le===h||le===l||le===o||le===p||le===A||typeof le=="object"&&le!==null&&(le.$$typeof===b||le.$$typeof===w||le.$$typeof===d||le.$$typeof===c||le.$$typeof===u||le.$$typeof===j||le.$$typeof===D||le.$$typeof===R||le.$$typeof===m)}function S(le){if(typeof le=="object"&&le!==null){var de=le.$$typeof;switch(de){case a:var X=le.type;switch(X){case g:case h:case i:case l:case o:case p:return X;default:var ce=X&&X.$$typeof;switch(ce){case c:case u:case b:case w:case d:return ce;default:return de}}case s:return de}}}var x=g,f=h,_=c,T=d,I=a,B=u,L=i,y=b,P=w,O=s,$=l,U=o,N=p,V=!1;function z(le){return V||(V=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),E(le)||S(le)===g}function E(le){return S(le)===h}function M(le){return S(le)===c}function F(le){return S(le)===d}function q(le){return typeof le=="object"&&le!==null&&le.$$typeof===a}function H(le){return S(le)===u}function re(le){return S(le)===i}function G(le){return S(le)===b}function J(le){return S(le)===w}function ae(le){return S(le)===s}function oe(le){return S(le)===l}function pe(le){return S(le)===o}function _e(le){return S(le)===p}Oe.AsyncMode=x,Oe.ConcurrentMode=f,Oe.ContextConsumer=_,Oe.ContextProvider=T,Oe.Element=I,Oe.ForwardRef=B,Oe.Fragment=L,Oe.Lazy=y,Oe.Memo=P,Oe.Portal=O,Oe.Profiler=$,Oe.StrictMode=U,Oe.Suspense=N,Oe.isAsyncMode=z,Oe.isConcurrentMode=E,Oe.isContextConsumer=M,Oe.isContextProvider=F,Oe.isElement=q,Oe.isForwardRef=H,Oe.isFragment=re,Oe.isLazy=G,Oe.isMemo=J,Oe.isPortal=ae,Oe.isProfiler=oe,Oe.isStrictMode=pe,Oe.isSuspense=_e,Oe.isValidElementType=k,Oe.typeOf=S})()),Oe}var Fr;function Vo(){return Fr||(Fr=1,process.env.NODE_ENV==="production"?hn.exports=cu():hn.exports=uu()),hn.exports}var xs,Ur;function pu(){if(Ur)return xs;Ur=1;var t=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;function i(l){if(l==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(l)}function o(){try{if(!Object.assign)return!1;var l=new String("abc");if(l[5]="de",Object.getOwnPropertyNames(l)[0]==="5")return!1;for(var d={},c=0;c<10;c++)d["_"+String.fromCharCode(c)]=c;var g=Object.getOwnPropertyNames(d).map(function(u){return d[u]});if(g.join("")!=="0123456789")return!1;var h={};return"abcdefghijklmnopqrst".split("").forEach(function(u){h[u]=u}),Object.keys(Object.assign({},h)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return xs=o()?Object.assign:function(l,d){for(var c,g=i(l),h,u=1;u<arguments.length;u++){c=Object(arguments[u]);for(var p in c)a.call(c,p)&&(g[p]=c[p]);if(t){h=t(c);for(var A=0;A<h.length;A++)s.call(c,h[A])&&(g[h[A]]=c[h[A]])}}return g},xs}var bs,$r;function ar(){if($r)return bs;$r=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return bs=t,bs}var js,Nr;function Wo(){return Nr||(Nr=1,js=Function.call.bind(Object.prototype.hasOwnProperty)),js}var Ss,Lr;function mu(){if(Lr)return Ss;Lr=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var a=ar(),s={},i=Wo();t=function(l){var d="Warning: "+l;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function o(l,d,c,g,h){if(process.env.NODE_ENV!=="production"){for(var u in l)if(i(l,u)){var p;try{if(typeof l[u]!="function"){var A=Error((g||"React class")+": "+c+" type `"+u+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof l[u]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw A.name="Invariant Violation",A}p=l[u](d,u,g,c,null,a)}catch(b){p=b}if(p&&!(p instanceof Error)&&t((g||"React class")+": type specification of "+c+" `"+u+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof p+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),p instanceof Error&&!(p.message in s)){s[p.message]=!0;var w=h?h():"";t("Failed "+c+" type: "+p.message+(w??""))}}}}return o.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(s={})},Ss=o,Ss}var ws,Br;function hu(){if(Br)return ws;Br=1;var t=Vo(),a=pu(),s=ar(),i=Wo(),o=mu(),l=function(){};process.env.NODE_ENV!=="production"&&(l=function(c){var g="Warning: "+c;typeof console<"u"&&console.error(g);try{throw new Error(g)}catch{}});function d(){return null}return ws=function(c,g){var h=typeof Symbol=="function"&&Symbol.iterator,u="@@iterator";function p(E){var M=E&&(h&&E[h]||E[u]);if(typeof M=="function")return M}var A="<<anonymous>>",w={array:D("array"),bigint:D("bigint"),bool:D("boolean"),func:D("function"),number:D("number"),object:D("object"),string:D("string"),symbol:D("symbol"),any:R(),arrayOf:k,element:S(),elementType:x(),instanceOf:f,node:B(),objectOf:T,oneOf:_,oneOfType:I,shape:y,exact:P};function b(E,M){return E===M?E!==0||1/E===1/M:E!==E&&M!==M}function m(E,M){this.message=E,this.data=M&&typeof M=="object"?M:{},this.stack=""}m.prototype=Error.prototype;function j(E){if(process.env.NODE_ENV!=="production")var M={},F=0;function q(re,G,J,ae,oe,pe,_e){if(ae=ae||A,pe=pe||J,_e!==s){if(g){var le=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw le.name="Invariant Violation",le}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var de=ae+":"+J;!M[de]&&F<3&&(l("You are manually calling a React.PropTypes validation function for the `"+pe+"` prop on `"+ae+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),M[de]=!0,F++)}}return G[J]==null?re?G[J]===null?new m("The "+oe+" `"+pe+"` is marked as required "+("in `"+ae+"`, but its value is `null`.")):new m("The "+oe+" `"+pe+"` is marked as required in "+("`"+ae+"`, but its value is `undefined`.")):null:E(G,J,ae,oe,pe)}var H=q.bind(null,!1);return H.isRequired=q.bind(null,!0),H}function D(E){function M(F,q,H,re,G,J){var ae=F[q],oe=U(ae);if(oe!==E){var pe=N(ae);return new m("Invalid "+re+" `"+G+"` of type "+("`"+pe+"` supplied to `"+H+"`, expected ")+("`"+E+"`."),{expectedType:E})}return null}return j(M)}function R(){return j(d)}function k(E){function M(F,q,H,re,G){if(typeof E!="function")return new m("Property `"+G+"` of component `"+H+"` has invalid PropType notation inside arrayOf.");var J=F[q];if(!Array.isArray(J)){var ae=U(J);return new m("Invalid "+re+" `"+G+"` of type "+("`"+ae+"` supplied to `"+H+"`, expected an array."))}for(var oe=0;oe<J.length;oe++){var pe=E(J,oe,H,re,G+"["+oe+"]",s);if(pe instanceof Error)return pe}return null}return j(M)}function S(){function E(M,F,q,H,re){var G=M[F];if(!c(G)){var J=U(G);return new m("Invalid "+H+" `"+re+"` of type "+("`"+J+"` supplied to `"+q+"`, expected a single ReactElement."))}return null}return j(E)}function x(){function E(M,F,q,H,re){var G=M[F];if(!t.isValidElementType(G)){var J=U(G);return new m("Invalid "+H+" `"+re+"` of type "+("`"+J+"` supplied to `"+q+"`, expected a single ReactElement type."))}return null}return j(E)}function f(E){function M(F,q,H,re,G){if(!(F[q]instanceof E)){var J=E.name||A,ae=z(F[q]);return new m("Invalid "+re+" `"+G+"` of type "+("`"+ae+"` supplied to `"+H+"`, expected ")+("instance of `"+J+"`."))}return null}return j(M)}function _(E){if(!Array.isArray(E))return process.env.NODE_ENV!=="production"&&(arguments.length>1?l("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):l("Invalid argument supplied to oneOf, expected an array.")),d;function M(F,q,H,re,G){for(var J=F[q],ae=0;ae<E.length;ae++)if(b(J,E[ae]))return null;var oe=JSON.stringify(E,function(_e,le){var de=N(le);return de==="symbol"?String(le):le});return new m("Invalid "+re+" `"+G+"` of value `"+String(J)+"` "+("supplied to `"+H+"`, expected one of "+oe+"."))}return j(M)}function T(E){function M(F,q,H,re,G){if(typeof E!="function")return new m("Property `"+G+"` of component `"+H+"` has invalid PropType notation inside objectOf.");var J=F[q],ae=U(J);if(ae!=="object")return new m("Invalid "+re+" `"+G+"` of type "+("`"+ae+"` supplied to `"+H+"`, expected an object."));for(var oe in J)if(i(J,oe)){var pe=E(J,oe,H,re,G+"."+oe,s);if(pe instanceof Error)return pe}return null}return j(M)}function I(E){if(!Array.isArray(E))return process.env.NODE_ENV!=="production"&&l("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var M=0;M<E.length;M++){var F=E[M];if(typeof F!="function")return l("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+V(F)+" at index "+M+"."),d}function q(H,re,G,J,ae){for(var oe=[],pe=0;pe<E.length;pe++){var _e=E[pe],le=_e(H,re,G,J,ae,s);if(le==null)return null;le.data&&i(le.data,"expectedType")&&oe.push(le.data.expectedType)}var de=oe.length>0?", expected one of type ["+oe.join(", ")+"]":"";return new m("Invalid "+J+" `"+ae+"` supplied to "+("`"+G+"`"+de+"."))}return j(q)}function B(){function E(M,F,q,H,re){return O(M[F])?null:new m("Invalid "+H+" `"+re+"` supplied to "+("`"+q+"`, expected a ReactNode."))}return j(E)}function L(E,M,F,q,H){return new m((E||"React class")+": "+M+" type `"+F+"."+q+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+H+"`.")}function y(E){function M(F,q,H,re,G){var J=F[q],ae=U(J);if(ae!=="object")return new m("Invalid "+re+" `"+G+"` of type `"+ae+"` "+("supplied to `"+H+"`, expected `object`."));for(var oe in E){var pe=E[oe];if(typeof pe!="function")return L(H,re,G,oe,N(pe));var _e=pe(J,oe,H,re,G+"."+oe,s);if(_e)return _e}return null}return j(M)}function P(E){function M(F,q,H,re,G){var J=F[q],ae=U(J);if(ae!=="object")return new m("Invalid "+re+" `"+G+"` of type `"+ae+"` "+("supplied to `"+H+"`, expected `object`."));var oe=a({},F[q],E);for(var pe in oe){var _e=E[pe];if(i(E,pe)&&typeof _e!="function")return L(H,re,G,pe,N(_e));if(!_e)return new m("Invalid "+re+" `"+G+"` key `"+pe+"` supplied to `"+H+"`.\nBad object: "+JSON.stringify(F[q],null," ")+`
|
|
10
|
+
Valid keys: `+JSON.stringify(Object.keys(E),null," "));var le=_e(J,pe,H,re,G+"."+pe,s);if(le)return le}return null}return j(M)}function O(E){switch(typeof E){case"number":case"string":case"undefined":return!0;case"boolean":return!E;case"object":if(Array.isArray(E))return E.every(O);if(E===null||c(E))return!0;var M=p(E);if(M){var F=M.call(E),q;if(M!==E.entries){for(;!(q=F.next()).done;)if(!O(q.value))return!1}else for(;!(q=F.next()).done;){var H=q.value;if(H&&!O(H[1]))return!1}}else return!1;return!0;default:return!1}}function $(E,M){return E==="symbol"?!0:M?M["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&M instanceof Symbol:!1}function U(E){var M=typeof E;return Array.isArray(E)?"array":E instanceof RegExp?"object":$(M,E)?"symbol":M}function N(E){if(typeof E>"u"||E===null)return""+E;var M=U(E);if(M==="object"){if(E instanceof Date)return"date";if(E instanceof RegExp)return"regexp"}return M}function V(E){var M=N(E);switch(M){case"array":case"object":return"an "+M;case"boolean":case"date":case"regexp":return"a "+M;default:return M}}function z(E){return!E.constructor||!E.constructor.name?A:E.constructor.name}return w.checkPropTypes=o,w.resetWarningCache=o.resetWarningCache,w.PropTypes=w,w},ws}var vs,qr;function fu(){if(qr)return vs;qr=1;var t=ar();function a(){}function s(){}return s.resetWarningCache=a,vs=function(){function i(d,c,g,h,u,p){if(p!==t){var A=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw A.name="Invariant Violation",A}}i.isRequired=i;function o(){return i}var l={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:o,element:i,elementType:i,instanceOf:o,node:i,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:s,resetWarningCache:a};return l.PropTypes=l,l},vs}var zr;function Ho(){if(zr)return mn.exports;if(zr=1,process.env.NODE_ENV!=="production"){var t=Vo(),a=!0;mn.exports=hu()(t.isElement,a)}else mn.exports=fu()();return mn.exports}var Yr;function yu(){if(Yr)return Ze;Yr=1;var t=Ze&&Ze.__extends||(function(){var w=function(b,m){return w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(j,D){j.__proto__=D}||function(j,D){for(var R in D)Object.prototype.hasOwnProperty.call(D,R)&&(j[R]=D[R])},w(b,m)};return function(b,m){if(typeof m!="function"&&m!==null)throw new TypeError("Class extends value "+String(m)+" is not a constructor or null");w(b,m);function j(){this.constructor=b}b.prototype=m===null?Object.create(m):(j.prototype=m.prototype,new j)}})(),a=Ze&&Ze.__assign||function(){return a=Object.assign||function(w){for(var b,m=1,j=arguments.length;m<j;m++){b=arguments[m];for(var D in b)Object.prototype.hasOwnProperty.call(b,D)&&(w[D]=b[D])}return w},a.apply(this,arguments)},s=Ze&&Ze.__createBinding||(Object.create?(function(w,b,m,j){j===void 0&&(j=m);var D=Object.getOwnPropertyDescriptor(b,m);(!D||("get"in D?!b.__esModule:D.writable||D.configurable))&&(D={enumerable:!0,get:function(){return b[m]}}),Object.defineProperty(w,j,D)}):(function(w,b,m,j){j===void 0&&(j=m),w[j]=b[m]})),i=Ze&&Ze.__setModuleDefault||(Object.create?(function(w,b){Object.defineProperty(w,"default",{enumerable:!0,value:b})}):function(w,b){w.default=b}),o=Ze&&Ze.__importStar||function(w){if(w&&w.__esModule)return w;var b={};if(w!=null)for(var m in w)m!=="default"&&Object.prototype.hasOwnProperty.call(w,m)&&s(b,w,m);return i(b,w),b},l=Ze&&Ze.__rest||function(w,b){var m={};for(var j in w)Object.prototype.hasOwnProperty.call(w,j)&&b.indexOf(j)<0&&(m[j]=w[j]);if(w!=null&&typeof Object.getOwnPropertySymbols=="function")for(var D=0,j=Object.getOwnPropertySymbols(w);D<j.length;D++)b.indexOf(j[D])<0&&Object.prototype.propertyIsEnumerable.call(w,j[D])&&(m[j[D]]=w[j[D]]);return m},d=Ze&&Ze.__importDefault||function(w){return w&&w.__esModule?w:{default:w}};Object.defineProperty(Ze,"__esModule",{value:!0});var c=o(r),g=d(du()),h=o(Ho());function u(w){return w&&w.replace(/ |\u202F|\u00A0/g," ").replace(/<br \/>/g,"<br>")}function p(w){var b=document.createTextNode("");w.appendChild(b);var m=document.activeElement===w;if(b!==null&&b.nodeValue!==null&&m){var j=window.getSelection();if(j!==null){var D=document.createRange();D.setStart(b,b.nodeValue.length),D.collapse(!0),j.removeAllRanges(),j.addRange(D)}w instanceof HTMLElement&&w.focus()}}var A=(function(w){t(b,w);function b(){var m=w!==null&&w.apply(this,arguments)||this;return m.lastHtml=m.props.html,m.el=typeof m.props.innerRef=="function"?{current:null}:c.createRef(),m.getEl=function(){return(m.props.innerRef&&typeof m.props.innerRef!="function"?m.props.innerRef:m.el).current},m.emitChange=function(j){var D=m.getEl();if(D){var R=D.innerHTML;if(m.props.onChange&&R!==m.lastHtml){var k=Object.assign({},j,{target:{value:R}});m.props.onChange(k)}m.lastHtml=R}},m}return b.prototype.render=function(){var m=this,j=this.props,D=j.tagName,R=j.html,k=j.innerRef,S=l(j,["tagName","html","innerRef"]);return c.createElement(D||"div",a(a({},S),{ref:typeof k=="function"?function(x){k(x),m.el.current=x}:k||this.el,onInput:this.emitChange,onBlur:this.props.onBlur||this.emitChange,onKeyUp:this.props.onKeyUp||this.emitChange,onKeyDown:this.props.onKeyDown||this.emitChange,contentEditable:!this.props.disabled,dangerouslySetInnerHTML:{__html:R}}),this.props.children)},b.prototype.shouldComponentUpdate=function(m){var j=this.props,D=this.getEl();return!D||u(m.html)!==u(D.innerHTML)?!0:j.disabled!==m.disabled||j.tagName!==m.tagName||j.className!==m.className||j.innerRef!==m.innerRef||j.placeholder!==m.placeholder||!(0,g.default)(j.style,m.style)},b.prototype.componentDidUpdate=function(){var m=this.getEl();m&&(this.props.html!==m.innerHTML&&(m.innerHTML=this.props.html),this.lastHtml=this.props.html,p(m))},b.propTypes={html:h.string.isRequired,onChange:h.func,disabled:h.bool,tagName:h.string,className:h.string,style:h.object,innerRef:h.oneOfType([h.object,h.func])},b})(c.Component);return Ze.default=A,Ze}var gu=yu();const Ko=Yo(gu),xu={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},bu={width:"100%",minHeight:40,padding:"8px 0",fontSize:"14px",color:"#222",background:"transparent",border:0,borderTop:0,borderLeft:0,borderRight:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",outline:"none",transition:"border-color 0.2s ease"},Y=r.forwardRef(({style:t,onFocus:a,onBlur:s,...i},o)=>{const[l,d]=r.useState(!1);return e.jsxs("div",{className:"",style:{width:"100%"},children:[i.label&&e.jsx("label",{className:"labelfont",style:xu,children:i.label}),e.jsx("input",{placeholder:i.placeholder||i.label,...i,ref:o,onFocus:c=>{d(!0),a?.(c)},onBlur:c=>{d(!1),s?.(c)},style:{...bu,borderBottom:`1px solid ${l?"#222":"#d9d9d9"}`,...t||{}}})]})}),Vr=[{value:"01",label:"January"},{value:"02",label:"February"},{value:"03",label:"March"},{value:"04",label:"April"},{value:"05",label:"May"},{value:"06",label:"June"},{value:"07",label:"July"},{value:"08",label:"August"},{value:"09",label:"September"},{value:"10",label:"October"},{value:"11",label:"November"},{value:"12",label:"December"}];function nr(t){const a=te().year(),s=[];for(let i=a;i>=a-t;i--)s.push({label:String(i),value:i});return s}function et(t){switch(t){case"late":return e.jsx("span",{className:"label label-late",children:"L"});case"present":return e.jsx("span",{className:"label label-success",children:"P"});case"absent":return e.jsx("span",{className:"label label-danger",children:"A"});case"P":return e.jsx("span",{className:"monthlyLabel label-success",children:"P"});case"A":return e.jsx("span",{className:"monthlyLabel label-danger",children:"A"});case"L":return e.jsx("span",{className:"monthlyLabel label-late",children:"L"});case"W":return e.jsx("span",{className:"monthlyLabel sunday",children:"W"});case"H":return e.jsx("span",{className:"monthlyLabel holiday",children:"H"});default:return e.jsx("span",{className:"label",children:t})}}function sr(t){const a=te().year(),s=te().month();return t<a?Vr:Vr.slice(0,s+1)}function Wr(t,a){switch(t){case"sunday":return e.jsx("span",{className:"monthlyLabel sunday",children:a});case"holiday":return e.jsx("span",{className:"monthlyLabel holiday",children:a});default:return e.jsx("span",{className:"monthlyLabel",children:a})}}function ju(){return[{label:"One Time (During Admission)",value:"one_time"},{label:"One Time",value:"one_time_without_admission"},{label:"Monthly",value:"monthly"},{label:"Quarterly",value:"quarterly"},{label:"Half Yearly",value:"half_yearly"},{label:"Yearly",value:"yearly"}]}const Go=t=>{switch(t){case"paid":return e.jsx("div",{style:{background:"#3cb371",color:"white",textAlign:"center"},children:"PAID"});case"due":return e.jsx("div",{style:{background:"red",color:"white",textAlign:"center"},children:"DUE"});case"partially_paid":return e.jsx("div",{style:{background:"#ff8d00",color:"white",textAlign:"center"},children:"Partially Paid"});case"Present":return e.jsx(n.Tag,{color:"success",children:"Present"});case"Absent":return e.jsx(n.Tag,{color:"error",children:"Absent"});case"NO Attendance":return e.jsx(n.Tag,{color:"error",children:"No Attendance"});case"one_time":return"ONETIME";case"monthly":return"MONTHLY";case"half_yearly":return"HALF YEARLY";case"quarterly":return"QUARTERLY";default:return""}},Tt=t=>{const a=JSON.parse(localStorage.getItem("genrall_settings"));return console.log("amount______",t),e.jsxs(e.Fragment,{children:[a?.currency_icon," ",Number(t||0).toLocaleString("en-IN")]})};var _a={},Ca={},ft={},Aa={},ta={},Hr;function Su(){if(Hr)return ta;Hr=1;var t=ta&&ta.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(ta,"__esModule",{value:!0});const a=t(r),s=vl,i=["string","number","boolean"];function o({header:l,body:d}){const c=a.default.createElement("tr",null,l.map(h=>a.default.createElement("th",{key:h},h))),g=d.map((h,u)=>Array.isArray(h)?a.default.createElement("tr",{key:u},h.map((p,A)=>a.default.createElement("th",{key:A}," ",p," "))):h!==null&&typeof h=="object"?a.default.createElement("tr",{key:u},Object.entries(h).map(([p,A],w)=>typeof A=="object"?(console.error(`typeof ${p} is incorrect, only accept ${i.join(", ")} `),a.default.createElement("th",{key:w})):a.default.createElement("th",{key:w},a.default.createElement(a.default.Fragment,null,A)))):(console.error(`
|
|
11
11
|
data structure is incorrect,
|
|
12
12
|
data structure type ->
|
|
13
13
|
" type data = Array<{ [key: string]: string | number | boolean }>
|
|
14
14
|
or
|
|
15
15
|
type data = Array<(string | number | boolean)[]>"
|
|
16
|
-
`),null));return(0,s.renderToString)(a.default.createElement("table",null,a.default.createElement("tbody",null,c,g)))}return ta.default=o,ta}var Yr;function Sc(){return Yr||(Yr=1,(function(t){var a=Aa&&Aa.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(t,"__esModule",{value:!0}),t.createTable=t.template=t.uri=t.format=t.base64=void 0;function s(l){return window.btoa(unescape(encodeURIComponent(l)))}t.base64=s;function r(l,d){return l.replace(/{(\w+)}/g,(c,g)=>d[g])}t.format=r,t.uri="data:application/vnd.ms-excel;base64,",t.template='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta charset="UTF-8"><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body>{table}</body></html>';var o=jc();Object.defineProperty(t,"createTable",{enumerable:!0,get:function(){return a(o).default}})})(Aa)),Aa}var Vr;function Oo(){if(Vr)return mt;Vr=1;var t=mt&&mt.__createBinding||(Object.create?(function(f,u,p,w){w===void 0&&(w=p);var v=Object.getOwnPropertyDescriptor(u,p);(!v||("get"in v?!u.__esModule:v.writable||v.configurable))&&(v={enumerable:!0,get:function(){return u[p]}}),Object.defineProperty(f,w,v)}):(function(f,u,p,w){w===void 0&&(w=p),f[w]=u[p]})),a=mt&&mt.__setModuleDefault||(Object.create?(function(f,u){Object.defineProperty(f,"default",{enumerable:!0,value:u})}):function(f,u){f.default=u}),s=mt&&mt.__importStar||function(f){if(f&&f.__esModule)return f;var u={};if(f!=null)for(var p in f)p!=="default"&&Object.prototype.hasOwnProperty.call(f,p)&&t(u,f,p);return a(u,f),u};Object.defineProperty(mt,"__esModule",{value:!0}),mt.downloadExcel=mt.excel=void 0;const r=s(Sc());function o(){return document?!0:((process==null?void 0:process.env.NODE_ENV)!=="production"&&console.error("Failed to access document object"),!1)}function l(f,u){const p=window.document.createElement("a");return p.href=r.uri+r.base64(r.format(r.template,u)),p.download=f,document.body.appendChild(p),p.click(),document.body.removeChild(p),!0}function d(f,u){if(f)return f.cloneNode(!0).outerHTML;if(u)return r.createTable(u);console.error("currentTableRef or tablePayload does not exist")}function c({fileName:f,sheet:u,tablePayload:p},w){if(!o())return!1;const v=d(w,p);return l(f,{worksheet:u||"Worksheet",table:v})}mt.downloadExcel=c;function g({currentTableRef:f,filename:u,sheet:p}){function w(){if(!o())return!1;const v=d(f),y=`${u}.xls`;return l(y,{worksheet:p||"Worksheet",table:v})}return{onDownload:w}}return mt.excel=g,mt}var Wr;function vc(){if(Wr)return Ca;Wr=1,Object.defineProperty(Ca,"__esModule",{value:!0}),Ca.useDownloadExcel=void 0;const t=i,a=Oo();function s({currentTableRef:r,filename:o,sheet:l}){const[d,c]=(0,t.useState)({});return(0,t.useEffect)(()=>{c({currentTableRef:r,filename:o,sheet:l})},[r,o,l]),(0,t.useMemo)(()=>(0,a.excel)(d),[d])}return Ca.useDownloadExcel=s,Ca}var Hr;function wc(){return Hr||(Hr=1,(function(t){var a=_a&&_a.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(t,"__esModule",{value:!0}),t.downloadExcel=t.useDownloadExcel=t.DownloadTableExcel=void 0;const s=a(i),r=vc();Object.defineProperty(t,"useDownloadExcel",{enumerable:!0,get:function(){return r.useDownloadExcel}});const o=Oo();Object.defineProperty(t,"downloadExcel",{enumerable:!0,get:function(){return o.downloadExcel}});const l=({currentTableRef:d,filename:c,sheet:g,children:f})=>{const{onDownload:u}=(0,r.useDownloadExcel)({currentTableRef:d,filename:c,sheet:g});return s.default.createElement("span",{onClick:u},f)};t.DownloadTableExcel=l})(_a)),_a}var Mo=wc();const jt=t=>{console.log("ExportDataWithHeader______",t);const{tableRef:a}=t.data;t?.tableRef;const s=new Date().getTime(),r=xa.useReactToPrint({content:()=>a.current});return e.jsx(e.Fragment,{children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(n.Row,{gutter:8,children:[e.jsx(n.Col,{children:e.jsx(n.Button,{type:"text",icon:e.jsx(ee.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:r})}),e.jsx(n.Col,{children:e.jsx(Mo.DownloadTableExcel,{filename:s,sheet:"users",currentTableRef:a.current,children:e.jsx(n.Button,{type:"text",icon:e.jsx(ee.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})})},Pt=t=>{const{tableRef:a}=t;return new Date().getTime(),e.jsx(e.Fragment,{children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{span:24,style:{display:"flex",justifyContent:"center",alignSelf:"center",paddingBottom:"20px",position:"relative"}})})})},Qt=i.createContext(),_c=()=>({modal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundcolor:"red"}},img:{outline:"none"},passwordmodal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center"}}),Me=t=>{const{columns:a,action:s,DrawerUpdate:r,editDesign:o,newData:l,Loading:d,error:c,deleteTodoMutation:g,open:f,ActionView:u,viewDetails:p,myType:w,type:v,urlkey:y,columnstype:m,rowSelection:x}=t.data,T=_c(),[D,k]=i.useState(!1),[C,j]=i.useState(null),[h,S]=i.useState("false"),[A,R]=i.useState(!1),[q,U]=i.useState(!1),[b,O]=i.useState(),[M,$]=i.useState(""),F=()=>k(!1),N=ne=>{S(ne),k(!0)},[V,z]=i.useState(),[P,I]=i.useState({page:t?.data?.pageController?t.data?.pageController?.page:1,rowsPerPage:t?.data?.pageController?t.data?.pageController?.rowsPerPage:10}),B=i.useRef(null),L=(ne,me)=>{t.parentCallback?.(ne,me),I({rowsPerPage:me,page:ne})},H=(ne,me)=>{j(me),R(!0),O(ne)},se=(ne,me)=>{j(me),U(!0),O(ne)},W=t?.data?.onNavigate??t?.onNavigate,K=(ne,me)=>{if(typeof W=="function"){W(ne,me);return}typeof window<"u"&&typeof ne=="string"&&ne.length>0&&window.location.assign(ne)},te=ne=>{if(v==="staff"){K(`/HumanResourceDashboard/StaffFullInformation?id=${ne.fk_staffID}`,ne);return}K(`/StudentInformation/StudentFullInformation?id=${ne.id}`,ne)},oe=(ne,me)=>{z(ne),r?.(me)},pe=async(ne,me,ge,re)=>{r?.(!0),ge!==""&&((await re({id:ne,admission_no:me,ec_no:ge}))?.Status==="Success"?n.message.success("Ec No updated successfully"):n.message.error("Failed to Update Ec No."))},we=()=>e.jsx(Qt.Provider,{value:V,children:o}),{trigger:le}=rt("branchapi/staff/updateStaffPassword",za),{trigger:de}=rt("branchapi/Student/updateEcNo",za),{trigger:Q}=rt(y,(ne,me)=>za("student/studentDetails/editStudentLogInCredential",me)),ce=async ne=>{ne.preventDefault(),R(!1);try{(await le({staff_id:b,new_passwod:ne.target.password.value}))?.Status==="Success"?n.message.success("Password updated successfully"):n.message.error("Failed to update password")}catch{n.message.error("Failed to update password")}},Te=async ne=>{ne.preventDefault(),U(!1);try{(await Q({edit_id:C?.edit_id,new_passwod:ne.target.password.value,username:ne.target.username.value,branch_id:JSON.parse(localStorage.getItem("genrall_settings"))?.fk_branchID}))?.Status==="Success"?n.message.success("Password updated successfully"):n.message.error("Failed to update password")}catch(me){n.message.error(me?.response?.data?.msg??"Failed to update password")}},Ee=(Array.isArray(a)?a:[]).some(ne=>ne?.fixed==="left"),Ie=[{title:"SR. NO.",dataIndex:"__serialNumber",key:"__serialNumber",width:90,fixed:m==="antd"&&Ee?"left":void 0,sorter:(ne,me)=>(ne.__serialNumber??0)-(me.__serialNumber??0),render:ne=>ne},...m==="antd"?a:(Array.isArray(a)?a:[]).map(ne=>({title:ne.name,dataIndex:ne.selector,key:ne.selector,sorter:ne.sorter||(ne.sortable?(me,ge)=>{const re=me[ne.selector]??"",ye=ge[ne.selector]??"";return typeof re=="number"&&typeof ye=="number"?re-ye:String(re).localeCompare(String(ye))}:!1),render:(me,ge)=>{switch(ne.selector){case"my_staff":return ge.staff_id!=="0"?ge.staff_id:"Admin";case"gallery_cat_logo":return e.jsx(n.Image,{width:50,src:`undefined/branch/gallery/${ge.gallery_cat_logo}`});case"file01":return ge.documents?e.jsx("div",{onClick:()=>N(`undefined/branch/frontoffice/${ge.documents}`),style:{textDecoration:"underline",color:"blue",cursor:"pointer"},children:"view file"}):"Not Uploaded";case"amount":case"fine_amount":case"basic_pay":case"net_amount":return Tt(me);case"full_name":return e.jsx("span",{onClick:()=>te(ge),style:{cursor:"pointer",color:"blue",textDecoration:"underline"},children:me||`${ge.firstname} ${ge.lastname}`});case"extra_curricular_activity":return me==="Yes"?"Extra Subject":"Fees Master";case"is_active":return me==="yes"?e.jsx("span",{className:"label label-success",children:"Active"}):e.jsx("span",{className:"label label-danger",children:"Inactive"});case"steps":return ge?.current_status==="Active"?e.jsx(n.Progress,{percent:ge.steps==="1"?30:ge.steps==="2"?70:100,steps:3}):e.jsx("span",{className:"label label-success",children:ge?.current_status});case"Password":return e.jsx("span",{onClick:()=>H(ge.id,ge),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"Passwordstd":return e.jsx("span",{onClick:()=>se(ge.id,ge),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"payment_status":return e.jsx(n.Tag,{onClick:()=>p?.(ge.id),color:me==="paid"?"#66aa18":me==="partially_paid"?"#ff5722":"#DC143C",children:me==="paid"?"Paid":me==="partially_paid"?"Partially Paid":"Due"});case"fees_duration":return bc().find(re=>re.value===me)?.label;case"status":return e.jsx("span",{onClick:()=>p?.(ge?.fk_staffID,ge?.total_leave),className:`label ${me==="due"?"label-danger":"label-success"}`,style:{cursor:"pointer"},children:me==="due"?"Due":"Paid"});case"subject_type_1":return e.jsxs(e.Fragment,{children:[ge.is_theory==="yes"&&"Theory, ",ge.is_practical==="yes"&&"Practical"]});case"ec_no":return e.jsx(ko,{html:ge.ec_no,onBlur:re=>pe(ge.id,ge.admission_no,re.target.innerHTML,de)});case"Assign":case"AssignExtCarriAci":case"Medical":return e.jsx(n.Button,{type:"primary",icon:e.jsx(ee.SendOutlined,{}),size:"small",onClick:()=>oe(ge.id,!0,ne.name),children:ne.name});case"Button":return e.jsx(n.Tag,{color:"cyan",onClick:()=>p?.(ge),children:ne.name});default:return me}}})),...s?[{title:"Action",key:"action",render:(ne,me)=>{const ge=me?.current_status==="Promoted",re=()=>{if(w=="sameAddUpdate"){oe(me,!0);return}if(w?.type==="examEdit"){w.editFunc(me.id);return}oe(me.id||me,!0)},ye=()=>{if(w==="student_result"){p?.(me);return}if(w==="student"){p?.(me.id,me.class_id);return}p?.(me.id)},Be=()=>{g?.(me?.id)};return e.jsxs("div",{style:{display:"flex",gap:"5px"},children:[u?.[0]?.status&&e.jsx(n.Button,{icon:e.jsx(ee.EditOutlined,{}),size:"small",disabled:ge,onClick:re}),u?.[1]?.status&&e.jsx(n.Button,{icon:e.jsx(ee.DeleteOutlined,{}),size:"small",danger:!0,disabled:ge,onClick:Be}),u?.[2]?.status&&e.jsx(n.Button,{icon:e.jsx(ee.EyeOutlined,{}),size:"small",onClick:ye})]})}}]:[]],Le=i.useMemo(()=>l?Array.isArray(l?.data)?l.data:Array.isArray(l)?l:[]:[],[l]),$e=i.useMemo(()=>{const ne=M.trim().toLowerCase();return ne?Le.filter(me=>Object.values(me??{}).some(ge=>String(ge??"").toLowerCase().includes(ne))):Le},[Le,M]),et=!!t.parentCallback,He=M?$e.length:l?.pagination?.total_rows??$e.length,Oe=(P.page-1)*P.rowsPerPage,Ke=et?$e:$e.slice(Oe,Oe+P.rowsPerPage),nt=i.useMemo(()=>(Ke??[]).map((ne,me)=>({...ne??{},__serialNumber:Oe+me+1})),[Oe,Ke]),he=He===0?0:Math.min(Oe+1,He),je=He===0?0:Math.min(Oe+Ke.length,He);let be;return d?be=e.jsx("p",{children:"Loading..."}):c?be=e.jsx("p",{children:c.message}):Ke.length?be=e.jsx(n.Table,{dataSource:nt,columns:Ie,size:"small",bordered:!0,pagination:!1,rowSelection:x,rowKey:(ne,me)=>ne?.id??ne?._id??me,scroll:{x:"max-content"}}):be=e.jsx(n.Empty,{}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx(n.Drawer,{open:f,placement:"right",onClose:()=>r?.(!1),width:720,children:we()}),e.jsx(n.Modal,{title:"Update Password",open:A,onCancel:()=>R(!1),footer:null,children:e.jsx("form",{onSubmit:ce,children:e.jsxs(E,{children:[e.jsx(E,{style:{marginBottom:12},children:e.jsx(Y,{type:"password",label:"Password",name:"password",required:"required"})}),e.jsx(E,{style:{marginTop:16},children:e.jsx(n.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(n.Modal,{title:" Update Credential",open:q,onCancel:()=>U(!1),footer:null,children:e.jsx("form",{onSubmit:Te,children:e.jsxs(E,{children:[e.jsx(E,{style:{marginBottom:12},children:e.jsx(Y,{type:"text",label:"User Name",name:"username",required:"required",value:C?.username?C?.username:"",onChange:ne=>j({...C,username:ne.target.value})})}),e.jsx(E,{style:{marginBottom:12},children:e.jsx(Y,{label:"Password",name:"password",required:"required",value:C?.password?C?.password:"",onChange:ne=>j({...C,password:ne.target.value})})}),e.jsx(E,{style:{marginTop:16},children:e.jsx(n.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(n.Modal,{open:D,onCancel:F,footer:null,centered:!0,width:"80%",className:T.modal,children:e.jsxs("div",{style:{position:"relative"},className:T.img,children:[e.jsx(n.Image,{src:h,alt:"",style:{width:"100%"},preview:!1}),e.jsx(n.Button,{type:"text",icon:e.jsx(ee.CloseOutlined,{}),onClick:F,style:{position:"absolute",top:8,right:8,background:"rgba(0,0,0,0.45)",color:"#fff"}})]})}),e.jsxs(n.Card,{bodyStyle:{padding:16,background:"#f7f7fa"},children:[e.jsx("style",{children:`
|
|
16
|
+
`),null));return(0,s.renderToString)(a.default.createElement("table",null,a.default.createElement("tbody",null,c,g)))}return ta.default=o,ta}var Kr;function wu(){return Kr||(Kr=1,(function(t){var a=Aa&&Aa.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(t,"__esModule",{value:!0}),t.createTable=t.template=t.uri=t.format=t.base64=void 0;function s(l){return window.btoa(unescape(encodeURIComponent(l)))}t.base64=s;function i(l,d){return l.replace(/{(\w+)}/g,(c,g)=>d[g])}t.format=i,t.uri="data:application/vnd.ms-excel;base64,",t.template='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta charset="UTF-8"><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body>{table}</body></html>';var o=Su();Object.defineProperty(t,"createTable",{enumerable:!0,get:function(){return a(o).default}})})(Aa)),Aa}var Gr;function Jo(){if(Gr)return ft;Gr=1;var t=ft&&ft.__createBinding||(Object.create?(function(h,u,p,A){A===void 0&&(A=p);var w=Object.getOwnPropertyDescriptor(u,p);(!w||("get"in w?!u.__esModule:w.writable||w.configurable))&&(w={enumerable:!0,get:function(){return u[p]}}),Object.defineProperty(h,A,w)}):(function(h,u,p,A){A===void 0&&(A=p),h[A]=u[p]})),a=ft&&ft.__setModuleDefault||(Object.create?(function(h,u){Object.defineProperty(h,"default",{enumerable:!0,value:u})}):function(h,u){h.default=u}),s=ft&&ft.__importStar||function(h){if(h&&h.__esModule)return h;var u={};if(h!=null)for(var p in h)p!=="default"&&Object.prototype.hasOwnProperty.call(h,p)&&t(u,h,p);return a(u,h),u};Object.defineProperty(ft,"__esModule",{value:!0}),ft.downloadExcel=ft.excel=void 0;const i=s(wu());function o(){return document?!0:((process==null?void 0:process.env.NODE_ENV)!=="production"&&console.error("Failed to access document object"),!1)}function l(h,u){const p=window.document.createElement("a");return p.href=i.uri+i.base64(i.format(i.template,u)),p.download=h,document.body.appendChild(p),p.click(),document.body.removeChild(p),!0}function d(h,u){if(h)return h.cloneNode(!0).outerHTML;if(u)return i.createTable(u);console.error("currentTableRef or tablePayload does not exist")}function c({fileName:h,sheet:u,tablePayload:p},A){if(!o())return!1;const w=d(A,p);return l(h,{worksheet:u||"Worksheet",table:w})}ft.downloadExcel=c;function g({currentTableRef:h,filename:u,sheet:p}){function A(){if(!o())return!1;const w=d(h),b=`${u}.xls`;return l(b,{worksheet:p||"Worksheet",table:w})}return{onDownload:A}}return ft.excel=g,ft}var Jr;function vu(){if(Jr)return Ca;Jr=1,Object.defineProperty(Ca,"__esModule",{value:!0}),Ca.useDownloadExcel=void 0;const t=r,a=Jo();function s({currentTableRef:i,filename:o,sheet:l}){const[d,c]=(0,t.useState)({});return(0,t.useEffect)(()=>{c({currentTableRef:i,filename:o,sheet:l})},[i,o,l]),(0,t.useMemo)(()=>(0,a.excel)(d),[d])}return Ca.useDownloadExcel=s,Ca}var Qr;function _u(){return Qr||(Qr=1,(function(t){var a=_a&&_a.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(t,"__esModule",{value:!0}),t.downloadExcel=t.useDownloadExcel=t.DownloadTableExcel=void 0;const s=a(r),i=vu();Object.defineProperty(t,"useDownloadExcel",{enumerable:!0,get:function(){return i.useDownloadExcel}});const o=Jo();Object.defineProperty(t,"downloadExcel",{enumerable:!0,get:function(){return o.downloadExcel}});const l=({currentTableRef:d,filename:c,sheet:g,children:h})=>{const{onDownload:u}=(0,i.useDownloadExcel)({currentTableRef:d,filename:c,sheet:g});return s.default.createElement("span",{onClick:u},h)};t.DownloadTableExcel=l})(_a)),_a}var Qo=_u();const wt=t=>{console.log("ExportDataWithHeader______",t);const{tableRef:a}=t.data;t?.tableRef;const s=new Date().getTime(),i=xa.useReactToPrint({content:()=>a.current});return e.jsx(e.Fragment,{children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(n.Row,{gutter:8,children:[e.jsx(n.Col,{children:e.jsx(n.Button,{type:"text",icon:e.jsx(ee.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:i})}),e.jsx(n.Col,{children:e.jsx(Qo.DownloadTableExcel,{filename:s,sheet:"users",currentTableRef:a.current,children:e.jsx(n.Button,{type:"text",icon:e.jsx(ee.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})})},Ot=t=>{const{tableRef:a}=t;return new Date().getTime(),e.jsx(e.Fragment,{children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{span:24,style:{display:"flex",justifyContent:"center",alignSelf:"center",paddingBottom:"20px",position:"relative"}})})})},At=r.createContext(),Cu=()=>({modal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center","&:hover":{backgroundcolor:"red"}},img:{outline:"none"},passwordmodal:{outline:"none",display:"flex",alignItems:"center",justifyContent:"center"}}),Te=t=>{const{columns:a,action:s,DrawerUpdate:i,editDesign:o,newData:l,Loading:d,error:c,deleteTodoMutation:g,open:h,ActionView:u,viewDetails:p,myType:A,type:w,urlkey:b,columnstype:m,rowSelection:j}=t.data,D=Cu(),[R,k]=r.useState(!1),[S,x]=r.useState(null),[f,_]=r.useState("false"),[T,I]=r.useState(!1),[B,L]=r.useState(!1),[y,P]=r.useState(),[O,$]=r.useState(""),U=()=>k(!1),N=se=>{_(se),k(!0)},[V,z]=r.useState(),[E,M]=r.useState({page:t?.data?.pageController?t.data?.pageController?.page:1,rowsPerPage:t?.data?.pageController?t.data?.pageController?.rowsPerPage:10}),F=r.useRef(null),q=(se,me)=>{t.parentCallback?.(se,me),M({rowsPerPage:me,page:se})},H=(se,me)=>{x(me),I(!0),P(se)},re=(se,me)=>{x(me),L(!0),P(se)},G=t?.data?.onNavigate??t?.onNavigate,J=(se,me)=>{if(typeof G=="function"){G(se,me);return}typeof window<"u"&&typeof se=="string"&&se.length>0&&window.location.assign(se)},ae=se=>{if(w==="staff"){J(`/HumanResourceDashboard/StaffFullInformation?id=${se.fk_staffID}`,se);return}J(`/StudentInformation/StudentFullInformation?id=${se.id}`,se)},oe=(se,me)=>{z(se),i?.(me)},pe=async(se,me,xe,ie)=>{i?.(!0),xe!==""&&((await ie({id:se,admission_no:me,ec_no:xe}))?.Status==="Success"?n.message.success("Ec No updated successfully"):n.message.error("Failed to Update Ec No."))},_e=()=>e.jsx(At.Provider,{value:V,children:o}),{trigger:le}=tt("branchapi/staff/updateStaffPassword",za),{trigger:de}=tt("branchapi/Student/updateEcNo",za),{trigger:X}=tt(b,(se,me)=>za("student/studentDetails/editStudentLogInCredential",me)),ce=async se=>{se.preventDefault(),I(!1);try{(await le({staff_id:y,new_passwod:se.target.password.value}))?.Status==="Success"?n.message.success("Password updated successfully"):n.message.error("Failed to update password")}catch{n.message.error("Failed to update password")}},Re=async se=>{se.preventDefault(),L(!1);try{(await X({edit_id:S?.edit_id,new_passwod:se.target.password.value,username:se.target.username.value,branch_id:JSON.parse(localStorage.getItem("genrall_settings"))?.fk_branchID}))?.Status==="Success"?n.message.success("Password updated successfully"):n.message.error("Failed to update password")}catch(me){n.message.error(me?.response?.data?.msg??"Failed to update password")}},Ue=(Array.isArray(a)?a:[]).some(se=>se?.fixed==="left"),ke=[{title:"SR. NO.",dataIndex:"__serialNumber",key:"__serialNumber",width:90,fixed:m==="antd"&&Ue?"left":void 0,sorter:(se,me)=>(se.__serialNumber??0)-(me.__serialNumber??0),render:se=>se},...m==="antd"?a:(Array.isArray(a)?a:[]).map(se=>({title:se.name,dataIndex:se.selector,key:se.selector,sorter:se.sorter||(se.sortable?(me,xe)=>{const ie=me[se.selector]??"",ye=xe[se.selector]??"";return typeof ie=="number"&&typeof ye=="number"?ie-ye:String(ie).localeCompare(String(ye))}:!1),render:(me,xe)=>{switch(se.selector){case"my_staff":return xe.staff_id!=="0"?xe.staff_id:"Admin";case"gallery_cat_logo":return e.jsx(n.Image,{width:50,src:`undefined/branch/gallery/${xe.gallery_cat_logo}`});case"file01":return xe.documents?e.jsx("div",{onClick:()=>N(`undefined/branch/frontoffice/${xe.documents}`),style:{textDecoration:"underline",color:"blue",cursor:"pointer"},children:"view file"}):"Not Uploaded";case"amount":case"fine_amount":case"basic_pay":case"net_amount":return Tt(me);case"full_name":return e.jsx("span",{onClick:()=>ae(xe),style:{cursor:"pointer",color:"blue",textDecoration:"underline"},children:me||`${xe.firstname} ${xe.lastname}`});case"extra_curricular_activity":return me==="Yes"?"Extra Subject":"Fees Master";case"is_active":return me==="yes"?e.jsx("span",{className:"label label-success",children:"Active"}):e.jsx("span",{className:"label label-danger",children:"Inactive"});case"steps":return xe?.current_status==="Active"?e.jsx(n.Progress,{percent:xe.steps==="1"?30:xe.steps==="2"?70:100,steps:3}):e.jsx("span",{className:"label label-success",children:xe?.current_status});case"Password":return e.jsx("span",{onClick:()=>H(xe.id,xe),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"Passwordstd":return e.jsx("span",{onClick:()=>re(xe.id,xe),style:{cursor:"pointer"},className:"label label-danger",children:"Update"});case"payment_status":return e.jsx(n.Tag,{onClick:()=>p?.(xe.id),color:me==="paid"?"#66aa18":me==="partially_paid"?"#ff5722":"#DC143C",children:me==="paid"?"Paid":me==="partially_paid"?"Partially Paid":"Due"});case"fees_duration":return ju().find(ie=>ie.value===me)?.label;case"status":return e.jsx("span",{onClick:()=>p?.(xe?.fk_staffID,xe?.total_leave),className:`label ${me==="due"?"label-danger":"label-success"}`,style:{cursor:"pointer"},children:me==="due"?"Due":"Paid"});case"subject_type_1":return e.jsxs(e.Fragment,{children:[xe.is_theory==="yes"&&"Theory, ",xe.is_practical==="yes"&&"Practical"]});case"ec_no":return e.jsx(Ko,{html:xe.ec_no,onBlur:ie=>pe(xe.id,xe.admission_no,ie.target.innerHTML,de)});case"Assign":case"AssignExtCarriAci":case"Medical":return e.jsx(n.Button,{type:"primary",icon:e.jsx(ee.SendOutlined,{}),size:"small",onClick:()=>oe(xe.id,!0,se.name),children:se.name});case"Button":return e.jsx(n.Tag,{color:"cyan",onClick:()=>p?.(xe),children:se.name});default:return typeof se.render=="function"?se.render(me,xe):me}}})),...s?[{title:"Action",key:"action",render:(se,me)=>{const xe=me?.current_status==="Promoted",ie=()=>{if(A=="sameAddUpdate"){oe(me,!0);return}if(A?.type==="examEdit"){A.editFunc(me.id);return}oe(me.id||me,!0)},ye=()=>{if(A==="student_result"){p?.(me);return}if(A==="student"){p?.(me.id,me.class_id);return}p?.(me.id)},Ye=()=>{g?.(me?.id)};return e.jsxs("div",{style:{display:"flex",gap:"5px"},children:[u?.[0]?.status&&e.jsx(n.Button,{icon:e.jsx(ee.EditOutlined,{}),size:"small",disabled:xe,onClick:ie}),u?.[1]?.status&&e.jsx(n.Button,{icon:e.jsx(ee.DeleteOutlined,{}),size:"small",danger:!0,disabled:xe,onClick:Ye}),u?.[2]?.status&&e.jsx(n.Button,{icon:e.jsx(ee.EyeOutlined,{}),size:"small",onClick:ye})]})}}]:[]],Ve=r.useMemo(()=>l?Array.isArray(l?.data)?l.data:Array.isArray(l)?l:[]:[],[l]),Le=r.useMemo(()=>{const se=O.trim().toLowerCase();return se?Ve.filter(me=>Object.values(me??{}).some(xe=>String(xe??"").toLowerCase().includes(se))):Ve},[Ve,O]),at=!!t.parentCallback,Ge=O?Le.length:l?.pagination?.total_rows??Le.length,Fe=(E.page-1)*E.rowsPerPage,Je=at?Le:Le.slice(Fe,Fe+E.rowsPerPage),it=r.useMemo(()=>(Je??[]).map((se,me)=>({...se??{},__serialNumber:Fe+me+1})),[Fe,Je]),fe=Ge===0?0:Math.min(Fe+1,Ge),Se=Ge===0?0:Math.min(Fe+Je.length,Ge);let je;return d?je=e.jsx("p",{children:"Loading..."}):c?je=e.jsx("p",{children:c.message}):Je.length?je=e.jsx(n.Table,{dataSource:it,columns:ke,size:"small",bordered:!0,pagination:!1,rowSelection:j,rowKey:(se,me)=>se?.id??se?._id??me,scroll:{x:"max-content"}}):je=e.jsx(n.Empty,{}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx(n.Drawer,{open:h,placement:"right",onClose:()=>i?.(!1),width:720,children:_e()}),e.jsx(n.Modal,{title:"Update Password",open:T,onCancel:()=>I(!1),footer:null,children:e.jsx("form",{onSubmit:ce,children:e.jsxs(C,{children:[e.jsx(C,{style:{marginBottom:12},children:e.jsx(Y,{type:"password",label:"Password",name:"password",required:"required"})}),e.jsx(C,{style:{marginTop:16},children:e.jsx(n.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(n.Modal,{title:" Update Credential",open:B,onCancel:()=>L(!1),footer:null,children:e.jsx("form",{onSubmit:Re,children:e.jsxs(C,{children:[e.jsx(C,{style:{marginBottom:12},children:e.jsx(Y,{type:"text",label:"User Name",name:"username",required:"required",value:S?.username?S?.username:"",onChange:se=>x({...S,username:se.target.value})})}),e.jsx(C,{style:{marginBottom:12},children:e.jsx(Y,{label:"Password",name:"password",required:"required",value:S?.password?S?.password:"",onChange:se=>x({...S,password:se.target.value})})}),e.jsx(C,{style:{marginTop:16},children:e.jsx(n.Button,{type:"primary",htmlType:"submit",children:"Update"})})]})})}),e.jsx(n.Modal,{open:R,onCancel:U,footer:null,centered:!0,width:"80%",className:D.modal,children:e.jsxs("div",{style:{position:"relative"},className:D.img,children:[e.jsx(n.Image,{src:f,alt:"",style:{width:"100%"},preview:!1}),e.jsx(n.Button,{type:"text",icon:e.jsx(ee.CloseOutlined,{}),onClick:U,style:{position:"absolute",top:8,right:8,background:"rgba(0,0,0,0.45)",color:"#fff"}})]})}),e.jsxs(n.Card,{bodyStyle:{padding:16,background:"#f7f7fa"},children:[e.jsx("style",{children:`
|
|
17
17
|
.ubk-table-shell .ant-table-wrapper {
|
|
18
18
|
background: #fff;
|
|
19
19
|
border: 1px solid #e7e8f2;
|
|
@@ -56,6 +56,6 @@ Valid keys: `+JSON.stringify(Object.keys(P),null," "));var le=we(K,pe,H,se,W+".
|
|
|
56
56
|
.ubk-table-shell .ant-pagination .ant-pagination-next button:hover {
|
|
57
57
|
color: #8f99ff;
|
|
58
58
|
}
|
|
59
|
-
`}),e.jsx(E,{children:e.jsx("div",{style:{display:"flex",justifyContent:"space-between"},children:e.jsx(jt,{data:{tableRef:B}})})}),e.jsxs("div",{className:"ubk-table-shell",ref:B,style:{marginTop:12},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,flexWrap:"wrap",marginBottom:14},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"#222"},children:[e.jsx("span",{children:"Show"}),e.jsx(n.Select,{size:"small",value:P.rowsPerPage,onChange:ne=>L(1,ne),options:[10,25,50,100].map(ne=>({label:ne,value:ne})),style:{width:72}}),e.jsx("span",{children:"entries"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:12,color:"#222"},children:"Search:"}),e.jsx(n.Input,{size:"small",allowClear:!0,value:M,onChange:ne=>{$(ne.target.value),I(me=>({...me,page:1}))},placeholder:"Enter search keyword",prefix:e.jsx(ee.SearchOutlined,{style:{color:"#a3a8cf"}}),style:{width:220,borderWidth:"0 0 1px 0",borderRadius:0,background:"transparent"}})]})]}),e.jsx("div",{className:"print-only",children:e.jsx(Pt,{})}),be]}),l&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,marginTop:16,flexWrap:"wrap"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:`Showing ${he} to ${je} of ${He} entries`}),e.jsx(n.Pagination,{current:P.page,pageSize:P.rowsPerPage,total:He||0,showSizeChanger:!1,onChange:L})]})]})]})},Cc=({token:t,type:a})=>{const[s,r]=i.useState({page:1,rowsPerPage:10}),o="api/branchapi/frontoffice/enquirytablelist",l=o.includes("?")?o.endsWith("?")||o.endsWith("&")?"":"&":"?",d=`${o}${l}page=${s.page}&per_page=${s.rowsPerPage}`,{isLoading:c,data:g,error:f}=G(t?[d,t]:null,([D,k])=>J(D,k)),[u,p]=i.useState(!1),w=(D,k)=>{r({page:D,rowsPerPage:parseInt(k)})},v=async D=>{},y=D=>{console.log("dsdsdsdsd",D),p(D)},m=()=>{},x=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],T=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0,sorter:{compare:(D,k)=>D.name.localeCompare(k.name)}},{id:"2",name:"Phone",selector:"contact",sortable:!0,sorter:(D,k)=>(D.contact||"").localeCompare(k.contact||"")},{id:"6",name:"Description",selector:"description",sortable:!0,sorter:(D,k)=>(D.description||"").localeCompare(k.description||"")},{id:"3",name:"Source",selector:"source_name",sortable:!0,sorter:(D,k)=>(D.source_name||"").localeCompare(k.source_name||"")},{id:"4",name:"Enquiry Date",selector:"date",sortable:!0,sorter:(D,k)=>new Date(D.date)-new Date(k.date)},{id:"5",name:"Next Follow Up Date",selector:"follow_up_date",sortable:!0,sorter:(D,k)=>new Date(D.follow_up_date)-new Date(k.follow_up_date)}]);return e.jsx("div",{children:e.jsx(Me,{parentCallback:w,data:{newData:g,columns:T,action:!0,Loading:c,error:f,open:u,viewDetails:m,deleteTodoMutation:v,DrawerUpdate:y,ActionView:x}})})};var Ac=Io();const Ss=To(Ac),Eo=()=>{};class tr extends i.Component{state={value:this.props.value||this.props.defaultValue||""};selectRef=null;setSelectRef=a=>{this.selectRef=a};componentDidUpdate(a){a.value!==this.props.value&&this.setState({value:this.props.value})}onChange=(a,s)=>{this.props.onChange(a,s),this.setState({value:a})};getValue=()=>{const{value:a}=this.state;return a?Array.isArray(a)?a.length?"valid":"":typeof a=="object"?a.value||"":a:""};render(){const{SelectComponent:a,required:s,...r}=this.props;console.log("sdsdsfsdddddddd",{...r});const{isDisabled:o}=this.props,l=!o;return e.jsxs("div",{children:[e.jsx(a,{...r,ref:this.setSelectRef,onChange:this.onChange}),l&&e.jsx("input",{tabIndex:-1,autoComplete:"off",style:{opacity:0,width:"100%",height:0,display:"block"},value:this.getValue(),onChange:Eo,onFocus:()=>this.selectRef.focus(),required:s})]})}}tr.defaultProps={onChange:Eo};tr.protoTypes={selectComponent:Ss.func.isRequired,onChange:Ss.func,required:Ss.bool};const Tc={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Dc={menuPortal:t=>({...t,zIndex:9999}),control:(t,a)=>({...t,minHeight:40,height:40,fontSize:"14px",border:"none",borderBottom:`1px solid ${a.isFocused?"#222":"#d9d9d9"}`,borderRadius:0,boxShadow:"none",backgroundColor:"transparent",transition:"border-color 0.2s ease","&:hover":{border:"none",borderBottom:`1px solid ${a.isFocused?"#222":"#a8a8a8"}`}}),valueContainer:t=>({...t,height:40,padding:"0 0",display:"flex",alignItems:"center"}),input:t=>({...t,margin:0,padding:0}),indicatorSeparator:()=>({display:"none"}),indicatorsContainer:t=>({...t,height:40}),dropdownIndicator:(t,a)=>({...t,padding:"0 0 0 8px",color:a.isFocused?"#222":"#b5b5b5"}),singleValue:t=>({...t,color:"#222",marginLeft:0}),placeholder:t=>({...t,color:"#9f9f9f",marginLeft:0}),option:(t,a)=>({...t,fontSize:"14px",backgroundColor:a.isFocused?"#f8f8f8":"#fff",color:"#222",cursor:"pointer"})},Fo=t=>e.jsx(to.components.Input,{...t,className:"input-cont",required:!!t?.selectProps?.required}),Rc=t=>e.jsx(tr,{...t,SelectComponent:to,components:{Input:Fo},options:t.options}),Z=i.forwardRef(({...t},a)=>e.jsxs("div",{className:"form-group",style:{height:"auto"},children:[t.label&&e.jsx("label",{className:"labelfont",style:Tc,children:t?.label}),e.jsx(Rc,{components:{Input:Fo},menuPortalTarget:document.body,styles:Dc,className:"input-cont",...t,ref:a})]})),Ic={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},kc={width:"100%",height:"40px",background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Pc=(t,a,s)=>a?t>ae(s).endOf("day")||t<ae(a).endOf("day"):!1,Ue=i.forwardRef(function(a,s){const{...r}=a;return e.jsxs("div",{className:"form-group",children:[r.Desplay&&e.jsx("label",{className:`labelfont ${r.classnme?r.classnme:""}`,style:Ic,children:r.Desplay}),e.jsx(n.DatePicker,{...r,style:{...kc,...r.style||{}},className:"form-group",disabledDate:o=>Pc(o,r.sessionStart||r.minDate?.subtract(1,"day").format("YYYY-MM-DD"),r.sessionEnd||r.maxDate?.format("YYYY-MM-DD")),required:!0,ref:s})]})}),Oc={minWidth:160,height:36,padding:"0 28px",border:"none",borderRadius:999,background:"linear-gradient(90deg, #f59b1c 0%, #ef3e7b 100%)",color:"#fff",fontSize:14,fontWeight:700,textTransform:"uppercase",cursor:"pointer",boxShadow:"none"},ie=i.forwardRef(({error:t,success:a,disabled:s,style:r,...o},l)=>e.jsx("div",{className:"form-group",style:{marginBottom:0},children:e.jsx("input",{...o,ref:l,disabled:s,style:{...Oc,opacity:s?.7:1,cursor:s?"not-allowed":"pointer",...r||{}}})})),Mc={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Ec={width:"100%",minHeight:80,padding:"8px 0",fontSize:"14px",color:"#222",background:"transparent",border:0,borderTop:0,borderLeft:0,borderRight:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",outline:"none",resize:"vertical",transition:"border-color 0.2s ease"},vt=({style:t,onFocus:a,onBlur:s,...r})=>{const[o,l]=i.useState(!1);return e.jsxs("div",{style:{width:"100%"},children:[r.label&&e.jsx("label",{className:"labelfont",style:Mc,children:r.label}),e.jsx("textarea",{placeholder:r.placeholder||r.label,...r,onFocus:d=>{l(!0),a?.(d)},onBlur:d=>{l(!1),s?.(d)},style:{...Ec,borderBottom:`1px solid ${o?"#222":"#d9d9d9"}`,...t||{}}})]})},We=t=>({optimisticData:a=>[...a.data,t],populateCache:(a,s)=>[...s.data,a]}),qe=t=>({optimisticData:a=>a.data.filter(s=>s.id!==t),populateCache:(a,s)=>s.data.filter(r=>r.id!==t)}),Fc=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},$c="api/branchapi/Frontoffice/visitorbookShowdata",Uc="api/branchapi/Frontoffice/purposedropdown";function Nc({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(Qt),o=$c.replace(/\?.*$/,""),{isLoading:l,data:d}=G(s&&r?[o,r,s]:null,([m,x,T])=>Qa(m,{id:x},T)),{isLoading:c,data:g}=G(s?[Uc,s]:null,([m,x])=>J(m,x)),f=i.useMemo(()=>Fc(g),[g]),u=d?.data?.[0],[p,w]=i.useState({purpose:void 0,name:"",phone:"",id_card:"",number_of_person:1,date:null,in_time:null,out_time:null,note:"",address:"",image:""});i.useEffect(()=>{u&&w({purpose:u?.purpose,name:u?.name||"",phone:u?.contact||"",id_card:u?.id_proof||"",number_of_person:u?.no_of_pepple||1,date:u?.date?ae(u.date):null,in_time:u?.in_time?ae(u.in_time,"h:mm a"):null,out_time:u?.out_time?ae(u.out_time,"h:mm a"):null,note:u?.note||"",address:u?.address||"",image:u?.image||""})},[u]);const v=(m,x)=>{w(T=>({...T,[m]:x}))},y=`${at()}/branchapi/frontoffice/uploadfrontofficeDocument`;return l||c?e.jsx(E,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(E,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:m=>a(m,r),children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Visitor"})}),e.jsx(E,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Z,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Purpose",name:"purpose",allowSelectAll:!1,value:p.purpose,onChange:m=>v("purpose",m)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"name",type:"text",label:"Name",required:!0,value:p.name,onChange:m=>v("name",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"phone",type:"text",label:"Phone No.",required:!0,value:p.phone,onChange:m=>v("phone",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"id_card",type:"text",label:"ID Card",value:p.id_card,onChange:m=>v("id_card",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"number_of_person",type:"number",label:"Number of Person",value:p.number_of_person,onChange:m=>v("number_of_person",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Ue,{format:"YYYY-MM-DD",value:p.date,Desplay:"Date",id:"date",name:"date",required:!0,onChange:m=>v("date",m)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(E,{children:[e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",value:p.in_time,onChange:m=>v("in_time",m),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time",value:p.in_time?p.in_time.format("h:mm a"):"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(E,{children:[e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",value:p.out_time,onChange:m=>v("out_time",m),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time",value:p.out_time?p.out_time.format("h:mm a"):"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"note",type:"text",label:"Note",value:p.note,onChange:m=>v("note",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(vt,{type:"text",label:"Address",name:"address",rows:3,required:!0,value:p.address,onChange:m=>v("address",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(E,{children:[e.jsx(n.Upload,{action:y,headers:{Authorization:s},maxCount:1,onChange:m=>{if(m.file.status==="removed"&&v("image",""),m.file.status==="done"){const x=m.file.response?.data??m.file.response?.file??"";v("image",String(x??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:p.image?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"image",value:p.image||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(E,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; } .textDanger { color: #dc2626; }"})]})}const Bc=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},aa="api/branchapi/Frontoffice/visitortablelist",Lc="api/branchapi/Frontoffice/purposedropdown",qc="api/branchapi/frontoffice/addvisitors",zc="api/branchapi/frontoffice/editvisitorsdata",Yc="api/branchapi/frontoffice/deletevisitors",Vc=`${at()}/branchapi/frontoffice/uploadfrontofficeDocument`;function Wc({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c,g]=i.useState(""),[f,u]=i.useState("03:30 PM"),p=(b,O)=>{s({page:b,rowsPerPage:Number.parseInt(O,10)})},w=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],v=i.useMemo(()=>{const b=aa.includes("?")?aa.endsWith("?")||aa.endsWith("&")?"":"&":"?";return`${aa}${b}page=${a.page}&per_page=${a.rowsPerPage}`},[aa,a.page,a.rowsPerPage]),{isLoading:y,error:m,data:x,mutate:T}=G(t?[v,t]:null,([b,O])=>J(b,O)),{isLoading:D,data:k}=G(t?[Lc,t]:null,([b,O])=>J(b,O)),C=i.useMemo(()=>Bc(k),[k]),j=async(b,O)=>{try{await T(Ne(b,O,t),We(O)),_.success("Success! Added new item.")}catch{_.error("Failed to add the new item.")}},h=async b=>{try{await T(Ve(Yc,b,t),qe(b)),_.success("Success! Deleted item.")}catch{_.error("Failed to delete the item.")}},S=async(b,O,M)=>{try{const $=await Qe(b,O,t);T($),Array.isArray($?.data)&&T(`${aa.replace(/\?.*$/,"")}?id=${M}`,$),_.success("Success! Updated item.")}catch{_.error("Failed to update the item.")}},A=async(b,O)=>{b.preventDefault();const M=new FormData(b.target);await S(zc,M,O),b.target.reset(),d(""),o(!1)},R=async b=>{if(b.preventDefault(),!b.target?.date?.value)_.error("Select required dates"),b.target?.date?.focus(),g("textDanger");else{const O=new FormData(b.target);await j(qc,O),b.target.reset(),g(""),d(""),u("03:30 PM")}},q=b=>{o(b)},U=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0},{id:"2",name:"Purpose",selector:"visitors_purpose",sortable:!0},{id:"3",name:"Phone",selector:"contact",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Address",selector:"address",sortable:!0},{id:"5",name:"In Time",selector:"in_time",sortable:!0},{id:"6",name:"Out Time",selector:"out_time",sortable:!0}],[]);return e.jsxs("div",{children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Visitor"})}),e.jsx(E,{p:3,children:e.jsx("form",{onSubmit:R,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Z,{options:C,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Purpose",name:"purpose",required:!0,allowSelectAll:!1})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{required:!0,name:"name",type:"text",label:"Name"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",name:"phone",type:"tel",label:"Phone No.",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"id_card",type:"text",label:"ID Card"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{defaultValue:1,name:"number_of_person",type:"number",label:"Number of Person"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Ue,{format:"YYYY-MM-DD",defaultValue:ae(),Desplay:"Date",id:"date",name:"date",classnme:c,onChange:()=>g("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(E,{children:[e.jsx(n.TimePicker,{defaultValue:ae("2022-04-17T15:30","h:mm a"),id:"in_time",use12Hours:!0,format:"h:mm a",onChange:(b,O)=>u(O),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time",value:f,readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(vt,{type:"text",label:"Address*",name:"address",rows:3,required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(E,{children:[e.jsx(n.Upload,{action:Vc,headers:{Authorization:t},maxCount:1,onChange:b=>{if(b.file.status==="removed"&&d(""),b.file.status==="done"){const O=b.file.response?.data??b.file.response?.file??"";d(String(O??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:l?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"image",value:l||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(E,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Visitor List"})}),e.jsx(E,{pt:3,children:e.jsx(Me,{parentCallback:p,data:{newData:x,columns:U,action:!0,ActionView:w,Loading:y,error:m,editDesign:e.jsx(Nc,{data:{handleUpdate:A,token:t}}),deleteTodoMutation:h,open:r,DrawerUpdate:q,viewDetails:""}})})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const Hc="api/branchapi/frontoffice/generalcallsShowdata",Kc=[{value:"Incoming",label:"Incoming"},{value:"Outgoing",label:"Outgoing"}];function Gc({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(Qt),o=Hc.replace(/\?.*$/,""),{isLoading:l,data:d}=G(s&&r?[o,r,s]:null,([p,w,v])=>Qa(p,{id:w},v)),c=d?.data?.[0],[g,f]=i.useState({name:"",phone:"",description:"",date:null,next_follow_up_date:null,call_duration:"",note:"",call_type:""});i.useEffect(()=>{c&&f({name:c?.name||"",phone:c?.contact||"",description:c?.description||"",date:c?.date?ae(c.date):null,next_follow_up_date:c?.follow_up_date?ae(c.follow_up_date):null,call_duration:c?.call_dureation||"",note:c?.note||"",call_type:c?.call_type||""})},[c]);const u=(p,w)=>{f(v=>({...v,[p]:w}))};return l?e.jsx(E,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(E,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:p=>a(p,r),children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Call Log"})}),e.jsx(E,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"name",type:"text",label:"Name",required:!0,value:g.name,onChange:p=>u("name",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",value:g.phone,onChange:p=>u("phone",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"description",type:"text",label:"Description",value:g.description,onChange:p=>u("description",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Ue,{format:"YYYY-MM-DD",value:g.date,Desplay:"Date",id:"date",name:"date",onChange:p=>u("date",p)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Ue,{format:"YYYY-MM-DD",value:g.next_follow_up_date,Desplay:"Next Follow Up Date",id:"fdate",name:"next_follow_up_date",onChange:p=>u("next_follow_up_date",p)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"call_duration",type:"text",label:"Call Duration",value:g.call_duration,onChange:p=>u("call_duration",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"note",type:"text",label:"Note",value:g.note,onChange:p=>u("note",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Z,{options:Kc,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Call Type",name:"call_type",required:!0,allowSelectAll:!1,value:g.call_type?{value:g.call_type,label:g.call_type}:null,onChange:p=>u("call_type",p?.value||"")})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(E,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const na="api/branchapi/frontoffice/generalcalltablelist",Jc="api/branchapi/frontoffice/addgenaralcalls",Qc="api/branchapi/frontoffice/editgeneralcall",Xc="api/branchapi/frontoffice/deletegeneralcall",Zc=[{value:"Incoming",label:"Incoming"},{value:"Outgoing",label:"Outgoing"}],eu=[{key:"all",label:"All Calls"},{key:"Incoming",label:"Incoming"},{key:"Outgoing",label:"Outgoing"}];function tu({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c,g]=i.useState(""),[f,u]=i.useState("all"),[p,w]=i.useState(""),v=i.useRef(null),y=(b,O)=>{s({page:b,rowsPerPage:Number.parseInt(O,10)})},m=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],x=i.useMemo(()=>{const b=na.includes("?")?na.endsWith("?")||na.endsWith("&")?"":"&":"?",O=new URLSearchParams;return O.set("page",String(a.page)),O.set("per_page",String(a.rowsPerPage)),f!=="all"&&O.set("call_type",f),`${na}${b}${O.toString()}`},[na,a.page,a.rowsPerPage,f]),{isLoading:T,error:D,data:k,mutate:C}=G(t?[x,t]:null,([b,O])=>J(b,O)),j=async(b,O)=>{try{await C(Ne(b,O,t),We(O)),_.success("Success! Added new item.")}catch{_.error("Failed to add the new item.")}},h=async b=>{try{await C(Ve(Xc,b,t),qe(b)),_.success("Success! Deleted item.")}catch{_.error("Failed to delete the item.")}},S=async(b,O,M)=>{try{const $=await Qe(b,O,t);C($),Array.isArray($?.data)&&C(`${na.replace(/\?.*$/,"")}?id=${M}`,$),_.success("Success! Updated item.")}catch{_.error("Failed to update the item.")}},A=async(b,O)=>{b.preventDefault();const M=new FormData(b.target);await S(Qc,M,O),b.target.reset(),d(""),o(!1)},R=async b=>{if(b.preventDefault(),!b.target?.date?.value)_.error("Select required dates"),b.target?.date?.focus(),g("textDanger");else{const O=new FormData(b.target);await j(Jc,O),b.target.reset(),g(""),d(""),w("")}},q=b=>{o(b)},U=i.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0},{id:"2",name:"Phone",selector:"contact",sortable:!0},{id:"3",name:"Description",selector:"description",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Follow Up Date",selector:"follow_up_date",sortable:!0},{id:"6",name:"Call Duration",selector:"call_dureation",sortable:!0}],[]);return e.jsxs(E,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Phone Call Log"})}),e.jsx(E,{p:3,children:e.jsx("form",{onSubmit:R,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{required:!0,name:"name",type:"text",label:"Name"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",name:"phone",type:"tel",label:"Phone",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"description",type:"text",label:"Description"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Ue,{format:"YYYY-MM-DD",defaultValue:ae(),Desplay:"Date",id:"date",name:"date",classnme:c,onChange:()=>g("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Ue,{format:"YYYY-MM-DD",Desplay:"Next Follow Up Date",id:"fdate",name:"follow_up_date"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"call_dureation",type:"text",label:"Call Duration"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Z,{options:Zc,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Call Type",name:"call_type",required:!0,allowSelectAll:!1,value:p?{value:p,label:p}:null,onChange:b=>w(b?.value||"")})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(E,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Phone Call Log List"})}),e.jsxs(E,{pt:3,children:[e.jsx(n.Tabs,{activeKey:f,onChange:u,items:eu}),e.jsx(jt,{data:{tableRef:v}}),e.jsx(Me,{parentCallback:y,data:{newData:k,columns:U,action:!0,ActionView:m,Loading:T,error:D,editDesign:e.jsx(Gc,{data:{handleUpdate:A,token:t}}),deleteTodoMutation:h,open:r,DrawerUpdate:q,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const au="api/branchapi/frontoffice/postaldispatchreceiveShowdata";function nu({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(Qt),o=au.replace(/\?.*$/,""),{isLoading:l,data:d}=G(s&&r?[o,r,s]:null,([p,w,v])=>Qa(p,{id:w},v)),c=d?.data?.[0],[g,f]=i.useState({to_title:"",refernce:"",address:"",note:"",from_title:"",date:null,image:""});i.useEffect(()=>{c&&f({to_title:c?.to_title||"",refernce:c?.reference_no||"",address:c?.address||"",note:c?.note||"",from_title:c?.from_title||"",date:c?.date?ae(c.date):null,image:c?.image||""})},[c]);const u=(p,w)=>{f(v=>({...v,[p]:w}))};return l?e.jsx(E,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(E,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:p=>a(p,r),children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Postal Dispatch"})}),e.jsx(E,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"title",type:"text",label:"To Title *",required:!0,value:g.to_title,onChange:p=>u("to_title",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"refernce",type:"text",label:"Reference No",value:g.refernce,onChange:p=>u("refernce",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"address",type:"text",label:"Address",required:!0,value:g.address,onChange:p=>u("address",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"note",type:"text",label:"Note",value:g.note,onChange:p=>u("note",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"from_title",type:"text",label:"From Title",required:!0,value:g.from_title,onChange:p=>u("from_title",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Ue,{format:"YYYY-MM-DD",value:g.date,Desplay:"Date",id:"date",name:"date",onChange:p=>u("date",p)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(E,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const sa="api/branchapi/frontoffice/postaldispatchtablelist",su="api/branchapi/frontoffice/addpostaldispatch",ru="api/branchapi/frontoffice/editpostaldispatch",iu="api/branchapi/frontoffice/deletepostalreceivedispatch";function ou({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c,g]=i.useState(""),f=i.useRef(null),u=(A,R)=>{s({page:A,rowsPerPage:Number.parseInt(R,10)})},p=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],w=i.useMemo(()=>{const A=sa.includes("?")?sa.endsWith("?")||sa.endsWith("&")?"":"&":"?";return`${sa}${A}page=${a.page}&per_page=${a.rowsPerPage}`},[sa,a.page,a.rowsPerPage]),{isLoading:v,error:y,data:m,mutate:x}=G(t?[w,t]:null,([A,R])=>J(A,R)),T=async(A,R)=>{try{await x(Ne(A,R,t),We(R)),_.success("Success! Added new item.")}catch{_.error("Failed to add the new item.")}},D=async A=>{try{await x(Ve(iu,A,t),qe(A)),_.success("Success! Deleted item.")}catch{_.error("Failed to delete the item.")}},k=async(A,R,q)=>{try{const U=await Qe(A,R,t);x(U),Array.isArray(U?.data)&&x(`${sa.replace(/\?.*$/,"")}?id=${q}`,U),_.success("Success! Updated item.")}catch{_.error("Failed to update the item.")}},C=async(A,R)=>{A.preventDefault();const q=new FormData(A.target);await k(ru,q,R),A.target.reset(),d(""),o(!1)},j=async A=>{if(A.preventDefault(),!A.target?.date?.value)_.error("Select required dates"),A.target?.date?.focus(),g("textDanger");else{const R=new FormData(A.target);await T(su,R),A.target.reset(),g(""),d("")}},h=A=>{o(A)},S=i.useMemo(()=>[{id:"1",name:"To Title",selector:"to_title",sortable:!0},{id:"2",name:"Reference No",selector:"reference_no",sortable:!0},{id:"3",name:"Address",selector:"address",sortable:!0},{id:"4",name:"Note",selector:"note",sortable:!0},{id:"5",name:"From Title",selector:"from_title",sortable:!0},{id:"6",name:"Date",selector:"date",sortable:!0}],[]);return e.jsxs(E,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Postal Dispatch"})}),e.jsx(E,{p:3,children:e.jsx("form",{onSubmit:j,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{required:!0,name:"title",type:"text",label:"To Title *"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"refernce",type:"text",label:"Reference No"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{required:!0,name:"address",type:"text",label:"Address"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{required:!0,name:"from_title",type:"text",label:"From Title"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Ue,{format:"YYYY-MM-DD",defaultValue:ae(),Desplay:"Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>g("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx("input",{type:"hidden",name:"image",value:l||"",readOnly:!0})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(E,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Postal Dispatch List"})}),e.jsxs(E,{pt:3,children:[e.jsx(jt,{data:{tableRef:f}}),e.jsx(Me,{parentCallback:u,data:{newData:m,columns:S,action:!0,ActionView:p,Loading:v,error:y,editDesign:e.jsx(nu,{data:{handleUpdate:C,token:t}}),deleteTodoMutation:D,open:r,DrawerUpdate:h,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const lu="api/branchapi/frontoffice/postaldispatchreceiveShowdata";function du({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(Qt),o=lu.replace(/\?.*$/,""),{isLoading:l,data:d}=G(s&&r?[o,r,s]:null,([p,w,v])=>Qa(p,{id:w},v)),c=d?.data?.[0],[g,f]=i.useState({from_title:"",refernce:"",address:"",note:"",title:"",date:null,image:""});i.useEffect(()=>{c&&f({from_title:c?.from_title||"",refernce:c?.reference_no||"",address:c?.address||"",note:c?.note||"",title:c?.to_title||"",date:c?.date?ae(c.date):null,image:c?.image||""})},[c]);const u=(p,w)=>{f(v=>({...v,[p]:w}))};return l?e.jsx(E,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(E,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:p=>a(p,r),children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Postal Receive"})}),e.jsx(E,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{type:"text",value:r,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"from_title",type:"text",label:"From Title *",required:!0,value:g.from_title,onChange:p=>u("from_title",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"refernce",type:"text",label:"Reference No",required:!0,value:g.refernce,onChange:p=>u("refernce",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"address",type:"text",label:"Address",required:!0,value:g.address,onChange:p=>u("address",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"note",type:"text",label:"Note",value:g.note,onChange:p=>u("note",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"title",type:"text",label:"To Title",required:!0,value:g.title,onChange:p=>u("title",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Ue,{format:"YYYY-MM-DD",value:g.date,Desplay:"Date",id:"date",name:"date",onChange:p=>u("date",p)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(E,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const ra="api/branchapi/frontoffice/postalrecivetablelist",cu="api/branchapi/frontoffice/addpostalrecive",uu="api/branchapi/frontoffice/editpostalrecive",pu="api/branchapi/frontoffice/deletepostalreceivedispatch";function mu({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c,g]=i.useState(""),f=i.useRef(null),u=(A,R)=>{s({page:A,rowsPerPage:Number.parseInt(R,10)})},p=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],w=i.useMemo(()=>{const A=ra.includes("?")?ra.endsWith("?")||ra.endsWith("&")?"":"&":"?";return`${ra}${A}page=${a.page}&per_page=${a.rowsPerPage}`},[ra,a.page,a.rowsPerPage]),{isLoading:v,error:y,data:m,mutate:x}=G(t?[w,t]:null,([A,R])=>J(A,R)),T=async(A,R)=>{try{await x(Ne(A,R,t),We(R)),_.success("Success! Added new item.")}catch{_.error("Failed to add the new item.")}},D=async A=>{try{await x(Ve(pu,A,t),qe(A)),_.success("Success! Deleted item.")}catch{_.error("Failed to delete the item.")}},k=async(A,R,q)=>{try{const U=await Qe(A,R,t);x(U),Array.isArray(U?.data)&&x(`${ra.replace(/\?.*$/,"")}?id=${q}`,U),_.success("Success! Updated item.")}catch{_.error("Failed to update the item.")}},C=async(A,R)=>{A.preventDefault();const q=new FormData(A.target);await k(uu,q,R),A.target.reset(),d(""),o(!1)},j=async A=>{if(A.preventDefault(),!A.target?.date?.value)_.error("Select required dates"),A.target?.date?.focus(),g("textDanger");else{const R=new FormData(A.target);await T(cu,R),A.target.reset(),g(""),d("")}},h=A=>{o(A)},S=i.useMemo(()=>[{id:"1",name:"From Title",selector:"from_title",sortable:!0},{id:"2",name:"Reference No",selector:"reference_no",sortable:!0},{id:"3",name:"Address",selector:"address",sortable:!0},{id:"4",name:"Note",selector:"note",sortable:!0},{id:"5",name:"To Title",selector:"to_title",sortable:!0},{id:"6",name:"Date",selector:"date",sortable:!0}],[]);return e.jsxs(E,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Postal Receive"})}),e.jsx(E,{p:3,children:e.jsx("form",{onSubmit:j,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{required:!0,name:"from_title",type:"text",label:"From Title *"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{required:!0,name:"refernce",type:"text",label:"Reference No"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{required:!0,name:"address",type:"text",label:"Address"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{required:!0,name:"title",type:"text",label:"To Title"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Ue,{format:"YYYY-MM-DD",defaultValue:ae(),Desplay:"Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>g("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx("input",{type:"hidden",name:"image",value:l||"",readOnly:!0})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(E,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Postal Receive List"})}),e.jsxs(E,{pt:3,children:[e.jsx(jt,{data:{tableRef:f}}),e.jsx(Me,{parentCallback:u,data:{newData:m,columns:S,action:!0,ActionView:p,Loading:v,error:y,editDesign:e.jsx(du,{data:{handleUpdate:C,token:t}}),deleteTodoMutation:D,open:r,DrawerUpdate:h,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const fu="api/branchapi/frontoffice/complaintShowdata",hu="api/branchapi/frontoffice/complainttypedropdown",yu=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function gu({data:t}){const{handleUpdate:a,token:s}=t||{},r=i.useContext(Qt),o=fu.replace(/\?.*$/,""),{isLoading:l,data:d}=G(s&&r?[o,r,s]:null,([m,x,T])=>Qa(m,{id:x},T)),{isLoading:c,data:g}=G(s?[hu,s]:null,([m,x])=>J(m,x)),f=i.useMemo(()=>yu(g).map(x=>({value:x?.value??x?.id??x?.complaint_type??"",label:x?.complaint_type??x?.label??""})),[g]),u=d?.data?.[0],[p,w]=i.useState({complain_type:"",complain_by_name:"",phone:"",date:null,description:"",action_token:"",assigned:"",note:"",file:""});i.useEffect(()=>{u&&w({complain_type:u?.complaint_type??"",complain_by_name:u?.name??"",phone:u?.contact??"",date:u?.date?ae(u.date):null,description:u?.description??"",action_token:u?.action_taken??"",assigned:u?.assigned??"",note:u?.note??"",file:u?.image??""})},[u]);const v=(m,x)=>{w(T=>({...T,[m]:x}))},y=i.useMemo(()=>f.find(m=>m.value===p.complain_type)||null,[f,p.complain_type]);return l||c?e.jsx(E,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsx(E,{pt:4,pb:1,style:{width:550},children:e.jsxs("form",{onSubmit:m=>a(m,r),children:[e.jsx("input",{type:"hidden",name:"id",value:r??""}),e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Complaint"})}),e.jsx(E,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Z,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Complain Type",name:"complain_type",allowSelectAll:!1,value:y,onChange:m=>v("complain_type",m?.value??"")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"complain_by_name",type:"text",label:"Complain By *",required:!0,value:p.complain_by_name,onChange:m=>v("complain_by_name",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{10}",value:p.phone,onChange:m=>v("phone",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Ue,{format:"YYYY-MM-DD",value:p.date,Desplay:"Enquiry Date",id:"date",name:"date",onChange:m=>v("date",m)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"description",type:"text",label:"Description",value:p.description,onChange:m=>v("description",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"action_token",type:"text",label:"Action Taken",value:p.action_token,onChange:m=>v("action_token",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"assigned",type:"text",label:"Assigned",value:p.assigned,onChange:m=>v("assigned",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"note",type:"text",label:"Note",value:p.note,onChange:m=>v("note",m.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(E,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})]})})}const ia="api/branchapi/frontoffice/complainttablelist",xu="api/branchapi/frontoffice/complainttypedropdown",bu="api/branchapi/frontoffice/addcomplaint",ju="api/branchapi/frontoffice/editcomplaint",Su="api/branchapi/frontoffice/deletecomplaint",vu=[{key:"all",label:"All Complaints"},{key:"pending",label:"Pending"},{key:"resolved",label:"Resolved"}];function wu({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c,g]=i.useState(""),[f,u]=i.useState("all"),p=i.useRef(null),w=(O,M)=>{s({page:O,rowsPerPage:Number.parseInt(M,10)})},v=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],y=i.useMemo(()=>{const O=ia.includes("?")?ia.endsWith("?")||ia.endsWith("&")?"":"&":"?",M=new URLSearchParams;return M.set("page",String(a.page)),M.set("per_page",String(a.rowsPerPage)),f!=="all"&&M.set("status",f),`${ia}${O}${M.toString()}`},[ia,a.page,a.rowsPerPage,f]),{isLoading:m,error:x,data:T,mutate:D}=G(t?[y,t]:null,([O,M])=>J(O,M)),{isLoading:k,data:C}=G(t?[xu,t]:null,([O,M])=>J(O,M)),j=i.useMemo(()=>{const O=C?.data??C??[];return Array.isArray(O)?O:Array.isArray(O?.data)?O.data:[]},[C]),h=async(O,M)=>{try{await D(Ne(O,M,t),We(M)),_.success("Success! Added new item.")}catch{_.error("Failed to add the new item.")}},S=async O=>{try{await D(Ve(Su,O,t),qe(O)),_.success("Success! Deleted item.")}catch{_.error("Failed to delete the item.")}},A=async(O,M,$)=>{try{const F=await Qe(O,M,t);D(F),Array.isArray(F?.data)&&D(`${ia.replace(/\?.*$/,"")}?id=${$}`,F),_.success("Success! Updated item.")}catch{_.error("Failed to update the item.")}},R=async(O,M)=>{O.preventDefault();const $=new FormData(O.target);await A(ju,$,M),O.target.reset(),d(""),o(!1)},q=async O=>{if(O.preventDefault(),!O.target?.date?.value)_.error("Select required dates"),O.target?.date?.focus(),g("textDanger");else{const M=new FormData(O.target);await h(bu,M),O.target.reset(),g(""),d("")}},U=O=>{o(O)},b=i.useMemo(()=>[{id:"1",name:"Complain Type",selector:"complaint_type",sortable:!0},{id:"2",name:"Name",selector:"name",sortable:!0},{id:"3",name:"Phone",selector:"contact",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Action Taken",selector:"action_taken",sortable:!0},{id:"6",name:"Assigned",selector:"assigned",sortable:!0}],[]);return e.jsxs(E,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Complaint"})}),e.jsx(E,{p:3,children:e.jsx("form",{onSubmit:q,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Z,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Complain Type",name:"complain_type",required:!0,allowSelectAll:!1})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"complain_by_name",type:"text",label:"Complain By *",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{3}[0-9]{3}[0-9]{4}"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Ue,{format:"YYYY-MM-DD",defaultValue:ae(),Desplay:"Complain Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>g("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"description",type:"text",label:"Description"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"action_token",type:"text",label:"Action Taken"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"assigned",type:"text",label:"Assigned"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx("input",{type:"hidden",name:"file",value:l||"",readOnly:!0})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(E,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Complaint List"})}),e.jsxs(E,{pt:3,children:[e.jsx(n.Tabs,{activeKey:f,onChange:u,items:vu}),e.jsx(jt,{data:{tableRef:p}}),e.jsx(Me,{parentCallback:w,data:{newData:T,columns:b,action:!0,ActionView:v,Loading:m,error:x,editDesign:e.jsx(gu,{data:{handleUpdate:R,token:t}}),deleteTodoMutation:S,open:r,DrawerUpdate:U,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const Wn="api/branchapi/Frontoffice/purposetablelist",$o="api/branchapi/Frontoffice/complaint_typetablelist",Uo="api/branchapi/Frontoffice/sourcetablelist",No="api/branchapi/Frontoffice/referencetablelist",pa=[{key:"purpose",label:"Purpose"},{key:"complainType",label:"Complain Type"},{key:"source",label:"Source"},{key:"reference",label:"Reference"}],Kr={purpose:[{id:"1",name:"Purpose",selector:"visitors_purpose",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],complainType:[{id:"1",name:"Complaint Type",selector:"complaint_type",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],source:[{id:"1",name:"Source",selector:"source",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],reference:[{id:"1",name:"Reference",selector:"reference",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}]};function _u({token:t}){const[a,s]=i.useState("purpose"),[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),c=i.useRef(null),g=(R,q)=>{o({page:R,rowsPerPage:Number.parseInt(q,10)})},f=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],u=()=>{switch(a){case"purpose":return Wn;case"complainType":return $o;case"source":return Uo;case"reference":return No;default:return Wn}},p=()=>{switch(a){case"purpose":return"api/branchapi/frontoffice/addvisitors_purpose";case"complainType":return"api/branchapi/frontoffice/addcomplaint_type";case"source":return"api/branchapi/frontoffice/addsource";case"reference":return"api/branchapi/frontoffice/addreference";default:return"api/branchapi/frontoffice/addvisitors_purpose"}},w=R=>{switch(a){case"purpose":return{url:"api/branchapi/frontoffice/deleteVisitorsPurpose",id:R};case"complainType":return{url:"api/branchapi/frontoffice/deletecomplaint_type",id:R};case"source":return{url:"api/branchapi/frontoffice/deletesource",id:R};case"reference":return{url:"api/branchapi/frontoffice/deletereference",id:R};default:return{url:"api/branchapi/frontoffice/deleteVisitorsPurpose",id:R}}},v=i.useMemo(()=>{const R=u(),q=R.includes("?")?R.endsWith("?")||R.endsWith("&")?"":"&":"?";return`${R}${q}page=${r.page}&per_page=${r.rowsPerPage}`},[a,r.page,r.rowsPerPage]),{isLoading:y,error:m,data:x,mutate:T}=G(t?[v,t]:null,([R,q])=>J(R,q)),D=async(R,q)=>{try{await T(Ne(R,q,t),We(q)),_.success("Success! Added new item.")}catch{_.error("Failed to add the new item.")}},k=async R=>{const{url:q,id:U}=w(R);try{await T(Ve(q,U,t),qe(U)),_.success("Success! Deleted item.")}catch{_.error("Failed to delete the item.")}},C=async(R,q,U)=>{try{const b=await Qe(R,q,t);T(b),Array.isArray(b?.data)&&T(`${u().replace(/\?.*$/,"")}?id=${U}`,b),_.success("Success! Updated item.")}catch{_.error("Failed to update the item.")}},j=async(R,q)=>{R.preventDefault();const U=new FormData(R.target),b=p();await C(b,U,q),R.target.reset(),d(!1)},h=async R=>{R.preventDefault();const q=new FormData(R.target),U=p();await D(U,q),R.target.reset()},S=R=>{d(R)},A=i.useMemo(()=>Kr[a]||Kr.purpose,[a]);return e.jsx(E,{pt:5,pb:1,children:e.jsx(n.Row,{gutter:[16,16],children:e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Setup Front Office"})}),e.jsxs(E,{p:3,children:[e.jsx(n.Tabs,{activeKey:a,onChange:R=>{s(R),o({page:1,rowsPerPage:10})},items:pa}),e.jsxs(n.Row,{gutter:[16,16],mt:3,children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx("form",{onSubmit:h,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:["Add ",pa.find(R=>R.key===a)?.label]})}),e.jsx(E,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsx(E,{children:e.jsx(Y,{required:!0,name:"name",type:"text",label:pa.find(R=>R.key===a)?.label+" *"})})}),e.jsx(n.Col,{xs:24,children:e.jsx(E,{children:e.jsx(Y,{name:"description",type:"text",label:"Description"})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(E,{children:e.jsx(ie,{type:"submit",value:"Add",color:"primary"})})})})]})})]})})}),e.jsx(n.Col,{xs:24,md:16,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:[pa.find(R=>R.key===a)?.label," List"]})}),e.jsxs(E,{pt:3,children:[e.jsx(jt,{data:{tableRef:c}}),e.jsx(Me,{parentCallback:g,data:{newData:x,columns:A,action:!0,ActionView:f,Loading:y,error:m,editDesign:e.jsx(Cu,{data:{handleUpdate:j,token:t,activeTab:a}}),deleteTodoMutation:k,open:l,DrawerUpdate:S,viewDetails:""}})]})]})})]})]})]})})})})}function Cu({data:t}){const{handleUpdate:a,token:s,activeTab:r}=t||{},o=i.useContext(Qt),d=(v=>{switch(v){case"purpose":return Wn;case"complainType":return $o;case"source":return Uo;case"reference":return No;default:return Wn}})(r).replace(/\?.*$/,""),{isLoading:c,data:g}=G(s&&o?[d,o,s]:null,([v,y,m])=>getDataById(v,{id:y},m)),f=g?.data?.[0],[u,p]=i.useState({name:"",description:""});i.useEffect(()=>{f&&p({name:f?.visitors_purpose||f?.complaint_type||f?.source||f?.reference||"",description:f?.description||""})},[f]);const w=(v,y)=>{p(m=>({...m,[v]:y}))};return c?e.jsx(E,{pt:4,pb:1,style:{width:350},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(E,{pt:4,pb:1,style:{width:350},children:[e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:["Edit ",pa.find(v=>v.key===r)?.label]})}),e.jsx(E,{p:3,children:e.jsx("form",{onSubmit:v=>a(v,o),children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsx(E,{children:e.jsx(Y,{type:"text",value:o,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,children:e.jsx(E,{children:e.jsx(Y,{name:"name",type:"text",label:pa.find(v=>v.key===r)?.label+" *",required:!0,value:u.name,onChange:v=>w("name",v.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(E,{children:e.jsx(Y,{name:"description",type:"text",label:"Description",value:u.description,onChange:v=>w("description",v.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(E,{children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})})})]})})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const Au="api/branchapi/Student/studentGatePass",Ta="api/branchapi/Student/studentGatePassList";function Tu({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:25}),[r,o]=i.useState(!1),l=i.useRef(null),d=(k,C)=>{s({page:k,rowsPerPage:Number.parseInt(C,10)})},c=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],{data:g,mutate:f}=G(t?[Au,t]:null,([k,C])=>J(k,C)),u=i.useMemo(()=>{const k=Ta.includes("?")?Ta.endsWith("?")||Ta.endsWith("&")?"":"&":"?";return`${Ta}${k}page=${a.page}&per_page=${a.rowsPerPage}`},[Ta,a.page,a.rowsPerPage]),{isLoading:p,error:w,data:v,mutate:y}=G(t?[u,t]:null,([k,C])=>J(k,C)),m=async k=>{const C="api/branchapi/frontoffice/deletevisitors";try{await y(deleteData(C,k,t),qe(k)),_.success("Success! Deleted item.")}catch{_.error("Failed to delete the item.")}},x=k=>{o(k)},T=()=>{},D=[{title:"Name",dataIndex:"lastname",key:"lastname",render:(k,C)=>`${C?.lastname||""} ${C?.firstname||""}`.trim()},{title:"Class",dataIndex:"class_name",key:"class_name",render:(k,C)=>`${C?.class_name||""}-${C?.section_name||""}`},{title:"Father Name",dataIndex:"father_name",key:"father_name"},{title:"Authorized Persons",dataIndex:"authorized_persons_fullname",key:"authorized_persons_fullname"},{title:"Relation",dataIndex:"authorized_persons_relation",key:"authorized_persons_relation"},{title:"Generated Date",dataIndex:"genrated_date_time",key:"genrated_date_time"},{title:"Return Date",dataIndex:"expected_return_date_time",key:"expected_return_date_time"},{title:"Reason",dataIndex:"reason",key:"reason"},{title:"Action",key:"action",render:(k,C)=>e.jsx(n.Tag,{color:C?.status==="Generated"?"green":"blue",children:C?.status||"Pending"})},{title:"Print",key:"print",render:(k,C)=>e.jsx(ee.PrinterOutlined,{style:{color:"#3892ee",cursor:"pointer"},onClick:()=>window.print()})}];return e.jsx(E,{pt:5,pb:1,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Today Gate Pass"})}),e.jsx(E,{pt:3,children:e.jsx(n.List,{grid:{column:4,gutter:16},dataSource:g?.data||[],style:{padding:0},renderItem:k=>e.jsx(n.List.Item,{style:{padding:0},children:e.jsx(n.Card,{size:"small",style:{marginBottom:8,width:"100%"},children:e.jsxs(E,{children:[e.jsxs(n.Typography.Text,{strong:!0,children:[k?.lastname," ",k?.firstname]}),e.jsx("br",{}),e.jsxs(n.Typography.Text,{type:"secondary",children:[k?.class_name,"-",k?.section_name]}),e.jsx("br",{}),e.jsxs(n.Typography.Text,{type:"secondary",children:["Return: ",k?.expected_return_date_time]}),e.jsx("br",{}),e.jsx(ie,{type:"button",value:"Print",color:"primary",size:"small",onClick:()=>window.print(),style:{marginTop:4}})]})})})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Gate Pass List"})}),e.jsxs(E,{pt:3,children:[e.jsx(jt,{data:{tableRef:l}}),e.jsx(Me,{parentCallback:d,data:{newData:v,columns:D,action:!1,ActionView:c,Loading:p,error:w,editDesign:"",deleteTodoMutation:m,open:r,DrawerUpdate:x,viewDetails:T}})]})]})})]})})}const ut=({id:t,funcName:a,disabled:s=!1})=>{const r="Data",[o,l]=i.useState(!1),d=()=>{l(!0),a(t),n.message.success(`${r} deleted successfully!`)},c=()=>{n.message.info(`Deletion of ${r} cancelled`)};return e.jsx(n.Popconfirm,{title:`Delete ${r}?`,description:`Are you sure you want to delete ${r}?`,onConfirm:d,onCancel:c,okText:"Yes",cancelText:"No",disabled:s||o,children:e.jsx(n.Button,{danger:!0,disabled:s,loading:o,icon:e.jsx(ee.DeleteOutlined,{}),size:"small"})})},Gr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Du({token:t,sampleTemplateUrl:a=rc}){const[s,r]=i.useState({pagination:{current:1,pageSize:10}}),[o,l]=i.useState(!1),[d,c]=i.useState(null),[g,f]=i.useState(null),[u,p]=i.useState(!1),[w,v]=i.useState([]),y=`api/branchapi/Transport/routeTableList?page=${s.pagination.current}&per_page=${s.pagination.pageSize}`,m="api/branchapi/Transport/addroute",x="api/branchapi/Transport/editroute",T="api/branchapi/Transport/deleteroute",D=void 0,{isLoading:k,data:C,error:j,mutate:h}=G(t?[y,t]:null,([z,P])=>J(z,P)),S=i.useMemo(()=>!C?.data||Array.isArray(C.data)?[]:C.data?.rows||[],[C]),A=C?.data?.pagination?.total_rows||C?.pagination?.total_rows||0,R=async(z,P)=>{try{await h(Ne(z,P,t),We(P)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},q=z=>{z.preventDefault();const P=new FormData(z.target);R(m,P),z.target.reset()},U=(z,P)=>{r(I=>({...I,pagination:{current:z,pageSize:parseInt(P,10)}}))},b=async z=>{try{await h(Ve(T,z,t),qe(z)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},O=z=>{c(z),l(!0)},M=async z=>{try{const P=await Qe(x,z,t);h(P),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),l(!1),c(null)}catch{_.error("Failed to update the item.",{duration:1e3})}},$=async z=>{z.preventDefault();const P=new FormData(z.target);P.append("id",d?.id),M(P)},F=async()=>{if(!g){_.error("Please select an Excel file to upload.",{duration:1e3});return}p(!0),v([]);try{const z=new FormData;z.append("file",g);const I=await(await fetch(`${D}`,{method:"POST",headers:{Authorization:t},body:z})).json();if(I.Status==="Success"){const B=I.data?.rows||[];v(B);const L=I.data?.success_count||0,H=I.data?.failed_count||0;_.success(I.message||`Route bulk upload completed. ${L} succeeded, ${H} failed.`,{duration:1e3}),L>0&&h()}else _.error(I.message||"Failed to upload routes.",{duration:1e3})}catch(z){_.error(z?.message||"Something went wrong.",{duration:1e3})}finally{p(!1),f(null)}},N=[{title:"Route Title",dataIndex:"route_title",key:"route_title",sorter:{compare:(z,P)=>(z.route_title||"").localeCompare(P.route_title||"")}},{title:"Fare (Monthly)",dataIndex:"fare",key:"fare",sorter:{compare:(z,P)=>Number(z.fare||0)-Number(P.fare||0)}},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(z,P)=>(z.note||"").localeCompare(P.note||"")}},{title:"Action",key:"action",render:(z,P)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>O(P),style:{padding:2}}),e.jsx(ut,{id:P?.id,funcName:b})]})}],V=d?.route_title?`Edit ${d.route_title}`:"Edit Route";return e.jsxs(E,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(De,{level:5,style:{margin:0,color:"#fff"},children:"Bulk Upload Routes"})}),e.jsxs(E,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(n.Upload,{accept:".xlsx",showUploadList:!1,beforeUpload:z=>(f(z),!1),children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),disabled:u,children:g?g.name:"Choose Excel File (.xlsx)"})})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(n.Button,{type:"primary",onClick:F,disabled:u||!g,loading:u,children:u?"Uploading...":"Upload Routes"})})})]}),w.length>0&&e.jsxs(E,{mt:3,children:[e.jsx(De,{level:5,children:"Upload Results"}),e.jsx(n.Table,{dataSource:w.map((z,P)=>({...z,key:P})),pagination:!1,size:"small",bordered:!0,columns:[{title:"Row",dataIndex:"row",width:80},{title:"Title",dataIndex:"title"},{title:"Status",dataIndex:"status",render:z=>e.jsx("span",{style:{color:z==="Success"?"green":"red",fontWeight:500},children:z})},{title:"Message",dataIndex:"message"}]})]}),a&&e.jsx(E,{mt:2,children:e.jsx("a",{href:a,download:!0,style:{color:"#5080f8",fontSize:13,textDecoration:"none"},children:"Download sample Excel template"})})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(De,{level:5,style:{margin:0,color:"#fff"},children:"Add Route"})}),e.jsx(E,{p:3,children:e.jsx("form",{onSubmit:q,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx(E,{children:e.jsx(Y,{type:"text",name:"title",label:"Title",placeholder:"Mumbai to Delhi",required:"required"})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(E,{children:e.jsx(Y,{type:"number",name:"fare",label:"Fare (Monthly)",required:"required"})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(E,{children:e.jsx(Y,{type:"text",name:"note",label:"Note"})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(E,{children:[e.jsx(ie,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",style:Gr,children:"Cancel"})]})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(De,{level:5,style:{margin:0,color:"#fff"},children:"Route List"})}),e.jsx(E,{p:3,children:e.jsx(Me,{parentCallback:U,data:{newData:{data:S,pagination:{total_rows:A}},columns:N,columnstype:"antd",action:!1,Loading:k,error:j,deleteTodoMutation:b}})})]})})]}),e.jsx(n.Drawer,{open:o,title:V,placement:"right",width:420,onClose:()=>{l(!1),c(null)},children:e.jsx("form",{onSubmit:$,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"title",label:"Title",defaultValue:d?.route_title||"",required:"required"}),e.jsx(Y,{type:"number",name:"fare",label:"Fare (Monthly)",defaultValue:d?.fare||"",required:"required"}),e.jsx(Y,{type:"text",name:"note",label:"Note",defaultValue:d?.note||""}),e.jsx("div",{style:{display:"none"},children:e.jsx(Y,{type:"text",name:"no_of_vehicle",label:"Note"})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{l(!1),c(null)},style:Gr,children:"Cancel"})]})]})})})]})}const Jr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Ru({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),c=`api/branchapi/Transport/vehiclesTableList?page=${a.page}&per_page=${a.rowsPerPage}`,g="api/branchapi/Transport/addvehicles",f="api/branchapi/Transport/editvehicle",u="api/branchapi/Transport/deletevehicle",{isLoading:p,data:w,error:v,mutate:y}=G(t?[c,t]:null,([A,R])=>J(A,R)),m=async(A,R)=>{try{await y(Ne(A,R,t),We(R)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},x=A=>{A.preventDefault();const R=new FormData(A.target);m(g,R),A.target.reset()},T=async A=>{try{await y(Ve(u,A,t),qe(A)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},D=A=>{d(A),o(!0)},k=async A=>{try{await Qe(f,A,t),await y(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch{_.error("Failed to update the item.",{duration:1e3})}},C=async A=>{A.preventDefault();const R=new FormData(A.target);R.append("id",l?.id),k(R)},j=(A,R)=>{s({page:A,rowsPerPage:parseInt(R,10)})},h=[{title:"Vehicle Number",dataIndex:"vehicle_no",key:"vehicle_no",sorter:{compare:(A,R)=>A.vehicle_no.localeCompare(R.vehicle_no)}},{title:"Vehicle Model",dataIndex:"vehicle_model",key:"vehicle_model",sorter:{compare:(A,R)=>A.vehicle_model.localeCompare(R.vehicle_model)}},{title:"Max Seating Capacity",dataIndex:"seating_capacity",key:"seating_capacity",sorter:{compare:(A,R)=>A.seating_capacity-R.seating_capacity}},{title:"Manufacture Year",dataIndex:"manufacture_year",key:"manufacture_year",sorter:{compare:(A,R)=>A.manufacture_year-R.manufacture_year}},{title:"Gps Url",key:"gps_url",sorter:{compare:(A,R)=>A.gps_url.localeCompare(R.gps_url)},render:(A,R)=>e.jsx("span",{title:R?.gps_url??"",style:{display:"inline-block",maxWidth:220,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:R?.gps_url})},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(A,R)=>A.note.localeCompare(R.note)}},{title:"Action",key:"action",render:(A,R)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>D(R),style:{padding:2}}),e.jsx(ut,{id:R?.id,funcName:T})]})}],S=l?.vehicle_no?`Edit ${l.vehicle_no}`:"Edit Vehicle";return e.jsxs("div",{children:[e.jsx(n.Drawer,{open:r,title:S,placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:C,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"number",label:"Vehicle Number",defaultValue:l?.vehicle_no||"",required:"required"}),e.jsx(Y,{type:"text",name:"model",label:"Vehicle Model",defaultValue:l?.vehicle_model||""}),e.jsx(Y,{type:"number",name:"manufacture_year",label:"Manufacture Year",defaultValue:l?.manufacture_year||""}),e.jsx(Y,{type:"number",name:"seating_capacity",label:"Max Seating Capacity",defaultValue:l?.seating_capacity||""}),e.jsx(Y,{type:"text",name:"gps_url",label:"Gps Url",defaultValue:l?.gps_url||""}),e.jsx(Y,{type:"text",name:"note",label:"Note",defaultValue:l?.note||""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Jr,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(E,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Add Vehicle"})}),e.jsx(E,{px:3,pb:2,children:e.jsx("form",{onSubmit:x,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"number",label:"Vehicle Number",required:"required"}),e.jsx(Y,{type:"text",name:"model",label:"Vehicle Model"}),e.jsx(Y,{type:"number",name:"manufacture_year",label:"Manufacture Year"}),e.jsx(Y,{type:"number",name:"seating_capacity",label:"Max Seating Capacity"}),e.jsx(Y,{type:"text",name:"gps_url",label:"Gps Url"}),e.jsx(Y,{type:"text",name:"note",label:"Note"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",style:Jr,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(E,{children:e.jsx(Me,{parentCallback:j,data:{newData:w,columns:h,columnstype:"antd",action:!1,Loading:p,error:v,deleteTodoMutation:T}})})]})})]})})]})}const Iu={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Qr=({dataIndex:t,title:a,record:s,children:r,isEditable:o,...l})=>e.jsx("td",{...l,children:o?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:r}):r});function ku({token:t}){const[a,s]=i.useState(!1),[r,o]=i.useState({pagination:{current:1,pageSize:50}}),[l,d]=i.useState(null),[c,g]=i.useState([]),f="api/branchapi/Transport/getrouteDropdown",u="api/branchapi/Transport/getvehicleDropdown",p="api/branchapi/Transport/getchechkedVehicleData",w="api/branchapi/Transport/assignedVehicleTable",v="api/branchapi/transport/assignvehicle",y="api/branchapi/Transport/deleteassignvehicle",m=l?`${p}?route_id=${l}`:null,{isLoading:x,data:T,mutate:D}=G(t?[`${w}?page=${r.pagination.current}&per_page=${r.pagination.pageSize}`,t]:null,([I,B])=>J(I,B)),{data:k}=G(t&&f?[f,t]:null,([I,B])=>J(I,B)),{data:C}=G(t&&u?[u,t]:null,([I,B])=>J(I,B)),j=t&&m?[m,t]:null,{isLoading:h,data:S}=G(j,([I,B])=>J(I,B)),{Status:A="Failed",pagination:{total_rows:R=0}={}}=T||{},{data:q=[]}=A==="Success"?T:{},U=i.useMemo(()=>{const I=k?.data??k??[];return Array.isArray(I)?I:[]},[k]),b=i.useMemo(()=>{const I=C?.data??C??[];return(Array.isArray(I)?I:[]).map(L=>{if(L==null)return null;if(typeof L=="string"||typeof L=="number")return{label:String(L),value:L};const H=L.value??L.vehicle_id??L.id??L.vehicleID,se=L.label??L.vehicle_name??L.vehicle_no??L.vehicle_number??L.name??String(H??"");return H==null||se===""?null:{label:String(se),value:H}}).filter(Boolean)},[C]),O=i.useMemo(()=>{const I=S?.data??S??[];return(Array.isArray(I)?I:[]).map(L=>L?.value??L?.vehicle_id??L?.id??L).filter(L=>L!=null)},[S]);i.useEffect(()=>{g(O)},[O,a]);const M=async(I,B,L)=>{try{await D(Ne(I,B,t),We(B)),m&&G.mutate(j),s(H=>!H),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(H){_.error(H?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},$=I=>{I.preventDefault();const B=new FormData;B.append("route_id",l??""),c.length?c.forEach(L=>B.append("vehicle_ids[]",L)):B.append("vehicle_ids[]",""),M(v,B)},F=I=>{o(B=>({...B,pagination:{current:I,pageSize:B.pagination.pageSize}}))},N=async I=>{try{await D(Ve(y,I,t),qe(I)),m&&G.mutate(j),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},V=[{title:"Route",dataIndex:"route_title"},{title:"Vehicle Numbers",render:(I,B,L)=>e.jsx(e.Fragment,{children:B.children.map((H,se,W)=>e.jsx("span",{children:`${H.vehicle_name} ${se+1===W.length?"":","}`},`${se}vehicle001`))})},{title:"Action",render:(I,B,L)=>e.jsx(e.Fragment,{children:e.jsx(ut,{id:B?.route_id,funcName:N})})}],z=I=>{const B=["route_id","index"];for(let L=0;L<B.length;L++)if(I[B[L]])return I[B[L]]},P=I=>{const{children:B=[]}=I||{},L=[{title:"Vehicle Name",dataIndex:"vehicle_name",onCell:H=>({isEditable:!0})},{title:"Driver Name",dataIndex:"driver_name",onCell:H=>({isEditable:!0})},{title:"Driver Contact",dataIndex:"driver_contact_number",onCell:H=>({isEditable:!0})},{title:"Driver Licence",dataIndex:"Driver_licence",onCell:H=>({isEditable:!0})},{title:"Start Time",dataIndex:"start_time",onCell:H=>({isEditable:!0})},{title:"Drop Time",dataIndex:"drop_time",onCell:H=>({isEditable:!0})},{title:"Type",dataIndex:"type",onCell:H=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(n.Table,{components:{body:{cell:Qr}},expandable:{childrenColumnName:"changed"},bordered:!0,size:"small",columns:L,rowKey:H=>z(H)+"cell01",dataSource:B,pagination:!1})})})};return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(E,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Assign Vehicle"})}),e.jsx(E,{px:3,pb:2,children:e.jsx("form",{onSubmit:$,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(220px, 320px) 1fr auto",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(Z,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,onChange:I=>{d(I?.value??null),s(B=>!B)}})}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:{display:"block",marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Vehicles"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:8,maxHeight:140,overflow:"auto"},children:e.jsx(n.Checkbox.Group,{style:{display:"flex",flexWrap:"wrap",gap:12},options:b,value:c,onChange:I=>g(I),disabled:!l||h})},`check001${a}`)]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"button",onClick:()=>{d(null),g([]),s(I=>!I)},style:Iu,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(E,{style:{padding:"10px 16px"},children:e.jsx(n.Table,{components:{body:{cell:Qr}},columns:V,bordered:!0,rowKey:I=>z(I),dataSource:Array.isArray(q)?q:[],loading:x,expandable:{expandedRowRender:P,childrenColumnName:"changed"},pagination:{current:r.pagination.current,pageSize:r.pagination.pageSize,total:R,showSizeChanger:!0,onChange:F,onShowSizeChange:(I,B)=>{o(L=>({...L,pagination:{current:1,pageSize:B}}))},showTotal:(I,B)=>`${B[0]}-${B[1]} of ${I} items`}})})]})})]})})]})}const Xr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},vs=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},oa=(t,a,s)=>{if(a==null||a==="")return null;const r=t.find(o=>String(o.value)===String(a));return r||(s?{label:String(s),value:a}:{label:String(a),value:a})},Pu=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},Ou=t=>{if(t==null||t===""||t==="null"||t==="undefined")return"";if(Array.isArray(t))return t.filter(s=>s!=null&&s!==""&&String(s).toLowerCase()!=="null"&&String(s).toLowerCase()!=="undefined").join(", ");const a=String(t).trim();return!a||a.toLowerCase()==="null"||a.toLowerCase()==="undefined"?"":a};function Mu({token:t,assignmentId:a,studentName:s,onClose:r,onSuccess:o}){const l="api/branchapi/Transport/showRouteAssignStudent",d="api/branchapi/Transport/updateTransportRoutesStudent",c="api/branchapi/Transport/getrouteDropdown",g="api/branchapi/Transport/getvehicleListByRouteIdwithCount",f="api/branchapi/Transport/getStoppageDropdown",u="api/branchapi/Transport/routeShowdata",[p,w]=i.useState(null),[v,y]=i.useState(null),[m,x]=i.useState(null),[T,D]=i.useState(ae()),[k,C]=i.useState(""),[j,h]=i.useState(0),[S,A]=i.useState(0),{data:R,isLoading:q}=G(t&&a?[`${l}?id=${a}`,t]:null,([Q,ce])=>J(Q,ce)),U=i.useMemo(()=>{if(!R||R?.Status&&R.Status!=="Success")return null;const Q=R?.data??R;return Array.isArray(Q)?Q[0]??null:Q},[R]);i.useEffect(()=>{const Q=U?.fk_route_id??U?.route_id;Q!=null&&w(Q),U?.vehicle_id!=null&&y(U.vehicle_id),U?.stop_id!=null&&x(U.stop_id),D(U?.start_date?ae(U.start_date):ae()),C(Ou(U?.service_push))},[U]);const b=t&&p?`${g}?route_id=${p}`:null,O=t&&p?`${u}?id=${p}`:null,M=t&&p?`${f}?route_id=${p}`:null,{data:$}=G(t&&c?[c,t]:null,([Q,ce])=>J(Q,ce)),{data:F,isLoading:N}=G(b?[b,t]:null,([Q,ce])=>J(Q,ce)),{data:V,isLoading:z}=G(M?[M,t]:null,([Q,ce])=>J(Q,ce)),{data:P}=G(O?[O,t]:null,([Q,ce])=>J(Q,ce)),I=i.useMemo(()=>vs($),[$]),B=i.useMemo(()=>vs(F),[F]),L=i.useMemo(()=>vs(V),[V]),H=R?.data[0]?.rootCost,se=Pu(),W=s||[U?.firstname,U?.lastname].filter(Boolean).join(" ")||"",K=(Q,ce)=>{switch(ce){case"route_id":w(Q?.value??null),y(null),x(null),h(Te=>Te+1),A(Te=>Te+1);break;case"vehicle_id":y(Q?.value??null),x(null),A(Te=>Te+1);break;case"stop_id":x(Q?.value??null);break}},te=async Q=>{if(Q.preventDefault(),!p||!v||!m){_.error("Please select Route, Vehicle and Stop",{duration:1200});return}const ce=new FormData;ce.append("id",String(a)),ce.append("student_id",String(U?.fk_student_id??U?.student_id??"")),ce.append("fk_route_id",String(p)),ce.append("vehicle_id",String(v)),ce.append("stop_id",String(m)),ce.append("rootCost",String(H??"")),ce.append("start_date",T?.isValid?.()?T.format("YYYY-MM-DD"):ae().format("YYYY-MM-DD")),ce.append("puse_service",String(k??""));try{await Qe(d,ce,t),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o?.(),r?.()}catch(Te){_.error(Te?.message??"Failed to update the item.",{duration:1e3})}};if(q||!(U&&!q&&(!p||!N&&!z)))return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:48},children:e.jsx(n.Spin,{})});if(!U)return e.jsxs("div",{style:{padding:"8px 0"},children:[e.jsx("p",{style:{color:"#666",fontSize:14,marginBottom:16},children:"Unable to load assignment details. Please try again."}),e.jsx(n.Button,{type:"text",onClick:r,style:Xr,children:"Close"})]});const pe=U.fk_route_id??U.route_id,we=oa(I,pe,U.route_title),le=oa(B,U.vehicle_id,U.vehicle_name??U.vehicle_no),de=oa(L,U.stop_id,U.stop_name??U.stoppage_name);return e.jsx("form",{onSubmit:te,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"title",label:"Student",defaultValue:W,readOnly:!0}),e.jsx("input",{type:"hidden",name:"student_id",value:U.fk_student_id??U.student_id??""}),e.jsx(Z,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:oa(I,p,we?.label)??null,onChange:Q=>K(Q,"route_id")}),e.jsx(Z,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:oa(B,v,le?.label)??null,onChange:Q=>K(Q,"vehicle_id")},`edit-vehicle-${j}`),e.jsx(Z,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:oa(L,m,de?.label)??null,onChange:Q=>K(Q,"stop_id")},`edit-stop-${S}`),e.jsx(Y,{type:"text",label:"Route Cost",value:H!=null?`${se}${H}`:"",readOnly:!0}),e.jsx("input",{type:"hidden",name:"rootCost",value:H??""}),e.jsx(Ue,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",allowClear:!1,value:T,onChange:Q=>D(Q)}),e.jsx(Y,{type:"text",label:"Pause Service",value:k,onChange:Q=>C(Q?.target?.value??""),placeholder:"e.g. 01, 02, 03"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginTop:4},children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:r,style:Xr,children:"Cancel"})]})]})},`edit-${a}-${j}`)}const Zr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Eu=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},Da=t=>Eu(t),Fu=t=>t||"",$u=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},Uu=t=>{const a=String(t??"Drawer").trim().toLowerCase().replace(/\s+/g,"");return a==="page"||a==="sendpage"?"page":"drawer"},Nu=(t,a)=>{const s=a||"/TransportDashboard/EditAssignStudentTransport?id={id}",r=t?.id??"",o=encodeURIComponent(String(r));if(s.includes("{id}"))return s.replaceAll("{id}",o);if(s.includes(":id"))return s.replace(":id",o);try{const d=new URL(s,"http://localhost");if(d.searchParams.has("id"))return d.searchParams.set("id",String(r)),`${d.pathname}${d.search}${d.hash}`}catch{}const l=s.includes("?")?"&":"?";return`${s}${l}id=${o}`};function Bu({token:t,editType:a,onNavigate:s,editPagePath:r,sampleTemplateUrl:o=ic}){const d=Uu(a)==="drawer",c="api/branchapi/academy/classdropdownlist",g="api/branchapi/academy/sectionoftheClass",f="api/branchapi/Transport/routeStudentList",u="api/branchapi/Transport/getrouteDropdown",p="api/branchapi/Transport/getvehicleListByRouteIdwithCount",w="api/branchapi/Transport/getStoppageDropdown",v="api/branchapi/Transport/routeShowdata",y="api/branchapi/Transport/assignTransportRoutesStudent",m="api/branchapi/transport/removeStudentTransport",x="api/branchapi/transport/assignTransportRoutesStudentBulk",[T,D]=i.useState(null),[k,C]=i.useState(!1),[j,h]=i.useState(!1),[S,A]=i.useState(null),[R,q]=i.useState(null),[U,b]=i.useState(null),[O,M]=i.useState(null),[$,F]=i.useState(!1),[N,V]=i.useState(!1),[z,P]=i.useState({page:1,rowsPerPage:50}),[I,B]=i.useState(null),[L,H]=i.useState(!1),[se,W]=i.useState(null),[K,te]=i.useState(null),[oe,pe]=i.useState(null),[we,le]=i.useState(null),[de,Q]=i.useState(null),[ce,Te]=i.useState(null),[Ee,Ie]=i.useState(null),[Le,$e]=i.useState(ae()),[et,He]=i.useState(""),[Oe,Ke]=i.useState(null),[nt,he]=i.useState(!1),[je,be]=i.useState([]),ne=(xe,_e)=>{const Je=xe?.value??null;switch(_e){case"class_id":pe(Je),le(null),B(Je?`${g}?class_id=${encodeURIComponent(String(Je))}`:null),C(Rt=>!Rt);break;case"route_id":Q(Je),Te(null),Ie(null),te(Je),q(Je?`${p}?route_id=${encodeURIComponent(String(Je))}`:null),b(Je?`${v}?id=${encodeURIComponent(String(Je))}`:null),M(null),F(Rt=>!Rt),V(Rt=>!Rt);break;case"vehicle_id":Te(Je),Ie(null),M(de?`${w}?route_id=${encodeURIComponent(String(de))}`:null),V(Rt=>!Rt);break;case"stop_id":Ie(Je);break}},me=xe=>{if(d){A(xe),h(!0);return}const _e=Nu(xe,r);if(typeof s=="function"){s(_e,xe);return}typeof window<"u"&&_e&&window.location.assign(_e)},ge=()=>{h(!1),A(null)},re=S?`Edit — ${S.firstname??""} ${S.lastname??""}`.trim():"Edit Student Transport",{data:ye}=G(t&&c?[c,t]:null,([xe,_e])=>J(xe,_e)),{data:Be}=G(t&&I?[I,t]:null,([xe,_e])=>J(xe,_e)),{data:St}=G(t&&R?[R,t]:null,([xe,_e])=>J(xe,_e)),{data:At}=G(t&&O?[O,t]:null,([xe,_e])=>J(xe,_e)),{data:yt}=G(t&&U?[U,t]:null,([xe,_e])=>J(xe,_e)),{data:Mt}=G(t&&u?[u,t]:null,([xe,_e])=>J(xe,_e)),Zt=t&&T?`${T}&page=${z.page}&per_page=${z.rowsPerPage}`:null,{isLoading:fe,error:ve,data:it,mutate:gt}=G(Zt?[Zt,t]:null,([xe,_e])=>J(xe,_e)),sn=i.useMemo(()=>Da(ye),[ye]),rn=i.useMemo(()=>Da(Be),[Be]),on=i.useMemo(()=>Da(St),[St]),ln=i.useMemo(()=>Da(At),[At]),dn=i.useMemo(()=>Da(Mt),[Mt]),ue=yt?.data?.[0]?.fare??yt?.data?.fare??yt?.fare??yt?.data?.data?.[0]?.fare??yt?.data?.data?.fare;i.useEffect(()=>{ue==null||ue===""||He(String(ue))},[ue]);const Se=async xe=>{try{await gt(Ve(m,xe,t),qe(xe)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},Fe=async()=>{if(!Oe){_.error("Please select an Excel file to upload.",{duration:1e3});return}he(!0),be([]);try{const xe=new FormData;xe.append("file",Oe);const Je=await(await fetch(`${x}`,{method:"POST",headers:{Authorization:t},body:xe})).json();if(Je.Status==="Success"){const Rt=Je.data?.rows||[];be(Rt);const ur=Je.data?.success_count||0,rl=Je.data?.failed_count||0;_.success(Je.message||`Transport bulk upload completed. ${ur} succeeded, ${rl} failed.`,{duration:1e3}),ur>0&>()}else _.error(Je.message||"Failed to upload student transport assignments.",{duration:1e3})}catch(xe){_.error(xe?.message||"Something went wrong.",{duration:1e3})}finally{he(!1),Ke(null)}},Ge=[{title:"Route Status",key:"route_status",render:(xe,_e)=>_e.fk_route_id?e.jsx("span",{children:_e.route_title}):e.jsx("span",{children:"Not Assigned"})},{title:"Vehicle Assign Date",dataIndex:"start_date",key:"start_date",render:(xe,_e)=>Fu(_e.start_date)},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Roll No",dataIndex:"roll_no",key:"roll_no"},{title:"Name",key:"name",render:(xe,_e)=>`${_e.firstname} ${_e.lastname}`},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Mobileno",dataIndex:"mobileno",key:"mobileno"},{title:"Action",key:"action",render:(xe,_e)=>e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:_e.fk_route_id?e.jsxs(e.Fragment,{children:[e.jsx(ut,{id:_e?.id,funcName:Se}),e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>me(_e),style:{padding:2}})]}):e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.PlusOutlined,{}),onClick:()=>ls(_e.student_id),style:{padding:2}})})}],st=async(xe,_e)=>{try{await gt(Ne(xe,_e,t),We(_e)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),H(!1),ds()}catch{_.error("Failed to add the new item.",{duration:1e3})}},pt=xe=>{if(xe.preventDefault(),!oe||!we){_.error("Please select Class and Section",{duration:1200});return}D(`${f}?cID=${encodeURIComponent(String(oe))}&sID=${encodeURIComponent(String(we))}`),P(_e=>({..._e,page:1}))},os=(xe,_e)=>{P({page:xe,rowsPerPage:parseInt(_e,10)})},ls=xe=>{W(xe),H(!0)},va=xe=>{if(xe.preventDefault(),!se){_.error("Student is required",{duration:1200});return}if(!de||!ce||!Ee){_.error("Please select Route, Vehicle and Stop",{duration:1300});return}const _e=new FormData;_e.append("student_id",String(se)),_e.append("fk_route_id",String(de)),_e.append("vehicle_id",String(ce)),_e.append("stop_id",String(Ee)),_e.append("start_date",Le?.isValid?.()?Le.format("YYYY-MM-DD"):ae().format("YYYY-MM-DD")),_e.append("rootCost",String(et??"")),st(y,_e)},ds=()=>{H(!1),q(null),b(null),M(null),te(null),Q(null),Te(null),Ie(null),$e(ae()),He(""),F(xe=>!xe),V(xe=>!xe)},sl=$u();return e.jsxs(E,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(De,{level:5,style:{margin:0,color:"#fff"},children:"Bulk Assign Students to Transport"})}),e.jsxs(E,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(n.Upload,{accept:".xlsx",showUploadList:!1,beforeUpload:xe=>(Ke(xe),!1),children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),disabled:nt,children:Oe?Oe.name:"Choose Excel File (.xlsx)"})})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(n.Button,{type:"primary",onClick:Fe,disabled:nt||!Oe,loading:nt,children:nt?"Uploading...":"Upload Students"})})})]}),o&&e.jsx(E,{mt:2,children:e.jsx("a",{href:o,download:!0,style:{color:"#5080f8",fontSize:13,textDecoration:"none"},children:"Download sample Excel template"})}),je.length>0&&e.jsxs(E,{mt:3,children:[e.jsx(De,{level:5,children:"Upload Results"}),e.jsx(n.Table,{dataSource:je.map((xe,_e)=>({...xe,key:_e})),pagination:!1,size:"small",bordered:!0,columns:[{title:"Row",dataIndex:"row",width:80},{title:"Student ID",dataIndex:"student_id"},{title:"Status",dataIndex:"status",render:xe=>e.jsx("span",{style:{color:xe==="Success"?"green":"red",fontWeight:500},children:xe})},{title:"Message",dataIndex:"message"}]})]})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(De,{level:5,style:{margin:0,color:"#fff"},children:"Search Students"})}),e.jsx(E,{p:3,children:e.jsx("form",{onSubmit:pt,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx(E,{children:e.jsx(Z,{options:sn,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",onChange:xe=>ne(xe,"class_id"),required:!0,allowSelectAll:!1,value:sn.find(xe=>String(xe.value)===String(oe))??null})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(E,{children:e.jsx(Z,{options:rn,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",allowSelectAll:!1,required:!0,value:rn.find(xe=>String(xe.value)===String(we))??null,onChange:xe=>le(xe?.value??null)},`section1${k}`)})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsxs(E,{display:"flex",alignItems:"center",height:"100%",mt:2,children:[e.jsx(ie,{type:"submit",value:"Search",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"button",onClick:()=>{D(null),B(null),pe(null),le(null),C(xe=>!xe)},style:Zr,children:"Cancel"})]})})]})})})]})}),T&&e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(De,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(E,{p:3,children:e.jsx(Me,{parentCallback:os,data:{newData:it,columns:Ge,columnstype:"antd",action:!1,Loading:fe,error:ve,deleteTodoMutation:Se,pageController:z}})})]})})]}),e.jsx(n.Drawer,{open:j,title:re,placement:"right",width:420,destroyOnClose:!0,onClose:ge,children:S?.id&&e.jsx(Mu,{token:t,assignmentId:S.id,studentName:`${S.firstname??""} ${S.lastname??""}`.trim(),onClose:ge,onSuccess:()=>gt()})}),e.jsx(n.Modal,{open:L,title:"Assign Student to Transport",onCancel:ds,footer:null,width:640,destroyOnClose:!0,children:e.jsx("form",{onSubmit:va,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Z,{options:dn,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:dn.find(xe=>String(xe.value)===String(de))??null,onChange:xe=>ne(xe,"route_id")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Z,{options:on,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:on.find(xe=>String(xe.value)===String(ce))??null,onChange:xe=>ne(xe,"vehicle_id")},`vehicle001${$}`)})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Z,{options:ln,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:ln.find(xe=>String(xe.value)===String(Ee))??null,onChange:xe=>ne(xe,"stop_id")},`stop001${N}`)})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Ue,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",value:Le,onChange:xe=>$e(xe)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{type:"text",name:"rootCost",label:"Route Cost",value:et,onChange:xe=>He(xe?.target?.value??"")})})}),e.jsx(n.Col,{xs:24,children:e.jsxs(E,{display:"flex",alignItems:"center",gap:12,children:[e.jsx(ie,{type:"submit",value:String(et??"").trim()?`${sl}${et} — Assign`:"Assign",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:ds,style:Zr,children:"Cancel"})]})})]})})})]})}const ei={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},mn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"};function Lu({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,g]=i.useState(""),[f,u]=i.useState(""),[p,w]=i.useState(""),[v,y]=i.useState(!1),m=`api/branchapi/Transport/getdriverTable?page=${a.page}&per_page=${a.rowsPerPage}`,x="api/branchapi/Transport/add_driver",T="api/branchapi/Transport/edit_driver",D="api/branchapi/Transport/deletedriver",k="api/branchapi/staff/uploadDocuments",C=i.useMemo(()=>String(k).startsWith("http")?k:`${at()??""}${String(k).replace(/^\/+/,"")}`,[k]),j=at()??"",{isLoading:h,data:S,error:A,mutate:R}=G(t?[m,t]:null,([z,P])=>J(z,P)),q=async(z,P)=>{try{await Ne(z,P,t),await R(),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),g("")}catch(I){_.error(I?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},U=z=>{z.preventDefault();const P=new FormData(z.target);q(x,P),z.target.reset()},b=async z=>{try{await R(Ve(D,z,t),qe(z)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}},O=z=>{d(z),g(z?.image??""),o(!0)},M=async z=>{try{await Qe(T,z,t),await R(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),g("")}catch(P){_.error(P?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},$=z=>{z.preventDefault();const P=new FormData(z.target);P.append("id",l?.id??""),M(P)},F=(z,P)=>{s({page:z,rowsPerPage:parseInt(P,10)})},N=[{title:"Driver Name",dataIndex:"name",key:"name",sorter:{compare:(z,P)=>String(z?.name??"").localeCompare(String(P?.name??""))}},{title:"Driver Licence",dataIndex:"Driver_licence",key:"Driver_licence",sorter:{compare:(z,P)=>String(z?.Driver_licence??"").localeCompare(String(P?.Driver_licence??""))}},{title:"Contact",dataIndex:"contact_number",key:"contact_number",sorter:{compare:(z,P)=>Number(z?.contact_number??0)-Number(P?.contact_number??0)}},{title:"Address",dataIndex:"address",key:"address",sorter:{compare:(z,P)=>String(z?.address??"").localeCompare(String(P?.address??""))}},{title:"Image",key:"image",width:100,render:(z,P)=>{const I=P?.image?`${j}staff/document/${P.image}`:"";return I?e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(n.Image,{width:80,src:I,preview:{visible:!1,onVisibleChange:()=>{y(!0),u(I),w(P?.name??"Driver")}}})}):null}},{title:"Action",key:"action",render:(z,P)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>O(P),style:{padding:2}}),e.jsx(ut,{id:P?.id,funcName:b})]})}],V=l?.name?`Edit ${l.name}`:"Edit Driver";return e.jsxs("div",{children:[e.jsx(n.Drawer,{open:r,title:V,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{o(!1),d(null),g("")},children:e.jsx("form",{onSubmit:$,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"name",label:"Driver Name",defaultValue:l?.name??"",required:"required"}),e.jsx(Y,{type:"text",name:"Driver_licence",label:"Driver Licence",defaultValue:l?.Driver_licence??"",required:"required"}),e.jsx(Y,{type:"number",name:"contact_number",label:"Driver Contact",defaultValue:l?.contact_number??"",required:"required"}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:mn,children:"Address"}),e.jsx(n.Input.TextArea,{name:"address",defaultValue:l?.address??"",rows:2,style:{width:"100%",border:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",paddingLeft:0,paddingRight:0}})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:mn,children:"Image"}),e.jsx(n.Upload,{maxCount:1,action:C,headers:t?{Authorization:t}:void 0,onChange:z=>{if(z?.file?.status!=="done")return;const P=z?.file?.response,I=P?.data??P?.filename??P?.file??P?.path??"";I&&g(String(I))},children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),disabled:!C,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null),g("")},style:ei,children:"Cancel"})]})]})})}),e.jsx(n.Modal,{zIndex:9999,open:v,title:p,footer:null,onCancel:()=>y(!1),children:e.jsx("img",{alt:"preview",style:{width:"100%"},src:f})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(E,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Add Driver"})}),e.jsx(E,{px:3,pb:2,children:e.jsx("form",{onSubmit:U,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"name",label:"Driver Name",required:"required"}),e.jsx(Y,{type:"text",name:"Driver_licence",label:"Driver Licence",required:"required"}),e.jsx(Y,{type:"number",name:"contact_number",label:"Driver Contact",required:"required"}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:mn,children:"Address"}),e.jsx(n.Input.TextArea,{name:"address",rows:2,style:{width:"100%",border:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",paddingLeft:0,paddingRight:0}})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:mn,children:"Image"}),e.jsx(n.Upload,{maxCount:1,action:C,headers:t?{Authorization:t}:void 0,onChange:z=>{if(z?.file?.status!=="done")return;const P=z?.file?.response,I=P?.data??P?.filename??P?.file??P?.path??"";I&&g(String(I))},children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),disabled:!C,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",onClick:()=>g(""),style:ei,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Driver List"})}),e.jsx(E,{children:e.jsx(Me,{parentCallback:F,data:{newData:S,columns:N,columnstype:"antd",action:!1,Loading:h,error:A,deleteTodoMutation:b}})})]})})]})})]})}const ti={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},la={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},fn={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},ai=[{label:"Pick",value:"pick"},{label:"Drop",value:"drop"}],hn=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function qu({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(!1),[c,g]=i.useState(null),[f,u]=i.useState(null),[p,w]=i.useState(null),[v,y]=i.useState(null),[m,x]=i.useState(ae()),[T,D]=i.useState(ae()),[k,C]=i.useState("pick"),[j,h]=i.useState(!1),[S,A]=i.useState(null),[R,q]=i.useState(null),[U,b]=i.useState(!1),[O,M]=i.useState(null),[$,F]=i.useState(null),[N,V]=i.useState(null),[z,P]=i.useState(null),[I,B]=i.useState(ae()),[L,H]=i.useState(ae()),[se,W]=i.useState("pick"),K=`api/branchapi/Transport/assignRouteTimeList?page=${a.page}&per_page=${a.rowsPerPage}`,te="api/branchapi/Transport/assignRouteTime",oe="api/branchapi/Transport/editAssignRouteTime",pe="api/branchapi/Transport/deleteAssignRouteTime",we="api/branchapi/Transport/driverDropdown",le="api/branchapi/transport/routeTimetableShowdata",de="api/branchapi/Transport/getrouteDropdown",Q="api/branchapi/Transport/getvehicleDropdown",{isLoading:ce,data:Te,error:Ee,mutate:Ie}=G(t?[K,t]:null,([fe,ve])=>J(fe,ve)),{data:Le}=G(t&&de?[de,t]:null,([fe,ve])=>J(fe,ve)),{data:$e}=G(t&&we?[we,t]:null,([fe,ve])=>J(fe,ve)),et=i.useMemo(()=>c?`${Q}?route_id=${c}`:null,[c,Q]),{data:He}=G(t&&et?[et,t]:null,([fe,ve])=>J(fe,ve)),Oe=i.useMemo(()=>hn(Le),[Le]),Ke=i.useMemo(()=>hn($e),[$e]),nt=i.useMemo(()=>hn(He),[He]),he=(fe,ve)=>{s({page:fe,rowsPerPage:parseInt(ve,10)})},je=async fe=>{fe.preventDefault();const ve=new FormData(fe.target);ve.set("route_id",f?.value??c??""),ve.set("driver_id",p?.value??""),ve.set("vehicle_id",v?.value??""),ve.set("start_time",m?m.format("h:mm a"):""),ve.set("drop_time",T?T.format("h:mm a"):""),ve.set("type",k);try{await Ne(te,ve,t),await Ie(),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),fe.target.reset(),g(null),u(null),w(null),y(null),d(it=>!it),x(ae()),D(ae()),C("pick"),o(it=>!it)}catch(it){_.error(it?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},be=async fe=>{try{await Ve(pe,fe,t),await Ie(),_.success("Success! Deleted item.",{duration:1e3})}catch(ve){_.error(ve?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},ne=fe=>{A(fe),h(!0);const ve=fe?.id??fe?.route_time_id??fe?.routeId??null;q(ve);const it=fe?.route_id??fe?.routeId??fe?.fk_route_id;M(it??null),F(Oe.find(gt=>gt?.value===(it??fe?.route_id))??null),V(Ke.find(gt=>gt?.value===(fe?.driver_id??fe?.driverId))??null),P(null),b(gt=>!gt),B(fe?.start_time?ae(fe.start_time,["h:mm a","HH:mm"]):ae()),H(fe?.drop_time?ae(fe.drop_time,["h:mm a","HH:mm"]):ae()),W(fe?.type??"pick")},me=i.useMemo(()=>{if(!R)return null;const fe=String(le).includes("?")?"&":"?";return`${le}${fe}id=${encodeURIComponent(String(R))}`},[R,le]),{data:ge,isLoading:re}=G(t&&me?[me,t]:null,([fe,ve])=>J(fe,ve)),ye=i.useMemo(()=>{const fe=ge?.data??ge;return Array.isArray(fe)?fe[0]??null:Array.isArray(fe?.data)?fe.data[0]??null:fe??null},[ge]),Be=i.useMemo(()=>O?`${Q}?route_id=${O}`:null,[O,Q]),{data:St}=G(t&&Be?[Be,t]:null,([fe,ve])=>J(fe,ve)),At=i.useMemo(()=>hn(St),[St]);i.useEffect(()=>{if(!ye)return;const fe=ye?.route_id??ye?.fk_route_id??ye?.routeId;M(fe??null),F(Oe.find(ve=>ve?.value===fe)??null),V(Ke.find(ve=>ve?.value===ye?.driver_id)??null),P(null),B(ye?.start_time?ae(ye.start_time,["h:mm a","HH:mm"]):ae()),H(ye?.drop_time?ae(ye.drop_time,["h:mm a","HH:mm"]):ae()),W(ye?.type??"pick"),b(ve=>!ve)},[Ke,ye,Oe]),i.useEffect(()=>{if(!ye)return;const fe=ye?.vehicle_id??ye?.vehicleId;fe&&P(At.find(ve=>ve?.value===fe)??null)},[ye,At]);const yt=async fe=>{if(fe.preventDefault(),!R)return;const ve=new FormData(fe.target);ve.set("id",String(R)),ve.set("route_id",$?.value??O??""),ve.set("driver_id",N?.value??""),ve.set("vehicle_id",z?.value??""),ve.set("start_time",I?I.format("h:mm a"):""),ve.set("drop_time",L?L.format("h:mm a"):""),ve.set("type",se);try{await Qe(oe,ve,t),await Ie(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),h(!1),A(null)}catch(it){_.error(it?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},Mt=[{title:"Route Name",dataIndex:"route_title",key:"route_title"},{title:"Driver Name",dataIndex:"driver_name",key:"driver_name"},{title:"Vehicle Name",dataIndex:"vehicle_name",key:"vehicle_name"},{title:"Start Time",dataIndex:"start_time",key:"start_time"},{title:"End Time",dataIndex:"drop_time",key:"drop_time"},{title:"Type",dataIndex:"type",key:"type"},{title:"Action",key:"action",render:(fe,ve)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>ne(ve),style:{padding:2}}),e.jsx(ut,{id:ve?.id??ve?.routeId??ve?.route_time_id,funcName:be})]})}],Zt=S?.route_title?`Edit ${S.route_title}`:"Edit Route Time";return e.jsxs("div",{children:[e.jsx(n.Drawer,{open:j,title:Zt,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{h(!1),A(null),q(null),M(null),F(null),V(null),P(null)},children:e.jsx("form",{onSubmit:yt,children:e.jsxs("div",{style:{display:"grid",gap:20,opacity:re?.6:1},children:[e.jsx(Z,{options:Oe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,value:$,onChange:fe=>{M(fe?.value??null),F(fe??null),P(null),b(ve=>!ve)}}),e.jsx(Z,{options:Ke,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",required:!0,allowSelectAll:!1,value:N,onChange:fe=>V(fe??null)}),e.jsx(Z,{options:At,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,value:z,onChange:fe=>P(fe??null)},`edit-vehicle-${U}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Start Time"}),e.jsx(n.TimePicker,{value:I,onChange:fe=>B(fe),use12Hours:!0,format:"h:mm a",allowClear:!1,style:fn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Drop Time"}),e.jsx(n.TimePicker,{value:L,onChange:fe=>H(fe),use12Hours:!0,format:"h:mm a",allowClear:!1,style:fn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(n.Radio.Group,{options:ai,optionType:"button",buttonStyle:"solid",value:se,onChange:fe=>W(fe.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{h(!1),A(null)},style:ti,children:"Cancel"})]})]})})}),e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(E,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(E,{px:3,pb:2,children:e.jsx("form",{onSubmit:je,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:Oe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",value:f,onChange:fe=>{g(fe?.value??null),u(fe??null),y(null),d(ve=>!ve)},allowSelectAll:!1,required:!0}),e.jsx(Z,{options:Ke,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",value:p,onChange:fe=>w(fe??null),allowSelectAll:!1,required:!0}),e.jsx(Z,{options:nt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",value:v,onChange:fe=>y(fe??null),allowSelectAll:!1,required:!0},`vehicle-${l}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Start Time"}),e.jsx(n.TimePicker,{value:m,onChange:fe=>x(fe),use12Hours:!0,format:"h:mm a",allowClear:!1,style:fn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Drop Time"}),e.jsx(n.TimePicker,{value:T,onChange:fe=>D(fe),use12Hours:!0,format:"h:mm a",allowClear:!1,style:fn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(n.Radio.Group,{options:ai,optionType:"button",buttonStyle:"solid",value:k,onChange:fe=>C(fe.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Add",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",onClick:()=>{g(null),u(null),w(null),y(null),d(fe=>!fe),x(ae()),D(ae()),C("pick"),o(fe=>!fe)},style:ti,children:"Cancel"})]})]})},`form-${r}`)})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Route Time List"})}),e.jsx(E,{children:e.jsx(Me,{parentCallback:he,data:{newData:Te,columns:Mt,columnstype:"antd",action:!1,Loading:ce,error:Ee,deleteTodoMutation:be}})})]})})]})})]})}const zu={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},ni={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},si={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},ri=({dataIndex:t,title:a,record:s,children:r,isEditable:o,...l})=>e.jsx("td",{...l,children:o?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:r}):r});let ii=2;function Yu({token:t}){const[a,s]=i.useState([]),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,g]=i.useState({pagination:{current:1,pageSize:50}}),{isLoading:f,data:u,mutate:p}=G(t?[`api/branchapi/transport/getrouteStoppageData?page=${c.pagination.current}&per_page=${c.pagination.pageSize}`,t]:null,([M,$])=>J(M,$)),{Status:w="Failed",pagination:{total_rows:v=0}={}}=u||{},{data:y=[]}=w==="Success"?u:{},{data:m}=G(t?["api/branchapi/Transport/getrouteDropdown",t]:null,([M,$])=>J(M,$)),x=i.useMemo(()=>{const M=m?.data??m??[];if(Array.isArray(M))return M;if(M&&typeof M=="object"){if(Array.isArray(M?.data))return M.data;if(Array.isArray(M?.data?.data))return M.data.data}return[]},[m]),{data:T}=G(t&&r?["api/branchapi/transport/getrouteStoppageData?route_id="+r,t]:null,([M,$])=>J(M,$)),{Status:D="Failed"}=T||{},k=async(M,$)=>{try{await p(Ne(M,$,t),We($)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{_.error("Failed to add the new item.",{duration:1e3})}},C=M=>M?typeof M=="string"?M:M?.isValid?.()?M.format("h:mm a"):"":"",j=(M,$=[])=>{const F=(Array.isArray(M)?M:[]).map(z=>({id:z?.id??"",name:String(z?.stop_name??z?.name??"").trim(),pickTime:C(z?.pickup_time??z?.pickTime??z?.pickupTime),drop_time:C(z?.drop_time??z?.dropTime)})),N=F.filter(z=>z?.id!=null&&String(z.id).trim()!==""),V=F.filter(z=>!(z?.id!=null&&String(z.id).trim()!==""));return{route_id:r??"",edit_stoppage:N,add_stoppage:V,delete_stoppage:Array.isArray($)?$:[]}},h=M=>{M.preventDefault();const $="/api/branchapi/transport/addstoppageToRoute",F=j(a,l);k($,F)},S=()=>{s(M=>[...Array.isArray(M)?M:[],{idKey:ii++,stop_name:"",pickup_time:ae().format("h:mm a"),drop_time:ae().format("h:mm a")}])},A=M=>{if(a.length===1)return;const $=a[M];$?.id!=null&&String($.id).trim()!==""&&!$?.idKey&&d(F=>{const N=Array.isArray(F)?F:[];return N.some(z=>String(z)===String($.id))?N:[...N,$.id]}),s(F=>{const N=[...F];return N.splice(M,1),N})},R=M=>{g($=>({...$,pagination:{current:M,pageSize:$.pagination.pageSize}}))},q=async M=>{const $="/api/branchapi/Transport/deletevehicle";try{await p(Ve($,M,t),qe(M)),_.success("Success! Deleted item.",{duration:1e3})}catch{_.error("Failed to delete the item.",{duration:1e3})}};i.useEffect(()=>{if(D==="Success"){const M=Array.isArray(T?.data)?T.data:[];M.length>0?(s(M),d([])):r&&(s([{idKey:ii++,stop_name:"",pickup_time:ae().format("h:mm a"),drop_time:ae().format("h:mm a")}]),d([]))}},[D,T,r]);const U=M=>{const{children:$=[]}=M||{},F=[{title:"Stop Name",dataIndex:"stop_name",onCell:N=>({isEditable:!0})},{title:"Pick Time",dataIndex:"pickup_time",onCell:N=>({isEditable:!0})},{title:"Drop Name",dataIndex:"drop_time",onCell:N=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(n.Table,{components:{body:{cell:ri}},expandable:{childrenColumnName:"changed"},bordered:!0,columns:F,rowKey:N=>b(N)+"cell01",dataSource:$,pagination:!1})})})},b=M=>{const $=["id","index"];for(let F=0;F<$.length;F++)if(M[$[F]])return M[$[F]]},O=[{title:"Route",dataIndex:"route_title"},{title:"Stoppages",render:(M,$,F)=>e.jsx(e.Fragment,{children:(Array.isArray($.children)?$.children:[]).map((N,V,z)=>e.jsx("span",{children:`${N.stop_name} ${V+1===z.length?"":","}`},`${V}vehicle001`))})},{title:"Action",render:(M,$,F)=>e.jsx(e.Fragment,{children:e.jsx(ut,{id:$?.route_id,funcName:q})})}];return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(E,{pt:5,pb:1,children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(E,{px:3,pb:2,children:e.jsxs("form",{onSubmit:h,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(Z,{options:x,value:x.find(M=>String(M.value)===String(r))??null,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",onChange:M=>{o(M?.value??null),s([]),d([])},allowSelectAll:!1,required:!0})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-start",gap:12},children:r&&e.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer",marginBottom:8},title:"Add Row",onClick:S,children:e.jsx(ee.PlusCircleOutlined,{style:{fontSize:24,color:"#28a745"}})})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(ie,{type:"submit",value:"Add",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"button",onClick:()=>{o(null),s([]),d([])},style:zu,children:"Cancel"})]})]}),e.jsx("div",{style:{marginTop:20},children:a.length>0&&a.map((M,$)=>{const F=M.pickup_time?ae(M.pickup_time,"h:mm a"):null,N=M.drop_time?ae(M.drop_time,"h:mm a"):null;return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr)) auto",gap:16,alignItems:"end",marginBottom:12},children:[e.jsxs("div",{children:[e.jsx(Y,{value:M.stop_name??"",type:"text",name:`stoppage[${$}][name]`,label:"Place Name*",required:"required",onChange:V=>{const z=V?.target?.value??"";s(P=>{const I=[...P];return I[$]={...I[$]??{},stop_name:z},I})}}),M?.id!=null&&String(M.id).trim()!==""&&e.jsx("input",{type:"hidden",name:`stoppage[${$}][id]`,value:String(M.id)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:ni,children:"Pick Time"}),e.jsx(n.TimePicker,{value:F,use12Hours:!0,format:"h:mm a",name:`stoppage[${$}][pickTime]`,allowClear:!1,style:si,onChange:V=>{const z=V?V.format("h:mm a"):"";s(P=>{const I=[...P];return I[$]={...I[$]??{},pickup_time:z},I})}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:ni,children:"Drop Time"}),e.jsx(n.TimePicker,{value:N,use12Hours:!0,format:"h:mm a",name:`stoppage[${$}][drop_time]`,allowClear:!1,style:si,onChange:V=>{const z=V?V.format("h:mm a"):"";s(P=>{const I=[...P];return I[$]={...I[$]??{},drop_time:z},I})}})]}),e.jsx("div",{style:{marginBottom:8},children:a.length>1&&e.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer"},onClick:()=>A($),children:e.jsx(ee.MinusCircleOutlined,{style:{fontSize:20,color:"#dc3545"}})})})]},M.idKey?M.idKey+"exp":M.id+"exp")})})]})}),e.jsx(E,{mx:2,mt:1,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Stoppage List"})}),e.jsx(E,{style:{padding:"10px 16px"},children:e.jsx(n.Table,{components:{body:{cell:ri}},columns:O,bordered:!0,size:"small",rowKey:M=>b(M),dataSource:y,loading:f,expandable:{expandedRowRender:U,childrenColumnName:"changed"},pagination:{current:c.pagination.current,pageSize:c.pagination.pageSize,total:v,showSizeChanger:!0,onChange:R,onShowSizeChange:(M,$)=>{g(F=>({...F,pagination:{current:1,pageSize:$}}))},showTotal:(M,$)=>`${$[0]}-${$[1]} of ${M} items`}})})]})]})}const oi={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Ra=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Vu({token:t}){const[a,s]=i.useState("api/branchapi/homeworks/gethomeworklistByClassSectionBranch?"),[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(null),[c,g]=i.useState(null),[f,u]=i.useState(null),[p,w]=i.useState(null),[v,y]=i.useState(!1),[m,x]=i.useState(null),[T,D]=i.useState(null),[k,C]=i.useState(null),[j,h]=i.useState(null),[S,A]=i.useState(null),[R,q]=i.useState(null),[U,b]=i.useState(!1),[O,M]=i.useState(""),[$,F]=i.useState(""),[N,V]=i.useState(""),z=(re,ye)=>{const Be=re?.value??null;switch(ye){case"class_id":d(Be),g(null),u(null);break;case"section_id":g(Be);break;case"subject_id":u(Be);break}},{data:P}=G(t?["api/branchapi/academy/classdropdownlist",t]:null,([re,ye])=>J(re,ye)),{data:I}=G(t&&S?[S,t]:null,([re,ye])=>J(re,ye)),{data:B}=G(t&&R?[R,t]:null,([re,ye])=>J(re,ye)),L=l?`api/branchapi/academy/sectionoftheClass?class_id=${l}`:null,{data:H}=G(t&&L?[L,t]:null,([re,ye])=>J(re,ye)),se=l?`api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${l}`:null,{data:W}=G(t&&se?[se,t]:null,([re,ye])=>J(re,ye)),K=i.useMemo(()=>Ra(P),[P]),te=i.useMemo(()=>Ra(I),[I]),oe=i.useMemo(()=>Ra(B),[B]),pe=i.useMemo(()=>Ra(H),[H]),we=i.useMemo(()=>Ra(W),[W]),le=t&&a?`${a}class_id=${l||""}&subject_id=${f||""}§ion_id=${c||""}&date=${p?.format("YYYY-MM-DD")||""}&page=${r.page}&per_page=${r.rowsPerPage}`:null,{isLoading:de,error:Q,data:ce,mutate:Te}=G(le?[le,t]:null,([re,ye])=>J(re,ye)),Ee=async(re,ye)=>{try{await Te(Ne(re,ye,t),We(ye)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),Oe()}catch(Be){console.error(Be),_.error("Failed to add the new item.",{duration:1e3})}},Ie=async re=>{try{await Te(Ve("api/student/Homework/deleteHomework",re,t),qe(re)),_.success("Success! Deleted item.",{duration:1e3})}catch(ye){console.error(ye),_.error("Failed to delete the item.",{duration:1e3})}},Le=async re=>{try{const ye=await Qe("api/student/Homework/updateHomework",re,t);Te(ye),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),Oe()}catch(ye){console.error(ye),_.error("Failed to update the item.",{duration:1e3})}},$e=re=>{re.preventDefault();const ye=new FormData(re.target),Be=ye.get("class_id")||l,St=ye.get("section_id")||c,At=ye.get("subject_id")||f,yt=p?.format("YYYY-MM-DD");s(`api/branchapi/homeworks/gethomeworklistByClassSectionBranch?class_id=${Be||""}&subject_id=${At||""}§ion_id=${St||""}${yt?`&date=${yt}`:""}&`),o(Mt=>({...Mt,page:1}))},et=re=>{re.preventDefault();const ye=new FormData(re.target);Ee("api/branchapi/homeworks/addHomework",ye),V("")},He=async(re,ye)=>{re.preventDefault();const Be=new FormData(re.target);Be.append("id",ye),await Le(Be)},Oe=()=>{y(!1),x(null),D(null),C(null),h(null),A(null),q(null),V("")},Ke=re=>{x(re);const ye=re?.class_id??re?.classId??null,Be=re?.section_id??re?.sectionId??null,St=re?.subject_id??re?.subjectId??null;D(ye),C(Be),h(St),ye?(A(`api/branchapi/academy/sectionoftheClass?class_id=${ye}`),q(`api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${ye}`)):(A(null),q(null)),V(re?.file||re?.document||""),y(!0)},nt=re=>{const ye=re?.value??null;D(ye),C(null),h(null),ye?(A(`api/branchapi/academy/sectionoftheClass?class_id=${ye}`),q(`api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${ye}`)):(A(null),q(null))},he=re=>{C(re?.value??null)},je=re=>{h(re?.value??null)},be=(re,ye)=>{o({page:re,rowsPerPage:parseInt(ye,10)})},ne=()=>{b(!1),M(""),F("")},me=(re,ye)=>{if(!re){_.error("No document found.",{duration:1e3});return}M(re),F(ye||"Document"),b(!0)},ge=[{title:"Date",dataIndex:"homework_date",key:"homework_date"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Title",dataIndex:"title",key:"title"},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0},{title:"Submission Date",dataIndex:"submit_date",key:"submit_date"},{title:"Staff Name",dataIndex:"staff_name",key:"staff_name"},{title:"Subject",dataIndex:"subject",key:"subject"},{title:"Document",key:"document",render:(re,ye)=>e.jsx("a",{style:{color:"#5080f8",cursor:"pointer"},onClick:()=>me(ye?.document_url,ye?.document),children:"View"})},{title:"Action",key:"action",render:(re,ye)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>Ke(ye),style:{padding:2}}),e.jsx(ut,{id:ye?.id,funcName:Ie})]})}];return e.jsxs(E,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(De,{level:5,style:{margin:0,color:"#fff"},children:"Search Homework"})}),e.jsx(E,{p:3,children:e.jsx("form",{onSubmit:$e,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(E,{children:e.jsx(Z,{options:K,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,value:K.find(re=>String(re.value)===String(l))??null,onChange:re=>z(re,"class_id")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(E,{children:e.jsx(Z,{options:pe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,value:pe.find(re=>String(re.value)===String(c))??null,onChange:re=>z(re,"section_id")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(E,{children:e.jsx(Z,{options:we,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subject",name:"subject_id",placeholder:"Subject",allowSelectAll:!1,value:we.find(re=>String(re.value)===String(f))??null,onChange:re=>z(re,"subject_id")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(E,{children:e.jsx(Ue,{Desplay:"Date",format:"YYYY-MM-DD",allowClear:!1,value:p,onChange:re=>w(re)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(E,{children:[e.jsx(ie,{type:"submit",value:"Search",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{s("api/branchapi/homeworks/gethomeworklistByClassSectionBranch?"),d(null),g(null),u(null),w(null)},style:oi,children:"Cancel"})]})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(De,{level:5,style:{margin:0,color:"#fff"},children:"Homework List"})}),e.jsx(E,{p:3,children:e.jsx(Me,{parentCallback:be,data:{newData:ce,columns:ge,columnstype:"antd",action:!1,Loading:de,error:Q,deleteTodoMutation:Ie,pageController:r}})})]})})]}),e.jsx(n.Drawer,{open:v,title:m?"Edit Homework":"Add Homework",placement:"right",width:600,destroyOnClose:!0,onClose:Oe,children:e.jsx("form",{onSubmit:m?re=>He(re,m.id):et,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Z,{options:K,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,placeholder:"Select Class",value:K.find(re=>String(re.value)===String(T))??null,onChange:nt})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Z,{options:te,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",required:!0,allowSelectAll:!1,placeholder:T?"Select Section":"Select Class First",value:te.find(re=>String(re.value)===String(k))??null,onChange:he,isDisabled:!T})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Z,{options:oe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subject",name:"sub_id",required:!0,allowSelectAll:!1,placeholder:T?"Select Subject":"Select Class First",value:oe.find(re=>String(re.value)===String(j))??null,onChange:je,isDisabled:!T})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Ue,{format:"YYYY-MM-DD",defaultValue:ae(),Desplay:"From",name:"homew_date"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Ue,{format:"YYYY-MM-DD",defaultValue:ae(),Desplay:"Deadline",name:"submission_date"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(Y,{type:"text",label:"Title",name:"title",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(E,{children:e.jsx(vt,{type:"text",label:"Description",name:"description",rows:3,required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(E,{children:[e.jsx(n.Upload,{action:"https://npmapi.ubkerp.com//SuperAdmin/uploadFile",headers:{Authorization:t},maxCount:1,onChange:re=>{if(re.file.status==="removed"&&V(""),re.file.status==="done"){const ye=re.file.response?.data??re.file.response?.file??"";V(String(ye??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:N?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:N||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(E,{children:[e.jsx(ie,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:Oe,style:oi,children:"Cancel"})]})})})})]})})}),e.jsx(n.Modal,{open:U,onCancel:ne,footer:null,width:900,closable:!0,children:e.jsxs(E,{p:3,children:[e.jsx(E,{mb:2,children:e.jsx(De,{level:5,children:$||"View Document"})}),O?O.match(/\.pdf(\?|#|$)/i)?e.jsx("iframe",{src:O,title:$||"Document Preview",style:{width:"100%",height:"70vh",border:"none"}}):e.jsx("img",{src:O,alt:$||"Document Preview",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(De,{children:"No document found"})]})}),e.jsx(E,{style:{position:"fixed",bottom:24,right:24,zIndex:1e3},children:e.jsx(n.Button,{type:"primary",size:"large",onClick:()=>{x(null),D(null),C(null),h(null),A(null),q(null),V(""),y(!0)},style:{borderRadius:"50%",width:56,height:56,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:24},children:"+"})})]})}const ws=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Wu({token:t}){const[a,s]=i.useState(!1),[r,o]=i.useState(null),[l,d]=i.useState(null),[c,g]=i.useState({page:1,rowsPerPage:10}),[f,u]=i.useState(!1),[p,w]=i.useState(""),[v,y]=i.useState(""),[m,x]=i.useState({label:"",value:""}),[T,D]=i.useState({label:"",value:""}),[k,C]=i.useState({label:"",value:""}),[j,h]=i.useState(!1),[S,A]=i.useState(!1),{data:R}=G(t?["api/branchapi/academy/classdropdownlist",t]:null,([W,K])=>J(W,K)),{data:q}=G(t&&a?[a,t]:null,([W,K])=>J(W,K)),{data:U}=G(t&&(r||!0)?[r||"api/branchapi/academy/subjecttableList",t]:null,([W,K])=>J(W,K)),b=i.useMemo(()=>ws(R),[R]),O=i.useMemo(()=>ws(q),[q]),M=i.useMemo(()=>ws(U),[U]),$=t&&l?`${l}page=${c.page}&per_page=${c.rowsPerPage}`:null,{isLoading:F,error:N,data:V,mutate:z}=G($?[$,t]:null,([W,K])=>J(W,K)),P=(W,K)=>{switch(K){case"class_id":x(W||{label:"",value:""}),D({label:"",value:""}),C({label:"",value:""}),o(`/api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${W?.value??""}`),s(`/api/branchapi/academy/sectionoftheClass?class_id=${W?.value??""}`),h(te=>!te),A(te=>!te);break;case"section_id":D(W||{label:"",value:""});break;case"subject_id":C(W||{label:"",value:""});break}},I=async W=>{W.preventDefault();const K="/api/branchapi/homeworks/gethomeworklistByClassSectionBranch",te=new URLSearchParams;m.value&&te.append("class_id",String(m.value)),T.value&&te.append("section_id",String(T.value)),k.value&&te.append("subject_id",String(k.value));const oe=te.toString(),pe=oe?`${K}?${oe}&`:`${K}?`;g(we=>({...we,page:1})),d(pe),await z()},B=(W,K)=>{g({page:W,rowsPerPage:parseInt(K,10)})},L=()=>{u(!1),w(""),y("")},H=(W,K)=>{w(W),y(K||"Document"),u(!0)},se=[{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Subject",dataIndex:"subject",key:"subject"},{title:"Assign By",dataIndex:"staff_name",key:"staff_name"},{title:"Title",dataIndex:"title",key:"title"},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0},{title:"Submission",dataIndex:"total_submission",key:"total_submission"},{title:"View Document",key:"document",render:(W,K)=>e.jsx("a",{style:{color:"#5080f8",cursor:"pointer"},onClick:()=>H(K.document_url,K.document),children:"View"})}];return e.jsxs(E,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(De,{level:5,style:{margin:0,color:"#fff"},children:"Submission Details"})}),e.jsx(E,{p:3,children:e.jsx("form",{onSubmit:I,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(E,{children:e.jsx(Z,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,value:b.find(W=>String(W.value)===String(m.value))??null,onChange:W=>P(W,"class_id")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(E,{children:e.jsx(Z,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,value:O.find(W=>String(W.value)===String(T.value))??null,onChange:W=>D(W||{label:"",value:""})},`sections1${j}`)})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(E,{children:e.jsx(Z,{options:M,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subject",name:"subject_id",placeholder:"Subject",allowSelectAll:!1,value:M.find(W=>String(W.value)===String(k.value))??null,onChange:W=>C(W||{label:"",value:""})},`subjects1${S}`)})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(E,{display:"flex",alignItems:"center",height:"100%",mt:2,children:e.jsx(ie,{type:"submit",value:"Search",color:"primary"})})})]})})})]})}),l&&e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(De,{level:5,style:{margin:0,color:"#fff"},children:"Students List"})}),e.jsx(E,{p:3,children:e.jsx(Me,{parentCallback:B,data:{newData:V,columns:se,columnstype:"antd",action:!1,Loading:F,error:N,pageController:c}})})]})})]}),e.jsx(n.Modal,{open:f,onClose:L,footer:null,width:900,children:e.jsxs(E,{p:3,children:[e.jsxs(E,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,children:[e.jsx(De,{level:5,children:v||"View Document"}),e.jsx(ie,{type:"button",value:"Close",color:"primary",onClick:L})]}),p?p.match(/\.pdf(\?|#|$)/i)?e.jsx("iframe",{src:p,title:v||"Document Preview",style:{width:"100%",height:"70vh",border:"none"}}):e.jsx("img",{src:p,alt:v||"Document Preview",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(De,{children:"No document found"})]})})]})}const Hu=(t,a)=>{const s=String(t??"").replace(/\/+$/,""),r=String(a).replace(/^\/+/,"");return`${s}/${r}`};function Ku({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,r]=i.useState(null),[o,l]=i.useState(null),[d,c]=i.useState(null),[g,f]=i.useState(null),[u,p]=i.useState(null),[w,v]=i.useState(null),[y,m]=i.useState(null),x="api/branchapi/library/bookCategorydropdown",T="api/branchapi/academy/classdropdownlist",D="api/branchapi/Academy/getClassSubjectdropdown",k="api/branchapi/library/addBook",C="api/branchapi/library/uploadcsv",{data:j}=G(a?[x,a]:null,([b,O])=>J(b,O)),{data:h}=G(a&&T?[T,a]:null,([b,O])=>J(b,O)),{data:S}=G(a&&D?[D,a]:null,([b,O])=>J(b,O)),A=i.useMemo(()=>Hu(at(),C),[C]),R=async b=>{b.preventDefault();const O=new FormData(b.target);O.set("cat_id",u?.value??""),O.set("class_id",w?.value??""),O.set("subject_id",y?.value??"");try{await Ne(k,O,a),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),b.target.reset(),p(null),v(null),m(null)}catch(M){_.error(M?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},q=async b=>{if(b.preventDefault(),!s){_.error("Please select a CSV file.",{duration:1e3});return}const O=new FormData;O.append("file",s),O.append("cat_id",o?.value??""),O.append("class_id",d?.value??""),O.append("subject_id",g?.value??"");try{const M=await ze.post(A,O,{headers:{Authorization:a,"Content-type":"multipart/form-data"}});M?.data?.Status==="Failed"?_.error(String(M?.data?.msg??"Upload failed."),{duration:1e3}):(_.success(String(M?.data?.msg??"Uploaded."),{duration:1e3,icon:"🚀"}),r(null),b.target.reset(),l(null),c(null),f(null))}catch(M){_.error(M?.response?.data?.msg??"Upload failed.",{duration:1e3})}},U=()=>{fetch("/books.csv").then(b=>{b.blob().then(O=>{const M=window.URL.createObjectURL(O);let $=document.createElement("a");$.href=M,$.download="/books.csv",$.click()})})};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Book in Bulk"}),extra:e.jsx(n.Button,{type:"link",icon:e.jsx(ee.DownloadOutlined,{}),onClick:U,children:"Download Sample"}),children:[e.jsx(n.Divider,{children:"Information"}),e.jsx(n.Typography.Paragraph,{style:{marginBottom:16},children:"1. Your CSV data should be in the format below. The first line of your CSV file should be the column headers as in the table example. Also make sure that your file is UTF-8 to avoid unnecessary encoding problems."}),e.jsx("form",{onSubmit:q,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:o,onChange:b=>l(b??null)}),e.jsx(Z,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:d,onChange:b=>c(b??null)}),e.jsx(Z,{options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:g,onChange:b=>f(b??null)}),e.jsx(Y,{type:"file",label:"Upload CSV",name:"csv",accept:".csv",onChange:b=>r(b.target.files?.[0]??null),required:!0}),e.jsx(ie,{type:"submit",value:"Save",color:"primary"})]})})]}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Book"}),children:e.jsx("form",{onSubmit:R,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",label:"Book Name",name:"title",required:!0}),e.jsx(Y,{type:"text",label:"Author",name:"author",required:!0}),e.jsx(Y,{type:"text",label:"Publication",name:"publisher"}),e.jsx(Y,{type:"number",label:"Qty",name:"quantity",required:!0}),e.jsx(Y,{type:"number",label:"Book Price",name:"price",required:!0}),e.jsx(Y,{type:"number",label:"Fine Per Day",name:"fine",required:!0}),e.jsx(Y,{type:"text",label:"Barcode",name:"barcode"}),e.jsx(Z,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:u,onChange:b=>p(b??null)}),e.jsx(Z,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:w,onChange:b=>v(b??null)}),e.jsx(Z,{options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:y,onChange:b=>m(b??null)}),e.jsx(ie,{type:"submit",value:"Save",color:"primary"})]})})})]})}const _s={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Cs=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function Gu({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,r]=i.useState([]),[o,l]=i.useState([]),d=i.useRef(),c={selectedRowKeys:s,onChange:(te,oe)=>{r(te),l(oe)}},g=xa.useReactToPrint({contentRef:d,documentTitle:"Book Barcodes"}),f=()=>{if(!(typeof window>"u")){if(!o.length){_.error("Select at least one book to print.",{duration:1e3});return}if(!d.current){_.error("Nothing to print.",{duration:1e3});return}g?.()}},[u,p]=i.useState(!1),[w,v]=i.useState(null),[y,m]=i.useState(null),[x,T]=i.useState(null),[D,k]=i.useState(null),[C,j]=i.useState({page:1,rowsPerPage:10}),h=(te,oe)=>{j({page:te,rowsPerPage:parseInt(oe,10)})},S="api/branchapi/library/booktable",A="api/branchapi/library/deletebooks",R="api/branchapi/library/editbook",q=`${S}?page=${C.page}&per_page=${C.rowsPerPage}`,{isLoading:U,error:b,data:O,mutate:M}=G(a?[q,a]:null,([te,oe])=>J(te,oe)),$="api/branchapi/library/bookCategorydropdown",F="api/branchapi/academy/classdropdownlist",N="api/branchapi/Academy/getClassSubjectdropdown",{data:V}=G(a?[$,a]:null,([te,oe])=>J(te,oe)),{data:z}=G(a&&F?[F,a]:null,([te,oe])=>J(te,oe)),{data:P}=G(a&&N?[N,a]:null,([te,oe])=>J(te,oe)),I=i.useMemo(()=>Cs(V),[V]),B=i.useMemo(()=>Cs(z),[z]),L=i.useMemo(()=>Cs(P),[P]),H=async te=>{try{await Ve(A,te,a),await M(),_.success("Success! Deleted item.",{duration:1e3})}catch(oe){_.error(oe?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},se=te=>{v(te??null);const oe=te?.cat_id??te?.fk_cat_id??te?.category_id,pe=te?.class_id??te?.fk_class_id,we=te?.subject_id??te?.fk_subject_id;m(I.find(le=>le?.value===oe)??null),T(B.find(le=>le?.value===pe)??null),k(L.find(le=>le?.value===we)??null),p(!0)},W=async te=>{te.preventDefault();const oe=w?.id??w?.book_id??w?._id;if(!oe)return;const pe=new FormData(te.target);pe.set("id",String(oe)),pe.set("cat_id",y?.value??""),pe.set("class_id",x?.value??""),pe.set("subject_id",D?.value??"");try{await Qe(R,pe,a),await M(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),p(!1),v(null)}catch(we){_.error(we?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},K=i.useMemo(()=>[{title:"Name",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Barcode",dataIndex:"barcode",key:"barcode",width:140,responsive:["sm"]},{title:"Publisher",dataIndex:"publish",key:"publish",width:160,responsive:["lg"]},{title:"Author",dataIndex:"author",key:"author",width:160,responsive:["lg"]},{title:"Class",dataIndex:"class_name",key:"class_name",width:140,responsive:["xl"]},{title:"Subject",dataIndex:"subject_name",key:"subject_name",width:160,responsive:["xl"]},{title:"Avl Qty",dataIndex:"available_qty",key:"available_qty",width:90},{title:"Book Price",dataIndex:"perunitcost",key:"perunitcost",width:120,responsive:["xl"]},{title:"Fine Amount",dataIndex:"fine_amount",key:"fine_amount",width:120,responsive:["xl"]},{title:"Category",dataIndex:"cat_name",key:"cat_name",width:160,responsive:["xl"]},{title:"Action",key:"action",width:140,fixed:"right",render:(te,oe)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>se(oe),style:{padding:2}}),e.jsx(n.Button,{type:"text",size:"small",danger:!0,onClick:()=>H(oe?.id??oe?.book_id??oe?._id),style:{padding:"2px 6px"},children:"Delete"})]})}],[I,B,H,L]);return e.jsxs("div",{style:{},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:u,title:"Edit Book",placement:"right",width:520,destroyOnClose:!0,onClose:()=>{p(!1),v(null)},children:e.jsx("form",{onSubmit:W,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Y,{label:"Book Name",name:"title",defaultValue:w?.book_title??"",required:!0}),e.jsx(Y,{label:"Author",name:"author",defaultValue:w?.author??"",required:!0}),e.jsx(Y,{label:"Publication",name:"publish",defaultValue:w?.publish??""}),e.jsx(Y,{label:"Qty",name:"quantity",type:"number",defaultValue:w?.quantity??""}),e.jsx(Y,{label:"Book Price",name:"perunitcost",type:"number",defaultValue:w?.perunitcost??""}),e.jsx(Y,{label:"Fine Amount",name:"fine_amount",type:"number",defaultValue:w?.fine_amount??""}),e.jsx(Y,{label:"Barcode",name:"barcode",defaultValue:w?.barcode??""}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:_s,children:"Category"}),e.jsx(Z,{options:I,value:y,onChange:te=>m(te??null),name:"cat_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:_s,children:"Class"}),e.jsx(Z,{options:B,value:x,onChange:te=>T(te??null),name:"class_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:_s,children:"Subject"}),e.jsx(Z,{options:L,value:D,onChange:te=>k(te??null),name:"subject_id"})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{p(!1),v(null)},children:"Cancel"})]})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Book List"}),extra:o.length>0?e.jsxs(n.Button,{type:"primary",onClick:f,children:["Print Barcode (",o.length,")"]}):null,children:e.jsx(Me,{parentCallback:h,data:{newData:O,columns:K,columnstype:"antd",action:!1,Loading:U,error:b,rowSelection:c}})}),e.jsx("div",{style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"},children:e.jsx("div",{ref:d,style:{padding:"20px"},children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"flex-start"},children:o.map((te,oe)=>e.jsxs("div",{style:{margin:"10px",textAlign:"center",border:"1px dashed black",padding:"10px",borderRadius:"5px",width:"fit-content"},children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:"bold",maxWidth:"200px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:te.book_title}),e.jsx(ao,{value:te.barcode?String(te.barcode):String(te.id),format:"CODE128",width:1.5,height:50,fontSize:12,displayValue:!0})]},oe))})})})]})}const Ju=(t,a)=>{const s=String(t??"").replace(/\/+$/,""),r=String(a).replace(/^\/+/,"");return`${s}/${r}`},Et=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},yn=t=>ae(t).add(1,"month").format("YYYY-MM-DD"),Qu=i.forwardRef(({token:t,onReturn:a},s)=>{const r=t??localStorage.getItem("authToken")??"",[o,l]=i.useState("issue"),d=o==="return",[c,g]=i.useState(!1),[f,u]=i.useState(!1),[p,w]=i.useState(null),[v,y]=i.useState([]),[m,x]=i.useState([]),[T,D]=i.useState([]),[k,C]=i.useState(0),[j,h]=i.useState(!1),[S,A]=i.useState(null),[R,q]=i.useState(null),[U,b]=i.useState(null),[O,M]=i.useState(!1),[$,F]=i.useState("Cash"),[N,V]=i.useState(""),[z,P]=i.useState(""),[I,B]=i.useState(0),[L,H]=i.useState("NO_FINE"),se=i.useRef(null),[W]=n.Form.useForm(),[K]=n.Form.useForm(),te="api/branchapi/library/bookCategorydropdown",oe="api/branchapi/academy/classdropdownlist",pe="api/branchapi/Academy/getClassSubjectdropdown",{data:we}=G(r?[te,r]:null,([ue,Se])=>J(ue,Se)),{data:le}=G(r&&oe?[oe,r]:null,([ue,Se])=>J(ue,Se)),{data:de}=G(r&&pe?[pe,r]:null,([ue,Se])=>J(ue,Se)),Q=i.useMemo(()=>Et(we),[we]),ce=i.useMemo(()=>Et(le),[le]),Te=i.useMemo(()=>Et(de),[de]),Ee="api/branchapi/library/studentsearchByNameID",Ie="api/branchapi/library/booksearchBybookname",Le="api/branchapi/library/issuedBookList",$e="api/branchapi/library/issueLibrarybook",et="api/branchapi/library/returnedLibrarybook",{trigger:He,data:Oe}=rt(Ee,(ue,Se)=>Kt(ue,Se,r)),{trigger:Ke,data:nt}=rt(Ie,(ue,Se)=>Kt(ue,Se,r)),{trigger:he,data:je}=rt(Le,(ue,Se)=>Kt(ue,Se,r)),{trigger:be}=rt(d?et:$e,(ue,Se)=>Zn(ue,Se,r)),ne=i.useMemo(()=>Et(Oe),[Oe]),me=i.useMemo(()=>Et(nt),[nt]),ge=i.useMemo(()=>Et(je),[je]),re=ue=>{const Se=yn(ae());y(Fe=>Fe.some(Ge=>String(Ge?.id)===String(ue?.id))?Fe:[...Fe,{...ue,return_date:ue?.return_date?ue.return_date:Se}])},ye=async()=>{console.log("Reloading IssueReturn..."),_.success("Success",{duration:1e3}),x([]),D([]),C(0),H("FINE_PAY_LATER"),await he({id:p?.student_id})};i.useImperativeHandle(s,()=>({reloadPayLater:ye}));const Be=ue=>{y(Se=>Se.filter(Fe=>String(Fe?.id)!==String(ue)))},St=async ue=>{if(r){if(!ue){w(null);return}c||await He({id:ue})}},At=async({search:ue})=>{if(!r||!c)return;const Se=await He({id:ue}),Fe=Et(Se);Fe.length===1&&(w(Fe[0]),await he({id:Fe[0]?.student_id}),W.resetFields())},yt=async(ue,Se)=>{w(Se??null),y([]),x([]),D([]),C(0),H("NO_FINE"),B(0),Se?.student_id&&await he({id:Se.student_id}),W.resetFields()},Mt=async ue=>{r&&ue&&(f||await Ke({book:ue}))},Zt=async({search_book:ue})=>{if(!r||!f)return;const Se=await Ke({book:ue,catID:S?.value??"",sID:U?.value??"",cID:R?.value??""}),Fe=Et(Se);Fe.length&&(re(Fe[0]),K.resetFields())},fe=(ue,Se)=>{re(Se),K.resetFields()},ve=async()=>{if(!p?.member_id){_.error("Select a student first.",{duration:1e3});return}if(!v.length){_.error("Select at least one book.",{duration:1e3});return}const ue=await be({member_id:p.member_id,fine:!1,books:v});ue?.Status==="Success"&&(_.success(String(ue?.msg??"Success"),{duration:1e3}),y([]),w(null),x([]),D([]),C(0))},it=async()=>{if(!p?.member_id){_.error("Select a student first.",{duration:1e3});return}if(!T.length){_.error("Select at least one book to return.",{duration:1e3});return}if(Number(k)>0){H("FINE_PAID"),M(!0);return}const ue=await be({member_id:p.member_id,collection_type:"NO_FINE",amount:0,books:JSON.stringify(T)});ue?.Status==="Success"?(_.success(String(ue?.msg??"Success"),{duration:1e3}),x([]),D([]),C(0),await he({id:p?.student_id})):_.error(String(ue?.msg??"Failed"),{duration:1e3})},gt=async()=>{if(!p?.member_id)return;const ue=Math.max(0,Number(k)-Number(I||0)),Se={member_id:p.member_id,collection_type:L,amount:L==="FINE_PAID"?ue:0,payment_type:$,notes:N,attchement:z,discount:I||0,books:JSON.stringify(T)},Fe=await be(Se);M(!1),Fe?.Status==="Success"?(_.success(String(Fe?.msg??"Success"),{duration:1e3}),x([]),D([]),C(0),B(0),V(""),P(""),H("NO_FINE"),await he({id:p?.student_id})):_.error(String(Fe?.msg??"Failed"),{duration:1e3})},sn=async()=>{if(!p?.member_id){_.error("Select a student first.",{duration:1e3});return}if(!T.length){_.error("Select at least one book to return.",{duration:1e3});return}const ue={member_id:p.member_id,collection_type:"FINE_PAY_LATER",amount:0,books:JSON.stringify(T)};a(ue)},rn=i.useMemo(()=>Ju(at(),"api/branchapi/frontoffice/uploadfrontofficeDocument"),[]),on=[{title:"Book",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Author",dataIndex:"author",key:"author",width:180,responsive:["lg"]},{title:"Return Date",key:"return_date",width:160,render:(ue,Se)=>e.jsx(Ue,{defaultValue:ae(Se?.return_date||ae().add(30,"day")),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:(Fe,Ge)=>{y(st=>st.map(pt=>String(pt?.id)===String(Se?.id)?{...pt,return_date:Ge}:pt))}})},{title:"Action",key:"action",width:120,fixed:"right",render:(ue,Se)=>e.jsx(n.Button,{type:"text",danger:!0,onClick:()=>Be(Se?.id),children:"Remove"})}],ln={selectedRowKeys:m,onChange:(ue,Se)=>{x(ue),D(Se);const Fe=(Se??[]).reduce((Ge,st)=>Ge+Number(st?.totalfine??0),0);C(Fe)},onSelect:(ue,Se,Fe)=>{if(Se){const Ge=Fe.map(st=>({...st,return_date:st?.return_date?st.return_date:yn(st?.issue_date||ae())}));D(Ge)}},onSelectAll:(ue,Se)=>{if(ue){const Fe=Se.map(Ge=>({...Ge,return_date:Ge?.return_date?Ge.return_date:yn(Ge?.issue_date||ae())}));D(Fe)}}},dn=[{title:"Book",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Barcode",dataIndex:"barcode",key:"barcode",width:140,responsive:["sm"]},{title:"Issue Date",dataIndex:"issue_date",key:"issue_date",width:140,responsive:["lg"]},{title:"Return Date",key:"return_date",width:160,render:(ue,Se)=>{const Ge=T.find(pt=>String(pt?.id)===String(Se?.id))?.return_date||Se?.return_date,st=yn(Se?.issue_date||ae());return e.jsx(Ue,{defaultValue:ae(Ge||st),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:(pt,os)=>{D(ls=>ls.map(va=>String(va?.id)===String(Se?.id)?{...va,return_date:os}:va))}})}},{title:"Days",key:"days",width:100,render:(ue,Se)=>{const Ge=T.find(pt=>String(pt?.id)===String(Se?.id))?.return_date||Se?.return_date,st=Se?.issue_date;if(st&&Ge){const pt=ae(Ge).diff(ae(st),"day");return pt>=0?pt:0}return"-"}},{title:"Due Date",dataIndex:"due_date",key:"due_date",width:140,responsive:["lg"]},{title:"Fine",dataIndex:"totalfine",key:"totalfine",width:120,fixed:"right",render:ue=>e.jsxs("span",{children:["₹ ",ue]})}];return e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:O,onCancel:()=>M(!1),footer:null,title:"Payment Options",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsx(n.Radio.Group,{value:$,onChange:ue=>F(ue.target.value),options:[{label:"Cash",value:"Cash"},{label:"UPI",value:"UPI"},{label:"DD",value:"DD"},{label:"Bank",value:"Bank"},{label:"Internet Banking",value:"Internet Banking"},{label:"Cheque",value:"Cheque"}]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Note"}),e.jsx(n.Input.TextArea,{rows:3,value:N,onChange:ue=>V(ue.target.value)})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{className:"labelfont",children:"Image Attachment"}),e.jsx(n.Upload,{action:rn,headers:{Authorization:r},maxCount:1,onChange:ue=>{if(ue.file.status==="done"){const Se=ue.file.response?.data??ue.file.response?.file??"";P(String(Se??""))}},children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),children:"Upload"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Discount"}),e.jsx(n.Input,{type:"number",value:I,onChange:ue=>B(ue.target.value),placeholder:"0"})]}),e.jsxs(n.Button,{type:"primary",onClick:gt,children:["Collect ₹",Math.max(0,Number(k)-Number(I||0))]}),e.jsx(n.Button,{onClick:()=>M(!1),children:"Cancel"})]})}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Issue / Return"}),children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:10,children:e.jsx(n.Radio.Group,{value:o,onChange:ue=>{const Se=ue.target.value;l(Se),y([]),x([]),D([]),C(0),H("NO_FINE"),B(0)},options:[{label:"Issue",value:"issue"},{label:"Return",value:"return"},{label:"Renewal",value:"Renewal"}],optionType:"button",buttonStyle:"solid"})}),e.jsx(n.Col,{xs:24,md:14,children:e.jsx(n.Form,{form:W,onFinish:At,layout:"vertical",children:e.jsx(n.Form.Item,{name:"search",label:"Search Student",children:e.jsx(n.Space.Compact,{style:{width:"100%"},children:c?e.jsx(n.Input,{autoFocus:!0,addonBefore:e.jsxs(n.Space,{children:[e.jsx(ee.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:c,onChange:ue=>g(ue.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(n.AutoComplete,{options:ne,onSelect:yt,onSearch:St,style:{width:"100%"},allowClear:!0,children:e.jsx(n.Input,{addonBefore:e.jsxs(n.Space,{children:[e.jsx(ee.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:c,onChange:ue=>g(ue.target.checked)})]}),placeholder:"Type student name / id",allowClear:!0})})})})})})]}),p?e.jsxs(e.Fragment,{children:[e.jsx(n.Divider,{}),e.jsxs(n.Row,{gutter:[12,12],children:[e.jsxs(n.Col,{xs:24,md:8,children:[e.jsx(n.Typography.Text,{strong:!0,children:"Name:"})," ",p?.value??""]}),e.jsxs(n.Col,{xs:24,md:8,children:[e.jsx(n.Typography.Text,{strong:!0,children:"Card No:"})," ",p?.library_card_no??""]}),e.jsxs(n.Col,{xs:24,md:8,children:[e.jsx(n.Typography.Text,{strong:!0,children:"Member ID:"})," ",p?.member_id??""]})]})]}):null,e.jsx(n.Divider,{}),d?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:760},children:e.jsx(n.Table,{dataSource:ge,columns:dn,rowSelection:ln,pagination:!1,rowKey:ue=>ue?.id??ue?.issue_id??ue?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(n.Divider,{}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap"},children:[e.jsxs(n.Typography.Text,{strong:!0,children:["Total Fine: ₹",k]}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsx(n.Button,{type:"primary",onClick:it,disabled:!T.length,children:k>0?`Pay Now ₹ ${Math.max(0,Number(k)-Number(I||0))}`:"Return Selected"}),k>0?e.jsx(n.Button,{onClick:sn,disabled:!T.length,children:"Pay Later"}):null]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:18,children:e.jsx(n.Form,{form:K,onFinish:Zt,layout:"vertical",children:e.jsx(n.Form.Item,{name:"search_book",label:"Search Book",children:e.jsx(n.Space.Compact,{style:{width:"100%"},children:f?e.jsx(n.Input,{autoFocus:!0,disabled:!p,addonBefore:e.jsxs(n.Space,{children:[e.jsx(ee.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:f,onChange:ue=>u(ue.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(n.AutoComplete,{disabled:!p,options:me,onSelect:fe,onSearch:Mt,style:{width:"100%"},allowClear:!0,children:e.jsx(n.Input,{addonBefore:e.jsxs(n.Space,{children:[e.jsx(ee.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:f,onChange:ue=>u(ue.target.checked)})]}),placeholder:"Type book name",allowClear:!0})})})})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(n.Button,{style:{width:"100%"},icon:e.jsx(ee.FilterOutlined,{}),onClick:()=>h(!0),children:"Filter"})})]}),e.jsx(n.Drawer,{open:j,onClose:()=>h(!1),title:"Filter",placement:"right",width:380,destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Z,{label:"Category",options:Q,value:S,onChange:ue=>A(ue??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"cat_id"}),e.jsx(Z,{label:"Class",options:ce,value:R,onChange:ue=>q(ue??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"class_id"}),e.jsx(Z,{label:"Subjects",options:Te,value:U,onChange:ue=>b(ue??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"subject_id"}),e.jsx(n.Button,{type:"primary",onClick:()=>h(!1),children:"Apply"})]})}),e.jsx(n.Divider,{}),e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:720},children:e.jsx(n.Table,{dataSource:v,columns:on,pagination:!1,rowKey:ue=>ue?.id??ue?.book_id??ue?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"button",value:"Issue",onClick:ve})})]})]}),e.jsx("div",{ref:se,style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"}})]})}),li=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function Xu({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,r]=i.useState({page:1,rowsPerPage:10}),[o,l]=i.useState(null),[d,c]=i.useState(null),[g,f]=i.useState(!1),[u,p]=i.useState(!1),[w,v]=i.useState(null),[y,m]=i.useState(!1),x="api/branchapi/academy/classdropdownlist",T="api/branchapi/academy/sectionoftheClass",D="api/branchapi/library/studenttableForLibrary",k="api/branchapi/library/addmembershipforStudent",C="api/branchapi/library/removemembershipforStudent",j=i.useMemo(()=>{if(!o?.value)return null;const P=T.includes("?")?"&":"?";return`${T}${P}class_id=${encodeURIComponent(String(o.value))}`},[T,o?.value]),h=i.useMemo(()=>{if(!o?.value||!d?.value)return null;const P=D.includes("?")?"&":"?";return`${D}${P}cID=${encodeURIComponent(String(o.value))}&sID=${encodeURIComponent(String(d.value))}&page=${s.page}&per_page=${s.rowsPerPage}`},[s.page,s.rowsPerPage,o?.value,d?.value,D]),{data:S}=G(a&&x?[x,a]:null,([P,I])=>J(P,I)),{data:A}=G(a&&j?[j,a]:null,([P,I])=>J(P,I)),{isLoading:R,error:q,data:U,mutate:b}=G(a&&h?[h,a]:null,([P,I])=>J(P,I)),O=i.useMemo(()=>li(S),[S]),M=i.useMemo(()=>li(A),[A]),$=(P,I)=>{r({page:P,rowsPerPage:parseInt(I,10)})},F=P=>{const I=P?.id??P?.student_id??P?.member_id;v(I??null),p(!0),m(B=>!B)},N=async P=>{if(P.preventDefault(),!w)return;const I=new FormData(P.target);I.set("id",String(w));try{await Ne(k,I,a),_.success("Success! Added member.",{duration:1e3,icon:"🎉"}),p(!1),v(null),await b()}catch(B){_.error(B?.response?.data?.msg??"Failed to add the member.",{duration:1e3})}},V=async P=>{try{await Ve(C,P,a),_.success("Success! Removed member.",{duration:1e3}),await b()}catch(I){_.error(I?.response?.data?.msg??"Failed to remove member.",{duration:1e3})}},z=i.useMemo(()=>[{title:"Library Card No",dataIndex:"library_card_no",key:"library_card_no",width:180,ellipsis:!0,fixed:"left"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:140,responsive:["sm"]},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:90,responsive:["lg"]},{title:"First Name",dataIndex:"firstname",key:"firstname",width:140,responsive:["sm"]},{title:"Last Name",dataIndex:"lastname",key:"lastname",width:140,responsive:["lg"]},{title:"Class",dataIndex:"class",key:"class",width:120,responsive:["xl"]},{title:"Section",dataIndex:"section",key:"section",width:120,responsive:["xl"]},{title:"Mobile",dataIndex:"mobileno",key:"mobileno",width:140,responsive:["lg"]},{title:"Action",key:"action",width:80,fixed:"right",render:(P,I)=>(console.log("data______________",I),e.jsx("div",{style:{display:"flex",gap:8,alignItems:"center"},children:I?.library_card_no==null?e.jsx(n.Button,{type:"primary",size:"small",icon:e.jsx(ee.UserAddOutlined,{}),onClick:()=>F(I)}):e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{}),onClick:()=>V(I?.id??I?.student_id??I?.member_id)})}))}],[V]);return e.jsxs("div",{style:{},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:u,title:"Add Member",onCancel:()=>{p(!1),v(null)},footer:null,destroyOnClose:!0,children:e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Y,{type:"text",label:"Library Card Number",name:"library_num",required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Add",color:"primary"})})]})},`add-${y}`)}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Student"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Z,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",value:o,onChange:P=>{l(P??null),c(null),f(I=>!I)},name:"class_id",required:!0,allowSelectAll:!1}),e.jsx(Z,{options:M,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",value:d,onChange:P=>c(P??null),allowSelectAll:!1,name:"section_id",required:!0},`section-${g}`),e.jsx(ie,{type:"submit",value:"Search",color:"primary",onClick:()=>{if(!o?.value||!d?.value){_.error("Select class and section.",{duration:1e3});return}r(P=>({...P,page:1}))}})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Students"}),children:e.jsx(Me,{parentCallback:$,data:{newData:U,columns:z,columnstype:"antd",action:!1,Loading:R,error:q}})})]})}function Zu({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,r]=i.useState({page:1,rowsPerPage:10}),[o]=n.Form.useForm(),[l]=n.Form.useForm(),[d,c]=i.useState(!1),[g,f]=i.useState(null),u="api/branchapi/library/BookCategorytable",p="api/branchapi/library/addBookCategory",w="api/branchapi/library/editBookCategory",v="api/branchapi/library/deleteBookCategory",y=i.useMemo(()=>{const q=u.includes("?")?"&":"?";return`${u}${q}page=${s.page}&per_page=${s.rowsPerPage}`},[u,s.page,s.rowsPerPage]),{isLoading:m,error:x,data:T,mutate:D}=G(a&&y?[y,a]:null,([q,U])=>J(q,U)),k=(q,U)=>{r({page:q,rowsPerPage:parseInt(U,10)})},C=async q=>{const U=new FormData;U.set("title",q?.title??"");try{await Ne(p,U,a),_.success("Success! Added new category.",{duration:1e3,icon:"🎉"}),o.resetFields(),await D()}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to add category.",{duration:1e3})}},j=q=>{f(q??null),l.setFieldsValue({title:q?.name??""}),c(!0)},h=()=>{c(!1),f(null),l.resetFields()},S=async q=>{const U=g?.id??g?.category_id??g?.cat_id;if(!U){_.error("Missing category id.",{duration:1e3});return}const b=new FormData;b.set("id",String(U)),b.set("title",q?.title??"");try{await Qe(w,b,a),_.success("Success! Updated category.",{duration:1e3,icon:"🚀"}),h(),await D()}catch(O){_.error(O?.response?.data?.msg??O?.message??"Failed to update category.",{duration:1e3})}},A=async q=>{const U=q?.id??q?.category_id??q?.cat_id;if(!U){_.error("Missing category id.",{duration:1e3});return}try{await Ve(v,U,a),_.success("Success! Deleted category.",{duration:1e3}),await D()}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to delete category.",{duration:1e3})}},R=i.useMemo(()=>[{title:"Category Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(q,U)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>j(U)}),e.jsx(n.Popconfirm,{title:"Remove category?",okText:"Yes",cancelText:"No",onConfirm:()=>A(U),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[A]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:d,title:"Edit Category",onCancel:h,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:l,layout:"vertical",onFinish:S,children:[e.jsx(n.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(n.Input,{placeholder:"Enter category name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:h,children:"Cancel"}),e.jsx(ie,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,lg:8,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Category"}),children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:C,children:[e.jsx(n.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(n.Input,{placeholder:"Enter category name"})}),e.jsx(ie,{type:"submit",value:"Add",color:"primary"})]})})}),e.jsx(n.Col,{xs:24,lg:16,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Category List"}),children:e.jsx(Me,{parentCallback:k,data:{newData:T,columns:R,columnstype:"antd",action:!1,Loading:m,error:x}})})})]})]})}const As=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function ep({token:t}){const[a,s]=i.useState([ae().format("YYYY-MM-DD"),ae().format("YYYY-MM-DD")]),[r,o]=i.useState(null),[l,d]=i.useState(null),[c,g]=i.useState(null),[f,u]=i.useState(!1),[p,w]=i.useState(!1),v="api/branchapi/academy/classdropdownlist",y="api/branchapi/academy/sectionoftheClass",m="api/branchapi/library/memberDropdown",x="api/report/libraryReport/libraryReport",T=i.useMemo(()=>{if(!r?.value)return null;const F=y.includes("?")?"&":"?";return`${y}${F}class_id=${encodeURIComponent(String(r.value))}`},[y,r?.value]),D=i.useMemo(()=>{if(!r?.value)return null;const F=m.includes("?")?"&":"?",N=`${m}${F}class=${encodeURIComponent(String(r.value))}`;return l?.value?`${N}§ion=${encodeURIComponent(String(l.value))}`:N},[m,r?.value,l?.value]),{isLoading:k,error:C,data:j,mutate:h}=G(t&&v?[v,t]:null,([F,N])=>J(F,N)),{data:S}=G(t&&T?[T,t]:null,([F,N])=>J(F,N)),{data:A}=G(t&&D?[D,t]:null,([F,N])=>J(F,N)),R=i.useMemo(()=>As(j),[j]),q=i.useMemo(()=>As(S),[S]),U=i.useMemo(()=>As(A),[A]),{trigger:b,data:O}=rt(x,(F,N)=>Qs(F,N,t));i.useEffect(()=>{(async()=>{w(!0);try{await b({duration:a})}finally{w(!1)}})()},[]);const M=async()=>{w(!0);try{await b({duration:a,class:r?.value??"",section:l?.value??"",student_id:c?.value??""})}finally{w(!1)}},$=[{title:"Name",dataIndex:"full_name",render:(F,N)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:N?.full_name??""})},{title:"Roll No",dataIndex:"roll_no",render:(F,N)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:N?.roll_no??""})},{title:"Class",dataIndex:"Class",key:"Class",render:(F,N)=>e.jsxs(n.Typography.Text,{style:{fontSize:12},children:[N?.class??"","(",N?.section??"",")"]})},{title:"Book",dataIndex:"book_title",render:(F,N)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:N?.book_title??""})},{title:"Issue Date",key:"date",render:(F,N,V)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:N?.issue_date??""})},{title:"Due Return Date",key:"date",render:(F,N,V)=>e.jsx(n.Tag,{color:"orange",children:N?.return_date??""})},{title:"Return Date",key:"date",render:(F,N,V)=>N?.retured_by_user?e.jsx(n.Tag,{color:"green",children:N?.retured_by_user??""}):null},{title:"Return Status",key:"date",render:(F,N,V)=>String(N?.is_returned??"")==="1"?e.jsx(n.Tag,{color:"green",children:"Return"}):e.jsx(n.Tag,{color:"red",children:"Not Return"})},{title:"Fine",key:"amount",dataIndex:"late_fine",render:(F,N,V)=>{const z=N?.late_fine?Number(N.late_fine):0;return z?e.jsx(n.Typography.Text,{style:{fontSize:12,color:"#cf1322"},children:z}):null}}];return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Library Monthly Report"}),style:{borderRadius:16},children:[e.jsxs(n.Row,{gutter:[16,16],align:"bottom",children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Duration"}),e.jsx(n.DatePicker.RangePicker,{style:{width:"100%"},value:[ae(a[0],"YYYY-MM-DD"),ae(a[1],"YYYY-MM-DD")],format:"YYYY-MM-DD",onChange:(F,N)=>{Array.isArray(N)&&N.length===2&&s([N[0],N[1]])}})]})}),e.jsx(n.Col,{xs:24,md:5,children:e.jsx(Z,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Classes",name:"class_id",value:r,onChange:F=>{o(F??null),d(null),g(null),u(N=>!N)},allowSelectAll:!1})}),e.jsx(n.Col,{xs:24,md:5,children:e.jsx(Z,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",value:l,onChange:F=>{d(F??null),g(null)},allowSelectAll:!1},`section1${f}`)}),e.jsx(n.Col,{xs:24,md:5,children:e.jsx(Z,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student",value:c,onChange:F=>g(F??null),allowSelectAll:!1})}),e.jsx(n.Col,{xs:24,md:1,children:e.jsx(n.Button,{type:"primary",icon:e.jsx(ee.SearchOutlined,{}),onClick:M,style:{width:"100%"},children:"Search"})})]}),e.jsx("div",{style:{marginTop:16},children:e.jsx(n.Table,{columns:$,pagination:!1,dataSource:Array.isArray(O?.data)?O.data:[],size:"small",rowKey:(F,N)=>F?.id??F?.issue_id??F?.fees_receipt_id??N,loading:p,scroll:{x:"max-content"},summary:F=>{const N=F.reduce((z,P)=>z+Number(P?.late_fine??0),0),V=F.reduce((z,P)=>z+Number(P?.is_returned??0),0);return e.jsxs(n.Table.Summary.Row,{children:[e.jsx(n.Table.Summary.Cell,{colSpan:4,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Book: ",F.length]})}),e.jsx(n.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Not Return: ",Number(F.length-V)]})}),e.jsx(n.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Return: ",V]})}),e.jsx(n.Table.Summary.Cell,{colSpan:1,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Fine:",N.toLocaleString("en-IN")]})})]})}})})]})]})}const di=[{label:"Today",value:"Today"},{label:"Yesterday",value:"Yesterday"},{label:"This Week",value:"This Week"},{label:"This Month",value:"This Month"},{label:"Last Month",value:"Last Month"},{label:"This Year",value:"This Year"},{label:"Custom",value:"Custom"}],ci=[{key:"renewalHistory",label:"Renewal History"},{key:"renewalFineReport",label:"Renewal + Fine"},{key:"currentlyRenewedBooks",label:"Currently Renewed"},{key:"upcomingRenewalDue",label:"Upcoming Due"},{key:"overdueRenewalReport",label:"Overdue"},{key:"renewalLimitReport",label:"Renewal Limit"},{key:"renewalStatusReport",label:"Renewal Status"},{key:"studentWiseReport",label:"Student-wise"},{key:"bookWiseReport",label:"Book-wise"},{key:"classWiseReport",label:"Class-wise"},{key:"staffWiseReport",label:"Staff-wise"},{key:"renewalStatisticsByDate",label:"Statistics by Date"}];function tp({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,r]=i.useState("renewalHistory"),[o,l]=i.useState("This Month"),[d,c]=i.useState(""),[g,f]=i.useState(""),[u,p]=i.useState(7),[w,v]=i.useState(1),[y,m]=i.useState(20),[x,T]=i.useState(""),[D,k]=i.useState("DESC"),C=i.useRef(null),j=N=>{const V=new URLSearchParams;return["renewalHistory","renewalFineReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport","renewalStatisticsByDate"].includes(s)&&(V.set("date_range",o),o==="Custom"&&d&&g&&(V.set("from_date",d),V.set("to_date",g))),["renewalHistory","renewalFineReport","currentlyRenewedBooks","upcomingRenewalDue","overdueRenewalReport","renewalLimitReport","renewalStatusReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport"].includes(s)&&(V.set("page",String(w)),V.set("per_page",String(y))),s==="upcomingRenewalDue"&&V.set("days_ahead",String(u)),x&&V.set("sort_by",x),D&&V.set("sort_dir",D),`${N}?${V.toString()}`},h=i.useMemo(()=>{switch(s){case"renewalHistory":return j(Hd);case"renewalFineReport":return j(Kd);case"currentlyRenewedBooks":return j(Gd);case"upcomingRenewalDue":return j(Jd);case"overdueRenewalReport":return j(Qd);case"renewalLimitReport":return j(Xd);case"renewalStatusReport":return j(Zd);case"studentWiseReport":return j(ec);case"bookWiseReport":return j(tc);case"classWiseReport":return j(ac);case"staffWiseReport":return j(nc);case"renewalStatisticsByDate":return j(sc);default:return null}},[s,o,d,g,u,w,y]),{data:S,isLoading:A}=G(a?[h,a]:null,([N,V])=>J(N,V)),R=S?.data||{},q=R?.rows||[],U=R?.pagination||{},b=N=>{r(N),v(1),m(20)},O=()=>{v(1)},M=()=>{switch(s){case"renewalHistory":case"renewalFineReport":return[{title:"Renewal ID",dataIndex:"renewal_id",key:"renewal_id"},{title:"Student",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Book",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Renewal No",dataIndex:"renewal_no",key:"renewal_no"},{title:"Old Due Date",dataIndex:"old_due_date",key:"old_due_date"},{title:"New Due Date",dataIndex:"new_due_date",key:"new_due_date"},{title:"Renewal Date",dataIndex:"renewal_date",key:"renewal_date"},{title:"Status",dataIndex:"status",key:"status",render:N=>e.jsx(n.Tag,{color:N==="renewed"?"green":"red",children:N})},{title:"Fine Amount",dataIndex:"fine_amount",key:"fine_amount",render:N=>N??"-"},{title:"Paid Amount",dataIndex:"paid_amount",key:"paid_amount",render:N=>N??"-"},{title:"Due Amount",dataIndex:"due_amount",key:"due_amount",render:N=>N??"-"},{title:"Fine Status",dataIndex:"fine_payment_status",key:"fine_payment_status",render:N=>N?e.jsx(n.Tag,{color:N==="paid"?"green":N==="partial"?"orange":"red",children:N}):"-"}];case"currentlyRenewedBooks":case"upcomingRenewalDue":case"overdueRenewalReport":case"renewalLimitReport":case"renewalStatusReport":return[{title:"Student",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Book",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Due Date",dataIndex:"return_date",key:"return_date"},{title:"Renewal Count",dataIndex:"renewal_count",key:"renewal_count"},{title:"Max Renewal",dataIndex:"maximum_renewal",key:"maximum_renewal"},{title:"Days Remaining",dataIndex:"days_remaining",key:"days_remaining",render:N=>N??"-"},{title:"Overdue Days",dataIndex:"overdue_days",key:"overdue_days",render:N=>N??"-"},{title:"Fine",dataIndex:"fine_amount",key:"fine_amount",render:N=>N??"-"},{title:"Due",dataIndex:"due_amount",key:"due_amount",render:N=>N??"-"},{title:"Can Renew",dataIndex:"can_renew",key:"can_renew",render:N=>e.jsx(n.Tag,{color:N?"green":"red",children:N?"Yes":"No"})},{title:"Reasons",dataIndex:"reasons",key:"reasons",render:N=>Array.isArray(N)?N.join("; "):"-"}];case"studentWiseReport":return[{title:"Student ID",dataIndex:"student_id",key:"student_id"},{title:"Student Name",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Books",dataIndex:"unique_books_renewed",key:"unique_books_renewed"},{title:"First Renewal",dataIndex:"first_renewal_date",key:"first_renewal_date"},{title:"Last Renewal",dataIndex:"last_renewal_date",key:"last_renewal_date"}];case"bookWiseReport":return[{title:"Book ID",dataIndex:"book_id",key:"book_id"},{title:"Title",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Category",dataIndex:"category",key:"category"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"}];case"classWiseReport":return[{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"}];case"staffWiseReport":return[{title:"Staff",dataIndex:"renewed_by",key:"renewed_by"},{title:"Staff Name",dataIndex:"staff_name",key:"staff_name"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"},{title:"Unique Books",dataIndex:"unique_books",key:"unique_books"}];case"renewalStatisticsByDate":return[{title:"Period",dataIndex:"period",key:"period"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"},{title:"Unique Books",dataIndex:"unique_books",key:"unique_books"}];default:return[]}},$=["renewalHistory","renewalFineReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport","renewalStatisticsByDate"].includes(s),F=i.useMemo(()=>M(),[s]);return e.jsx(E,{pt:5,pb:1,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,padding:"4px 8px",color:"#fff",display:"inline-block"}}),e.jsxs(E,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],mb:3,children:[$&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Z,{options:di,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Date Range",allowSelectAll:!1,value:di.find(N=>N.value===o)||null,onChange:N=>l(N?.value||"This Month")})}),o==="Custom"&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Ue,{Desplay:"From Date",format:"YYYY-MM-DD",onChange:N=>c(N?N.format("YYYY-MM-DD"):"")})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Ue,{Desplay:"To Date",format:"YYYY-MM-DD",onChange:N=>f(N?N.format("YYYY-MM-DD"):"")})})]})]}),s==="upcomingRenewalDue"&&e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Z,{options:[{label:"7 Days",value:7},{label:"14 Days",value:14},{label:"30 Days",value:30}],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Days Ahead",allowSelectAll:!1,value:{label:u+" Days",value:u},onChange:N=>p(N?.value||7)})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(E,{display:"flex",alignItems:"center",height:"100%",mt:2,children:e.jsx(ie,{type:"button",value:"Search",color:"primary",onClick:O})})})]}),e.jsx(n.Tabs,{activeKey:s,onChange:b,items:ci})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:ci.find(N=>N.key===s)?.label||"Report"})}),e.jsxs(E,{p:3,children:[e.jsx(jt,{data:{tableRef:C}}),A?e.jsx(E,{py:8,textAlign:"center",children:e.jsx(n.Typography.Text,{type:"secondary",children:"Loading report data..."})}):e.jsx(n.Table,{size:"small",dataSource:q,columns:F,loading:A,pagination:!1,bordered:!0,rowKey:N=>N.renewal_id||N.id||JSON.stringify(N),ref:C}),q.length>0&&e.jsx(n.Pagination,{current:w,pageSize:y,total:U.total_rows||q.length,onChange:(N,V)=>{v(N),m(V)},showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:[10,20,50,100],style:{marginTop:16,textAlign:"right"}})]})]})})]})})}const es=t=>t??localStorage.getItem("authToken")??"",ap=(t,a)=>{const s=String(t??""),r=String(a);return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},Ye={upload:"api/branchapi/frontoffice/uploadfrontofficeDocument",academy:{classes:"api/branchapi/academy/classdropdownlist",sections:"api/branchapi/academy/sectionoftheClass"},student:{dropdown:"api/branchapi/student/studentDropdown"},vendor:{list:"api/accounts/vendor/vendorTable",add:"api/accounts/vendor/addvendor",edit:"api/accounts/vendor/editVendor",remove:"api/accounts/vendor/removecategory",dropdown:"api/accounts/vendor/vendorlist"},category:{list:"api/accounts/category/fetchcategorytable",add:"api/accounts/category/addcategory",edit:"api/accounts/category/editcategory",remove:"api/accounts/category/removecategory",dropdown:"api/accounts/category/categoryDropdown"},subCategory:{list:"api/accounts/category/fetchsubcategorytable",add:"api/accounts/category/addsubcategory",edit:"api/accounts/category/editsubcategory",remove:"api/accounts/category/removesubcategory",dropdown:"api/accounts/category/subcategoryDropdown"},unit:{list:"api/accounts/category/fetchunit",add:"api/accounts/category/addunit",edit:"api/accounts/category/editunit",remove:"api/accounts/category/removeunit",dropdown:"api/accounts/category/unitDropdown"},product:{list:"api/accounts/product/fetchproducttable",add:"api/accounts/product/addproduct",edit:"api/accounts/product/editproduct",remove:"api/accounts/product/removeproduct",dropdown:"api/accounts/product/productdropdown",search:"api/accounts/product/searchproductbyNameandBarcode",addStock:"api/accounts/product/addStock",sellProduct:"api/accounts/product/sellproduct",sellReports:"api/accounts/product/getstoreSellReports"},report:{stock:"api/report/StoreReport/stock_report"}},np=()=>ap(at(),Ye.upload),sp=async({baseUrl:t,page:a=1,perPage:s=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return J(l,es(r))},Xa=async(t,a,s)=>Ne(t,a,es(s)),ja=async(t,a,s)=>Qe(t,a,es(s)),Za=async(t,a,s)=>Ve(t,a,es(s)),rp=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",ya=({token:t,value:a,onChange:s})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(n.Upload,{maxCount:1,action:np(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=rp(o?.file?.response);l&&s?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:"Upload"})})},kn=Ye.vendor,en=({baseUrl:t,page:a=1,perPage:s=10,token:r})=>G(r&&t?[t,a,s,r]:null,([l,d,c,g])=>sp({baseUrl:l,page:d,perPage:c},g)),ip=({token:t,page:a=1,perPage:s=10})=>en({baseUrl:kn.list,page:a,perPage:s,token:t}),op={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},ui=[{name:"name",label:"Name*",required:!0,type:"text"},{name:"email",label:"Email*",required:!0,type:"text"},{name:"address",label:"Address*",required:!0,type:"text"},{name:"phone",label:"Phone*",required:!0,type:"number"},{name:"business_name",label:"Brand Name*",required:!0,type:"text"},{name:"acc_number",label:"Account Number",required:!1,type:"text"},{name:"ifsc_code",label:"IFSC Code",required:!1,type:"text"},{name:"acc_holder_name",label:"Account Holder Name",required:!1,type:"text"},{name:"gst_number",label:"GST Number",required:!1,type:"text"},{name:"cin_num",label:"CIN Number",required:!1,type:"text"},{name:"upi_id",label:"UPI ID",required:!1,type:"text"}];function lp({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,g]=i.useState(""),{isLoading:f,error:u,data:p,mutate:w}=ip({token:t,page:a.page,perPage:a.rowsPerPage}),v=async C=>{try{await w(Xa(kn.add,C,t),We(C)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(j){_.error(j?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},y=C=>{C.preventDefault();const j=new FormData(C.target);c&&j.set("image",c),v(j),C.target.reset(),g("")},m=(C,j)=>{s({page:C,rowsPerPage:parseInt(j,10)})},x=async C=>{try{await w(Za(kn.remove,C,t),qe(C)),_.success("Success! Deleted item.",{duration:1e3})}catch(j){_.error(j?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},T=C=>{d(C),o(!0),g("")},D=async C=>{C.preventDefault();const j=new FormData(C.target);j.set("id",String(l?.id??"")),c&&j.set("image",c);try{await ja(kn.edit,j,t),await w(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),g("")}catch(h){_.error(h?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},k=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Email",dataIndex:"email",key:"email",ellipsis:!0,responsive:["md"]},{title:"Address",dataIndex:"address",key:"address",ellipsis:!0,responsive:["lg"]},{title:"Phone",dataIndex:"phone",key:"phone",ellipsis:!0,responsive:["md"]},{title:"Branch Name",dataIndex:"business_name",key:"business_name",ellipsis:!0,responsive:["lg"]},{title:"Account Holder",dataIndex:"acc_holder_name",key:"acc_holder_name",ellipsis:!0,responsive:["xl"]},{title:"Account Number",dataIndex:"acc_number",key:"acc_number",ellipsis:!0,responsive:["xl"]},{title:"UPI ID",dataIndex:"upi_id",key:"upi_id",ellipsis:!0,responsive:["xl"]},{title:"Action",key:"action",width:100,fixed:"right",render:(C,j)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>T(j),style:{padding:2}}),e.jsx(ut,{id:j?.id,funcName:x})]})}],[x]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Vendor",placement:"right",width:520,onClose:()=>{o(!1),d(null),g("")},children:e.jsx("form",{onSubmit:D,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[ui.map(C=>e.jsx(Y,{type:C.type,name:C.name,label:C.label,defaultValue:l?.[C.name]??"",required:C.required?"required":void 0},C.name)),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:g})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null),g("")},style:op,children:"Cancel"})]})]})})}),e.jsxs(E,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Add Vendor"})}),e.jsx(E,{px:3,pb:2,children:e.jsx("form",{onSubmit:y,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16,alignItems:"end"},children:[ui.map(C=>e.jsx(Y,{type:C.type,name:C.name,label:C.label,required:C.required?"required":void 0},C.name)),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:g})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Add Vendor",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Vendors List"})}),e.jsx(E,{pt:3,children:e.jsx(Me,{parentCallback:m,data:{newData:p,columns:k,columnstype:"antd",action:!1,Loading:f,error:u}})})]})]})]})}const dp=({token:t})=>e.jsx(lp,{token:t}),Pn=Ye.product,pi=Ye.vendor.dropdown,mi=Ye.category.dropdown,cp=Ye.subCategory.dropdown,fi=Ye.unit.dropdown,Bo=({token:t,page:a=1,perPage:s=10})=>en({baseUrl:Pn.list,page:a,perPage:s,token:t}),up=({token:t})=>G(t&&pi?[pi,t]:null,([s,r])=>J(s,r)),pp=({token:t})=>G(t&&mi?[mi,t]:null,([s,r])=>J(s,r)),mp=({token:t})=>G(t&&fi?[fi,t]:null,([s,r])=>J(s,r)),fp=({token:t,categoryId:a})=>{const s=t&&a?`${cp}?category_id=${encodeURIComponent(String(a))}`:null;return G(s?[s,t]:null,([o,l])=>J(o,l))},gn=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},hp={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function yp({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,g]=i.useState(""),[f,u]=i.useState(""),[p,w]=i.useState(""),[v,y]=i.useState(""),[m,x]=i.useState(""),{isLoading:T,error:D,data:k,mutate:C}=Bo({token:t,page:a.page,perPage:a.rowsPerPage}),{data:j}=up({token:t}),{data:h}=pp({token:t}),{data:S}=mp({token:t}),{data:A}=fp({token:t,categoryId:f}),R=i.useMemo(()=>gn(j),[j]),q=i.useMemo(()=>gn(h),[h]),U=i.useMemo(()=>gn(S),[S]),b=i.useMemo(()=>gn(A),[A]),O=async P=>{try{await C(Xa(Pn.add,P,t),We(P)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(I){_.error(I?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},M=P=>{P.preventDefault();const I=new FormData(P.target);f&&I.set("fk_categoryID",String(f)),p&&I.set("fk_sub_categoryID",String(p)),v&&I.set("vendor_id",String(v)),m&&I.set("unit",String(m)),c&&I.set("image",c),O(I),P.target.reset(),g(""),u(""),w(""),y(""),x("")},$=(P,I)=>{s({page:P,rowsPerPage:parseInt(I,10)})},F=async P=>{try{await C(Za(Pn.remove,P,t),qe(P)),_.success("Success! Deleted item.",{duration:1e3})}catch(I){_.error(I?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},N=P=>{d(P),o(!0),g(""),u(P?.fk_categoryID??P?.category_id??""),w(P?.fk_sub_categoryID??P?.sub_category_id??""),y(P?.vendor_id??""),x(P?.unit??P?.unit_id??"")},V=async P=>{P.preventDefault();const I=new FormData(P.target);I.set("id",String(l?.id??"")),f&&I.set("fk_categoryID",String(f)),p&&I.set("fk_sub_categoryID",String(p)),v&&I.set("vendor_id",String(v)),m&&I.set("unit",String(m)),c&&I.set("image",c);try{await ja(Pn.edit,I,t),await C(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),g("")}catch(B){_.error(B?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},z=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,fixed:"left",width:180},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,responsive:["lg"]},{title:"Category",dataIndex:"storecategory",key:"storecategory",ellipsis:!0,responsive:["md"]},{title:"Quantity",dataIndex:"quantity",key:"quantity",ellipsis:!0,width:100,responsive:["md"]},{title:"Unit",dataIndex:"unit_name",key:"unit_name",ellipsis:!0,width:120,responsive:["md"]},{title:"Price",dataIndex:"price",key:"price",ellipsis:!0,width:100,responsive:["md"]},{title:"Barcode",dataIndex:"barcode",key:"barcode",ellipsis:!0,responsive:["xl"]},{title:"Hsn Code",dataIndex:"hsn_code",key:"hsn_code",ellipsis:!0,responsive:["xl"]},{title:"Action",key:"action",width:100,fixed:"right",render:(P,I)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>N(I),style:{padding:2}}),e.jsx(ut,{id:I?.id,funcName:F})]})}],[F]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Product",placement:"right",width:520,onClose:()=>{o(!1),d(null),g("")},children:e.jsx("form",{onSubmit:V,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx(Y,{type:"text",name:"name",label:"Product Name*",defaultValue:l?.name??"",required:"required"}),e.jsx(Z,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:P=>{const I=P?.value??"";u(I),w("")},defaultValue:f?q.find(P=>String(P?.value)===String(f)):null}),e.jsx(Z,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:P=>w(P?.value??""),defaultValue:p?b.find(P=>String(P?.value)===String(p)):null}),e.jsx(Y,{type:"text",name:"barcode",label:"Barcode",defaultValue:l?.barcode??""}),e.jsx(Z,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:P=>x(P?.value??""),defaultValue:m?U.find(P=>String(P?.value)===String(m)):null}),e.jsx(Y,{type:"number",name:"quantity",label:"Quantity*",defaultValue:l?.quantity??"",required:"required"}),e.jsx(Y,{type:"number",name:"price",label:"Price*",defaultValue:l?.price??"",required:"required"}),e.jsx(Z,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:P=>y(P?.value??""),defaultValue:v?R.find(P=>String(P?.value)===String(v)):null}),e.jsx(Y,{type:"number",name:"hsn_code",label:"Hsn Code",defaultValue:l?.hsn_code??""}),e.jsx(vt,{type:"text",label:"Description",name:"description",rows:3,defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:g})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null),g("")},style:hp,children:"Cancel"})]})]})})}),e.jsxs(E,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Add Product"})}),e.jsx(E,{px:3,pb:2,children:e.jsx("form",{onSubmit:M,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"name",label:"Product Name*",required:"required"}),e.jsx(Z,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:P=>{const I=P?.value??"";u(I),w("")}}),e.jsx(Z,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:P=>w(P?.value??"")},`subcat_${f}`),e.jsx(Y,{type:"text",name:"barcode",label:"Barcode"}),e.jsx(Z,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:P=>x(P?.value??"")}),e.jsx(Y,{type:"number",name:"quantity",label:"Quantity*",required:"required"}),e.jsx(Y,{type:"number",name:"price",label:"Price*",required:"required"}),e.jsx(Z,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:P=>y(P?.value??"")}),e.jsx(Y,{type:"number",name:"hsn_code",label:"Hsn Code"}),e.jsx(vt,{type:"text",label:"Description",name:"description",rows:3}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:g})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Add Product",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Products List"})}),e.jsx(E,{pt:3,children:e.jsx(Me,{parentCallback:$,data:{newData:k,columns:z,columnstype:"antd",action:!1,Loading:T,error:D}})})]})]})]})}const gp=({token:t})=>e.jsx(yp,{token:t}),On=Ye.category,xp=({token:t,page:a=1,perPage:s=10})=>en({baseUrl:On.list,page:a,perPage:s,token:t}),bp={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function jp({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:c,error:g,data:f,mutate:u}=xp({token:t,page:a.page,perPage:a.rowsPerPage}),p=async D=>{try{await u(Xa(On.add,D,t),We(D)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(k){_.error(k?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},w=D=>{D.preventDefault();const k=new FormData(D.target);p(k),D.target.reset()},v=(D,k)=>{s({page:D,rowsPerPage:parseInt(k,10)})},y=async D=>{try{await u(Za(On.remove,D,t),qe(D)),_.success("Success! Deleted item.",{duration:1e3})}catch(k){_.error(k?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},m=D=>{d(D),o(!0)},x=async D=>{D.preventDefault();const k=new FormData(D.target);k.set("id",String(l?.id??""));try{await ja(On.edit,k,t),await u(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch(C){_.error(C?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},T=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(D,k)=>String(D?.name??"").localeCompare(String(k?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(D,k)=>String(D?.description??"").localeCompare(String(k?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(D,k)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>m(k),style:{padding:2}}),e.jsx(ut,{id:k?.id,funcName:y})]})}],[y]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Category",placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:x,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"name",label:"Name",defaultValue:l?.name??"",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:bp,children:"Cancel"})]})]})})}),e.jsxs(E,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Add Category"})}),e.jsx(E,{px:3,pb:2,children:e.jsx("form",{onSubmit:w,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Category List"})}),e.jsx(E,{pt:3,children:e.jsx(Me,{parentCallback:v,data:{newData:f,columns:T,columnstype:"antd",action:!1,Loading:c,error:g}})})]})]})]})}const Sp=({token:t})=>e.jsx(jp,{token:t}),Mn=Ye.subCategory,hi=Ye.category.dropdown,vp=({token:t,page:a=1,perPage:s=10})=>en({baseUrl:Mn.list,page:a,perPage:s,token:t}),wp=({token:t})=>G(t&&hi?[hi,t]:null,([s,r])=>J(s,r)),_p=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},Cp={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Ap({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,g]=i.useState(""),{isLoading:f,error:u,data:p,mutate:w}=vp({token:t,page:a.page,perPage:a.rowsPerPage}),{data:v}=wp({token:t}),y=i.useMemo(()=>_p(v),[v]),m=async h=>{try{await w(Xa(Mn.add,h,t),We(h)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(S){_.error(S?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},x=h=>{h.preventDefault();const S=new FormData(h.target);S.set("status","active"),S.set("img",c||""),m(S),h.target.reset(),g("")},T=(h,S)=>{s({page:h,rowsPerPage:parseInt(S,10)})},D=async h=>{try{await w(Za(Mn.remove,h,t),qe(h)),_.success("Success! Deleted item.",{duration:1e3})}catch(S){_.error(S?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},k=h=>{d(h),o(!0)},C=async h=>{h.preventDefault();const S=new FormData(h.target);S.set("id",String(l?.id??"")),c&&S.set("img",c);try{await ja(Mn.edit,S,t),await w(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),g("")}catch(A){_.error(A?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},j=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(h,S)=>String(h?.name??"").localeCompare(String(S?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(h,S)=>String(h?.description??"").localeCompare(String(S?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(h,S)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>k(S),style:{padding:2}}),e.jsx(ut,{id:S?.id,funcName:D})]})}],[D]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Sub Category",placement:"right",width:420,onClose:()=>{o(!1),d(null),g("")},children:e.jsx("form",{onSubmit:C,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Z,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",defaultValue:l?.category_id?y.find(h=>String(h?.value)===String(l.category_id)):null,allowSelectAll:!1,required:!0}),e.jsx(Y,{type:"text",name:"name",label:"Name*",defaultValue:l?.name??"",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:g})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null),g("")},style:Cp,children:"Cancel"})]})]})})}),e.jsxs(E,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Add Sub Category"})}),e.jsx(E,{px:3,pb:2,children:e.jsx("form",{onSubmit:x,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",allowSelectAll:!1,required:!0}),e.jsx(Y,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:g})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Sub Category List"})}),e.jsx(E,{pt:3,children:e.jsx(Me,{parentCallback:T,data:{newData:p,columns:j,columnstype:"antd",action:!1,Loading:f,error:u}})})]})]})]})}const Tp=({token:t})=>e.jsx(Ap,{token:t}),Ts=Ye.product,Dp=Ye.academy.classes,Rp=Ye.academy.sections,Ip=Ye.student.dropdown;function Ia(t){const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]}function xn(t,a){const s=Math.trunc(Number(t)||1),r=Math.max(1,s);return!Number.isFinite(Number(a))||Number(a)<=0?r:Math.min(r,Math.trunc(Number(a)))}function ot(t){return String(t??"")}function kp({token:t}){const[a,s]=i.useState(""),[r,o]=i.useState(""),[l,d]=i.useState(""),[c,g]=i.useState(!1),[f,u]=i.useState(""),[p,w]=i.useState([]),[v,y]=i.useState({}),[m,x]=i.useState({}),[T,D]=i.useState(!1),[k,C]=i.useState(""),[j,h]=i.useState(0),[S,A]=i.useState(""),[R,q]=i.useState(ae()),[U,b]=i.useState([]),O={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},M=!!(a&&r&&l),{data:$}=G(t?[Dp,t]:null,([he,je])=>J(he,je)),F=i.useMemo(()=>Ia($),[$]),N=t&&a?`${Rp}?class_id=${encodeURIComponent(String(a))}`:null,{data:V}=G(N?[N,t]:null,([he,je])=>J(he,je)),z=i.useMemo(()=>Ia(V),[V]),P=t&&a&&r?`${Ip}?class=${encodeURIComponent(String(a))}§ion=${encodeURIComponent(String(r))}`:null,{data:I}=G(P?[P,t]:null,([he,je])=>J(he,je)),B=i.useMemo(()=>Ia(I),[I]),L=M?`${Ts.list}?page=1&per_page=10000`:null,{data:H,isLoading:se}=G(t&&L?[L,t]:null,([he,je])=>J(he,je),{revalidateOnFocus:!1}),W=i.useMemo(()=>Ia(H),[H]),K=i.useMemo(()=>{const he=new Map;return(Array.isArray(W)?W:[]).forEach(je=>{he.set(ot(je?.id),je)}),he},[W]),te=i.useMemo(()=>{const he=Object.entries(m||{});return he.length===0?[]:he.map(([je,be])=>{const ne=K.get(ot(je));return ne?{id:ne?.id,name:ne?.name,barcode:ne?.barcode,stock:Number(ne?.quantity||0),price:Number(ne?.price||0),quantity:xn(be,Number(ne?.quantity||0))}:null}).filter(Boolean)},[m,K]),oe=i.useMemo(()=>new Set(te.map(he=>ot(he?.id))),[te]),pe=i.useMemo(()=>(Array.isArray(te)?te:[]).reduce((je,be)=>je+Number(be?.price||0)*Number(be?.quantity||1),0),[te]),we=i.useMemo(()=>{const he=Number(j||0);return!Number.isFinite(he)||he<=0?0:Math.min(he,pe)},[j,pe]),le=i.useMemo(()=>Math.max(0,pe-we),[we,pe]),de=i.useMemo(()=>(Array.isArray(W)?W:[]).slice(0,30).map(he=>({value:ot(he?.id),label:`${he?.name??""}${he?.barcode?` • ${he.barcode}`:""}${he?.quantity!==void 0&&he?.quantity!==null?` • Stock: ${he.quantity}`:""}`,product:he})),[W]),{trigger:Q}=rt(t&&M?Ts.search:null,(he,{arg:je})=>Kt(he,{arg:je},t));i.useEffect(()=>{if(!M){w([]);return}const he=String(f||"").trim();if(he.length<2){w(de);return}let je=!0;const be=setTimeout(async()=>{let ne=[];try{if(Q){const ge=await Q({search:he});ne=Ia(ge)}}catch{ne=[]}if(!Array.isArray(ne)||ne.length===0){const ge=he.toLowerCase();ne=(Array.isArray(W)?W:[]).filter(re=>{const ye=String(re?.name??"").toLowerCase(),Be=String(re?.barcode??"").toLowerCase();return ye.includes(ge)||Be.includes(ge)}).slice(0,30)}const me=ne.slice(0,30).map(ge=>({value:ot(ge?.id),label:`${ge?.name??""}${ge?.barcode?` • ${ge.barcode}`:""}${ge?.quantity!==void 0&&ge?.quantity!==null?` • Stock: ${ge.quantity}`:""}`,product:ge}));je&&w(me)},250);return()=>{je=!1,clearTimeout(be)}},[de,M,Q,W,f]),i.useEffect(()=>{x({}),y({}),u(""),w([]),D(!1),C(""),h(0),A(""),q(ae()),b([])},[a,r,l]);const ce=i.useCallback((he,je=1)=>{const be=he?.id;if(!be)return;const ne=Number(he?.quantity||0);if(ne<=0){_.error("Out of stock.",{duration:1e3});return}const me=xn(je,ne);x(ge=>{const re=ge||{};return Object.prototype.hasOwnProperty.call(re,ot(be))?(_.error("Product already added.",{duration:1e3}),re):{...re,[ot(be)]:me}})},[x]),Te=i.useCallback((he,je,be)=>{x(ne=>{const me=ne||{},ge=ot(he);return Object.prototype.hasOwnProperty.call(me,ge)?{...me,[ge]:xn(je,be)}:me})},[]),Ee=i.useCallback(he=>{x(je=>{const be=je||{},ne=ot(he);if(!Object.prototype.hasOwnProperty.call(be,ne))return be;const me={...be};return delete me[ne],me})},[]),Ie=i.useCallback((he,je,be)=>{y(ne=>({...ne||{},[ot(he)]:xn(je,be)}))},[]),Le=i.useCallback((he,je)=>{je?.product&&ce(je.product,1),u(""),w(de)},[ce,de]),$e=i.useCallback(he=>{if(he.key!=="Enter")return;he.preventDefault();const je=Array.isArray(p)&&p.length>0?p[0]:null;if(je?.product){ce(je.product,1),u(""),w(de);return}const be=String(f||"").trim().toLowerCase();if(be.length===0)return;const ne=(Array.isArray(W)?W:[]).find(me=>{const ge=String(me?.name??"").toLowerCase(),re=String(me?.barcode??"").toLowerCase();return ge.includes(be)||re.includes(be)});ne&&(ce(ne,1),u(""),w(de))},[ce,de,W,p,f]),et=()=>{if(!t){_.error("Missing token.",{duration:1e3});return}if(!a){_.error("Select class.",{duration:1e3});return}if(!r){_.error("Select section.",{duration:1e3});return}if(!l){_.error("Select student.",{duration:1e3});return}if(!te||te.length===0){_.error("Add at least one product.",{duration:1e3});return}D(!0)},{trigger:He,isMutating:Oe}=rt(t?Ts.sellProduct:null,(he,{arg:je})=>Zn(he,{arg:je},t)),Ke=async()=>{if(!k){_.error("Select payment type.",{duration:1e3});return}const he=(Array.isArray(te)?te:[]).map(be=>({id:be?.id,quantity:Number(be?.quantity||1),price:Number(be?.price||0),total_price:Number(be?.total_price||0),fk_vendor_id:be?.fk_vendor_id||"",fk_categoryID:be?.fk_categoryID||"",name:be?.name||"",class_id:be?.class_id||"",fk_sub_categoryID:be?.fk_sub_categoryID||"",description:be?.description||"",min_quantity:Number(be?.min_quantity||0),storecategory:Number(be?.storecategory||0),barcode:be?.barcode||""})),je={amount:pe,class:a,section:r,student_id:l,payment_type:k,discount:we,notes:S||"",receipt_date:R?ae(R).format("YYYY-MM-DD"):"",product:JSON.stringify(he),total_payable_amount:pe,attchement:U[0]?.originFileObj||""};try{const ne=Array.isArray(U)&&U.length>0&&U[0]?.originFileObj?(()=>{const ge=new FormData;return Object.entries(je).forEach(([re,ye])=>{if(re==="products"){ge.append("product",JSON.stringify(ye));return}ge.append(re,String(ye??""))}),ge.append("attachment",U[0].originFileObj),ge})():je,me=await He(ne);me?.Status==="Success"?(_.success("Success! Product sold.",{duration:1e3}),D(!1),x({}),y({}),u(""),w(de),C(""),h(0),A(""),q(ae()),b([])):_.error(me?.msg??"Failed to submit.",{duration:1e3})}catch{_.error("Failed to submit.",{duration:1e3})}},nt=i.useMemo(()=>[{title:"Product Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Barcode",dataIndex:"barcode",key:"barcode",width:160},{title:"Stock",dataIndex:"quantity",key:"quantity",width:110},{title:"Price",dataIndex:"price",key:"price",width:120},{title:"Quantity",key:"quantity",width:160,render:(he,je)=>{const be=ot(je?.id),ne=Number(je?.quantity||0),me=oe.has(be),ge=(me?m?.[be]:v?.[be])??1;return e.jsx(n.InputNumber,{min:1,max:Number.isFinite(ne)&&ne>0?ne:void 0,value:ge,onChange:re=>{me?Te(be,re,ne):Ie(be,re,ne)},disabled:ne<=0})}},{title:"Amount",key:"amount",width:140,render:(he,je)=>{const be=ot(je?.id),ne=(oe.has(be)?m?.[be]:v?.[be])??1;return Number(je?.price||0)*Number(ne||1)}},{title:"Action",key:"action",width:120,render:(he,je)=>{const be=ot(je?.id),ne=Number(je?.quantity||0),me=oe.has(be),ge=(me?m?.[be]:v?.[be])??1;return me?e.jsx(n.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(ee.DeleteOutlined,{}),onClick:()=>Ee(be),style:{padding:2}}):e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.PlusOutlined,{}),disabled:ne<=0,onClick:()=>ce(je,ge),style:{padding:2}})}}],[ce,oe,m,v,Ee,Ie,Te]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(E,{pt:5,pb:2,children:[e.jsxs(E,{style:{padding:"12px 16px"},children:[e.jsx(E,{children:"Sell Product"}),e.jsx(n.Card,{style:{borderRadius:16},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Z,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,required:!0,onChange:he=>{const je=he?.value??"";s(je),o(""),d(""),g(be=>!be)}}),e.jsx(Z,{options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,required:!0,onChange:he=>{const je=he?.value??"";o(je),d("")}},`section_${c}`),e.jsx(Z,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student_id",placeholder:"Student",allowSelectAll:!1,required:!0,onChange:he=>d(he?.value??"")})]})})]}),e.jsx("div",{style:{padding:"0 16px"},children:e.jsxs(n.Card,{style:{borderRadius:16,marginTop:12},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(260px, 520px) 1fr",gap:12,alignItems:"center",marginBottom:12},children:[e.jsx(E,{style:{marginTop:12},children:"Product Section"}),e.jsx(n.AutoComplete,{value:f,options:p,onSearch:u,onFocus:()=>{M&&String(f||"").trim().length<2&&w(de)},onSelect:Le,disabled:!M,children:e.jsx(n.Input,{placeholder:"Search by product name or barcode",onKeyDown:$e,allowClear:!0})}),e.jsxs("div",{style:{justifySelf:"end",fontWeight:700},children:["Total: ",Tt(pe)]})]}),e.jsx(n.Table,{rowKey:he=>ot(he?.id),columns:nt,dataSource:W,loading:se,size:"small",bordered:!0,pagination:{pageSize:50,showSizeChanger:!0,pageSizeOptions:[25,50,100,200]},scroll:{x:"max-content"}}),e.jsxs("div",{style:{position:"sticky",bottom:0,background:"#fff",paddingTop:12,marginTop:12,borderTop:"1px solid #f0f0f0"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700},children:[e.jsx("span",{children:"Selected Items"}),e.jsx("span",{children:te.length})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700,marginTop:6},children:[e.jsx("span",{children:"Total Amount"}),e.jsx("span",{children:Tt(pe)})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginTop:12},children:[e.jsx(ie,{type:"button",value:"Submit",disabled:!M||te.length===0,onClick:et,style:{flex:1,minWidth:140}}),e.jsx(n.Button,{type:"text",style:O,onClick:()=>{x({}),y({}),u(""),w(de)},disabled:te.length===0,children:"Clear"})]})]})]})})]}),e.jsx(n.Modal,{open:T,title:"Payment",onCancel:()=>D(!1),onOk:Ke,confirmLoading:Oe,okText:"Submit",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Payment Type"}),e.jsx(n.Select,{value:k||void 0,onChange:C,placeholder:"Select payment type",style:{width:"100%"},options:[{value:"Cash",label:"Cash"},{value:"UPI",label:"UPI"},{value:"Bank",label:"Bank"},{value:"Cheque",label:"Cheque"},{value:"DD",label:"DD"},{value:"Internet Banking",label:"Internet Banking"}]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Receipt Date"}),e.jsx(n.DatePicker,{value:R,onChange:he=>q(he),style:{width:"100%"},format:"YYYY-MM-DD"})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Discount"}),e.jsx(n.InputNumber,{min:0,max:pe,value:j,onChange:he=>h(Number(he||0)),style:{width:"100%"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Attachment"}),e.jsx(n.Upload,{fileList:U,beforeUpload:()=>!1,onChange:({fileList:he})=>b((he||[]).slice(-1)),maxCount:1,children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),children:"Upload"})})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Notes"}),e.jsx(n.Input.TextArea,{value:S,onChange:he=>A(he.target.value),rows:3})]}),e.jsx(n.Card,{style:{borderRadius:12,background:"#fafcff"},children:e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Total Amount"}),e.jsx("span",{children:Tt(pe)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Discount"}),e.jsx("span",{children:Tt(we)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700},children:[e.jsx("span",{children:"Net Amount"}),e.jsx("span",{children:Tt(le)})]})]})})]})})]})}const Pp=({token:t})=>e.jsx(kp,{token:t}),En=Ye.unit,Op=({token:t,page:a=1,perPage:s=10})=>en({baseUrl:En.list,page:a,perPage:s,token:t}),Mp={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Ep({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),{isLoading:c,error:g,data:f,mutate:u}=Op({token:t,page:a.page,perPage:a.rowsPerPage}),p=async D=>{try{await u(Xa(En.add,D,t),We(D)),_.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(k){_.error(k?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},w=D=>{D.preventDefault();const k=new FormData(D.target);p(k),D.target.reset()},v=(D,k)=>{s({page:D,rowsPerPage:parseInt(k,10)})},y=async D=>{try{await u(Za(En.remove,D,t),qe(D)),_.success("Success! Deleted item.",{duration:1e3})}catch(k){_.error(k?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},m=D=>{d(D),o(!0)},x=async D=>{D.preventDefault();const k=new FormData(D.target);k.set("id",String(l?.id??""));try{await ja(En.edit,k,t),await u(),_.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch(C){_.error(C?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},T=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(D,k)=>String(D?.name??"").localeCompare(String(k?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(D,k)=>String(D?.description??"").localeCompare(String(k?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(D,k)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>m(k),style:{padding:2}}),e.jsx(ut,{id:k?.id,funcName:y})]})}],[y]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:r,title:l?.name?`Edit ${l.name}`:"Edit Unit",placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:x,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"name",label:"Unit Name",defaultValue:l?.name??"",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Mp,children:"Cancel"})]})]})})}),e.jsxs(E,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Add Unit"})}),e.jsx(E,{px:3,pb:2,children:e.jsx("form",{onSubmit:w,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"name",label:"Unit Name*",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(De,{variant:"h6",color:"white",children:"Unit List"})}),e.jsx(E,{pt:3,children:e.jsx(Me,{parentCallback:v,data:{newData:f,columns:T,columnstype:"antd",action:!1,Loading:c,error:g}})})]})]})]})}const Fp=({token:t})=>e.jsx(Ep,{token:t}),$p=Ye.product.sellReports,Up=Ye.academy.classes,Np=Ye.academy.sections,Bp=Ye.student.dropdown,yi=t=>{const a=Number(t??0);return Number.isFinite(a)?a.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}):String(t??"")};function Lp({token:t}){const a=i.useRef(null),[s,r]=i.useState(null),[o,l]=i.useState(""),[d,c]=i.useState(""),[g,f]=i.useState(""),[u,p]=i.useState(!1),w=b=>{const O=b?.data?.data??b?.data??b??[];return Array.isArray(O)?O:Array.isArray(O?.data)?O.data:[]},{data:v}=G(t?[Up,t]:null,([b,O])=>J(b,O)),y=i.useMemo(()=>w(v),[v]),m=t&&o?`${Np}?class_id=${encodeURIComponent(String(o))}`:null,{data:x}=G(m?[m,t]:null,([b,O])=>J(b,O)),T=i.useMemo(()=>w(x),[x]),D=t&&o&&d?`${Bp}?class=${encodeURIComponent(String(o))}§ion=${encodeURIComponent(String(d))}`:null,{data:k}=G(D?[D,t]:null,([b,O])=>J(b,O)),C=i.useMemo(()=>w(k),[k]),{trigger:j,isMutating:h,data:S}=rt($p,(b,{arg:O})=>Qs(b,{arg:O},t));i.useEffect(()=>{const O=new Date().toISOString().slice(0,10);j({duration:[O,O]})},[j]);const A=i.useMemo(()=>{const b=S?.data??S??[];return Array.isArray(b)?b:[]},[S]),R=b=>{const O=Array.isArray(b?.product_details)?b.product_details:[];return O.length===0?null:e.jsx(n.Table,{size:"small",bordered:!0,pagination:!1,rowKey:M=>`${b?.receipt_id??"r"}_${M?.product_name??M?.product_pricem??""}`,columns:[{title:"Product",dataIndex:"product_name",key:"product_name"},{title:"Amount",dataIndex:"product_pricem",key:"product_pricem",render:M=>yi(M)}],dataSource:O})},q=[{title:"Receipt No",dataIndex:"receipt_no",key:"receipt_no"},{title:"Date",dataIndex:"receipt_date",key:"receipt_date"},{title:"Amount",dataIndex:"receipt_amount",key:"receipt_amount",render:b=>yi(b)}],U=async()=>{if(!s||s.length!==2)return;const[b,O]=s;await j({duration:[b.format("YYYY-MM-DD"),O.format("YYYY-MM-DD")],class:o||"",section:d||"",student_id:g||""})};return e.jsx("div",{children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,lg:8,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Filters"}),style:{borderRadius:16},children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Duration"}),e.jsx(n.DatePicker.RangePicker,{value:s,onChange:r,style:{width:"100%"}})]}),e.jsx(Z,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",placeholder:"Class",allowSelectAll:!1,onChange:b=>{const O=b?.value??"";l(O),c(""),f(""),p(M=>!M)}}),e.jsx(Z,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",placeholder:"Section",allowSelectAll:!1,onChange:b=>{const O=b?.value??"";c(O),f("")}},`section_${u}`),e.jsx(Z,{options:C,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",placeholder:"Student",allowSelectAll:!1,onChange:b=>f(b?.value??"")}),e.jsx(ie,{type:"button",value:h?"Searching...":"Search",disabled:h,onClick:U,style:{width:"100%"}})]})})}),e.jsx(n.Col,{xs:24,lg:16,children:e.jsx(n.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Sell Reports"}),e.jsx(jt,{data:{tableRef:a}})]}),style:{borderRadius:16},children:e.jsxs("div",{ref:a,children:[e.jsx("div",{className:"print-only",children:e.jsx(Pt,{})}),e.jsx(n.Table,{bordered:!0,size:"small",loading:h,rowKey:b=>String(b?.receipt_id??b?.receipt_no??Math.random()),columns:q,expandable:{expandedRowRender:R},dataSource:A,pagination:{pageSize:20}})]})})})]})})}const qp=({token:t})=>e.jsx(Lp,{token:t}),zp=Ye.product;function Yp({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState([]),[l,d]=i.useState([]),[c,g]=i.useState(!1),[f,u]=i.useState(!1),[p,w]=i.useState(null),[v,y]=i.useState(0),[m,x]=i.useState(null),[T,D]=i.useState(""),k=i.useRef(null),C=xa.useReactToPrint({contentRef:k,documentTitle:"Stock Barcodes"}),{isLoading:j,error:h,data:S,mutate:A}=Bo({token:t,page:a.page,perPage:a.rowsPerPage}),R=($,F)=>{s({page:$,rowsPerPage:parseInt(F,10)})},q={selectedRowKeys:r,onChange:($,F)=>{o($),d(F)}},U=$=>{w($),y(Number($?.quantity??0)),x(null),D(""),g(!0)},b=()=>{g(!1),w(null),y(0),x(null),D("")},O=async()=>{if(!p?.id)return;u(!0);const $=new FormData;$.append("product_id",String(p.id)),$.append("qty",String(v??0)),m&&$.append("tran_date",m.format("YYYY-MM-DD")),T&&$.append("remarks",T);try{const F=await ja(zp.addStock,$,t);F?.Status==="Success"?(_.success("Success! Updated quantity.",{duration:1e3}),b(),await A()):_.error(F?.msg??"Failed to update quantity.",{duration:1e3})}catch{_.error("Failed to update quantity.",{duration:1e3})}finally{u(!1)}},M=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,fixed:"left",width:180},{title:"Category",dataIndex:"storecategory",key:"storecategory",ellipsis:!0,responsive:["md"]},{title:"Quantity",dataIndex:"quantity",key:"quantity",width:100},{title:"Unit",dataIndex:"unit_name",key:"unit_name",width:120,responsive:["md"]},{title:"Price",dataIndex:"price",key:"price",width:100,responsive:["md"]},{title:"Barcode",dataIndex:"barcode",key:"barcode",ellipsis:!0,responsive:["lg"]},{title:"Action",key:"action",width:160,fixed:"right",render:($,F)=>e.jsx("div",{style:{display:"flex",gap:8},children:e.jsx(n.Button,{size:"small",onClick:()=>U(F),children:"Update Qty"})})}],[]);return e.jsxs("div",{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:p?.name?`Update Stock: ${p.name}`:"Update Stock",open:c,onCancel:b,onOk:O,okButtonProps:{loading:f},children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Quantity"}),e.jsx(n.InputNumber,{min:0,style:{width:"100%"},value:v,onChange:$=>y($??0)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{style:{width:"100%"},value:m,onChange:x})]}),e.jsx(vt,{label:"Remarks",name:"remarks",rows:3,value:T,onChange:$=>D($.target.value)})]})}),e.jsxs(E,{pt:5,pb:2,children:[e.jsxs(E,{children:["Manage Stock",e.jsx(ie,{type:"button",value:"Print Barcodes",disabled:!l||l.length===0,onClick:()=>C?.(),style:{minWidth:170}})]}),e.jsx(E,{style:{padding:"12px 16px"},children:e.jsx(n.Card,{style:{borderRadius:16},children:e.jsx(Me,{parentCallback:R,data:{newData:S,columns:M,columnstype:"antd",action:!1,Loading:j,error:h,rowSelection:q}})})})]}),e.jsx("div",{style:{position:"absolute",left:-1e4,top:0},children:e.jsx("div",{ref:k,children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:16,padding:24},children:(Array.isArray(l)?l:[]).map($=>e.jsxs("div",{style:{border:"1px solid #ddd",padding:12},children:[e.jsx("div",{style:{marginBottom:6,fontSize:12},children:$?.name??""}),e.jsx(ao,{value:String($?.barcode??$?.id??""),height:50,width:1.6,displayValue:!0})]},$?.id??$?.barcode??$?.name))})})})]})}const Vp=({token:t})=>e.jsx(Yp,{token:t}),Wp=Ye.report.stock,Hp=Ye.product.dropdown,Kp=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function Gp({token:t}){const a=i.useRef(null),[s,r]=i.useState(null),[o,l]=i.useState(""),{data:d}=G(t?[Hp,t]:null,([y,m])=>J(y,m)),c=i.useMemo(()=>Kp(d),[d]),{trigger:g,isMutating:f,data:u}=rt(Wp,(y,{arg:m})=>Qs(y,{arg:m},t));i.useEffect(()=>{const m=new Date().toISOString().slice(0,10);g({duration:[m,m]})},[g]);const p=i.useMemo(()=>{const y=u?.data??u??[];return(Array.isArray(y)?y:[]).flatMap(x=>(Array.isArray(x?.ledger)?x.ledger:[]).map((T,D)=>({key:`${x.product_id??x.product_name??"p"}-${D}`,date:T?.date,product:x?.product_name,opening:T?.opening,inward:T?.inward,outward:T?.outward,closing:T?.closing})))},[u]),w=[{title:"Date",dataIndex:"date",key:"date"},{title:"Product",dataIndex:"product",key:"product"},{title:"Opening",dataIndex:"opening",key:"opening"},{title:"Inward",dataIndex:"inward",key:"inward"},{title:"Outward",dataIndex:"outward",key:"outward"},{title:"Closing",dataIndex:"closing",key:"closing",render:y=>e.jsx("span",{style:{color:Number(y)<0?"red":"green"},children:y})}],v=async()=>{if(!s||s.length!==2)return;const[y,m]=s;await g({duration:[y.format("YYYY-MM-DD"),m.format("YYYY-MM-DD")],product_id:o||""})};return e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Stock Report"}),style:{borderRadius:16},children:[e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center",marginBottom:16,flexWrap:"wrap"},children:[e.jsx(n.DatePicker.RangePicker,{value:s,onChange:r}),e.jsxs("select",{value:o,onChange:y=>l(y.target.value),style:{height:32,borderRadius:6,border:"1px solid #d9d9d9",padding:"0 8px"},children:[e.jsx("option",{value:"",children:"All Products"}),c.map(y=>e.jsx("option",{value:String(y?.value??""),children:String(y?.label??"")},String(y?.value??y?.id??y?.label)))]}),e.jsx(n.Button,{type:"primary",onClick:v,loading:f,children:"Search"}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(jt,{data:{tableRef:a}})})]}),e.jsxs("div",{ref:a,children:[e.jsx("div",{className:"print-only",children:e.jsx(Pt,{})}),e.jsx(n.Table,{bordered:!0,size:"small",loading:f,rowKey:"key",columns:w,dataSource:p,pagination:{pageSize:50}})]})]})}const Jp=({token:t})=>e.jsx(Gp,{token:t}),gi=[{label:"Today",value:"Today"},{label:"Yesterday",value:"Yesterday"},{label:"This Week",value:"This Week"},{label:"This Month",value:"This Month"},{label:"Last Month",value:"Last Month"},{label:"This Year",value:"This Year"},{label:"Custom",value:"Custom"}],It={total_packages:124,total_downloads:45892,active_packages:118,deprecated_packages:6,pending_approval:3,published_this_month:12,published_this_week:4,packages_needing_update:8,packages_with_issues:2},xi=[{npm_id:"NPM-001",package_name:"@ubk/erp-core",version:"1.2.1",description:"Core ERP utilities and shared types",author:"UBK Infotech",repository:"https://github.com/ubk/erp-core",license:"MIT",status:"published",created_at:"2024-01-15",updated_at:"2025-06-20"},{npm_id:"NPM-002",package_name:"@ubk/erp-components",version:"2.0.0",description:"Reusable Ant Design ERP component library",author:"UBK Infotech",repository:"https://github.com/ubk/erp-components",license:"ISC",status:"published",created_at:"2024-03-10",updated_at:"2025-08-01"},{npm_id:"NPM-003",package_name:"@ubk/erp-api-client",version:"0.9.5",description:"Axios-based API client for UBK ERP backends",author:"UBK Infotech",repository:"https://github.com/ubk/erp-api-client",license:"MIT",status:"draft",created_at:"2025-05-22",updated_at:"2025-07-14"},{npm_id:"NPM-004",package_name:"@ubk/erp-hooks",version:"1.1.0",description:"Custom React hooks for ERP workflows",author:"UBK Infotech",repository:"https://github.com/ubk/erp-hooks",license:"MIT",status:"published",created_at:"2024-08-05",updated_at:"2025-04-30"},{npm_id:"NPM-005",package_name:"@ubk/erp-utils",version:"3.2.1",description:"Utility functions for date, currency, and validation",author:"UBK Infotech",repository:"https://github.com/ubk/erp-utils",license:"ISC",status:"deprecated",created_at:"2023-11-20",updated_at:"2025-02-10"}],bi=[{key:"dashboard",label:"Dashboard"},{key:"allPackages",label:"All Packages"},{key:"published",label:"Published"},{key:"draft",label:"Draft"},{key:"deprecated",label:"Deprecated"},{key:"pendingApproval",label:"Pending Approval"}];function Qp(){const[t,a]=i.useState("dashboard"),[s,r]=i.useState("This Month"),[o,l]=i.useState(""),[d,c]=i.useState(""),[g,f]=i.useState(1),[u,p]=i.useState(10),[w,v]=i.useState(""),y=i.useRef(null),m=["dashboard","allPackages","published","draft","deprecated","pendingApproval"].includes(t),x=i.useMemo(()=>{if(!w.trim())return xi;const j=w.toLowerCase();return xi.filter(h=>Object.values(h).some(S=>String(S??"").toLowerCase().includes(j)))},[w]),T=i.useMemo(()=>{const j=(g-1)*u;return x.slice(j,j+u)},[x,g,u]),D=()=>{f(1)},k=()=>{const j=[{title:"Total Packages",value:It.total_packages,icon:e.jsx(ee.FileTextOutlined,{}),color:"#1976d2"},{title:"Total Downloads",value:It.total_downloads.toLocaleString(),icon:e.jsx(ee.StarOutlined,{}),color:"#2e7d32"},{title:"Active Packages",value:It.active_packages,icon:e.jsx(ee.CheckCircleOutlined,{}),color:"#0288d1"},{title:"Deprecated",value:It.deprecated_packages,icon:e.jsx(ee.CloseCircleOutlined,{}),color:"#d32f2f"},{title:"Pending Approval",value:It.pending_approval,icon:e.jsx(ee.ClockCircleOutlined,{}),color:"#ed6c02"},{title:"Published This Month",value:It.published_this_month,icon:e.jsx(ee.CalendarOutlined,{}),color:"#9c27b0"},{title:"Published This Week",value:It.published_this_week,icon:e.jsx(ee.SyncOutlined,{}),color:"#455a64"},{title:"Needs Update",value:It.packages_needing_update,icon:e.jsx(ee.CodeOutlined,{}),color:"#c62828"},{title:"With Issues",value:It.packages_with_issues,icon:e.jsx(ee.CloseCircleOutlined,{}),color:"#f57c00"}];return e.jsx(n.Row,{gutter:[16,16],children:j.map((h,S)=>e.jsx(n.Col,{xs:24,sm:12,md:8,lg:6,children:e.jsxs(n.Card,{style:{display:"flex",alignItems:"center",padding:16,borderLeft:`6px solid ${h.color}`,transition:"0.2s",cursor:"default"},bodyStyle:{display:"flex",alignItems:"center",width:"100%"},children:[e.jsx(E,{style:{width:48,height:48,borderRadius:"50%",backgroundColor:`${h.color}15`,color:h.color,display:"flex",alignItems:"center",justifyContent:"center",fontSize:22,marginRight:16,flexShrink:0},children:h.icon}),e.jsxs(E,{children:[e.jsx(n.Typography.Text,{type:"secondary",style:{fontSize:12,fontWeight:500},children:h.title}),e.jsx("div",{style:{fontSize:22,fontWeight:700,marginTop:4},children:h.value})]})]})},S))})},C=()=>{const j=[{title:"NPM ID",dataIndex:"npm_id",key:"npm_id",width:100},{title:"Package Name",dataIndex:"package_name",key:"package_name",ellipsis:!0},{title:"Version",dataIndex:"version",key:"version",width:100},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,responsive:["md"]},{title:"Author",dataIndex:"author",key:"author",width:140,responsive:["lg"]},{title:"License",dataIndex:"license",key:"license",width:100},{title:"Status",dataIndex:"status",key:"status",width:120,render:h=>{let S="default";return h==="published"?S="green":h==="draft"?S="orange":h==="deprecated"?S="red":h==="pending"&&(S="blue"),e.jsx(n.Tag,{color:S,children:h.toUpperCase()})}},{title:"Created Date",dataIndex:"created_at",key:"created_at",width:120,responsive:["lg"]},{title:"Updated Date",dataIndex:"updated_at",key:"updated_at",width:120,responsive:["lg"]},{title:"Actions",key:"action",width:120,fixed:"right",render:(h,S)=>e.jsx("a",{style:{color:"#5080f8",cursor:"pointer",fontSize:13},children:"View"})}];return t==="dashboard"?[]:j};return e.jsx(E,{pt:5,pb:1,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"NPM Package Report"})}),e.jsxs(E,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],mb:3,children:[m&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Z,{options:gi,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Date Range",allowSelectAll:!1,value:gi.find(j=>j.value===s)||null,onChange:j=>r(j?.value||"This Month")})}),s==="Custom"&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Ue,{Desplay:"From Date",format:"YYYY-MM-DD",onChange:j=>l(j?j.format("YYYY-MM-DD"):"")})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Ue,{Desplay:"To Date",format:"YYYY-MM-DD",onChange:j=>c(j?j.format("YYYY-MM-DD"):"")})})]})]}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(E,{display:"flex",alignItems:"center",height:"100%",mt:t==="dashboard"?0:2,children:e.jsx(ie,{type:"button",value:"Search",color:"primary",onClick:D})})})]}),e.jsx(n.Tabs,{activeKey:t,onChange:a,items:bi})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(E,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:bi.find(j=>j.key===t)?.label||"Report"})}),e.jsxs(E,{p:3,children:[t!=="dashboard"&&e.jsx(jt,{data:{tableRef:y}}),t==="dashboard"?k():e.jsx(n.Table,{size:"small",dataSource:T,columns:C(),loading:!1,pagination:!1,bordered:!0,rowKey:j=>j.npm_id||j.package_name||Math.random(),ref:y}),t!=="dashboard"&&x.length>0&&e.jsx(n.Pagination,{current:g,pageSize:u,total:x.length,onChange:(j,h)=>{f(j),p(h)},showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:[10,20,50,100],style:{marginTop:16,textAlign:"right"}})]})]})})]})})}const ts=t=>t??localStorage.getItem("authToken")??"",ar=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},Re={upload:"api/branchapi/frontoffice/uploadfrontofficeDocument",roleDropdown:"api/Branch/getRoledropdownforBranch",staff:{list:"api/branchapi/staff/stafflist",searchByRole:"api/branchapi/staff/staffsearchbyRole",searchByKeywords:"api/branchapi/staff/staffsearchbyKeywords",deactivate:"api/branchapi/staff/staff_deactive",basicById:"api/branchapi/staff/getbasicdetailsbyID",experienceById:"api/branchapi/staff/getworkexperencebyID",payrollById:"api/branchapi/staff/getpayrollbyID",lastEmpNo:"api/branchapi/staff/getLastStaffEMPnumber",addBasic:"api/branchapi/staff/addstaffbasicdetails",editBasic:"api/branchapi/staff/editstaffbasicdetails",addExperience:"api/branchapi/staff/addstaffExperience",editExperience:"api/branchapi/staff/editstaffExperience",addPayroll:"api/branchapi/staff/addstaffpayroll",editPayroll:"api/branchapi/staff/editstaffpayroll",uploadProfile:"api/branchapi/staff/uploadstaffProfilepicture",uploadDocuments:"api/branchapi/staff/uploadDocuments"},master:{shift:{dropdown:"api/branchapi/generalSettings/shiftDropdown",table:"api/branchapi/generalSettings/shiftTable",add:"api/branchapi/generalSettings/shiftTable",add:"api/branchapi/generalSettings/addshift",edit:"api/branchapi/generalSettings/addshift",edit:"api/branchapi/generalSettings/editshift",remove:"api/branchapi/generalSettings/deleteshift",show:"api/branchapi/generalSettings/shiftShowdata"},department:{dropdown:"api/branchapi/humanResource/departmentDropdown",table:"api/branchapi/humanResource/departmenttypeTable",add:"api/branchapi/humanResource/adddepartment",edit:"api/branchapi/humanResource/editdepartment",remove:"api/branchapi/humanResource/deletedepartment",show:"api/branchapi/humanResource/departmentShowdata"},designation:{dropdown:"api/branchapi/humanResource/designationDropdown",table:"api/branchapi/humanResource/designationTable",add:"api/branchapi/humanResource/adddesignation",edit:"api/branchapi/humanResource/editdesignation",remove:"api/branchapi/humanResource/deletedesignation",show:"api/branchapi/humanResource/designationShowdata"},leaveType:{dropdown:"api/branchapi/humanResource/leavetypeDropdown",table:"api/branchapi/humanResource/LeavetypeTable",add:"api/branchapi/humanResource/addleavetype",edit:"api/branchapi/humanResource/editleavetype",remove:"api/branchapi/humanResource/deleteleavetype",show:"api/branchapi/humanResource/leavetypeShowdata"}},leave:{table:"api/branchapi/humanResource/LeaveTable",apply:"api/branchapi/humanResource/applyLeave",requestTable:"api/branchapi/humanResource/leaverequestTable",approveRequest:"api/branchapi/humanResource/approveleaveRequest"},attendance:{staffListForAttendance:"api/staff/attendence/stafflistforAttendence",staffDropdownByRole:"api/staff/attendence/getStaffDropDownByRoleId",addAttendanceToStaffByBranch:"api/staff/attendence/addattendencetoStaffbyBranch",manualAttendance:"api/staff/attendence/staffMenualAttendance",staffShiftByStaffId:"api/branchapi/staff/getStaffShiftByStaffId",dailyAttendance:"api/staff/attendence/dailyAttendance",dailyAttendanceMultipleShift:"api/staff/attendence/dailyAttendanceMultipleShift"},attendanceReport:{monthlyStaffReport:"api/AttendenceReport/staffmonthlyAttendenceReport_new",staffAttendanceList:"api/AttendenceReport/staffAttendanceList",overallStaffReport:"api/staff/attendence/getAlloverAttendenceReportofStaff"},payroll:{monthlyGraph:"api/branchapi/reportGraph/monthlyPayroleReportgraph",staffPayrollByStaffId:"api/branchapi/humanResource/getStaffPayroleByStaffID",generatePayslip:"api/branchapi/humanResource/generatePayslip",payrollByRole:"api/branchapi/humanResource/getpayrolebyRole",monthlyReport:"api/branchapi/humanResource/monthlyPayRolereport"}},Lo=()=>ar(at(),Re.upload),Xp=()=>ar(at(),Re.staff.uploadProfile),Zp=()=>ar(at(),Re.staff.uploadDocuments),em=async({baseUrl:t,page:a=1,perPage:s=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return J(l,ts(r))},Dt=async(t,a,s)=>Ne(t,a,ts(s)),qt=async(t,a,s)=>Qe(t,a,ts(s)),tn=async(t,a,s)=>Ve(t,a,ts(s)),Gt=Re.staff,tm=Re.master.shift.dropdown,am=Re.master.department.dropdown,nm=Re.master.designation.dropdown,sm=Re.roleDropdown,bn=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},rm=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",ka={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},ji={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function im({token:t,mode:a,staffId:s,initialValues:r,onSubmitted:o}){const l=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))}catch{return null}},[]),d=String(l?.multiple_shift??"").toLowerCase()==="yes",[c,g]=i.useState(r?.roleValue??null),[f,u]=i.useState(r?.departmentValue??null),[p,w]=i.useState(r?.designationValue??null),[v,y]=i.useState(r?.genderValue??null),[m,x]=i.useState(r?.shiftValue??(d?[]:null)),[T,D]=i.useState(r?.dob?ae(r.dob):null),[k,C]=i.useState(r?.doj?ae(r.doj):null),[j,h]=i.useState(r?.file??""),{data:S}=G(t?[tm,t]:null,([V,z])=>J(V,z)),{data:A}=G(t?[am,t]:null,([V,z])=>J(V,z)),{data:R}=G(t?[nm,t]:null,([V,z])=>J(V,z)),{data:q}=G(t?[sm,t]:null,([V,z])=>J(V,z)),{data:U}=G(t?[Gt.lastEmpNo,t]:null,([V,z])=>J(V,z)),b=i.useMemo(()=>bn(S),[S]),O=i.useMemo(()=>bn(A),[A]),M=i.useMemo(()=>bn(R),[R]),$=i.useMemo(()=>bn(q),[q]),F=i.useMemo(()=>{const V=U?.data?.emp_number??U?.emp_number??U?.data??"";return String(V??"")},[U]),N=async V=>{V.preventDefault();const z=new FormData(V.target);z.set("role",c?.value??c??""),z.set("department",f?.value??f??""),z.set("designation",p?.value??p??""),z.set("gender",v?.value??v??""),z.set("dob",T?T.format("YYYY-MM-DD"):""),z.set("doj",k?k.format("YYYY-MM-DD"):""),d?(z.delete("shift_id"),(Array.isArray(m)?m:[]).forEach(I=>{z.append("shift_id[]",I?.value??I??"")})):z.set("shift_id",m?.value??m??""),j&&z.set("file",j);try{const P=a==="edit"&&s,I=P?Gt.editBasic:Gt.addBasic;P&&z.set("staff_id",String(s));const B=P?await qt(I,z,t):await Dt(I,z,t),L=B?.ID??B?.id??s??null;_.success("Success!",{duration:1e3}),o?.({staffId:L,basic:{roleValue:c,departmentValue:f,designationValue:p,genderValue:v,shiftValue:m,dob:T,doj:k,file:j}})}catch(P){_.error(P?.response?.data?.msg??P?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"number",name:"emp_number",label:"EMP No",defaultValue:r?.emp_number??F,required:!0}),e.jsx(Y,{type:"text",name:"f_name",label:"First Name",defaultValue:r?.f_name??"",required:!0}),e.jsx(Y,{type:"text",name:"l_name",label:"Last Name",defaultValue:r?.l_name??"",required:!0}),e.jsx(Y,{type:"text",name:"pan_no",label:"PAN",defaultValue:r?.pan_no??""}),e.jsx(Y,{type:"text",name:"adhar_no",label:"Aadhar",defaultValue:r?.adhar_no??""}),e.jsx(Z,{label:"Role",options:$,value:c,onChange:V=>g(V??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Z,{label:"Department",options:O,value:f,onChange:V=>u(V??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Z,{label:"Designation",options:M,value:p,onChange:V=>w(V??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Z,{label:"Gender",options:[{value:"Male",label:"Male"},{value:"Female",label:"Female"},{value:"Other",label:"Other"}],value:v,onChange:V=>y(V??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Y,{type:"text",name:"email",label:"Email",defaultValue:r?.email??""}),e.jsxs("div",{children:[e.jsx("div",{style:ka,children:"DOB"}),e.jsx(n.DatePicker,{value:T,onChange:V=>D(V),style:ji,placeholder:"Select DOB"})]}),e.jsxs("div",{children:[e.jsx("div",{style:ka,children:"DOJ"}),e.jsx(n.DatePicker,{value:k,onChange:V=>C(V),style:ji,placeholder:"Select DOJ"})]}),e.jsx(Y,{type:"text",name:"bloodGroup",label:"Blood Group",defaultValue:r?.bloodGroup??""}),e.jsx(Y,{type:"text",name:"contact_no",label:"Contact No",defaultValue:r?.contact_no??"",required:!0}),e.jsx(Y,{type:"text",name:"education",label:"Education",defaultValue:r?.education??""}),e.jsxs("div",{children:[e.jsx("div",{style:ka,children:"Shift"}),e.jsx(Z,{options:b,value:m,onChange:V=>x(V??(d?[]:null)),isMulti:d,closeMenuOnSelect:!d,hideSelectedOptions:!1,allowSelectAll:!1,required:!0})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{style:ka,children:"Profile Picture"}),e.jsx(n.Upload,{maxCount:1,action:Xp(),headers:t?{Authorization:t}:void 0,onChange:V=>{if(V?.file?.status==="done"){const z=rm(V?.file?.response);z&&h(z)}V?.file?.status==="removed"&&h("")},children:e.jsx(n.Button,{type:"link",style:{paddingLeft:0},children:j?"Change":"Upload"})})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:ka,children:"Address"}),e.jsx("textarea",{name:"address",rows:3,defaultValue:r?.address??"",placeholder:"Address",style:{width:"100%",resize:"vertical",padding:10,border:"1px solid #d9d9d9",borderRadius:8,outline:"none"}})]}),e.jsx("div",{style:{gridColumn:"1 / -1",display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save & Next",color:"primary"})})]})})}const jn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Si={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},om=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",vi=t=>{if(!t)return null;const a=ae(t);return a.isValid()?a:null};function lm({token:t,mode:a,staffId:s,initialRows:r,onSubmitted:o,onBack:l}){const[d,c]=i.useState(()=>(Array.isArray(r)&&r.length?r:[{name:"",from:null,to:null,image:""}]).map(y=>({name:y?.name??"",from:vi(y?.from),to:vi(y?.to),image:y?.image??""}))),g=i.useMemo(()=>t?{Authorization:t}:void 0,[t]),f=(v,y)=>{c(m=>m.map((x,T)=>T===v?{...x,...y}:x))},u=()=>c(v=>[...v,{name:"",from:null,to:null,image:""}]),p=v=>c(y=>y.length<=1?y:y.filter((m,x)=>x!==v)),w=async v=>{if(v.preventDefault(),!s){_.error("Missing staff id.",{duration:1e3});return}const y=new FormData;y.append("staff_id",String(s)),d.forEach((m,x)=>{y.append(`experience[${x}][name]`,String(m?.name??"")),y.append(`experience[${x}][from]`,m?.from?m.from.format("YYYY-MM-DD"):""),y.append(`experience[${x}][to]`,m?.to?m.to.format("YYYY-MM-DD"):""),y.append(`experience[${x}][image]`,String(m?.image??""))});try{const m=a==="edit",x=m?Gt.editExperience:Gt.addExperience,T=m?await qt(x,y,t):await Dt(x,y,t);_.success("Success!",{duration:1e3}),o?.({experience:d,result:T})}catch(m){_.error(m?.response?.data?.msg??m?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:w,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[d.map((v,y)=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end",border:"1px solid #eee",borderRadius:12,padding:14},children:[e.jsxs("div",{children:[e.jsx("div",{style:jn,children:"Name"}),e.jsx("input",{value:v.name,onChange:m=>f(y,{name:m.target.value}),placeholder:"Company / School",style:{width:"100%",height:40,border:"none",borderBottom:"1px solid #d9d9d9",outline:"none",background:"transparent"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:jn,children:"From"}),e.jsx(n.DatePicker,{value:v.from,onChange:m=>f(y,{from:m}),style:Si})]}),e.jsxs("div",{children:[e.jsx("div",{style:jn,children:"To"}),e.jsx(n.DatePicker,{value:v.to,onChange:m=>f(y,{to:m}),style:Si})]}),e.jsxs("div",{children:[e.jsx("div",{style:jn,children:"Document"}),e.jsx(n.Upload,{maxCount:1,action:Zp(),headers:g,onChange:m=>{if(m?.file?.status==="done"){const x=om(m?.file?.response);x&&f(y,{image:x})}m?.file?.status==="removed"&&f(y,{image:""})},children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),children:"Upload"})}),!!v.image&&e.jsx("div",{style:{fontSize:12,color:"#666",marginTop:6},children:v.image})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:e.jsx(n.Button,{type:"text",icon:e.jsx(ee.DeleteOutlined,{}),danger:!0,onClick:()=>p(y),disabled:d.length<=1})})]},`exp-${y}`)),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12},children:[e.jsx(n.Button,{icon:e.jsx(ee.PlusOutlined,{}),onClick:u,children:"Add Experience"}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(n.Button,{onClick:l,children:"Back"}),e.jsx(ie,{type:"submit",value:"Save & Next",color:"primary"})]})]})]})})}const wi=(t,a=[])=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){const s=a.length?a:["allowances","Allowances","dedection","Dedection","deductions","Deductions"],r=[t];t?.data&&typeof t.data=="object"&&r.push(t.data);for(const l of r)for(const d of s){const c=l?.[d]??l?.[d.toLowerCase()]??l?.[d.toUpperCase()];if(Array.isArray(c)&&c.length>0)return c}const o=t?.data;if(Array.isArray(o)&&o.length>0)return o}return[]},Pa=[{label:"Per Hour",value:"Hourly"},{label:"Per Lecture",value:"lecture_wise"}];function dm({token:t,mode:a,staffId:s,initialValues:r,onSubmitted:o,onBack:l}){const[d,c]=i.useState(r?.type??"Permanent"),[g,f]=i.useState(r?.salary_type??Pa[0]?.value),[u,p]=i.useState(Number(r?.amount??0)),[w,v]=i.useState(Number(r?.basic_pay)),[y,m]=i.useState(r?.declarationPERyear??""),{data:x}=G(t?[Wd,t]:null,([h,S])=>J(h,S),{revalidateOnFocus:!1}),T=i.useMemo(()=>wi(x,["allowances","Allowances"]),[x]),D=i.useMemo(()=>wi(x,["dedection","Dedection","deductions","Deductions"]),[x]),k=i.useMemo(()=>{const h=Number(w||0),S=(Array.isArray(T)?T:[]).map(b=>{const O=b?.amount_type??b?.amountType??b?.type??"",M=Number(b?.Amount??b?.amount??0),F=String(O).trim().toLowerCase()==="flat"?M:Number(h)/100*Number(M||0);return{...b,value:Number.isFinite(F)?F:0}}),A=(Array.isArray(D)?D:[]).map(b=>{const O=b?.amount_type??b?.amountType??b?.type??"",M=Number(b?.Amount??b?.amount??0),F=String(O).trim().toLowerCase()==="flat"?M:Number(h)/100*Number(M||0);return{...b,value:Number.isFinite(F)?F:0}}),R=S.reduce((b,O)=>b+Number(O?.value||0),0),q=A.reduce((b,O)=>b+Number(O?.value||0),0),U=Math.max(0,Number(h)+R-q);return{allowances:S,deductions:A,netAmount:U}},[T,D,w]),C=async h=>{if(h.preventDefault(),!s){_.error("Missing staff id.",{duration:1e3});return}const S=new FormData;S.append("staff_id",String(s)),S.append("type",d),d==="Nonpermanent"?(S.append("salary_type",g??""),S.append("amount",String(u||"")),S.append("Allowances",JSON.stringify([])),S.append("Dedection",JSON.stringify([]))):(S.append("basic_pay",String(w||"")),S.append("declarationPERyear",String(y??"")),S.append("Allowances",JSON.stringify(k.allowances||[])),S.append("Dedection",JSON.stringify(k.deductions||[])),S.append("amount",String(k.netAmount||0)));try{const A=a==="edit",R=A?Gt.editPayroll:Gt.addPayroll,q=A?await qt(R,S,t):await Dt(R,S,t);o?.({payroll:{staffType:d,salaryType:g,amount:u,basicPay:w,declaration:y},result:q})}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed.",{duration:1e3})}},j=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",ellipsis:!0},{title:"Amount",key:"amount",width:160,render:(h,S)=>`${S?.Amount??""} / ${S?.amount_type??""}`},{title:"Value",dataIndex:"value",key:"value",width:120}],[]);return e.jsx("form",{onSubmit:C,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{label:"Employment Type",options:[{label:"Permanent",value:"Permanent"},{label:"Non Permanent",value:"Nonpermanent"}],value:{label:d==="Nonpermanent"?"Non Permanent":"Permanent",value:d},onChange:h=>c(h?.value??"Permanent"),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),d==="Nonpermanent"?e.jsxs(e.Fragment,{children:[e.jsx(Z,{label:"Type",options:Pa,value:Pa.find(h=>h.value===g)??Pa[0],onChange:h=>f(h?.value??Pa[0]?.value),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Y,{type:"number",label:"Amount",value:u,onChange:h=>p(Number(h.target.value||0)),required:!0})]}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{type:"number",label:"Basic Pay",value:w,onChange:h=>v(Number(h.target.value||0)),required:!0}),e.jsx(Y,{type:"text",label:"IT Declarations/Year",value:y,onChange:h=>m(h.target.value)}),e.jsx(Y,{type:"number",label:"Net Amount",value:k.netAmount,disabled:!0})]})]}),d==="Permanent"&&e.jsxs(e.Fragment,{children:[e.jsx(n.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Allowances"}),children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(h,S)=>`${h?.title??"a"}-${S}`,columns:j,dataSource:k.allowances,pagination:!1})}),e.jsx(n.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Deductions"}),children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(h,S)=>`${h?.title??"d"}-${S}`,columns:j,dataSource:k.deductions,pagination:!1})})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:e.jsx(ie,{type:"submit",value:"Finish",color:"primary"})})]})})}const cm=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function um({token:t,mode:a="add",staffId:s,onFinished:r}){const[o,l]=i.useState(0),[d,c]=i.useState(s??null),[g,f]=i.useState(null),[u,p]=i.useState(null),[w,v]=i.useState(null),y=a==="edit"?s??d:null,m=i.useMemo(()=>y?`${Re.staff.basicById}?staff_id=${encodeURIComponent(String(y))}`:null,[y]),x=i.useMemo(()=>y?`${Re.staff.experienceById}?staff_id=${encodeURIComponent(String(y))}`:null,[y]),T=i.useMemo(()=>y?`${Re.staff.payrollById}?staff_id=${encodeURIComponent(String(y))}`:null,[y]),{data:D}=G(t&&m?[m,t]:null,([R,q])=>J(R,q)),{data:k}=G(t&&x?[x,t]:null,([R,q])=>J(R,q)),{data:C}=G(t&&T?[T,t]:null,([R,q])=>J(R,q)),j=i.useMemo(()=>{const R=cm(D)[0]??D?.data??D??null;return R?{emp_number:R?.emp_number??R?.empNo??"",f_name:R?.f_name??R?.firstname??R?.first_name??"",l_name:R?.l_name??R?.lastname??R?.last_name??"",pan_no:R?.pan_no??"",adhar_no:R?.adhar_no??"",email:R?.email??"",dob:R?.dob??"",doj:R?.doj??"",bloodGroup:R?.bloodGroup??R?.blood_group??"",contact_no:R?.contact_no??R?.phone??"",education:R?.education??"",address:R?.address??"",file:R?.file??R?.profile_picture??""}:null},[D]),h=i.useMemo(()=>{const R=k?.data??k??null;return(Array.isArray(R?.experience)?R.experience:Array.isArray(R)?R:[]).map(U=>({name:U?.name??"",from:U?.from??"",to:U?.to??"",image:U?.image??""}))},[k]),S=i.useMemo(()=>{const R=C?.data??C??null;return R?{type:R?.type??"Permanent",salary_type:R?.salary_type??"",amount:R?.amount??"",basic_pay:R?.basic_pay??"",declarationPERyear:R?.declarationPERyear??""}:null},[C]),A=i.useMemo(()=>[{title:"Basic"},{title:"Experience"},{title:"Payroll"}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:a==="edit"?"Edit Staff":"Add Staff"}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(n.Steps,{current:o,items:A}),o===0&&e.jsx(im,{token:t,mode:a,staffId:y,initialValues:j,onSubmitted:({staffId:R})=>{R&&c(R),l(1)}}),o===1&&e.jsx(lm,{token:t,mode:a,staffId:y??d,initialRows:h,onBack:()=>l(0),onSubmitted:()=>l(2)}),o===2&&e.jsx(dm,{token:t,mode:a,staffId:y??d,initialValues:S,onBack:()=>l(1),onSubmitted:()=>{_.success("Completed.",{duration:1e3}),r?.({staffId:y??d}),l(0),a!=="edit"&&(c(null),f(null),p(null),v(null))}})]})})]})}function pm({token:t}){return e.jsx(um,{token:t,mode:"add"})}const mm=({token:t})=>e.jsx(pm,{token:t}),Sn=Re.staff,fm=Re.roleDropdown,hm=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},ym=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function gm({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(""),[l,d]=i.useState(""),{data:c}=G(t?[fm,t]:null,([T,D])=>J(T,D)),g=i.useMemo(()=>hm(c),[c]),f=i.useMemo(()=>{const T=a.page,D=a.rowsPerPage,k=r&&!l?`${Sn.searchByRole}?role_id=${encodeURIComponent(String(r))}`:l?`${Sn.searchByKeywords}?key=${encodeURIComponent(String(l))}`:Sn.list,C=k.includes("?")?"&":"?";return`${k}${C}page=${encodeURIComponent(String(T))}&per_page=${encodeURIComponent(String(D))}`},[a.page,a.rowsPerPage,l,r]),{isLoading:u,error:p,data:w,mutate:v}=G(t?[f,t]:null,([T,D])=>J(T,D)),y=i.useMemo(()=>ym(w),[w]),m=async T=>{const D=T?.id??T?.fk_staffID??T?.staff_id;if(D)try{await tn(Sn.deactivate,D,t),_.success("Success! Staff deactivated.",{duration:1e3}),await v()}catch(k){_.error(k?.response?.data?.msg??k?.message??"Failed to deactivate staff.",{duration:1e3})}},x=i.useMemo(()=>[{title:"Name",key:"name",ellipsis:!0,render:(T,D)=>`${D?.firstname??D?.first_name??""} ${D?.lastname??D?.last_name??""}`.trim()||D?.name||""},{title:"Role",dataIndex:"role_name",key:"role_name",ellipsis:!0,responsive:["md"]},{title:"Phone",dataIndex:"phone",key:"phone",ellipsis:!0,responsive:["md"]},{title:"Email",dataIndex:"email",key:"email",ellipsis:!0,responsive:["lg"]},{title:"Status",dataIndex:"status",key:"status",width:120,responsive:["lg"]},{title:"Action",key:"action",width:90,fixed:"right",render:(T,D)=>e.jsx(n.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(ee.DeleteOutlined,{}),onClick:()=>m(D),style:{padding:2}})}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20,alignItems:"start"},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:3,style:{margin:0},children:"Filters"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:[{value:"",label:"All Roles"},...g],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Role",placeholder:"Role",allowSelectAll:!1,onChange:T=>{o(T?.value??""),s(D=>({...D,page:1}))}}),e.jsx(Y,{type:"text",label:"Keyword",value:l,onChange:T=>d(T.target.value),placeholder:"Search by keywords"}),e.jsx(ie,{type:"button",value:"Refresh",onClick:()=>v()})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:7,style:{margin:0},children:"Staff Directory"}),children:e.jsx(n.Table,{bordered:!0,size:"small",loading:u,rowKey:T=>String(T?.id??T?.fk_staffID??T?.staff_id??Math.random()),columns:x,dataSource:y,pagination:{current:a.page,pageSize:a.rowsPerPage,onChange:(T,D)=>s({page:T,rowsPerPage:D}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})]})}const xm=({token:t})=>e.jsx(gm,{token:t}),bm=Re.attendance,jm=Re.roleDropdown,_i=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},vn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Ci={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Sm({token:t,open:a,onClose:s,roleId:r,onSaved:o}){const[l,d]=i.useState(null),[c,g]=i.useState(""),[f,u]=i.useState(ae()),[p,w]=i.useState(ae()),[v,y]=i.useState(ae()),m=i.useMemo(()=>r?`${Re.attendance.staffDropdownByRole}?role_id=${encodeURIComponent(String(r))}`:null,[r]),{data:x}=G(t&&m?[m,t]:null,([h,S])=>J(h,S)),T=i.useMemo(()=>_i(x),[x]),{trigger:D,data:k}=rt(t?Re.attendance.staffShiftByStaffId:null,(h,{arg:S})=>Kt(h,{arg:S},t)),C=i.useMemo(()=>_i(k),[k]),j=async()=>{if(!l?.value){_.error("Select staff.",{duration:1e3});return}if(!c){_.error("Select shift.",{duration:1e3});return}const h=new FormData;h.set("staffID",String(l.value)),h.set("shift_id",String(c)),h.set("attendance_date",f?f.format("YYYY-MM-DD"):""),h.set("intime",p?p.format("h:mm a"):""),h.set("outime",v?v.format("h:mm a"):"");try{await Dt(Re.attendance.manualAttendance,h,t),_.success("Success!",{duration:1e3}),o?.(),s?.(),d(null),g(""),u(ae()),w(ae()),y(ae())}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed.",{duration:1e3})}};return e.jsx(n.Modal,{open:a,onCancel:s,footer:null,destroyOnClose:!0,title:"Attendance",width:620,children:e.jsx(n.Card,{children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Z,{label:"Staff",options:T,value:l,onChange:async h=>{if(d(h??null),g(""),h?.value&&D)try{await D({staff_id:h.value})}catch{}},closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:vn,children:"Shift"}),e.jsx(n.Radio.Group,{value:c,onChange:h=>g(h.target.value),style:{display:"grid",gap:8},children:C.map(h=>e.jsx(n.Radio,{value:h?.value,children:h?.label??h?.name??h?.title??String(h?.value??"")},String(h?.value)))})]}),e.jsxs("div",{children:[e.jsx("div",{style:vn,children:"Date"}),e.jsx(n.DatePicker,{value:f,onChange:h=>h&&u(h),style:{width:"100%"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:vn,children:"Start Time"}),e.jsx(n.TimePicker,{value:p,onChange:h=>h&&w(h),use12Hours:!0,format:"h:mm a",style:Ci})]}),e.jsxs("div",{children:[e.jsx("div",{style:vn,children:"End Time"}),e.jsx(n.TimePicker,{value:v,onChange:h=>h&&y(h),use12Hours:!0,format:"h:mm a",style:Ci})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(n.Button,{onClick:s,children:"Cancel"}),e.jsx(ie,{type:"button",value:"Save",color:"primary",onClick:j})]})]})})})}const vm=({tableRef:t,excelDisabled:a})=>{const s=new Date().getTime(),r=xa.useReactToPrint({content:()=>t?.current});return e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(n.Row,{gutter:8,children:[e.jsx(n.Col,{children:e.jsx(n.Button,{type:"text",icon:e.jsx(ee.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:r})}),e.jsx(n.Col,{children:a?e.jsx(n.Button,{type:"text",icon:e.jsx(ee.FileTextOutlined,{style:{color:"gray"}}),onClick:()=>_.error("You must save attendance before download",{duration:2e3})}):e.jsx(Mo.DownloadTableExcel,{filename:s,sheet:"users",currentTableRef:t?.current,children:e.jsx(n.Button,{type:"text",icon:e.jsx(ee.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})},wm=(t,a)=>{const s=t?.data?.data??t?.data??t??null;return s?a==="student"?Array.isArray(s?.student)?s.student:[]:Array.isArray(s?.staff)?s.staff:[]:[]},_m=t=>{const a=t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.total??t?.total_rows,s=Number(a);return Number.isFinite(s)&&s>=0?s:0},Cm=(t,a)=>{const s=t?.data?.data??t?.data??t??null;return s?a==="student"?{sunday:String(s?.sunday??"").toLowerCase()==="yes",holiday:String(s?.holiday??"").toLowerCase()==="yes"}:{sunday:!!s?.sunday,holiday:!!s?.holiday}:{sunday:!1,holiday:!1}};function Am({token:t,url:a,columns:s,reload:r,setReload:o,saveBtnRef:l,setSaveBtnDisabled:d,date:c,type:g="staff"}){const f=i.useRef(null),[u,p]=i.useState({page:0,rowsPerPage:10}),[w,v]=i.useState(!1),[y,m]=i.useState(!1),[x,T]=i.useState(null),[D,k]=i.useState([]),[C,j]=i.useState({sunday:!1,holiday:!1}),[h,S]=i.useState(!0);i.useEffect(()=>{p(U=>({...U,page:0}))},[a]),i.useEffect(()=>{let U=!0;return(async()=>{if(!(!t||!a)){v(!0);try{const O=String(a).includes("?")?"&":"?",M=`${a}${O}page=${u.page+1}&per_page=${u.rowsPerPage}`,$=await J(M,t);if(!U)return;T($),$?.Status==="Success"?(d?.(!1),k(wm($,g)),j(Cm($,g))):(d?.(!0),k([]),j({sunday:!1,holiday:!1}))}catch{if(!U)return;d?.(!0),k([])}finally{U&&v(!1)}}})(),()=>{U=!1}},[u.page,u.rowsPerPage,r,d,t,g,a]);const A=i.useMemo(()=>_m(x),[x]);i.useEffect(()=>{const U=(Array.isArray(D)?D:[]).find(b=>b?.attendence_type_id===null);S(!!U)},[D]);const R=async()=>{if(t){m(!0);try{if(g==="staff"){const U=(Array.isArray(D)?D:[]).map(b=>({staff_id:b?.staff_id,attendence_type_id:b?.attendence_type_id?b.attendence_type_id:"1",in_time:b?.intime,out_time:b?.outtime,date:c}));await Dt(Re.attendance.addAttendanceToStaffByBranch,U,t),_.success("Attendance saved successfully",{duration:2e3}),o?.(b=>!b)}else _.error("Student attendance save is not migrated yet.",{duration:2e3})}catch(U){_.error(U?.response?.data?.msg??U?.message??"Failed required dates",{duration:2e3})}finally{m(!1)}}},q=i.useMemo(()=>(Array.isArray(s)?s:[]).map(b=>b?.selector==="attendence_type_id"?{title:b?.name??"Attendance",dataIndex:b.selector,key:b.selector,render:O=>O==null||O===""?e.jsx(n.Tag,{color:"orange",children:"Not Set"}):String(O)==="1"?e.jsx(n.Tag,{color:"green",children:"Present"}):String(O)==="4"?e.jsx(n.Tag,{color:"red",children:"Absent"}):String(O)==="3"?e.jsx(n.Tag,{color:"orange",children:"Late"}):e.jsx(n.Tag,{children:String(O)})}:b?.selector==="snum"?{title:b?.name??"Sl",key:b.selector,render:(O,M,$)=>$+1}:{title:b?.name??b?.selector,dataIndex:b?.selector,key:b?.selector}),[s]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(n.Card,{children:[e.jsx(vm,{tableRef:f,excelDisabled:h}),e.jsx(n.Modal,{open:y,footer:null,closable:!1,centered:!0,children:e.jsxs("div",{style:{display:"grid",placeItems:"center",gap:12,padding:12},children:[e.jsx(n.Spin,{size:"large"}),e.jsx("div",{children:"Please wait..."})]})}),C.sunday?e.jsx("div",{style:{textAlign:"center",fontWeight:600,padding:"16px 0"},children:"Weekly Off"}):C.holiday?e.jsx("div",{style:{textAlign:"center",padding:"16px 0"},children:e.jsx("div",{style:{fontWeight:700,marginBottom:6},children:"Holiday"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:f,children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(U,b)=>String(U?.id??U?.staff_id??b),columns:q,dataSource:D,loading:w,pagination:{current:u.page+1,pageSize:u.rowsPerPage,total:A,showSizeChanger:!0,onChange:(U,b)=>p({page:U-1,rowsPerPage:b})},scroll:{x:"max-content"}})}),e.jsx("button",{type:"button",onClick:R,ref:l,style:{display:"none"},children:"hidden"})]})]})]})}const Tm=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Dm={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Rm({token:t}){const[a,s]=i.useState(""),[r,o]=i.useState(ae().format("YYYY-MM-DD")),[l,d]=i.useState(!1),[c,g]=i.useState(null),[f,u]=i.useState(!1),[p,w]=i.useState(!0),[v,y]=i.useState(!1),m=i.useRef(null),{data:x}=G(t?[jm,t]:null,([k,C])=>J(k,C)),T=i.useMemo(()=>Tm(x),[x]),D=i.useMemo(()=>[{id:"1",name:"Staff Id",selector:"employee_id",sortable:!0},{id:"2",name:"Name",selector:"full_name",sortable:!0},{id:"4",name:"Contact",selector:"contact_no",sortable:!0},{id:"3",name:"Attendance",selector:"attendence_type_id",sortable:!0},{id:"5",name:"In Time",selector:"intime",sortable:!0},{id:"6",name:"Out Time",selector:"outtime",sortable:!0}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,onChange:k=>s(k?.value??""),required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{defaultValue:ae(),onChange:k=>k&&o(k.format("YYYY-MM-DD")),style:Dm,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"button",value:"Search",color:"primary",onClick:()=>{!a||!r||(g(`${bm.staffListForAttendance}?role=${encodeURIComponent(String(a))}&date=${encodeURIComponent(String(r))}`),d(k=>!k))}})})]})}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap",marginBottom:12},children:[e.jsx(n.Button,{size:"small",type:f?"primary":"default",onClick:()=>u(k=>!k),children:f?"Marked":"Mark As Holiday"}),e.jsx(n.Button,{size:"small",type:"default",disabled:p,onClick:()=>y(!0),children:"Give Attendance"})]}),c?e.jsx(Am,{token:t,url:c,columns:D,reload:l,setReload:d,saveBtnRef:m,setSaveBtnDisabled:w,date:r,type:"staff",holidayChecked:f}):null]}),e.jsx(Sm,{token:t,open:v,onClose:()=>y(!1),roleId:a,onSaved:()=>d(k=>!k)})]})}const Im=({token:t})=>e.jsx(Rm,{token:t}),Ai=Re.attendanceReport.monthlyStaffReport,km=Re.roleDropdown,Pm=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Om({token:t}){const a=i.useRef(null),[s,r]=i.useState(!1),[o,l]=i.useState([]),[d,c]=i.useState({role:"",rolllabel:"",year:"",month:""}),g=i.useMemo(()=>Zs(5),[]),{data:f}=G(t?[km,t]:null,([U,b])=>J(U,b)),u=i.useMemo(()=>Pm(f),[f]),[p,w]=i.useState([]),[v,y]=i.useState(1),[m,x]=i.useState(!1),[T,D]=i.useState(!1),[k,C]=i.useState(null),j=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.session_id??"1"}catch{return"1"}},[]),{trigger:h}=rt(t&&Ai?`${Ai}?page=${v}&per_page=3`:null,(U,{arg:b})=>Kt(U,{arg:b},t),{onSuccess:U=>{x(!1);const b=Array.isArray(U)?U:[];b.length>0&&w(O=>[...O||[],...b]),b.length>1?y(O=>O+1):D(!1)},onError:()=>{x(!1),D(!1)}});i.useEffect(()=>{T&&h&&k&&h(k)},[T,v,k,h]);const S=i.useMemo(()=>{const U=[{title:"Staff Id",dataIndex:"employee_id",key:"employee_id",align:"center"},{title:"Name",dataIndex:"full_name",key:"full_name",render:(b,O)=>e.jsx("span",{className:"attendanceFont",style:{cursor:"pointer",whiteSpace:"nowrap",color:"blue",textDecoration:"underline"},children:O?.full_name??""})}];return Array.isArray(p)&&p.length>0&&((p[0]?.monthly_data??[]).forEach((O,M)=>{U.push({title:M+1,align:"center",key:String(M+1),render:($,F)=>{const N=F?.monthly_data?.[M]?.[0]?.data?.[0]??{},V=N?.intime??"",z=N?.outtime??"",P=N?.attendance_type??"";return e.jsx(n.Tooltip,{title:e.jsxs("div",{style:{fontSize:12},children:[e.jsxs("div",{children:["In Time ",V]}),e.jsxs("div",{children:["Out Time ",z]})]}),placement:"top",children:e.jsx("span",{className:"attendanceFont",style:{fontSize:10,display:"flex",justifyContent:"center"},children:Ze(P)})})}})}),U.push({title:"Total",key:"Total",render:(O,M)=>{const $=M?.monthly_data??[],F=$.filter(V=>V?.[0]?.data?.[0]?.attendance_type==="A").length,N=$.filter(V=>V?.[0]?.data?.[0]?.attendance_type==="P").length;return e.jsx("span",{className:"attendanceFont",children:e.jsxs("b",{children:["A : ",F," P : ",N]})})}})),U},[p]),A=i.useMemo(()=>[{label:"Present",el:Ze("P")},{label:"Absent",el:Ze("A")},{label:"Leave",el:Ze("L")},{label:"Weekly Off",el:Ze("W")},{label:"Holiday",el:Ze("H")}],[]),R=i.useMemo(()=>d.month?o.find(U=>U?.value==d.month)?.label??d.month??"--":"--",[d.month,o]),q=async U=>{if(U.preventDefault(),!d.role||!d.year||!d.month)return;y(1),x(!0),w([]);const b={session:j,year:d.year,month:d.month,day:"01",role:d.role};C(b),D(!0),await h?.(b)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{className:"d-print-none",title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Attendance Report"}),children:e.jsx("form",{onSubmit:q,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:u,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:U=>c(b=>({...b,role:U?.value??"",rolllabel:U?.label??""}))}),e.jsx(Z,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:U=>{const b=er(U?.value);l(b),r(O=>!O),c(O=>({...O,year:U?.label??""}))}}),e.jsx(Z,{options:o,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:U=>c(b=>({...b,month:U?.value??""}))},`month-${s}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Monthly Attendance Report"}),children:e.jsxs("div",{ref:a,children:[e.jsx("div",{className:"print-only",children:e.jsx(Pt,{})}),e.jsxs("div",{style:{border:"1px solid #ddd",borderRadius:8,padding:16,marginBottom:24,backgroundColor:"#f8f9fa"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:12,alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:18,fontWeight:600,marginBottom:6},children:"Staff Attendance Summary"}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:10,fontSize:13},children:[e.jsxs("div",{children:["Role: ",e.jsx("span",{style:{fontWeight:700},children:d.rolllabel||"--"})]}),e.jsxs("div",{children:["Year: ",e.jsx("span",{style:{fontWeight:700},children:d.year||"--"})]}),e.jsxs("div",{children:["Month: ",e.jsx("span",{style:{fontWeight:700},children:R})]})]})]}),e.jsx("div",{className:"d-print-none",style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(jt,{data:{tableRef:a}})})]}),e.jsx("div",{style:{marginTop:14,paddingTop:14,borderTop:"1px solid #e0e0e0"},children:e.jsx("div",{style:{display:"flex",justifyContent:"center",flexWrap:"wrap",gap:12,fontSize:12},children:A.map(U=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsxs("div",{children:[U.label," :"]}),e.jsx("div",{children:U.el})]},U.label))})})]}),e.jsx(n.Skeleton,{active:!0,loading:m,paragraph:{rows:10},children:e.jsx(n.Table,{size:"small",bordered:!0,className:"my-zero-padding-table",columns:S,dataSource:p,pagination:!1,scroll:{x:"max-content"},rowKey:(U,b)=>String(U?.staff_id??U?.id??b)})})]})})]})}const Mm=({token:t})=>e.jsx(Om,{token:t}),Ti=Re.payroll,Em=Re.roleDropdown,Fm=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},$m=t=>t?.data?.data??t?.data??t??[];function Um({token:t,receiptDetailsPath:a="/HumanResourceDashboard/PayrollReceiptDetails",onOpenReceiptDetails:s}){const[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),[c,g]=i.useState([]),[f,u]=i.useState({role:"",roleLabel:"",year:"",month:""}),[p,w]=i.useState(null),v=S=>{if(!S)return;if(typeof s=="function"){s(S);return}const A=`${a}?id=${encodeURIComponent(String(S))}`;typeof window<"u"&&window?.location&&(window.location.href=A)},{data:y}=G(t?[Em,t]:null,([S,A])=>J(S,A)),m=i.useMemo(()=>Fm(y),[y]),x=i.useMemo(()=>Zs(5),[]),{isLoading:T,error:D,data:k}=G(t&&p?[p,t]:null,([S,A])=>J(S,A)),C=i.useMemo(()=>{const S=$m(k);return Array.isArray(S)?S:[]},[k]),j=i.useMemo(()=>{const S=k?.pagination?.total_rows??k?.data?.pagination?.total_rows??k?.total??k?.total_rows,A=Number(S);return Number.isFinite(A)&&A>=0?A:C.length},[k,C.length]),h=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(S,A,R)=>R+1},{title:"Name",dataIndex:"full_name",key:"full_name",ellipsis:!0},{title:"Designations",dataIndex:"designations",key:"designations",ellipsis:!0,responsive:["md"]},{title:"Mobile No",dataIndex:"contact_no",key:"contact_no",width:140,responsive:["md"]},{title:"Status",dataIndex:"status",key:"status",width:120,align:"center",render:(S,A)=>{const R=A?.id??A?.staff_id??A?.staffId;return e.jsx(n.Button,{type:"link",size:"small",style:{padding:0,fontSize:12},onClick:()=>{v(R)},children:Po(A?.status)})}}],[]);return e.jsx("div",{style:{display:"grid",gap:20},children:e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll"}),children:[e.jsx("form",{onSubmit:S=>{if(S.preventDefault(),!f.role||!f.year||!f.month)return;const A=`${Ti.payrollByRole}?page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.rowsPerPage))}&role=${encodeURIComponent(String(f.role))}&year=${encodeURIComponent(String(f.year))}&month=${encodeURIComponent(String(f.month))}`;w(A)},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end",marginBottom:14,padding:14,borderRadius:12,border:"1px solid #eee",background:"#fafafa"},children:[e.jsx(Z,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:S=>u(A=>({...A,role:S?.value??"",roleLabel:S?.label??""}))}),e.jsx(Z,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:S=>{const A=er(S?.value);g(A),d(R=>!R),u(R=>({...R,year:S?.label??"",month:""}))}}),e.jsx(Z,{options:c,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:S=>u(A=>({...A,month:S?.value??""}))},`month-${l}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Search",color:"primary",onClick:()=>o(S=>({...S,page:1}))})})]})}),e.jsx(n.Table,{bordered:!0,size:"small",loading:T,rowKey:(S,A)=>String(S?.id??S?.staff_id??A),columns:h,dataSource:C,pagination:{current:r.page,pageSize:r.rowsPerPage,total:j,showSizeChanger:!0,onChange:(S,A)=>{o({page:S,rowsPerPage:A}),!(!f.role||!f.year||!f.month)&&w(`${Ti.payrollByRole}?page=${encodeURIComponent(String(S))}&per_page=${encodeURIComponent(String(A))}&role=${encodeURIComponent(String(f.role))}&year=${encodeURIComponent(String(f.year))}&month=${encodeURIComponent(String(f.month))}`)}},scroll:{x:"max-content"}})]})})}const Nm=({token:t})=>e.jsx(Um,{token:t}),qo=Re.leave,Sa=({baseUrl:t,page:a=1,perPage:s=10,token:r})=>G(r&&t?[t,a,s,r]:null,([l,d,c,g])=>em({baseUrl:l,page:d,perPage:c},g)),Bm=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:qo.requestTable,page:a,perPage:s}),Lm=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},qm=(t,a)=>{const s=new FormData;return Object.entries(t??{}).forEach(([r,o])=>{o!=null&&s.append(r,String(o))}),s.set("status",a),s};function zm({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),{isLoading:r,error:o,data:l,mutate:d}=Bm({token:t,page:a.page,perPage:a.rowsPerPage}),c=i.useMemo(()=>Lm(l),[l]),g=async(u,p)=>{try{const w=qm(u,p),v=await qt(qo.approveRequest,w,t);v?.Status==="Success"?_.success("Success! Updated request.",{duration:1e3,icon:"🚀"}):_.error(v?.msg??"Failed to update request.",{duration:1e3}),await d()}catch(w){_.error(w?.response?.data?.msg??w?.message??"Failed to update request.",{duration:1e3})}},f=i.useMemo(()=>[{title:"Name",key:"full_name",ellipsis:!0,render:(u,p)=>p?.full_name??p?.staff_name??""},{title:"From",key:"leave_from",width:120,render:(u,p)=>p?.leave_from??p?.from_date??""},{title:"To",key:"leave_to",width:120,render:(u,p)=>p?.leave_to??p?.to_date??""},{title:"Leave Type",key:"leavetype",ellipsis:!0,render:(u,p)=>p?.leavetype??p?.leave_type??""},{title:"Leave Days",key:"leave_days",width:110,render:(u,p)=>p?.leave_days??""},{title:"Remarks",key:"employee_remark",ellipsis:!0,responsive:["md"],render:(u,p)=>p?.employee_remark??p?.reason??""},{title:"View",key:"document_file",width:140,render:(u,p)=>{const w=p?.document_file;return w?e.jsx(n.Button,{size:"small",onClick:()=>window.open(w,"_blank","noopener,noreferrer"),children:"View Document"}):"-"}},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(u,p)=>{const w=String(p?.status??"").toLowerCase();return w==="approved"?e.jsx(n.Tag,{color:"green",children:"Approved"}):w==="declined"?e.jsx(n.Tag,{color:"red",children:"Declined"}):e.jsxs("div",{style:{display:"flex",justifyContent:"center",gap:10},children:[e.jsx(n.Button,{type:"text",size:"small",onClick:()=>g(p,"approved"),icon:e.jsx(ee.CheckOutlined,{style:{color:"#06c937"}})}),e.jsx(n.Button,{type:"text",size:"small",onClick:()=>g(p,"declined"),icon:e.jsx(ee.CloseOutlined,{style:{color:"#e80911"}})})]})}}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Approve Leave Requests"}),children:e.jsx(n.Table,{bordered:!0,size:"small",loading:r,rowKey:(u,p)=>String(u?.id??u?.leave_id??p),columns:f,dataSource:c,pagination:{current:a.page,pageSize:a.rowsPerPage,onChange:(u,p)=>s({page:u,rowsPerPage:p}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const Ym=({token:t})=>e.jsx(zm,{token:t}),Vm=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Wm=({token:t,value:a,onChange:s})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(n.Upload,{maxCount:1,action:Lo(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=Vm(o?.file?.response);l&&s?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})})},zo=Re.leave,Hm=Re.master.leaveType.dropdown,Km=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:zo.table,page:a,perPage:s}),Gm=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Ds={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Jm({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(""),[c]=n.Form.useForm(),{isLoading:g,error:f,data:u,mutate:p}=Km({token:t,page:a.page,perPage:a.rowsPerPage}),{data:w}=G(t?[Hm,t]:null,([C,j])=>J(C,j)),v=i.useMemo(()=>Gm(w),[w]),y=(C,j)=>s({page:C,rowsPerPage:parseInt(j,10)}),m=()=>{d(""),c.resetFields(),c.setFieldsValue({apply_date:ae()}),o(!0)},x=()=>{o(!1),d(""),c.resetFields()},T=async C=>{const j=new FormData;j.set("apply_date",C?.apply_date?C.apply_date.format("YYYY-MM-DD"):""),j.set("leave_type",C?.leave_type?.value??C?.leave_type??""),j.set("from_date",C?.from_date?C.from_date.format("YYYY-MM-DD"):""),j.set("to_date",C?.to_date?C.to_date.format("YYYY-MM-DD"):""),j.set("reason",C?.reason??""),l&&j.set("file",l);try{await Dt(zo.apply,j,t),_.success("Success! Leave request submitted.",{duration:1e3}),x(),await p()}catch(h){_.error(h?.response?.data?.msg??h?.message??"Failed to submit leave request.",{duration:1e3})}},D=i.useMemo(()=>{const C=u?.data??u??[];return Array.isArray(C)?C:Array.isArray(C?.data)?C.data:[]},[u]),k=i.useMemo(()=>[{title:"Leave Type",key:"leavetype",render:(C,j)=>j?.leavetype??j?.leave_type??""},{title:"Apply Date",key:"date",width:130,render:(C,j)=>j?.date??j?.apply_date??""},{title:"From",key:"leave_from",width:130,render:(C,j)=>j?.leave_from??j?.from_date??""},{title:"To",key:"leave_to",width:130,render:(C,j)=>j?.leave_to??j?.to_date??""},{title:"Approval Status",dataIndex:"status",key:"status",width:140},{title:"Remark",key:"employee_remark",render:(C,j)=>j?.employee_remark??"",ellipsis:!0,responsive:["md"]}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:r,title:"Add Leave Request",onCancel:x,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:c,layout:"vertical",onFinish:T,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"apply_date",rules:[{required:!0,message:"Select date"}],children:e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{style:Ds})]})}),e.jsx(n.Form.Item,{name:"leave_type",rules:[{required:!0,message:"Select leave type"}],children:e.jsx(Z,{options:v,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Leave Type",allowSelectAll:!1})}),e.jsx(n.Form.Item,{name:"from_date",rules:[{required:!0,message:"Select from date"}],children:e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"From"}),e.jsx(n.DatePicker,{style:Ds})]})}),e.jsx(n.Form.Item,{name:"to_date",rules:[{required:!0,message:"Select to date"}],children:e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"To"}),e.jsx(n.DatePicker,{style:Ds})]})}),e.jsx(n.Form.Item,{name:"reason",rules:[{required:!0,message:"Enter reason"}],children:e.jsx(Y,{type:"text",label:"Reason",placeholder:"Reason"})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:22},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222"},children:"Attachment"}),e.jsx(Wm,{token:t,value:l,onChange:d})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:12},children:[e.jsx(n.Button,{onClick:x,children:"Cancel"}),e.jsx(ie,{type:"submit",value:"Save",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Apply Leave"}),extra:e.jsx(ie,{type:"button",value:"Add Leave Request",onClick:m})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Leave Requests"}),children:e.jsx(n.Table,{bordered:!0,size:"small",loading:g,rowKey:(C,j)=>String(C?.id??C?.leave_id??j),columns:k,dataSource:D,pagination:{current:a.page,pageSize:a.rowsPerPage,onChange:(C,j)=>y(C,j),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const Qm=({token:t})=>e.jsx(Jm,{token:t}),Fn=Re.master.leaveType,Xm=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:Fn.table,page:a,perPage:s});function Zm({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=i.useState(!1),[c,g]=i.useState(null),{isLoading:f,error:u,data:p,mutate:w}=Xm({token:t,page:a.page,perPage:a.rowsPerPage}),v=(C,j)=>{s({page:C,rowsPerPage:parseInt(j,10)})},y=async C=>{const j=new FormData;j.set("title",C?.title??"");try{await w(Dt(Fn.add,j,t),We(j)),_.success("Success! Added new leave type.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(h){_.error(h?.response?.data?.msg??h?.message??"Failed to add leave type.",{duration:1e3})}},m=C=>{g(C??null),o.setFieldsValue({title:C?.leave_type_name??C?.name??""}),d(!0)},x=()=>{d(!1),g(null),o.resetFields()},T=async C=>{const j=c?.id??c?.leave_type_id;if(!j){_.error("Missing leave type id.",{duration:1e3});return}const h=new FormData;h.set("id",String(j)),h.set("title",C?.title??"");try{await qt(Fn.edit,h,t),await w(),_.success("Success! Updated leave type.",{duration:1e3,icon:"🚀"}),x()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to update leave type.",{duration:1e3})}},D=async C=>{const j=C?.id??C?.leave_type_id;if(j)try{await w(tn(Fn.remove,j,t),qe(j)),_.success("Success! Deleted leave type.",{duration:1e3})}catch(h){_.error(h?.response?.data?.msg??h?.message??"Failed to delete leave type.",{duration:1e3})}},k=i.useMemo(()=>[{title:"Name",dataIndex:"type",key:"type",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(C,j)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>m(j)}),e.jsx(n.Popconfirm,{title:"Remove leave type?",okText:"Yes",cancelText:"No",onConfirm:()=>D(j),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:l,title:"Edit Leave Type",onCancel:x,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:T,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:x,children:"Cancel"}),e.jsx(ie,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Leave Type"}),children:e.jsxs(n.Form,{form:r,layout:"vertical",onFinish:y,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsx(ie,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Leave Type List"}),children:e.jsx(Me,{parentCallback:v,data:{newData:p,columns:k,columnstype:"antd",action:!1,Loading:f,error:u}})})]})}const ef=({token:t})=>e.jsx(Zm,{token:t}),$n=Re.master.department,tf=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:$n.table,page:a,perPage:s});function af({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=i.useState(!1),[c,g]=i.useState(null),{isLoading:f,error:u,data:p,mutate:w}=tf({token:t,page:a.page,perPage:a.rowsPerPage}),v=(C,j)=>{s({page:C,rowsPerPage:parseInt(j,10)})},y=async C=>{const j=new FormData;j.set("title",C?.title??"");try{await w(Dt($n.add,j,t),We(j)),_.success("Success! Added new department.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(h){_.error(h?.response?.data?.msg??h?.message??"Failed to add department.",{duration:1e3})}},m=C=>{g(C??null),o.setFieldsValue({title:C?.department_name??C?.name??""}),d(!0)},x=()=>{d(!1),g(null),o.resetFields()},T=async C=>{const j=c?.id??c?.department_id;if(!j){_.error("Missing department id.",{duration:1e3});return}const h=new FormData;h.set("id",String(j)),h.set("title",C?.title??"");try{await qt($n.edit,h,t),await w(),_.success("Success! Updated department.",{duration:1e3,icon:"🚀"}),x()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to update department.",{duration:1e3})}},D=async C=>{const j=C?.id??C?.department_id;if(j)try{await w(tn($n.remove,j,t),qe(j)),_.success("Success! Deleted department.",{duration:1e3})}catch(h){_.error(h?.response?.data?.msg??h?.message??"Failed to delete department.",{duration:1e3})}},k=i.useMemo(()=>[{title:"Name",dataIndex:"department_name",key:"department_name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(C,j)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>m(j)}),e.jsx(n.Popconfirm,{title:"Remove department?",okText:"Yes",cancelText:"No",onConfirm:()=>D(j),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:l,title:"Edit Department",onCancel:x,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:T,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:x,children:"Cancel"}),e.jsx(ie,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Department"}),children:e.jsxs(n.Form,{form:r,layout:"vertical",onFinish:y,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsx(ie,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Department List"}),children:e.jsx(Me,{parentCallback:v,data:{newData:p,columns:k,columnstype:"antd",action:!1,Loading:f,error:u}})})]})}const nf=({token:t})=>e.jsx(af,{token:t}),Un=Re.master.designation,sf=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:Un.table,page:a,perPage:s});function rf({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=i.useState(!1),[c,g]=i.useState(null),{isLoading:f,error:u,data:p,mutate:w}=sf({token:t,page:a.page,perPage:a.rowsPerPage}),v=(C,j)=>{s({page:C,rowsPerPage:parseInt(j,10)})},y=async C=>{const j=new FormData;j.set("title",C?.title??"");try{await w(Dt(Un.add,j,t),We(j)),_.success("Success! Added new designation.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(h){_.error(h?.response?.data?.msg??h?.message??"Failed to add designation.",{duration:1e3})}},m=C=>{g(C??null),o.setFieldsValue({title:C?.designation??""}),d(!0)},x=()=>{d(!1),g(null),o.resetFields()},T=async C=>{const j=c?.id??c?.designation_id;if(!j){_.error("Missing designation id.",{duration:1e3});return}const h=new FormData;h.set("id",String(j)),h.set("title",C?.title??"");try{await qt(Un.edit,h,t),await w(),_.success("Success! Updated designation.",{duration:1e3,icon:"🚀"}),x()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to update designation.",{duration:1e3})}},D=async C=>{const j=C?.id??C?.designation_id;if(j)try{await w(tn(Un.remove,j,t),qe(j)),_.success("Success! Deleted designation.",{duration:1e3})}catch(h){_.error(h?.response?.data?.msg??h?.message??"Failed to delete designation.",{duration:1e3})}},k=i.useMemo(()=>[{title:"Name",dataIndex:"designation",key:"designation",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(C,j)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>m(j)}),e.jsx(n.Popconfirm,{title:"Remove designation?",okText:"Yes",cancelText:"No",onConfirm:()=>D(j),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:l,title:"Edit Designation",onCancel:x,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:T,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:x,children:"Cancel"}),e.jsx(ie,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Designation"}),children:e.jsxs(n.Form,{form:r,layout:"vertical",onFinish:y,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsx(ie,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Designation List"}),children:e.jsx(Me,{parentCallback:v,data:{newData:p,columns:k,columnstype:"antd",action:!1,Loading:f,error:u}})})]})}const of=({token:t})=>e.jsx(rf,{token:t}),Nn=Re.master.shift,lf=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:Nn.table,page:a,perPage:s}),lt="hh:mm A",da=t=>{const a=String(t??"");if(!a)return null;const s=ae(a,[lt,"HH:mm","HH:mm:ss"],!0);return s.isValid()?s:null},ca=t=>t?t.format(lt):"",bt={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function df({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=i.useState(!1),[c,g]=i.useState(null),{isLoading:f,error:u,data:p,mutate:w}=lf({token:t,page:a.page,perPage:a.rowsPerPage}),v=(h,S)=>{s({page:h,rowsPerPage:parseInt(S,10)})},y=(h,S)=>{const A=new FormData;return S&&A.set("id",String(S)),A.set("name",h?.name??""),A.set("start_time",ca(h?.start_time)),A.set("end_time",ca(h?.end_time)),A.set("shift_start_from",ca(h?.shift_start_from)),A.set("shift_start_to",ca(h?.shift_start_to)),A.set("shift_end_from",ca(h?.shift_end_from)),A.set("shift_end_to",ca(h?.shift_end_to)),A},m=async h=>{try{const S=y(h);await w(Dt(Nn.add,S,t),We(S)),_.success("Success! Added new shift.",{duration:1e3,icon:"🎉"}),r.resetFields()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to add shift.",{duration:1e3})}},x=h=>{g(h??null),o.setFieldsValue({name:h?.shift_name??h?.name??"",start_time:da(h?.start_time),end_time:da(h?.end_time),shift_start_from:da(h?.shift_start_from),shift_start_to:da(h?.shift_start_to),shift_end_from:da(h?.shift_end_from),shift_end_to:da(h?.shift_end_to)}),d(!0)},T=()=>{d(!1),g(null),o.resetFields()},D=async h=>{const S=c?.id??c?.shift_id;if(!S){_.error("Missing shift id.",{duration:1e3});return}try{const A=y(h,S);await qt(Nn.edit,A,t),await w(),_.success("Success! Updated shift.",{duration:1e3,icon:"🚀"}),T()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to update shift.",{duration:1e3})}},k=async h=>{const S=h?.id??h?.shift_id;if(S)try{await w(tn(Nn.remove,S,t),qe(S)),_.success("Success! Deleted shift.",{duration:1e3})}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to delete shift.",{duration:1e3})}},C=i.useMemo(()=>[{title:"Name",dataIndex:"shift_name",key:"shift_name",ellipsis:!0,fixed:"left",width:160},{title:"Start Time",dataIndex:"start_time",key:"start_time",width:120},{title:"End Time",dataIndex:"end_time",key:"end_time",width:120},{title:"Start From",dataIndex:"shift_start_from",key:"shift_start_from",width:120,responsive:["md"]},{title:"Start To",dataIndex:"shift_start_to",key:"shift_start_to",width:120,responsive:["md"]},{title:"End From",dataIndex:"shift_end_from",key:"shift_end_from",width:120,responsive:["md"]},{title:"End To",dataIndex:"shift_end_to",key:"shift_end_to",width:120,responsive:["md"]},{title:"Action",key:"action",width:110,fixed:"right",render:(h,S)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>x(S)}),e.jsx(n.Popconfirm,{title:"Remove shift?",okText:"Yes",cancelText:"No",onConfirm:()=>k(S),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[]),j=[{required:!0,message:"Select time"}];return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:l,title:"Edit Shift",onCancel:T,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:D,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsx(n.Form.Item,{name:"start_time",label:"Start Time",rules:j,children:e.jsx(n.TimePicker,{format:lt,use12Hours:!0,style:bt})}),e.jsx(n.Form.Item,{name:"end_time",label:"End Time",rules:j,children:e.jsx(n.TimePicker,{format:lt,use12Hours:!0,style:bt})}),e.jsx(n.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(n.TimePicker,{format:lt,use12Hours:!0,style:bt})}),e.jsx(n.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(n.TimePicker,{format:lt,use12Hours:!0,style:bt})}),e.jsx(n.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(n.TimePicker,{format:lt,use12Hours:!0,style:bt})}),e.jsx(n.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(n.TimePicker,{format:lt,use12Hours:!0,style:bt})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:T,children:"Cancel"}),e.jsx(ie,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Shift"}),children:e.jsx(n.Form,{form:r,layout:"vertical",onFinish:m,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsx(n.Form.Item,{name:"start_time",label:"Start Time",rules:j,children:e.jsx(n.TimePicker,{format:lt,use12Hours:!0,style:bt})}),e.jsx(n.Form.Item,{name:"end_time",label:"End Time",rules:j,children:e.jsx(n.TimePicker,{format:lt,use12Hours:!0,style:bt})}),e.jsx(n.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(n.TimePicker,{format:lt,use12Hours:!0,style:bt})}),e.jsx(n.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(n.TimePicker,{format:lt,use12Hours:!0,style:bt})}),e.jsx(n.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(n.TimePicker,{format:lt,use12Hours:!0,style:bt})}),e.jsx(n.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(n.TimePicker,{format:lt,use12Hours:!0,style:bt})}),e.jsx(ie,{type:"submit",value:"Save",color:"primary"})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Shift List"}),children:e.jsx(Me,{parentCallback:v,data:{newData:p,columns:C,columnstype:"antd",action:!1,Loading:f,error:u}})})]})}const cf=({token:t})=>e.jsx(df,{token:t}),Di=Re.attendance;function uf({data:t}){return t?e.jsx("div",{style:{margin:15,fontSize:13,padding:10},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e.jsxs("thead",{children:[e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{}),(t?.shifts??[]).map((a,s)=>e.jsx("th",{colSpan:"2",style:{border:"1px solid #000",paddingLeft:10},children:a?.shift_name??""},`${s}heading1`))]}),e.jsxs("tr",{children:[e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Sl.No"}),e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Teacher's Name"}),(t?.shifts??[]).map((a,s)=>e.jsxs(i.Fragment,{children:[e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"In Time"}),e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Out Time"})]},`${s}heading2`))]})]}),e.jsx("tbody",{children:(t?.data??[]).map((a,s)=>e.jsxs("tr",{children:[e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:s+1})}),e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:`${a?.name??""} ${a?.surname??""}`.trim()})}),(t?.shifts??[]).map((r,o)=>e.jsxs(i.Fragment,{children:[e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:a?.attendance_data?(a.attendance_data?.[r?.office_shift_id]?.checkintime??"").toUpperCase():""})}),e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:a?.attendance_data?(a.attendance_data?.[r?.office_shift_id]?.checkouttime??"").toUpperCase():""})})]},`${o}cells${s}`))]},`${s}row`))})]})}):null}const pf=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},mf=t=>{const a=String(t??"").toLowerCase();return a==="present"?e.jsx(n.Tag,{color:"green",children:"Present"}):a==="absent"?e.jsx(n.Tag,{color:"red",children:"Absent"}):a==="leave"?e.jsx(n.Tag,{color:"orange",children:"Leave"}):e.jsx(n.Tag,{children:t??""})};function ff({token:t}){const[a,s]=i.useState(ae()),[r,o]=i.useState(!1),[l,d]=i.useState(0),c=i.useMemo(()=>`${r?Di.dailyAttendanceMultipleShift:Di.dailyAttendance}?attendance_date=${encodeURIComponent(a.format("YYYY-MM-DD"))}`,[a,r,l]),{isLoading:g,error:f,data:u}=G(t?[c,t]:null,([m,x])=>J(m,x)),p=i.useMemo(()=>pf(u),[u]),w=i.useMemo(()=>r?u?.data?.data??u?.data??u??null:null,[u,r]),v=xa.useReactToPrint({content:()=>document.getElementById("ubk-hr-daily-attendance-print")}),y=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(m,x,T)=>T+1},{title:"Name",key:"name",render:(m,x)=>`${x?.name??""} ${x?.surname??""}`.trim(),ellipsis:!0},{title:"Designations",dataIndex:"designations",key:"designations",ellipsis:!0,responsive:["md"]},{title:"Status",key:"attendance",width:160,render:(m,x)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[mf(x?.attendance),x?.late_time?e.jsx(n.Tag,{color:"red",children:"L"}):null]})},{title:"In Time",key:"intime",width:120,render:(m,x)=>x?.attendance_data?.[0]?.intime??""},{title:"Out Time",key:"outtime",width:120,render:(m,x)=>x?.attendance_data?.[0]?.outtime??""},{title:"Late",key:"late",width:100,render:(m,x)=>x?.late_time?e.jsx(n.Tag,{color:"red",children:x.late_time}):""}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Daily Attendance"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end",padding:14,borderRadius:12,border:"1px solid #eee",background:"#fafafa"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{value:a,onChange:m=>m&&s(m),style:{width:"100%"},allowClear:!1})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:22},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222"},children:"Multiple Shift"}),e.jsx(n.Switch,{checked:r,onChange:o})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"button",value:"Search",onClick:()=>d(m=>m+1)})})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),extra:e.jsx(ee.PrinterOutlined,{style:{color:"#5080f8",fontSize:18,cursor:"pointer"},onClick:v}),children:e.jsxs("div",{id:"ubk-hr-daily-attendance-print",children:[e.jsx("div",{className:"print-only",children:e.jsx(Pt,{})}),r?e.jsx(uf,{data:w}):e.jsx(n.Table,{bordered:!0,size:"small",loading:g,rowKey:(m,x)=>String(m?.id??m?.staff_id??x),columns:y,dataSource:p,pagination:{pageSize:20},scroll:{x:"max-content"}})]})})]})}const hf=({token:t})=>e.jsx(ff,{token:t}),Ri=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},yf=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"";function gf({token:t,staffId:a}){const[s,r]=i.useState(!1),[o,l]=i.useState(null),[d,c]=i.useState({value:"Cash",label:"Cash"}),[g,f]=i.useState(""),[u,p]=i.useState(""),w=i.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.currency_icon??""}catch{return""}},[]),v=R=>{const q=Number(R??0),U=Number.isFinite(q)?q.toLocaleString("en-IN"):"0";return`${w?`${w} `:""}${U}`},y=i.useMemo(()=>a?`${Re.staff.basicById}?staff_id=${encodeURIComponent(String(a))}`:null,[a]),m=i.useMemo(()=>a?`${Re.payroll.staffPayrollByStaffId}?staff_id=${encodeURIComponent(String(a))}`:null,[a]),{data:x}=G(t&&y?[y,t]:null,([R,q])=>J(R,q)),{data:T,isLoading:D,mutate:k}=G(t&&m?[m,t]:null,([R,q])=>J(R,q)),C=i.useMemo(()=>Ri(x)[0]??x?.data??x??null,[x]),j=i.useMemo(()=>Ri(T),[T]),h=i.useMemo(()=>[{title:"Month",dataIndex:"month",key:"month",width:120,align:"center"},{title:"Basic Salary",dataIndex:"basic_salary",key:"basic_salary",width:140,align:"center",render:(R,q)=>e.jsx("div",{style:{fontSize:11},children:Tt(q?.basic_salary)})},{title:"Gross Salary",dataIndex:"gross_salary",key:"gross_salary",width:140,align:"center",render:(R,q)=>e.jsx("div",{style:{fontSize:11},children:Tt(q?.gross_salary)})},{title:"Net Salary",dataIndex:"net_amount",key:"net_amount",width:140,align:"center",render:(R,q)=>e.jsx("div",{style:{fontSize:11},children:Tt(q?.net_amount)})},{title:"Payable",dataIndex:"Total_Payable_Amount",key:"Total_Payable_Amount",width:140,align:"center",render:(R,q)=>e.jsx("div",{style:{fontSize:11},children:Tt(q?.Total_Payable_Amount)})},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(R,q)=>e.jsx("div",{style:{cursor:q?.status==="due"?"pointer":"default"},onClick:()=>{q?.status==="due"&&(l(q),r(!0))},children:Po(q?.status)})}],[]),S=i.useMemo(()=>[{value:"Cash",label:"Cash"},{value:"UPI",label:"UPI"},{value:"DD",label:"DD"},{value:"Bank",label:"Bank"},{value:"Internet Banking",label:"Internet Banking"},{value:"Cheque",label:"Cheque"}],[]),A=async()=>{if(!o)return;const R={...o,staff_id:a,payment_type:d?.value??"",notes:g,attchement:u};try{await Ne(Re.payroll.generatePayslip,{arg:R},t),_.success("Success!",{duration:1e3}),r(!1),l(null),f(""),p(""),await k()}catch(q){_.error(q?.response?.data?.msg??q?.message??"Failed.",{duration:1e3})}};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll Receipt Details"}),children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx("div",{style:{fontSize:13,color:"#444"},children:C?`${C?.f_name??C?.firstname??""} ${C?.l_name??C?.lastname??""}`.trim():""}),e.jsx(n.Table,{bordered:!0,size:"small",loading:D,rowKey:(R,q)=>String(R?.id??`${R?.month}-${q}`),columns:h,dataSource:j,pagination:{pageSize:12},scroll:{x:"max-content"}})]})}),e.jsx(n.Modal,{open:s,onCancel:()=>{r(!1),l(null)},footer:null,destroyOnClose:!0,title:"Payment Options",width:640,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Z,{label:"Pay",options:S,value:d,onChange:R=>c(R??S[0]),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Note"}),e.jsx(n.Input.TextArea,{rows:4,placeholder:"Note",value:g,onChange:R=>f(R.target.value)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Attachment"}),e.jsx(n.Upload,{maxCount:1,action:Lo(),headers:t?{Authorization:t}:void 0,onChange:R=>{if(R?.file?.status==="done"){const q=yf(R?.file?.response);q&&p(q)}R?.file?.status==="removed"&&p("")},children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),children:"Upload"})}),!!u&&e.jsx("div",{style:{fontSize:12,color:"#666",marginTop:6},children:u})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(n.Button,{onClick:()=>r(!1),children:"Cancel"}),e.jsx(ie,{type:"button",value:o?.Total_Payable_Amount?`Pay ${v(o.Total_Payable_Amount)}`:"Pay",onClick:A})]})]})})]})}function xf({token:t,staffId:a}){const s=i.useMemo(()=>{if(a!=null&&String(a).trim()!=="")return a;if(typeof window>"u")return null;const r=new URLSearchParams(window.location.search).get("id");return r||null},[a]);return s?e.jsx(gf,{token:t,staffId:s}):e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll Receipt Details"}),children:e.jsx("div",{style:{fontSize:13,color:"#666"},children:"Missing staff id."})})}function zt({onAdd:t,onExport:a,onPrint:s,onDownload:r,onFilter:o,onRefresh:l,actions:d}){const c=i.useMemo(()=>[{key:"add",title:"Add",icon:e.jsx(ee.PlusOutlined,{}),onClick:t},{key:"export",title:"Export",icon:e.jsx(ee.FileExcelOutlined,{}),onClick:a},{key:"print",title:"Print",icon:e.jsx(ee.PrinterOutlined,{}),onClick:s},{key:"download",title:"Download",icon:e.jsx(ee.DownloadOutlined,{}),onClick:r},{key:"filter",title:"Filter",icon:e.jsx(ee.FilterOutlined,{}),onClick:o},{key:"refresh",title:"Refresh",icon:e.jsx(ee.ReloadOutlined,{}),onClick:l}],[t,a,s,r,o,l]),g=i.useMemo(()=>{const f=Array.isArray(d)&&d.length?new Set(d):null;return f?c.filter(u=>f.has(u.key)):c},[c,d]);return e.jsx(n.Space,{size:8,children:g.map(f=>e.jsx(n.Tooltip,{title:f.title,children:e.jsx(n.Button,{type:"text",icon:f.icon,onClick:f.onClick,disabled:!f.onClick})},f.key))})}const nr=t=>t??localStorage.getItem("authToken")??"",kt={dashboard:{monthlyGraph:"api/branchapi/reportGraph/studentPresentvsAbsentmonthlyReportgraph",weeklyGraph:"api/branchapi/reportGraph/studentPresentvsAbsentweeklyReportgraph"},dropdowns:{classes:"api/branchapi/academy/classdropdownlist",sectionsByClass:"api/branchapi/academy/sectionoftheClass",sessions:"api/branchapi/generalSettings/sessiondropdown"},studentAttendance:{list:"api/StudentAttendace/studentlistforBranchbyClass",save:"api/studentAttendace/addattendencebyBranch",emergencyLeave:"api/StudentAttendace/emergency_leave"},dailyAttendance:{list:"api/StudentAttendace/studentlistforBranchbyClass"},monthlyReport:{table:"api/branchapi/student/studentmonthlyAttendence",byStudent:"api/branchapi/student/getStududentMonthlyByIdUrlnew"},yearlyReport:{table:"api/branchapi/student/studentyearlyAttendenceReport"}},Ut=async(t,a)=>J(t,nr(a)),bf=async(t,a,s)=>Ne(t,a,nr(s)),jf=async(t,a,s)=>za(t,{arg:a},nr(s)),Ya=(t,a)=>{const s=new URLSearchParams;Object.entries(a??{}).forEach(([o,l])=>{l==null||l===""||s.set(o,String(l))});const r=t.includes("?")?"&":"?";return`${t}${r}${s.toString()}`},Ii=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1"}catch{return"1"}},Sf=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Yo=(t,a)=>{const s=t?.data?.data??t?.data??t??{},r=a?s?.[a]:s;return Array.isArray(r)?r:Array.isArray(s?.student)?s.student:Array.isArray(s?.staff)?s.staff:Array.isArray(s?.data)?s.data:[]},vf=t=>Array.isArray(t?.monthly_data)?t.monthly_data:Array.isArray(t?.month_data)?t.month_data:[],wf=t=>{const a={present:0,absent:0,late:0,leave:0};return(Array.isArray(t)?t:[]).forEach(s=>{if(Array.isArray(s?.monthly_data)||Array.isArray(s?.month_data)){vf(s).forEach(o=>{const l=o?.[0]?.data?.[0]??o?.data?.[0]??o??{},d=String(l?.attendance_type??l?.attendence_type_id??"").toUpperCase();(d==="P"||d==="1")&&(a.present+=1),(d==="A"||d==="4")&&(a.absent+=1),(d==="L"||d==="3")&&(a.late+=1),(d==="LEAVE"||d==="2")&&(a.leave+=1)});return}const r=String(s?.attendance_type??s?.attendence_type_id??"").toUpperCase();(r==="P"||r==="1")&&(a.present+=1),(r==="A"||r==="4")&&(a.absent+=1),(r==="L"||r==="3")&&(a.late+=1),(r==="LEAVE"||r==="2")&&(a.leave+=1)}),a},sr=(t,a)=>{const{data:s,isLoading:r,error:o}=G(a&&t?[t,a]:null,([l,d])=>Ut(l,d));return{isLoading:r,error:o,data:s,options:i.useMemo(()=>Sf(s),[s])}},as=t=>sr(kt.dropdowns.classes,t),ns=(t,a)=>{const s=t?`${kt.dropdowns.sectionsByClass}?class_id=${encodeURIComponent(String(t))}`:null;return sr(s,a)},_f=t=>sr(kt.dropdowns.sessions,t),rr=t=>{const a=String(t??"").toUpperCase();return Ze(a==="1"||a==="P"||a==="PRESENT"?"P":a==="4"||a==="A"||a==="ABSENT"?"A":a==="3"||a==="L"||a==="LATE"?"L":a==="2"||a==="LEAVE"?"LEAVE":a==="W"?"W":a==="H"?"H":a||"-")},Vo=(t,a,s)=>{const r=new Blob([t],{type:a}),o=URL.createObjectURL(r),l=document.createElement("a");l.href=o,l.download=s,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(o)},ki=t=>String(t??"").replace(/"/g,'""'),Cf=({rows:t,columns:a,fileName:s})=>{const r=Array.isArray(a)?a:[],o=Array.isArray(t)?t:[],l=r.map(c=>`"${ki(c?.title??c?.name??c?.key??c?.dataIndex)}"`).join(","),d=o.map((c,g)=>r.map(f=>{const u=f?.dataIndex??f?.selector??f?.key,p=u==="sl"?g+1:c?.[u];return`"${ki(p)}"`}).join(",")).join(`
|
|
60
|
-
`);
|
|
61
|
-
`),"text/csv;charset=utf-8;",s)},Af=({value:t,fileName:a})=>{Vo(JSON.stringify(t??null,null,2),"application/json;charset=utf-8;",a)};function Wo({summary:t}){const a=[{key:"present",label:"Present",color:"#52c41a"},{key:"absent",label:"Absent",color:"#ff4d4f"},{key:"late",label:"Late",color:"#fa8c16"},{key:"leave",label:"Leave",color:"#1677ff"}];return e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(170px, 1fr))",gap:16},children:a.map(s=>e.jsxs(n.Card,{size:"small",styles:{body:{padding:16}},children:[e.jsx("div",{style:{fontSize:12,color:"#666",marginBottom:8},children:s.label}),e.jsx("div",{style:{fontSize:24,fontWeight:700,color:s.color},children:t?.[s.key]??0})]},s.key))})}function ga({summary:t,title:a="Attendance Overview"}){const s=i.useMemo(()=>[{key:"present",label:"Present",value:Number(t?.present??0),color:"#52c41a"},{key:"absent",label:"Absent",value:Number(t?.absent??0),color:"#ff4d4f"},{key:"late",label:"Late",value:Number(t?.late??0),color:"#fa8c16"},{key:"leave",label:"Leave",value:Number(t?.leave??0),color:"#1677ff"}],[t]),r=Math.max(...s.map(o=>o.value),1);return e.jsx(n.Card,{size:"small",title:a,children:e.jsx("div",{style:{display:"grid",gap:12},children:s.map(o=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"100px 1fr 50px",gap:12,alignItems:"center"},children:[e.jsx("div",{style:{fontSize:12,color:"#444"},children:o.label}),e.jsx("div",{style:{height:12,background:"#f0f0f0",borderRadius:999},children:e.jsx("div",{style:{width:`${o.value/r*100}%`,height:"100%",background:o.color,borderRadius:999}})}),e.jsx("div",{style:{fontSize:12,fontWeight:600,textAlign:"right"},children:o.value})]},o.key))})})}function Tf(){const t=[{label:"Present",node:Ze("P")},{label:"Absent",node:Ze("A")},{label:"Late",node:Ze("L")},{label:"Weekly Off",node:Ze("W")},{label:"Holiday",node:Ze("H")}];return e.jsx(n.Space,{wrap:!0,size:[12,8],children:t.map(a=>e.jsxs(n.Space,{size:6,children:[e.jsx("span",{style:{fontSize:12,color:"#555"},children:a.label}),a.node]},a.label))})}function Nt({items:t}){const a=Array.isArray(t)?t.filter(s=>s?.value):[];return a.length?e.jsx(n.Space,{wrap:!0,size:[8,8],children:a.map(s=>e.jsxs(n.Tag,{color:"blue",children:[s.label,": ",s.value]},s.label))}):null}function ss({title:t,subtitle:a,printRef:s,exportRows:r,exportColumns:o,onRefresh:l,onAdd:d,filterSection:c,summary:g,chartContent:f,reportTitle:u,reportExtra:p,children:w,fileBaseName:v="attendance"}){const y=xa.useReactToPrint({content:()=>s?.current});return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsxs("div",{children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:t}),a?e.jsx(n.Typography.Text,{type:"secondary",style:{display:"block",marginTop:4},children:a}):null]}),extra:e.jsx(zt,{actions:["add","export","print","download","refresh"],onAdd:d,onExport:()=>Cf({rows:r,columns:o,fileName:`${v}.csv`}),onPrint:y,onDownload:()=>Af({value:r,fileName:`${v}.json`}),onRefresh:l}),children:c}),e.jsx(Wo,{summary:g}),f===!1?null:f||e.jsx(ga,{summary:g}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:u}),extra:p,children:w})]})}const Df=[{label:"Present",value:"1"},{label:"Absent",value:"4"},{label:"Late",value:"3"},{label:"Leave",value:"2"}];function Rf({rows:t,loading:a,sunday:s,holiday:r,holidayTitle:o,onChangeRows:l,onEmergency:d}){const c=(f,u)=>{const p=(Array.isArray(t)?t:[]).map((w,v)=>(w?.student_session_id??w?.student_id??w?.id??v)===f?{...w,...u}:w);l?.(p)},g=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(f,u,p)=>p+1},{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:130},{title:"EC No",dataIndex:"ecno",key:"ecno",width:100},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",key:"full_name",render:(f,u)=>u?.full_name??u?.student_name??u?.name??"--"},{title:"Attendance",dataIndex:"attendence_type_id",key:"attendence_type_id",width:180,render:(f,u,p)=>{const w=u?.student_session_id??u?.student_id??u?.id??p;return e.jsx(n.Select,{size:"small",style:{width:"100%"},options:Df,value:String(f??"1"),onChange:v=>c(w,{attendence_type_id:v})})}},{title:"Date",dataIndex:"date",key:"date",width:120,render:f=>f?ae(f).format("DD-MM-YYYY"):"--"},{title:"Remarks",dataIndex:"remark",key:"remark",width:140},{title:"In Time",dataIndex:"intime",key:"intime",width:120},{title:"Out Time",dataIndex:"outtime",key:"outtime",width:120},{title:"Emergency Leave",key:"emergency_leave",width:140,render:(f,u)=>e.jsx(n.Tag,{color:"orange",style:{cursor:"pointer"},icon:e.jsx(ee.ClockCircleOutlined,{}),onClick:()=>d?.(u),children:"E.L"})}],[d,t]);return s?e.jsx("div",{style:{textAlign:"center",fontWeight:700,padding:"32px 0"},children:"Weekly Off"}):r?e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{fontWeight:700,marginBottom:8},children:"Holiday"}),e.jsx("div",{children:o||"--"})]}):e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(f,u)=>String(f?.student_session_id??f?.student_id??f?.id??u),columns:g,dataSource:Array.isArray(t)?t:[],loading:a,pagination:{pageSize:25},scroll:{x:"max-content"}})}function If({rows:t,loading:a,sunday:s,holiday:r,holidayTitle:o}){const l=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(d,c,g)=>g+1},{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:130},{title:"EC No",dataIndex:"ecno",key:"ecno",width:100},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",key:"full_name",render:(d,c)=>c?.full_name??c?.student_name??c?.name??"--"},{title:"Attendance",dataIndex:"attendence_type_id",key:"attendence_type_id",width:120,render:d=>rr(d)},{title:"Date",dataIndex:"date",key:"date",width:120,render:d=>d?ae(d).format("DD-MM-YYYY"):"--"},{title:"Remarks",dataIndex:"remark",key:"remark",width:140},{title:"In Time",dataIndex:"intime",key:"intime",width:120},{title:"Out Time",dataIndex:"outtime",key:"outtime",width:120}],[]);return s?e.jsx("div",{style:{textAlign:"center",fontWeight:700,padding:"32px 0"},children:"Weekly Off"}):r?e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{fontWeight:700,marginBottom:8},children:"Holiday"}),e.jsx("div",{children:o||"--"})]}):e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(d,c)=>String(d?.student_session_id??d?.student_id??d?.id??c),columns:l,dataSource:Array.isArray(t)?t:[],loading:a,pagination:{pageSize:25},scroll:{x:"max-content"}})}function kf({data:t,loading:a,onViewStudent:s}){const r=t?.data??t??{},o=Array.isArray(r?.studentAttendance)?r.studentAttendance:Array.isArray(r)?r:[],l=Array.isArray(r?.monthly_holiday)?r.monthly_holiday:[],d=Array.isArray(r?.dateSun)?r.dateSun:[],c=Number(r?.totalDaysMonth??0),g=i.useMemo(()=>{const f=[{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:90,fixed:"left"},{title:"Name",key:"student_name",width:180,fixed:"left",render:(u,p)=>e.jsx(n.Button,{type:"link",style:{padding:0},onClick:()=>s?.(p),children:p?.student_name??p?.full_name??"--"})}];return[...new Array(c).keys()].forEach(u=>{f.push({title:String(u+1),key:`day-${u+1}`,width:52,align:"center",render:(p,w)=>{const y=w?.[`${w?.student_id}_${o.indexOf(w)}`]?.[u]??{},m=y?.attendance_date,x=l.find(T=>T?.date===m);return d.includes(m)?qr("sunday","W"):x?qr("holiday","H"):rr(y?.attendence_type_id)}})}),f.push({title:"Total",key:"total",width:140,fixed:"right",render:(u,p)=>{let w=0,v=0,y=0;return[...new Array(c).keys()].forEach(m=>{const x=p?.[`${p?.student_id}_${o.indexOf(p)}`]?.[m]??{},T=String(x?.attendence_type_id??"");T==="1"&&(w+=1),T==="4"&&(v+=1),T==="3"&&(y+=1)}),e.jsxs("span",{children:["P: ",w," A: ",v," L: ",y]})}}),f},[l,s,o,d,c]);return e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(f,u)=>String(f?.student_id??u),columns:g,dataSource:o,loading:a,pagination:{pageSize:20},scroll:{x:"max-content"},locale:{emptyText:e.jsx(n.Empty,{description:"No monthly report found"})}})}function Pf({open:t,onClose:a,loading:s,data:r,studentName:o}){const l=Array.isArray(r?.data?.report)?r.data.report:[],d=[{title:"Date",dataIndex:"attendance_date",key:"attendance_date",render:c=>c?ae(c).format("DD-MM-YYYY"):"--"},{title:"Status",key:"status",render:(c,g)=>rr(g?.attendence_type_id??g?.attendance_type)},{title:"In Time",dataIndex:"intime",key:"intime"},{title:"Out Time",dataIndex:"outtime",key:"outtime"},{title:"Remark",dataIndex:"remark",key:"remark"}];return e.jsx(n.Modal,{open:t,onCancel:a,footer:null,width:900,title:`Monthly Details${o?` - ${o}`:""}`,children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(c,g)=>String(c?.attendance_date??g),columns:d,dataSource:l,loading:s,pagination:{pageSize:20},scroll:{x:"max-content"}})})}function Of({open:t,onClose:a,onSubmit:s,loading:r}){const[o,l]=n.Modal.useModal(),[d,c]=i.useState(null),[g,f]=i.useState(""),u=async()=>{if(!d){await o.warning({title:"Select time"});return}await s?.({outtime:d.format("h:mm a"),message:g}),c(null),f("")};return e.jsxs(e.Fragment,{children:[l,e.jsx(n.Modal,{title:"Emergency Leave",open:t,onCancel:a,onOk:u,confirmLoading:r,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginBottom:6},children:"Select Time"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",value:d,onChange:c,style:{width:"100%"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginBottom:6},children:"Purpose"}),e.jsx(n.Input.TextArea,{rows:4,value:g,onChange:p=>f(p.target.value)})]})]})})]})}const Ho=t=>wf(t),Pi=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a.reduce((s,r)=>({present:s.present+Number(r?.present??r?.Present??r?.total_present??0),absent:s.absent+Number(r?.absent??r?.Absent??r?.total_absent??0),late:s.late+Number(r?.late??r?.Late??0),leave:s.leave+Number(r?.leave??r?.Leave??0)}),{present:0,absent:0,late:0,leave:0}):{present:Number(a?.present??a?.Present??a?.total_present??0),absent:Number(a?.absent??a?.Absent??a?.total_absent??0),late:Number(a?.late??a?.Late??0),leave:Number(a?.leave??a?.Leave??0)}};function Mf({token:t}){const{data:a}=G(t?[kt.dashboard.monthlyGraph,t]:null,([l,d])=>Ut(l,d)),{data:s}=G(t?[kt.dashboard.weeklyGraph,t]:null,([l,d])=>Ut(l,d)),r=i.useMemo(()=>Pi(a),[a]),o=i.useMemo(()=>Pi(s),[s]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsxs(n.Card,{children:[e.jsx(n.Typography.Title,{level:4,style:{marginTop:0},children:"Attendance Dashboard"}),e.jsx(n.Typography.Paragraph,{style:{marginBottom:0},children:"Student attendance overview with monthly and weekly analytics migrated from the ERP dashboard."})]}),e.jsx(Wo,{summary:r}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20},children:[e.jsx(ga,{summary:r,title:"Monthly Attendance Chart"}),e.jsx(ga,{summary:o,title:"Weekly Attendance Chart"})]})]})}const Rs=kt.studentAttendance,Ef={width:"100%",height:40};function Ff({token:t}){const a=i.useRef(null),[s,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[g,f]=i.useState(""),[u,p]=i.useState(""),[w,v]=i.useState(""),[y,m]=i.useState(ae()),[x,T]=i.useState(0),[D,k]=i.useState([]),[C,j]=i.useState(!1),[h,S]=i.useState(null),[A,R]=i.useState(!1),[q,U]=i.useState(!1),b=as(t),O=ns(s,t),M=i.useMemo(()=>!s||!d||x===0?null:Ya(Rs.list,{cID:s,sID:d,batch_id:u,date:y.format("YYYY-MM-DD")}),[u,s,y,x,d]),{data:$,isLoading:F,mutate:N}=G(t&&M?[M,t]:null,([K,te])=>Ut(K,te));i.useEffect(()=>{k(Yo($,"student"))},[$]);const V=$?.data?.data??$?.data??$??{},z=!!V?.sunday,P=!!V?.holiday?.holiday,I=V?.holiday?.title??"",B=i.useMemo(()=>Ho(D),[D]),L=i.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no"},{title:"EC No",dataIndex:"ecno"},{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Attendance",dataIndex:"attendence_type_id"},{title:"Date",dataIndex:"date"},{title:"Remarks",dataIndex:"remark"},{title:"In Time",dataIndex:"intime"},{title:"Out Time",dataIndex:"outtime"}],[]),H=async()=>{if(D.length)try{U(!0),await bf(Rs.save,{attendenceData:D,date:y.format("YYYY-MM-DD"),holiday:C?"YES":"NO"},t),_.success("Student attendance saved."),N?.()}catch(K){_.error(K?.message??"Failed to save attendance.")}finally{U(!1)}},se=async({outtime:K,message:te})=>{if(h?.attendence_id)try{R(!0),await jf(Rs.emergencyLeave,{outtime:K,message:te,id:h.attendence_id},t),_.success("Emergency leave updated."),S(null),N?.()}catch(oe){_.error(oe?.message??"Failed to update emergency leave.")}finally{R(!1)}},W=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Z,{options:b.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:K=>{r(K?.value??""),l(K?.label??""),c(""),f(""),p(""),v("")},required:!0}),e.jsx(Z,{options:O.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:K=>{c(K?.value??""),f(K?.label??""),p(""),v("")},required:!0},`section-${s}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{value:y,onChange:K=>K&&m(K),style:Ef,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"button",value:"Search",color:"primary",onClick:()=>T(K=>K+1)})})]}),e.jsx(Nt,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Date",value:y.format("DD-MM-YYYY")}]})]});return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{}),e.jsx(ss,{title:"Student Attendance",printRef:a,exportRows:D,exportColumns:L,onRefresh:()=>N?.(),filterSection:W,summary:B,chartContent:!1,reportTitle:"Student Attendance List",reportExtra:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(n.Button,{size:"small",type:C?"primary":"default",onClick:()=>j(K=>!K),children:C?"Marked":"Mark As Holiday"}),e.jsx(n.Button,{size:"small",type:"primary",onClick:H,loading:q,disabled:!D.length,children:"Save Attendance"})]}),fileBaseName:"student-attendance",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(Pt,{}),e.jsx(n.Typography.Title,{level:5,children:"Student Attendance"}),e.jsx(n.Card,{size:"small",style:{marginBottom:12},children:e.jsx(Nt,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Date",value:y.format("DD-MM-YYYY")}]})})]}),e.jsx(Rf,{rows:D,loading:F,sunday:z,holiday:P,holidayTitle:I,onChangeRows:k,onEmergency:S})]})}),e.jsx(Of,{open:!!h,onClose:()=>S(null),onSubmit:se,loading:A})]})}const $f=kt.dailyAttendance,Uf={width:"100%",height:40};function Nf({token:t}){const a=i.useRef(null),[s,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[g,f]=i.useState(""),[u,p]=i.useState(""),[w,v]=i.useState(ae()),[y,m]=i.useState(0),x=as(t),T=ns(s,t),D=i.useMemo(()=>!s||!d||y===0?null:Ya($f.list,{cID:s,sID:d,batch_id:u,date:w.format("YYYY-MM-DD")}),[u,s,w,y,d]),{data:k,isLoading:C,mutate:j}=G(t&&D?[D,t]:null,([M,$])=>Ut(M,$)),h=i.useMemo(()=>Yo(k,"student"),[k]),S=k?.data?.data??k?.data??k??{},A=!!S?.sunday,R=!!S?.holiday?.holiday,q=S?.holiday?.title??"",U=i.useMemo(()=>Ho(h),[h]),b=i.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no"},{title:"EC No",dataIndex:"ecno"},{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Attendance",dataIndex:"attendence_type_id"},{title:"Date",dataIndex:"date"},{title:"Remarks",dataIndex:"remark"},{title:"In Time",dataIndex:"intime"},{title:"Out Time",dataIndex:"outtime"}],[]),O=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Z,{options:x.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{r(M?.value??""),l(M?.label??""),c(""),f(""),p(""),setBatchLabel("")},required:!0}),e.jsx(Z,{options:T.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{c(M?.value??""),f(M?.label??""),p(""),setBatchLabel("")},required:!0},`section-${s}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{value:w,onChange:M=>M&&v(M),style:Uf,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"button",value:"Search",color:"primary",onClick:()=>m(M=>M+1)})})]}),e.jsx(Nt,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Date",value:w.format("DD-MM-YYYY")}]})]});return e.jsx(ss,{title:"Daily Attendance",subtitle:"Read-only daily attendance enquiry migrated from ERP AttendanceDashboard.",printRef:a,exportRows:h,exportColumns:b,onRefresh:()=>j?.(),filterSection:O,summary:U,chartContent:e.jsx(ga,{summary:U,title:"Daily Attendance Overview"}),reportTitle:"Daily Attendance List",fileBaseName:"daily-attendance",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(Pt,{}),e.jsx(Nt,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Date",value:w.format("DD-MM-YYYY")}]})]}),e.jsx(If,{rows:h,loading:C,sunday:A,holiday:R,holidayTitle:q})]})})}const Oi=kt.monthlyReport,Bf=t=>{const a=Array.isArray(t?.studentAttendance)?t.studentAttendance:[],s=Number(t?.totalDaysMonth??0),r={present:0,absent:0,late:0,leave:0};return a.forEach((o,l)=>{[...new Array(s).keys()].forEach(d=>{const c=o?.[`${o?.student_id}_${l}`]?.[d]??{},g=String(c?.attendence_type_id??"");g==="1"&&(r.present+=1),g==="4"&&(r.absent+=1),g==="3"&&(r.late+=1),g==="2"&&(r.leave+=1)})}),r},Lf=t=>{const a=Array.isArray(t?.studentAttendance)?t.studentAttendance:[],s=Number(t?.totalDaysMonth??0);return a.map((r,o)=>{let l=0,d=0,c=0;return[...new Array(s).keys()].forEach(g=>{const f=r?.[`${r?.student_id}_${o}`]?.[g]??{},u=String(f?.attendence_type_id??"");u==="1"&&(l+=1),u==="4"&&(d+=1),u==="3"&&(c+=1)}),{roll_no:r?.roll_no??"",student_name:r?.student_name??r?.full_name??"",present:l,absent:d,late:c}})};function qf({token:t}){const a=i.useRef(null),[s,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[g,f]=i.useState(""),[u,p]=i.useState(""),[w,v]=i.useState(""),[y,m]=i.useState(String(new Date().getFullYear())),[x,T]=i.useState(String(new Date().getMonth()+1).padStart(2,"0")),[D,k]=i.useState(0),[C,j]=i.useState(null),h=as(t),S=ns(s,t),A=i.useMemo(()=>er(Number(y)),[y]),R=i.useMemo(()=>Zs(10),[]),q=i.useMemo(()=>!s||!d||!y||!x||D===0?null:Ya(Oi.table,{session:Ii(),class_id:s,section_id:d,year:y,month:x,batch_id:u}),[u,s,x,D,d,y]),{data:U,isLoading:b,mutate:O}=G(t&&q?[q,t]:null,([B,L])=>Ut(B,L)),M=U?.data?.data??U?.data??U??{},$=i.useMemo(()=>Bf(M),[M]),F=i.useMemo(()=>Lf(M),[M]),N=i.useMemo(()=>[{title:"Roll No",dataIndex:"roll_no"},{title:"Name",dataIndex:"student_name"},{title:"Present",dataIndex:"present"},{title:"Absent",dataIndex:"absent"},{title:"Late",dataIndex:"late"}],[]),V=i.useMemo(()=>C?.student_id?Ya(Oi.byStudent,{student_id:C.student_id,month:x,year:y,session:Ii()}):null,[x,C,y]),{data:z,isLoading:P}=G(t&&V?[V,t]:null,([B,L])=>Ut(B,L)),I=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Z,{options:h.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:B=>{r(B?.value??""),l(B?.label??""),c(""),f(""),p(""),v("")},required:!0}),e.jsx(Z,{options:S.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:B=>{c(B?.value??""),f(B?.label??""),p(""),v("")},required:!0},`section-${s}`),e.jsx(Z,{options:R,label:"Year",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:R.find(B=>String(B?.value)===String(y))??null,onChange:B=>m(String(B?.value??"")),required:!0}),e.jsx(Z,{options:A,label:"Month",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:A.find(B=>String(B?.value)===String(x))??null,onChange:B=>T(String(B?.value??"").padStart(2,"0")),required:!0},`month-${y}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"button",value:"Search",color:"primary",onClick:()=>k(B=>B+1)})})]}),e.jsx(Nt,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Month",value:A.find(B=>String(B?.value)===String(x))?.label??x},{label:"Year",value:y}]}),e.jsx(Tf,{})]});return e.jsxs(e.Fragment,{children:[e.jsx(ss,{title:"Monthly Report",subtitle:"Monthly class-wise attendance matrix and student drilldown.",printRef:a,exportRows:F,exportColumns:N,onRefresh:()=>O?.(),filterSection:I,summary:$,chartContent:e.jsx(ga,{summary:$,title:"Monthly Attendance Summary"}),reportTitle:"Monthly Attendance Table",fileBaseName:"monthly-attendance-report",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(Pt,{}),e.jsx(Nt,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Month",value:A.find(B=>String(B?.value)===String(x))?.label??x},{label:"Year",value:y}]})]}),e.jsx(kf,{data:M,loading:b,onViewStudent:j})]})}),e.jsx(Pf,{open:!!C,onClose:()=>j(null),loading:P,data:z,studentName:C?.student_name??C?.full_name})]})}const zf=kt.yearlyReport,Yf=t=>{const a=t?.data?.data??t?.data??t??{};return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:Array.isArray(a?.students)?a.students:Array.isArray(a?.report)?a.report:[]},Vf=t=>(Array.isArray(t)?t:[]).reduce((a,s)=>({present:a.present+Number(s?.singleStudentPresentData??s?.present??0),absent:a.absent+Number(s?.singleStudentAbsentData??s?.absent??0),late:a.late+Number(s?.late??0),leave:a.leave+Number(s?.leave??0)}),{present:0,absent:0,late:0,leave:0});function Wf({token:t}){const a=i.useRef(null),[s,r]=i.useState(""),[o,l]=i.useState(""),[d,c]=i.useState(""),[g,f]=i.useState(""),[u,p]=i.useState(""),[w,v]=i.useState(""),[y,m]=i.useState(""),[x,T]=i.useState(""),[D,k]=i.useState(0),C=as(t),j=ns(s,t),h=_f(t),S=i.useMemo(()=>!s||!d||D===0?null:Ya(zf.table,{class_id:s,section_id:d,session_id:u,batch_id:y}),[y,s,D,d,u]),{data:A,isLoading:R,mutate:q}=G(t&&S?[S,t]:null,([F,N])=>Ut(F,N)),U=i.useMemo(()=>Yf(A),[A]),b=i.useMemo(()=>Vf(U),[U]),O=i.useMemo(()=>[{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Present",dataIndex:"singleStudentPresentData"},{title:"Absent",dataIndex:"singleStudentAbsentData"}],[]),M=i.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(F,N,V)=>V+1},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",dataIndex:"full_name",key:"full_name"},{title:"Total Present",dataIndex:"singleStudentPresentData",key:"singleStudentPresentData",width:130},{title:"Total Absent",dataIndex:"singleStudentAbsentData",key:"singleStudentAbsentData",width:130}],[]),$=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Z,{options:C.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:F=>{r(F?.value??""),l(F?.label??""),c(""),f(""),m(""),T("")},required:!0}),e.jsx(Z,{options:j.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:F=>{c(F?.value??""),f(F?.label??""),m(""),T("")},required:!0},`section-${s}`),e.jsx(Z,{options:h.options,label:"Session",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:F=>{p(F?.value??""),v(F?.label??"")},required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"button",value:"Search",color:"primary",onClick:()=>k(F=>F+1)})})]}),e.jsx(Nt,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Session",value:w}]})]});return e.jsx(ss,{title:"Yearly Report",subtitle:"Yearly attendance summary migrated from ERP AttendanceDashboard.",printRef:a,exportRows:U,exportColumns:O,onRefresh:()=>q?.(),filterSection:$,summary:b,chartContent:e.jsx(ga,{summary:b,title:"Yearly Attendance Summary"}),reportTitle:"Yearly Attendance List",fileBaseName:"yearly-attendance-report",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(Pt,{}),e.jsx(Nt,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Session",value:w}]})]}),e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(F,N)=>String(F?.student_id??F?.id??N),columns:M,dataSource:U,loading:R,pagination:{pageSize:25},scroll:{x:"max-content"}})]})})}function Hf(){return null}const rs=t=>t??localStorage.getItem("authToken")??"",Kf=(t,a)=>{const s=String(t??""),r=String(a);return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},Ko=()=>JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",Ae={uploadNotes:"api/branchapi/Academy/uploadNotes",master:{classes:{dropdown:"api/branchapi/academy/classdropdownlist",table:"api/branchapi/academy/classestableList",add:"api/branchapi/academy/addclasses",edit:"api/branchapi/academy/editclass",remove:"api/branchapi/academy/deleteclass",show:"api/branchapi/academy/classShowdata"},sections:{list:"api/branchapi/academy/sectionlist",table:"api/branchapi/academy/sectiontableList",add:"api/branchapi/academy/addsections",edit:"api/branchapi/academy/editsection",remove:"api/branchapi/academy/deletesection",show:"api/branchapi/academy/sectionShowdata",byClass:"api/branchapi/academy/sectionoftheClass"},subjects:{dropdown:"api/branchapi/Academy/getClassSubjectdropdown",byClassLabelValue:"api/branchapi/Academy/getSubjectsbyClassaslablevalue",table:"api/branchapi/academy/subjecttableList",add:"api/branchapi/academy/addsubjects",edit:"api/branchapi/academy/editsubject",remove:"api/branchapi/academy/deletesubject",show:"api/branchapi/academy/subjectShowdata"},holidays:{table:"api/branchapi/academy/holidayList",add:"api/branchapi/academy/addholidays",edit:"api/branchapi/academy/editholidays",remove:"api/branchapi/academy/deleteholiday",show:"api/branchapi/academy/getByIdholidays"}},assignSubjects:{assign:"api/branchapi/Academy/assign_class_subjects",list:"api/branchapi/academy/getSubjectsbyClass",update:"api/branchapi/academy/updateAssignSubject",editByClass:"api/branchapi/academy/editSubjectsbyClass"},assignByClass:{teacherDropdown:"api/branchapi/topics/getTeacherDropdown",classWithSection:"api/branchapi/academy/getClasswithSection",assignedSubjectsOfTeacher:"api/branchapi/academy/getassignedSubjectsofTeacher",subjectsOfTeacherByTeacherId:"api/branchapi/academy/getSubjectsofTeacherbyTeacherID",assignClassToTeacher:"api/branchapi/academy/assignClasstoTeacher",deleteTeacherSub:"api/branchapi/academy/deleteTeacherSub"},promoteStudents:{searchByClassSection:"api/branchapi/student/currentSessionStudentlist",sessionDropdown:"api/branchapi/generalSettings/sessiondropdown",promote:"api/branchapi/student/promotestudent"},timeGroup:{table:"api/branchapi/academy/getTimeGroupTable",add:"api/branchapi/academy/addTimeGroup",edit:"api/branchapi/academy/editTimeGroup",remove:"api/branchapi/academy/deleteTimeGroup",show:"api/branchapi/academy/getTimeGroupDataById",dropdown:"api/branchapi/academy/getTimeGroupDropDown"},assignTimeGroup:{classIdByTimeGroup:"api/branchapi/academy/getClassIdByTimeGroup",table:"api/branchapi/academy/getAssignedTimeGroupTable",show:"api/branchapi/academy/getAssignedTimeGroupDataById",assign:"api/branchapi/academy/assignTimeGroup"},timetable:{save:"api/timetable/save",byClassSection:"api/timetable/class",teacherTimetable:"api/timetable/teacher/",teachersBySubject:"api/branchapi/Academy/gettechersSubject"},notes:{table:"api/branchapi/Academy/getNotesTable",add:"api/branchapi/Academy/addNotes"},syllabus:{table:"api/branchapi/Academy/getsyllabusTable",add:"api/branchapi/Academy/addsyllabus",edit:"api/branchapi/Academy/editsyllabus"},transferCertificate:{studentList:"api/branchapi/student/getstudenttransferCertificateList",addData:"api/branchapi/academy/addtransferCertificatedata",view:"api/branchapi/academy/gettransferCertificateUrl"},coscholastic:{table:"api/branchapi/academy/getcoscholastic",addSkill:"api/branchapi/academy/add_coscholastic_skill",deleteSkill:"api/branchapi/academy/deleteCoscholastic",categoryDropdown:"api/branchapi/academy/coscholastic_categorydropdown",addCategory:"api/branchapi/academy/addcoscholastic_category",deleteCategory:"api/branchapi/academy/coscholasticCategoryDelete"}},Gf=()=>Kf(at(),Ae.uploadNotes),Jf=async({baseUrl:t,page:a=1,perPage:s=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return J(l,rs(r))},wt=async(t,a,s,{includeSession:r=!1}={})=>{const o=a instanceof FormData?a:new FormData;return r&&!o.has("session_id")&&o.append("session_id",Ko()),Ne(t,o,rs(s))},Bt=async(t,a,s,{includeSession:r=!1}={})=>{const o=a instanceof FormData?a:new FormData;return r&&!o.has("session_id")&&o.append("session_id",Ko()),Qe(t,o,rs(s))},Lt=async(t,a,s)=>Ve(t,a,rs(s)),Bn=Ae.master.sections,an=({baseUrl:t,page:a=1,perPage:s=10,token:r})=>G(r&&t?[t,a,s,r]:null,([l,d,c,g])=>Jf({baseUrl:l,page:d,perPage:c},g)),Qf=({token:t,page:a=1,perPage:s=10})=>an({token:t,baseUrl:Bn.table,page:a,perPage:s}),Xf=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Zf({token:t}){const[a,s]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=n.Form.useForm(),{data:g,isLoading:f,mutate:u}=Qf({token:t,page:a.page,perPage:a.perPage}),p=i.useMemo(()=>Xf(g),[g]),w=i.useMemo(()=>g?.pagination?.total_rows??g?.pagination?.total??p.length??0,[g,p]),v=async D=>{D.preventDefault();const k=new FormData(D.target);try{await wt(Bn.add,k,t),_.success("Success! Added new item.",{duration:1e3}),D.target.reset(),u()}catch(C){_.error(C?.response?.data?.msg??C?.message??"Failed to add the new item.",{duration:1500})}},y=async D=>{try{await Lt(Bn.remove,D,t),_.success("Success! Deleted item.",{duration:1e3}),u()}catch(k){_.error(k?.response?.data?.msg??k?.message??"Failed to delete the item.",{duration:1500})}},m=D=>{d(D),o(!0),c.setFieldsValue({section:D?.section??""})},x=async D=>{const k=new FormData;k.append("id",String(l?.id??"")),k.append("section",D.section??"");try{await Bt(Bn.edit,k,t),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),u()}catch(C){_.error(C?.response?.data?.msg??C?.message??"Failed to update the item.",{duration:1500})}},T=i.useMemo(()=>[{title:"Section",dataIndex:"section",key:"section"},{title:"Actions",key:"actions",width:120,render:(D,k)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>m(k)}),e.jsx(n.Popconfirm,{title:"Delete this section?",onConfirm:()=>y(k?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Section",open:r,onClose:()=>{o(!1),d(null)},width:420,children:e.jsxs(n.Form,{form:c,layout:"vertical",onFinish:x,children:[e.jsx(n.Form.Item,{label:"Section Name",name:"section",rules:[{required:!0,message:"Section Name is required"}],children:e.jsx(n.Input,{placeholder:"Section Name"})}),e.jsxs(n.Space,{children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Section"}),children:e.jsx("form",{onSubmit:v,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"section",label:"Section Name",required:!0}),e.jsx(ie,{type:"submit",value:"Submit",color:"primary"})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Section List"}),extra:e.jsx(n.Space,{}),children:e.jsx(n.Table,{rowKey:D=>D.id,columns:T,dataSource:p,loading:f,pagination:{current:a.page,pageSize:a.perPage,total:w,showSizeChanger:!0,onChange:(D,k)=>s({page:D,perPage:k})}})})]})}function eh({token:t}){return e.jsx(Zf,{token:t})}const Na=Ae.master.classes,th=({token:t,page:a=1,perPage:s=10})=>an({token:t,baseUrl:Na.table,page:a,perPage:s}),ah=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},nh=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:[];function sh({token:t}){const[a,s]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=n.Form.useForm(),[g]=n.Form.useForm(),{data:f}=G(t?[Ae.master.sections.list,t]:null,([A,R])=>J(A,R)),u=i.useMemo(()=>nh(f),[f]),p=i.useMemo(()=>u.map(A=>({label:A.label??A.section??String(A.value??""),value:String(A.value??A.id??"")})),[u]),{data:w,isLoading:v,mutate:y}=th({token:t,page:a.page,perPage:a.perPage}),m=i.useMemo(()=>ah(w),[w]),x=i.useMemo(()=>w?.pagination?.total_rows??w?.pagination?.total??m.length??0,[w,m]),{data:T}=G(t&&l?[`${Na.show}?id=${encodeURIComponent(String(l))}`,t]:null,([A,R])=>J(A,R)),D=i.useMemo(()=>{const A=T?.data??T;return Array.isArray(A)?A:Array.isArray(A?.data)?A.data:A?[A]:[]},[T]),k=A=>{const R=A?.id??A?.class_id;R&&(d(R),o(!0))};i.useEffect(()=>{if(!r||!D.length)return;const A=D[0],R=D.map(b=>b?.section_id??b?.fk_sectionId??b?.sectionId??b?.section).filter(b=>b!=null&&String(b).trim()!=="").map(b=>String(b)),q=Array.isArray(A?.section_ids)?A.section_ids.map(b=>String(b)):typeof A?.section_ids=="string"?A.section_ids.split(",").map(b=>b.trim()).filter(Boolean):Array.isArray(A?.section)?A.section.map(b=>String(b)):[],U=R.length?R:q;g.setFieldsValue({name:A?.class??A?.name??"",section:U})},[r,D,g]);const C=async A=>{const R=new FormData;R.append("name",A.name??""),(A.section??[]).forEach(q=>R.append("section[]",String(q)));try{await wt(Na.add,R,t),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),y()}catch(q){_.error(q?.response?.data?.msg??q?.message??"Failed to add the new item.",{duration:1500})}},j=async A=>{const R=new FormData;R.append("id",String(l??"")),R.append("name",A.name??""),(A.section??[]).forEach(q=>R.append("section[]",String(q)));try{await Bt(Na.edit,R,t),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),y()}catch(q){_.error(q?.response?.data?.msg??q?.message??"Failed to update the item.",{duration:1500})}},h=async A=>{try{await Lt(Na.remove,A,t),_.success("Success! Deleted item.",{duration:1e3}),y()}catch(R){_.error(R?.response?.data?.msg??R?.message??"Failed to delete the item.",{duration:1500})}},S=i.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class",render:(A,R)=>A??R?.name??""},{title:"Section",dataIndex:"sections",key:"sections",render:A=>A??""},{title:"Actions",key:"actions",width:120,render:(A,R)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>k(R)}),e.jsx(n.Popconfirm,{title:"Delete this class?",onConfirm:()=>h(R?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Class",open:r,onClose:()=>{o(!1),d(null)},width:520,children:e.jsxs(n.Form,{form:g,layout:"vertical",onFinish:j,children:[e.jsx(n.Form.Item,{label:"Class",name:"name",rules:[{required:!0,message:"Class is required"}],children:e.jsx(n.Input,{placeholder:"Class"})}),e.jsx(n.Form.Item,{label:"Sections",name:"section",rules:[{required:!0,message:"Please select at least one section"}],children:e.jsx(n.Checkbox.Group,{options:p})}),e.jsxs(n.Space,{children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Class"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:C,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",label:"Class",rules:[{required:!0,message:"Class is required"}],children:e.jsx(n.Input,{placeholder:"Class"})}),e.jsx(n.Form.Item,{name:"section",label:"Sections",rules:[{required:!0,message:"Select at least one section"}],children:e.jsx(n.Checkbox.Group,{options:p})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Class List"}),children:e.jsx(n.Table,{rowKey:A=>A.id,columns:S,dataSource:m,loading:v,pagination:{current:a.page,pageSize:a.perPage,total:x,showSizeChanger:!0,onChange:(A,R)=>s({page:A,perPage:R})}})})]})}function rh({token:t}){return e.jsx(sh,{token:t})}const Ba=Ae.master.subjects,ih=({token:t,page:a=1,perPage:s=10})=>an({token:t,baseUrl:Ba.table,page:a,perPage:s}),oh=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Mi=[{value:"Practical",label:"Practical"},{value:"Theory",label:"Theory"}],Ei=[{value:"Main",label:"Main"},{value:"Additional",label:"Minor/Additional"},{value:"extra_curricular_activities",label:"Extra Curricular Activities"}];function lh({token:t}){const[a,s]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=n.Form.useForm(),[g]=n.Form.useForm(),{data:f,isLoading:u,mutate:p}=ih({token:t,page:a.page,perPage:a.perPage}),w=i.useMemo(()=>oh(f),[f]),v=i.useMemo(()=>f?.pagination?.total_rows??f?.pagination?.total??w.length??0,[f,w]),{data:y}=G(t&&l?[`${Ba.show}?id=${encodeURIComponent(String(l))}`,t]:null,([j,h])=>J(j,h)),m=i.useMemo(()=>{const j=y?.data??y;return Array.isArray(j)?j[0]:j??null},[y]);i.useEffect(()=>{r&&m&&g.setFieldsValue({name:m?.name??"",subject_type:m?.subject_type??m?.type??"",type:"",subject_types:Array.isArray(m?.subject_types)?m.subject_types:typeof m?.subject_types=="string"?m.subject_types.split(",").map(j=>j.trim()).filter(Boolean):[],code:m?.code??""})},[r,m,g]);const x=async j=>{const h=j?.type??j?.subject_type??"",S={name:j?.name??"",subject_type:h,type:h,subject_types:Array.isArray(j?.subject_types)?j.subject_types:[],code:j?.code??""};try{await Ne(Ba.add,S,t),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),p()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to add the new item.",{duration:1500})}},T=async j=>{const h=new FormData,S=j?.type??j?.subject_type??"";h.append("id",String(l??"")),h.append("name",j.name??""),h.append("subject_type",j.subject_type??""),h.append("subject_type",S),h.append("type",S),h.append("code",j.code??"");try{await Bt(Ba.edit,h,t),_.success("Success! Updated item.",{duration:1e3}),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),p()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to update the item.",{duration:1500})}},D=async j=>{try{await Lt(Ba.remove,j,t),_.success("Success! Deleted item.",{duration:1e3}),p()}catch(h){_.error(h?.response?.data?.msg??h?.message??"Failed to delete the item.",{duration:1500})}},k=j=>{const h=j?.id;h&&(d(h),o(!0))},C=i.useMemo(()=>[{title:"Subject Name",dataIndex:"name",key:"name"},{title:"Subject",dataIndex:"subject_type",key:"subject_type"},{title:"Subject Code",dataIndex:"code",key:"code"},{title:"Subject Type",key:"subject_types",render:(j,h)=>{const S=[],A=h?.subject_types;Array.isArray(A)?A.forEach(O=>{const M=String(O??"").trim();M&&S.push(M)}):typeof A=="string"&&A.split(",").map(O=>O.trim()).filter(Boolean).forEach(O=>S.push(O));const R=["yes","1","true"].includes(String(h?.is_practical??"").toLowerCase()),q=["yes","1","true"].includes(String(h?.is_theory??"").toLowerCase());R&&S.push("Practical"),q&&S.push("Theory");const U=S.map(O=>String(O??"").trim()).filter(Boolean).map(O=>O.toLowerCase()==="practical"?"Practical":O.toLowerCase()==="theory"?"Theory":O),b=Array.from(new Set(U));return b.length?b.join(", "):"-"}},{title:"Actions",key:"actions",width:120,render:(j,h)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>k(h)}),e.jsx(n.Popconfirm,{title:"Delete this subject?",onConfirm:()=>D(h?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Subject",open:r,onClose:()=>{o(!1),d(null)},width:560,children:e.jsxs(n.Form,{form:g,layout:"vertical",onFinish:T,children:[e.jsx(n.Form.Item,{label:"Subject Name",name:"name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(Y,{placeholder:"Subject Name"})}),e.jsx(n.Form.Item,{label:"Subject",name:"subject_type",rules:[{required:!0,message:"Select subject category"}],children:e.jsx(n.Radio.Group,{options:Ei})}),e.jsx(n.Form.Item,{label:"Subject Type",name:"subject_types",rules:[{required:!0,type:"array",min:1,message:"Please choose at least one field"}],children:e.jsx(n.Checkbox.Group,{options:Mi})}),e.jsx(n.Form.Item,{label:"Subject Code",name:"code",children:e.jsx(Y,{placeholder:"Subject Code"})}),e.jsxs(n.Space,{children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Subject"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:x,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",label:"Subject Name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(Y,{placeholder:"Subject Name"})}),e.jsx(n.Form.Item,{name:"subject_type",label:"Subject",rules:[{required:!0,message:"Select subject"}],children:e.jsx(n.Radio.Group,{options:Ei})}),e.jsx(n.Form.Item,{name:"subject_types",label:"Subject Type",rules:[{required:!0,type:"array",min:1,message:"Please choose at least one field"}],children:e.jsx(n.Checkbox.Group,{options:Mi})}),e.jsx(n.Form.Item,{name:"code",label:"Subject Code",children:e.jsx(Y,{placeholder:"Subject Code"})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Subject List"}),children:e.jsx(n.Table,{rowKey:j=>j.id,columns:C,dataSource:w,loading:u,pagination:{current:a.page,pageSize:a.perPage,total:v,showSizeChanger:!0,onChange:(j,h)=>s({page:j,perPage:h})}})})]})}function dh({token:t}){return e.jsx(lh,{token:t})}const La=Ae.master.holidays,ch=({token:t,page:a=1,perPage:s=10})=>an({token:t,baseUrl:La.table,page:a,perPage:s}),uh=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},wn={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function ph({token:t}){const[a,s]=i.useState({page:1,perPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=n.Form.useForm(),[g]=n.Form.useForm(),{data:f,isLoading:u,mutate:p}=ch({token:t,page:a.page,perPage:a.perPage}),w=i.useMemo(()=>uh(f),[f]),v=i.useMemo(()=>f?.pagination?.total_rows??f?.pagination?.total??w.length??0,[f,w]),{data:y}=G(t&&l?[`${La.show}?id=${encodeURIComponent(String(l))}`,t]:null,([j,h])=>J(j,h)),m=i.useMemo(()=>{const j=y?.data??y;return Array.isArray(j)?j[0]:j??null},[y]);i.useEffect(()=>{r&&m&&g.setFieldsValue({title:m?.holiday_title??"",description:m?.holiday_description??"",from:m?.start_date?ae(m.start_date):null,to:m?.end_date?ae(m.end_date):null})},[r,m,g]);const x=async j=>{const h=new FormData;h.append("title",j.title??""),h.append("description",j.description??""),h.append("from",j.from?ae(j.from).format("YYYY-MM-DD"):""),h.append("to",j.to?ae(j.to).format("YYYY-MM-DD"):"");try{await wt(La.add,h,t,{includeSession:!0}),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),p()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to add the new item.",{duration:1500})}},T=async j=>{const h=new FormData;h.append("id",String(l??"")),h.append("title",j.title??""),h.append("description",j.description??""),h.append("from",j.from?ae(j.from).format("YYYY-MM-DD"):""),h.append("to",j.to?ae(j.to).format("YYYY-MM-DD"):"");try{await Bt(La.edit,h,t,{includeSession:!0}),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),p()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to update the item.",{duration:1500})}},D=async j=>{try{await Lt(La.remove,j,t),_.success("Success! Deleted item.",{duration:1e3}),p()}catch(h){_.error(h?.response?.data?.msg??h?.message??"Failed to delete the item.",{duration:1500})}},k=j=>{const h=j?.id;h&&(d(h),o(!0))},C=i.useMemo(()=>[{title:"Holiday Title",dataIndex:"holiday_title",key:"holiday_title"},{title:"Holiday Description",dataIndex:"holiday_description",key:"holiday_description"},{title:"Start From",dataIndex:"start_date",key:"start_date"},{title:"End At",dataIndex:"end_date",key:"end_date"},{title:"Actions",key:"actions",width:120,render:(j,h)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>k(h)}),e.jsx(n.Popconfirm,{title:"Delete this holiday?",onConfirm:()=>D(h?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Holiday",open:r,onClose:()=>{o(!1),d(null)},width:560,children:e.jsxs(n.Form,{form:g,layout:"vertical",onFinish:T,children:[e.jsx(n.Form.Item,{label:"Holiday Title",name:"title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(Y,{placeholder:"Holiday Title"})}),e.jsx(n.Form.Item,{label:"Holiday Description",name:"description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(Y,{placeholder:"Holiday Description"})}),e.jsx(n.Form.Item,{label:"Start From",name:"from",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:wn})}),e.jsx(n.Form.Item,{label:"End At",name:"to",rules:[{required:!0,message:"End date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:wn})}),e.jsxs(n.Space,{children:[e.jsx(ie,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Holidays"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:x,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"title",label:"Holiday Title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(Y,{placeholder:"Holiday Title"})}),e.jsx(n.Form.Item,{name:"description",label:"Holiday Description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(vt,{placeholder:"Holiday Description"})}),e.jsx(n.Form.Item,{name:"from",label:"Start From",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:wn})}),e.jsx(n.Form.Item,{name:"to",label:"End At",rules:[{required:!0,message:"End date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:wn})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Holidays List"}),children:e.jsx(n.Table,{rowKey:j=>j.id,columns:C,dataSource:w,loading:u,pagination:{current:a.page,pageSize:a.perPage,total:v,showSizeChanger:!0,onChange:(j,h)=>s({page:j,perPage:h})}})})]})}function mh({token:t}){return e.jsx(ph,{token:t})}const Ln=Ae.assignSubjects,fh=({token:t,page:a=1,perPage:s=50})=>an({token:t,baseUrl:Ln.list,page:a,perPage:s}),Fi=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],hh=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function yh({token:t}){const[a,s]=i.useState({page:1,perPage:50}),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,g]=i.useState(!1),[f,u]=i.useState(!1),[p,w]=i.useState(null),[v,y]=i.useState([]),{data:m}=G(t?[Ae.master.classes.dropdown,t]:null,([M,$])=>J(M,$)),{data:x}=G(t?[Ae.master.subjects.dropdown,t]:null,([M,$])=>J(M,$)),T=i.useMemo(()=>Fi(m),[m]),D=i.useMemo(()=>Fi(x),[x]),k=i.useMemo(()=>D.map(M=>({label:M.label??M.subject??String(M.value??""),value:M.value??M.id})),[D]),{data:C,isLoading:j,mutate:h}=fh({token:t,page:a.page,perPage:a.perPage}),S=i.useMemo(()=>hh(C),[C]),A=i.useMemo(()=>C?.pagination?.total_rows??C?.pagination?.total??S.length??0,[C,S]),{data:R}=G(t&&p?[`${Ln.editByClass}?class_id=${encodeURIComponent(String(p))}`,t]:null,([M,$])=>J(M,$));i.useEffect(()=>{if(!f)return;const M=R?.data??R,$=Array.isArray(M)?M:Array.isArray(M?.data)?M.data:[];y($.map(F=>F.subject_id).filter(Boolean))},[f,R]);const q=async M=>{if(M.preventDefault(),!r?.value){_.error("Please select class",{duration:1200});return}if(!l.length){_.error("Please select subjects",{duration:1200});return}const $=new FormData;$.append("class_id",String(r.value)),l.forEach(F=>$.append("subject[]",String(F)));try{g(!0),await Bt(Ln.assign,$,t),_.success("Success! Updated item.",{duration:1e3}),o(null),d([]),h()}catch(F){_.error(F?.response?.data?.msg??F?.message??"Failed to update the item.",{duration:1500})}finally{g(!1)}},U=M=>{M&&(w(M),u(!0))},b=async()=>{if(!p)return;if(!v.length){_.error("Please select subjects",{duration:1200});return}const M=new FormData;M.append("class_id",String(p)),v.forEach($=>M.append("subject[]",String($)));try{await Bt(Ln.update,M,t),_.success("Success! Updated item.",{duration:1e3}),u(!1),w(null),h()}catch($){_.error($?.response?.data?.msg??$?.message??"Failed to update the item.",{duration:1500})}},O=i.useMemo(()=>[{title:"Class",dataIndex:"class",align:"center",width:"15%"},{title:"Subject",dataIndex:"subject_name",width:"70%",render:(M,$)=>e.jsx("div",{style:{paddingLeft:10,paddingRight:10,fontSize:14},children:($?.subject_name??M??"").split(",").join(", ")})},{title:"Action",width:"10%",render:(M,$)=>e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>U($?.class_id)})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Assigned Subjects",open:f,onClose:()=>{u(!1),w(null)},width:520,extra:e.jsxs(n.Space,{children:[e.jsx(n.Button,{onClick:()=>u(!1),children:"Cancel"}),e.jsx(n.Button,{type:"primary",onClick:b,children:"Update"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Z,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:T.find(M=>String(M.value)===String(p))??null,onChange:()=>{},isDisabled:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(n.Checkbox.Group,{options:k,value:v,onChange:y})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Subject"}),children:e.jsx("form",{onSubmit:q,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:r,onChange:M=>o(M??null)}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(n.Checkbox.Group,{options:k,value:l,onChange:d})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:c?"Please Wait..":"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assigned Subject List"}),children:e.jsx(n.Table,{rowKey:M=>M.id,columns:O,dataSource:S,loading:j,pagination:{current:a.page,pageSize:a.perPage,total:A,showSizeChanger:!0,onChange:(M,$)=>s({page:M,perPage:$})}})})]})}function gh({token:t}){return e.jsx(yh,{token:t})}const ua=Ae.assignByClass,Go=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(typeof t?.data?.Status=="string"&&Array.isArray(t?.data?.data))return t.data.data;if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},Oa=t=>Go(t),xh=t=>Go(t),Ma=t=>Array.isArray(t)?t:t==null||t===""?[]:[t];function bh({token:t}){const[a,s]=i.useState(null),[r,o]=i.useState(null),[l,d]=i.useState(null),[c,g]=i.useState("No"),[f,u]=i.useState([]),[p,w]=i.useState([]),[v,y]=i.useState(null),[m,x]=i.useState(null),[T,D]=i.useState(!1),[k,C]=i.useState(""),{data:j}=G(t?[ua.teacherDropdown,t]:null,([de,Q])=>J(de,Q)),{data:h}=G(t?[Ae.master.classes.dropdown,t]:null,([de,Q])=>J(de,Q)),{data:S}=G(t&&m?[m,t]:null,([de,Q])=>J(de,Q)),{data:A}=G(t&&v?[v,t]:null,([de,Q])=>J(de,Q)),R=i.useMemo(()=>Oa(j),[j]),q=i.useMemo(()=>Oa(h),[h]),U=i.useMemo(()=>Oa(S),[S]),b=i.useMemo(()=>Oa(A),[A]),{data:O}=G(t&&a&&r&&l?[`${ua.subjectsOfTeacherByTeacherId}?teacher_id=${encodeURIComponent(String(a))}&class_id=${encodeURIComponent(String(r))}§ion_id=${encodeURIComponent(String(l))}`,t]:null,([de,Q])=>J(de,Q)),M=O?.data??O??null;i.useEffect(()=>{M&&(u(Array.isArray(M?.subject_ids)?M.subject_ids:[]),g(M?.isClassTeacher||"No"),w([]))},[M]);const{data:$}=G(t?[ua.classWithSection,t]:null,([de,Q])=>J(de,Q)),F=i.useMemo(()=>Oa($),[$]),[N,V]=i.useState(null),[z,P]=i.useState({page:1,perPage:25});i.useEffect(()=>{N||F?.[0]&&V(`${F[0].class_id}val${F[0].section_id}`)},[F,N]);const I=i.useMemo(()=>typeof window>"u"?"1":JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",[]),B=i.useMemo(()=>{if(!N)return null;const[de,Q]=String(N).split("val");if(!de||!Q)return null;const ce=z.page??1,Te=z.perPage??25;return`${ua.assignedSubjectsOfTeacher}?page=${encodeURIComponent(String(ce))}&per_page=${encodeURIComponent(String(Te))}&session_id=${encodeURIComponent(String(I))}&class_id=${encodeURIComponent(String(de))}§ion_id=${encodeURIComponent(String(Q))}`},[N,z.page,z.perPage,I]),{data:L,isLoading:H,mutate:se}=G(t&&B?[B,t]:null,([de,Q])=>J(de,Q),{revalidateOnFocus:!1}),W=i.useMemo(()=>xh(L),[L]),K=i.useMemo(()=>{const de=L?.pagination??L?.data?.pagination??L?.data?.data?.pagination;return de?.total_rows??de?.total??W.length??0},[L,W]),te=async de=>{if(de.preventDefault(),C(""),!a||!r||!l){_.error("Please select Teacher, Class and Section",{duration:1200});return}if(!Array.isArray(f)||f.length===0){C("error"),_.error("Please Select Subject",{duration:1200});return}const Q=new FormData;Q.append("teacher_id",String(a)),Q.append("class_id",String(r)),Q.append("section_id",String(l)),Q.append("isClassTeacher",String(c??"No")),Ma(f).forEach(ce=>Q.append("subject_ids[]",String(ce))),Ma(p).forEach(ce=>Q.append("delete_subject[]",String(ce)));try{await wt(ua.assignClassToTeacher,Q,t,{includeSession:!0}),_.success("Success! Added new item.",{duration:1e3}),C(""),se()}catch(ce){_.error(ce?.response?.data?.msg??ce?.message??"Failed to add the new item.",{duration:1500})}},oe=async de=>{try{await Lt(ua.deleteTeacherSub,de,t),_.success("Success! Deleted item.",{duration:1e3}),se()}catch(Q){_.error(Q?.response?.data?.msg??Q?.message??"Failed to delete the item.",{duration:1500})}},pe=de=>{const Q=Array.isArray(de?.child)?de.child:[],ce=[{title:"Subject",dataIndex:"subject",key:"subject",align:"center"},{title:"Subject Code",dataIndex:"code",key:"code",align:"center"},{title:"Action",key:"action",align:"center",render:(Te,Ee)=>e.jsx(n.Popconfirm,{title:"Delete this subject?",onConfirm:()=>oe(Ee?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})}];return e.jsx("div",{style:{margin:12},children:e.jsx(n.Table,{columns:ce,bordered:!0,size:"small",dataSource:Q,pagination:!1,rowKey:Te=>Te.id})})},we=[{title:"Teacher Name",dataIndex:"teacher_name",key:"teacher_name",align:"center",render:(de,Q)=>e.jsxs("div",{children:[Q.teacher_name,Q.classTeacher==="Yes"?e.jsx("span",{style:{fontWeight:700},children:" (Class Teacher)"}):null]})}],le=i.useMemo(()=>(F??[]).map(de=>({label:de.label??`${de.class_name??""} ${de.section_name??""}`.trim(),key:`${de.class_id}val${de.section_id}`,children:e.jsx(n.Table,{size:"small",columns:we,bordered:!0,dataSource:Array.isArray(W)?W:[],loading:H,rowKey:Q=>Q.id,expandable:{expandedRowRender:pe},pagination:{current:z.page,pageSize:z.perPage,total:K,showSizeChanger:!0,onChange:(Q,ce)=>P({page:Q,perPage:ce})}})})),[F,z.page,z.perPage,W,H,K]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(320px, 380px) 1fr",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign by Class"}),children:e.jsx("form",{onSubmit:te,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Z,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teachers",name:"teacher_id",required:!0,allowSelectAll:!1,value:R.find(de=>String(de.value)===String(a))??null,onChange:de=>s(de?.value??null)}),e.jsx(Z,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:q.find(de=>String(de.value)===String(r))??null,onChange:de=>{const Q=de?.value??null;o(Q),d(null),y(Q?`${Ae.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(Q))}`:null),x(Q?`${Ae.master.sections.byClass}?class_id=${encodeURIComponent(String(Q))}`:null),D(ce=>!ce)}}),e.jsx(Z,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",required:!0,allowSelectAll:!1,value:U.find(de=>String(de.value)===String(l))??null,onChange:de=>d(de?.value??null)},`section_${T}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Is Class Teacher?"}),(()=>{const de=[{label:"Yes",value:"Yes"},{label:"No",value:"No"}];return e.jsx(Z,{style:{width:"100%"},options:de,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:de.find(Q=>String(Q.value)===String(c??"No"))??de[1],onChange:Q=>g(Q?.value??"No")})})()]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subject"}),e.jsx(Z,{isMulti:!0,style:{width:"100%"},placeholder:"select Subject",options:b,value:(b??[]).filter(de=>Ma(f).some(Q=>String(Q)===String(de.value))),onChange:(de,Q)=>{const Te=(Array.isArray(de)?de:[]).map($e=>$e?.value).filter($e=>$e!=null&&$e!=="");u(Te);const Ee=Array.isArray(M?.subject_ids)?M.subject_ids.map(String):[],Ie=Q?.removedValue?.value,Le=Q?.option?.value;(Q?.action==="remove-value"||Q?.action==="pop-value")&&Ie!=null&&Ee.includes(String(Ie))&&w($e=>Array.from(new Set([...Ma($e).map(String),String(Ie)]))),Q?.action==="select-option"&&Le!=null&&Ee.includes(String(Le))&&w($e=>Ma($e).filter(et=>String(et)!==String(Le)))}},`subjects_${T}`),k?e.jsx("div",{style:{color:"#ff4d4f",marginTop:6,fontSize:12},children:"Please select subject"}):null]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Teacher List"}),children:e.jsx(n.Tabs,{activeKey:N??void 0,onChange:de=>{V(de),P(Q=>({...Q,page:1}))},items:le,type:"card",size:"small"})})]})]})}function jh({token:t}){return e.jsx(bh,{token:t})}const Ea=Ae.timeGroup,Sh=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Ft={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function _n(t){if(!t)return null;const a=ae(String(t),["h:mm a","HH:mm:ss","HH:mm"],!0);return a.isValid()?a:null}function $t(t){return t?ae(t).format("h:mm a"):""}function vh({token:t}){const[a,s]=i.useState({page:1,perPage:50}),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c]=n.Form.useForm(),[g]=n.Form.useForm(),f=`${Ea.table}?page=${encodeURIComponent(String(a.page))}&per_page=${encodeURIComponent(String(a.perPage))}`,{data:u,isLoading:p,mutate:w}=G(t?[f,t]:null,([h,S])=>J(h,S)),v=i.useMemo(()=>Sh(u),[u]),y=i.useMemo(()=>u?.pagination?.total_rows??u?.pagination?.total??v.length??0,[u,v]),{data:m}=G(t&&l?[`${Ea.show}?id=${encodeURIComponent(String(l))}`,t]:null,([h,S])=>J(h,S)),x=i.useMemo(()=>{const h=m?.data??m;return Array.isArray(h)?h[0]:h??null},[m]);i.useEffect(()=>{r&&x&&g.setFieldsValue({title:x?.title??"",start_time_from:_n(x?.start_time_from),start_time_to:_n(x?.start_time_to),end_time_from:_n(x?.end_time_from),end_time_to:_n(x?.end_time_to)})},[r,x,g]);const T=async h=>{const S=new FormData;S.append("title",h.title??""),S.append("start_time_from",$t(h.start_time_from)),S.append("start_time_to",$t(h.start_time_to)),S.append("end_time_from",$t(h.end_time_from)),S.append("end_time_to",$t(h.end_time_to));try{await wt(Ea.add,S,t),_.success("Success! Added new item.",{duration:1e3}),c.resetFields(),w()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to add the new item.",{duration:1500})}},D=async h=>{const S=new FormData;S.append("id",String(l??"")),S.append("title",h.title??""),S.append("start_time_from",$t(h.start_time_from)),S.append("start_time_to",$t(h.start_time_to)),S.append("end_time_from",$t(h.end_time_from)),S.append("end_time_to",$t(h.end_time_to));try{await Bt(Ea.edit,S,t),_.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),w()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to update the item.",{duration:1500})}},k=async h=>{try{await Lt(Ea.remove,h,t),_.success("Success! Deleted item.",{duration:1e3}),w()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to delete the item.",{duration:1500})}},C=h=>{h?.id&&(d(h.id),o(!0))},j=i.useMemo(()=>[{title:"Title",dataIndex:"title",align:"center"},{title:"Start Time From",dataIndex:"start_time_from",align:"center"},{title:"Start Time To",dataIndex:"start_time_to",align:"center"},{title:"End Time From",dataIndex:"end_time_from",align:"center"},{title:"End Time To",dataIndex:"end_time_to",align:"center"},{title:"Action",align:"center",width:120,render:(h,S)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>C(S)}),e.jsx(n.Popconfirm,{title:"Delete this time group?",onConfirm:()=>k(S?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Time Group",open:r,onClose:()=>{o(!1),d(null)},width:520,children:e.jsxs(n.Form,{form:g,layout:"vertical",onFinish:D,children:[e.jsx(n.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(Y,{placeholder:"Title"})}),e.jsx(n.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ft})}),e.jsx(n.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ft})}),e.jsx(n.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ft})}),e.jsx(n.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ft})}),e.jsxs(n.Space,{children:[e.jsx(ie,{type:"submit",value:"Submit",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Create Time Group"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:T,initialValues:{},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(Y,{placeholder:"Title"})}),e.jsx(n.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ft})}),e.jsx(n.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ft})}),e.jsx(n.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ft})}),e.jsx(n.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ft})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Time Group List"}),children:e.jsx(n.Table,{rowKey:h=>h.id,columns:j,dataSource:v,loading:p,pagination:{current:a.page,pageSize:a.perPage,total:y,showSizeChanger:!0,onChange:(h,S)=>s({page:h,perPage:S})}})})]})}function wh({token:t}){return e.jsx(vh,{token:t})}const Fa=Ae.assignTimeGroup,_h=Ae.timeGroup.dropdown,Ch=Ae.master.classes.dropdown,$i=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Ah=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Th({token:t}){const[a,s]=i.useState({page:1,perPage:50}),[r,o]=i.useState(null),[l,d]=i.useState([]),[c,g]=i.useState(""),[f,u]=i.useState(""),[p,w]=i.useState(null),[v,y]=i.useState(!1),[m,x]=i.useState(!1),[T,D]=i.useState(null),[k,C]=i.useState([]),[j,h]=i.useState(""),[S,A]=i.useState(""),{data:R}=G(t?[_h,t]:null,([W,K])=>J(W,K)),{data:q}=G(t?[Ch,t]:null,([W,K])=>J(W,K)),U=i.useMemo(()=>$i(R?.data??R),[R]),b=i.useMemo(()=>$i(q),[q]),{data:O}=G(t&&p?[p,t]:null,([W,K])=>J(W,K));i.useEffect(()=>{const W=Array.isArray(O?.data)?O.data.map(K=>K.fk_classId):[];W.length&&d(W)},[O]);const M=`${Fa.table}?page=${encodeURIComponent(String(a.page))}&per_page=${encodeURIComponent(String(a.perPage))}`,{data:$,isLoading:F,mutate:N}=G(t?[M,t]:null,([W,K])=>J(W,K)),V=i.useMemo(()=>Ah($),[$]),z=i.useMemo(()=>$?.pagination?.total_rows??$?.pagination?.total??V.length??0,[$,V]),{data:P}=G(t&&T?[`${Fa.show}?id=${encodeURIComponent(String(T))}`,t]:null,([W,K])=>J(W,K)),I=P?.data??P??null;i.useEffect(()=>{if(!m||!I)return;const W=Array.isArray(I?.class_ids)?I.class_ids:[];C(W);const K=Array.isArray(U)?U.find(te=>String(te.value)===String(I?.timegroup_id)):null;K&&A(`${K.start_time_from} -> ${K.end_time_from}`)},[m,I,U]);const B=async W=>{if(W.preventDefault(),g(""),!r?.value){_.error("Select Time Group",{duration:1200});return}if(!l.length){g("error"),_.error("Please Select Classes",{duration:1200});return}const K=new FormData;K.append("timegroup_id",String(r.value)),l.forEach(te=>K.append("class_ids[]",String(te)));try{await wt(Fa.assign,K,t),_.success("Success! Added new item.",{duration:1e3}),d([]),o(null),u(""),N()}catch(te){_.error(te?.response?.data?.msg??te?.message??"Failed to add the new item.",{duration:1500})}},L=async()=>{if(h(""),!T)return;if(!k.length){h("error"),_.error("Please Select Classes",{duration:1200});return}const W=new FormData;W.append("id",String(T)),W.append("timegroup_id",String(I?.timegroup_id??"")),k.forEach(K=>W.append("class_ids[]",String(K)));try{await Bt(Fa.assign,W,t),_.success("Success! Updated item.",{duration:1e3}),x(!1),D(null),N()}catch(K){_.error(K?.response?.data?.msg??K?.message??"Failed to update the item.",{duration:1500})}},H=W=>{W&&(D(W),x(!0))},se=i.useMemo(()=>[{title:"Title",dataIndex:"title",align:"center"},{title:"Class Names",dataIndex:"class_names",align:"center"},{title:"Start Time From",dataIndex:"start_time_from",align:"center"},{title:"Start Time To",dataIndex:"start_time_to",align:"center"},{title:"End Time From",dataIndex:"end_time_from",align:"center"},{title:"End Time To",dataIndex:"end_time_to",align:"center"},{title:"Action",align:"center",width:90,render:(W,K)=>K?.class_names?e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>H(K?.id)}):null}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Assigned Time Group",open:m,onClose:()=>{x(!1),D(null)},width:520,extra:e.jsxs(n.Space,{children:[e.jsx(n.Button,{onClick:()=>x(!1),children:"Cancel"}),e.jsx(n.Button,{type:"primary",onClick:L,children:"Submit"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Z,{options:Array.isArray(U)?U:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",allowSelectAll:!1,value:U.find(W=>String(W.value)===String(I?.timegroup_id))??null,onChange:()=>{},isDisabled:!0}),e.jsx("div",{style:{marginTop:4,fontSize:16},children:S}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(n.Select,{mode:"multiple",style:{width:"100%"},status:j,value:k,placeholder:"Select Classes",onChange:W=>C(W),options:Array.isArray(b)?b:[]})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Time Group"}),children:e.jsx("form",{onSubmit:B,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsxs("div",{children:[e.jsx(Z,{options:Array.isArray(U)?U:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",required:!0,allowSelectAll:!1,value:r,onChange:W=>{o(W??null),d([]),g(""),W?.value?(w(`${Fa.classIdByTimeGroup}?id=${encodeURIComponent(String(W.value))}`),u(`${W.start_time_from} -> ${W.end_time_from}`)):(w(null),u("")),y(K=>!K)}}),e.jsx("div",{style:{marginTop:6},children:f})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(Z,{mode:"multiple",style:{width:"100%"},status:c,value:l,placeholder:"Select Classes",onChange:W=>d(W),options:Array.isArray(b)?b:[]},`class_${v}`)]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assigned Time group List"}),children:e.jsx(n.Table,{rowKey:W=>W.id,columns:se,dataSource:V,loading:F,pagination:{current:a.page,pageSize:a.perPage,total:z,showSizeChanger:!0,onChange:(W,K)=>s({page:W,perPage:K})}})})]})}function Dh({token:t}){return e.jsx(Th,{token:t})}const Vs=Ae.promoteStudents,Rh=({token:t})=>G(t?[Vs.sessionDropdown,t]:null,([a,s])=>J(a,s)),Cn=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},Ih=(t,a)=>{const s=t?.pagination??t?.data?.pagination??t?.data?.data?.pagination,r=s?.total_rows??s?.total??s?.totalItems;return Number.isFinite(Number(r))?Number(r):a};function kh({token:t}){const[a]=n.Form.useForm(),[s,r]=i.useState({page:1,perPage:300}),[o,l]=i.useState({classId:null,sectionId:null}),[d,c]=i.useState({sessionId:null,classId:null}),[g,f]=i.useState(!1),[u,p]=i.useState([]),w=i.useMemo(()=>new Set(u),[u]),[v,y]=i.useState({}),[m,x]=i.useState({}),{data:T}=G(t?[Ae.master.classes.dropdown,t]:null,([L,H])=>J(L,H)),D=i.useMemo(()=>Cn(T),[T]),k=i.useMemo(()=>o.classId?`${Ae.master.sections.byClass}?class_id=${encodeURIComponent(String(o.classId))}`:null,[o.classId]),{data:C}=G(t&&k?[k,t]:null,([L,H])=>J(L,H)),j=i.useMemo(()=>Cn(C),[C]),h=i.useMemo(()=>d.classId?`${Ae.master.sections.byClass}?class_id=${encodeURIComponent(String(d.classId))}`:null,[d.classId]),{data:S}=G(t&&h?[h,t]:null,([L,H])=>J(L,H),{revalidateOnFocus:!1}),A=i.useMemo(()=>Cn(S),[S]),{data:R}=Rh({token:t}),q=i.useMemo(()=>Cn(R),[R]),{trigger:U,data:b,isMutating:O}=rt(t?Vs.searchByClassSection:null,(L,{arg:H})=>Kt(L,{arg:H},t)),M=i.useMemo(()=>{const L=b?.data?.data??b?.data??b??[];return Array.isArray(L)?L:Array.isArray(L?.data)?L.data:[]},[b]),$=i.useMemo(()=>Ih(b,M.length??0),[b,M.length]),F=i.useMemo(()=>{const L=new Map;return(Array.isArray(M)?M:[]).forEach(H=>{H?.id!==void 0&&H?.id!==null&&L.set(String(H.id),H)}),L},[M]),N=i.useCallback((L,H)=>{const se=String(L);x(W=>({...W,[se]:{...W?.[se]??{},...H}}))},[]),V=i.useCallback((L,H)=>{const se=String(L),W=H==="Leave";y(K=>({...K,[se]:W}))},[]),z=L=>{const H=L?.class_id?.value??L?.class_id??null,se=L?.section_id?.value??L?.section_id??null;if(!H||!se){_.error("Please select Class and Section",{duration:1200});return}r(W=>({...W,page:1})),l({classId:H,sectionId:se}),p([]),y({}),x({})},P=async()=>{if(!d.sessionId||!d.classId){_.error("Please select Session and Class for promotion",{duration:1300});return}if(!Array.isArray(u)||u.length===0){_.error("Please select students to promote",{duration:1200});return}const L=u.map(K=>String(K)).map(K=>{const te=F.get(K)??{},oe=!!v?.[K],pe=m?.[K]??{},we=String(pe.current_result??"Pass");if(oe){const Q=String(pe.leave_date??"");return{student_id:K,current_result:we,next_session_status:"Leave",leave_date:Q}}const le=String(pe.roll_no??te?.roll_no??""),de=String(pe.section_id??"");return{student_id:K,roll_no:le,section_id:de,current_result:we,next_session_status:"Continue"}});if(L.some(K=>K?.next_session_status==="Leave"&&!String(K?.leave_date??"").trim())){_.error("Leave date is required for Leave students.",{duration:1500});return}if(L.some(K=>K?.next_session_status==="Continue"&&!String(K?.section_id??"").trim())){_.error("Section is required for Continue students.",{duration:1500});return}const W={class_id:String(d.classId),session_id:String(d.sessionId),students:L};try{const K=await Qe(Vs.promote,W,t);if(K?.Status&&String(K.Status)!=="success")throw new Error(K?.msg||"Failed to update");_.success("Success! Updated.",{duration:1e3});const te=Number(K?.success_count??0)+Number(K?.leave_count??0),oe=s.page===Math.ceil((Number($)||0)/s.perPage||1),pe=te>0&&te===M.length&&M.length===u.length,we=oe&&pe&&s.page>1?s.page-1:s.page;r(le=>({...le,page:we})),U?.({cID:o.classId,sID:o.sectionId,page:we,per_page:s.perPage}),p([]),y({}),x({})}catch(K){_.error(K?.response?.data?.msg??K?.message??"Failed to update",{duration:1500})}},I=i.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:140},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:120,render:(L,H)=>{const se=String(H?.id??""),W=w.has(se),K=!!v?.[se],oe=(m?.[se]??{}).roll_no??(K?"":H?.roll_no??"");return e.jsx(n.Input,{value:W?oe:H?.roll_no,style:W?{textAlign:"center"}:{textAlign:"center",border:"none",background:"transparent",cursor:"default"},disabled:!W||K,onChange:pe=>N(se,{roll_no:pe.target.value})})}},{title:"Name",dataIndex:"firstname",key:"name",render:(L,H)=>`${H?.firstname??""} ${H?.lastname??""}`.trim()},{title:"Section",dataIndex:"section",key:"section",width:160,render:(L,H)=>{const se=String(H?.id??""),W=w.has(se),K=!!v?.[se],oe=(m?.[se]??{}).section_id??"",pe=Array.isArray(A)?A:[];return e.jsx(n.Select,{options:pe,placeholder:W&&!K?"Select Section":"Section",disabled:!W||K,value:W&&!K&&oe||void 0,style:{width:"100%"},onChange:we=>N(se,{section_id:we})},`section_${se}_${g}_${K?"L":"C"}`)}},{title:"Current Result",dataIndex:"current_result",key:"current_result",width:160,render:(L,H)=>{const se=String(H?.id??""),W=w.has(se),K=m?.[se]??{},te=String(K.current_result??"Pass");return e.jsxs(n.Radio.Group,{value:te,disabled:!W,buttonStyle:"solid",onChange:oe=>N(se,{current_result:oe.target.value}),children:[e.jsx(n.Radio.Button,{value:"Pass",children:"Pass"}),e.jsx(n.Radio.Button,{value:"Fail",children:"Fail"})]})}},{title:"Next Session Status",dataIndex:"next_session_status",key:"next_session_status",width:220,render:(L,H)=>{const se=String(H?.id??""),W=w.has(se),K=!!v?.[se],te=m?.[se]??{},oe=String(te.leave_date??"");return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsxs(n.Radio.Group,{value:K?"Leave":"Continue",disabled:!W,buttonStyle:"solid",onChange:pe=>V(se,pe.target.value),children:[e.jsx(n.Radio.Button,{value:"Continue",children:"Continue"}),e.jsx(n.Radio.Button,{value:"Leave",children:"Leave"})]}),W&&K&&e.jsx(n.DatePicker,{style:{width:"100%"},value:oe?ae(oe):null,onChange:pe=>N(se,{leave_date:pe?pe.format("YYYY-MM-DD"):""}),placeholder:"Leave date"})]})}}],[V,v,m,w,g,A,N]),B=i.useMemo(()=>({selectedRowKeys:u,onChange:L=>p((Array.isArray(L)?L:[]).map(H=>String(H)))}),[u]);return i.useEffect(()=>{!o.classId||!o.sectionId||U&&U({cID:o.classId,sID:o.sectionId,page:s.page,per_page:s.perPage})},[s.page,s.perPage,U,o.classId,o.sectionId]),e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Promote Students"}),children:e.jsx(n.Form,{form:a,layout:"vertical",onFinish:z,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"class_id",label:"Class",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:L=>L,children:e.jsx(Z,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:L=>{const H=L?.value??null;a.setFieldValue("section_id",null),l({classId:H,sectionId:null})}})}),e.jsx(n.Form.Item,{name:"section_id",label:"Section",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:L=>L,children:e.jsx(Z,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Promote Students In Next Session"}),extra:e.jsx(zt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(n.Typography.Text,{children:["Selected: ",u.length]}),e.jsx(n.Typography.Text,{type:"secondary",children:"Select students → set Continue/Leave → Save"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{label:"Session",options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:q.find(L=>String(L.value)===String(d.sessionId))??null,onChange:L=>c(H=>({...H,sessionId:L?.value??null}))}),e.jsx(Z,{label:"Class",options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:D.find(L=>String(L.value)===String(d.classId))??null,onChange:L=>{const H=L?.value??null;c(se=>({...se,classId:H})),f(se=>!se)}}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"button",value:"Save",color:"primary",onClick:P})})]}),e.jsx(n.Table,{rowKey:L=>String(L.id),rowSelection:B,columns:I,dataSource:M,loading:O,pagination:{current:s.page,pageSize:s.perPage,total:$,showSizeChanger:!0,onChange:(L,H)=>{r({page:L,perPage:H}),p([]),y({}),x({})}}})]})})]})}function Ph({token:t}){return e.jsx(kh,{token:t})}const ma=Ae.coscholastic,Oh=({token:t})=>G(t?[ma.table,t]:null,([a,s])=>J(a,s),{revalidateOnFocus:!1}),Mh=({token:t})=>G(t?[ma.categoryDropdown,t]:null,([a,s])=>J(a,s),{revalidateOnFocus:!1}),Ui=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]};function Eh({token:t}){const[a,s]=i.useState(""),[r,o]=i.useState(null),[l,d]=i.useState(null),c=i.useRef(null),{data:g}=G(t?[Ae.master.classes.dropdown,t]:null,([S,A])=>J(S,A)),f=i.useMemo(()=>Ui(g),[g]),{data:u,isLoading:p,mutate:w}=Oh({token:t}),v=i.useMemo(()=>{const S=u?.data?.data??u?.data??u??[];return Array.isArray(S)?S:Array.isArray(S?.data)?S.data:[]},[u]),{data:y,mutate:m}=Mh({token:t}),x=i.useMemo(()=>Ui(y),[y]),T=i.useMemo(()=>(Array.isArray(x)?x:[]).map(S=>({value:S?.value??S?.id,label:S?.label??S?.title??""})),[x]),D=async()=>{const S=String(a??"").trim();if(!S){_.error("Please enter category title",{duration:1200});return}try{await Ne(ma.addCategory,{title:S},t),_.success("Success! Added category.",{duration:1e3}),s(""),m()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to add category",{duration:1500})}},k=async S=>{try{await Lt(ma.deleteCategory,S,t),_.success("Success! Deleted category.",{duration:1e3}),m()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to delete category",{duration:1500})}},C=async S=>{if(S.preventDefault(),!r){_.error("Please select Category",{duration:1200});return}if(!l){_.error("Please select Class",{duration:1200});return}if(!S?.target?.skill?.value){_.error("Please enter Skill Name",{duration:1200});return}const R=new FormData(S.target);R.append("scholastic_catid",String(r)),R.append("class_id",String(l));try{await wt(ma.addSkill,R,t),_.success("Success! Added new item.",{duration:1e3}),S.target.reset(),d(null),w()}catch(q){_.error(q?.response?.data?.msg??q?.message??"Failed to add the new item.",{duration:1500})}},j=async S=>{try{await Lt(ma.deleteSkill,S,t),_.success("Success! Deleted item.",{duration:1e3}),w()}catch(A){_.error(A?.response?.data?.msg??A?.message??"Failed to delete the item.",{duration:1500})}},h=i.useMemo(()=>[{title:"Skill Category",dataIndex:"title",key:"title"},{title:"Class",dataIndex:"class",key:"class"},{title:"Skill Name",dataIndex:"skill",key:"skill"},{title:"Action",key:"action",width:90,render:(S,A)=>e.jsx(n.Popconfirm,{title:"Delete this skill?",onConfirm:()=>j(A?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Co Scholastic Area"}),children:e.jsx("form",{onSubmit:C,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Category"}),e.jsx(Z,{style:{width:"100%"},value:T.find(S=>String(S.value)===String(r))??null,placeholder:"Select Category",onChange:S=>o(S?.value??null),options:T}),e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center",marginTop:10},children:[e.jsx(Y,{placeholder:"New category",ref:c,value:a,onChange:S=>s(S.target.value)}),e.jsx(n.Button,{type:"text",icon:e.jsx(ee.PlusOutlined,{}),onClick:D}),e.jsx(n.Popconfirm,{title:"Delete selected category?",onConfirm:()=>{r&&(k(r),o(null))},children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{}),disabled:!r})})]})]}),e.jsx(Z,{label:"Class",options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:f.find(S=>String(S.value)===String(l))??null,onChange:S=>d(S?.value??null)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Skill Name"}),e.jsx(Y,{name:"skill",placeholder:"Skill Name"})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Co Scholastic Area List"}),extra:e.jsx(zt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(n.Table,{rowKey:S=>S.id,columns:h,dataSource:v,loading:p,pagination:!1})})]})}function Fh({token:t}){return e.jsx(Eh,{token:t})}const $h=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Jo=({token:t,value:a,onChange:s})=>{const r=i.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(n.Upload,{maxCount:1,action:Gf(),headers:r,onChange:o=>{if(o?.file?.status==="done"){const l=$h(o?.file?.response);l&&s?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})})},Ni=Ae.notes,Uh=({token:t,url:a})=>G(t&&a?[a,t]:null,([s,r])=>J(s,r),{revalidateOnFocus:!1}),An=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},Nh=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r};function Bh({token:t}){const[a]=n.Form.useForm(),[s]=n.Form.useForm(),[r,o]=i.useState({page:1,perPage:50}),[l,d]=i.useState({classId:null,sectionId:null}),[c,g]=i.useState(!1),[f,u]=i.useState(""),{data:p}=G(t?[Ae.master.classes.dropdown,t]:null,([B,L])=>J(B,L)),w=i.useMemo(()=>An(p),[p]),v=i.useMemo(()=>l.classId?`${Ae.master.sections.byClass}?class_id=${encodeURIComponent(String(l.classId))}`:null,[l.classId]),{data:y}=G(t&&v?[v,t]:null,([B,L])=>J(B,L)),m=i.useMemo(()=>An(y),[y]),x=i.useMemo(()=>!l.classId||!l.sectionId?null:`${Ni.table}?class_id=${encodeURIComponent(String(l.classId))}§ion_id=${encodeURIComponent(String(l.sectionId))}&page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.perPage))}`,[l.classId,l.sectionId,r.page,r.perPage]),{data:T,isLoading:D,mutate:k}=Uh({token:t,url:x}),C=i.useMemo(()=>{const B=T?.data?.data??T?.data??T??[];return Array.isArray(B)?B:Array.isArray(B?.data)?B.data:[]},[T]),j=i.useMemo(()=>T?.pagination?.total_rows??T?.pagination?.total??C.length??0,[T,C.length]),[h,S]=i.useState(null),[A,R]=i.useState(null),[q,U]=i.useState(null),[b,O]=i.useState(!1),{data:M}=G(t&&q?[q,t]:null,([B,L])=>J(B,L),{revalidateOnFocus:!1}),$=i.useMemo(()=>An(M),[M]),{data:F}=G(t&&A?[A,t]:null,([B,L])=>J(B,L)),N=i.useMemo(()=>An(F),[F]),V=B=>{const L=B?.class_id?.value??null,H=B?.section_id?.value??null;!L||!H||(o(se=>({...se,page:1})),d({classId:L,sectionId:H}))},z=()=>{u(""),g(!0),S(null),R(null),U(null),O(B=>!B),s.resetFields()},P=async B=>{const L=B?.class_id?.value??null,H=B?.section_id?.value??null,se=B?.sub_id?.value??null,W=B?.status?.value??"publish",K=B?.title??"",te=B?.remark??"";if(!L||!H||!se||!K||!te||!f){_.error("Please fill all fields",{duration:1200});return}const oe=new FormData;oe.append("class_id",String(L)),oe.append("section_id",String(H)),oe.append("sub_id",String(se)),oe.append("title",String(K)),oe.append("remark",String(te)),oe.append("status",String(W)),oe.append("file",String(f));try{await wt(Ni.add,oe,t),_.success("Success! Added new item.",{duration:1e3}),g(!1),k()}catch(pe){_.error(pe?.response?.data?.msg??pe?.message??"Failed to add the new item.",{duration:1500})}},I=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",align:"center"},{title:"Remarks",dataIndex:"remark",key:"remark",align:"center"},{title:"Subject",dataIndex:"subject",key:"subject",align:"center"},{title:"Staff Name",dataIndex:"teacher_name",key:"teacher_name",align:"center"},{title:"Status",key:"status",align:"center",render:(B,L)=>{const H=String(L?.status??"").toLowerCase();return e.jsx(n.Tag,{color:H==="publish"?"green":"red",children:L?.status??"-"})}},{title:"File",key:"file",align:"center",render:(B,L)=>{const H=L?.file;if(!H)return"-";const se=Nh(at(),`/student/note/${H}`);return e.jsx("a",{href:se,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Date",dataIndex:"publish_date",key:"publish_date",align:"center"}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:"Add Note",open:c,onCancel:()=>g(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsx(n.Form,{form:s,layout:"vertical",onFinish:P,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:B=>B,children:e.jsx(Z,{options:w,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:B=>{const L=B?.value??null;S(L),s.setFieldValue("section_id",null),s.setFieldValue("sub_id",null),U(L?`${Ae.master.sections.byClass}?class_id=${encodeURIComponent(String(L))}`:null),R(L?`${Ae.master.subjects.dropdown}?class_id=${encodeURIComponent(String(L))}`:null),O(H=>!H)}},`class_${b}`)}),e.jsx(n.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:B=>B,children:e.jsx(Z,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${b}_${h??"none"}`)}),e.jsx(n.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:B=>B,children:e.jsx(Z,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${b}_${A??"none"}`)}),e.jsx(n.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(Y,{placeholder:"Title"})}),e.jsx(n.Form.Item,{label:"Remark",name:"remark",rules:[{required:!0,message:"Remark is required"}],children:e.jsx(Y,{placeholder:"Remark"})}),e.jsx(n.Form.Item,{label:"Status",name:"status",initialValue:{label:"Publish",value:"publish"},getValueFromEvent:B=>B,children:e.jsx(Z,{options:[{label:"Publish",value:"publish"},{label:"Unpublish",value:"unpublish"}],closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx(n.Form.Item,{label:"File",required:!0,children:e.jsx(Jo,{token:t,value:f,onChange:u})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(ie,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>g(!1),children:"Cancel"})]})]})})}),e.jsx(n.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Notes"}),e.jsx(zt,{actions:["add","export","print","download","filter"],onAdd:z,onPrint:()=>window.print()})]}),children:e.jsx(n.Form,{form:a,layout:"vertical",onFinish:V,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:B=>B,children:e.jsx(Z,{options:w,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:B=>{const L=B?.value??null;a.setFieldValue("section_id",null),d({classId:L,sectionId:null})}})}),e.jsx(n.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:B=>B,children:e.jsx(Z,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Note List"}),children:e.jsx(n.Table,{rowKey:B=>B.id,columns:I,dataSource:C,loading:D,pagination:{current:r.page,pageSize:r.perPage,total:j,showSizeChanger:!0,onChange:(B,L)=>o({page:B,perPage:L})}})})]})}function Lh({token:t}){return e.jsx(Bh,{token:t})}const qh=({token:t})=>G(t?[Ae.promoteStudents.sessionDropdown,t]:null,([a,s])=>J(a,s),{revalidateOnFocus:!1}),Bi=Ae.transferCertificate,Is=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},zh={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Yh=(t,a)=>t.inputtype==="Select"?null:t.inputtype==="date"?ae():"",Li=t=>[{name:"ncc_details",inputtype:"text",label:"Ncc Details",required:!1},{name:"extra_curricular_activites",inputtype:"text",label:"Games played or extra-curricular activities in which the pupil usually took part",required:!1},{name:"generalConduct",inputtype:"text",label:"General conduct",required:!1},{name:"qualified_class",inputtype:"Select",label:"Qualified class",required:!1},{name:"application_date",inputtype:"date",label:"Date of application for certificate",required:!1},{name:"issue_date",inputtype:"date",label:"Date of issue of certificate",required:!1},{name:"reason_of_leaving",inputtype:"text",label:"Reason for leaving the school",required:!1},{name:"otherRemarks",inputtype:"text",label:"Any other remarks",required:!1},{name:"student_id",inputtype:"hidden",label:"",required:!1,value:t},{name:"qualified_for_promotion",inputtype:"radio",label:"Qualified for promotion",required:!1},{name:"failed",inputtype:"radio",label:"Failed",required:!1},{name:"nationality",inputtype:"text",label:"Nationality",required:!1},{name:"checked_by",inputtype:"text",label:"Checked By",required:!1},{name:"checked_by_designation",inputtype:"text",label:"Checked By Designation",required:!1}],qi=t=>[{name:"change_of_school",inputtype:"text",label:"Change of School",required:!1},{name:"character_remark",inputtype:"text",label:"Character",required:!1},{name:"generalConduct",inputtype:"text",label:"General conduct",required:!1},{name:"application_date",inputtype:"date",label:"Date of application for certificate",required:!1},{name:"issue_date",inputtype:"date",label:"Date of issue of certificate",required:!1},{name:"last_attendance",inputtype:"date",label:"Last Class Attendence",required:!1},{name:"otherRemarks",inputtype:"text",label:"Any other remarks",required:!1},{name:"student_id",inputtype:"hidden",label:"",required:!1,value:t},{name:"qualified_for_promotion",inputtype:"radio",label:"Qualified for promotion",required:!1}];function Vh({token:t,transferCertificateViewPath:a="/AcademicsDashboard/TransferCertificateView",onOpenTransferCertificateView:s}){const[r]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=i.useState({page:1,perPage:10}),[c,g]=i.useState({classId:null,sectionId:null,sessionId:null}),[f,u]=i.useState(null),[p,w]=i.useState(!1),{data:v}=G(t?[Ae.master.classes.dropdown,t]:null,([I,B])=>J(I,B)),y=i.useMemo(()=>Is(v),[v]),{data:m}=G(t&&f?[f,t]:null,([I,B])=>J(I,B)),x=i.useMemo(()=>Is(m),[m]),{data:T}=qh({token:t}),D=i.useMemo(()=>Is(T),[T]),k=i.useMemo(()=>!c.classId||!c.sectionId||!c.sessionId?null:`${Bi.studentList}?class_id=${encodeURIComponent(String(c.classId))}§ion_id=${encodeURIComponent(String(c.sectionId))}&session_id=${encodeURIComponent(String(c.sessionId))}&page=${encodeURIComponent(String(l.page))}&per_page=${encodeURIComponent(String(l.perPage))}`,[c.classId,c.sectionId,c.sessionId,l.page,l.perPage]),{data:C,isLoading:j,mutate:h}=G(t&&k?[k,t]:null,([I,B])=>J(I,B),{revalidateOnFocus:!1,onSuccess:I=>{const B=I?.data?.data??I?.data??[];Array.isArray(B)&&B[0]?.transefer_certificate_id&&M(String(B[0].transefer_certificate_id))}}),S=i.useMemo(()=>{const I=C?.data?.data??C?.data??C??[];return Array.isArray(I)?I:Array.isArray(I?.data)?I.data:[]},[C]),A=i.useMemo(()=>C?.pagination?.total_rows??C?.pagination?.total??S.length??0,[C,S.length]),[R,q]=i.useState(!1),[U,b]=i.useState(null),[O,M]=i.useState("1"),$=I=>{b(I);const B=O==="1"?Li(I):qi(I),L={};B.forEach(H=>{L[H.name]=H.value??Yh(H)}),o.setFieldsValue(L),q(!0)},F=async I=>{if(!I)return;if(typeof s=="function")return s(I);const B=`${a}?id=${encodeURIComponent(String(I))}`;window.location.href=B},N=I=>{const B=I?.class_id?.value??null,L=I?.section_id?.value??null,H=I?.session_id?.value??null;if(!B||!L||!H){_.error("Please select Class, Section and Session",{duration:1200});return}d(se=>({...se,page:1})),g({classId:B,sectionId:L,sessionId:H})},V=async I=>{const B=new FormData;Object.entries(I??{}).forEach(([L,H])=>{if(H!=null){if(ae.isDayjs(H)){B.append(L,H.format("YYYY-MM-DD"));return}B.append(L,String(H))}});try{await wt(Bi.addData,B,t),_.success("Success! Added new item.",{duration:1e3}),q(!1),b(null),h()}catch(L){_.error(L?.response?.data?.msg??L?.message??"Failed to add the new item.",{duration:1500})}},z=i.useMemo(()=>O==="1"?Li(U):qi(U),[O,U]),P=i.useMemo(()=>[{title:"Admission no",dataIndex:"admission_no",key:"admission_no",align:"center"},{title:"Roll NO",dataIndex:"roll_no",key:"roll_no",align:"center"},{title:"Name",dataIndex:"full_name",key:"full_name",align:"center"},{title:"Class",dataIndex:"class",key:"class",align:"center"},{title:"Section",dataIndex:"section",key:"section",align:"center"},{title:"Guardian Name",dataIndex:"guardian_name",key:"guardian_name",align:"center"},{title:"Mobile No",dataIndex:"mobileno",key:"mobileno",align:"center"},{title:"Action",key:"action",align:"center",width:80,render:(I,B)=>e.jsx(n.Button,{type:"text",icon:B?.transfer_certificate_data==="not_present"?e.jsx(ee.EyeOutlined,{}):e.jsx(ee.CheckOutlined,{}),onClick:()=>{B?.transfer_certificate_data==="not_present"?$(B?.id):F(B?.id)}})}],[O]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:"Transfer Certificate",open:R,onCancel:()=>q(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:V,children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:z.map(I=>I.inputtype==="hidden"?e.jsx(n.Form.Item,{name:I.name,initialValue:I.value??"",style:{display:"none"},children:e.jsx("input",{type:"hidden"})},I.name):I.inputtype==="date"?e.jsx(n.Form.Item,{label:I.label,name:I.name,children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:zh})},I.name):I.inputtype==="radio"?e.jsx(n.Form.Item,{label:I.label,name:I.name,children:e.jsx(n.Radio.Group,{options:[{label:"Yes",value:"Yes"},{label:"No",value:"No"}]})},I.name):I.inputtype==="Select"?e.jsx(n.Form.Item,{label:I.label,name:I.name,getValueFromEvent:B=>B,children:e.jsx(Z,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})},I.name):e.jsx(n.Form.Item,{label:I.label,name:I.name,children:e.jsx(Y,{placeholder:I.label})},I.name))}),e.jsxs(n.Space,{style:{width:"100%",justifyContent:"flex-end"},children:[e.jsx(ie,{type:"submit",value:"Submit",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>q(!1),children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Student History"}),children:e.jsx(n.Form,{form:r,layout:"vertical",onFinish:N,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:I=>I,children:e.jsx(Z,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:I=>{const B=I?.value??null;u(B?`${Ae.master.sections.byClass}?class_id=${encodeURIComponent(String(B))}`:null),w(L=>!L),r.setFieldValue("section_id",null)}})}),e.jsx(n.Form.Item,{label:"Section",name:"section_id",getValueFromEvent:I=>I,children:e.jsx(Z,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${p}`)}),e.jsx(n.Form.Item,{label:"Session",name:"session_id",rules:[{required:!0,message:"Session is required"}],getValueFromEvent:I=>I,children:e.jsx(Z,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Student List"}),extra:e.jsx(zt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(n.Table,{rowKey:I=>I.id,columns:P,dataSource:S,loading:j,pagination:{current:l.page,pageSize:l.perPage,total:A,showSizeChanger:!0,onChange:(I,B)=>d({page:I,perPage:B})}})})]})}function Wh({token:t,transferCertificateViewPath:a,onOpenTransferCertificateView:s}){return e.jsx(Vh,{token:t,transferCertificateViewPath:a,onOpenTransferCertificateView:s})}const Hh=({token:t,url:a})=>G(t&&a?[a,t]:null,([s,r])=>J(s,r),{revalidateOnFocus:!1}),ks=Ae.syllabus,zi=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},Kh=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r};function Gh({token:t}){const[a]=n.Form.useForm(),[s]=n.Form.useForm(),[r,o]=i.useState({page:1,perPage:50}),[l,d]=i.useState({classId:null}),[c,g]=i.useState(!1),[f,u]=i.useState(null),[p,w]=i.useState(""),{data:v}=G(t?[Ae.master.classes.dropdown,t]:null,([F,N])=>J(F,N)),y=i.useMemo(()=>zi(v),[v]),m=i.useMemo(()=>l.classId?`${ks.table}?class_id=${encodeURIComponent(String(l.classId))}&page=${encodeURIComponent(String(r.page))}&per_page=${encodeURIComponent(String(r.perPage))}`:null,[l.classId,r.page,r.perPage]),{data:x,isLoading:T,mutate:D}=Hh({token:t,url:m}),k=i.useMemo(()=>{const F=x?.data?.data??x?.data??x??[];return Array.isArray(F)?F:Array.isArray(F?.data)?F.data:[]},[x]),C=i.useMemo(()=>x?.pagination?.total_rows??x?.pagination?.total??k.length??0,[x,k.length]),[j,h]=i.useState(null),[S,A]=i.useState(!1),{data:R}=G(t&&j?[j,t]:null,([F,N])=>J(F,N),{revalidateOnFocus:!1}),q=i.useMemo(()=>zi(R),[R]),U=F=>{const N=F?.class_id?.value??null;N&&(o(V=>({...V,page:1})),d({classId:N}))},b=()=>{u(null),w(""),h(null),A(F=>!F),s.resetFields(),g(!0)},O=F=>{u(F),w(F?.attchement??"");const N=F?.class_id;h(N?`${Ae.master.subjects.dropdown}?class_id=${encodeURIComponent(String(N))}`:null),A(V=>!V),s.setFieldsValue({class_id:y.find(V=>String(V.value)===String(N))??null,sub_id:q.find(V=>String(V.value)===String(F?.sub_id??F?.subject_id))??(F?.sub_id||F?.subject_id?{label:F?.subject_title??"Subject",value:F?.sub_id??F?.subject_id}:null),title:F?.title??"",description:F?.description??""}),g(!0)},M=async F=>{const N=F?.class_id?.value??null,V=F?.sub_id?.value??null,z=F?.title??"",P=F?.description??"";if(!N||!V||!z||!P||!p){_.error("Please fill all fields",{duration:1200});return}const I=new FormData;I.append("class_id",String(N)),I.append("sub_id",String(V)),I.append("title",String(z)),I.append("description",String(P)),I.append("file",String(p));try{f?.id?(I.append("id",String(f.id)),await wt(ks.edit,I,t),_.success("Success! Updated item.",{duration:1e3})):(await wt(ks.add,I,t),_.success("Success! Added new item.",{duration:1e3})),g(!1),u(null),D()}catch(B){_.error(B?.response?.data?.msg??B?.message??"Failed to save",{duration:1500})}},$=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",align:"center"},{title:"Description",dataIndex:"description",key:"description",align:"center"},{title:"Subject",dataIndex:"subject_title",key:"subject_title",align:"center"},{title:"File",key:"file",align:"center",render:(F,N)=>{const V=N?.attchement;if(!V)return"-";const z=Kh(at(),`uploads/student/note/${V}`);return e.jsx("a",{href:z,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Action",key:"action",width:80,align:"center",render:(F,N)=>e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>O(N)})}],[q,y]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:f?"Edit Syllabus":"Add Syllabus",open:c,onCancel:()=>{g(!1),u(null),w("")},footer:null,width:820,destroyOnClose:!0,children:e.jsx(n.Form,{form:s,layout:"vertical",onFinish:M,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:F=>F,children:e.jsx(Z,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:F=>{const N=F?.value??null;s.setFieldValue("sub_id",null),h(N?`${Ae.master.subjects.dropdown}?class_id=${encodeURIComponent(String(N))}`:null),A(V=>!V)}},`class_${f?.id??"add"}_${S}`)}),e.jsx(n.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:F=>F,children:e.jsx(Z,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${f?.id??"add"}_${S}_${j??"none"}`)}),e.jsx(n.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(Y,{placeholder:"Title"})}),e.jsx(n.Form.Item,{label:"Description",name:"description",rules:[{required:!0,message:"Description is required"}],children:e.jsx(vt,{placeholder:"Description"})}),e.jsx(n.Form.Item,{label:"File",required:!0,children:e.jsx(Jo,{token:t,value:p,onChange:w})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(ie,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>g(!1),children:"Cancel"})]})]})})}),e.jsx(n.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Syllabus"}),e.jsx(zt,{actions:["add","export","print","download","filter"],onAdd:b,onPrint:()=>window.print()})]}),children:e.jsx(n.Form,{form:a,layout:"vertical",onFinish:U,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:F=>F,children:e.jsx(Z,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Syllabus List"}),children:e.jsx(n.Table,{rowKey:F=>F.id,columns:$,dataSource:k,loading:T,pagination:{current:r.page,pageSize:r.perPage,total:C,showSizeChanger:!0,onChange:(F,N)=>o({page:F,perPage:N})}})})]})}function Jh({token:t}){return e.jsx(Gh,{token:t})}const is=Ae.timetable,Yi=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},Vi=t=>{if(!t)return"";const a=ae(t,"HH:mm:ss");return a.isValid()?a.format("h:mm a"):String(t)},Qh=t=>{const a=String(t).trim().toLowerCase();if(!a)return"default";let s=0;for(let o=0;o<a.length;o+=1)s=(s*31+a.charCodeAt(o))%1e5;const r=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return r[s%r.length]},Wi=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Xh=t=>{const a=String(t||"");return a?a.charAt(0).toUpperCase()+a.slice(1):"-"};function Zh({token:t}){const[a,s]=i.useState(null),[r,o]=i.useState(!1),[l,d]=i.useState(null),[c,g]=i.useState(""),[f,u]=i.useState(""),{data:p}=G(t?[Ae.master.classes.dropdown,t]:null,([h,S])=>J(h,S)),w=i.useMemo(()=>Yi(p),[p]),{data:v}=G(t&&a?[a,t]:null,([h,S])=>J(h,S)),y=i.useMemo(()=>Yi(v),[v]),{data:m,isLoading:x}=G(t&&l?[l,t]:null,([h,S])=>J(h,S),{revalidateOnFocus:!1}),T=i.useMemo(()=>m?.days??m?.data?.days??m?.data?.data?.days??{},[m]),{dataSource:D,daySpanByFirstKey:k}=i.useMemo(()=>{const h=Object.entries(T||{}).slice().sort((R,q)=>Wi.indexOf(String(R[0]).toLowerCase())-Wi.indexOf(String(q[0]).toLowerCase())),S=new Map,A=[];for(const[R,q]of h){const U=(Array.isArray(q)?q:[]).slice().sort((O,M)=>Number(O?.order_no||0)-Number(M?.order_no||0)),b=U.length;for(let O=0;O<b;O+=1){const M=U[O],$=M?.id||`${R}-${M?.order_no}-${O}`;O===0&&S.set($,b),A.push({key:$,_dayKey:R,...M})}}return{dataSource:A,daySpanByFirstKey:S}},[T]),C=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(h,S)=>{const A=k.get(S.key);return A===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(ee.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(n.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:Xh(h)})]}),props:{rowSpan:A}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:h=>e.jsx(n.Tag,{color:"#5080f8",style:{fontWeight:500},children:h})},{title:"Time",key:"time",width:180,render:(h,S)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(ee.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(n.Typography.Text,{children:[Vi(S?.time_from)," - ",Vi(S?.time_to)]})]})},{title:"Subject",key:"subject",render:(h,S)=>{if(String(S?.is_break)==="1")return e.jsx(n.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const R=S?.subject_name||"-";return e.jsx(n.Tag,{color:Qh(R),style:{fontWeight:500},children:R})}},{title:"Teacher",key:"teacher",render:(h,S)=>{const A=String(S?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(ee.UserOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(n.Typography.Text,{children:A?"-":S?.teacher_full_name||"-"})]})}},{title:"Room",key:"room_no",width:120,render:(h,S)=>{const A=String(S?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(ee.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(n.Typography.Text,{children:A?"-":S?.room_no||"-"})]})}}],[k]),j=h=>{h.preventDefault();const S=h.target.class_id?.value,A=h.target.section_id?.value;if(!S||!A)return;const R=w.find(O=>String(O.value)===String(S)),q=y.find(O=>String(O.value)===String(A));g(R?.label||""),u(q?.label||"");const b=`${is.byClassSection}/${S}/section/${A}`;d(b)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Class / Section Wise Timetable"}),extra:e.jsx(zt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx("form",{onSubmit:j,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:w,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,required:!0,onChange:h=>{s(`${Ae.master.sections.byClass}?class_id=${encodeURIComponent(String(h?.value??""))}`),o(S=>!S)}}),e.jsx(Z,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",allowSelectAll:!1,required:!0},`section_${r}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:c||f?`Timetable: ${c} ${f}`:"Timetable"}),children:e.jsx(n.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:D,columns:C,rowKey:"key",loading:x,scroll:{x:"max-content"}})})]})}const ey=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},Hi=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],ty=t=>{const a=String(t||"");return a?a.charAt(0).toUpperCase()+a.slice(1):"-"},Ki=t=>{if(!t)return"";const a=ae(t,"HH:mm:ss");return a.isValid()?a.format("h:mm a"):String(t)},ay=t=>{const a=String(t).trim().toLowerCase();if(!a)return"default";let s=0;for(let o=0;o<a.length;o+=1)s=(s*31+a.charCodeAt(o))%1e5;const r=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return r[s%r.length]};function ny({token:t}){const[a,s]=i.useState(null),[r,o]=i.useState(null),{data:l}=G(t?[Ae.assignByClass.teacherDropdown,t]:null,([v,y])=>J(v,y)),d=i.useMemo(()=>ey(l),[l]),{data:c,isLoading:g}=G(t&&r?[r,t]:null,([v,y])=>J(v,y),{revalidateOnFocus:!1}),{dataSource:f,daySpanByFirstKey:u}=i.useMemo(()=>{const y=(Array.isArray(c?.data)&&c.data||Array.isArray(c?.data?.data)&&c.data.data||[]).slice().sort((D,k)=>{const C=Hi.indexOf(String(D?.day_name||"").toLowerCase()),j=Hi.indexOf(String(k?.day_name||"").toLowerCase());if(C!==j)return C-j;const h=Number(D?.order_no||0),S=Number(k?.order_no||0);return h!==S?h-S:String(D?.time_from||"").localeCompare(String(k?.time_from||""))}),m=new Map,x=[];let T=0;for(;T<y.length;){const D=String(y[T]?.day_name||"").toLowerCase();let k=T;for(;k<y.length&&String(y[k]?.day_name||"").toLowerCase()===D;)k+=1;const C=k-T;for(let j=T;j<k;j+=1){const h=y[j],S=h?.id||`${D}-${h?.order_no}-${j}`;j===T&&m.set(S,C),x.push({key:S,_dayKey:D,...h})}T=k}return{dataSource:x,daySpanByFirstKey:m}},[c]),p=i.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(v,y)=>{const m=u.get(y.key);return m===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(ee.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(n.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:ty(v)})]}),props:{rowSpan:m}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:v=>e.jsx(n.Tag,{color:"#5080f8",style:{fontWeight:500},children:v})},{title:"Time",key:"time",width:180,render:(v,y)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(ee.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(n.Typography.Text,{children:[Ki(y?.time_from)," - ",Ki(y?.time_to)]})]})},{title:"Subject",key:"subject",render:(v,y)=>{if(String(y?.is_break)==="1")return e.jsx(n.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const x=y?.subject_name||"-";return e.jsx(n.Tag,{color:ay(x),style:{fontWeight:500},children:x})}},{title:"Class",key:"class",width:160,render:(v,y)=>e.jsxs(n.Tag,{color:"purple",style:{fontWeight:500},children:[y?.class_name||y?.class_id||"-"," ",y?.section_name?`(${y.section_name})`:""]})},{title:"Room",key:"room_no",width:120,render:(v,y)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(ee.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(n.Typography.Text,{children:y?.room_no||"-"})]})}],[u]),w=v=>{v.preventDefault();const y=v.target.teacher_id?.value;if(!y)return;s(y);const x=`${is.teacherTimetable}${encodeURIComponent(String(y))}`;o(x)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Teacher Wise Timetable"}),extra:e.jsx(zt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx("form",{onSubmit:w,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Z,{options:d,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teacher",name:"teacher_id",allowSelectAll:!1,required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Timetable"}),children:e.jsx(n.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:f,columns:p,rowKey:"key",loading:g,scroll:{x:"max-content"}})})]})}function Gi(t){if(!t)return null;const a=String(t).trim().replaceAll(".",":");if(!a)return null;const s=a.toLowerCase(),r=s.includes("am")||s.includes("pm");let o=0,l=0,d=0;if(r){const g=s.replace(/\s+/g," ").match(/^(\d{1,2})\s*:\s*(\d{1,2})(?:\s*:\s*(\d{1,2}))?\s*(am|pm)$/i);if(!g)return null;o=Number.parseInt(g[1],10),l=Number.parseInt(g[2],10),d=Number.parseInt(g[3]||"0",10);const f=g[4].toLowerCase();f==="pm"&&o<12&&(o+=12),f==="am"&&o===12&&(o=0)}else{const c=a.split(":").map(g=>g.trim());if(c.length<2)return null;o=Number.parseInt(c[0],10),l=Number.parseInt(c[1],10),d=Number.parseInt(c[2]||"0",10)}return![o,l,d].every(c=>Number.isFinite(c))||o<0||o>23||l<0||l>59||d<0||d>59?null:ae().hour(o).minute(l).second(d).millisecond(0)}function $a(t,a){const s=Number.parseInt(a,10);return!Number.isFinite(s)||s<=0||!t||!t.isValid?.()?null:t.add(s,"minute")}const qn=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},qa={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"},sy=t=>{const a=qa[String(t)];return a?a.charAt(0).toUpperCase()+a.slice(1):String(t)},ry=({token:t,classId:a,sectionId:s,subjectId:r,value:o,onChange:l,disabled:d})=>{const c=t&&a&&s&&r?`${is.teachersBySubject}?subject_id=${encodeURIComponent(String(r))}&class_id=${encodeURIComponent(String(a))}§ion_id=${encodeURIComponent(String(s))}`:null,{data:g,isLoading:f}=G(c?[c,t]:null,([p,w])=>J(p,w),{revalidateOnFocus:!1}),u=i.useMemo(()=>qn(g?.data??g).map(w=>({value:w?.value??w?.id,label:w?.label??w?.name??w?.teacher_name??""})),[g]);return e.jsx(n.Select,{placeholder:d?"-":"Select Teacher",loading:f,disabled:d,style:{width:"100%"},options:u,value:o?String(o):void 0,onChange:p=>l?.(p),showSearch:!0,optionFilterProp:"label"})};function iy({token:t}){const[a]=n.Form.useForm(),[s,r]=i.useState({classId:null,sectionId:null,dayKey:"1",daysEnabled:{0:!1,1:!0,2:!0,3:!0,4:!0,5:!0,6:!0}}),[o,l]=i.useState({startTime:null,endTime:null,duration:40,interval:0,roomNo:"",tiffinEnabled:!1,tiffinAfterPeriod:3,tiffinDuration:20}),[d,c]=i.useState({0:[],1:[],2:[],3:[],4:[],5:[],6:[]}),[g,f]=i.useState(!1),u=i.useMemo(()=>t?Ae.master.classes.dropdown:null,[t]),{data:p}=G(u?[u,t]:null,([b,O])=>J(b,O)),w=i.useMemo(()=>qn(p).map(b=>({value:b?.value??b?.id,label:b?.label??b?.title??""})),[p]),v=i.useMemo(()=>!t||!s.classId?null:`${Ae.master.sections.byClass}?class_id=${encodeURIComponent(String(s.classId))}`,[s.classId,t]),{data:y}=G(v?[v,t]:null,([b,O])=>J(b,O)),m=i.useMemo(()=>qn(y).map(b=>({value:b?.value??b?.id,label:b?.label??b?.title??""})),[y]),x=i.useMemo(()=>!t||!s.classId?null:`${Ae.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(s.classId))}`,[s.classId,t]),{data:T}=G(x?[x,t]:null,([b,O])=>J(b,O)),D=i.useMemo(()=>qn(T).map(b=>({value:b?.value??b?.id,label:b?.label??b?.title??""})),[T]),k=i.useMemo(()=>Array.isArray(d?.[s.dayKey])?d[s.dayKey]:[],[s.dayKey,d]),C=i.useCallback((b,O,M)=>{c($=>{const F={...$},N=Array.isArray(F[b])?F[b].slice():[];return N[O]={...N[O]??{},...M},F[b]=N,F})},[]),j=i.useCallback((b,O)=>{c(M=>{const $={...M},F=Array.isArray($[b])?$[b].slice():[];return F.splice(O,1),$[b]=F.map((N,V)=>({...N,order_no:V+1})),$})},[]),h=i.useCallback(b=>{c(O=>{const M={...O},$=Array.isArray(M[b])?M[b].slice():[];let F=null,N=null;const V=$[$.length-1];if(V?.time_to){const z=Gi(V.time_to),P=Number.parseInt(o.interval,10)||0,I=Number.parseInt(o.duration,10)||0,B=$a(z,P),L=I>0?$a(B,I):null;F=B?.isValid?.()?B.format("HH:mm:ss"):null,N=L?.isValid?.()?L.format("HH:mm:ss"):null}return $.push({order_no:$.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:F,time_to:N,is_break:!1}),M[b]=$,M})},[o.duration,o.interval,o.roomNo]),S=i.useCallback(()=>{const b=o.startTime,O=o.endTime,M=Number.parseInt(o.duration,10),$=Number.parseInt(o.interval,10);if(!b||!b.isValid?.()){_.error("Start time is required",{duration:1500});return}if(!O||!O.isValid?.()){_.error("End time is required",{duration:1500});return}if(!O.isAfter(b)){_.error("End time must be after start time",{duration:1500});return}if(!Number.isFinite(M)||M<=0){_.error("Duration must be a positive number",{duration:1500});return}if(!Number.isFinite($)||$<0){_.error("Interval must be 0 or more",{duration:1500});return}const F=()=>{const N=[];let V=b;for(let z=0;z<50;z+=1){const P=$a(V,M);if(!P||!P.isValid?.()||P.isAfter(O))break;N.push({order_no:N.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:V.format("HH:mm:ss"),time_to:P.format("HH:mm:ss"),is_break:!1});const I=$a(P,$);if(!I||!I.isValid?.()||I.isAfter(O)||I.isSame(O))break;V=I}if(o.tiffinEnabled){const z=Math.max(0,Number.parseInt(o.tiffinAfterPeriod,10)||0),P=Math.max(0,Number.parseInt(o.tiffinDuration,10)||0),I=Math.min(z,N.length);if(I>0&&P>0){const B=N[I-1],L=B?.time_to?Gi(B.time_to):null,H=L?$a(L,P):null;L?.isValid?.()&&H?.isValid?.()&&!H.isAfter(O)&&N.splice(I,0,{order_no:I+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:L.format("HH:mm:ss"),time_to:H.format("HH:mm:ss"),is_break:!0})}}return N.map((z,P)=>({...z,order_no:P+1}))};c(N=>{const V={...N};return Object.keys(qa).forEach(z=>{s.daysEnabled?.[z]&&(V[z]=F())}),V}),_.success("Generated schedule",{duration:1e3})},[o,s.daysEnabled]),A=i.useCallback(()=>{const b=localStorage.getItem("genrall_settings"),M=(b?JSON.parse(b):{})?.session_id??"1",$=s.classId,F=s.sectionId,N=Object.keys(qa).map(V=>{const z=(Array.isArray(d?.[V])?d[V]:[]).map((P,I)=>({order_no:I+1,subject_id:P?.is_break?0:P?.subject_id??null,teacher_id:P?.is_break?0:P?.teacher_id??null,room_no:P?.room_no??"",time_from:P?.time_from??null,time_to:P?.time_to??null,is_break:P?.is_break?1:0}));return{day:qa[V],class_id:$,section_id:F,session_id:M,args:z}});return{class_id:$,section_id:F,session_id:M,days:N}},[s.classId,s.sectionId,d]),R=i.useCallback(async()=>{if(!s.classId||!s.sectionId){_.error("Please select Class and Section",{duration:1500});return}const b=A(),O=Array.isArray(b?.days)?b.days:[];if(!O.some(F=>Array.isArray(F?.args)&&F.args.length>0)){_.error("No timetable rows to submit",{duration:1500});return}const $=F=>{const N=F?.is_break;return N===1||N==="1"||N===!0?!0:String(N??"").toLowerCase()==="true"};O.some(F=>(Array.isArray(F?.args)?F.args:[]).some(N=>String(N?.time_from??"").trim()&&String(N?.time_to??"").trim()?$(N)?!1:!String(N?.subject_id??"").trim()||!String(N?.teacher_id??"").trim():!0)),f(!0);try{const F=is.save,N=F==="api/timetable/save"?"timetable/save":null,V=async I=>{const B=await Zn(I,b,t);if(B&&typeof B=="object")return B;throw new Error("No response from server")};let z;try{z=await V(F)}catch{z=await V(N)}const P=String(z?.msg??"");if(String(z?.Status)==="Success"){if(Array.isArray(z?.data)&&z.data.length===0&&P){_.error(P,{duration:3e3});return}_.success(P||"Weekly Time Table added successfully!",{duration:1200});return}_.error(P||"Failed to add time table",{duration:3e3})}catch(F){_.error(F?.response?.data?.msg??F?.message??"Failed to add time table",{duration:3e3})}finally{f(!1)}},[A,s.classId,s.sectionId,t]),q=i.useMemo(()=>[{title:"Period",dataIndex:"order_no",key:"order_no",width:80},{title:"Time From",dataIndex:"time_from",key:"time_from",width:120,render:b=>b?ae(b,"HH:mm:ss").format("h:mm a"):"-"},{title:"Time To",dataIndex:"time_to",key:"time_to",width:120,render:b=>b?ae(b,"HH:mm:ss").format("h:mm a"):"-"},{title:"Break",dataIndex:"is_break",key:"is_break",width:90,render:(b,O,M)=>e.jsx(n.Switch,{checked:!!O?.is_break,onChange:$=>{C(s.dayKey,M,{is_break:$,subject_id:$?"":O?.subject_id??"",teacher_id:$?"":O?.teacher_id??""})}})},{title:"Subject",dataIndex:"subject_id",key:"subject_id",width:220,render:(b,O,M)=>e.jsx(n.Select,{placeholder:O?.is_break?"-":"Select Subject",disabled:!!O?.is_break,style:{width:"100%"},options:D,value:O?.subject_id?String(O.subject_id):void 0,onChange:$=>C(s.dayKey,M,{subject_id:$,teacher_id:""}),showSearch:!0,optionFilterProp:"label"})},{title:"Teacher",dataIndex:"teacher_id",key:"teacher_id",width:240,render:(b,O,M)=>e.jsx(ry,{token:t,classId:s.classId,sectionId:s.sectionId,subjectId:O?.subject_id,disabled:!!O?.is_break||!O?.subject_id,value:O?.teacher_id,onChange:$=>C(s.dayKey,M,{teacher_id:$})})},{title:"Room",dataIndex:"room_no",key:"room_no",width:140,render:(b,O,M)=>e.jsx(n.Input,{value:O?.room_no??"",onChange:$=>C(s.dayKey,M,{room_no:$.target.value})})},{title:"Action",key:"action",width:90,render:(b,O,M)=>e.jsx(n.Popconfirm,{title:"Delete this row?",onConfirm:()=>j(s.dayKey,M),children:e.jsx(n.Button,{danger:!0,type:"text",children:"Delete"})})}],[s.classId,s.dayKey,s.sectionId,j,D,t,C]),U=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Create Time Table"}),children:e.jsx(n.Form,{form:a,layout:"vertical",initialValues:{duration:o.duration,interval:o.interval,roomNo:o.roomNo,tiffinEnabled:o.tiffinEnabled,tiffinAfterPeriod:o.tiffinAfterPeriod,tiffinDuration:o.tiffinDuration},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",required:!0,children:e.jsx(n.Select,{placeholder:"Select Class",options:w,value:s.classId?String(s.classId):void 0,onChange:b=>{r(O=>({...O,classId:b,sectionId:null})),c({0:[],1:[],2:[],3:[],4:[],5:[],6:[]})},showSearch:!0,optionFilterProp:"label"})}),e.jsx(n.Form.Item,{label:"Section",required:!0,children:e.jsx(n.Select,{placeholder:"Select Section",options:m,value:s.sectionId?String(s.sectionId):void 0,onChange:b=>r(O=>({...O,sectionId:b})),disabled:!s.classId,showSearch:!0,optionFilterProp:"label"})}),e.jsx(n.Form.Item,{label:"Start Time",required:!0,children:e.jsx(n.TimePicker,{value:o.startTime,onChange:b=>l(O=>({...O,startTime:b})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"End Time",required:!0,children:e.jsx(n.TimePicker,{value:o.endTime,onChange:b=>l(O=>({...O,endTime:b})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"Duration (min)",required:!0,children:e.jsx(n.InputNumber,{min:1,value:o.duration,onChange:b=>l(O=>({...O,duration:b})),style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"Interval (min)",children:e.jsx(n.InputNumber,{min:0,value:o.interval,onChange:b=>l(O=>({...O,interval:b})),style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"Room No",children:e.jsx(n.Input,{value:o.roomNo,onChange:b=>l(O=>({...O,roomNo:b.target.value}))})}),e.jsx(n.Form.Item,{label:"Tiffin Break",children:e.jsxs(n.Space,{children:[e.jsx(n.Switch,{checked:o.tiffinEnabled,onChange:b=>l(O=>({...O,tiffinEnabled:b}))}),e.jsx(n.Typography.Text,{type:"secondary",children:o.tiffinEnabled?"Enabled":"Disabled"})]})}),e.jsx(n.Form.Item,{label:"After Period",tooltip:"Insert break row after this period",style:{marginBottom:0},children:e.jsx(n.InputNumber,{min:1,value:o.tiffinAfterPeriod,onChange:b=>l(O=>({...O,tiffinAfterPeriod:b})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsx(n.Form.Item,{label:"Break Duration (min)",style:{marginBottom:0},children:e.jsx(n.InputNumber,{min:1,value:o.tiffinDuration,onChange:b=>l(O=>({...O,tiffinDuration:b})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(n.Button,{onClick:S,children:"Generate"}),e.jsx(n.Button,{type:"primary",loading:g,onClick:R,children:"Save"})]})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Edit Week"}),extra:e.jsxs(n.Space,{children:[e.jsx(n.Typography.Text,{type:"secondary",children:"Day"}),e.jsx(n.Select,{style:{width:160},value:s.dayKey,onChange:b=>r(O=>({...O,dayKey:b})),options:Object.keys(qa).map(b=>({value:String(b),label:sy(b)}))}),e.jsx(n.Button,{onClick:()=>h(s.dayKey),children:"Add Row"})]}),children:e.jsx(n.Table,{rowKey:(b,O)=>`${s.dayKey}_${O}`,columns:q,dataSource:k,pagination:!1,size:"middle",scroll:{x:"max-content"}})})]});return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Typography.Title,{level:4,style:{margin:0},children:"Time Table"}),e.jsx(n.Tabs,{type:"card",items:[{key:"create",label:"Create",children:U},{key:"routine",label:"Routine",children:e.jsx(Zh,{token:t})},{key:"teacher",label:"Teacher Wise",children:e.jsx(ny,{token:t})}]})]})}function oy({token:t}){return e.jsx(iy,{token:t})}function ly(){return null}const Xt=t=>t??localStorage.getItem("authToken")??"",ir=(t,a)=>{const s=String(t??""),r=String(a??"");return s?r?s.endsWith("/")&&r.startsWith("/")?`${s}${r.slice(1)}`:!s.endsWith("/")&&!r.startsWith("/")?`${s}/${r}`:`${s}${r}`:s:r},ft={organization:{get:"api/branchapi/generalSettings/getorganizationsettingsData",save:"api/branchapi/generalSettings/addorganizationSetting",currencyDropdown:"api/branchapi/generalSettings/currencyDropdown",countryCodeDropdown:"api/branchapi/generalSettings/contrycodeDropdown",timezoneDropdown:"api/branchapi/generalSettings/timezoneDropdown",boardsDropdown:"api/branchapi/generalSettings/getAffliatedBoardsDropDown",uploadLogo:"api/superAdmin/upload_logo",uploadSignature:"api/branchapi/generalSettings/upload_signature",uploadFirebaseJson:"api/branchapi/generalSettings/firebaseJsonUpload"},academicYear:{table:"api/branchapi/generalSettings/sessiontable",add:"api/branchapi/generalSettings/addsession",setActive:"api/branchapi/generalSettings/setsession",remove:"api/branchapi/generalSettings/deletesession"},feeReceiptSetting:{get:"api/branchapi/generalSettings/feesReceiptSettingData",save:"api/branchapi/generalSettings/feesReceiptSetting"},marksheetSetting:{templateTypes:"api/branchapi/GeneralSettings/getmarkssheetTemplate",classDropdown:"api/exam/exam/getClassforAssignMarksSheetType",assignedTable:"api/branchapi/GeneralSettings/getassign_templete",assign:"api/branchapi/GeneralSettings/assign_templete",remove:"api/branchapi/GeneralSettings/deleteTemplate"},legalPages:{get:"api/branchapi/generalSettings/getlegalpage",termsSave:"api/branchapi/generalSettings/terms",privacySave:"api/branchapi/generalSettings/privacy",aboutSave:"api/branchapi/generalSettings/about_us"},feesInfo:{get:"api/branchapi/generalSettings/getFeesInfo",save:"api/branchapi/generalSettings/addFeesInfo",statesDropdown:"api/superAdmin/states"},payrollSettings:{table:"api/branchapi/GeneralSettings/getsetting_allowances_dedection",add:"api/branchapi/GeneralSettings/addsetting_allowances_dedection",edit:"api/branchapi/GeneralSettings/updatesetting_allowances_dedection",remove:"api/branchapi/GeneralSettings/deletesetting_allowances_dedection",byId:"api/branchapi/GeneralSettings/getsetting_allowances_dedectionById"},paymentGateway:{get:"api/payment_gateway/PaymentProcess/getPaymentGatewayList",save:"api/payment_gateway/PaymentProcess"}},or=t=>ir(at(),t),dy=()=>ir(at(),"uploads"),Qo=t=>ir(dy(),t),cy=async({baseUrl:t,page:a=1,perPage:s=10},r)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return J(l,Xt(r))},uy=async(t,a)=>J(t,Xt(a)),nn=async(t,a,s)=>Ne(t,a,Xt(s)),Xo=async(t,a,s)=>Qe(t,a,Xt(s)),lr=async(t,a,s)=>Ve(t,a,Xt(s)),py=async(t,a,s)=>Zn(t,{arg:a},Xt(s)),Zo=async(t,a,s)=>za(t,{arg:a},Xt(s)),el=({baseUrl:t,page:a=1,perPage:s=10,token:r})=>G(r&&t?[t,a,s,r]:null,([l,d,c,g])=>cy({baseUrl:l,page:d,perPage:c},g)),ht=({url:t,token:a})=>G(a&&t?[t,a]:null,([r,o])=>uy(r,o)),my={border:"1px solid #d9d9d9",borderRadius:8,padding:12,minHeight:320,background:"#fff"};function fy({value:t,onChange:a,placeholder:s}){const[r,o]=i.useState(t??""),l=i.useMemo(()=>typeof t=="string"?t:r,[r,t]);return e.jsx("div",{style:my,children:e.jsx(ko,{html:l||"",onChange:d=>{const c=d?.target?.value??"";o(c),a?.(c)},style:{outline:"none",minHeight:280},placeholder:s})})}function Yt({title:t,actions:a,children:s,headerExtra:r}){return e.jsx("div",{style:{display:"grid",gap:20},children:s})}const hy=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null;function dr({token:t,title:a,fetchUrl:s,saveUrl:r,fieldName:o,initialHtmlFieldName:l}){const d=i.useRef(null),c=ht({url:s,token:t}),f=i.useMemo(()=>hy(c.data),[c.data])?.[l??o]??"",[u,p]=i.useState("");i.useEffect(()=>{p(typeof f=="string"?f:"")},[f]);const w=()=>p(typeof f=="string"?f:""),v=()=>{const x=new Blob([String(u??"")],{type:"text/html"}),T=URL.createObjectURL(x),D=document.createElement("a");D.href=T,D.download=`${String(a??"legal").toLowerCase().replaceAll(" ","-")}.html`,D.click(),URL.revokeObjectURL(T)},y=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(ee.SyncOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:w},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:v,disabled:!u}],[u,f]),m=async x=>{x.preventDefault();try{(await Zo(r,{[o]:u??""},t))?.Status==="Success"?_.success("Updated successfully.",{duration:1e3}):_.success("Updated.",{duration:1e3}),c.mutate?.()}catch(T){_.error(T?.response?.data?.msg??T?.message??"Failed to update.",{duration:1500})}};return c.isLoading&&!c.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Yt,{title:a,actions:y,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Editor"}),children:e.jsxs("form",{ref:d,onSubmit:m,children:[e.jsx(fy,{value:u,onChange:p,placeholder:`Enter ${a} content...`}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Update"})})]})})})]})}const yy=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",gy=t=>/^https?:\/\//i.test(String(t??""))||String(t??"").startsWith("data:");function fa({token:t,value:a,onChange:s,action:r,accept:o,maxCount:l=1,previewUrl:d}){const c=i.useMemo(()=>{if(t)return{Authorization:t}},[t]),g=i.useMemo(()=>a?d||(gy(a)?a:""):"",[d,a]);return e.jsxs("div",{style:{display:"grid",gap:8},children:[g?e.jsx("img",{src:g,alt:"upload-preview",style:{width:88,height:88,objectFit:"cover",borderRadius:8,border:"1px solid #d9d9d9",background:"#fafafa"}}):null,e.jsx(n.Upload,{maxCount:l,action:r,accept:o,headers:c,onChange:f=>{if(f?.file?.status==="removed"&&s?.(""),f?.file?.status==="done"){const u=yy(f?.file?.response);u&&s?.(u)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})})]})}const Ot=ft.organization,tl=()=>or(Ot.uploadLogo),Ps=()=>or(Ot.uploadSignature),xy=()=>or(Ot.uploadFirebaseJson),by=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[]:[],jy=({token:t})=>ht({url:Ot.get,token:t}),Sy=({token:t})=>ht({url:Ot.currencyDropdown,token:t}),vy=({token:t})=>ht({url:Ot.countryCodeDropdown,token:t}),wy=({token:t})=>ht({url:Ot.timezoneDropdown,token:t}),_y=({token:t})=>ht({url:Ot.boardsDropdown,token:t}),Tn=t=>by(t?.data),Ji={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Cy=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"].map(t=>({value:t,label:t})),Qi=[{value:"Yes",label:"Yes"},{value:"No",label:"No"}],Xi=[{value:"yes",label:"Yes"},{value:"no",label:"No"}],Ay=t=>{const a=t?.data;return Array.isArray(a?.data)?a.data[0]??null:Array.isArray(a)?a[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null},Ty=t=>t?.data?.inout_setting?.[0]??t?.inout_setting?.[0]??null,Dy=t=>t?.data?.notification_settings?.[0]??t?.notification_settings?.[0]??null;function Ry({token:t}){const a=i.useRef(null),s=jy({token:t}),r=Sy({token:t}),o=vy({token:t}),l=wy({token:t}),d=_y({token:t}),c=i.useMemo(()=>Ay(s.data),[s.data]),g=i.useMemo(()=>Ty(s.data),[s.data]),f=i.useMemo(()=>Dy(s.data),[s.data]),u=i.useMemo(()=>Tn(r),[r.data]),p=i.useMemo(()=>Tn(o),[o.data]),w=i.useMemo(()=>Tn(l),[l.data]),v=i.useMemo(()=>Tn(d),[d.data]),[y,m]=i.useState(null),[x,T]=i.useState(null),[D,k]=i.useState(null),[C,j]=i.useState(null),[h,S]=i.useState([]),[A,R]=i.useState("No"),[q,U]=i.useState("yes"),[b,O]=i.useState("no"),[M,$]=i.useState("Yes"),[F,N]=i.useState(""),[V,z]=i.useState(""),[P,I]=i.useState(null),[B,L]=i.useState(null),[H,se]=i.useState(null),[W,K]=i.useState(null),te=()=>{const Q=(()=>{try{const ce=c?.weekly_off;if(!ce)return[];const Te=Array.isArray(ce)?ce:JSON.parse(ce);return Array.isArray(Te)?Te.filter(Boolean).map(Ee=>({value:Ee,label:Ee})):[]}catch{return[]}})();S(Q),m(u.find(ce=>ce?.value===c?.currency)??null),T(p.find(ce=>ce?.value===c?.country_code)??null),k(w.find(ce=>ce?.value===c?.time_zone)??null),j(v.find(ce=>ce?.value===c?.affliated_board_id)??null),N(c?.logo??""),z(c?.json_file??""),R(c?.attendance_salary_calculation??"No"),U(c?.salary_period??"yes"),O(c?.multiple_shift??"no"),$(c?.readmission_charges??"Yes"),I(g?.in_from?ae(g.in_from,"h:mm A"):null),L(g?.in_to?ae(g.in_to,"h:mm A"):null),se(g?.out_from?ae(g.out_from,"h:mm A"):null),K(g?.out_to?ae(g.out_to,"h:mm A"):null)};i.useEffect(()=>{c&&te()},[c,u,p,w,v]);const oe=()=>{a.current?.reset?.(),te()},pe=()=>{const Q=new FormData(a.current??void 0),ce=Object.fromEntries(Q.entries());ce.weekly_off_day=h.map(Le=>Le?.value).filter(Boolean);const Te=new Blob([JSON.stringify(ce,null,2)],{type:"application/json"}),Ee=URL.createObjectURL(Te),Ie=document.createElement("a");Ie.href=Ee,Ie.download="organization-setting.json",Ie.click(),URL.revokeObjectURL(Ee)},we=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(ee.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:oe},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:pe,disabled:!c}],[c,h]),le=async Q=>{Q.preventDefault();try{const ce=new FormData(Q.target);ce.set("currency",y?.value??""),ce.set("code",x?.value??""),ce.set("time_zone",D?.value??""),ce.set("affliated_board_id",C?.value??""),ce.set("board_name",C?.label??""),ce.set("attendance_salary_calculation",A),ce.set("salary_period",q),ce.set("multiple_shift",b),ce.set("readmission_charges",M),h.forEach(Ie=>{Ie?.value&&ce.append("weekly_off_day[]",Ie.value)}),ce.set("logo",F??""),ce.set("json_file",V??""),ce.set("server_key",f?.server_key??""),ce.set("in_time_start",P?ae(P).format("h:mm A"):""),ce.set("in_time_end",B?ae(B).format("h:mm A"):""),ce.set("out_time_start",H?ae(H).format("h:mm A"):""),ce.set("out_time_end",W?ae(W).format("h:mm A"):""),await nn(Ot.save,ce,t);const Ee={...JSON.parse(localStorage.getItem("genrall_settings")??"null")??{},logo:F||c?.logo||"",affliated_board_id:C?.value??c?.affliated_board_id??"",board_name:C?.label??c?.board_name??"",multiple_shift:b??c?.multiple_shift??""};localStorage.setItem("genrall_settings",JSON.stringify(Ee)),_.success("Organization settings saved.",{duration:1e3}),s.mutate?.()}catch(ce){_.error(ce?.response?.data?.msg??ce?.message??"Failed to save settings.",{duration:1500})}},de=A==="Yes";return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Yt,{title:"Organization",actions:we,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Organization Details"}),children:e.jsxs("form",{ref:a,onSubmit:le,children:[e.jsxs("div",{style:Ji,children:[e.jsx(Y,{type:"text",name:"name",label:"Organization Name*",required:!0,defaultValue:c?.name??""}),e.jsxs("div",{children:[e.jsx(Z,{label:"Currency*",options:u,value:y,onChange:Q=>m(Q)}),e.jsx("input",{type:"hidden",name:"currency",value:y?.value??""})]}),e.jsxs("div",{children:[e.jsx(Z,{label:"Default Country Code*",options:p,value:x,onChange:Q=>T(Q)}),e.jsx("input",{type:"hidden",name:"code",value:x?.value??""})]}),e.jsxs("div",{children:[e.jsx(Z,{label:"Time Zone*",options:w,value:D,onChange:Q=>k(Q)}),e.jsx("input",{type:"hidden",name:"time_zone",value:D?.value??""})]}),e.jsx(Y,{type:"text",name:"admission_prefix",label:"Receipt Prefix*",required:!0,defaultValue:c?.admission_prefix??""}),e.jsx(Y,{type:"number",name:"admission_start_number",label:"Admission Start Number*",required:!0,defaultValue:c?.admission_no_prefix??c?.admission_start_number??""}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Re-admission Charges"}),e.jsx(n.Radio.Group,{options:Qi,optionType:"button",buttonStyle:"solid",value:M,onChange:Q=>$(Q.target.value)}),e.jsx("input",{type:"hidden",name:"readmission_charges",value:M})]}),e.jsxs("div",{children:[e.jsx(Z,{label:"Weekly off Day",options:Cy,isMulti:!0,value:h,onChange:Q=>S(Q??[])}),h.map(Q=>e.jsx("input",{type:"hidden",name:"weekly_off_day[]",value:Q.value},Q.value))]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"In Time Start*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:P,onChange:Q=>I(Q),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_start",value:P?ae(P).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"In Time End*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:B,onChange:Q=>L(Q),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_end",value:B?ae(B).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Out Time Start*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:H,onChange:Q=>se(Q),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_start",value:H?ae(H).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Out Time End*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:W,onChange:Q=>K(Q),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_end",value:W?ae(W).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Salary Period"}),e.jsx(n.Radio.Group,{options:Xi,optionType:"button",buttonStyle:"solid",value:q,onChange:Q=>U(Q.target.value)}),e.jsx("input",{type:"hidden",name:"salary_period",value:q})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Salary Deduction"}),e.jsx(n.Radio.Group,{options:Qi,optionType:"button",buttonStyle:"solid",value:A,onChange:Q=>R(Q.target.value)}),e.jsx("input",{type:"hidden",name:"attendance_salary_calculation",value:A})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Multiple Shift"}),e.jsx(n.Radio.Group,{options:Xi,optionType:"button",buttonStyle:"solid",value:b,onChange:Q=>O(Q.target.value)}),e.jsx("input",{type:"hidden",name:"multiple_shift",value:b})]}),de?e.jsx(Y,{type:"number",name:"late_absent_day",label:"No of Late",defaultValue:c?.late_absent_day??""}):e.jsx("input",{type:"hidden",name:"late_absent_day",value:""})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:Ji,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Logo Upload"}),e.jsx(fa,{token:t,action:tl(),value:F,accept:"image/*",onChange:Q=>N(Q)}),e.jsx("input",{type:"hidden",name:"logo",value:F??""})]}),e.jsxs("div",{children:[e.jsx(Z,{label:"Select Affiliated Board",options:v,value:C,onChange:Q=>j(Q)}),e.jsx("input",{type:"hidden",name:"affliated_board_id",value:C?.value??""}),e.jsx("input",{type:"hidden",name:"board_name",value:C?.label??""})]}),e.jsx(vt,{label:"Address",name:"address",rows:3,defaultValue:c?.location_name??c?.address??""}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Json for Notification"}),e.jsx(fa,{token:t,action:xy(),value:V,accept:".json",onChange:Q=>z(Q)}),e.jsx("input",{type:"hidden",name:"json_file",value:V??""})]})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save",color:"primary"})})]})})})]})}function Iy({token:t}){return e.jsx(Ry,{token:t})}const zn=ft.academicYear,ky=({token:t,page:a=1,perPage:s=10})=>el({baseUrl:zn.table,token:t,page:a,perPage:s}),Py={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Oy=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[],My=(t,a=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??a;function Ey({token:t}){const[a,s]=i.useState({page:1,rowsPerPage:10}),[r,o]=i.useState(!1),[l,d]=i.useState(()=>{const h=ae(),S=ae().add(1,"year");return`${h.format("YYYY")}-${S.format("YYYY")}`}),[c,g]=i.useState(ae()),[f,u]=i.useState(ae().add(1,"year")),{isLoading:p,data:w,mutate:v}=ky({token:t,page:a.page,perPage:a.rowsPerPage}),y=i.useMemo(()=>Oy(w),[w]),m=i.useMemo(()=>My(w,y.length),[w,y.length]),x=async()=>{if(!l){_.error("Session name is required.");return}if(f&&c&&ae(f).isBefore(c)){_.error("End date must be after start date.");return}try{const h=new FormData;h.set("name",l),h.set("start_date",c?ae(c).format("YYYY-MM-DD"):""),h.set("end_date",f?ae(f).format("YYYY-MM-DD"):""),await nn(zn.add,h,t),_.success("Academic year added.",{duration:1e3}),o(!1),v?.()}catch(h){_.error(h?.response?.data?.msg??h?.message??"Failed to add academic year.",{duration:1500})}},T=async h=>{try{const S=new FormData;S.set("session",String(h)),await Xo(zn.setActive,S,t);const A=JSON.parse(localStorage.getItem("genrall_settings")??"null")??{};localStorage.setItem("genrall_settings",JSON.stringify({...A,session_id:String(h)})),_.success("Academic year activated.",{duration:1e3}),v?.()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to activate academic year.",{duration:1500})}},D=async h=>{try{await v(lr(zn.remove,h,t)),_.success("Academic year deleted.",{duration:1e3})}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to delete academic year.",{duration:1500})}},k=()=>{const h=new Blob([JSON.stringify(y,null,2)],{type:"application/json"}),S=URL.createObjectURL(h),A=document.createElement("a");A.href=S,A.download="academic-years.json",A.click(),URL.revokeObjectURL(S)},C=i.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(ee.PlusOutlined,{}),onClick:()=>o(!0)},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:()=>v?.()},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:k,disabled:y.length===0}],[y.length,v]),j=i.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name"},{title:"Start Date",dataIndex:"start_date",key:"start_date"},{title:"End Date",dataIndex:"end_date",key:"end_date"},{title:"Active",key:"active",render:(h,S)=>{const A=S.status==="Active";return e.jsxs("span",{children:[e.jsx(n.Popconfirm,{title:A?"Deactivate Academic Year?":"Activate Academic Year?",description:A?"Deactivate is not allowed. Activate another session to switch.":"This will set this year as the current academic session.",onConfirm:()=>{A?_.error("Deactivate is not allowed. Activate another session to switch."):T(S.id)},okText:"Yes",cancelText:"No",children:e.jsx(n.Switch,{checked:A})}),A&&e.jsx(n.Tag,{color:"green",style:{marginLeft:8},children:"Active"})]})}},{title:"Action",key:"action",render:(h,S)=>e.jsx(n.Popconfirm,{title:"Delete academic year?",description:"This will remove the session.",onConfirm:()=>D(S.id),okText:"Yes",cancelText:"No",children:e.jsx(n.Button,{type:"link",danger:!0,children:"Delete"})})}],[t,y.length]);return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Yt,{title:"Academic Year",actions:C,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Sessions"}),children:e.jsx(n.Table,{rowKey:"id",dataSource:y,columns:j,loading:p,pagination:{current:a.page,pageSize:a.rowsPerPage,total:m,showSizeChanger:!0,onChange:(h,S)=>s({page:h,rowsPerPage:Number(S)})}})})}),e.jsx(n.Modal,{open:r,onCancel:()=>o(!1),footer:null,title:"Add Academic Year",children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:Py,children:[e.jsx(Y,{label:"Session Name*",value:l,onChange:h=>d(h.target.value)}),e.jsxs("div",{children:[e.jsx(Ue,{Desplay:"Start Date*",value:c,onChange:h=>g(h),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:c?ae(c).format("YYYY-MM-DD"):""})]}),e.jsxs("div",{children:[e.jsx(Ue,{Desplay:"End Date*",value:f,onChange:h=>u(h),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:f?ae(f).format("YYYY-MM-DD"):""})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(ie,{value:"Submit",type:"button",onClick:x}),e.jsx(n.Button,{onClick:()=>o(!1),children:"Cancel"})]})]})})]})}function Fy({token:t}){return e.jsx(Ey,{token:t})}const al=ft.feeReceiptSetting,$y=({token:t})=>ht({url:al.get,token:t}),Os={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:16,alignItems:"start"},Uy=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null;function Ny({token:t}){const a=i.useRef(null),s=$y({token:t}),r=i.useMemo(()=>Uy(s.data),[s.data]),[o,l]=i.useState(""),[d,c]=i.useState(!1),[g,f]=i.useState(!1),[u,p]=i.useState(!1),[w,v]=i.useState("0"),[y,m]=i.useState("0"),[x,T]=i.useState("0"),[D,k]=i.useState(!1),[C,j]=i.useState(!1),[h,S]=i.useState(""),[A,R]=i.useState(!1),q=()=>{l(r?.number_of_receipt??""),c(String(r?.roll_number??"0")==="1"),f(String(r?.address??"0")==="1"),p(String(r?.gardian_name??"0")==="1"),v(String(r?.authorized_signatory??"0")),m(String(r?.parent_signatory??"0")),T(String(r?.dynamic_qr_code_device??"0")),k(String(r?.sequence_payment??"0")==="1"),j(String(r?.previois_fees??"0")==="1"),S(r?.upfront_payment_months??"")};i.useEffect(()=>{r&&q()},[r]);const U=()=>{a.current?.reset?.(),q()},b=()=>{const $={number_of_receipt:o,rollnumber:d?1:0,address:g?1:0,gardianname:u?1:0,authorizedsignatory:w,parentsignatory:y,dynamic_qr_code_device:x,sequence_payment:D?1:0,previois_fees:C?1:0,upfront_payment_months:h},F=new Blob([JSON.stringify($,null,2)],{type:"application/json"}),N=URL.createObjectURL(F),V=document.createElement("a");V.href=N,V.download="fee-receipt-setting.json",V.click(),URL.revokeObjectURL(N)},O=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(ee.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:U},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:b,disabled:!r}],[r,o,d,g,u,w,y,x,D,C,h]),M=async $=>{$.preventDefault(),R(!0);try{const F=new FormData;F.set("number_of_receipt",String(o??"")),F.set("rollnumber",d?"1":"0"),F.set("address",g?"1":"0"),F.set("gardianname",u?"1":"0"),F.set("authorizedsignatory",String(w??"0")),F.set("parentsignatory",String(y??"0")),F.set("dynamic_qr_code_device",String(x??"0")),F.set("sequence_payment",D?"1":"0"),F.set("previois_fees",C?"1":"0"),F.set("upfront_payment_months",String(h??"")),await nn(al.save,F,t),_.success("Fee receipt settings updated.",{duration:1e3}),s.mutate?.()}catch(F){_.error(F?.response?.data?.msg??F?.message??"Failed to update settings.",{duration:1500})}finally{R(!1)}};return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Yt,{title:"Fee Receipt Setting",actions:O,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Settings Form"}),children:e.jsxs("form",{ref:a,onSubmit:M,children:[e.jsxs("div",{style:Os,children:[e.jsx(Y,{type:"number",name:"number_of_receipt",label:"Number Of Receipt",value:o,onChange:$=>l($.target.value)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Roll Number"}),e.jsx(n.Checkbox,{checked:d,onChange:$=>c($.target.checked),children:"Show Roll Number in Fees Receipt"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Address"}),e.jsx(n.Checkbox,{checked:g,onChange:$=>f($.target.checked),children:"Show address in Fees Receipt"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Guardian Name"}),e.jsx(n.Checkbox,{checked:u,onChange:$=>p($.target.checked),children:"Show Guardian Name in Fees Receipt"})]})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:Os,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Authorized Signatory"}),e.jsxs(n.Radio.Group,{value:w,onChange:$=>v($.target.value),children:[e.jsx(n.Radio,{value:"1",children:"Enable"}),e.jsx(n.Radio,{value:"0",children:"Disable"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Parent Signatory"}),e.jsxs(n.Radio.Group,{value:y,onChange:$=>m($.target.value),children:[e.jsx(n.Radio,{value:"1",children:"Enable"}),e.jsx(n.Radio,{value:"0",children:"Disable"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Dynamic QR Code Device"}),e.jsxs(n.Radio.Group,{value:x,onChange:$=>T($.target.value),children:[e.jsx(n.Radio,{value:"1",children:"Enable"}),e.jsx(n.Radio,{value:"0",children:"Disable"})]})]})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:Os,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Sequence Payment"}),e.jsx(n.Checkbox,{checked:D,onChange:$=>k($.target.checked),children:"Student can pay in sequence"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Previous Fees"}),e.jsx(n.Checkbox,{checked:C,onChange:$=>j($.target.checked),children:"Previous Fees Carry Over to Next Year"})]}),e.jsx(Y,{type:"number",name:"upfront_payment_months",label:"Max Advance Payment (Months)",value:h,onChange:$=>S($.target.value)})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:A?"Updating...":"Done",disabled:A})})]})})})]})}function By({token:t}){return e.jsx(Ny,{token:t})}const Va=ft.marksheetSetting,Ly=({token:t})=>ht({url:Va.templateTypes,token:t}),qy=({token:t})=>ht({url:Va.classDropdown,token:t}),zy=({token:t})=>ht({url:Va.assignedTable,token:t}),Yy={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:20,alignItems:"end"},Zi=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[]:[],Vy=Array.from({length:12},(t,a)=>({value:String(a+1),label:`Design ${a+1}`})),Wy=t=>t?Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t)?t:[]:[];function Hy({token:t}){const a=i.useRef(null),s=Ly({token:t}),r=qy({token:t}),o=zy({token:t}),l=i.useMemo(()=>Zi(s.data),[s.data]),d=i.useMemo(()=>Zi(r.data),[r.data]),c=i.useMemo(()=>Wy(o.data),[o.data]),[g,f]=i.useState(null),[u,p]=i.useState(null),[w,v]=i.useState([]),y=()=>{a.current?.reset?.(),f(null),p(null),v([])},m=()=>{const C=new Blob([JSON.stringify(c,null,2)],{type:"application/json"}),j=URL.createObjectURL(C),h=document.createElement("a");h.href=j,h.download="marksheet-templates.json",h.click(),URL.revokeObjectURL(j)},x=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:y},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:m,disabled:c.length===0}],[c.length]),T=async C=>{if(C.preventDefault(),!g?.value){_.error("Select marksheet type.",{duration:1200});return}if(!u?.value){_.error("Select design.",{duration:1200});return}if(!w?.length){_.error("Select at least one class.",{duration:1200});return}try{const j=new FormData;j.set("temp_id",String(g.value)),j.set("ui_id",String(u.value)),w.forEach(h=>j.append("class_id[]",String(h))),await nn(Va.assign,j,t),_.success("Marksheet template assigned.",{duration:1e3}),o.mutate?.(),y()}catch(j){_.error(j?.response?.data?.msg??j?.message??"Failed to assign template.",{duration:1500})}},D=async C=>{try{await lr(Va.remove,C,t),_.success("Template removed.",{duration:1e3}),o.mutate?.()}catch(j){_.error(j?.response?.data?.msg??j?.message??"Failed to remove template.",{duration:1500})}},k=i.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class"},{title:"Template Name",dataIndex:"name",key:"name"},{title:"Template Design",dataIndex:"ui_id",key:"ui_id"},{title:"Action",key:"action",render:(C,j)=>e.jsx(ut,{id:j?.id,funcName:D})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Yt,{title:"Marksheet Setting",actions:x,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))"},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Template"}),children:e.jsxs("form",{ref:a,onSubmit:T,children:[e.jsxs("div",{style:Yy,children:[e.jsxs("div",{children:[e.jsx(Z,{label:"Select Marksheet Type",options:l,value:g,onChange:C=>f(C)}),e.jsx("input",{type:"hidden",name:"temp_id",value:g?.value??""})]}),e.jsxs("div",{children:[e.jsx(Z,{label:"Select Design",options:Vy,value:u,onChange:C=>p(C)}),e.jsx("input",{type:"hidden",name:"ui_id",value:u?.value??""})]})]}),e.jsx(n.Divider,{}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:8},children:"Class"}),e.jsx(n.Checkbox.Group,{options:d,value:w,onChange:C=>v(C)})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save"})})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Marksheet List"}),children:e.jsx(n.Table,{size:"small",rowKey:"id",columns:k,dataSource:c,pagination:!1})})]})})]})}function Ky({token:t}){return e.jsx(Hy,{token:t})}const Ms={fetch:`${ft.legalPages.get}?page_name=terms`,save:ft.legalPages.termsSave,fieldName:"terms_data"};function Gy({token:t}){return e.jsx(dr,{token:t,title:"Terms",fetchUrl:Ms.fetch,saveUrl:Ms.save,fieldName:Ms.fieldName})}function Jy({token:t}){return e.jsx(Gy,{token:t})}const Es={fetch:`${ft.legalPages.get}?page_name=privacy`,save:ft.legalPages.privacySave,fieldName:"privacy_data"};function Qy({token:t}){return e.jsx(dr,{token:t,title:"Privacy",fetchUrl:Es.fetch,saveUrl:Es.save,fieldName:Es.fieldName})}function Xy({token:t}){return e.jsx(Qy,{token:t})}const Fs={fetch:`${ft.legalPages.get}?page_name=about_us`,save:ft.legalPages.aboutSave,fieldName:"about_data"};function Zy({token:t}){return e.jsx(dr,{token:t,title:"About",fetchUrl:Fs.fetch,saveUrl:Fs.save,fieldName:Fs.fieldName})}function eg({token:t}){return e.jsx(Zy,{token:t})}const cr=ft.feesInfo,tg=({token:t})=>ht({url:cr.get,token:t}),ag=({token:t})=>ht({url:cr.statesDropdown,token:t}),$s={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},ng=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null,sg=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[]:[],rg=t=>t?Qo(`branch/logo/${t}`):"",Us=t=>t?Qo(`branch/signature/${t}`):"";function ig({token:t}){const a=i.useRef(null),s=tg({token:t}),r=ag({token:t}),o=i.useMemo(()=>ng(s.data),[s.data]),l=i.useMemo(()=>sg(r.data),[r.data]),[d,c]=i.useState(null),[g,f]=i.useState(""),[u,p]=i.useState(""),[w,v]=i.useState(""),[y,m]=i.useState(""),x=h=>{const S=new FormData(h),A=Object.fromEntries(S.entries());return A.state_id=d?.value??"",A.fees_receipt_logo=g,A.manager_signature=u,A.principal_signature=w,A.stamp=y,A},T=()=>{c(l.find(h=>String(h?.value)===String(o?.state_id??""))??null),f(o?.fees_receipt_logo??""),p(o?.manager_signature??""),v(o?.principal_signature??""),m(o?.stamp??"")};i.useEffect(()=>{o&&T()},[o,l]);const D=()=>{a.current?.reset?.(),T()},k=()=>{const h=x(a.current),S=new Blob([JSON.stringify(h,null,2)],{type:"application/json"}),A=URL.createObjectURL(S),R=document.createElement("a");R.href=A,R.download="fees-info.json",R.click(),URL.revokeObjectURL(A)},C=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(ee.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:D},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:k,disabled:!o}],[o,d,g,u,w,y]),j=async h=>{h.preventDefault();try{const S=x(h.target);await py(cr.save,S,t),_.success("Fees info saved.",{duration:1e3}),s.mutate?.()}catch(S){_.error(S?.response?.data?.msg??S?.message??"Failed to save fees info.",{duration:1500})}};return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Yt,{title:"Fees Info",actions:C,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"School Information"}),children:e.jsxs("form",{ref:a,onSubmit:j,children:[e.jsxs("div",{style:$s,children:[e.jsx(Y,{name:"Bussiness_name",label:"Business Name*",defaultValue:o?.name??"",required:!0}),e.jsx(Y,{name:"cin",label:"Sub Heading",defaultValue:o?.cin??""}),e.jsx(Y,{name:"school_no",type:"number",label:"School Number",defaultValue:o?.school_no??""}),e.jsx(Y,{name:"website",label:"Website",defaultValue:o?.website??""}),e.jsx(Y,{name:"school_Code",label:"School Code",defaultValue:o?.school_Code??""}),e.jsx(Y,{name:"offical_number",label:"Official Number",defaultValue:o?.offical_number??""}),e.jsx(Y,{name:"email_id",label:"Email",defaultValue:o?.email_id??""}),e.jsx(Y,{name:"receipt_prefix",label:"Receipt Prefix",defaultValue:o?.receipt_prefix??""}),e.jsx(Y,{name:"recipt_start_number",type:"number",label:"Receipt Start Number",defaultValue:o?.recipt_start_number??""}),e.jsxs("div",{children:[e.jsx(Z,{label:"State",options:l,value:d,onChange:c}),e.jsx("input",{type:"hidden",name:"state_id",value:d?.value??""})]}),e.jsx(Y,{name:"affiliation_no",label:"Affiliation Number",defaultValue:o?.affiliation_no??""}),e.jsx(Y,{name:"affiliation_desc",label:"Affiliation Description",defaultValue:o?.affiliation_desc??""}),e.jsx(Y,{name:"udise_code",label:"UDISE Code",defaultValue:o?.udise_code??""}),e.jsx(Y,{name:"color_code",label:"Primary Color",defaultValue:o?.color_code??""}),e.jsx(Y,{name:"fontcolor_code",label:"Font Color",defaultValue:o?.fontcolor_code??""})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:$s,children:[e.jsx(vt,{name:"Bussiness_address",rows:3,label:"Business Address",defaultValue:o?.Bussiness_address??o?.bussiness_address??""}),e.jsx(vt,{name:"note",rows:3,label:"Note",defaultValue:o?.note??""})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:$s,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Fees Receipt Logo"}),e.jsx(fa,{token:t,action:tl(),value:g,previewUrl:rg(g),accept:"image/*",onChange:f}),e.jsx("input",{type:"hidden",name:"fees_receipt_logo",value:g})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Manager Signature"}),e.jsx(fa,{token:t,action:Ps(),value:u,previewUrl:Us(u),accept:"image/*",onChange:p}),e.jsx("input",{type:"hidden",name:"manager_signature",value:u})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Principal Signature"}),e.jsx(fa,{token:t,action:Ps(),value:w,previewUrl:Us(w),accept:"image/*",onChange:v}),e.jsx("input",{type:"hidden",name:"principal_signature",value:w})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Stamp"}),e.jsx(fa,{token:t,action:Ps(),value:y,previewUrl:Us(y),accept:"image/*",onChange:m}),e.jsx("input",{type:"hidden",name:"stamp",value:y})]})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save"})})]})})})]})}function og({token:t}){return e.jsx(ig,{token:t})}const Yn=ft.payrollSettings,lg=({token:t,page:a=1,perPage:s=10})=>el({baseUrl:Yn.table,token:t,page:a,perPage:s}),dg={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Ua=[{value:"Allowances",label:"Allowances"},{value:"Dedection",label:"Dedection"}],Ns=[{value:"Flat",label:"Flat"},{value:"Percentage",label:"Percentage"}],cg=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],ug=(t,a=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??a;function pg({token:t}){const a=i.useRef(null),s=i.useRef(null),[r,o]=i.useState({page:1,rowsPerPage:10}),[l,d]=i.useState(!1),[c,g]=i.useState(null),[f,u]=i.useState(Ua[0]),[p,w]=i.useState(null),[v,y]=i.useState(null),[m,x]=i.useState(null),T=lg({token:t,page:r.page,perPage:r.rowsPerPage}),D=i.useMemo(()=>cg(T.data),[T.data]),k=i.useMemo(()=>ug(T.data,D.length),[T.data,D.length]),C=async U=>{U.preventDefault();try{const b=new FormData(U.target);b.set("type",f?.value??""),b.set("amount_type",p?.value??""),await nn(Yn.add,b,t),_.success("Payroll setting added.",{duration:1e3}),T.mutate?.(),U.target.reset(),w(null),u(Ua[0])}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to add payroll setting.",{duration:1500})}},j=U=>{g(U),y(Ua.find(b=>b.value===U?.type)??null),x(Ns.find(b=>b.value===U?.amount_type)??null),d(!0)},h=async U=>{U.preventDefault();try{const b=new FormData(U.target);b.set("id",String(c?.id??"")),b.set("type",v?.value??""),b.set("amount_type",m?.value??""),await Xo(Yn.edit,b,t),_.success("Payroll setting updated.",{duration:1e3}),d(!1),T.mutate?.()}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to update payroll setting.",{duration:1500})}},S=async U=>{try{await lr(Yn.remove,U,t),_.success("Payroll setting deleted.",{duration:1e3}),T.mutate?.()}catch(b){_.error(b?.response?.data?.msg??b?.message??"Failed to delete payroll setting.",{duration:1500})}},A=()=>{const U=new Blob([JSON.stringify(D,null,2)],{type:"application/json"}),b=URL.createObjectURL(U),O=document.createElement("a");O.href=b,O.download="payroll-settings.json",O.click(),URL.revokeObjectURL(b)},R=i.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(ee.PlusOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:()=>T.mutate?.()},{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:A,disabled:D.length===0}],[D.length]),q=i.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title"},{title:"Type",dataIndex:"type",key:"type"},{title:"Amount Type",dataIndex:"amount_type",key:"amount_type"},{title:"Amount",dataIndex:"Amount",key:"Amount"},{title:"Action",key:"action",render:(U,b)=>e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>j(b)}),e.jsx(n.Popconfirm,{title:"Delete payroll setting?",onConfirm:()=>S(b.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Yt,{title:"Payroll Settings",actions:R,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"minmax(320px, 420px) 1fr"},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Allowances / Deductions"}),children:e.jsxs("form",{ref:a,onSubmit:C,children:[e.jsxs("div",{style:dg,children:[e.jsx(Y,{name:"title",label:"Title",required:!0}),e.jsxs("div",{children:[e.jsx(Z,{label:"Type",options:Ua,value:f,onChange:u}),e.jsx("input",{type:"hidden",name:"type",value:f?.value??""})]}),e.jsxs("div",{children:[e.jsx(Z,{label:"Amount Type",options:Ns,value:p,onChange:w}),e.jsx("input",{type:"hidden",name:"amount_type",value:p?.value??""})]}),e.jsx(Y,{name:"Amount",type:"number",label:"Amount",required:!0})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:20},children:e.jsx(ie,{type:"submit",value:"Submit"})})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll Settings List"}),children:e.jsx(n.Table,{rowKey:"id",columns:q,dataSource:D,loading:T.isLoading,pagination:{current:r.page,pageSize:r.rowsPerPage,total:k,showSizeChanger:!0,onChange:(U,b)=>o({page:U,rowsPerPage:Number(b)})}})})]})}),e.jsx(n.Drawer,{open:l,onClose:()=>d(!1),title:"Edit Payroll Setting",width:420,children:e.jsx("form",{ref:s,onSubmit:h,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{name:"title",label:"Title",required:!0,defaultValue:c?.title??""}),e.jsxs("div",{children:[e.jsx(Z,{label:"Type",options:Ua,value:v,onChange:y}),e.jsx("input",{type:"hidden",name:"type",value:v?.value??""})]}),e.jsxs("div",{children:[e.jsx(Z,{label:"Amount Type",options:Ns,value:m,onChange:x}),e.jsx("input",{type:"hidden",name:"amount_type",value:m?.value??""})]}),e.jsx(Y,{name:"Amount",type:"number",label:"Amount",required:!0,defaultValue:c?.Amount??""}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Update"})})]})})})]})}function mg({token:t}){return e.jsx(pg,{token:t})}const nl=ft.paymentGateway,fg=({token:t})=>ht({url:nl.get,token:t}),hg=[{id:"Razorpay",title:"Razorpay",fields:["keyId","keySecret"]},{id:"PhonePe",title:"Pine Labs",fields:["merchantId","saltKey","saltIndex"]},{id:"Paytm",title:"HDFC",fields:["merchantId","merchantKey"]},{id:"SabPaisa",title:"SabPaisa",fields:["clientCode","transUserName","transUserPassword","authKey","authIV"]}],Vt={Razorpay:{keyId:"",keySecret:"",isActive:!0},PhonePe:{merchantId:"",saltKey:"",saltIndex:"1",isActive:!1},Paytm:{merchantId:"",merchantKey:"",isActive:!1},SabPaisa:{clientCode:"",transUserName:"",transUserPassword:"",authKey:"",authIV:"",isActive:!1}},eo=t=>{const a=Array.isArray(t?.data)&&t.data[0]||Array.isArray(t?.data?.data)&&t.data.data[0]||Array.isArray(t)&&t[0]||null;if(!a?.data)return Vt;try{const s=JSON.parse(a.data||"{}"),r=s?.data&&typeof s.data=="object"?s.data:s;return{Razorpay:{...Vt.Razorpay,...r?.Razorpay??{}},PhonePe:{...Vt.PhonePe,...r?.PhonePe??r?.PineLab??r?.PineLabs??{}},Paytm:{...Vt.Paytm,...r?.Paytm??r?.HDFC??{}},SabPaisa:{...Vt.SabPaisa,...r?.SabPaisa??{}}}}catch{return Vt}};function yg({token:t}){const a=i.useRef(null),s=fg({token:t}),[r,o]=i.useState(Vt);i.useEffect(()=>{s.data&&o(eo(s.data))},[s.data]);const l=(u,p,w)=>{o(v=>({...v,[u]:{...v[u],[p]:w}}))},d=()=>o(eo(s.data)),c=()=>{const u=new Blob([JSON.stringify(r,null,2)],{type:"application/json"}),p=URL.createObjectURL(u),w=document.createElement("a");w.href=p,w.download="payment-gateway-settings.json",w.click(),URL.revokeObjectURL(p)},g=i.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(ee.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:d},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:c}],[r,s.data]),f=async u=>{u.preventDefault();try{await Zo(nl.save,{data:r},t),_.success("Payment gateway settings saved.",{duration:1e3}),s.mutate?.()}catch(p){_.error(p?.response?.data?.msg??p?.message??"Failed to save gateway settings.",{duration:1500})}};return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(_.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Yt,{title:"Payment Gateway",actions:g,children:e.jsxs("form",{ref:a,onSubmit:f,style:{display:"grid",gap:20},children:[hg.map(u=>{const p=r[u.id]??{};return e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:u.title}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("span",{style:{fontSize:14,fontWeight:500},children:["Enable ",u.title]}),e.jsx(n.Switch,{checked:!!p.isActive,onChange:w=>l(u.id,"isActive",w)})]}),e.jsx(n.Divider,{style:{margin:0}}),e.jsx("div",{style:{display:"grid",gap:16,gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))"},children:u.fields.map(w=>e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:w}),e.jsx(n.Input,{value:p[w]??"",type:w.toLowerCase().includes("secret")||w.toLowerCase().includes("password")?"password":"text",onChange:v=>l(u.id,w,v.target.value)})]},w))})]})},u.id)}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ie,{type:"submit",value:"Save"})})]})})]})}function gg({token:t}){return e.jsx(yg,{token:t})}const xg=({routes:t=[],onNavigate:a})=>e.jsx(n.Row,{gutter:[16,16],children:t.map((s,r)=>e.jsx(n.Col,{xs:24,md:8,lg:8,children:e.jsx(E,{children:e.jsx(no,{icon:s?.icon??"",title:s?.title??"",path:s?.path??"",onClick:a})})},`${r}route001`))});exports.About=eg;exports.AcademicYear=Fy;exports.Academics=Hf;exports.AddBook=Ku;exports.AddDriver=Lu;exports.AddHomework=Vu;exports.AddStaff=mm;exports.AdmissionEnquiry=Cc;exports.ApplyLeave=Qm;exports.AprroveLeaveRequest=Ym;exports.AssignByClass=jh;exports.AssignStudentToTransport=Bu;exports.AssignSubjects=gh;exports.AssignTimeGroup=Dh;exports.AssignVehicles=ku;exports.AttendanceDashboard=Mf;exports.BookList=Gu;exports.BuySellProduct=Pp;exports.Category=Sp;exports.Class=rh;exports.CoScholasticArea=Fh;exports.Complain=wu;exports.CreateTimeGroup=wh;exports.DailyAttendance=Nf;exports.Department=nf;exports.Designation=of;exports.ErpDashboard=ol;exports.FeeReceiptSetting=By;exports.FeesInfo=og;exports.GatePass=Tu;exports.GeneralSetting=ly;exports.Holidays=mh;exports.IssueReturn=Qu;exports.LeaveType=ef;exports.LibraryAssignStudent=Xu;exports.LibraryCategory=Zu;exports.LibraryRenewalReport=tp;exports.LibraryReport=ep;exports.ManageStock=Vp;exports.MarksheetSetting=Ky;exports.MenuSubmenu=oc;exports.MonthlyReport=qf;exports.Notes=Lh;exports.NpmReport=Qp;exports.Organization=Iy;exports.PaymentGateway=gg;exports.Payroll=Nm;exports.PayrollReceiptDetails=xf;exports.PayrollSettings=mg;exports.PhoneCallLog=tu;exports.PostalDispatch=ou;exports.PostalReceive=mu;exports.Privacy=Xy;exports.Products=gp;exports.PromoteStudents=Ph;exports.RoutePage=xg;exports.RouteTimeTable=qu;exports.Sections=eh;exports.SellReports=qp;exports.SetupFrontOffice=_u;exports.Shift=cf;exports.StaffAttendance=Im;exports.StaffAttendanceReport=Mm;exports.StaffDailyAttendance=hf;exports.StaffDirectory=xm;exports.StockReport=Jp;exports.Stoppage=Yu;exports.StudentAttendance=Ff;exports.SubCategory=Tp;exports.Subjects=dh;exports.SubmissionDetails=Wu;exports.Syllabus=Jh;exports.Terms=Jy;exports.TimeTable=oy;exports.TransferCertificate=Wh;exports.TransportRoutes=Du;exports.TransportVehicles=Ru;exports.Unit=Fp;exports.Vendor=dp;exports.VisitorBook=Wc;exports.YearlyReport=Wf;exports.setBaseUrl=Yd;
|
|
59
|
+
`}),e.jsx(C,{children:e.jsx("div",{style:{display:"flex",justifyContent:"space-between"},children:e.jsx(wt,{data:{tableRef:F}})})}),e.jsxs("div",{className:"ubk-table-shell",ref:F,style:{marginTop:12},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,flexWrap:"wrap",marginBottom:14},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"#222"},children:[e.jsx("span",{children:"Show"}),e.jsx(n.Select,{size:"small",value:E.rowsPerPage,onChange:se=>q(1,se),options:[10,25,50,100].map(se=>({label:se,value:se})),style:{width:72}}),e.jsx("span",{children:"entries"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:12,color:"#222"},children:"Search:"}),e.jsx(n.Input,{size:"small",allowClear:!0,value:O,onChange:se=>{$(se.target.value),M(me=>({...me,page:1}))},placeholder:"Enter search keyword",prefix:e.jsx(ee.SearchOutlined,{style:{color:"#a3a8cf"}}),style:{width:220,borderWidth:"0 0 1px 0",borderRadius:0,background:"transparent"}})]})]}),e.jsx("div",{className:"print-only",children:e.jsx(Ot,{})}),je]}),l&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,marginTop:16,flexWrap:"wrap"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:`Showing ${fe} to ${Se} of ${Ge} entries`}),e.jsx(n.Pagination,{current:E.page,pageSize:E.rowsPerPage,total:Ge||0,showSizeChanger:!1,onChange:q})]})]})]})},Au=({token:t,type:a})=>{const[s,i]=r.useState({page:1,rowsPerPage:10}),o="api/branchapi/frontoffice/enquirytablelist",l=o.includes("?")?o.endsWith("?")||o.endsWith("&")?"":"&":"?",d=`${o}${l}page=${s.page}&per_page=${s.rowsPerPage}`,{isLoading:c,data:g,error:h}=W(t?[d,t]:null,([R,k])=>K(R,k)),[u,p]=r.useState(!1),A=(R,k)=>{i({page:R,rowsPerPage:parseInt(k)})},w=async R=>{},b=R=>{console.log("dsdsdsdsd",R),p(R)},m=()=>{},j=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],D=r.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0,sorter:{compare:(R,k)=>R.name.localeCompare(k.name)}},{id:"2",name:"Phone",selector:"contact",sortable:!0,sorter:(R,k)=>(R.contact||"").localeCompare(k.contact||"")},{id:"6",name:"Description",selector:"description",sortable:!0,sorter:(R,k)=>(R.description||"").localeCompare(k.description||"")},{id:"3",name:"Source",selector:"source_name",sortable:!0,sorter:(R,k)=>(R.source_name||"").localeCompare(k.source_name||"")},{id:"4",name:"Enquiry Date",selector:"date",sortable:!0,sorter:(R,k)=>new Date(R.date)-new Date(k.date)},{id:"5",name:"Next Follow Up Date",selector:"follow_up_date",sortable:!0,sorter:(R,k)=>new Date(R.follow_up_date)-new Date(k.follow_up_date)}]);return e.jsx("div",{children:e.jsx(Te,{parentCallback:A,data:{newData:g,columns:D,action:!0,Loading:c,error:h,open:u,viewDetails:m,deleteTodoMutation:w,DrawerUpdate:b,ActionView:j}})})};var Du=Ho();const _s=Yo(Du),Xo=()=>{};class rr extends r.Component{state={value:this.props.value||this.props.defaultValue||""};selectRef=null;setSelectRef=a=>{this.selectRef=a};componentDidUpdate(a){a.value!==this.props.value&&this.setState({value:this.props.value})}onChange=(a,s)=>{this.props.onChange(a,s),this.setState({value:a})};getValue=()=>{const{value:a}=this.state;return a?Array.isArray(a)?a.length?"valid":"":typeof a=="object"?a.value||"":a:""};render(){const{SelectComponent:a,required:s,...i}=this.props;console.log("sdsdsfsdddddddd",{...i});const{isDisabled:o}=this.props,l=!o;return e.jsxs("div",{children:[e.jsx(a,{...i,ref:this.setSelectRef,onChange:this.onChange}),l&&e.jsx("input",{tabIndex:-1,autoComplete:"off",style:{opacity:0,width:"100%",height:0,display:"block"},value:this.getValue(),onChange:Xo,onFocus:()=>this.selectRef.focus(),required:s})]})}}rr.defaultProps={onChange:Xo};rr.protoTypes={selectComponent:_s.func.isRequired,onChange:_s.func,required:_s.bool};const Tu={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Ru={menuPortal:t=>({...t,zIndex:9999}),control:(t,a)=>({...t,minHeight:40,height:40,fontSize:"14px",border:"none",borderBottom:`1px solid ${a.isFocused?"#222":"#d9d9d9"}`,borderRadius:0,boxShadow:"none",backgroundColor:"transparent",transition:"border-color 0.2s ease","&:hover":{border:"none",borderBottom:`1px solid ${a.isFocused?"#222":"#a8a8a8"}`}}),valueContainer:t=>({...t,height:40,padding:"0 0",display:"flex",alignItems:"center"}),input:t=>({...t,margin:0,padding:0}),indicatorSeparator:()=>({display:"none"}),indicatorsContainer:t=>({...t,height:40}),dropdownIndicator:(t,a)=>({...t,padding:"0 0 0 8px",color:a.isFocused?"#222":"#b5b5b5"}),singleValue:t=>({...t,color:"#222",marginLeft:0}),placeholder:t=>({...t,color:"#9f9f9f",marginLeft:0}),option:(t,a)=>({...t,fontSize:"14px",backgroundColor:a.isFocused?"#f8f8f8":"#fff",color:"#222",cursor:"pointer"})},Zo=t=>e.jsx(po.components.Input,{...t,className:"input-cont",required:!!t?.selectProps?.required}),Iu=t=>e.jsx(rr,{...t,SelectComponent:po,components:{Input:Zo},options:t.options}),Q=r.forwardRef(({...t},a)=>e.jsxs("div",{className:"form-group",style:{height:"auto"},children:[t.label&&e.jsx("label",{className:"labelfont",style:Tu,children:t?.label}),e.jsx(Iu,{components:{Input:Zo},menuPortalTarget:document.body,styles:Ru,className:"input-cont",...t,ref:a})]})),ku={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Pu={width:"100%",height:"40px",background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},Ou=(t,a,s)=>a?t>te(s).endOf("day")||t<te(a).endOf("day"):!1,Me=r.forwardRef(function(a,s){const{...i}=a;return e.jsxs("div",{className:"form-group",children:[i.Desplay&&e.jsx("label",{className:`labelfont ${i.classnme?i.classnme:""}`,style:ku,children:i.Desplay}),e.jsx(n.DatePicker,{...i,style:{...Pu,...i.style||{}},className:"form-group",disabledDate:o=>Ou(o,i.sessionStart||i.minDate?.subtract(1,"day").format("YYYY-MM-DD"),i.sessionEnd||i.maxDate?.format("YYYY-MM-DD")),required:!0,ref:s})]})}),Mu={minWidth:160,height:36,padding:"0 28px",border:"none",borderRadius:999,background:"linear-gradient(90deg, #f59b1c 0%, #ef3e7b 100%)",color:"#fff",fontSize:14,fontWeight:700,textTransform:"uppercase",cursor:"pointer",boxShadow:"none"},ne=r.forwardRef(({error:t,success:a,disabled:s,style:i,...o},l)=>e.jsx("div",{className:"form-group",style:{marginBottom:0},children:e.jsx("input",{...o,ref:l,disabled:s,style:{...Mu,opacity:s?.7:1,cursor:s?"not-allowed":"pointer",...i||{}}})})),Eu={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Fu={width:"100%",minHeight:80,padding:"8px 0",fontSize:"14px",color:"#222",background:"transparent",border:0,borderTop:0,borderLeft:0,borderRight:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",outline:"none",resize:"vertical",transition:"border-color 0.2s ease"},st=({style:t,onFocus:a,onBlur:s,...i})=>{const[o,l]=r.useState(!1);return e.jsxs("div",{style:{width:"100%"},children:[i.label&&e.jsx("label",{className:"labelfont",style:Eu,children:i.label}),e.jsx("textarea",{placeholder:i.placeholder||i.label,...i,onFocus:d=>{l(!0),a?.(d)},onBlur:d=>{l(!1),s?.(d)},style:{...Fu,borderBottom:`1px solid ${o?"#222":"#d9d9d9"}`,...t||{}}})]})},ze=t=>({optimisticData:a=>[...a.data,t],populateCache:(a,s)=>[...s.data,a]}),Ne=t=>({optimisticData:a=>a.data.filter(s=>s.id!==t),populateCache:(a,s)=>s.data.filter(i=>i.id!==t)}),Uu=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},$u="api/branchapi/Frontoffice/visitorbookShowdata",Nu="api/branchapi/Frontoffice/purposedropdown";function Lu({data:t}){const{handleUpdate:a,token:s}=t||{},i=r.useContext(At),o=$u.replace(/\?.*$/,""),{isLoading:l,data:d}=W(s&&i?[o,i,s]:null,([m,j,D])=>Qa(m,{id:j},D)),{isLoading:c,data:g}=W(s?[Nu,s]:null,([m,j])=>K(m,j)),h=r.useMemo(()=>Uu(g),[g]),u=d?.data?.[0],[p,A]=r.useState({purpose:void 0,name:"",phone:"",id_card:"",number_of_person:1,date:null,in_time:null,out_time:null,note:"",address:"",image:""});r.useEffect(()=>{u&&A({purpose:u?.purpose,name:u?.name||"",phone:u?.contact||"",id_card:u?.id_proof||"",number_of_person:u?.no_of_pepple||1,date:u?.date?te(u.date):null,in_time:u?.in_time?te(u.in_time,"h:mm a"):null,out_time:u?.out_time?te(u.out_time,"h:mm a"):null,note:u?.note||"",address:u?.address||"",image:u?.image||""})},[u]);const w=(m,j)=>{A(D=>({...D,[m]:j}))},b=`${He()}/branchapi/frontoffice/uploadfrontofficeDocument`;return l||c?e.jsx(C,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(C,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:m=>a(m,i),children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Visitor"})}),e.jsx(C,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{type:"text",value:i,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Q,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Purpose",name:"purpose",allowSelectAll:!1,value:p.purpose,onChange:m=>w("purpose",m)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"name",type:"text",label:"Name",required:!0,value:p.name,onChange:m=>w("name",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"phone",type:"text",label:"Phone No.",required:!0,value:p.phone,onChange:m=>w("phone",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"id_card",type:"text",label:"ID Card",value:p.id_card,onChange:m=>w("id_card",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"number_of_person",type:"number",label:"Number of Person",value:p.number_of_person,onChange:m=>w("number_of_person",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:p.date,Desplay:"Date",id:"date",name:"date",required:!0,onChange:m=>w("date",m)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(C,{children:[e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",value:p.in_time,onChange:m=>w("in_time",m),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time",value:p.in_time?p.in_time.format("h:mm a"):"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(C,{children:[e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",value:p.out_time,onChange:m=>w("out_time",m),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time",value:p.out_time?p.out_time.format("h:mm a"):"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"note",type:"text",label:"Note",value:p.note,onChange:m=>w("note",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(st,{type:"text",label:"Address",name:"address",rows:3,required:!0,value:p.address,onChange:m=>w("address",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(C,{children:[e.jsx(n.Upload,{action:b,headers:{Authorization:s},maxCount:1,onChange:m=>{if(m.file.status==="removed"&&w("image",""),m.file.status==="done"){const j=m.file.response?.data??m.file.response?.file??"";w("image",String(j??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:p.image?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"image",value:p.image||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; } .textDanger { color: #dc2626; }"})]})}const Bu=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},aa="api/branchapi/Frontoffice/visitortablelist",qu="api/branchapi/Frontoffice/purposedropdown",zu="api/branchapi/frontoffice/addvisitors",Yu="api/branchapi/frontoffice/editvisitorsdata",Vu="api/branchapi/frontoffice/deletevisitors",Wu=`${He()}/branchapi/frontoffice/uploadfrontofficeDocument`;function Hu({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(""),[c,g]=r.useState(""),[h,u]=r.useState("03:30 PM"),p=(y,P)=>{s({page:y,rowsPerPage:Number.parseInt(P,10)})},A=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],w=r.useMemo(()=>{const y=aa.includes("?")?aa.endsWith("?")||aa.endsWith("&")?"":"&":"?";return`${aa}${y}page=${a.page}&per_page=${a.rowsPerPage}`},[aa,a.page,a.rowsPerPage]),{isLoading:b,error:m,data:j,mutate:D}=W(t?[w,t]:null,([y,P])=>K(y,P)),{isLoading:R,data:k}=W(t?[qu,t]:null,([y,P])=>K(y,P)),S=r.useMemo(()=>Bu(k),[k]),x=async(y,P)=>{try{await D(Ee(y,P,t),ze(P)),v.success("Success! Added new item.")}catch{v.error("Failed to add the new item.")}},f=async y=>{try{await D(qe(Vu,y,t),Ne(y)),v.success("Success! Deleted item.")}catch{v.error("Failed to delete the item.")}},_=async(y,P,O)=>{try{const $=await Be(y,P,t);D($),Array.isArray($?.data)&&D(`${aa.replace(/\?.*$/,"")}?id=${O}`,$),v.success("Success! Updated item.")}catch{v.error("Failed to update the item.")}},T=async(y,P)=>{y.preventDefault();const O=new FormData(y.target);await _(Yu,O,P),y.target.reset(),d(""),o(!1)},I=async y=>{if(y.preventDefault(),!y.target?.date?.value)v.error("Select required dates"),y.target?.date?.focus(),g("textDanger");else{const P=new FormData(y.target);await x(zu,P),y.target.reset(),g(""),d(""),u("03:30 PM")}},B=y=>{o(y)},L=r.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0},{id:"2",name:"Purpose",selector:"visitors_purpose",sortable:!0},{id:"3",name:"Phone",selector:"contact",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Address",selector:"address",sortable:!0},{id:"5",name:"In Time",selector:"in_time",sortable:!0},{id:"6",name:"Out Time",selector:"out_time",sortable:!0}],[]);return e.jsxs("div",{children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Visitor"})}),e.jsx(C,{p:3,children:e.jsx("form",{onSubmit:I,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Q,{options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Purpose",name:"purpose",required:!0,allowSelectAll:!1})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{required:!0,name:"name",type:"text",label:"Name"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",name:"phone",type:"tel",label:"Phone No.",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"id_card",type:"text",label:"ID Card"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{defaultValue:1,name:"number_of_person",type:"number",label:"Number of Person"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:te(),Desplay:"Date",id:"date",name:"date",classnme:c,onChange:()=>g("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(C,{children:[e.jsx(n.TimePicker,{defaultValue:te("2022-04-17T15:30","h:mm a"),id:"in_time",use12Hours:!0,format:"h:mm a",onChange:(y,P)=>u(P),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time",value:h,readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(st,{type:"text",label:"Address*",name:"address",rows:3,required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(C,{children:[e.jsx(n.Upload,{action:Wu,headers:{Authorization:t},maxCount:1,onChange:y=>{if(y.file.status==="removed"&&d(""),y.file.status==="done"){const P=y.file.response?.data??y.file.response?.file??"";d(String(P??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:l?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"image",value:l||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Visitor List"})}),e.jsx(C,{pt:3,children:e.jsx(Te,{parentCallback:p,data:{newData:j,columns:L,action:!0,ActionView:A,Loading:b,error:m,editDesign:e.jsx(Lu,{data:{handleUpdate:T,token:t}}),deleteTodoMutation:f,open:i,DrawerUpdate:B,viewDetails:""}})})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const Ku="api/branchapi/frontoffice/generalcallsShowdata",Gu=[{value:"Incoming",label:"Incoming"},{value:"Outgoing",label:"Outgoing"}];function Ju({data:t}){const{handleUpdate:a,token:s}=t||{},i=r.useContext(At),o=Ku.replace(/\?.*$/,""),{isLoading:l,data:d}=W(s&&i?[o,i,s]:null,([p,A,w])=>Qa(p,{id:A},w)),c=d?.data?.[0],[g,h]=r.useState({name:"",phone:"",description:"",date:null,next_follow_up_date:null,call_duration:"",note:"",call_type:""});r.useEffect(()=>{c&&h({name:c?.name||"",phone:c?.contact||"",description:c?.description||"",date:c?.date?te(c.date):null,next_follow_up_date:c?.follow_up_date?te(c.follow_up_date):null,call_duration:c?.call_dureation||"",note:c?.note||"",call_type:c?.call_type||""})},[c]);const u=(p,A)=>{h(w=>({...w,[p]:A}))};return l?e.jsx(C,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(C,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:p=>a(p,i),children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Call Log"})}),e.jsx(C,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{type:"text",value:i,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"name",type:"text",label:"Name",required:!0,value:g.name,onChange:p=>u("name",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",value:g.phone,onChange:p=>u("phone",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"description",type:"text",label:"Description",value:g.description,onChange:p=>u("description",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:g.date,Desplay:"Date",id:"date",name:"date",onChange:p=>u("date",p)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:g.next_follow_up_date,Desplay:"Next Follow Up Date",id:"fdate",name:"next_follow_up_date",onChange:p=>u("next_follow_up_date",p)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"call_duration",type:"text",label:"Call Duration",value:g.call_duration,onChange:p=>u("call_duration",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"note",type:"text",label:"Note",value:g.note,onChange:p=>u("note",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Q,{options:Gu,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Call Type",name:"call_type",required:!0,allowSelectAll:!1,value:g.call_type?{value:g.call_type,label:g.call_type}:null,onChange:p=>u("call_type",p?.value||"")})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const na="api/branchapi/frontoffice/generalcalltablelist",Qu="api/branchapi/frontoffice/addgenaralcalls",Xu="api/branchapi/frontoffice/editgeneralcall",Zu="api/branchapi/frontoffice/deletegeneralcall",ep=[{value:"Incoming",label:"Incoming"},{value:"Outgoing",label:"Outgoing"}],tp=[{key:"all",label:"All Calls"},{key:"Incoming",label:"Incoming"},{key:"Outgoing",label:"Outgoing"}];function ap({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(""),[c,g]=r.useState(""),[h,u]=r.useState("all"),[p,A]=r.useState(""),w=r.useRef(null),b=(y,P)=>{s({page:y,rowsPerPage:Number.parseInt(P,10)})},m=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],j=r.useMemo(()=>{const y=na.includes("?")?na.endsWith("?")||na.endsWith("&")?"":"&":"?",P=new URLSearchParams;return P.set("page",String(a.page)),P.set("per_page",String(a.rowsPerPage)),h!=="all"&&P.set("call_type",h),`${na}${y}${P.toString()}`},[na,a.page,a.rowsPerPage,h]),{isLoading:D,error:R,data:k,mutate:S}=W(t?[j,t]:null,([y,P])=>K(y,P)),x=async(y,P)=>{try{await S(Ee(y,P,t),ze(P)),v.success("Success! Added new item.")}catch{v.error("Failed to add the new item.")}},f=async y=>{try{await S(qe(Zu,y,t),Ne(y)),v.success("Success! Deleted item.")}catch{v.error("Failed to delete the item.")}},_=async(y,P,O)=>{try{const $=await Be(y,P,t);S($),Array.isArray($?.data)&&S(`${na.replace(/\?.*$/,"")}?id=${O}`,$),v.success("Success! Updated item.")}catch{v.error("Failed to update the item.")}},T=async(y,P)=>{y.preventDefault();const O=new FormData(y.target);await _(Xu,O,P),y.target.reset(),d(""),o(!1)},I=async y=>{if(y.preventDefault(),!y.target?.date?.value)v.error("Select required dates"),y.target?.date?.focus(),g("textDanger");else{const P=new FormData(y.target);await x(Qu,P),y.target.reset(),g(""),d(""),A("")}},B=y=>{o(y)},L=r.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0},{id:"2",name:"Phone",selector:"contact",sortable:!0},{id:"3",name:"Description",selector:"description",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Follow Up Date",selector:"follow_up_date",sortable:!0},{id:"6",name:"Call Duration",selector:"call_dureation",sortable:!0}],[]);return e.jsxs(C,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Phone Call Log"})}),e.jsx(C,{p:3,children:e.jsx("form",{onSubmit:I,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{required:!0,name:"name",type:"text",label:"Name"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{pattern:"[0-9]{3}[0-9]{3}[0-9]{4}",name:"phone",type:"tel",label:"Phone",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"description",type:"text",label:"Description"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:te(),Desplay:"Date",id:"date",name:"date",classnme:c,onChange:()=>g("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Me,{format:"YYYY-MM-DD",Desplay:"Next Follow Up Date",id:"fdate",name:"follow_up_date"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"call_dureation",type:"text",label:"Call Duration"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Q,{options:ep,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Call Type",name:"call_type",required:!0,allowSelectAll:!1,value:p?{value:p,label:p}:null,onChange:y=>A(y?.value||"")})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Phone Call Log List"})}),e.jsxs(C,{pt:3,children:[e.jsx(n.Tabs,{activeKey:h,onChange:u,items:tp}),e.jsx(wt,{data:{tableRef:w}}),e.jsx(Te,{parentCallback:b,data:{newData:k,columns:L,action:!0,ActionView:m,Loading:D,error:R,editDesign:e.jsx(Ju,{data:{handleUpdate:T,token:t}}),deleteTodoMutation:f,open:i,DrawerUpdate:B,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const np="api/branchapi/frontoffice/postaldispatchreceiveShowdata";function sp({data:t}){const{handleUpdate:a,token:s}=t||{},i=r.useContext(At),o=np.replace(/\?.*$/,""),{isLoading:l,data:d}=W(s&&i?[o,i,s]:null,([p,A,w])=>Qa(p,{id:A},w)),c=d?.data?.[0],[g,h]=r.useState({to_title:"",refernce:"",address:"",note:"",from_title:"",date:null,image:""});r.useEffect(()=>{c&&h({to_title:c?.to_title||"",refernce:c?.reference_no||"",address:c?.address||"",note:c?.note||"",from_title:c?.from_title||"",date:c?.date?te(c.date):null,image:c?.image||""})},[c]);const u=(p,A)=>{h(w=>({...w,[p]:A}))};return l?e.jsx(C,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(C,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:p=>a(p,i),children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Postal Dispatch"})}),e.jsx(C,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{type:"text",value:i,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"title",type:"text",label:"To Title *",required:!0,value:g.to_title,onChange:p=>u("to_title",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"refernce",type:"text",label:"Reference No",value:g.refernce,onChange:p=>u("refernce",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"address",type:"text",label:"Address",required:!0,value:g.address,onChange:p=>u("address",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"note",type:"text",label:"Note",value:g.note,onChange:p=>u("note",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"from_title",type:"text",label:"From Title",required:!0,value:g.from_title,onChange:p=>u("from_title",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:g.date,Desplay:"Date",id:"date",name:"date",onChange:p=>u("date",p)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const sa="api/branchapi/frontoffice/postaldispatchtablelist",rp="api/branchapi/frontoffice/addpostaldispatch",ip="api/branchapi/frontoffice/editpostaldispatch",op="api/branchapi/frontoffice/deletepostalreceivedispatch";function lp({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(""),[c,g]=r.useState(""),h=r.useRef(null),u=(T,I)=>{s({page:T,rowsPerPage:Number.parseInt(I,10)})},p=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],A=r.useMemo(()=>{const T=sa.includes("?")?sa.endsWith("?")||sa.endsWith("&")?"":"&":"?";return`${sa}${T}page=${a.page}&per_page=${a.rowsPerPage}`},[sa,a.page,a.rowsPerPage]),{isLoading:w,error:b,data:m,mutate:j}=W(t?[A,t]:null,([T,I])=>K(T,I)),D=async(T,I)=>{try{await j(Ee(T,I,t),ze(I)),v.success("Success! Added new item.")}catch{v.error("Failed to add the new item.")}},R=async T=>{try{await j(qe(op,T,t),Ne(T)),v.success("Success! Deleted item.")}catch{v.error("Failed to delete the item.")}},k=async(T,I,B)=>{try{const L=await Be(T,I,t);j(L),Array.isArray(L?.data)&&j(`${sa.replace(/\?.*$/,"")}?id=${B}`,L),v.success("Success! Updated item.")}catch{v.error("Failed to update the item.")}},S=async(T,I)=>{T.preventDefault();const B=new FormData(T.target);await k(ip,B,I),T.target.reset(),d(""),o(!1)},x=async T=>{if(T.preventDefault(),!T.target?.date?.value)v.error("Select required dates"),T.target?.date?.focus(),g("textDanger");else{const I=new FormData(T.target);await D(rp,I),T.target.reset(),g(""),d("")}},f=T=>{o(T)},_=r.useMemo(()=>[{id:"1",name:"To Title",selector:"to_title",sortable:!0},{id:"2",name:"Reference No",selector:"reference_no",sortable:!0},{id:"3",name:"Address",selector:"address",sortable:!0},{id:"4",name:"Note",selector:"note",sortable:!0},{id:"5",name:"From Title",selector:"from_title",sortable:!0},{id:"6",name:"Date",selector:"date",sortable:!0}],[]);return e.jsxs(C,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Postal Dispatch"})}),e.jsx(C,{p:3,children:e.jsx("form",{onSubmit:x,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{required:!0,name:"title",type:"text",label:"To Title *"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"refernce",type:"text",label:"Reference No"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{required:!0,name:"address",type:"text",label:"Address"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{required:!0,name:"from_title",type:"text",label:"From Title"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:te(),Desplay:"Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>g("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx("input",{type:"hidden",name:"image",value:l||"",readOnly:!0})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Postal Dispatch List"})}),e.jsxs(C,{pt:3,children:[e.jsx(wt,{data:{tableRef:h}}),e.jsx(Te,{parentCallback:u,data:{newData:m,columns:_,action:!0,ActionView:p,Loading:w,error:b,editDesign:e.jsx(sp,{data:{handleUpdate:S,token:t}}),deleteTodoMutation:R,open:i,DrawerUpdate:f,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const dp="api/branchapi/frontoffice/postaldispatchreceiveShowdata";function cp({data:t}){const{handleUpdate:a,token:s}=t||{},i=r.useContext(At),o=dp.replace(/\?.*$/,""),{isLoading:l,data:d}=W(s&&i?[o,i,s]:null,([p,A,w])=>Qa(p,{id:A},w)),c=d?.data?.[0],[g,h]=r.useState({from_title:"",refernce:"",address:"",note:"",title:"",date:null,image:""});r.useEffect(()=>{c&&h({from_title:c?.from_title||"",refernce:c?.reference_no||"",address:c?.address||"",note:c?.note||"",title:c?.to_title||"",date:c?.date?te(c.date):null,image:c?.image||""})},[c]);const u=(p,A)=>{h(w=>({...w,[p]:A}))};return l?e.jsx(C,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(C,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:p=>a(p,i),children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Postal Receive"})}),e.jsx(C,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{type:"text",value:i,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"from_title",type:"text",label:"From Title *",required:!0,value:g.from_title,onChange:p=>u("from_title",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"refernce",type:"text",label:"Reference No",required:!0,value:g.refernce,onChange:p=>u("refernce",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"address",type:"text",label:"Address",required:!0,value:g.address,onChange:p=>u("address",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"note",type:"text",label:"Note",value:g.note,onChange:p=>u("note",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"title",type:"text",label:"To Title",required:!0,value:g.title,onChange:p=>u("title",p.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:g.date,Desplay:"Date",id:"date",name:"date",onChange:p=>u("date",p)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const ra="api/branchapi/frontoffice/postalrecivetablelist",up="api/branchapi/frontoffice/addpostalrecive",pp="api/branchapi/frontoffice/editpostalrecive",mp="api/branchapi/frontoffice/deletepostalreceivedispatch";function hp({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(""),[c,g]=r.useState(""),h=r.useRef(null),u=(T,I)=>{s({page:T,rowsPerPage:Number.parseInt(I,10)})},p=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],A=r.useMemo(()=>{const T=ra.includes("?")?ra.endsWith("?")||ra.endsWith("&")?"":"&":"?";return`${ra}${T}page=${a.page}&per_page=${a.rowsPerPage}`},[ra,a.page,a.rowsPerPage]),{isLoading:w,error:b,data:m,mutate:j}=W(t?[A,t]:null,([T,I])=>K(T,I)),D=async(T,I)=>{try{await j(Ee(T,I,t),ze(I)),v.success("Success! Added new item.")}catch{v.error("Failed to add the new item.")}},R=async T=>{try{await j(qe(mp,T,t),Ne(T)),v.success("Success! Deleted item.")}catch{v.error("Failed to delete the item.")}},k=async(T,I,B)=>{try{const L=await Be(T,I,t);j(L),Array.isArray(L?.data)&&j(`${ra.replace(/\?.*$/,"")}?id=${B}`,L),v.success("Success! Updated item.")}catch{v.error("Failed to update the item.")}},S=async(T,I)=>{T.preventDefault();const B=new FormData(T.target);await k(pp,B,I),T.target.reset(),d(""),o(!1)},x=async T=>{if(T.preventDefault(),!T.target?.date?.value)v.error("Select required dates"),T.target?.date?.focus(),g("textDanger");else{const I=new FormData(T.target);await D(up,I),T.target.reset(),g(""),d("")}},f=T=>{o(T)},_=r.useMemo(()=>[{id:"1",name:"From Title",selector:"from_title",sortable:!0},{id:"2",name:"Reference No",selector:"reference_no",sortable:!0},{id:"3",name:"Address",selector:"address",sortable:!0},{id:"4",name:"Note",selector:"note",sortable:!0},{id:"5",name:"To Title",selector:"to_title",sortable:!0},{id:"6",name:"Date",selector:"date",sortable:!0}],[]);return e.jsxs(C,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Postal Receive"})}),e.jsx(C,{p:3,children:e.jsx("form",{onSubmit:x,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{required:!0,name:"from_title",type:"text",label:"From Title *"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{required:!0,name:"refernce",type:"text",label:"Reference No"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{required:!0,name:"address",type:"text",label:"Address"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{required:!0,name:"title",type:"text",label:"To Title"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:te(),Desplay:"Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>g("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx("input",{type:"hidden",name:"image",value:l||"",readOnly:!0})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Postal Receive List"})}),e.jsxs(C,{pt:3,children:[e.jsx(wt,{data:{tableRef:h}}),e.jsx(Te,{parentCallback:u,data:{newData:m,columns:_,action:!0,ActionView:p,Loading:w,error:b,editDesign:e.jsx(cp,{data:{handleUpdate:S,token:t}}),deleteTodoMutation:R,open:i,DrawerUpdate:f,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const fp="api/branchapi/frontoffice/complaintShowdata",yp="api/branchapi/frontoffice/complainttypedropdown",gp=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function xp({data:t}){const{handleUpdate:a,token:s}=t||{},i=r.useContext(At),o=fp.replace(/\?.*$/,""),{isLoading:l,data:d}=W(s&&i?[o,i,s]:null,([m,j,D])=>Qa(m,{id:j},D)),{isLoading:c,data:g}=W(s?[yp,s]:null,([m,j])=>K(m,j)),h=r.useMemo(()=>gp(g).map(j=>({value:j?.value??j?.id??j?.complaint_type??"",label:j?.complaint_type??j?.label??""})),[g]),u=d?.data?.[0],[p,A]=r.useState({complain_type:"",complain_by_name:"",phone:"",date:null,description:"",action_token:"",assigned:"",note:"",file:""});r.useEffect(()=>{u&&A({complain_type:u?.complaint_type??"",complain_by_name:u?.name??"",phone:u?.contact??"",date:u?.date?te(u.date):null,description:u?.description??"",action_token:u?.action_taken??"",assigned:u?.assigned??"",note:u?.note??"",file:u?.image??""})},[u]);const w=(m,j)=>{A(D=>({...D,[m]:j}))},b=r.useMemo(()=>h.find(m=>m.value===p.complain_type)||null,[h,p.complain_type]);return l||c?e.jsx(C,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsx(C,{pt:4,pb:1,style:{width:550},children:e.jsxs("form",{onSubmit:m=>a(m,i),children:[e.jsx("input",{type:"hidden",name:"id",value:i??""}),e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Edit Complaint"})}),e.jsx(C,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Q,{options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Complain Type",name:"complain_type",allowSelectAll:!1,value:b,onChange:m=>w("complain_type",m?.value??"")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"complain_by_name",type:"text",label:"Complain By *",required:!0,value:p.complain_by_name,onChange:m=>w("complain_by_name",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{10}",value:p.phone,onChange:m=>w("phone",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:p.date,Desplay:"Enquiry Date",id:"date",name:"date",onChange:m=>w("date",m)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"description",type:"text",label:"Description",value:p.description,onChange:m=>w("description",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"action_token",type:"text",label:"Action Taken",value:p.action_token,onChange:m=>w("action_token",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"assigned",type:"text",label:"Assigned",value:p.assigned,onChange:m=>w("assigned",m.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"note",type:"text",label:"Note",value:p.note,onChange:m=>w("note",m.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})]})]})})}const ia="api/branchapi/frontoffice/complainttablelist",bp="api/branchapi/frontoffice/complainttypedropdown",jp="api/branchapi/frontoffice/addcomplaint",Sp="api/branchapi/frontoffice/editcomplaint",wp="api/branchapi/frontoffice/deletecomplaint",vp=[{key:"all",label:"All Complaints"},{key:"pending",label:"Pending"},{key:"resolved",label:"Resolved"}];function _p({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(""),[c,g]=r.useState(""),[h,u]=r.useState("all"),p=r.useRef(null),A=(P,O)=>{s({page:P,rowsPerPage:Number.parseInt(O,10)})},w=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],b=r.useMemo(()=>{const P=ia.includes("?")?ia.endsWith("?")||ia.endsWith("&")?"":"&":"?",O=new URLSearchParams;return O.set("page",String(a.page)),O.set("per_page",String(a.rowsPerPage)),h!=="all"&&O.set("status",h),`${ia}${P}${O.toString()}`},[ia,a.page,a.rowsPerPage,h]),{isLoading:m,error:j,data:D,mutate:R}=W(t?[b,t]:null,([P,O])=>K(P,O)),{isLoading:k,data:S}=W(t?[bp,t]:null,([P,O])=>K(P,O)),x=r.useMemo(()=>{const P=S?.data??S??[];return Array.isArray(P)?P:Array.isArray(P?.data)?P.data:[]},[S]),f=async(P,O)=>{try{await R(Ee(P,O,t),ze(O)),v.success("Success! Added new item.")}catch{v.error("Failed to add the new item.")}},_=async P=>{try{await R(qe(wp,P,t),Ne(P)),v.success("Success! Deleted item.")}catch{v.error("Failed to delete the item.")}},T=async(P,O,$)=>{try{const U=await Be(P,O,t);R(U),Array.isArray(U?.data)&&R(`${ia.replace(/\?.*$/,"")}?id=${$}`,U),v.success("Success! Updated item.")}catch{v.error("Failed to update the item.")}},I=async(P,O)=>{P.preventDefault();const $=new FormData(P.target);await T(Sp,$,O),P.target.reset(),d(""),o(!1)},B=async P=>{if(P.preventDefault(),!P.target?.date?.value)v.error("Select required dates"),P.target?.date?.focus(),g("textDanger");else{const O=new FormData(P.target);await f(jp,O),P.target.reset(),g(""),d("")}},L=P=>{o(P)},y=r.useMemo(()=>[{id:"1",name:"Complain Type",selector:"complaint_type",sortable:!0},{id:"2",name:"Name",selector:"name",sortable:!0},{id:"3",name:"Phone",selector:"contact",sortable:!0},{id:"4",name:"Date",selector:"date",sortable:!0},{id:"5",name:"Action Taken",selector:"action_taken",sortable:!0},{id:"6",name:"Assigned",selector:"assigned",sortable:!0}],[]);return e.jsxs(C,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Add Complaint"})}),e.jsx(C,{p:3,children:e.jsx("form",{onSubmit:B,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Q,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Complain Type",name:"complain_type",required:!0,allowSelectAll:!1})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"complain_by_name",type:"text",label:"Complain By *",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"phone",type:"tel",label:"Phone",pattern:"[0-9]{3}[0-9]{3}[0-9]{4}"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:te(),Desplay:"Complain Date",id:"date",name:"date",status:c===""?"":"error",classnme:c,onChange:()=>g("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"description",type:"text",label:"Description"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"action_token",type:"text",label:"Action Taken"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"assigned",type:"text",label:"Assigned"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"note",type:"text",label:"Note"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx("input",{type:"hidden",name:"file",value:l||"",readOnly:!0})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Complaint List"})}),e.jsxs(C,{pt:3,children:[e.jsx(n.Tabs,{activeKey:h,onChange:u,items:vp}),e.jsx(wt,{data:{tableRef:p}}),e.jsx(Te,{parentCallback:A,data:{newData:D,columns:y,action:!0,ActionView:w,Loading:m,error:j,editDesign:e.jsx(xp,{data:{handleUpdate:I,token:t}}),deleteTodoMutation:_,open:i,DrawerUpdate:L,viewDetails:""}})]})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}const Gn="api/branchapi/Frontoffice/purposetablelist",el="api/branchapi/Frontoffice/complaint_typetablelist",tl="api/branchapi/Frontoffice/sourcetablelist",al="api/branchapi/Frontoffice/referencetablelist",pa=[{key:"purpose",label:"Purpose"},{key:"complainType",label:"Complain Type"},{key:"source",label:"Source"},{key:"reference",label:"Reference"}],Xr={purpose:[{id:"1",name:"Purpose",selector:"visitors_purpose",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],complainType:[{id:"1",name:"Complaint Type",selector:"complaint_type",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],source:[{id:"1",name:"Source",selector:"source",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],reference:[{id:"1",name:"Reference",selector:"reference",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}]};function Cp({token:t}){const[a,s]=r.useState("purpose"),[i,o]=r.useState({page:1,rowsPerPage:10}),[l,d]=r.useState(!1),c=r.useRef(null),g=(I,B)=>{o({page:I,rowsPerPage:Number.parseInt(B,10)})},h=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],u=()=>{switch(a){case"purpose":return Gn;case"complainType":return el;case"source":return tl;case"reference":return al;default:return Gn}},p=()=>{switch(a){case"purpose":return"api/branchapi/frontoffice/addvisitors_purpose";case"complainType":return"api/branchapi/frontoffice/addcomplaint_type";case"source":return"api/branchapi/frontoffice/addsource";case"reference":return"api/branchapi/frontoffice/addreference";default:return"api/branchapi/frontoffice/addvisitors_purpose"}},A=I=>{switch(a){case"purpose":return{url:"api/branchapi/frontoffice/deleteVisitorsPurpose",id:I};case"complainType":return{url:"api/branchapi/frontoffice/deletecomplaint_type",id:I};case"source":return{url:"api/branchapi/frontoffice/deletesource",id:I};case"reference":return{url:"api/branchapi/frontoffice/deletereference",id:I};default:return{url:"api/branchapi/frontoffice/deleteVisitorsPurpose",id:I}}},w=r.useMemo(()=>{const I=u(),B=I.includes("?")?I.endsWith("?")||I.endsWith("&")?"":"&":"?";return`${I}${B}page=${i.page}&per_page=${i.rowsPerPage}`},[a,i.page,i.rowsPerPage]),{isLoading:b,error:m,data:j,mutate:D}=W(t?[w,t]:null,([I,B])=>K(I,B)),R=async(I,B)=>{try{await D(Ee(I,B,t),ze(B)),v.success("Success! Added new item.")}catch{v.error("Failed to add the new item.")}},k=async I=>{const{url:B,id:L}=A(I);try{await D(qe(B,L,t),Ne(L)),v.success("Success! Deleted item.")}catch{v.error("Failed to delete the item.")}},S=async(I,B,L)=>{try{const y=await Be(I,B,t);D(y),Array.isArray(y?.data)&&D(`${u().replace(/\?.*$/,"")}?id=${L}`,y),v.success("Success! Updated item.")}catch{v.error("Failed to update the item.")}},x=async(I,B)=>{I.preventDefault();const L=new FormData(I.target),y=p();await S(y,L,B),I.target.reset(),d(!1)},f=async I=>{I.preventDefault();const B=new FormData(I.target),L=p();await R(L,B),I.target.reset()},_=I=>{d(I)},T=r.useMemo(()=>Xr[a]||Xr.purpose,[a]);return e.jsx(C,{pt:5,pb:1,children:e.jsx(n.Row,{gutter:[16,16],children:e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Setup Front Office"})}),e.jsxs(C,{p:3,children:[e.jsx(n.Tabs,{activeKey:a,onChange:I=>{s(I),o({page:1,rowsPerPage:10})},items:pa}),e.jsxs(n.Row,{gutter:[16,16],mt:3,children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx("form",{onSubmit:f,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:["Add ",pa.find(I=>I.key===a)?.label]})}),e.jsx(C,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsx(C,{children:e.jsx(Y,{required:!0,name:"name",type:"text",label:pa.find(I=>I.key===a)?.label+" *"})})}),e.jsx(n.Col,{xs:24,children:e.jsx(C,{children:e.jsx(Y,{name:"description",type:"text",label:"Description"})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Add",color:"primary"})})})})]})})]})})}),e.jsx(n.Col,{xs:24,md:16,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:[pa.find(I=>I.key===a)?.label," List"]})}),e.jsxs(C,{pt:3,children:[e.jsx(wt,{data:{tableRef:c}}),e.jsx(Te,{parentCallback:g,data:{newData:j,columns:T,action:!0,ActionView:h,Loading:b,error:m,editDesign:e.jsx(Ap,{data:{handleUpdate:x,token:t,activeTab:a}}),deleteTodoMutation:k,open:l,DrawerUpdate:_,viewDetails:""}})]})]})})]})]})]})})})})}function Ap({data:t}){const{handleUpdate:a,token:s,activeTab:i}=t||{},o=r.useContext(At),d=(w=>{switch(w){case"purpose":return Gn;case"complainType":return el;case"source":return tl;case"reference":return al;default:return Gn}})(i).replace(/\?.*$/,""),{isLoading:c,data:g}=W(s&&o?[d,o,s]:null,([w,b,m])=>getDataById(w,{id:b},m)),h=g?.data?.[0],[u,p]=r.useState({name:"",description:""});r.useEffect(()=>{h&&p({name:h?.visitors_purpose||h?.complaint_type||h?.source||h?.reference||"",description:h?.description||""})},[h]);const A=(w,b)=>{p(m=>({...m,[w]:b}))};return c?e.jsx(C,{pt:4,pb:1,style:{width:350},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(C,{pt:4,pb:1,style:{width:350},children:[e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsxs(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:["Edit ",pa.find(w=>w.key===i)?.label]})}),e.jsx(C,{p:3,children:e.jsx("form",{onSubmit:w=>a(w,o),children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsx(C,{children:e.jsx(Y,{type:"text",value:o,name:"id",required:!0,className:"noDisplay",onChange:()=>{}})})}),e.jsx(n.Col,{xs:24,children:e.jsx(C,{children:e.jsx(Y,{name:"name",type:"text",label:pa.find(w=>w.key===i)?.label+" *",required:!0,value:u.name,onChange:w=>A("name",w.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(C,{children:e.jsx(Y,{name:"description",type:"text",label:"Description",value:u.description,onChange:w=>A("description",w.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})]})})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const Dp="api/branchapi/Student/studentGatePass",Da="api/branchapi/Student/studentGatePassList";function Tp({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:25}),[i,o]=r.useState(!1),l=r.useRef(null),d=(k,S)=>{s({page:k,rowsPerPage:Number.parseInt(S,10)})},c=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],{data:g,mutate:h}=W(t?[Dp,t]:null,([k,S])=>K(k,S)),u=r.useMemo(()=>{const k=Da.includes("?")?Da.endsWith("?")||Da.endsWith("&")?"":"&":"?";return`${Da}${k}page=${a.page}&per_page=${a.rowsPerPage}`},[Da,a.page,a.rowsPerPage]),{isLoading:p,error:A,data:w,mutate:b}=W(t?[u,t]:null,([k,S])=>K(k,S)),m=async k=>{const S="api/branchapi/frontoffice/deletevisitors";try{await b(deleteData(S,k,t),Ne(k)),v.success("Success! Deleted item.")}catch{v.error("Failed to delete the item.")}},j=k=>{o(k)},D=()=>{},R=[{title:"Name",dataIndex:"lastname",key:"lastname",render:(k,S)=>`${S?.lastname||""} ${S?.firstname||""}`.trim()},{title:"Class",dataIndex:"class_name",key:"class_name",render:(k,S)=>`${S?.class_name||""}-${S?.section_name||""}`},{title:"Father Name",dataIndex:"father_name",key:"father_name"},{title:"Authorized Persons",dataIndex:"authorized_persons_fullname",key:"authorized_persons_fullname"},{title:"Relation",dataIndex:"authorized_persons_relation",key:"authorized_persons_relation"},{title:"Generated Date",dataIndex:"genrated_date_time",key:"genrated_date_time"},{title:"Return Date",dataIndex:"expected_return_date_time",key:"expected_return_date_time"},{title:"Reason",dataIndex:"reason",key:"reason"},{title:"Action",key:"action",render:(k,S)=>e.jsx(n.Tag,{color:S?.status==="Generated"?"green":"blue",children:S?.status||"Pending"})},{title:"Print",key:"print",render:(k,S)=>e.jsx(ee.PrinterOutlined,{style:{color:"#3892ee",cursor:"pointer"},onClick:()=>window.print()})}];return e.jsx(C,{pt:5,pb:1,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Today Gate Pass"})}),e.jsx(C,{pt:3,children:e.jsx(n.List,{grid:{column:4,gutter:16},dataSource:g?.data||[],style:{padding:0},renderItem:k=>e.jsx(n.List.Item,{style:{padding:0},children:e.jsx(n.Card,{size:"small",style:{marginBottom:8,width:"100%"},children:e.jsxs(C,{children:[e.jsxs(n.Typography.Text,{strong:!0,children:[k?.lastname," ",k?.firstname]}),e.jsx("br",{}),e.jsxs(n.Typography.Text,{type:"secondary",children:[k?.class_name,"-",k?.section_name]}),e.jsx("br",{}),e.jsxs(n.Typography.Text,{type:"secondary",children:["Return: ",k?.expected_return_date_time]}),e.jsx("br",{}),e.jsx(ne,{type:"button",value:"Print",color:"primary",size:"small",onClick:()=>window.print(),style:{marginTop:4}})]})})})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"Gate Pass List"})}),e.jsxs(C,{pt:3,children:[e.jsx(wt,{data:{tableRef:l}}),e.jsx(Te,{parentCallback:d,data:{newData:w,columns:R,action:!1,ActionView:c,Loading:p,error:A,editDesign:"",deleteTodoMutation:m,open:i,DrawerUpdate:j,viewDetails:D}})]})]})})]})})}const mt=({id:t,funcName:a,disabled:s=!1})=>{const i="Data",[o,l]=r.useState(!1),d=()=>{l(!0),a(t),n.message.success(`${i} deleted successfully!`)},c=()=>{n.message.info(`Deletion of ${i} cancelled`)};return e.jsx(n.Popconfirm,{title:`Delete ${i}?`,description:`Are you sure you want to delete ${i}?`,onConfirm:d,onCancel:c,okText:"Yes",cancelText:"No",disabled:s||o,children:e.jsx(n.Button,{danger:!0,disabled:s,loading:o,icon:e.jsx(ee.DeleteOutlined,{}),size:"small"})})},Zr={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Rp({token:t,sampleTemplateUrl:a=vc}){const[s,i]=r.useState({pagination:{current:1,pageSize:10}}),[o,l]=r.useState(!1),[d,c]=r.useState(null),[g,h]=r.useState(null),[u,p]=r.useState(!1),[A,w]=r.useState([]),b=`api/branchapi/Transport/routeTableList?page=${s.pagination.current}&per_page=${s.pagination.pageSize}`,m="api/branchapi/Transport/addroute",j="api/branchapi/Transport/editroute",D="api/branchapi/Transport/deleteroute",R=void 0,{isLoading:k,data:S,error:x,mutate:f}=W(t?[b,t]:null,([z,E])=>K(z,E)),_=r.useMemo(()=>!S?.data||Array.isArray(S.data)?[]:S.data?.rows||[],[S]),T=S?.data?.pagination?.total_rows||S?.pagination?.total_rows||0,I=async(z,E)=>{try{await f(Ee(z,E,t),ze(E)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{v.error("Failed to add the new item.",{duration:1e3})}},B=z=>{z.preventDefault();const E=new FormData(z.target);I(m,E),z.target.reset()},L=(z,E)=>{i(M=>({...M,pagination:{current:z,pageSize:parseInt(E,10)}}))},y=async z=>{try{await f(qe(D,z,t),Ne(z)),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}},P=z=>{c(z),l(!0)},O=async z=>{try{const E=await Be(j,z,t);f(E),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),l(!1),c(null)}catch{v.error("Failed to update the item.",{duration:1e3})}},$=async z=>{z.preventDefault();const E=new FormData(z.target);E.append("id",d?.id),O(E)},U=async()=>{if(!g){v.error("Please select an Excel file to upload.",{duration:1e3});return}p(!0),w([]);try{const z=new FormData;z.append("file",g);const M=await(await fetch(`${R}`,{method:"POST",headers:{Authorization:t},body:z})).json();if(M.Status==="Success"){const F=M.data?.rows||[];w(F);const q=M.data?.success_count||0,H=M.data?.failed_count||0;v.success(M.message||`Route bulk upload completed. ${q} succeeded, ${H} failed.`,{duration:1e3}),q>0&&f()}else v.error(M.message||"Failed to upload routes.",{duration:1e3})}catch(z){v.error(z?.message||"Something went wrong.",{duration:1e3})}finally{p(!1),h(null)}},N=[{title:"Route Title",dataIndex:"route_title",key:"route_title",sorter:{compare:(z,E)=>(z.route_title||"").localeCompare(E.route_title||"")}},{title:"Fare (Monthly)",dataIndex:"fare",key:"fare",sorter:{compare:(z,E)=>Number(z.fare||0)-Number(E.fare||0)}},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(z,E)=>(z.note||"").localeCompare(E.note||"")}},{title:"Action",key:"action",render:(z,E)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>P(E),style:{padding:2}}),e.jsx(mt,{id:E?.id,funcName:y})]})}],V=d?.route_title?`Edit ${d.route_title}`:"Edit Route";return e.jsxs(C,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Bulk Upload Routes"})}),e.jsxs(C,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(n.Upload,{accept:".xlsx",showUploadList:!1,beforeUpload:z=>(h(z),!1),children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),disabled:u,children:g?g.name:"Choose Excel File (.xlsx)"})})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(n.Button,{type:"primary",onClick:U,disabled:u||!g,loading:u,children:u?"Uploading...":"Upload Routes"})})})]}),A.length>0&&e.jsxs(C,{mt:3,children:[e.jsx(ge,{level:5,children:"Upload Results"}),e.jsx(n.Table,{dataSource:A.map((z,E)=>({...z,key:E})),pagination:!1,size:"small",bordered:!0,columns:[{title:"Row",dataIndex:"row",width:80},{title:"Title",dataIndex:"title"},{title:"Status",dataIndex:"status",render:z=>e.jsx("span",{style:{color:z==="Success"?"green":"red",fontWeight:500},children:z})},{title:"Message",dataIndex:"message"}]})]}),a&&e.jsx(C,{mt:2,children:e.jsx("a",{href:a,download:!0,style:{color:"#5080f8",fontSize:13,textDecoration:"none"},children:"Download sample Excel template"})})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Add Route"})}),e.jsx(C,{p:3,children:e.jsx("form",{onSubmit:B,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx(C,{children:e.jsx(Y,{type:"text",name:"title",label:"Title",placeholder:"Mumbai to Delhi",required:"required"})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(C,{children:e.jsx(Y,{type:"number",name:"fare",label:"Fare (Monthly)",required:"required"})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(C,{children:e.jsx(Y,{type:"text",name:"note",label:"Note"})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(C,{children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",style:Zr,children:"Cancel"})]})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Route List"})}),e.jsx(C,{p:3,children:e.jsx(Te,{parentCallback:L,data:{newData:{data:_,pagination:{total_rows:T}},columns:N,columnstype:"antd",action:!1,Loading:k,error:x,deleteTodoMutation:y}})})]})})]}),e.jsx(n.Drawer,{open:o,title:V,placement:"right",width:420,onClose:()=>{l(!1),c(null)},children:e.jsx("form",{onSubmit:$,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"title",label:"Title",defaultValue:d?.route_title||"",required:"required"}),e.jsx(Y,{type:"number",name:"fare",label:"Fare (Monthly)",defaultValue:d?.fare||"",required:"required"}),e.jsx(Y,{type:"text",name:"note",label:"Note",defaultValue:d?.note||""}),e.jsx("div",{style:{display:"none"},children:e.jsx(Y,{type:"text",name:"no_of_vehicle",label:"Note"})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{l(!1),c(null)},style:Zr,children:"Cancel"})]})]})})})]})}const ei={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Ip({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(null),c=`api/branchapi/Transport/vehiclesTableList?page=${a.page}&per_page=${a.rowsPerPage}`,g="api/branchapi/Transport/addvehicles",h="api/branchapi/Transport/editvehicle",u="api/branchapi/Transport/deletevehicle",{isLoading:p,data:A,error:w,mutate:b}=W(t?[c,t]:null,([T,I])=>K(T,I)),m=async(T,I)=>{try{await b(Ee(T,I,t),ze(I)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{v.error("Failed to add the new item.",{duration:1e3})}},j=T=>{T.preventDefault();const I=new FormData(T.target);m(g,I),T.target.reset()},D=async T=>{try{await b(qe(u,T,t),Ne(T)),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}},R=T=>{d(T),o(!0)},k=async T=>{try{await Be(h,T,t),await b(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch{v.error("Failed to update the item.",{duration:1e3})}},S=async T=>{T.preventDefault();const I=new FormData(T.target);I.append("id",l?.id),k(I)},x=(T,I)=>{s({page:T,rowsPerPage:parseInt(I,10)})},f=[{title:"Vehicle Number",dataIndex:"vehicle_no",key:"vehicle_no",sorter:{compare:(T,I)=>T.vehicle_no.localeCompare(I.vehicle_no)}},{title:"Vehicle Model",dataIndex:"vehicle_model",key:"vehicle_model",sorter:{compare:(T,I)=>T.vehicle_model.localeCompare(I.vehicle_model)}},{title:"Max Seating Capacity",dataIndex:"seating_capacity",key:"seating_capacity",sorter:{compare:(T,I)=>T.seating_capacity-I.seating_capacity}},{title:"Manufacture Year",dataIndex:"manufacture_year",key:"manufacture_year",sorter:{compare:(T,I)=>T.manufacture_year-I.manufacture_year}},{title:"Gps Url",key:"gps_url",sorter:{compare:(T,I)=>T.gps_url.localeCompare(I.gps_url)},render:(T,I)=>e.jsx("span",{title:I?.gps_url??"",style:{display:"inline-block",maxWidth:220,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:I?.gps_url})},{title:"Note",dataIndex:"note",key:"note",sorter:{compare:(T,I)=>T.note.localeCompare(I.note)}},{title:"Action",key:"action",render:(T,I)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>R(I),style:{padding:2}}),e.jsx(mt,{id:I?.id,funcName:D})]})}],_=l?.vehicle_no?`Edit ${l.vehicle_no}`:"Edit Vehicle";return e.jsxs("div",{children:[e.jsx(n.Drawer,{open:i,title:_,placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:S,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"number",label:"Vehicle Number",defaultValue:l?.vehicle_no||"",required:"required"}),e.jsx(Y,{type:"text",name:"model",label:"Vehicle Model",defaultValue:l?.vehicle_model||""}),e.jsx(Y,{type:"number",name:"manufacture_year",label:"Manufacture Year",defaultValue:l?.manufacture_year||""}),e.jsx(Y,{type:"number",name:"seating_capacity",label:"Max Seating Capacity",defaultValue:l?.seating_capacity||""}),e.jsx(Y,{type:"text",name:"gps_url",label:"Gps Url",defaultValue:l?.gps_url||""}),e.jsx(Y,{type:"text",name:"note",label:"Note",defaultValue:l?.note||""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:ei,children:"Cancel"})]})]})})}),e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(C,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Add Vehicle"})}),e.jsx(C,{px:3,pb:2,children:e.jsx("form",{onSubmit:j,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"number",label:"Vehicle Number",required:"required"}),e.jsx(Y,{type:"text",name:"model",label:"Vehicle Model"}),e.jsx(Y,{type:"number",name:"manufacture_year",label:"Manufacture Year"}),e.jsx(Y,{type:"number",name:"seating_capacity",label:"Max Seating Capacity"}),e.jsx(Y,{type:"text",name:"gps_url",label:"Gps Url"}),e.jsx(Y,{type:"text",name:"note",label:"Note"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",style:ei,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(C,{children:e.jsx(Te,{parentCallback:x,data:{newData:A,columns:f,columnstype:"antd",action:!1,Loading:p,error:w,deleteTodoMutation:D}})})]})})]})})]})}const kp={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},ti=({dataIndex:t,title:a,record:s,children:i,isEditable:o,...l})=>e.jsx("td",{...l,children:o?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:i}):i});function Pp({token:t}){const[a,s]=r.useState(!1),[i,o]=r.useState({pagination:{current:1,pageSize:50}}),[l,d]=r.useState(null),[c,g]=r.useState([]),h="api/branchapi/Transport/getrouteDropdown",u="api/branchapi/Transport/getvehicleDropdown",p="api/branchapi/Transport/getchechkedVehicleData",A="api/branchapi/Transport/assignedVehicleTable",w="api/branchapi/transport/assignvehicle",b="api/branchapi/Transport/deleteassignvehicle",m=l?`${p}?route_id=${l}`:null,{isLoading:j,data:D,mutate:R}=W(t?[`${A}?page=${i.pagination.current}&per_page=${i.pagination.pageSize}`,t]:null,([M,F])=>K(M,F)),{data:k}=W(t&&h?[h,t]:null,([M,F])=>K(M,F)),{data:S}=W(t&&u?[u,t]:null,([M,F])=>K(M,F)),x=t&&m?[m,t]:null,{isLoading:f,data:_}=W(x,([M,F])=>K(M,F)),{Status:T="Failed",pagination:{total_rows:I=0}={}}=D||{},{data:B=[]}=T==="Success"?D:{},L=r.useMemo(()=>{const M=k?.data??k??[];return Array.isArray(M)?M:[]},[k]),y=r.useMemo(()=>{const M=S?.data??S??[];return(Array.isArray(M)?M:[]).map(q=>{if(q==null)return null;if(typeof q=="string"||typeof q=="number")return{label:String(q),value:q};const H=q.value??q.vehicle_id??q.id??q.vehicleID,re=q.label??q.vehicle_name??q.vehicle_no??q.vehicle_number??q.name??String(H??"");return H==null||re===""?null:{label:String(re),value:H}}).filter(Boolean)},[S]),P=r.useMemo(()=>{const M=_?.data??_??[];return(Array.isArray(M)?M:[]).map(q=>q?.value??q?.vehicle_id??q?.id??q).filter(q=>q!=null)},[_]);r.useEffect(()=>{g(P)},[P,a]);const O=async(M,F,q)=>{try{await R(Ee(M,F,t),ze(F)),m&&W.mutate(x),s(H=>!H),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(H){v.error(H?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},$=M=>{M.preventDefault();const F=new FormData;F.append("route_id",l??""),c.length?c.forEach(q=>F.append("vehicle_ids[]",q)):F.append("vehicle_ids[]",""),O(w,F)},U=M=>{o(F=>({...F,pagination:{current:M,pageSize:F.pagination.pageSize}}))},N=async M=>{try{await R(qe(b,M,t),Ne(M)),m&&W.mutate(x),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}},V=[{title:"Route",dataIndex:"route_title"},{title:"Vehicle Numbers",render:(M,F,q)=>e.jsx(e.Fragment,{children:F.children.map((H,re,G)=>e.jsx("span",{children:`${H.vehicle_name} ${re+1===G.length?"":","}`},`${re}vehicle001`))})},{title:"Action",render:(M,F,q)=>e.jsx(e.Fragment,{children:e.jsx(mt,{id:F?.route_id,funcName:N})})}],z=M=>{const F=["route_id","index"];for(let q=0;q<F.length;q++)if(M[F[q]])return M[F[q]]},E=M=>{const{children:F=[]}=M||{},q=[{title:"Vehicle Name",dataIndex:"vehicle_name",onCell:H=>({isEditable:!0})},{title:"Driver Name",dataIndex:"driver_name",onCell:H=>({isEditable:!0})},{title:"Driver Contact",dataIndex:"driver_contact_number",onCell:H=>({isEditable:!0})},{title:"Driver Licence",dataIndex:"Driver_licence",onCell:H=>({isEditable:!0})},{title:"Start Time",dataIndex:"start_time",onCell:H=>({isEditable:!0})},{title:"Drop Time",dataIndex:"drop_time",onCell:H=>({isEditable:!0})},{title:"Type",dataIndex:"type",onCell:H=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(n.Table,{components:{body:{cell:ti}},expandable:{childrenColumnName:"changed"},bordered:!0,size:"small",columns:q,rowKey:H=>z(H)+"cell01",dataSource:F,pagination:!1})})})};return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(C,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Assign Vehicle"})}),e.jsx(C,{px:3,pb:2,children:e.jsx("form",{onSubmit:$,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(220px, 320px) 1fr auto",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(Q,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,onChange:M=>{d(M?.value??null),s(F=>!F)}})}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:{display:"block",marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Vehicles"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:8,maxHeight:140,overflow:"auto"},children:e.jsx(n.Checkbox.Group,{style:{display:"flex",flexWrap:"wrap",gap:12},options:y,value:c,onChange:M=>g(M),disabled:!l||f})},`check001${a}`)]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"button",onClick:()=>{d(null),g([]),s(M=>!M)},style:kp,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Vehicle List"})}),e.jsx(C,{style:{padding:"10px 16px"},children:e.jsx(n.Table,{components:{body:{cell:ti}},columns:V,bordered:!0,rowKey:M=>z(M),dataSource:Array.isArray(B)?B:[],loading:j,expandable:{expandedRowRender:E,childrenColumnName:"changed"},pagination:{current:i.pagination.current,pageSize:i.pagination.pageSize,total:I,showSizeChanger:!0,onChange:U,onShowSizeChange:(M,F)=>{o(q=>({...q,pagination:{current:1,pageSize:F}}))},showTotal:(M,F)=>`${F[0]}-${F[1]} of ${M} items`}})})]})})]})})]})}const ai={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Cs=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},oa=(t,a,s)=>{if(a==null||a==="")return null;const i=t.find(o=>String(o.value)===String(a));return i||(s?{label:String(s),value:a}:{label:String(a),value:a})},Op=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},Mp=t=>{if(t==null||t===""||t==="null"||t==="undefined")return"";if(Array.isArray(t))return t.filter(s=>s!=null&&s!==""&&String(s).toLowerCase()!=="null"&&String(s).toLowerCase()!=="undefined").join(", ");const a=String(t).trim();return!a||a.toLowerCase()==="null"||a.toLowerCase()==="undefined"?"":a};function Ep({token:t,assignmentId:a,studentName:s,onClose:i,onSuccess:o}){const l="api/branchapi/Transport/showRouteAssignStudent",d="api/branchapi/Transport/updateTransportRoutesStudent",c="api/branchapi/Transport/getrouteDropdown",g="api/branchapi/Transport/getvehicleListByRouteIdwithCount",h="api/branchapi/Transport/getStoppageDropdown",u="api/branchapi/Transport/routeShowdata",[p,A]=r.useState(null),[w,b]=r.useState(null),[m,j]=r.useState(null),[D,R]=r.useState(te()),[k,S]=r.useState(""),[x,f]=r.useState(0),[_,T]=r.useState(0),{data:I,isLoading:B}=W(t&&a?[`${l}?id=${a}`,t]:null,([X,ce])=>K(X,ce)),L=r.useMemo(()=>{if(!I||I?.Status&&I.Status!=="Success")return null;const X=I?.data??I;return Array.isArray(X)?X[0]??null:X},[I]);r.useEffect(()=>{const X=L?.fk_route_id??L?.route_id;X!=null&&A(X),L?.vehicle_id!=null&&b(L.vehicle_id),L?.stop_id!=null&&j(L.stop_id),R(L?.start_date?te(L.start_date):te()),S(Mp(L?.service_push))},[L]);const y=t&&p?`${g}?route_id=${p}`:null,P=t&&p?`${u}?id=${p}`:null,O=t&&p?`${h}?route_id=${p}`:null,{data:$}=W(t&&c?[c,t]:null,([X,ce])=>K(X,ce)),{data:U,isLoading:N}=W(y?[y,t]:null,([X,ce])=>K(X,ce)),{data:V,isLoading:z}=W(O?[O,t]:null,([X,ce])=>K(X,ce)),{data:E}=W(P?[P,t]:null,([X,ce])=>K(X,ce)),M=r.useMemo(()=>Cs($),[$]),F=r.useMemo(()=>Cs(U),[U]),q=r.useMemo(()=>Cs(V),[V]),H=I?.data[0]?.rootCost,re=Op(),G=s||[L?.firstname,L?.lastname].filter(Boolean).join(" ")||"",J=(X,ce)=>{switch(ce){case"route_id":A(X?.value??null),b(null),j(null),f(Re=>Re+1),T(Re=>Re+1);break;case"vehicle_id":b(X?.value??null),j(null),T(Re=>Re+1);break;case"stop_id":j(X?.value??null);break}},ae=async X=>{if(X.preventDefault(),!p||!w||!m){v.error("Please select Route, Vehicle and Stop",{duration:1200});return}const ce=new FormData;ce.append("id",String(a)),ce.append("student_id",String(L?.fk_student_id??L?.student_id??"")),ce.append("fk_route_id",String(p)),ce.append("vehicle_id",String(w)),ce.append("stop_id",String(m)),ce.append("rootCost",String(H??"")),ce.append("start_date",D?.isValid?.()?D.format("YYYY-MM-DD"):te().format("YYYY-MM-DD")),ce.append("puse_service",String(k??""));try{await Be(d,ce,t),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o?.(),i?.()}catch(Re){v.error(Re?.message??"Failed to update the item.",{duration:1e3})}};if(B||!(L&&!B&&(!p||!N&&!z)))return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:48},children:e.jsx(n.Spin,{})});if(!L)return e.jsxs("div",{style:{padding:"8px 0"},children:[e.jsx("p",{style:{color:"#666",fontSize:14,marginBottom:16},children:"Unable to load assignment details. Please try again."}),e.jsx(n.Button,{type:"text",onClick:i,style:ai,children:"Close"})]});const pe=L.fk_route_id??L.route_id,_e=oa(M,pe,L.route_title),le=oa(F,L.vehicle_id,L.vehicle_name??L.vehicle_no),de=oa(q,L.stop_id,L.stop_name??L.stoppage_name);return e.jsx("form",{onSubmit:ae,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"title",label:"Student",defaultValue:G,readOnly:!0}),e.jsx("input",{type:"hidden",name:"student_id",value:L.fk_student_id??L.student_id??""}),e.jsx(Q,{options:M,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:oa(M,p,_e?.label)??null,onChange:X=>J(X,"route_id")}),e.jsx(Q,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:oa(F,w,le?.label)??null,onChange:X=>J(X,"vehicle_id")},`edit-vehicle-${x}`),e.jsx(Q,{options:q,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:oa(q,m,de?.label)??null,onChange:X=>J(X,"stop_id")},`edit-stop-${_}`),e.jsx(Y,{type:"text",label:"Route Cost",value:H!=null?`${re}${H}`:"",readOnly:!0}),e.jsx("input",{type:"hidden",name:"rootCost",value:H??""}),e.jsx(Me,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",allowClear:!1,value:D,onChange:X=>R(X)}),e.jsx(Y,{type:"text",label:"Pause Service",value:k,onChange:X=>S(X?.target?.value??""),placeholder:"e.g. 01, 02, 03"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginTop:4},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:i,style:ai,children:"Cancel"})]})]})},`edit-${a}-${x}`)}const ni={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Fp=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},Ta=t=>Fp(t),Up=t=>t||"",$p=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")||"{}")?.currency_symbol??""}catch{return""}},Np=t=>{const a=String(t??"Drawer").trim().toLowerCase().replace(/\s+/g,"");return a==="page"||a==="sendpage"?"page":"drawer"},Lp=(t,a)=>{const s=a||"/TransportDashboard/EditAssignStudentTransport?id={id}",i=t?.id??"",o=encodeURIComponent(String(i));if(s.includes("{id}"))return s.replaceAll("{id}",o);if(s.includes(":id"))return s.replace(":id",o);try{const d=new URL(s,"http://localhost");if(d.searchParams.has("id"))return d.searchParams.set("id",String(i)),`${d.pathname}${d.search}${d.hash}`}catch{}const l=s.includes("?")?"&":"?";return`${s}${l}id=${o}`};function Bp({token:t,editType:a,onNavigate:s,editPagePath:i,sampleTemplateUrl:o=_c}){const d=Np(a)==="drawer",c="api/branchapi/academy/classdropdownlist",g="api/branchapi/academy/sectionoftheClass",h="api/branchapi/Transport/routeStudentList",u="api/branchapi/Transport/getrouteDropdown",p="api/branchapi/Transport/getvehicleListByRouteIdwithCount",A="api/branchapi/Transport/getStoppageDropdown",w="api/branchapi/Transport/routeShowdata",b="api/branchapi/Transport/assignTransportRoutesStudent",m="api/branchapi/transport/removeStudentTransport",j="api/branchapi/transport/assignTransportRoutesStudentBulk",[D,R]=r.useState(null),[k,S]=r.useState(!1),[x,f]=r.useState(!1),[_,T]=r.useState(null),[I,B]=r.useState(null),[L,y]=r.useState(null),[P,O]=r.useState(null),[$,U]=r.useState(!1),[N,V]=r.useState(!1),[z,E]=r.useState({page:1,rowsPerPage:50}),[M,F]=r.useState(null),[q,H]=r.useState(!1),[re,G]=r.useState(null),[J,ae]=r.useState(null),[oe,pe]=r.useState(null),[_e,le]=r.useState(null),[de,X]=r.useState(null),[ce,Re]=r.useState(null),[Ue,ke]=r.useState(null),[Ve,Le]=r.useState(te()),[at,Ge]=r.useState(""),[Fe,Je]=r.useState(null),[it,fe]=r.useState(!1),[Se,je]=r.useState([]),se=(be,Ce)=>{const Xe=be?.value??null;switch(Ce){case"class_id":pe(Xe),le(null),F(Xe?`${g}?class_id=${encodeURIComponent(String(Xe))}`:null),S(It=>!It);break;case"route_id":X(Xe),Re(null),ke(null),ae(Xe),B(Xe?`${p}?route_id=${encodeURIComponent(String(Xe))}`:null),y(Xe?`${w}?id=${encodeURIComponent(String(Xe))}`:null),O(null),U(It=>!It),V(It=>!It);break;case"vehicle_id":Re(Xe),ke(null),O(de?`${A}?route_id=${encodeURIComponent(String(de))}`:null),V(It=>!It);break;case"stop_id":ke(Xe);break}},me=be=>{if(d){T(be),f(!0);return}const Ce=Lp(be,i);if(typeof s=="function"){s(Ce,be);return}typeof window<"u"&&Ce&&window.location.assign(Ce)},xe=()=>{f(!1),T(null)},ie=_?`Edit — ${_.firstname??""} ${_.lastname??""}`.trim():"Edit Student Transport",{data:ye}=W(t&&c?[c,t]:null,([be,Ce])=>K(be,Ce)),{data:Ye}=W(t&&M?[M,t]:null,([be,Ce])=>K(be,Ce)),{data:vt}=W(t&&I?[I,t]:null,([be,Ce])=>K(be,Ce)),{data:Dt}=W(t&&P?[P,t]:null,([be,Ce])=>K(be,Ce)),{data:xt}=W(t&&L?[L,t]:null,([be,Ce])=>K(be,Ce)),{data:Et}=W(t&&u?[u,t]:null,([be,Ce])=>K(be,Ce)),Zt=t&&D?`${D}&page=${z.page}&per_page=${z.rowsPerPage}`:null,{isLoading:he,error:ve,data:lt,mutate:bt}=W(Zt?[Zt,t]:null,([be,Ce])=>K(be,Ce)),on=r.useMemo(()=>Ta(ye),[ye]),ln=r.useMemo(()=>Ta(Ye),[Ye]),dn=r.useMemo(()=>Ta(vt),[vt]),cn=r.useMemo(()=>Ta(Dt),[Dt]),un=r.useMemo(()=>Ta(Et),[Et]),ue=xt?.data?.[0]?.fare??xt?.data?.fare??xt?.fare??xt?.data?.data?.[0]?.fare??xt?.data?.data?.fare;r.useEffect(()=>{ue==null||ue===""||Ge(String(ue))},[ue]);const we=async be=>{try{await bt(qe(m,be,t),Ne(be)),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}},$e=async()=>{if(!Fe){v.error("Please select an Excel file to upload.",{duration:1e3});return}fe(!0),je([]);try{const be=new FormData;be.append("file",Fe);const Xe=await(await fetch(`${j}`,{method:"POST",headers:{Authorization:t},body:be})).json();if(Xe.Status==="Success"){const It=Xe.data?.rows||[];je(It);const fr=Xe.data?.success_count||0,wl=Xe.data?.failed_count||0;v.success(Xe.message||`Transport bulk upload completed. ${fr} succeeded, ${wl} failed.`,{duration:1e3}),fr>0&&bt()}else v.error(Xe.message||"Failed to upload student transport assignments.",{duration:1e3})}catch(be){v.error(be?.message||"Something went wrong.",{duration:1e3})}finally{fe(!1),Je(null)}},Qe=[{title:"Route Status",key:"route_status",render:(be,Ce)=>Ce.fk_route_id?e.jsx("span",{children:Ce.route_title}):e.jsx("span",{children:"Not Assigned"})},{title:"Vehicle Assign Date",dataIndex:"start_date",key:"start_date",render:(be,Ce)=>Up(Ce.start_date)},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Roll No",dataIndex:"roll_no",key:"roll_no"},{title:"Name",key:"name",render:(be,Ce)=>`${Ce.firstname} ${Ce.lastname}`},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Mobileno",dataIndex:"mobileno",key:"mobileno"},{title:"Action",key:"action",render:(be,Ce)=>e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:Ce.fk_route_id?e.jsxs(e.Fragment,{children:[e.jsx(mt,{id:Ce?.id,funcName:we}),e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>me(Ce),style:{padding:2}})]}):e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.PlusOutlined,{}),onClick:()=>us(Ce.student_id),style:{padding:2}})})}],ot=async(be,Ce)=>{try{await bt(Ee(be,Ce,t),ze(Ce)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),H(!1),ps()}catch{v.error("Failed to add the new item.",{duration:1e3})}},ht=be=>{if(be.preventDefault(),!oe||!_e){v.error("Please select Class and Section",{duration:1200});return}R(`${h}?cID=${encodeURIComponent(String(oe))}&sID=${encodeURIComponent(String(_e))}`),E(Ce=>({...Ce,page:1}))},cs=(be,Ce)=>{E({page:be,rowsPerPage:parseInt(Ce,10)})},us=be=>{G(be),H(!0)},wa=be=>{if(be.preventDefault(),!re){v.error("Student is required",{duration:1200});return}if(!de||!ce||!Ue){v.error("Please select Route, Vehicle and Stop",{duration:1300});return}const Ce=new FormData;Ce.append("student_id",String(re)),Ce.append("fk_route_id",String(de)),Ce.append("vehicle_id",String(ce)),Ce.append("stop_id",String(Ue)),Ce.append("start_date",Ve?.isValid?.()?Ve.format("YYYY-MM-DD"):te().format("YYYY-MM-DD")),Ce.append("rootCost",String(at??"")),ot(b,Ce)},ps=()=>{H(!1),B(null),y(null),O(null),ae(null),X(null),Re(null),ke(null),Le(te()),Ge(""),U(be=>!be),V(be=>!be)},Sl=$p();return e.jsxs(C,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Bulk Assign Students to Transport"})}),e.jsxs(C,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(n.Upload,{accept:".xlsx",showUploadList:!1,beforeUpload:be=>(Je(be),!1),children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),disabled:it,children:Fe?Fe.name:"Choose Excel File (.xlsx)"})})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(n.Button,{type:"primary",onClick:$e,disabled:it||!Fe,loading:it,children:it?"Uploading...":"Upload Students"})})})]}),o&&e.jsx(C,{mt:2,children:e.jsx("a",{href:o,download:!0,style:{color:"#5080f8",fontSize:13,textDecoration:"none"},children:"Download sample Excel template"})}),Se.length>0&&e.jsxs(C,{mt:3,children:[e.jsx(ge,{level:5,children:"Upload Results"}),e.jsx(n.Table,{dataSource:Se.map((be,Ce)=>({...be,key:Ce})),pagination:!1,size:"small",bordered:!0,columns:[{title:"Row",dataIndex:"row",width:80},{title:"Student ID",dataIndex:"student_id"},{title:"Status",dataIndex:"status",render:be=>e.jsx("span",{style:{color:be==="Success"?"green":"red",fontWeight:500},children:be})},{title:"Message",dataIndex:"message"}]})]})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Search Students"})}),e.jsx(C,{p:3,children:e.jsx("form",{onSubmit:ht,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx(C,{children:e.jsx(Q,{options:on,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",onChange:be=>se(be,"class_id"),required:!0,allowSelectAll:!1,value:on.find(be=>String(be.value)===String(oe))??null})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(C,{children:e.jsx(Q,{options:ln,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",allowSelectAll:!1,required:!0,value:ln.find(be=>String(be.value)===String(_e))??null,onChange:be=>le(be?.value??null)},`section1${k}`)})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsxs(C,{display:"flex",alignItems:"center",height:"100%",mt:2,children:[e.jsx(ne,{type:"submit",value:"Search",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"button",onClick:()=>{R(null),F(null),pe(null),le(null),S(be=>!be)},style:ni,children:"Cancel"})]})})]})})})]})}),D&&e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(C,{p:3,children:e.jsx(Te,{parentCallback:cs,data:{newData:lt,columns:Qe,columnstype:"antd",action:!1,Loading:he,error:ve,deleteTodoMutation:we,pageController:z}})})]})})]}),e.jsx(n.Drawer,{open:x,title:ie,placement:"right",width:420,destroyOnClose:!0,onClose:xe,children:_?.id&&e.jsx(Ep,{token:t,assignmentId:_.id,studentName:`${_.firstname??""} ${_.lastname??""}`.trim(),onClose:xe,onSuccess:()=>bt()})}),e.jsx(n.Modal,{open:q,title:"Assign Student to Transport",onCancel:ps,footer:null,width:640,destroyOnClose:!0,children:e.jsx("form",{onSubmit:wa,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Q,{options:un,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",required:!0,allowSelectAll:!1,value:un.find(be=>String(be.value)===String(de))??null,onChange:be=>se(be,"route_id")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Q,{options:dn,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",required:!0,allowSelectAll:!1,value:dn.find(be=>String(be.value)===String(ce))??null,onChange:be=>se(be,"vehicle_id")},`vehicle001${$}`)})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Q,{options:cn,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Stop",required:!0,allowSelectAll:!1,value:cn.find(be=>String(be.value)===String(Ue))??null,onChange:be=>se(be,"stop_id")},`stop001${N}`)})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Me,{Desplay:"Start Date",placement:"bottomRight",format:"YYYY-MM-DD",value:Ve,onChange:be=>Le(be)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{type:"text",name:"rootCost",label:"Route Cost",value:at,onChange:be=>Ge(be?.target?.value??"")})})}),e.jsx(n.Col,{xs:24,children:e.jsxs(C,{display:"flex",alignItems:"center",gap:12,children:[e.jsx(ne,{type:"submit",value:String(at??"").trim()?`${Sl}${at} — Assign`:"Assign",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:ps,style:ni,children:"Cancel"})]})})]})})})]})}const si={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},fn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"};function qp({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:50}),[i,o]=r.useState(!1),[l,d]=r.useState(null),[c,g]=r.useState(""),[h,u]=r.useState(""),[p,A]=r.useState(""),[w,b]=r.useState(!1),m=`api/branchapi/Transport/getdriverTable?page=${a.page}&per_page=${a.rowsPerPage}`,j="api/branchapi/Transport/add_driver",D="api/branchapi/Transport/edit_driver",R="api/branchapi/Transport/deletedriver",k="api/branchapi/staff/uploadDocuments",S=r.useMemo(()=>String(k).startsWith("http")?k:`${He()??""}${String(k).replace(/^\/+/,"")}`,[k]),x=He()??"",{isLoading:f,data:_,error:T,mutate:I}=W(t?[m,t]:null,([z,E])=>K(z,E)),B=async(z,E)=>{try{await Ee(z,E,t),await I(),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),g("")}catch(M){v.error(M?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},L=z=>{z.preventDefault();const E=new FormData(z.target);B(j,E),z.target.reset()},y=async z=>{try{await I(qe(R,z,t),Ne(z)),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}},P=z=>{d(z),g(z?.image??""),o(!0)},O=async z=>{try{await Be(D,z,t),await I(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),g("")}catch(E){v.error(E?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},$=z=>{z.preventDefault();const E=new FormData(z.target);E.append("id",l?.id??""),O(E)},U=(z,E)=>{s({page:z,rowsPerPage:parseInt(E,10)})},N=[{title:"Driver Name",dataIndex:"name",key:"name",sorter:{compare:(z,E)=>String(z?.name??"").localeCompare(String(E?.name??""))}},{title:"Driver Licence",dataIndex:"Driver_licence",key:"Driver_licence",sorter:{compare:(z,E)=>String(z?.Driver_licence??"").localeCompare(String(E?.Driver_licence??""))}},{title:"Contact",dataIndex:"contact_number",key:"contact_number",sorter:{compare:(z,E)=>Number(z?.contact_number??0)-Number(E?.contact_number??0)}},{title:"Address",dataIndex:"address",key:"address",sorter:{compare:(z,E)=>String(z?.address??"").localeCompare(String(E?.address??""))}},{title:"Image",key:"image",width:100,render:(z,E)=>{const M=E?.image?`${x}staff/document/${E.image}`:"";return M?e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx(n.Image,{width:80,src:M,preview:{visible:!1,onVisibleChange:()=>{b(!0),u(M),A(E?.name??"Driver")}}})}):null}},{title:"Action",key:"action",render:(z,E)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>P(E),style:{padding:2}}),e.jsx(mt,{id:E?.id,funcName:y})]})}],V=l?.name?`Edit ${l.name}`:"Edit Driver";return e.jsxs("div",{children:[e.jsx(n.Drawer,{open:i,title:V,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{o(!1),d(null),g("")},children:e.jsx("form",{onSubmit:$,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"name",label:"Driver Name",defaultValue:l?.name??"",required:"required"}),e.jsx(Y,{type:"text",name:"Driver_licence",label:"Driver Licence",defaultValue:l?.Driver_licence??"",required:"required"}),e.jsx(Y,{type:"number",name:"contact_number",label:"Driver Contact",defaultValue:l?.contact_number??"",required:"required"}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:fn,children:"Address"}),e.jsx(n.Input.TextArea,{name:"address",defaultValue:l?.address??"",rows:2,style:{width:"100%",border:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",paddingLeft:0,paddingRight:0}})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:fn,children:"Image"}),e.jsx(n.Upload,{maxCount:1,action:S,headers:t?{Authorization:t}:void 0,onChange:z=>{if(z?.file?.status!=="done")return;const E=z?.file?.response,M=E?.data??E?.filename??E?.file??E?.path??"";M&&g(String(M))},children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),disabled:!S,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null),g("")},style:si,children:"Cancel"})]})]})})}),e.jsx(n.Modal,{zIndex:9999,open:w,title:p,footer:null,onCancel:()=>b(!1),children:e.jsx("img",{alt:"preview",style:{width:"100%"},src:h})}),e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(C,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Add Driver"})}),e.jsx(C,{px:3,pb:2,children:e.jsx("form",{onSubmit:L,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"name",label:"Driver Name",required:"required"}),e.jsx(Y,{type:"text",name:"Driver_licence",label:"Driver Licence",required:"required"}),e.jsx(Y,{type:"number",name:"contact_number",label:"Driver Contact",required:"required"}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:fn,children:"Address"}),e.jsx(n.Input.TextArea,{name:"address",rows:2,style:{width:"100%",border:0,borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none",paddingLeft:0,paddingRight:0}})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:fn,children:"Image"}),e.jsx(n.Upload,{maxCount:1,action:S,headers:t?{Authorization:t}:void 0,onChange:z=>{if(z?.file?.status!=="done")return;const E=z?.file?.response,M=E?.data??E?.filename??E?.file??E?.path??"";M&&g(String(M))},children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),disabled:!S,children:"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",onClick:()=>g(""),style:si,children:"Cancel"})]})]})})})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Driver List"})}),e.jsx(C,{children:e.jsx(Te,{parentCallback:U,data:{newData:_,columns:N,columnstype:"antd",action:!1,Loading:f,error:T,deleteTodoMutation:y}})})]})})]})})]})}const ri={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},la={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},yn={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},ii=[{label:"Pick",value:"pick"},{label:"Drop",value:"drop"}],gn=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function zp({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:50}),[i,o]=r.useState(!1),[l,d]=r.useState(!1),[c,g]=r.useState(null),[h,u]=r.useState(null),[p,A]=r.useState(null),[w,b]=r.useState(null),[m,j]=r.useState(te()),[D,R]=r.useState(te()),[k,S]=r.useState("pick"),[x,f]=r.useState(!1),[_,T]=r.useState(null),[I,B]=r.useState(null),[L,y]=r.useState(!1),[P,O]=r.useState(null),[$,U]=r.useState(null),[N,V]=r.useState(null),[z,E]=r.useState(null),[M,F]=r.useState(te()),[q,H]=r.useState(te()),[re,G]=r.useState("pick"),J=`api/branchapi/Transport/assignRouteTimeList?page=${a.page}&per_page=${a.rowsPerPage}`,ae="api/branchapi/Transport/assignRouteTime",oe="api/branchapi/Transport/editAssignRouteTime",pe="api/branchapi/Transport/deleteAssignRouteTime",_e="api/branchapi/Transport/driverDropdown",le="api/branchapi/transport/routeTimetableShowdata",de="api/branchapi/Transport/getrouteDropdown",X="api/branchapi/Transport/getvehicleDropdown",{isLoading:ce,data:Re,error:Ue,mutate:ke}=W(t?[J,t]:null,([he,ve])=>K(he,ve)),{data:Ve}=W(t&&de?[de,t]:null,([he,ve])=>K(he,ve)),{data:Le}=W(t&&_e?[_e,t]:null,([he,ve])=>K(he,ve)),at=r.useMemo(()=>c?`${X}?route_id=${c}`:null,[c,X]),{data:Ge}=W(t&&at?[at,t]:null,([he,ve])=>K(he,ve)),Fe=r.useMemo(()=>gn(Ve),[Ve]),Je=r.useMemo(()=>gn(Le),[Le]),it=r.useMemo(()=>gn(Ge),[Ge]),fe=(he,ve)=>{s({page:he,rowsPerPage:parseInt(ve,10)})},Se=async he=>{he.preventDefault();const ve=new FormData(he.target);ve.set("route_id",h?.value??c??""),ve.set("driver_id",p?.value??""),ve.set("vehicle_id",w?.value??""),ve.set("start_time",m?m.format("h:mm a"):""),ve.set("drop_time",D?D.format("h:mm a"):""),ve.set("type",k);try{await Ee(ae,ve,t),await ke(),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),he.target.reset(),g(null),u(null),A(null),b(null),d(lt=>!lt),j(te()),R(te()),S("pick"),o(lt=>!lt)}catch(lt){v.error(lt?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},je=async he=>{try{await qe(pe,he,t),await ke(),v.success("Success! Deleted item.",{duration:1e3})}catch(ve){v.error(ve?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},se=he=>{T(he),f(!0);const ve=he?.id??he?.route_time_id??he?.routeId??null;B(ve);const lt=he?.route_id??he?.routeId??he?.fk_route_id;O(lt??null),U(Fe.find(bt=>bt?.value===(lt??he?.route_id))??null),V(Je.find(bt=>bt?.value===(he?.driver_id??he?.driverId))??null),E(null),y(bt=>!bt),F(he?.start_time?te(he.start_time,["h:mm a","HH:mm"]):te()),H(he?.drop_time?te(he.drop_time,["h:mm a","HH:mm"]):te()),G(he?.type??"pick")},me=r.useMemo(()=>{if(!I)return null;const he=String(le).includes("?")?"&":"?";return`${le}${he}id=${encodeURIComponent(String(I))}`},[I,le]),{data:xe,isLoading:ie}=W(t&&me?[me,t]:null,([he,ve])=>K(he,ve)),ye=r.useMemo(()=>{const he=xe?.data??xe;return Array.isArray(he)?he[0]??null:Array.isArray(he?.data)?he.data[0]??null:he??null},[xe]),Ye=r.useMemo(()=>P?`${X}?route_id=${P}`:null,[P,X]),{data:vt}=W(t&&Ye?[Ye,t]:null,([he,ve])=>K(he,ve)),Dt=r.useMemo(()=>gn(vt),[vt]);r.useEffect(()=>{if(!ye)return;const he=ye?.route_id??ye?.fk_route_id??ye?.routeId;O(he??null),U(Fe.find(ve=>ve?.value===he)??null),V(Je.find(ve=>ve?.value===ye?.driver_id)??null),E(null),F(ye?.start_time?te(ye.start_time,["h:mm a","HH:mm"]):te()),H(ye?.drop_time?te(ye.drop_time,["h:mm a","HH:mm"]):te()),G(ye?.type??"pick"),y(ve=>!ve)},[Je,ye,Fe]),r.useEffect(()=>{if(!ye)return;const he=ye?.vehicle_id??ye?.vehicleId;he&&E(Dt.find(ve=>ve?.value===he)??null)},[ye,Dt]);const xt=async he=>{if(he.preventDefault(),!I)return;const ve=new FormData(he.target);ve.set("id",String(I)),ve.set("route_id",$?.value??P??""),ve.set("driver_id",N?.value??""),ve.set("vehicle_id",z?.value??""),ve.set("start_time",M?M.format("h:mm a"):""),ve.set("drop_time",q?q.format("h:mm a"):""),ve.set("type",re);try{await Be(oe,ve,t),await ke(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),f(!1),T(null)}catch(lt){v.error(lt?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},Et=[{title:"Route Name",dataIndex:"route_title",key:"route_title"},{title:"Driver Name",dataIndex:"driver_name",key:"driver_name"},{title:"Vehicle Name",dataIndex:"vehicle_name",key:"vehicle_name"},{title:"Start Time",dataIndex:"start_time",key:"start_time"},{title:"End Time",dataIndex:"drop_time",key:"drop_time"},{title:"Type",dataIndex:"type",key:"type"},{title:"Action",key:"action",render:(he,ve)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>se(ve),style:{padding:2}}),e.jsx(mt,{id:ve?.id??ve?.routeId??ve?.route_time_id,funcName:je})]})}],Zt=_?.route_title?`Edit ${_.route_title}`:"Edit Route Time";return e.jsxs("div",{children:[e.jsx(n.Drawer,{open:x,title:Zt,placement:"right",width:420,destroyOnClose:!0,onClose:()=>{f(!1),T(null),B(null),O(null),U(null),V(null),E(null)},children:e.jsx("form",{onSubmit:xt,children:e.jsxs("div",{style:{display:"grid",gap:20,opacity:ie?.6:1},children:[e.jsx(Q,{options:Fe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",required:!0,allowSelectAll:!1,value:$,onChange:he=>{O(he?.value??null),U(he??null),E(null),y(ve=>!ve)}}),e.jsx(Q,{options:Je,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",required:!0,allowSelectAll:!1,value:N,onChange:he=>V(he??null)}),e.jsx(Q,{options:Dt,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",required:!0,allowSelectAll:!1,value:z,onChange:he=>E(he??null)},`edit-vehicle-${L}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Start Time"}),e.jsx(n.TimePicker,{value:M,onChange:he=>F(he),use12Hours:!0,format:"h:mm a",allowClear:!1,style:yn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Drop Time"}),e.jsx(n.TimePicker,{value:q,onChange:he=>H(he),use12Hours:!0,format:"h:mm a",allowClear:!1,style:yn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(n.Radio.Group,{options:ii,optionType:"button",buttonStyle:"solid",value:re,onChange:he=>G(he.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{f(!1),T(null)},style:ri,children:"Cancel"})]})]})})}),e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(C,{pt:5,pb:1,children:e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(C,{px:3,pb:2,children:e.jsx("form",{onSubmit:Se,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:Fe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",value:h,onChange:he=>{g(he?.value??null),u(he??null),b(null),d(ve=>!ve)},allowSelectAll:!1,required:!0}),e.jsx(Q,{options:Je,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Driver",name:"driver_id",value:p,onChange:he=>A(he??null),allowSelectAll:!1,required:!0}),e.jsx(Q,{options:it,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vehicle",name:"vehicle_id",value:w,onChange:he=>b(he??null),allowSelectAll:!1,required:!0},`vehicle-${l}`),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Start Time"}),e.jsx(n.TimePicker,{value:m,onChange:he=>j(he),use12Hours:!0,format:"h:mm a",allowClear:!1,style:yn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Drop Time"}),e.jsx(n.TimePicker,{value:D,onChange:he=>R(he),use12Hours:!0,format:"h:mm a",allowClear:!1,style:yn})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("label",{className:"labelfont",style:la,children:"Type"}),e.jsx("div",{style:{borderBottom:"1px solid #d9d9d9",paddingBottom:6},children:e.jsx(n.Radio.Group,{options:ii,optionType:"button",buttonStyle:"solid",value:k,onChange:he=>S(he.target.value)})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Add",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"reset",onClick:()=>{g(null),u(null),A(null),b(null),d(he=>!he),j(te()),R(te()),S("pick"),o(he=>!he)},style:ri,children:"Cancel"})]})]})},`form-${i}`)})]}),e.jsx("div",{style:{marginTop:24},children:e.jsxs("div",{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Route Time List"})}),e.jsx(C,{children:e.jsx(Te,{parentCallback:fe,data:{newData:Re,columns:Et,columnstype:"antd",action:!1,Loading:ce,error:Ue,deleteTodoMutation:je}})})]})})]})})]})}const Yp={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},oi={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},li={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},di=({dataIndex:t,title:a,record:s,children:i,isEditable:o,...l})=>e.jsx("td",{...l,children:o?e.jsx("div",{style:{display:"flex",marginLeft:"5%"},children:i}):i});let ci=2;function Vp({token:t}){const[a,s]=r.useState([]),[i,o]=r.useState(null),[l,d]=r.useState([]),[c,g]=r.useState({pagination:{current:1,pageSize:50}}),{isLoading:h,data:u,mutate:p}=W(t?[`api/branchapi/transport/getrouteStoppageData?page=${c.pagination.current}&per_page=${c.pagination.pageSize}`,t]:null,([O,$])=>K(O,$)),{Status:A="Failed",pagination:{total_rows:w=0}={}}=u||{},{data:b=[]}=A==="Success"?u:{},{data:m}=W(t?["api/branchapi/Transport/getrouteDropdown",t]:null,([O,$])=>K(O,$)),j=r.useMemo(()=>{const O=m?.data??m??[];if(Array.isArray(O))return O;if(O&&typeof O=="object"){if(Array.isArray(O?.data))return O.data;if(Array.isArray(O?.data?.data))return O.data.data}return[]},[m]),{data:D}=W(t&&i?["api/branchapi/transport/getrouteStoppageData?route_id="+i,t]:null,([O,$])=>K(O,$)),{Status:R="Failed"}=D||{},k=async(O,$)=>{try{await p(Ee(O,$,t),ze($)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{v.error("Failed to add the new item.",{duration:1e3})}},S=O=>O?typeof O=="string"?O:O?.isValid?.()?O.format("h:mm a"):"":"",x=(O,$=[])=>{const U=(Array.isArray(O)?O:[]).map(z=>({id:z?.id??"",name:String(z?.stop_name??z?.name??"").trim(),pickTime:S(z?.pickup_time??z?.pickTime??z?.pickupTime),drop_time:S(z?.drop_time??z?.dropTime)})),N=U.filter(z=>z?.id!=null&&String(z.id).trim()!==""),V=U.filter(z=>!(z?.id!=null&&String(z.id).trim()!==""));return{route_id:i??"",edit_stoppage:N,add_stoppage:V,delete_stoppage:Array.isArray($)?$:[]}},f=O=>{O.preventDefault();const $="/api/branchapi/transport/addstoppageToRoute",U=x(a,l);k($,U)},_=()=>{s(O=>[...Array.isArray(O)?O:[],{idKey:ci++,stop_name:"",pickup_time:te().format("h:mm a"),drop_time:te().format("h:mm a")}])},T=O=>{if(a.length===1)return;const $=a[O];$?.id!=null&&String($.id).trim()!==""&&!$?.idKey&&d(U=>{const N=Array.isArray(U)?U:[];return N.some(z=>String(z)===String($.id))?N:[...N,$.id]}),s(U=>{const N=[...U];return N.splice(O,1),N})},I=O=>{g($=>({...$,pagination:{current:O,pageSize:$.pagination.pageSize}}))},B=async O=>{const $="/api/branchapi/Transport/deletevehicle";try{await p(qe($,O,t),Ne(O)),v.success("Success! Deleted item.",{duration:1e3})}catch{v.error("Failed to delete the item.",{duration:1e3})}};r.useEffect(()=>{if(R==="Success"){const O=Array.isArray(D?.data)?D.data:[];O.length>0?(s(O),d([])):i&&(s([{idKey:ci++,stop_name:"",pickup_time:te().format("h:mm a"),drop_time:te().format("h:mm a")}]),d([]))}},[R,D,i]);const L=O=>{const{children:$=[]}=O||{},U=[{title:"Stop Name",dataIndex:"stop_name",onCell:N=>({isEditable:!0})},{title:"Pick Time",dataIndex:"pickup_time",onCell:N=>({isEditable:!0})},{title:"Drop Name",dataIndex:"drop_time",onCell:N=>({isEditable:!0})}];return e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("div",{style:{width:"95%",margin:8},children:e.jsx(n.Table,{components:{body:{cell:di}},expandable:{childrenColumnName:"changed"},bordered:!0,columns:U,rowKey:N=>y(N)+"cell01",dataSource:$,pagination:!1})})})},y=O=>{const $=["id","index"];for(let U=0;U<$.length;U++)if(O[$[U]])return O[$[U]]},P=[{title:"Route",dataIndex:"route_title"},{title:"Stoppages",render:(O,$,U)=>e.jsx(e.Fragment,{children:(Array.isArray($.children)?$.children:[]).map((N,V,z)=>e.jsx("span",{children:`${N.stop_name} ${V+1===z.length?"":","}`},`${V}vehicle001`))})},{title:"Action",render:(O,$,U)=>e.jsx(e.Fragment,{children:e.jsx(mt,{id:$?.route_id,funcName:B})})}];return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(C,{pt:5,pb:1,children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Route Time Table"})}),e.jsx(C,{px:3,pb:2,children:e.jsxs("form",{onSubmit:f,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx("div",{children:e.jsx(Q,{options:j,value:j.find(O=>String(O.value)===String(i))??null,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Route",name:"route_id",onChange:O=>{o(O?.value??null),s([]),d([])},allowSelectAll:!1,required:!0})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-start",gap:12},children:i&&e.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer",marginBottom:8},title:"Add Row",onClick:_,children:e.jsx(ee.PlusCircleOutlined,{style:{fontSize:24,color:"#28a745"}})})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(ne,{type:"submit",value:"Add",color:"primary"}),e.jsx(n.Button,{type:"text",htmlType:"button",onClick:()=>{o(null),s([]),d([])},style:Yp,children:"Cancel"})]})]}),e.jsx("div",{style:{marginTop:20},children:a.length>0&&a.map((O,$)=>{const U=O.pickup_time?te(O.pickup_time,"h:mm a"):null,N=O.drop_time?te(O.drop_time,"h:mm a"):null;return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr)) auto",gap:16,alignItems:"end",marginBottom:12},children:[e.jsxs("div",{children:[e.jsx(Y,{value:O.stop_name??"",type:"text",name:`stoppage[${$}][name]`,label:"Place Name*",required:"required",onChange:V=>{const z=V?.target?.value??"";s(E=>{const M=[...E];return M[$]={...M[$]??{},stop_name:z},M})}}),O?.id!=null&&String(O.id).trim()!==""&&e.jsx("input",{type:"hidden",name:`stoppage[${$}][id]`,value:String(O.id)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:oi,children:"Pick Time"}),e.jsx(n.TimePicker,{value:U,use12Hours:!0,format:"h:mm a",name:`stoppage[${$}][pickTime]`,allowClear:!1,style:li,onChange:V=>{const z=V?V.format("h:mm a"):"";s(E=>{const M=[...E];return M[$]={...M[$]??{},pickup_time:z},M})}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:oi,children:"Drop Time"}),e.jsx(n.TimePicker,{value:N,use12Hours:!0,format:"h:mm a",name:`stoppage[${$}][drop_time]`,allowClear:!1,style:li,onChange:V=>{const z=V?V.format("h:mm a"):"";s(E=>{const M=[...E];return M[$]={...M[$]??{},drop_time:z},M})}})]}),e.jsx("div",{style:{marginBottom:8},children:a.length>1&&e.jsx("button",{type:"button",style:{padding:2,border:"none",background:"transparent",cursor:"pointer"},onClick:()=>T($),children:e.jsx(ee.MinusCircleOutlined,{style:{fontSize:20,color:"#dc3545"}})})})]},O.idKey?O.idKey+"exp":O.id+"exp")})})]})}),e.jsx(C,{mx:2,mt:1,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Stoppage List"})}),e.jsx(C,{style:{padding:"10px 16px"},children:e.jsx(n.Table,{components:{body:{cell:di}},columns:P,bordered:!0,size:"small",rowKey:O=>y(O),dataSource:b,loading:h,expandable:{expandedRowRender:L,childrenColumnName:"changed"},pagination:{current:c.pagination.current,pageSize:c.pagination.pageSize,total:w,showSizeChanger:!0,onChange:I,onShowSizeChange:(O,$)=>{g(U=>({...U,pagination:{current:1,pageSize:$}}))},showTotal:(O,$)=>`${$[0]}-${$[1]} of ${O} items`}})})]})]})}const{Step:xn}=n.Steps;function Wp({token:t}){const[a,s]=r.useState(0),[i,o]=r.useState(void 0),[l,d]=r.useState(void 0),[c,g]=r.useState(!1),[h,u]=r.useState(null),[p,A]=r.useState(!1),[w,b]=r.useState(!1),[m,j]=r.useState(!1),[D,R]=r.useState([]),[k,S]=r.useState(null),[x,f]=r.useState(null),[_,T]=r.useState(!1),{isLoading:I,data:B}=W(t?[Xa,t]:null,([F,q])=>K(F,q)),{isLoading:L,data:y}=W(_?[_,t]:null,([F,q])=>K(F,q)),{data:P}=W(c?[c,t]:null,([F,q])=>K(F,q)),O=r.useMemo(()=>[{title:"Excel Row",dataIndex:"row",width:90,render:F=>F??"-"},{title:"Student Name",dataIndex:"student_name_system",render:F=>F?e.jsx("span",{style:{color:"#d97706"},children:F}):"-"},{title:"Route",dataIndex:"route",render:F=>F||"-"},{title:"Vehicle",dataIndex:"vehicle",render:F=>F||"-"},{title:"Stop",dataIndex:"stop",render:F=>F||"-"},{title:"Start Date",dataIndex:"start_date",render:F=>F||"-"},{title:"Transport Fee",dataIndex:"transport_fee",render:F=>F??"-"},{title:"Status",dataIndex:"status",width:110,render:F=>{const H={Valid:"success",Invalid:"error",Duplicate:"warning",Imported:"success",Skipped:"warning",Failed:"error"}[F]||"default";return e.jsx("span",{style:{color:H,fontWeight:500},children:F})}},{title:"Message",dataIndex:"message",render:F=>F?e.jsx("span",{style:{color:"#dc2626"},children:F}):"-"}],[]),$=()=>{u(null),A(!1),b(!1),j(!1),R([]),S(null),f(null),o(void 0),d(void 0),g(!1),s(0)},U=async()=>{try{const F=await su({class_id:i?.value,section_id:l?.value},t),q=window.URL.createObjectURL(F),H=document.createElement("a");H.href=q,H.download="transport-bulk-template.xlsx",document.body.appendChild(H),H.click(),document.body.removeChild(H),window.URL.revokeObjectURL(q),v.success("Template downloaded.",{duration:1e3})}catch(F){v.error(F?.message||"Failed to download template.",{duration:1e3})}},N=async()=>{if(!h){v.error("Please select an Excel file to upload.",{duration:1e3});return}b(!0),R([]),S(null),f(null);try{const F=await ru(h,t);if(F.Status!=="Success"){v.error(F.msg||"Validation failed.",{duration:1e3}),b(!1);return}S(F.data?.summary||null),R(F.data?.rows||[]),s(2),v.success(F.msg||"Validation complete.",{duration:1e3})}catch(F){v.error(F?.message||"Validation failed.",{duration:1e3})}finally{b(!1)}},V=async()=>{if(!D.length){v.error("No rows provided to import.",{duration:1e3});return}j(!0),f(null);try{const F=await iu(D,t,"skip");if(F.Status!=="Success"){v.error(F.msg||"Import failed.",{duration:1e3}),j(!1);return}f(F.data||null),s(3),v.success(F.msg||"Import completed.",{duration:1e3})}catch(F){v.error(F?.message||"Import failed.",{duration:1e3})}finally{j(!1)}},z=async F=>{if(!F||!F.length){v.error("No rows provided.",{duration:1e3});return}try{const q=await ou(F,t),H=window.URL.createObjectURL(q),re=document.createElement("a");re.href=H,re.download="transport-bulk-error-report.xlsx",document.body.appendChild(re),re.click(),document.body.removeChild(re),window.URL.revokeObjectURL(H),v.success("Error report downloaded.",{duration:1e3})}catch(q){v.error(q?.message||"Failed to download error report.",{duration:1e3})}},E=r.useMemo(()=>D.length?(x?x.rows:D).filter(q=>!["Valid","Imported"].includes(q.status)):[],[D,x]),M={background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"};return e.jsx(C,{pt:5,pb:1,children:e.jsx(n.Row,{gutter:[16,16],children:e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:M,children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Transport / Bulk Upload"})}),e.jsxs(C,{p:3,children:[e.jsxs(n.Steps,{current:a,style:{marginBottom:16},children:[e.jsx(xn,{title:"Download Template"}),e.jsx(xn,{title:"Upload & Validate"}),e.jsx(xn,{title:"Review"}),e.jsx(xn,{title:"Import Result"})]}),a===0&&e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:4,children:e.jsx(C,{children:e.jsx(Q,{label:"Class",options:Array.isArray(B)?B:[],value:i,onChange:F=>{o(F),F?g(`${Za}?class_id=${F.value}`):(d(void 0),g(!1))},showSearch:!0,allowClear:!0})})}),e.jsx(n.Col,{xs:24,md:4,children:e.jsx(C,{children:e.jsx(Q,{label:"Section",options:Array.isArray(P)?P:[],value:l,onChange:d,showSearch:!0,allowClear:!0})})}),e.jsx(n.Col,{xs:24,md:4,style:{marginTop:20},children:e.jsx(C,{children:e.jsx(n.Button,{type:"primary",onClick:U,block:!0,children:"Download Excel Template"})})}),e.jsx(n.Col,{xs:24,children:e.jsx(C,{mt:1,children:e.jsx(n.Button,{type:"primary",onClick:()=>s(1),children:"Next: Upload Excel"})})})]}),a===1&&e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsxs(C,{children:[e.jsx(n.Upload,{accept:".xlsx",showUploadList:!1,beforeUpload:F=>(u(F),!1),children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),block:!0,disabled:p||w,children:h?h.name:"Choose Excel File (.xlsx)"})}),h&&e.jsxs(C,{mt:.5,display:"flex",alignItems:"center",gap:1,children:[e.jsxs(ge,{level:6,color:"textSecondary",children:[(h.size/1024).toFixed(1)," KB"]}),e.jsx(n.Button,{size:"small",danger:!0,onClick:()=>u(null),children:"Remove"})]})]})}),e.jsx(n.Col,{xs:24,md:3,children:e.jsx(C,{children:e.jsx(ne,{type:"button",value:w?"Validating...":"Validate & Preview",color:"primary",onClick:N,disabled:w||!h})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Button,{type:"text",size:"small",onClick:()=>{$(),s(0)},children:"Back"})})]}),a===2&&e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(C,{p:1.5,children:[e.jsx(ge,{level:6,color:"textSecondary",children:"Total"}),e.jsx(ge,{level:4,children:k?.total??D.length})]})})}),e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(C,{p:1.5,children:[e.jsx(ge,{level:6,color:"textSecondary",children:"Valid"}),e.jsx(ge,{level:4,style:{color:"#52c41a"},children:k?.valid??0})]})})}),e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(C,{p:1.5,children:[e.jsx(ge,{level:6,color:"textSecondary",children:"Invalid"}),e.jsx(ge,{level:4,style:{color:"#ff4d4f"},children:k?.invalid??0})]})})}),e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(C,{p:1.5,children:[e.jsx(ge,{level:6,color:"textSecondary",children:"Duplicate"}),e.jsx(ge,{level:4,style:{color:"#faad14"},children:k?.duplicate??0})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(C,{style:{maxHeight:400,overflow:"auto",width:"100%"},children:e.jsx(n.Table,{dataSource:D.map((F,q)=>({...F,key:`${F.row}-${q}`})),columns:O,size:"small",bordered:!0,scroll:{x:!0},pagination:{pageSize:10,showSizeChanger:!0,showTotal:(F,q)=>`${q[0]}-${q[1]} of ${F} items`}})})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Row,{gutter:[8,8],align:"middle",children:[e.jsx(n.Col,{children:e.jsx(ne,{type:"button",value:m?"Importing...":"Import Valid Rows",color:"primary",onClick:V,disabled:m})}),e.jsx(n.Col,{children:e.jsx(n.Button,{size:"small",onClick:()=>z(E),disabled:!E.length,children:"Download Error Report"})}),e.jsx(n.Col,{children:e.jsx(n.Button,{type:"text",size:"small",onClick:()=>{$(),s(1)},children:"Upload Another File"})})]})})]}),a===3&&e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(C,{p:1.5,children:[e.jsxs(ge,{level:6,color:"textSecondary",children:["Total "," "]}),e.jsx(ge,{level:4,children:x?.total??0})]})})}),e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(C,{p:1.5,children:[e.jsxs(ge,{level:6,color:"textSecondary",children:["Imported "," "]}),e.jsx(ge,{level:4,style:{color:"#52c41a"},children:x?.imported??0})]})})}),e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(C,{p:1.5,children:[e.jsxs(ge,{level:6,color:"textSecondary",children:["Skipped "," "]}),e.jsx(ge,{level:4,style:{color:"#faad14"},children:x?.skipped??0})]})})}),e.jsx(n.Col,{xs:6,md:3,children:e.jsx(n.Card,{children:e.jsxs(C,{p:1.5,children:[e.jsxs(ge,{level:6,color:"textSecondary",children:["Failed "," "]}),e.jsx(ge,{level:4,style:{color:"#ff4d4f"},children:x?.failed??0})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(C,{style:{maxHeight:400,overflow:"auto",width:"100%"},children:e.jsx(n.Table,{dataSource:(x?.rows||[]).map((F,q)=>({...F,key:`${F.row}-${q}`})),columns:O,size:"small",bordered:!0,scroll:{x:!0},pagination:{pageSize:10,showSizeChanger:!0,showTotal:(F,q)=>`${q[0]}-${q[1]} of ${F} items`}})})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Row,{gutter:[8,8],align:"middle",children:[e.jsx(n.Col,{children:e.jsx(n.Button,{size:"small",onClick:()=>z(E),disabled:!E.length,children:"Download Error Report"})}),e.jsx(n.Col,{children:e.jsx(n.Button,{type:"primary",size:"small",onClick:$,children:"Upload Another File"})})]})})]})]})]})})})})}const ui={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},Ra=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Hp({token:t}){const[a,s]=r.useState("api/branchapi/homeworks/gethomeworklistByClassSectionBranch?"),[i,o]=r.useState({page:1,rowsPerPage:10}),[l,d]=r.useState(null),[c,g]=r.useState(null),[h,u]=r.useState(null),[p,A]=r.useState(null),[w,b]=r.useState(!1),[m,j]=r.useState(null),[D,R]=r.useState(null),[k,S]=r.useState(null),[x,f]=r.useState(null),[_,T]=r.useState(null),[I,B]=r.useState(null),[L,y]=r.useState(!1),[P,O]=r.useState(""),[$,U]=r.useState(""),[N,V]=r.useState(""),z=(ie,ye)=>{const Ye=ie?.value??null;switch(ye){case"class_id":d(Ye),g(null),u(null);break;case"section_id":g(Ye);break;case"subject_id":u(Ye);break}},{data:E}=W(t?["api/branchapi/academy/classdropdownlist",t]:null,([ie,ye])=>K(ie,ye)),{data:M}=W(t&&_?[_,t]:null,([ie,ye])=>K(ie,ye)),{data:F}=W(t&&I?[I,t]:null,([ie,ye])=>K(ie,ye)),q=l?`api/branchapi/academy/sectionoftheClass?class_id=${l}`:null,{data:H}=W(t&&q?[q,t]:null,([ie,ye])=>K(ie,ye)),re=l?`api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${l}`:null,{data:G}=W(t&&re?[re,t]:null,([ie,ye])=>K(ie,ye)),J=r.useMemo(()=>Ra(E),[E]),ae=r.useMemo(()=>Ra(M),[M]),oe=r.useMemo(()=>Ra(F),[F]),pe=r.useMemo(()=>Ra(H),[H]),_e=r.useMemo(()=>Ra(G),[G]),le=t&&a?`${a}class_id=${l||""}&subject_id=${h||""}§ion_id=${c||""}&date=${p?.format("YYYY-MM-DD")||""}&page=${i.page}&per_page=${i.rowsPerPage}`:null,{isLoading:de,error:X,data:ce,mutate:Re}=W(le?[le,t]:null,([ie,ye])=>K(ie,ye)),Ue=async(ie,ye)=>{try{await Re(Ee(ie,ye,t),ze(ye)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),Fe()}catch(Ye){console.error(Ye),v.error("Failed to add the new item.",{duration:1e3})}},ke=async ie=>{try{await Re(qe("api/student/Homework/deleteHomework",ie,t),Ne(ie)),v.success("Success! Deleted item.",{duration:1e3})}catch(ye){console.error(ye),v.error("Failed to delete the item.",{duration:1e3})}},Ve=async ie=>{try{const ye=await Be("api/student/Homework/updateHomework",ie,t);Re(ye),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),Fe()}catch(ye){console.error(ye),v.error("Failed to update the item.",{duration:1e3})}},Le=ie=>{ie.preventDefault();const ye=new FormData(ie.target),Ye=ye.get("class_id")||l,vt=ye.get("section_id")||c,Dt=ye.get("subject_id")||h,xt=p?.format("YYYY-MM-DD");s(`api/branchapi/homeworks/gethomeworklistByClassSectionBranch?class_id=${Ye||""}&subject_id=${Dt||""}§ion_id=${vt||""}${xt?`&date=${xt}`:""}&`),o(Et=>({...Et,page:1}))},at=ie=>{ie.preventDefault();const ye=new FormData(ie.target);Ue("api/branchapi/homeworks/addHomework",ye),V("")},Ge=async(ie,ye)=>{ie.preventDefault();const Ye=new FormData(ie.target);Ye.append("id",ye),await Ve(Ye)},Fe=()=>{b(!1),j(null),R(null),S(null),f(null),T(null),B(null),V("")},Je=ie=>{j(ie);const ye=ie?.class_id??ie?.classId??null,Ye=ie?.section_id??ie?.sectionId??null,vt=ie?.subject_id??ie?.subjectId??null;R(ye),S(Ye),f(vt),ye?(T(`api/branchapi/academy/sectionoftheClass?class_id=${ye}`),B(`api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${ye}`)):(T(null),B(null)),V(ie?.file||ie?.document||""),b(!0)},it=ie=>{const ye=ie?.value??null;R(ye),S(null),f(null),ye?(T(`api/branchapi/academy/sectionoftheClass?class_id=${ye}`),B(`api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${ye}`)):(T(null),B(null))},fe=ie=>{S(ie?.value??null)},Se=ie=>{f(ie?.value??null)},je=(ie,ye)=>{o({page:ie,rowsPerPage:parseInt(ye,10)})},se=()=>{y(!1),O(""),U("")},me=(ie,ye)=>{if(!ie){v.error("No document found.",{duration:1e3});return}O(ie),U(ye||"Document"),y(!0)},xe=[{title:"Date",dataIndex:"homework_date",key:"homework_date"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Title",dataIndex:"title",key:"title"},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0},{title:"Submission Date",dataIndex:"submit_date",key:"submit_date"},{title:"Staff Name",dataIndex:"staff_name",key:"staff_name"},{title:"Subject",dataIndex:"subject",key:"subject"},{title:"Document",key:"document",render:(ie,ye)=>e.jsx("a",{style:{color:"#5080f8",cursor:"pointer"},onClick:()=>me(ye?.document_url,ye?.document),children:"View"})},{title:"Action",key:"action",render:(ie,ye)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>Je(ye),style:{padding:2}}),e.jsx(mt,{id:ye?.id,funcName:ke})]})}];return e.jsxs(C,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Search Homework"})}),e.jsx(C,{p:3,children:e.jsx("form",{onSubmit:Le,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(C,{children:e.jsx(Q,{options:J,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,value:J.find(ie=>String(ie.value)===String(l))??null,onChange:ie=>z(ie,"class_id")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(C,{children:e.jsx(Q,{options:pe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,value:pe.find(ie=>String(ie.value)===String(c))??null,onChange:ie=>z(ie,"section_id")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(C,{children:e.jsx(Q,{options:_e,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subject",name:"subject_id",placeholder:"Subject",allowSelectAll:!1,value:_e.find(ie=>String(ie.value)===String(h))??null,onChange:ie=>z(ie,"subject_id")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(C,{children:e.jsx(Me,{Desplay:"Date",format:"YYYY-MM-DD",allowClear:!1,value:p,onChange:ie=>A(ie)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(C,{children:[e.jsx(ne,{type:"submit",value:"Search",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{s("api/branchapi/homeworks/gethomeworklistByClassSectionBranch?"),d(null),g(null),u(null),A(null)},style:ui,children:"Cancel"})]})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Homework List"})}),e.jsx(C,{p:3,children:e.jsx(Te,{parentCallback:je,data:{newData:ce,columns:xe,columnstype:"antd",action:!1,Loading:de,error:X,deleteTodoMutation:ke,pageController:i}})})]})})]}),e.jsx(n.Drawer,{open:w,title:m?"Edit Homework":"Add Homework",placement:"right",width:600,destroyOnClose:!0,onClose:Fe,children:e.jsx("form",{onSubmit:m?ie=>Ge(ie,m.id):at,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Q,{options:J,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,placeholder:"Select Class",value:J.find(ie=>String(ie.value)===String(D))??null,onChange:it})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Q,{options:ae,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",required:!0,allowSelectAll:!1,placeholder:D?"Select Section":"Select Class First",value:ae.find(ie=>String(ie.value)===String(k))??null,onChange:fe,isDisabled:!D})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Q,{options:oe,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subject",name:"sub_id",required:!0,allowSelectAll:!1,placeholder:D?"Select Subject":"Select Class First",value:oe.find(ie=>String(ie.value)===String(x))??null,onChange:Se,isDisabled:!D})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:te(),Desplay:"From",name:"homew_date"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:te(),Desplay:"Deadline",name:"submission_date"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{type:"text",label:"Title",name:"title",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(st,{type:"text",label:"Description",name:"description",rows:3,required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(C,{children:[e.jsx(n.Upload,{action:"https://npmapi.ubkerp.com//SuperAdmin/uploadFile",headers:{Authorization:t},maxCount:1,onChange:ie=>{if(ie.file.status==="removed"&&V(""),ie.file.status==="done"){const ye=ie.file.response?.data??ie.file.response?.file??"";V(String(ye??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:N?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"file",value:N||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(C,{children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:Fe,style:ui,children:"Cancel"})]})})})})]})})}),e.jsx(n.Modal,{open:L,onCancel:se,footer:null,width:900,closable:!0,children:e.jsxs(C,{p:3,children:[e.jsx(C,{mb:2,children:e.jsx(ge,{level:5,children:$||"View Document"})}),P?P.match(/\.pdf(\?|#|$)/i)?e.jsx("iframe",{src:P,title:$||"Document Preview",style:{width:"100%",height:"70vh",border:"none"}}):e.jsx("img",{src:P,alt:$||"Document Preview",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(ge,{children:"No document found"})]})}),e.jsx(C,{style:{position:"fixed",bottom:24,right:24,zIndex:1e3},children:e.jsx(n.Button,{type:"primary",size:"large",onClick:()=>{j(null),R(null),S(null),f(null),T(null),B(null),V(""),b(!0)},style:{borderRadius:"50%",width:56,height:56,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:24},children:"+"})})]})}const As=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Kp({token:t}){const[a,s]=r.useState(!1),[i,o]=r.useState(null),[l,d]=r.useState(null),[c,g]=r.useState({page:1,rowsPerPage:10}),[h,u]=r.useState(!1),[p,A]=r.useState(""),[w,b]=r.useState(""),[m,j]=r.useState({label:"",value:""}),[D,R]=r.useState({label:"",value:""}),[k,S]=r.useState({label:"",value:""}),[x,f]=r.useState(!1),[_,T]=r.useState(!1),{data:I}=W(t?["api/branchapi/academy/classdropdownlist",t]:null,([G,J])=>K(G,J)),{data:B}=W(t&&a?[a,t]:null,([G,J])=>K(G,J)),{data:L}=W(t&&(i||!0)?[i||"api/branchapi/academy/subjecttableList",t]:null,([G,J])=>K(G,J)),y=r.useMemo(()=>As(I),[I]),P=r.useMemo(()=>As(B),[B]),O=r.useMemo(()=>As(L),[L]),$=t&&l?`${l}page=${c.page}&per_page=${c.rowsPerPage}`:null,{isLoading:U,error:N,data:V,mutate:z}=W($?[$,t]:null,([G,J])=>K(G,J)),E=(G,J)=>{switch(J){case"class_id":j(G||{label:"",value:""}),R({label:"",value:""}),S({label:"",value:""}),o(`/api/branchapi/academy/getSubjectsbyClassaslablevalue?class_id=${G?.value??""}`),s(`/api/branchapi/academy/sectionoftheClass?class_id=${G?.value??""}`),f(ae=>!ae),T(ae=>!ae);break;case"section_id":R(G||{label:"",value:""});break;case"subject_id":S(G||{label:"",value:""});break}},M=async G=>{G.preventDefault();const J="/api/branchapi/homeworks/gethomeworklistByClassSectionBranch",ae=new URLSearchParams;m.value&&ae.append("class_id",String(m.value)),D.value&&ae.append("section_id",String(D.value)),k.value&&ae.append("subject_id",String(k.value));const oe=ae.toString(),pe=oe?`${J}?${oe}&`:`${J}?`;g(_e=>({..._e,page:1})),d(pe),await z()},F=(G,J)=>{g({page:G,rowsPerPage:parseInt(J,10)})},q=()=>{u(!1),A(""),b("")},H=(G,J)=>{A(G),b(J||"Document"),u(!0)},re=[{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Subject",dataIndex:"subject",key:"subject"},{title:"Assign By",dataIndex:"staff_name",key:"staff_name"},{title:"Title",dataIndex:"title",key:"title"},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0},{title:"Submission",dataIndex:"total_submission",key:"total_submission"},{title:"View Document",key:"document",render:(G,J)=>e.jsx("a",{style:{color:"#5080f8",cursor:"pointer"},onClick:()=>H(J.document_url,J.document),children:"View"})}];return e.jsxs(C,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Submission Details"})}),e.jsx(C,{p:3,children:e.jsx("form",{onSubmit:M,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(C,{children:e.jsx(Q,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,value:y.find(G=>String(G.value)===String(m.value))??null,onChange:G=>E(G,"class_id")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(C,{children:e.jsx(Q,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,value:P.find(G=>String(G.value)===String(D.value))??null,onChange:G=>R(G||{label:"",value:""})},`sections1${x}`)})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(C,{children:e.jsx(Q,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subject",name:"subject_id",placeholder:"Subject",allowSelectAll:!1,value:O.find(G=>String(G.value)===String(k.value))??null,onChange:G=>S(G||{label:"",value:""})},`subjects1${_}`)})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(C,{display:"flex",alignItems:"center",height:"100%",mt:2,children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})})]})})})]})}),l&&e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Students List"})}),e.jsx(C,{p:3,children:e.jsx(Te,{parentCallback:F,data:{newData:V,columns:re,columnstype:"antd",action:!1,Loading:U,error:N,pageController:c}})})]})})]}),e.jsx(n.Modal,{open:h,onClose:q,footer:null,width:900,children:e.jsxs(C,{p:3,children:[e.jsxs(C,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,children:[e.jsx(ge,{level:5,children:w||"View Document"}),e.jsx(ne,{type:"button",value:"Close",color:"primary",onClick:q})]}),p?p.match(/\.pdf(\?|#|$)/i)?e.jsx("iframe",{src:p,title:w||"Document Preview",style:{width:"100%",height:"70vh",border:"none"}}):e.jsx("img",{src:p,alt:w||"Document Preview",style:{width:"100%",maxHeight:"70vh",objectFit:"contain"}}):e.jsx(ge,{children:"No document found"})]})})]})}const Gp=(t,a)=>{const s=String(t??"").replace(/\/+$/,""),i=String(a).replace(/^\/+/,"");return`${s}/${i}`};function Jp({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,i]=r.useState(null),[o,l]=r.useState(null),[d,c]=r.useState(null),[g,h]=r.useState(null),[u,p]=r.useState(null),[A,w]=r.useState(null),[b,m]=r.useState(null),j="api/branchapi/library/bookCategorydropdown",D="api/branchapi/academy/classdropdownlist",R="api/branchapi/Academy/getClassSubjectdropdown",k="api/branchapi/library/addBook",S="api/branchapi/library/uploadcsv",{data:x}=W(a?[j,a]:null,([y,P])=>K(y,P)),{data:f}=W(a&&D?[D,a]:null,([y,P])=>K(y,P)),{data:_}=W(a&&R?[R,a]:null,([y,P])=>K(y,P)),T=r.useMemo(()=>Gp(He(),S),[S]),I=async y=>{y.preventDefault();const P=new FormData(y.target);P.set("cat_id",u?.value??""),P.set("class_id",A?.value??""),P.set("subject_id",b?.value??"");try{await Ee(k,P,a),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"}),y.target.reset(),p(null),w(null),m(null)}catch(O){v.error(O?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},B=async y=>{if(y.preventDefault(),!s){v.error("Please select a CSV file.",{duration:1e3});return}const P=new FormData;P.append("file",s),P.append("cat_id",o?.value??""),P.append("class_id",d?.value??""),P.append("subject_id",g?.value??"");try{const O=await We.post(T,P,{headers:{Authorization:a,"Content-type":"multipart/form-data"}});O?.data?.Status==="Failed"?v.error(String(O?.data?.msg??"Upload failed."),{duration:1e3}):(v.success(String(O?.data?.msg??"Uploaded."),{duration:1e3,icon:"🚀"}),i(null),y.target.reset(),l(null),c(null),h(null))}catch(O){v.error(O?.response?.data?.msg??"Upload failed.",{duration:1e3})}},L=()=>{fetch("/books.csv").then(y=>{y.blob().then(P=>{const O=window.URL.createObjectURL(P);let $=document.createElement("a");$.href=O,$.download="/books.csv",$.click()})})};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Book in Bulk"}),extra:e.jsx(n.Button,{type:"link",icon:e.jsx(ee.DownloadOutlined,{}),onClick:L,children:"Download Sample"}),children:[e.jsx(n.Divider,{children:"Information"}),e.jsx(n.Typography.Paragraph,{style:{marginBottom:16},children:"1. Your CSV data should be in the format below. The first line of your CSV file should be the column headers as in the table example. Also make sure that your file is UTF-8 to avoid unnecessary encoding problems."}),e.jsx("form",{onSubmit:B,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:o,onChange:y=>l(y??null)}),e.jsx(Q,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:d,onChange:y=>c(y??null)}),e.jsx(Q,{options:_,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:g,onChange:y=>h(y??null)}),e.jsx(Y,{type:"file",label:"Upload CSV",name:"csv",accept:".csv",onChange:y=>i(y.target.files?.[0]??null),required:!0}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})})]}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Book"}),children:e.jsx("form",{onSubmit:I,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",label:"Book Name",name:"title",required:!0}),e.jsx(Y,{type:"text",label:"Author",name:"author",required:!0}),e.jsx(Y,{type:"text",label:"Publication",name:"publisher"}),e.jsx(Y,{type:"number",label:"Qty",name:"quantity",required:!0}),e.jsx(Y,{type:"number",label:"Book Price",name:"price",required:!0}),e.jsx(Y,{type:"number",label:"Fine Per Day",name:"fine",required:!0}),e.jsx(Y,{type:"text",label:"Barcode",name:"barcode"}),e.jsx(Q,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",allowSelectAll:!1,name:"cat_id",required:!0,value:u,onChange:y=>p(y??null)}),e.jsx(Q,{options:f,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:A,onChange:y=>w(y??null)}),e.jsx(Q,{options:_,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Subjects",name:"subject_id",allowSelectAll:!1,value:b,onChange:y=>m(y??null)}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})})})]})}const Ds={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Ts=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function Qp({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,i]=r.useState([]),[o,l]=r.useState([]),d=r.useRef(),c={selectedRowKeys:s,onChange:(ae,oe)=>{i(ae),l(oe)}},g=xa.useReactToPrint({contentRef:d,documentTitle:"Book Barcodes"}),h=()=>{if(!(typeof window>"u")){if(!o.length){v.error("Select at least one book to print.",{duration:1e3});return}if(!d.current){v.error("Nothing to print.",{duration:1e3});return}g?.()}},[u,p]=r.useState(!1),[A,w]=r.useState(null),[b,m]=r.useState(null),[j,D]=r.useState(null),[R,k]=r.useState(null),[S,x]=r.useState({page:1,rowsPerPage:10}),f=(ae,oe)=>{x({page:ae,rowsPerPage:parseInt(oe,10)})},_="api/branchapi/library/booktable",T="api/branchapi/library/deletebooks",I="api/branchapi/library/editbook",B=`${_}?page=${S.page}&per_page=${S.rowsPerPage}`,{isLoading:L,error:y,data:P,mutate:O}=W(a?[B,a]:null,([ae,oe])=>K(ae,oe)),$="api/branchapi/library/bookCategorydropdown",U="api/branchapi/academy/classdropdownlist",N="api/branchapi/Academy/getClassSubjectdropdown",{data:V}=W(a?[$,a]:null,([ae,oe])=>K(ae,oe)),{data:z}=W(a&&U?[U,a]:null,([ae,oe])=>K(ae,oe)),{data:E}=W(a&&N?[N,a]:null,([ae,oe])=>K(ae,oe)),M=r.useMemo(()=>Ts(V),[V]),F=r.useMemo(()=>Ts(z),[z]),q=r.useMemo(()=>Ts(E),[E]),H=async ae=>{try{await qe(T,ae,a),await O(),v.success("Success! Deleted item.",{duration:1e3})}catch(oe){v.error(oe?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},re=ae=>{w(ae??null);const oe=ae?.cat_id??ae?.fk_cat_id??ae?.category_id,pe=ae?.class_id??ae?.fk_class_id,_e=ae?.subject_id??ae?.fk_subject_id;m(M.find(le=>le?.value===oe)??null),D(F.find(le=>le?.value===pe)??null),k(q.find(le=>le?.value===_e)??null),p(!0)},G=async ae=>{ae.preventDefault();const oe=A?.id??A?.book_id??A?._id;if(!oe)return;const pe=new FormData(ae.target);pe.set("id",String(oe)),pe.set("cat_id",b?.value??""),pe.set("class_id",j?.value??""),pe.set("subject_id",R?.value??"");try{await Be(I,pe,a),await O(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),p(!1),w(null)}catch(_e){v.error(_e?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},J=r.useMemo(()=>[{title:"Name",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Barcode",dataIndex:"barcode",key:"barcode",width:140,responsive:["sm"]},{title:"Publisher",dataIndex:"publish",key:"publish",width:160,responsive:["lg"]},{title:"Author",dataIndex:"author",key:"author",width:160,responsive:["lg"]},{title:"Class",dataIndex:"class_name",key:"class_name",width:140,responsive:["xl"]},{title:"Subject",dataIndex:"subject_name",key:"subject_name",width:160,responsive:["xl"]},{title:"Avl Qty",dataIndex:"available_qty",key:"available_qty",width:90},{title:"Book Price",dataIndex:"perunitcost",key:"perunitcost",width:120,responsive:["xl"]},{title:"Fine Amount",dataIndex:"fine_amount",key:"fine_amount",width:120,responsive:["xl"]},{title:"Category",dataIndex:"cat_name",key:"cat_name",width:160,responsive:["xl"]},{title:"Action",key:"action",width:140,fixed:"right",render:(ae,oe)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>re(oe),style:{padding:2}}),e.jsx(n.Button,{type:"text",size:"small",danger:!0,onClick:()=>H(oe?.id??oe?.book_id??oe?._id),style:{padding:"2px 6px"},children:"Delete"})]})}],[M,F,H,q]);return e.jsxs("div",{style:{},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:u,title:"Edit Book",placement:"right",width:520,destroyOnClose:!0,onClose:()=>{p(!1),w(null)},children:e.jsx("form",{onSubmit:G,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Y,{label:"Book Name",name:"title",defaultValue:A?.book_title??"",required:!0}),e.jsx(Y,{label:"Author",name:"author",defaultValue:A?.author??"",required:!0}),e.jsx(Y,{label:"Publication",name:"publish",defaultValue:A?.publish??""}),e.jsx(Y,{label:"Qty",name:"quantity",type:"number",defaultValue:A?.quantity??""}),e.jsx(Y,{label:"Book Price",name:"perunitcost",type:"number",defaultValue:A?.perunitcost??""}),e.jsx(Y,{label:"Fine Amount",name:"fine_amount",type:"number",defaultValue:A?.fine_amount??""}),e.jsx(Y,{label:"Barcode",name:"barcode",defaultValue:A?.barcode??""}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Ds,children:"Category"}),e.jsx(Q,{options:M,value:b,onChange:ae=>m(ae??null),name:"cat_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Ds,children:"Class"}),e.jsx(Q,{options:F,value:j,onChange:ae=>D(ae??null),name:"class_id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",style:Ds,children:"Subject"}),e.jsx(Q,{options:q,value:R,onChange:ae=>k(ae??null),name:"subject_id"})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{p(!1),w(null)},children:"Cancel"})]})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Book List"}),extra:o.length>0?e.jsxs(n.Button,{type:"primary",onClick:h,children:["Print Barcode (",o.length,")"]}):null,children:e.jsx(Te,{parentCallback:f,data:{newData:P,columns:J,columnstype:"antd",action:!1,Loading:L,error:y,rowSelection:c}})}),e.jsx("div",{style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"},children:e.jsx("div",{ref:d,style:{padding:"20px"},children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"flex-start"},children:o.map((ae,oe)=>e.jsxs("div",{style:{margin:"10px",textAlign:"center",border:"1px dashed black",padding:"10px",borderRadius:"5px",width:"fit-content"},children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:"bold",maxWidth:"200px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:ae.book_title}),e.jsx(mo,{value:ae.barcode?String(ae.barcode):String(ae.id),format:"CODE128",width:1.5,height:50,fontSize:12,displayValue:!0})]},oe))})})})]})}const Xp=(t,a)=>{const s=String(t??"").replace(/\/+$/,""),i=String(a).replace(/^\/+/,"");return`${s}/${i}`},Ft=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},bn=t=>te(t).add(1,"month").format("YYYY-MM-DD"),Zp=r.forwardRef(({token:t,onReturn:a},s)=>{const i=t??localStorage.getItem("authToken")??"",[o,l]=r.useState("issue"),d=o==="return",[c,g]=r.useState(!1),[h,u]=r.useState(!1),[p,A]=r.useState(null),[w,b]=r.useState([]),[m,j]=r.useState([]),[D,R]=r.useState([]),[k,S]=r.useState(0),[x,f]=r.useState(!1),[_,T]=r.useState(null),[I,B]=r.useState(null),[L,y]=r.useState(null),[P,O]=r.useState(!1),[$,U]=r.useState("Cash"),[N,V]=r.useState(""),[z,E]=r.useState(""),[M,F]=r.useState(0),[q,H]=r.useState("NO_FINE"),re=r.useRef(null),[G]=n.Form.useForm(),[J]=n.Form.useForm(),ae="api/branchapi/library/bookCategorydropdown",oe="api/branchapi/academy/classdropdownlist",pe="api/branchapi/Academy/getClassSubjectdropdown",{data:_e}=W(i?[ae,i]:null,([ue,we])=>K(ue,we)),{data:le}=W(i&&oe?[oe,i]:null,([ue,we])=>K(ue,we)),{data:de}=W(i&&pe?[pe,i]:null,([ue,we])=>K(ue,we)),X=r.useMemo(()=>Ft(_e),[_e]),ce=r.useMemo(()=>Ft(le),[le]),Re=r.useMemo(()=>Ft(de),[de]),Ue="api/branchapi/library/studentsearchByNameID",ke="api/branchapi/library/booksearchBybookname",Ve="api/branchapi/library/issuedBookList",Le="api/branchapi/library/issueLibrarybook",at="api/branchapi/library/returnedLibrarybook",{trigger:Ge,data:Fe}=tt(Ue,(ue,we)=>Gt(ue,we,i)),{trigger:Je,data:it}=tt(ke,(ue,we)=>Gt(ue,we,i)),{trigger:fe,data:Se}=tt(Ve,(ue,we)=>Gt(ue,we,i)),{trigger:je}=tt(d?at:Le,(ue,we)=>as(ue,we,i)),se=r.useMemo(()=>Ft(Fe),[Fe]),me=r.useMemo(()=>Ft(it),[it]),xe=r.useMemo(()=>Ft(Se),[Se]),ie=ue=>{const we=bn(te());b($e=>$e.some(Qe=>String(Qe?.id)===String(ue?.id))?$e:[...$e,{...ue,return_date:ue?.return_date?ue.return_date:we}])},ye=async()=>{console.log("Reloading IssueReturn..."),v.success("Success",{duration:1e3}),j([]),R([]),S(0),H("FINE_PAY_LATER"),await fe({id:p?.student_id})};r.useImperativeHandle(s,()=>({reloadPayLater:ye}));const Ye=ue=>{b(we=>we.filter($e=>String($e?.id)!==String(ue)))},vt=async ue=>{if(i){if(!ue){A(null);return}c||await Ge({id:ue})}},Dt=async({search:ue})=>{if(!i||!c)return;const we=await Ge({id:ue}),$e=Ft(we);$e.length===1&&(A($e[0]),await fe({id:$e[0]?.student_id}),G.resetFields())},xt=async(ue,we)=>{A(we??null),b([]),j([]),R([]),S(0),H("NO_FINE"),F(0),we?.student_id&&await fe({id:we.student_id}),G.resetFields()},Et=async ue=>{i&&ue&&(h||await Je({book:ue}))},Zt=async({search_book:ue})=>{if(!i||!h)return;const we=await Je({book:ue,catID:_?.value??"",sID:L?.value??"",cID:I?.value??""}),$e=Ft(we);$e.length&&(ie($e[0]),J.resetFields())},he=(ue,we)=>{ie(we),J.resetFields()},ve=async()=>{if(!p?.member_id){v.error("Select a student first.",{duration:1e3});return}if(!w.length){v.error("Select at least one book.",{duration:1e3});return}const ue=await je({member_id:p.member_id,fine:!1,books:w});ue?.Status==="Success"&&(v.success(String(ue?.msg??"Success"),{duration:1e3}),b([]),A(null),j([]),R([]),S(0))},lt=async()=>{if(!p?.member_id){v.error("Select a student first.",{duration:1e3});return}if(!D.length){v.error("Select at least one book to return.",{duration:1e3});return}if(Number(k)>0){H("FINE_PAID"),O(!0);return}const ue=await je({member_id:p.member_id,collection_type:"NO_FINE",amount:0,books:JSON.stringify(D)});ue?.Status==="Success"?(v.success(String(ue?.msg??"Success"),{duration:1e3}),j([]),R([]),S(0),await fe({id:p?.student_id})):v.error(String(ue?.msg??"Failed"),{duration:1e3})},bt=async()=>{if(!p?.member_id)return;const ue=Math.max(0,Number(k)-Number(M||0)),we={member_id:p.member_id,collection_type:q,amount:q==="FINE_PAID"?ue:0,payment_type:$,notes:N,attchement:z,discount:M||0,books:JSON.stringify(D)},$e=await je(we);O(!1),$e?.Status==="Success"?(v.success(String($e?.msg??"Success"),{duration:1e3}),j([]),R([]),S(0),F(0),V(""),E(""),H("NO_FINE"),await fe({id:p?.student_id})):v.error(String($e?.msg??"Failed"),{duration:1e3})},on=async()=>{if(!p?.member_id){v.error("Select a student first.",{duration:1e3});return}if(!D.length){v.error("Select at least one book to return.",{duration:1e3});return}const ue={member_id:p.member_id,collection_type:"FINE_PAY_LATER",amount:0,books:JSON.stringify(D)};a(ue)},ln=r.useMemo(()=>Xp(He(),"api/branchapi/frontoffice/uploadfrontofficeDocument"),[]),dn=[{title:"Book",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Author",dataIndex:"author",key:"author",width:180,responsive:["lg"]},{title:"Return Date",key:"return_date",width:160,render:(ue,we)=>e.jsx(Me,{defaultValue:te(we?.return_date||te().add(30,"day")),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:($e,Qe)=>{b(ot=>ot.map(ht=>String(ht?.id)===String(we?.id)?{...ht,return_date:Qe}:ht))}})},{title:"Action",key:"action",width:120,fixed:"right",render:(ue,we)=>e.jsx(n.Button,{type:"text",danger:!0,onClick:()=>Ye(we?.id),children:"Remove"})}],cn={selectedRowKeys:m,onChange:(ue,we)=>{j(ue),R(we);const $e=(we??[]).reduce((Qe,ot)=>Qe+Number(ot?.totalfine??0),0);S($e)},onSelect:(ue,we,$e)=>{if(we){const Qe=$e.map(ot=>({...ot,return_date:ot?.return_date?ot.return_date:bn(ot?.issue_date||te())}));R(Qe)}},onSelectAll:(ue,we)=>{if(ue){const $e=we.map(Qe=>({...Qe,return_date:Qe?.return_date?Qe.return_date:bn(Qe?.issue_date||te())}));R($e)}}},un=[{title:"Book",dataIndex:"book_title",key:"book_title",width:220,ellipsis:!0,fixed:"left"},{title:"Barcode",dataIndex:"barcode",key:"barcode",width:140,responsive:["sm"]},{title:"Issue Date",dataIndex:"issue_date",key:"issue_date",width:140,responsive:["lg"]},{title:"Return Date",key:"return_date",width:160,render:(ue,we)=>{const Qe=D.find(ht=>String(ht?.id)===String(we?.id))?.return_date||we?.return_date,ot=bn(we?.issue_date||te());return e.jsx(Me,{defaultValue:te(Qe||ot),Desplay:"",format:"YYYY-MM-DD",allowClear:!1,onChange:(ht,cs)=>{R(us=>us.map(wa=>String(wa?.id)===String(we?.id)?{...wa,return_date:cs}:wa))}})}},{title:"Days",key:"days",width:100,render:(ue,we)=>{const Qe=D.find(ht=>String(ht?.id)===String(we?.id))?.return_date||we?.return_date,ot=we?.issue_date;if(ot&&Qe){const ht=te(Qe).diff(te(ot),"day");return ht>=0?ht:0}return"-"}},{title:"Due Date",dataIndex:"due_date",key:"due_date",width:140,responsive:["lg"]},{title:"Fine",dataIndex:"totalfine",key:"totalfine",width:120,fixed:"right",render:ue=>e.jsxs("span",{children:["₹ ",ue]})}];return e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:P,onCancel:()=>O(!1),footer:null,title:"Payment Options",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsx(n.Radio.Group,{value:$,onChange:ue=>U(ue.target.value),options:[{label:"Cash",value:"Cash"},{label:"UPI",value:"UPI"},{label:"DD",value:"DD"},{label:"Bank",value:"Bank"},{label:"Internet Banking",value:"Internet Banking"},{label:"Cheque",value:"Cheque"}]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Note"}),e.jsx(n.Input.TextArea,{rows:3,value:N,onChange:ue=>V(ue.target.value)})]}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{className:"labelfont",children:"Image Attachment"}),e.jsx(n.Upload,{action:ln,headers:{Authorization:i},maxCount:1,onChange:ue=>{if(ue.file.status==="done"){const we=ue.file.response?.data??ue.file.response?.file??"";E(String(we??""))}},children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),children:"Upload"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Discount"}),e.jsx(n.Input,{type:"number",value:M,onChange:ue=>F(ue.target.value),placeholder:"0"})]}),e.jsxs(n.Button,{type:"primary",onClick:bt,children:["Collect ₹",Math.max(0,Number(k)-Number(M||0))]}),e.jsx(n.Button,{onClick:()=>O(!1),children:"Cancel"})]})}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Issue / Return"}),children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:10,children:e.jsx(n.Radio.Group,{value:o,onChange:ue=>{const we=ue.target.value;l(we),b([]),j([]),R([]),S(0),H("NO_FINE"),F(0)},options:[{label:"Issue",value:"issue"},{label:"Return",value:"return"},{label:"Renewal",value:"Renewal"}],optionType:"button",buttonStyle:"solid"})}),e.jsx(n.Col,{xs:24,md:14,children:e.jsx(n.Form,{form:G,onFinish:Dt,layout:"vertical",children:e.jsx(n.Form.Item,{name:"search",label:"Search Student",children:e.jsx(n.Space.Compact,{style:{width:"100%"},children:c?e.jsx(n.Input,{autoFocus:!0,addonBefore:e.jsxs(n.Space,{children:[e.jsx(ee.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:c,onChange:ue=>g(ue.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(n.AutoComplete,{options:se,onSelect:xt,onSearch:vt,style:{width:"100%"},allowClear:!0,children:e.jsx(n.Input,{addonBefore:e.jsxs(n.Space,{children:[e.jsx(ee.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:c,onChange:ue=>g(ue.target.checked)})]}),placeholder:"Type student name / id",allowClear:!0})})})})})})]}),p?e.jsxs(e.Fragment,{children:[e.jsx(n.Divider,{}),e.jsxs(n.Row,{gutter:[12,12],children:[e.jsxs(n.Col,{xs:24,md:8,children:[e.jsx(n.Typography.Text,{strong:!0,children:"Name:"})," ",p?.value??""]}),e.jsxs(n.Col,{xs:24,md:8,children:[e.jsx(n.Typography.Text,{strong:!0,children:"Card No:"})," ",p?.library_card_no??""]}),e.jsxs(n.Col,{xs:24,md:8,children:[e.jsx(n.Typography.Text,{strong:!0,children:"Member ID:"})," ",p?.member_id??""]})]})]}):null,e.jsx(n.Divider,{}),d?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:760},children:e.jsx(n.Table,{dataSource:xe,columns:un,rowSelection:cn,pagination:!1,rowKey:ue=>ue?.id??ue?.issue_id??ue?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(n.Divider,{}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap"},children:[e.jsxs(n.Typography.Text,{strong:!0,children:["Total Fine: ₹",k]}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsx(n.Button,{type:"primary",onClick:lt,disabled:!D.length,children:k>0?`Pay Now ₹ ${Math.max(0,Number(k)-Number(M||0))}`:"Return Selected"}),k>0?e.jsx(n.Button,{onClick:on,disabled:!D.length,children:"Pay Later"}):null]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(n.Row,{gutter:[16,16],align:"middle",children:[e.jsx(n.Col,{xs:24,md:18,children:e.jsx(n.Form,{form:J,onFinish:Zt,layout:"vertical",children:e.jsx(n.Form.Item,{name:"search_book",label:"Search Book",children:e.jsx(n.Space.Compact,{style:{width:"100%"},children:h?e.jsx(n.Input,{autoFocus:!0,disabled:!p,addonBefore:e.jsxs(n.Space,{children:[e.jsx(ee.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:h,onChange:ue=>u(ue.target.checked)})]}),placeholder:"Scan barcode",allowClear:!0}):e.jsx(n.AutoComplete,{disabled:!p,options:me,onSelect:he,onSearch:Et,style:{width:"100%"},allowClear:!0,children:e.jsx(n.Input,{addonBefore:e.jsxs(n.Space,{children:[e.jsx(ee.BarcodeOutlined,{}),e.jsx(n.Checkbox,{checked:h,onChange:ue=>u(ue.target.checked)})]}),placeholder:"Type book name",allowClear:!0})})})})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(n.Button,{style:{width:"100%"},icon:e.jsx(ee.FilterOutlined,{}),onClick:()=>f(!0),children:"Filter"})})]}),e.jsx(n.Drawer,{open:x,onClose:()=>f(!1),title:"Filter",placement:"right",width:380,destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Q,{label:"Category",options:X,value:_,onChange:ue=>T(ue??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"cat_id"}),e.jsx(Q,{label:"Class",options:ce,value:I,onChange:ue=>B(ue??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"class_id"}),e.jsx(Q,{label:"Subjects",options:Re,value:L,onChange:ue=>y(ue??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"subject_id"}),e.jsx(n.Button,{type:"primary",onClick:()=>f(!1),children:"Apply"})]})}),e.jsx(n.Divider,{}),e.jsx("div",{style:{width:"100%",overflowX:"auto"},children:e.jsx("div",{style:{minWidth:720},children:e.jsx(n.Table,{dataSource:w,columns:dn,pagination:!1,rowKey:ue=>ue?.id??ue?.book_id??ue?.barcode??Math.random(),scroll:{x:"max-content"},size:"small"})})}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Issue",onClick:ve})})]})]}),e.jsx("div",{ref:re,style:{position:"fixed",left:-1e4,top:0,width:0,height:0,overflow:"hidden"}})]})}),pi=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function em({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,i]=r.useState({page:1,rowsPerPage:10}),[o,l]=r.useState(null),[d,c]=r.useState(null),[g,h]=r.useState(!1),[u,p]=r.useState(!1),[A,w]=r.useState(null),[b,m]=r.useState(!1),j="api/branchapi/academy/classdropdownlist",D="api/branchapi/academy/sectionoftheClass",R="api/branchapi/library/studenttableForLibrary",k="api/branchapi/library/addmembershipforStudent",S="api/branchapi/library/removemembershipforStudent",x=r.useMemo(()=>{if(!o?.value)return null;const E=D.includes("?")?"&":"?";return`${D}${E}class_id=${encodeURIComponent(String(o.value))}`},[D,o?.value]),f=r.useMemo(()=>{if(!o?.value||!d?.value)return null;const E=R.includes("?")?"&":"?";return`${R}${E}cID=${encodeURIComponent(String(o.value))}&sID=${encodeURIComponent(String(d.value))}&page=${s.page}&per_page=${s.rowsPerPage}`},[s.page,s.rowsPerPage,o?.value,d?.value,R]),{data:_}=W(a&&j?[j,a]:null,([E,M])=>K(E,M)),{data:T}=W(a&&x?[x,a]:null,([E,M])=>K(E,M)),{isLoading:I,error:B,data:L,mutate:y}=W(a&&f?[f,a]:null,([E,M])=>K(E,M)),P=r.useMemo(()=>pi(_),[_]),O=r.useMemo(()=>pi(T),[T]),$=(E,M)=>{i({page:E,rowsPerPage:parseInt(M,10)})},U=E=>{const M=E?.id??E?.student_id??E?.member_id;w(M??null),p(!0),m(F=>!F)},N=async E=>{if(E.preventDefault(),!A)return;const M=new FormData(E.target);M.set("id",String(A));try{await Ee(k,M,a),v.success("Success! Added member.",{duration:1e3,icon:"🎉"}),p(!1),w(null),await y()}catch(F){v.error(F?.response?.data?.msg??"Failed to add the member.",{duration:1e3})}},V=async E=>{try{await qe(S,E,a),v.success("Success! Removed member.",{duration:1e3}),await y()}catch(M){v.error(M?.response?.data?.msg??"Failed to remove member.",{duration:1e3})}},z=r.useMemo(()=>[{title:"Library Card No",dataIndex:"library_card_no",key:"library_card_no",width:180,ellipsis:!0,fixed:"left"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:140,responsive:["sm"]},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:90,responsive:["lg"]},{title:"First Name",dataIndex:"firstname",key:"firstname",width:140,responsive:["sm"]},{title:"Last Name",dataIndex:"lastname",key:"lastname",width:140,responsive:["lg"]},{title:"Class",dataIndex:"class",key:"class",width:120,responsive:["xl"]},{title:"Section",dataIndex:"section",key:"section",width:120,responsive:["xl"]},{title:"Mobile",dataIndex:"mobileno",key:"mobileno",width:140,responsive:["lg"]},{title:"Action",key:"action",width:80,fixed:"right",render:(E,M)=>(console.log("data______________",M),e.jsx("div",{style:{display:"flex",gap:8,alignItems:"center"},children:M?.library_card_no==null?e.jsx(n.Button,{type:"primary",size:"small",icon:e.jsx(ee.UserAddOutlined,{}),onClick:()=>U(M)}):e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{}),onClick:()=>V(M?.id??M?.student_id??M?.member_id)})}))}],[V]);return e.jsxs("div",{style:{},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:u,title:"Add Member",onCancel:()=>{p(!1),w(null)},footer:null,destroyOnClose:!0,children:e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Y,{type:"text",label:"Library Card Number",name:"library_num",required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Add",color:"primary"})})]})},`add-${b}`)}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Student"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Q,{options:P,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",value:o,onChange:E=>{l(E??null),c(null),h(M=>!M)},name:"class_id",required:!0,allowSelectAll:!1}),e.jsx(Q,{options:O,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",value:d,onChange:E=>c(E??null),allowSelectAll:!1,name:"section_id",required:!0},`section-${g}`),e.jsx(ne,{type:"submit",value:"Search",color:"primary",onClick:()=>{if(!o?.value||!d?.value){v.error("Select class and section.",{duration:1e3});return}i(E=>({...E,page:1}))}})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Students"}),children:e.jsx(Te,{parentCallback:$,data:{newData:L,columns:z,columnstype:"antd",action:!1,Loading:I,error:B}})})]})}function tm({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,i]=r.useState({page:1,rowsPerPage:10}),[o]=n.Form.useForm(),[l]=n.Form.useForm(),[d,c]=r.useState(!1),[g,h]=r.useState(null),u="api/branchapi/library/BookCategorytable",p="api/branchapi/library/addBookCategory",A="api/branchapi/library/editBookCategory",w="api/branchapi/library/deleteBookCategory",b=r.useMemo(()=>{const B=u.includes("?")?"&":"?";return`${u}${B}page=${s.page}&per_page=${s.rowsPerPage}`},[u,s.page,s.rowsPerPage]),{isLoading:m,error:j,data:D,mutate:R}=W(a&&b?[b,a]:null,([B,L])=>K(B,L)),k=(B,L)=>{i({page:B,rowsPerPage:parseInt(L,10)})},S=async B=>{const L=new FormData;L.set("title",B?.title??"");try{await Ee(p,L,a),v.success("Success! Added new category.",{duration:1e3,icon:"🎉"}),o.resetFields(),await R()}catch(y){v.error(y?.response?.data?.msg??y?.message??"Failed to add category.",{duration:1e3})}},x=B=>{h(B??null),l.setFieldsValue({title:B?.name??""}),c(!0)},f=()=>{c(!1),h(null),l.resetFields()},_=async B=>{const L=g?.id??g?.category_id??g?.cat_id;if(!L){v.error("Missing category id.",{duration:1e3});return}const y=new FormData;y.set("id",String(L)),y.set("title",B?.title??"");try{await Be(A,y,a),v.success("Success! Updated category.",{duration:1e3,icon:"🚀"}),f(),await R()}catch(P){v.error(P?.response?.data?.msg??P?.message??"Failed to update category.",{duration:1e3})}},T=async B=>{const L=B?.id??B?.category_id??B?.cat_id;if(!L){v.error("Missing category id.",{duration:1e3});return}try{await qe(w,L,a),v.success("Success! Deleted category.",{duration:1e3}),await R()}catch(y){v.error(y?.response?.data?.msg??y?.message??"Failed to delete category.",{duration:1e3})}},I=r.useMemo(()=>[{title:"Category Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(B,L)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>x(L)}),e.jsx(n.Popconfirm,{title:"Remove category?",okText:"Yes",cancelText:"No",onConfirm:()=>T(L),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[T]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:d,title:"Edit Category",onCancel:f,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:l,layout:"vertical",onFinish:_,children:[e.jsx(n.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(n.Input,{placeholder:"Enter category name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:f,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,lg:8,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Category"}),children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:S,children:[e.jsx(n.Form.Item,{label:"Name",name:"title",rules:[{required:!0,message:"Enter category name"}],children:e.jsx(n.Input,{placeholder:"Enter category name"})}),e.jsx(ne,{type:"submit",value:"Add",color:"primary"})]})})}),e.jsx(n.Col,{xs:24,lg:16,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Category List"}),children:e.jsx(Te,{parentCallback:k,data:{newData:D,columns:I,columnstype:"antd",action:!1,Loading:m,error:j}})})})]})]})}const Rs=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function am({token:t}){const[a,s]=r.useState([te().format("YYYY-MM-DD"),te().format("YYYY-MM-DD")]),[i,o]=r.useState(null),[l,d]=r.useState(null),[c,g]=r.useState(null),[h,u]=r.useState(!1),[p,A]=r.useState(!1),w="api/branchapi/academy/classdropdownlist",b="api/branchapi/academy/sectionoftheClass",m="api/branchapi/library/memberDropdown",j="api/report/libraryReport/libraryReport",D=r.useMemo(()=>{if(!i?.value)return null;const U=b.includes("?")?"&":"?";return`${b}${U}class_id=${encodeURIComponent(String(i.value))}`},[b,i?.value]),R=r.useMemo(()=>{if(!i?.value)return null;const U=m.includes("?")?"&":"?",N=`${m}${U}class=${encodeURIComponent(String(i.value))}`;return l?.value?`${N}§ion=${encodeURIComponent(String(l.value))}`:N},[m,i?.value,l?.value]),{isLoading:k,error:S,data:x,mutate:f}=W(t&&w?[w,t]:null,([U,N])=>K(U,N)),{data:_}=W(t&&D?[D,t]:null,([U,N])=>K(U,N)),{data:T}=W(t&&R?[R,t]:null,([U,N])=>K(U,N)),I=r.useMemo(()=>Rs(x),[x]),B=r.useMemo(()=>Rs(_),[_]),L=r.useMemo(()=>Rs(T),[T]),{trigger:y,data:P}=tt(j,(U,N)=>tr(U,N,t));r.useEffect(()=>{(async()=>{A(!0);try{await y({duration:a})}finally{A(!1)}})()},[]);const O=async()=>{A(!0);try{await y({duration:a,class:i?.value??"",section:l?.value??"",student_id:c?.value??""})}finally{A(!1)}},$=[{title:"Name",dataIndex:"full_name",render:(U,N)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:N?.full_name??""})},{title:"Roll No",dataIndex:"roll_no",render:(U,N)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:N?.roll_no??""})},{title:"Class",dataIndex:"Class",key:"Class",render:(U,N)=>e.jsxs(n.Typography.Text,{style:{fontSize:12},children:[N?.class??"","(",N?.section??"",")"]})},{title:"Book",dataIndex:"book_title",render:(U,N)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:N?.book_title??""})},{title:"Issue Date",key:"date",render:(U,N,V)=>e.jsx(n.Typography.Text,{style:{fontSize:12},children:N?.issue_date??""})},{title:"Due Return Date",key:"date",render:(U,N,V)=>e.jsx(n.Tag,{color:"orange",children:N?.return_date??""})},{title:"Return Date",key:"date",render:(U,N,V)=>N?.retured_by_user?e.jsx(n.Tag,{color:"green",children:N?.retured_by_user??""}):null},{title:"Return Status",key:"date",render:(U,N,V)=>String(N?.is_returned??"")==="1"?e.jsx(n.Tag,{color:"green",children:"Return"}):e.jsx(n.Tag,{color:"red",children:"Not Return"})},{title:"Fine",key:"amount",dataIndex:"late_fine",render:(U,N,V)=>{const z=N?.late_fine?Number(N.late_fine):0;return z?e.jsx(n.Typography.Text,{style:{fontSize:12,color:"#cf1322"},children:z}):null}}];return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Library Monthly Report"}),style:{borderRadius:16},children:[e.jsxs(n.Row,{gutter:[16,16],align:"bottom",children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsxs("div",{children:[e.jsx("label",{className:"labelfont",children:"Duration"}),e.jsx(n.DatePicker.RangePicker,{style:{width:"100%"},value:[te(a[0],"YYYY-MM-DD"),te(a[1],"YYYY-MM-DD")],format:"YYYY-MM-DD",onChange:(U,N)=>{Array.isArray(N)&&N.length===2&&s([N[0],N[1]])}})]})}),e.jsx(n.Col,{xs:24,md:5,children:e.jsx(Q,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Classes",name:"class_id",value:i,onChange:U=>{o(U??null),d(null),g(null),u(N=>!N)},allowSelectAll:!1})}),e.jsx(n.Col,{xs:24,md:5,children:e.jsx(Q,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",value:l,onChange:U=>{d(U??null),g(null)},allowSelectAll:!1},`section1${h}`)}),e.jsx(n.Col,{xs:24,md:5,children:e.jsx(Q,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student",value:c,onChange:U=>g(U??null),allowSelectAll:!1})}),e.jsx(n.Col,{xs:24,md:1,children:e.jsx(n.Button,{type:"primary",icon:e.jsx(ee.SearchOutlined,{}),onClick:O,style:{width:"100%"},children:"Search"})})]}),e.jsx("div",{style:{marginTop:16},children:e.jsx(n.Table,{columns:$,pagination:!1,dataSource:Array.isArray(P?.data)?P.data:[],size:"small",rowKey:(U,N)=>U?.id??U?.issue_id??U?.fees_receipt_id??N,loading:p,scroll:{x:"max-content"},summary:U=>{const N=U.reduce((z,E)=>z+Number(E?.late_fine??0),0),V=U.reduce((z,E)=>z+Number(E?.is_returned??0),0);return e.jsxs(n.Table.Summary.Row,{children:[e.jsx(n.Table.Summary.Cell,{colSpan:4,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Book: ",U.length]})}),e.jsx(n.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Not Return: ",Number(U.length-V)]})}),e.jsx(n.Table.Summary.Cell,{colSpan:2,children:e.jsxs("span",{style:{fontWeight:700},children:["Return: ",V]})}),e.jsx(n.Table.Summary.Cell,{colSpan:1,children:e.jsxs("span",{style:{fontWeight:700},children:["Total Fine:",N.toLocaleString("en-IN")]})})]})}})})]})]})}const mi=[{label:"Today",value:"Today"},{label:"Yesterday",value:"Yesterday"},{label:"This Week",value:"This Week"},{label:"This Month",value:"This Month"},{label:"Last Month",value:"Last Month"},{label:"This Year",value:"This Year"},{label:"Custom",value:"Custom"}],hi=[{key:"renewalHistory",label:"Renewal History"},{key:"renewalFineReport",label:"Renewal + Fine"},{key:"currentlyRenewedBooks",label:"Currently Renewed"},{key:"upcomingRenewalDue",label:"Upcoming Due"},{key:"overdueRenewalReport",label:"Overdue"},{key:"renewalLimitReport",label:"Renewal Limit"},{key:"renewalStatusReport",label:"Renewal Status"},{key:"studentWiseReport",label:"Student-wise"},{key:"bookWiseReport",label:"Book-wise"},{key:"classWiseReport",label:"Class-wise"},{key:"staffWiseReport",label:"Staff-wise"},{key:"renewalStatisticsByDate",label:"Statistics by Date"}];function nm({token:t}){const a=t??localStorage.getItem("authToken")??"",[s,i]=r.useState("renewalHistory"),[o,l]=r.useState("This Month"),[d,c]=r.useState(""),[g,h]=r.useState(""),[u,p]=r.useState(7),[A,w]=r.useState(1),[b,m]=r.useState(20),[j,D]=r.useState(""),[R,k]=r.useState("DESC"),S=r.useRef(null),x=N=>{const V=new URLSearchParams;return["renewalHistory","renewalFineReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport","renewalStatisticsByDate"].includes(s)&&(V.set("date_range",o),o==="Custom"&&d&&g&&(V.set("from_date",d),V.set("to_date",g))),["renewalHistory","renewalFineReport","currentlyRenewedBooks","upcomingRenewalDue","overdueRenewalReport","renewalLimitReport","renewalStatusReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport"].includes(s)&&(V.set("page",String(A)),V.set("per_page",String(b))),s==="upcomingRenewalDue"&&V.set("days_ahead",String(u)),j&&V.set("sort_by",j),R&&V.set("sort_dir",R),`${N}?${V.toString()}`},f=r.useMemo(()=>{switch(s){case"renewalHistory":return x(uc);case"renewalFineReport":return x(pc);case"currentlyRenewedBooks":return x(mc);case"upcomingRenewalDue":return x(hc);case"overdueRenewalReport":return x(fc);case"renewalLimitReport":return x(yc);case"renewalStatusReport":return x(gc);case"studentWiseReport":return x(xc);case"bookWiseReport":return x(bc);case"classWiseReport":return x(jc);case"staffWiseReport":return x(Sc);case"renewalStatisticsByDate":return x(wc);default:return null}},[s,o,d,g,u,A,b]),{data:_,isLoading:T}=W(a?[f,a]:null,([N,V])=>K(N,V)),I=_?.data||{},B=I?.rows||[],L=I?.pagination||{},y=N=>{i(N),w(1),m(20)},P=()=>{w(1)},O=()=>{switch(s){case"renewalHistory":case"renewalFineReport":return[{title:"Renewal ID",dataIndex:"renewal_id",key:"renewal_id"},{title:"Student",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Book",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Renewal No",dataIndex:"renewal_no",key:"renewal_no"},{title:"Old Due Date",dataIndex:"old_due_date",key:"old_due_date"},{title:"New Due Date",dataIndex:"new_due_date",key:"new_due_date"},{title:"Renewal Date",dataIndex:"renewal_date",key:"renewal_date"},{title:"Status",dataIndex:"status",key:"status",render:N=>e.jsx(n.Tag,{color:N==="renewed"?"green":"red",children:N})},{title:"Fine Amount",dataIndex:"fine_amount",key:"fine_amount",render:N=>N??"-"},{title:"Paid Amount",dataIndex:"paid_amount",key:"paid_amount",render:N=>N??"-"},{title:"Due Amount",dataIndex:"due_amount",key:"due_amount",render:N=>N??"-"},{title:"Fine Status",dataIndex:"fine_payment_status",key:"fine_payment_status",render:N=>N?e.jsx(n.Tag,{color:N==="paid"?"green":N==="partial"?"orange":"red",children:N}):"-"}];case"currentlyRenewedBooks":case"upcomingRenewalDue":case"overdueRenewalReport":case"renewalLimitReport":case"renewalStatusReport":return[{title:"Student",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Book",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Due Date",dataIndex:"return_date",key:"return_date"},{title:"Renewal Count",dataIndex:"renewal_count",key:"renewal_count"},{title:"Max Renewal",dataIndex:"maximum_renewal",key:"maximum_renewal"},{title:"Days Remaining",dataIndex:"days_remaining",key:"days_remaining",render:N=>N??"-"},{title:"Overdue Days",dataIndex:"overdue_days",key:"overdue_days",render:N=>N??"-"},{title:"Fine",dataIndex:"fine_amount",key:"fine_amount",render:N=>N??"-"},{title:"Due",dataIndex:"due_amount",key:"due_amount",render:N=>N??"-"},{title:"Can Renew",dataIndex:"can_renew",key:"can_renew",render:N=>e.jsx(n.Tag,{color:N?"green":"red",children:N?"Yes":"No"})},{title:"Reasons",dataIndex:"reasons",key:"reasons",render:N=>Array.isArray(N)?N.join("; "):"-"}];case"studentWiseReport":return[{title:"Student ID",dataIndex:"student_id",key:"student_id"},{title:"Student Name",dataIndex:"student_name",key:"student_name"},{title:"Admission No",dataIndex:"admission_no",key:"admission_no"},{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Books",dataIndex:"unique_books_renewed",key:"unique_books_renewed"},{title:"First Renewal",dataIndex:"first_renewal_date",key:"first_renewal_date"},{title:"Last Renewal",dataIndex:"last_renewal_date",key:"last_renewal_date"}];case"bookWiseReport":return[{title:"Book ID",dataIndex:"book_id",key:"book_id"},{title:"Title",dataIndex:"book_title",key:"book_title"},{title:"Author",dataIndex:"author",key:"author"},{title:"Barcode",dataIndex:"barcode",key:"barcode"},{title:"Category",dataIndex:"category",key:"category"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"}];case"classWiseReport":return[{title:"Class",dataIndex:"class",key:"class"},{title:"Section",dataIndex:"section",key:"section"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"}];case"staffWiseReport":return[{title:"Staff",dataIndex:"renewed_by",key:"renewed_by"},{title:"Staff Name",dataIndex:"staff_name",key:"staff_name"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"},{title:"Unique Books",dataIndex:"unique_books",key:"unique_books"}];case"renewalStatisticsByDate":return[{title:"Period",dataIndex:"period",key:"period"},{title:"Total Renewals",dataIndex:"total_renewals",key:"total_renewals"},{title:"Unique Students",dataIndex:"unique_students",key:"unique_students"},{title:"Unique Books",dataIndex:"unique_books",key:"unique_books"}];default:return[]}},$=["renewalHistory","renewalFineReport","studentWiseReport","bookWiseReport","classWiseReport","staffWiseReport","renewalStatisticsByDate"].includes(s),U=r.useMemo(()=>O(),[s]);return e.jsx(C,{pt:5,pb:1,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,padding:"4px 8px",color:"#fff",display:"inline-block"}}),e.jsxs(C,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],mb:3,children:[$&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Q,{options:mi,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Date Range",allowSelectAll:!1,value:mi.find(N=>N.value===o)||null,onChange:N=>l(N?.value||"This Month")})}),o==="Custom"&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Me,{Desplay:"From Date",format:"YYYY-MM-DD",onChange:N=>c(N?N.format("YYYY-MM-DD"):"")})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Me,{Desplay:"To Date",format:"YYYY-MM-DD",onChange:N=>h(N?N.format("YYYY-MM-DD"):"")})})]})]}),s==="upcomingRenewalDue"&&e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Q,{options:[{label:"7 Days",value:7},{label:"14 Days",value:14},{label:"30 Days",value:30}],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Days Ahead",allowSelectAll:!1,value:{label:u+" Days",value:u},onChange:N=>p(N?.value||7)})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(C,{display:"flex",alignItems:"center",height:"100%",mt:2,children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:P})})})]}),e.jsx(n.Tabs,{activeKey:s,onChange:y,items:hi})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:hi.find(N=>N.key===s)?.label||"Report"})}),e.jsxs(C,{p:3,children:[e.jsx(wt,{data:{tableRef:S}}),T?e.jsx(C,{py:8,textAlign:"center",children:e.jsx(n.Typography.Text,{type:"secondary",children:"Loading report data..."})}):e.jsx(n.Table,{size:"small",dataSource:B,columns:U,loading:T,pagination:!1,bordered:!0,rowKey:N=>N.renewal_id||N.id||JSON.stringify(N),ref:S}),B.length>0&&e.jsx(n.Pagination,{current:A,pageSize:b,total:L.total_rows||B.length,onChange:(N,V)=>{w(N),m(V)},showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:[10,20,50,100],style:{marginTop:16,textAlign:"right"}})]})]})})]})})}const ns=t=>t??localStorage.getItem("authToken")??"",sm=(t,a)=>{const s=String(t??""),i=String(a);return s?i?s.endsWith("/")&&i.startsWith("/")?`${s}${i.slice(1)}`:!s.endsWith("/")&&!i.startsWith("/")?`${s}/${i}`:`${s}${i}`:s:i},Ke={upload:"api/branchapi/frontoffice/uploadfrontofficeDocument",academy:{classes:"api/branchapi/academy/classdropdownlist",sections:"api/branchapi/academy/sectionoftheClass"},student:{dropdown:"api/branchapi/student/studentDropdown"},vendor:{list:"api/accounts/vendor/vendorTable",add:"api/accounts/vendor/addvendor",edit:"api/accounts/vendor/editVendor",remove:"api/accounts/vendor/removecategory",dropdown:"api/accounts/vendor/vendorlist"},category:{list:"api/accounts/category/fetchcategorytable",add:"api/accounts/category/addcategory",edit:"api/accounts/category/editcategory",remove:"api/accounts/category/removecategory",dropdown:"api/accounts/category/categoryDropdown"},subCategory:{list:"api/accounts/category/fetchsubcategorytable",add:"api/accounts/category/addsubcategory",edit:"api/accounts/category/editsubcategory",remove:"api/accounts/category/removesubcategory",dropdown:"api/accounts/category/subcategoryDropdown"},unit:{list:"api/accounts/category/fetchunit",add:"api/accounts/category/addunit",edit:"api/accounts/category/editunit",remove:"api/accounts/category/removeunit",dropdown:"api/accounts/category/unitDropdown"},product:{list:"api/accounts/product/fetchproducttable",add:"api/accounts/product/addproduct",edit:"api/accounts/product/editproduct",remove:"api/accounts/product/removeproduct",dropdown:"api/accounts/product/productdropdown",search:"api/accounts/product/searchproductbyNameandBarcode",addStock:"api/accounts/product/addStock",sellProduct:"api/accounts/product/sellproduct",sellReports:"api/accounts/product/getstoreSellReports"},report:{stock:"api/report/StoreReport/stock_report"}},rm=()=>sm(He(),Ke.upload),im=async({baseUrl:t,page:a=1,perPage:s=10},i)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return K(l,ns(i))},en=async(t,a,s)=>Ee(t,a,ns(s)),ja=async(t,a,s)=>Be(t,a,ns(s)),tn=async(t,a,s)=>qe(t,a,ns(s)),om=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",ya=({token:t,value:a,onChange:s})=>{const i=r.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(n.Upload,{maxCount:1,action:rm(),headers:i,onChange:o=>{if(o?.file?.status==="done"){const l=om(o?.file?.response);l&&s?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:"Upload"})})},Mn=Ke.vendor,an=({baseUrl:t,page:a=1,perPage:s=10,token:i})=>W(i&&t?[t,a,s,i]:null,([l,d,c,g])=>im({baseUrl:l,page:d,perPage:c},g)),lm=({token:t,page:a=1,perPage:s=10})=>an({baseUrl:Mn.list,page:a,perPage:s,token:t}),dm={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},fi=[{name:"name",label:"Name*",required:!0,type:"text"},{name:"email",label:"Email*",required:!0,type:"text"},{name:"address",label:"Address*",required:!0,type:"text"},{name:"phone",label:"Phone*",required:!0,type:"number"},{name:"business_name",label:"Brand Name*",required:!0,type:"text"},{name:"acc_number",label:"Account Number",required:!1,type:"text"},{name:"ifsc_code",label:"IFSC Code",required:!1,type:"text"},{name:"acc_holder_name",label:"Account Holder Name",required:!1,type:"text"},{name:"gst_number",label:"GST Number",required:!1,type:"text"},{name:"cin_num",label:"CIN Number",required:!1,type:"text"},{name:"upi_id",label:"UPI ID",required:!1,type:"text"}];function cm({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(null),[c,g]=r.useState(""),{isLoading:h,error:u,data:p,mutate:A}=lm({token:t,page:a.page,perPage:a.rowsPerPage}),w=async S=>{try{await A(en(Mn.add,S,t),ze(S)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(x){v.error(x?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},b=S=>{S.preventDefault();const x=new FormData(S.target);c&&x.set("image",c),w(x),S.target.reset(),g("")},m=(S,x)=>{s({page:S,rowsPerPage:parseInt(x,10)})},j=async S=>{try{await A(tn(Mn.remove,S,t),Ne(S)),v.success("Success! Deleted item.",{duration:1e3})}catch(x){v.error(x?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},D=S=>{d(S),o(!0),g("")},R=async S=>{S.preventDefault();const x=new FormData(S.target);x.set("id",String(l?.id??"")),c&&x.set("image",c);try{await ja(Mn.edit,x,t),await A(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),g("")}catch(f){v.error(f?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},k=r.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Email",dataIndex:"email",key:"email",ellipsis:!0,responsive:["md"]},{title:"Address",dataIndex:"address",key:"address",ellipsis:!0,responsive:["lg"]},{title:"Phone",dataIndex:"phone",key:"phone",ellipsis:!0,responsive:["md"]},{title:"Branch Name",dataIndex:"business_name",key:"business_name",ellipsis:!0,responsive:["lg"]},{title:"Account Holder",dataIndex:"acc_holder_name",key:"acc_holder_name",ellipsis:!0,responsive:["xl"]},{title:"Account Number",dataIndex:"acc_number",key:"acc_number",ellipsis:!0,responsive:["xl"]},{title:"UPI ID",dataIndex:"upi_id",key:"upi_id",ellipsis:!0,responsive:["xl"]},{title:"Action",key:"action",width:100,fixed:"right",render:(S,x)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>D(x),style:{padding:2}}),e.jsx(mt,{id:x?.id,funcName:j})]})}],[j]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:i,title:l?.name?`Edit ${l.name}`:"Edit Vendor",placement:"right",width:520,onClose:()=>{o(!1),d(null),g("")},children:e.jsx("form",{onSubmit:R,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[fi.map(S=>e.jsx(Y,{type:S.type,name:S.name,label:S.label,defaultValue:l?.[S.name]??"",required:S.required?"required":void 0},S.name)),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:g})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null),g("")},style:dm,children:"Cancel"})]})]})})}),e.jsxs(C,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Add Vendor"})}),e.jsx(C,{px:3,pb:2,children:e.jsx("form",{onSubmit:b,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16,alignItems:"end"},children:[fi.map(S=>e.jsx(Y,{type:S.type,name:S.name,label:S.label,required:S.required?"required":void 0},S.name)),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:g})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Add Vendor",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Vendors List"})}),e.jsx(C,{pt:3,children:e.jsx(Te,{parentCallback:m,data:{newData:p,columns:k,columnstype:"antd",action:!1,Loading:h,error:u}})})]})]})]})}const um=({token:t})=>e.jsx(cm,{token:t}),En=Ke.product,yi=Ke.vendor.dropdown,gi=Ke.category.dropdown,pm=Ke.subCategory.dropdown,xi=Ke.unit.dropdown,nl=({token:t,page:a=1,perPage:s=10})=>an({baseUrl:En.list,page:a,perPage:s,token:t}),mm=({token:t})=>W(t&&yi?[yi,t]:null,([s,i])=>K(s,i)),hm=({token:t})=>W(t&&gi?[gi,t]:null,([s,i])=>K(s,i)),fm=({token:t})=>W(t&&xi?[xi,t]:null,([s,i])=>K(s,i)),ym=({token:t,categoryId:a})=>{const s=t&&a?`${pm}?category_id=${encodeURIComponent(String(a))}`:null;return W(s?[s,t]:null,([o,l])=>K(o,l))},jn=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},gm={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function xm({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(null),[c,g]=r.useState(""),[h,u]=r.useState(""),[p,A]=r.useState(""),[w,b]=r.useState(""),[m,j]=r.useState(""),{isLoading:D,error:R,data:k,mutate:S}=nl({token:t,page:a.page,perPage:a.rowsPerPage}),{data:x}=mm({token:t}),{data:f}=hm({token:t}),{data:_}=fm({token:t}),{data:T}=ym({token:t,categoryId:h}),I=r.useMemo(()=>jn(x),[x]),B=r.useMemo(()=>jn(f),[f]),L=r.useMemo(()=>jn(_),[_]),y=r.useMemo(()=>jn(T),[T]),P=async E=>{try{await S(en(En.add,E,t),ze(E)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(M){v.error(M?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},O=E=>{E.preventDefault();const M=new FormData(E.target);h&&M.set("fk_categoryID",String(h)),p&&M.set("fk_sub_categoryID",String(p)),w&&M.set("vendor_id",String(w)),m&&M.set("unit",String(m)),c&&M.set("image",c),P(M),E.target.reset(),g(""),u(""),A(""),b(""),j("")},$=(E,M)=>{s({page:E,rowsPerPage:parseInt(M,10)})},U=async E=>{try{await S(tn(En.remove,E,t),Ne(E)),v.success("Success! Deleted item.",{duration:1e3})}catch(M){v.error(M?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},N=E=>{d(E),o(!0),g(""),u(E?.fk_categoryID??E?.category_id??""),A(E?.fk_sub_categoryID??E?.sub_category_id??""),b(E?.vendor_id??""),j(E?.unit??E?.unit_id??"")},V=async E=>{E.preventDefault();const M=new FormData(E.target);M.set("id",String(l?.id??"")),h&&M.set("fk_categoryID",String(h)),p&&M.set("fk_sub_categoryID",String(p)),w&&M.set("vendor_id",String(w)),m&&M.set("unit",String(m)),c&&M.set("image",c);try{await ja(En.edit,M,t),await S(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),g("")}catch(F){v.error(F?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},z=r.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,fixed:"left",width:180},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,responsive:["lg"]},{title:"Category",dataIndex:"storecategory",key:"storecategory",ellipsis:!0,responsive:["md"]},{title:"Quantity",dataIndex:"quantity",key:"quantity",ellipsis:!0,width:100,responsive:["md"]},{title:"Unit",dataIndex:"unit_name",key:"unit_name",ellipsis:!0,width:120,responsive:["md"]},{title:"Price",dataIndex:"price",key:"price",ellipsis:!0,width:100,responsive:["md"]},{title:"Barcode",dataIndex:"barcode",key:"barcode",ellipsis:!0,responsive:["xl"]},{title:"Hsn Code",dataIndex:"hsn_code",key:"hsn_code",ellipsis:!0,responsive:["xl"]},{title:"Action",key:"action",width:100,fixed:"right",render:(E,M)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>N(M),style:{padding:2}}),e.jsx(mt,{id:M?.id,funcName:U})]})}],[U]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:i,title:l?.name?`Edit ${l.name}`:"Edit Product",placement:"right",width:520,onClose:()=>{o(!1),d(null),g("")},children:e.jsx("form",{onSubmit:V,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx(Y,{type:"text",name:"name",label:"Product Name*",defaultValue:l?.name??"",required:"required"}),e.jsx(Q,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:E=>{const M=E?.value??"";u(M),A("")},defaultValue:h?B.find(E=>String(E?.value)===String(h)):null}),e.jsx(Q,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:E=>A(E?.value??""),defaultValue:p?y.find(E=>String(E?.value)===String(p)):null}),e.jsx(Y,{type:"text",name:"barcode",label:"Barcode",defaultValue:l?.barcode??""}),e.jsx(Q,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:E=>j(E?.value??""),defaultValue:m?L.find(E=>String(E?.value)===String(m)):null}),e.jsx(Y,{type:"number",name:"quantity",label:"Quantity*",defaultValue:l?.quantity??"",required:"required"}),e.jsx(Y,{type:"number",name:"price",label:"Price*",defaultValue:l?.price??"",required:"required"}),e.jsx(Q,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:E=>b(E?.value??""),defaultValue:w?I.find(E=>String(E?.value)===String(w)):null}),e.jsx(Y,{type:"number",name:"hsn_code",label:"Hsn Code",defaultValue:l?.hsn_code??""}),e.jsx(st,{type:"text",label:"Description",name:"description",rows:3,defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:g})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null),g("")},style:gm,children:"Cancel"})]})]})})}),e.jsxs(C,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Add Product"})}),e.jsx(C,{px:3,pb:2,children:e.jsx("form",{onSubmit:O,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"name",label:"Product Name*",required:"required"}),e.jsx(Q,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category*",name:"fk_categoryID",allowSelectAll:!1,required:!0,onChange:E=>{const M=E?.value??"";u(M),A("")}}),e.jsx(Q,{options:y,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"SubCategory",name:"fk_sub_categoryID",allowSelectAll:!1,onChange:E=>A(E?.value??"")},`subcat_${h}`),e.jsx(Y,{type:"text",name:"barcode",label:"Barcode"}),e.jsx(Q,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Unit*",name:"unit",allowSelectAll:!1,required:!0,onChange:E=>j(E?.value??"")}),e.jsx(Y,{type:"number",name:"quantity",label:"Quantity*",required:"required"}),e.jsx(Y,{type:"number",name:"price",label:"Price*",required:"required"}),e.jsx(Q,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Vendor*",name:"vendor_id",allowSelectAll:!1,required:!0,onChange:E=>b(E?.value??"")}),e.jsx(Y,{type:"number",name:"hsn_code",label:"Hsn Code"}),e.jsx(st,{type:"text",label:"Description",name:"description",rows:3}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:g})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Add Product",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Products List"})}),e.jsx(C,{pt:3,children:e.jsx(Te,{parentCallback:$,data:{newData:k,columns:z,columnstype:"antd",action:!1,Loading:D,error:R}})})]})]})]})}const bm=({token:t})=>e.jsx(xm,{token:t}),Fn=Ke.category,jm=({token:t,page:a=1,perPage:s=10})=>an({baseUrl:Fn.list,page:a,perPage:s,token:t}),Sm={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function wm({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(null),{isLoading:c,error:g,data:h,mutate:u}=jm({token:t,page:a.page,perPage:a.rowsPerPage}),p=async R=>{try{await u(en(Fn.add,R,t),ze(R)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(k){v.error(k?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},A=R=>{R.preventDefault();const k=new FormData(R.target);p(k),R.target.reset()},w=(R,k)=>{s({page:R,rowsPerPage:parseInt(k,10)})},b=async R=>{try{await u(tn(Fn.remove,R,t),Ne(R)),v.success("Success! Deleted item.",{duration:1e3})}catch(k){v.error(k?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},m=R=>{d(R),o(!0)},j=async R=>{R.preventDefault();const k=new FormData(R.target);k.set("id",String(l?.id??""));try{await ja(Fn.edit,k,t),await u(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch(S){v.error(S?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},D=r.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(R,k)=>String(R?.name??"").localeCompare(String(k?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(R,k)=>String(R?.description??"").localeCompare(String(k?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(R,k)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>m(k),style:{padding:2}}),e.jsx(mt,{id:k?.id,funcName:b})]})}],[b]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:i,title:l?.name?`Edit ${l.name}`:"Edit Category",placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:j,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"name",label:"Name",defaultValue:l?.name??"",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Sm,children:"Cancel"})]})]})})}),e.jsxs(C,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Add Category"})}),e.jsx(C,{px:3,pb:2,children:e.jsx("form",{onSubmit:A,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Category List"})}),e.jsx(C,{pt:3,children:e.jsx(Te,{parentCallback:w,data:{newData:h,columns:D,columnstype:"antd",action:!1,Loading:c,error:g}})})]})]})]})}const vm=({token:t})=>e.jsx(wm,{token:t}),Un=Ke.subCategory,bi=Ke.category.dropdown,_m=({token:t,page:a=1,perPage:s=10})=>an({baseUrl:Un.list,page:a,perPage:s,token:t}),Cm=({token:t})=>W(t&&bi?[bi,t]:null,([s,i])=>K(s,i)),Am=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]},Dm={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Tm({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(null),[c,g]=r.useState(""),{isLoading:h,error:u,data:p,mutate:A}=_m({token:t,page:a.page,perPage:a.rowsPerPage}),{data:w}=Cm({token:t}),b=r.useMemo(()=>Am(w),[w]),m=async f=>{try{await A(en(Un.add,f,t),ze(f)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(_){v.error(_?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},j=f=>{f.preventDefault();const _=new FormData(f.target);_.set("status","active"),_.set("img",c||""),m(_),f.target.reset(),g("")},D=(f,_)=>{s({page:f,rowsPerPage:parseInt(_,10)})},R=async f=>{try{await A(tn(Un.remove,f,t),Ne(f)),v.success("Success! Deleted item.",{duration:1e3})}catch(_){v.error(_?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},k=f=>{d(f),o(!0)},S=async f=>{f.preventDefault();const _=new FormData(f.target);_.set("id",String(l?.id??"")),c&&_.set("img",c);try{await ja(Un.edit,_,t),await A(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null),g("")}catch(T){v.error(T?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},x=r.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(f,_)=>String(f?.name??"").localeCompare(String(_?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(f,_)=>String(f?.description??"").localeCompare(String(_?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(f,_)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>k(_),style:{padding:2}}),e.jsx(mt,{id:_?.id,funcName:R})]})}],[R]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:i,title:l?.name?`Edit ${l.name}`:"Edit Sub Category",placement:"right",width:420,onClose:()=>{o(!1),d(null),g("")},children:e.jsx("form",{onSubmit:S,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Q,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",defaultValue:l?.category_id?b.find(f=>String(f?.value)===String(l.category_id)):null,allowSelectAll:!1,required:!0}),e.jsx(Y,{type:"text",name:"name",label:"Name*",defaultValue:l?.name??"",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:g})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null),g("")},style:Dm,children:"Cancel"})]})]})})}),e.jsxs(C,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Add Sub Category"})}),e.jsx(C,{px:3,pb:2,children:e.jsx("form",{onSubmit:j,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Category",name:"category_id",allowSelectAll:!1,required:!0}),e.jsx(Y,{type:"text",name:"name",label:"Name*",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{fontSize:12,color:"#222"},children:"Image"}),e.jsx(ya,{token:t,value:c,onChange:g})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Sub Category List"})}),e.jsx(C,{pt:3,children:e.jsx(Te,{parentCallback:D,data:{newData:p,columns:x,columnstype:"antd",action:!1,Loading:h,error:u}})})]})]})]})}const Rm=({token:t})=>e.jsx(Tm,{token:t}),Is=Ke.product,Im=Ke.academy.classes,km=Ke.academy.sections,Pm=Ke.student.dropdown;function Ia(t){const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]}function Sn(t,a){const s=Math.trunc(Number(t)||1),i=Math.max(1,s);return!Number.isFinite(Number(a))||Number(a)<=0?i:Math.min(i,Math.trunc(Number(a)))}function dt(t){return String(t??"")}function Om({token:t}){const[a,s]=r.useState(""),[i,o]=r.useState(""),[l,d]=r.useState(""),[c,g]=r.useState(!1),[h,u]=r.useState(""),[p,A]=r.useState([]),[w,b]=r.useState({}),[m,j]=r.useState({}),[D,R]=r.useState(!1),[k,S]=r.useState(""),[x,f]=r.useState(0),[_,T]=r.useState(""),[I,B]=r.useState(te()),[L,y]=r.useState([]),P={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"},O=!!(a&&i&&l),{data:$}=W(t?[Im,t]:null,([fe,Se])=>K(fe,Se)),U=r.useMemo(()=>Ia($),[$]),N=t&&a?`${km}?class_id=${encodeURIComponent(String(a))}`:null,{data:V}=W(N?[N,t]:null,([fe,Se])=>K(fe,Se)),z=r.useMemo(()=>Ia(V),[V]),E=t&&a&&i?`${Pm}?class=${encodeURIComponent(String(a))}§ion=${encodeURIComponent(String(i))}`:null,{data:M}=W(E?[E,t]:null,([fe,Se])=>K(fe,Se)),F=r.useMemo(()=>Ia(M),[M]),q=O?`${Is.list}?page=1&per_page=10000`:null,{data:H,isLoading:re}=W(t&&q?[q,t]:null,([fe,Se])=>K(fe,Se),{revalidateOnFocus:!1}),G=r.useMemo(()=>Ia(H),[H]),J=r.useMemo(()=>{const fe=new Map;return(Array.isArray(G)?G:[]).forEach(Se=>{fe.set(dt(Se?.id),Se)}),fe},[G]),ae=r.useMemo(()=>{const fe=Object.entries(m||{});return fe.length===0?[]:fe.map(([Se,je])=>{const se=J.get(dt(Se));return se?{id:se?.id,name:se?.name,barcode:se?.barcode,stock:Number(se?.quantity||0),price:Number(se?.price||0),quantity:Sn(je,Number(se?.quantity||0))}:null}).filter(Boolean)},[m,J]),oe=r.useMemo(()=>new Set(ae.map(fe=>dt(fe?.id))),[ae]),pe=r.useMemo(()=>(Array.isArray(ae)?ae:[]).reduce((Se,je)=>Se+Number(je?.price||0)*Number(je?.quantity||1),0),[ae]),_e=r.useMemo(()=>{const fe=Number(x||0);return!Number.isFinite(fe)||fe<=0?0:Math.min(fe,pe)},[x,pe]),le=r.useMemo(()=>Math.max(0,pe-_e),[_e,pe]),de=r.useMemo(()=>(Array.isArray(G)?G:[]).slice(0,30).map(fe=>({value:dt(fe?.id),label:`${fe?.name??""}${fe?.barcode?` • ${fe.barcode}`:""}${fe?.quantity!==void 0&&fe?.quantity!==null?` • Stock: ${fe.quantity}`:""}`,product:fe})),[G]),{trigger:X}=tt(t&&O?Is.search:null,(fe,{arg:Se})=>Gt(fe,{arg:Se},t));r.useEffect(()=>{if(!O){A([]);return}const fe=String(h||"").trim();if(fe.length<2){A(de);return}let Se=!0;const je=setTimeout(async()=>{let se=[];try{if(X){const xe=await X({search:fe});se=Ia(xe)}}catch{se=[]}if(!Array.isArray(se)||se.length===0){const xe=fe.toLowerCase();se=(Array.isArray(G)?G:[]).filter(ie=>{const ye=String(ie?.name??"").toLowerCase(),Ye=String(ie?.barcode??"").toLowerCase();return ye.includes(xe)||Ye.includes(xe)}).slice(0,30)}const me=se.slice(0,30).map(xe=>({value:dt(xe?.id),label:`${xe?.name??""}${xe?.barcode?` • ${xe.barcode}`:""}${xe?.quantity!==void 0&&xe?.quantity!==null?` • Stock: ${xe.quantity}`:""}`,product:xe}));Se&&A(me)},250);return()=>{Se=!1,clearTimeout(je)}},[de,O,X,G,h]),r.useEffect(()=>{j({}),b({}),u(""),A([]),R(!1),S(""),f(0),T(""),B(te()),y([])},[a,i,l]);const ce=r.useCallback((fe,Se=1)=>{const je=fe?.id;if(!je)return;const se=Number(fe?.quantity||0);if(se<=0){v.error("Out of stock.",{duration:1e3});return}const me=Sn(Se,se);j(xe=>{const ie=xe||{};return Object.prototype.hasOwnProperty.call(ie,dt(je))?(v.error("Product already added.",{duration:1e3}),ie):{...ie,[dt(je)]:me}})},[j]),Re=r.useCallback((fe,Se,je)=>{j(se=>{const me=se||{},xe=dt(fe);return Object.prototype.hasOwnProperty.call(me,xe)?{...me,[xe]:Sn(Se,je)}:me})},[]),Ue=r.useCallback(fe=>{j(Se=>{const je=Se||{},se=dt(fe);if(!Object.prototype.hasOwnProperty.call(je,se))return je;const me={...je};return delete me[se],me})},[]),ke=r.useCallback((fe,Se,je)=>{b(se=>({...se||{},[dt(fe)]:Sn(Se,je)}))},[]),Ve=r.useCallback((fe,Se)=>{Se?.product&&ce(Se.product,1),u(""),A(de)},[ce,de]),Le=r.useCallback(fe=>{if(fe.key!=="Enter")return;fe.preventDefault();const Se=Array.isArray(p)&&p.length>0?p[0]:null;if(Se?.product){ce(Se.product,1),u(""),A(de);return}const je=String(h||"").trim().toLowerCase();if(je.length===0)return;const se=(Array.isArray(G)?G:[]).find(me=>{const xe=String(me?.name??"").toLowerCase(),ie=String(me?.barcode??"").toLowerCase();return xe.includes(je)||ie.includes(je)});se&&(ce(se,1),u(""),A(de))},[ce,de,G,p,h]),at=()=>{if(!t){v.error("Missing token.",{duration:1e3});return}if(!a){v.error("Select class.",{duration:1e3});return}if(!i){v.error("Select section.",{duration:1e3});return}if(!l){v.error("Select student.",{duration:1e3});return}if(!ae||ae.length===0){v.error("Add at least one product.",{duration:1e3});return}R(!0)},{trigger:Ge,isMutating:Fe}=tt(t?Is.sellProduct:null,(fe,{arg:Se})=>as(fe,{arg:Se},t)),Je=async()=>{if(!k){v.error("Select payment type.",{duration:1e3});return}const fe=(Array.isArray(ae)?ae:[]).map(je=>({id:je?.id,quantity:Number(je?.quantity||1),price:Number(je?.price||0),total_price:Number(je?.total_price||0),fk_vendor_id:je?.fk_vendor_id||"",fk_categoryID:je?.fk_categoryID||"",name:je?.name||"",class_id:je?.class_id||"",fk_sub_categoryID:je?.fk_sub_categoryID||"",description:je?.description||"",min_quantity:Number(je?.min_quantity||0),storecategory:Number(je?.storecategory||0),barcode:je?.barcode||""})),Se={amount:pe,class:a,section:i,student_id:l,payment_type:k,discount:_e,notes:_||"",receipt_date:I?te(I).format("YYYY-MM-DD"):"",product:JSON.stringify(fe),total_payable_amount:pe,attchement:L[0]?.originFileObj||""};try{const se=Array.isArray(L)&&L.length>0&&L[0]?.originFileObj?(()=>{const xe=new FormData;return Object.entries(Se).forEach(([ie,ye])=>{if(ie==="products"){xe.append("product",JSON.stringify(ye));return}xe.append(ie,String(ye??""))}),xe.append("attachment",L[0].originFileObj),xe})():Se,me=await Ge(se);me?.Status==="Success"?(v.success("Success! Product sold.",{duration:1e3}),R(!1),j({}),b({}),u(""),A(de),S(""),f(0),T(""),B(te()),y([])):v.error(me?.msg??"Failed to submit.",{duration:1e3})}catch{v.error("Failed to submit.",{duration:1e3})}},it=r.useMemo(()=>[{title:"Product Name",dataIndex:"name",key:"name",ellipsis:!0},{title:"Barcode",dataIndex:"barcode",key:"barcode",width:160},{title:"Stock",dataIndex:"quantity",key:"quantity",width:110},{title:"Price",dataIndex:"price",key:"price",width:120},{title:"Quantity",key:"quantity",width:160,render:(fe,Se)=>{const je=dt(Se?.id),se=Number(Se?.quantity||0),me=oe.has(je),xe=(me?m?.[je]:w?.[je])??1;return e.jsx(n.InputNumber,{min:1,max:Number.isFinite(se)&&se>0?se:void 0,value:xe,onChange:ie=>{me?Re(je,ie,se):ke(je,ie,se)},disabled:se<=0})}},{title:"Amount",key:"amount",width:140,render:(fe,Se)=>{const je=dt(Se?.id),se=(oe.has(je)?m?.[je]:w?.[je])??1;return Number(Se?.price||0)*Number(se||1)}},{title:"Action",key:"action",width:120,render:(fe,Se)=>{const je=dt(Se?.id),se=Number(Se?.quantity||0),me=oe.has(je),xe=(me?m?.[je]:w?.[je])??1;return me?e.jsx(n.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(ee.DeleteOutlined,{}),onClick:()=>Ue(je),style:{padding:2}}):e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.PlusOutlined,{}),disabled:se<=0,onClick:()=>ce(Se,xe),style:{padding:2}})}}],[ce,oe,m,w,Ue,ke,Re]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(C,{pt:5,pb:2,children:[e.jsxs(C,{style:{padding:"12px 16px"},children:[e.jsx(C,{children:"Sell Product"}),e.jsx(n.Card,{style:{borderRadius:16},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Q,{options:U,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",placeholder:"Class",allowSelectAll:!1,required:!0,onChange:fe=>{const Se=fe?.value??"";s(Se),o(""),d(""),g(je=>!je)}}),e.jsx(Q,{options:z,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",placeholder:"Section",allowSelectAll:!1,required:!0,onChange:fe=>{const Se=fe?.value??"";o(Se),d("")}},`section_${c}`),e.jsx(Q,{options:F,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",name:"student_id",placeholder:"Student",allowSelectAll:!1,required:!0,onChange:fe=>d(fe?.value??"")})]})})]}),e.jsx("div",{style:{padding:"0 16px"},children:e.jsxs(n.Card,{style:{borderRadius:16,marginTop:12},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(260px, 520px) 1fr",gap:12,alignItems:"center",marginBottom:12},children:[e.jsx(C,{style:{marginTop:12},children:"Product Section"}),e.jsx(n.AutoComplete,{value:h,options:p,onSearch:u,onFocus:()=>{O&&String(h||"").trim().length<2&&A(de)},onSelect:Ve,disabled:!O,children:e.jsx(n.Input,{placeholder:"Search by product name or barcode",onKeyDown:Le,allowClear:!0})}),e.jsxs("div",{style:{justifySelf:"end",fontWeight:700},children:["Total: ",Tt(pe)]})]}),e.jsx(n.Table,{rowKey:fe=>dt(fe?.id),columns:it,dataSource:G,loading:re,size:"small",bordered:!0,pagination:{pageSize:50,showSizeChanger:!0,pageSizeOptions:[25,50,100,200]},scroll:{x:"max-content"}}),e.jsxs("div",{style:{position:"sticky",bottom:0,background:"#fff",paddingTop:12,marginTop:12,borderTop:"1px solid #f0f0f0"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700},children:[e.jsx("span",{children:"Selected Items"}),e.jsx("span",{children:ae.length})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700,marginTop:6},children:[e.jsx("span",{children:"Total Amount"}),e.jsx("span",{children:Tt(pe)})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginTop:12},children:[e.jsx(ne,{type:"button",value:"Submit",disabled:!O||ae.length===0,onClick:at,style:{flex:1,minWidth:140}}),e.jsx(n.Button,{type:"text",style:P,onClick:()=>{j({}),b({}),u(""),A(de)},disabled:ae.length===0,children:"Clear"})]})]})]})})]}),e.jsx(n.Modal,{open:D,title:"Payment",onCancel:()=>R(!1),onOk:Je,confirmLoading:Fe,okText:"Submit",destroyOnClose:!0,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Payment Type"}),e.jsx(n.Select,{value:k||void 0,onChange:S,placeholder:"Select payment type",style:{width:"100%"},options:[{value:"Cash",label:"Cash"},{value:"UPI",label:"UPI"},{value:"Bank",label:"Bank"},{value:"Cheque",label:"Cheque"},{value:"DD",label:"DD"},{value:"Internet Banking",label:"Internet Banking"}]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Receipt Date"}),e.jsx(n.DatePicker,{value:I,onChange:fe=>B(fe),style:{width:"100%"},format:"YYYY-MM-DD"})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Discount"}),e.jsx(n.InputNumber,{min:0,max:pe,value:x,onChange:fe=>f(Number(fe||0)),style:{width:"100%"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Attachment"}),e.jsx(n.Upload,{fileList:L,beforeUpload:()=>!1,onChange:({fileList:fe})=>y((fe||[]).slice(-1)),maxCount:1,children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),children:"Upload"})})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Notes"}),e.jsx(n.Input.TextArea,{value:_,onChange:fe=>T(fe.target.value),rows:3})]}),e.jsx(n.Card,{style:{borderRadius:12,background:"#fafcff"},children:e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Total Amount"}),e.jsx("span",{children:Tt(pe)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:"Discount"}),e.jsx("span",{children:Tt(_e)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:700},children:[e.jsx("span",{children:"Net Amount"}),e.jsx("span",{children:Tt(le)})]})]})})]})})]})}const Mm=({token:t})=>e.jsx(Om,{token:t}),$n=Ke.unit,Em=({token:t,page:a=1,perPage:s=10})=>an({baseUrl:$n.list,page:a,perPage:s,token:t}),Fm={height:36,padding:"0 14px",border:"none",background:"transparent",color:"#243a9b",fontSize:14,fontWeight:500,textTransform:"uppercase",boxShadow:"none"};function Um({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(null),{isLoading:c,error:g,data:h,mutate:u}=Em({token:t,page:a.page,perPage:a.rowsPerPage}),p=async R=>{try{await u(en($n.add,R,t),ze(R)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch(k){v.error(k?.response?.data?.msg??"Failed to add the new item.",{duration:1e3})}},A=R=>{R.preventDefault();const k=new FormData(R.target);p(k),R.target.reset()},w=(R,k)=>{s({page:R,rowsPerPage:parseInt(k,10)})},b=async R=>{try{await u(tn($n.remove,R,t),Ne(R)),v.success("Success! Deleted item.",{duration:1e3})}catch(k){v.error(k?.response?.data?.msg??"Failed to delete the item.",{duration:1e3})}},m=R=>{d(R),o(!0)},j=async R=>{R.preventDefault();const k=new FormData(R.target);k.set("id",String(l?.id??""));try{await ja($n.edit,k,t),await u(),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),o(!1),d(null)}catch(S){v.error(S?.response?.data?.msg??"Failed to update the item.",{duration:1e3})}},D=r.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,sorter:{compare:(R,k)=>String(R?.name??"").localeCompare(String(k?.name??""))}},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,sorter:{compare:(R,k)=>String(R?.description??"").localeCompare(String(k?.description??""))}},{title:"Action",key:"action",width:100,fixed:"right",render:(R,k)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>m(k),style:{padding:2}}),e.jsx(mt,{id:k?.id,funcName:b})]})}],[b]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{open:i,title:l?.name?`Edit ${l.name}`:"Edit Unit",placement:"right",width:420,onClose:()=>{o(!1),d(null)},children:e.jsx("form",{onSubmit:j,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{type:"text",name:"name",label:"Unit Name",defaultValue:l?.name??"",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description",defaultValue:l?.description??""}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},style:Fm,children:"Cancel"})]})]})})}),e.jsxs(C,{pt:5,pb:1,children:[e.jsxs("div",{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Add Unit"})}),e.jsx(C,{px:3,pb:2,children:e.jsx("form",{onSubmit:A,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"name",label:"Unit Name*",required:"required"}),e.jsx(Y,{type:"text",name:"description",label:"Description"}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})})]}),e.jsxs("div",{style:{marginTop:24},children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,variant:"gradient",bgColor:"info",borderRadius:"lg",coloredShadow:"info",children:e.jsx(ge,{variant:"h6",color:"white",children:"Unit List"})}),e.jsx(C,{pt:3,children:e.jsx(Te,{parentCallback:w,data:{newData:h,columns:D,columnstype:"antd",action:!1,Loading:c,error:g}})})]})]})]})}const $m=({token:t})=>e.jsx(Um,{token:t}),Nm=Ke.product.sellReports,Lm=Ke.academy.classes,Bm=Ke.academy.sections,qm=Ke.student.dropdown,ji=t=>{const a=Number(t??0);return Number.isFinite(a)?a.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}):String(t??"")};function zm({token:t}){const a=r.useRef(null),[s,i]=r.useState(null),[o,l]=r.useState(""),[d,c]=r.useState(""),[g,h]=r.useState(""),[u,p]=r.useState(!1),A=y=>{const P=y?.data?.data??y?.data??y??[];return Array.isArray(P)?P:Array.isArray(P?.data)?P.data:[]},{data:w}=W(t?[Lm,t]:null,([y,P])=>K(y,P)),b=r.useMemo(()=>A(w),[w]),m=t&&o?`${Bm}?class_id=${encodeURIComponent(String(o))}`:null,{data:j}=W(m?[m,t]:null,([y,P])=>K(y,P)),D=r.useMemo(()=>A(j),[j]),R=t&&o&&d?`${qm}?class=${encodeURIComponent(String(o))}§ion=${encodeURIComponent(String(d))}`:null,{data:k}=W(R?[R,t]:null,([y,P])=>K(y,P)),S=r.useMemo(()=>A(k),[k]),{trigger:x,isMutating:f,data:_}=tt(Nm,(y,{arg:P})=>tr(y,{arg:P},t));r.useEffect(()=>{const P=new Date().toISOString().slice(0,10);x({duration:[P,P]})},[x]);const T=r.useMemo(()=>{const y=_?.data??_??[];return Array.isArray(y)?y:[]},[_]),I=y=>{const P=Array.isArray(y?.product_details)?y.product_details:[];return P.length===0?null:e.jsx(n.Table,{size:"small",bordered:!0,pagination:!1,rowKey:O=>`${y?.receipt_id??"r"}_${O?.product_name??O?.product_pricem??""}`,columns:[{title:"Product",dataIndex:"product_name",key:"product_name"},{title:"Amount",dataIndex:"product_pricem",key:"product_pricem",render:O=>ji(O)}],dataSource:P})},B=[{title:"Receipt No",dataIndex:"receipt_no",key:"receipt_no"},{title:"Date",dataIndex:"receipt_date",key:"receipt_date"},{title:"Amount",dataIndex:"receipt_amount",key:"receipt_amount",render:y=>ji(y)}],L=async()=>{if(!s||s.length!==2)return;const[y,P]=s;await x({duration:[y.format("YYYY-MM-DD"),P.format("YYYY-MM-DD")],class:o||"",section:d||"",student_id:g||""})};return e.jsx("div",{children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,lg:8,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Filters"}),style:{borderRadius:16},children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Duration"}),e.jsx(n.DatePicker.RangePicker,{value:s,onChange:i,style:{width:"100%"}})]}),e.jsx(Q,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",placeholder:"Class",allowSelectAll:!1,onChange:y=>{const P=y?.value??"";l(P),c(""),h(""),p(O=>!O)}}),e.jsx(Q,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",placeholder:"Section",allowSelectAll:!1,onChange:y=>{const P=y?.value??"";c(P),h("")}},`section_${u}`),e.jsx(Q,{options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Student",placeholder:"Student",allowSelectAll:!1,onChange:y=>h(y?.value??"")}),e.jsx(ne,{type:"button",value:f?"Searching...":"Search",disabled:f,onClick:L,style:{width:"100%"}})]})})}),e.jsx(n.Col,{xs:24,lg:16,children:e.jsx(n.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Sell Reports"}),e.jsx(wt,{data:{tableRef:a}})]}),style:{borderRadius:16},children:e.jsxs("div",{ref:a,children:[e.jsx("div",{className:"print-only",children:e.jsx(Ot,{})}),e.jsx(n.Table,{bordered:!0,size:"small",loading:f,rowKey:y=>String(y?.receipt_id??y?.receipt_no??Math.random()),columns:B,expandable:{expandedRowRender:I},dataSource:T,pagination:{pageSize:20}})]})})})]})})}const Ym=({token:t})=>e.jsx(zm,{token:t}),Vm=Ke.product;function Wm({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState([]),[l,d]=r.useState([]),[c,g]=r.useState(!1),[h,u]=r.useState(!1),[p,A]=r.useState(null),[w,b]=r.useState(0),[m,j]=r.useState(null),[D,R]=r.useState(""),k=r.useRef(null),S=xa.useReactToPrint({contentRef:k,documentTitle:"Stock Barcodes"}),{isLoading:x,error:f,data:_,mutate:T}=nl({token:t,page:a.page,perPage:a.rowsPerPage}),I=($,U)=>{s({page:$,rowsPerPage:parseInt(U,10)})},B={selectedRowKeys:i,onChange:($,U)=>{o($),d(U)}},L=$=>{A($),b(Number($?.quantity??0)),j(null),R(""),g(!0)},y=()=>{g(!1),A(null),b(0),j(null),R("")},P=async()=>{if(!p?.id)return;u(!0);const $=new FormData;$.append("product_id",String(p.id)),$.append("qty",String(w??0)),m&&$.append("tran_date",m.format("YYYY-MM-DD")),D&&$.append("remarks",D);try{const U=await ja(Vm.addStock,$,t);U?.Status==="Success"?(v.success("Success! Updated quantity.",{duration:1e3}),y(),await T()):v.error(U?.msg??"Failed to update quantity.",{duration:1e3})}catch{v.error("Failed to update quantity.",{duration:1e3})}finally{u(!1)}},O=r.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name",ellipsis:!0,fixed:"left",width:180},{title:"Category",dataIndex:"storecategory",key:"storecategory",ellipsis:!0,responsive:["md"]},{title:"Quantity",dataIndex:"quantity",key:"quantity",width:100},{title:"Unit",dataIndex:"unit_name",key:"unit_name",width:120,responsive:["md"]},{title:"Price",dataIndex:"price",key:"price",width:100,responsive:["md"]},{title:"Barcode",dataIndex:"barcode",key:"barcode",ellipsis:!0,responsive:["lg"]},{title:"Action",key:"action",width:160,fixed:"right",render:($,U)=>e.jsx("div",{style:{display:"flex",gap:8},children:e.jsx(n.Button,{size:"small",onClick:()=>L(U),children:"Update Qty"})})}],[]);return e.jsxs("div",{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:p?.name?`Update Stock: ${p.name}`:"Update Stock",open:c,onCancel:y,onOk:P,okButtonProps:{loading:h},children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Quantity"}),e.jsx(n.InputNumber,{min:0,style:{width:"100%"},value:w,onChange:$=>b($??0)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{style:{width:"100%"},value:m,onChange:j})]}),e.jsx(st,{label:"Remarks",name:"remarks",rows:3,value:D,onChange:$=>R($.target.value)})]})}),e.jsxs(C,{pt:5,pb:2,children:[e.jsxs(C,{children:["Manage Stock",e.jsx(ne,{type:"button",value:"Print Barcodes",disabled:!l||l.length===0,onClick:()=>S?.(),style:{minWidth:170}})]}),e.jsx(C,{style:{padding:"12px 16px"},children:e.jsx(n.Card,{style:{borderRadius:16},children:e.jsx(Te,{parentCallback:I,data:{newData:_,columns:O,columnstype:"antd",action:!1,Loading:x,error:f,rowSelection:B}})})})]}),e.jsx("div",{style:{position:"absolute",left:-1e4,top:0},children:e.jsx("div",{ref:k,children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:16,padding:24},children:(Array.isArray(l)?l:[]).map($=>e.jsxs("div",{style:{border:"1px solid #ddd",padding:12},children:[e.jsx("div",{style:{marginBottom:6,fontSize:12},children:$?.name??""}),e.jsx(mo,{value:String($?.barcode??$?.id??""),height:50,width:1.6,displayValue:!0})]},$?.id??$?.barcode??$?.name))})})})]})}const Hm=({token:t})=>e.jsx(Wm,{token:t}),Km=Ke.report.stock,Gm=Ke.product.dropdown,Jm=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:[]};function Qm({token:t}){const a=r.useRef(null),[s,i]=r.useState(null),[o,l]=r.useState(""),{data:d}=W(t?[Gm,t]:null,([b,m])=>K(b,m)),c=r.useMemo(()=>Jm(d),[d]),{trigger:g,isMutating:h,data:u}=tt(Km,(b,{arg:m})=>tr(b,{arg:m},t));r.useEffect(()=>{const m=new Date().toISOString().slice(0,10);g({duration:[m,m]})},[g]);const p=r.useMemo(()=>{const b=u?.data??u??[];return(Array.isArray(b)?b:[]).flatMap(j=>(Array.isArray(j?.ledger)?j.ledger:[]).map((D,R)=>({key:`${j.product_id??j.product_name??"p"}-${R}`,date:D?.date,product:j?.product_name,opening:D?.opening,inward:D?.inward,outward:D?.outward,closing:D?.closing})))},[u]),A=[{title:"Date",dataIndex:"date",key:"date"},{title:"Product",dataIndex:"product",key:"product"},{title:"Opening",dataIndex:"opening",key:"opening"},{title:"Inward",dataIndex:"inward",key:"inward"},{title:"Outward",dataIndex:"outward",key:"outward"},{title:"Closing",dataIndex:"closing",key:"closing",render:b=>e.jsx("span",{style:{color:Number(b)<0?"red":"green"},children:b})}],w=async()=>{if(!s||s.length!==2)return;const[b,m]=s;await g({duration:[b.format("YYYY-MM-DD"),m.format("YYYY-MM-DD")],product_id:o||""})};return e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Stock Report"}),style:{borderRadius:16},children:[e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center",marginBottom:16,flexWrap:"wrap"},children:[e.jsx(n.DatePicker.RangePicker,{value:s,onChange:i}),e.jsxs("select",{value:o,onChange:b=>l(b.target.value),style:{height:32,borderRadius:6,border:"1px solid #d9d9d9",padding:"0 8px"},children:[e.jsx("option",{value:"",children:"All Products"}),c.map(b=>e.jsx("option",{value:String(b?.value??""),children:String(b?.label??"")},String(b?.value??b?.id??b?.label)))]}),e.jsx(n.Button,{type:"primary",onClick:w,loading:h,children:"Search"}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(wt,{data:{tableRef:a}})})]}),e.jsxs("div",{ref:a,children:[e.jsx("div",{className:"print-only",children:e.jsx(Ot,{})}),e.jsx(n.Table,{bordered:!0,size:"small",loading:h,rowKey:"key",columns:A,dataSource:p,pagination:{pageSize:50}})]})]})}const Xm=({token:t})=>e.jsx(Qm,{token:t}),Si=[{label:"Today",value:"Today"},{label:"Yesterday",value:"Yesterday"},{label:"This Week",value:"This Week"},{label:"This Month",value:"This Month"},{label:"Last Month",value:"Last Month"},{label:"This Year",value:"This Year"},{label:"Custom",value:"Custom"}],kt={total_packages:124,total_downloads:45892,active_packages:118,deprecated_packages:6,pending_approval:3,published_this_month:12,published_this_week:4,packages_needing_update:8,packages_with_issues:2},wi=[{npm_id:"NPM-001",package_name:"@ubk/erp-core",version:"1.2.1",description:"Core ERP utilities and shared types",author:"UBK Infotech",repository:"https://github.com/ubk/erp-core",license:"MIT",status:"published",created_at:"2024-01-15",updated_at:"2025-06-20"},{npm_id:"NPM-002",package_name:"@ubk/erp-components",version:"2.0.0",description:"Reusable Ant Design ERP component library",author:"UBK Infotech",repository:"https://github.com/ubk/erp-components",license:"ISC",status:"published",created_at:"2024-03-10",updated_at:"2025-08-01"},{npm_id:"NPM-003",package_name:"@ubk/erp-api-client",version:"0.9.5",description:"Axios-based API client for UBK ERP backends",author:"UBK Infotech",repository:"https://github.com/ubk/erp-api-client",license:"MIT",status:"draft",created_at:"2025-05-22",updated_at:"2025-07-14"},{npm_id:"NPM-004",package_name:"@ubk/erp-hooks",version:"1.1.0",description:"Custom React hooks for ERP workflows",author:"UBK Infotech",repository:"https://github.com/ubk/erp-hooks",license:"MIT",status:"published",created_at:"2024-08-05",updated_at:"2025-04-30"},{npm_id:"NPM-005",package_name:"@ubk/erp-utils",version:"3.2.1",description:"Utility functions for date, currency, and validation",author:"UBK Infotech",repository:"https://github.com/ubk/erp-utils",license:"ISC",status:"deprecated",created_at:"2023-11-20",updated_at:"2025-02-10"}],vi=[{key:"dashboard",label:"Dashboard"},{key:"allPackages",label:"All Packages"},{key:"published",label:"Published"},{key:"draft",label:"Draft"},{key:"deprecated",label:"Deprecated"},{key:"pendingApproval",label:"Pending Approval"}];function Zm(){const[t,a]=r.useState("dashboard"),[s,i]=r.useState("This Month"),[o,l]=r.useState(""),[d,c]=r.useState(""),[g,h]=r.useState(1),[u,p]=r.useState(10),[A,w]=r.useState(""),b=r.useRef(null),m=["dashboard","allPackages","published","draft","deprecated","pendingApproval"].includes(t),j=r.useMemo(()=>{if(!A.trim())return wi;const x=A.toLowerCase();return wi.filter(f=>Object.values(f).some(_=>String(_??"").toLowerCase().includes(x)))},[A]),D=r.useMemo(()=>{const x=(g-1)*u;return j.slice(x,x+u)},[j,g,u]),R=()=>{h(1)},k=()=>{const x=[{title:"Total Packages",value:kt.total_packages,icon:e.jsx(ee.FileTextOutlined,{}),color:"#1976d2"},{title:"Total Downloads",value:kt.total_downloads.toLocaleString(),icon:e.jsx(ee.StarOutlined,{}),color:"#2e7d32"},{title:"Active Packages",value:kt.active_packages,icon:e.jsx(ee.CheckCircleOutlined,{}),color:"#0288d1"},{title:"Deprecated",value:kt.deprecated_packages,icon:e.jsx(ee.CloseCircleOutlined,{}),color:"#d32f2f"},{title:"Pending Approval",value:kt.pending_approval,icon:e.jsx(ee.ClockCircleOutlined,{}),color:"#ed6c02"},{title:"Published This Month",value:kt.published_this_month,icon:e.jsx(ee.CalendarOutlined,{}),color:"#9c27b0"},{title:"Published This Week",value:kt.published_this_week,icon:e.jsx(ee.SyncOutlined,{}),color:"#455a64"},{title:"Needs Update",value:kt.packages_needing_update,icon:e.jsx(ee.CodeOutlined,{}),color:"#c62828"},{title:"With Issues",value:kt.packages_with_issues,icon:e.jsx(ee.CloseCircleOutlined,{}),color:"#f57c00"}];return e.jsx(n.Row,{gutter:[16,16],children:x.map((f,_)=>e.jsx(n.Col,{xs:24,sm:12,md:8,lg:6,children:e.jsxs(n.Card,{style:{display:"flex",alignItems:"center",padding:16,borderLeft:`6px solid ${f.color}`,transition:"0.2s",cursor:"default"},bodyStyle:{display:"flex",alignItems:"center",width:"100%"},children:[e.jsx(C,{style:{width:48,height:48,borderRadius:"50%",backgroundColor:`${f.color}15`,color:f.color,display:"flex",alignItems:"center",justifyContent:"center",fontSize:22,marginRight:16,flexShrink:0},children:f.icon}),e.jsxs(C,{children:[e.jsx(n.Typography.Text,{type:"secondary",style:{fontSize:12,fontWeight:500},children:f.title}),e.jsx("div",{style:{fontSize:22,fontWeight:700,marginTop:4},children:f.value})]})]})},_))})},S=()=>{const x=[{title:"NPM ID",dataIndex:"npm_id",key:"npm_id",width:100},{title:"Package Name",dataIndex:"package_name",key:"package_name",ellipsis:!0},{title:"Version",dataIndex:"version",key:"version",width:100},{title:"Description",dataIndex:"description",key:"description",ellipsis:!0,responsive:["md"]},{title:"Author",dataIndex:"author",key:"author",width:140,responsive:["lg"]},{title:"License",dataIndex:"license",key:"license",width:100},{title:"Status",dataIndex:"status",key:"status",width:120,render:f=>{let _="default";return f==="published"?_="green":f==="draft"?_="orange":f==="deprecated"?_="red":f==="pending"&&(_="blue"),e.jsx(n.Tag,{color:_,children:f.toUpperCase()})}},{title:"Created Date",dataIndex:"created_at",key:"created_at",width:120,responsive:["lg"]},{title:"Updated Date",dataIndex:"updated_at",key:"updated_at",width:120,responsive:["lg"]},{title:"Actions",key:"action",width:120,fixed:"right",render:(f,_)=>e.jsx("a",{style:{color:"#5080f8",cursor:"pointer",fontSize:13},children:"View"})}];return t==="dashboard"?[]:x};return e.jsx(C,{pt:5,pb:1,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:"NPM Package Report"})}),e.jsxs(C,{p:3,children:[e.jsxs(n.Row,{gutter:[16,16],mb:3,children:[m&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Q,{options:Si,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Date Range",allowSelectAll:!1,value:Si.find(x=>x.value===s)||null,onChange:x=>i(x?.value||"This Month")})}),s==="Custom"&&e.jsxs(e.Fragment,{children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Me,{Desplay:"From Date",format:"YYYY-MM-DD",onChange:x=>l(x?x.format("YYYY-MM-DD"):"")})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(Me,{Desplay:"To Date",format:"YYYY-MM-DD",onChange:x=>c(x?x.format("YYYY-MM-DD"):"")})})]})]}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(C,{display:"flex",alignItems:"center",height:"100%",mt:t==="dashboard"?0:2,children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:R})})})]}),e.jsx(n.Tabs,{activeKey:t,onChange:a,items:vi})]})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(n.Typography.Title,{level:5,style:{margin:0,color:"#fff"},children:vi.find(x=>x.key===t)?.label||"Report"})}),e.jsxs(C,{p:3,children:[t!=="dashboard"&&e.jsx(wt,{data:{tableRef:b}}),t==="dashboard"?k():e.jsx(n.Table,{size:"small",dataSource:D,columns:S(),loading:!1,pagination:!1,bordered:!0,rowKey:x=>x.npm_id||x.package_name||Math.random(),ref:b}),t!=="dashboard"&&j.length>0&&e.jsx(n.Pagination,{current:g,pageSize:u,total:j.length,onChange:(x,f)=>{h(x),p(f)},showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:[10,20,50,100],style:{marginTop:16,textAlign:"right"}})]})]})})]})})}const ss=t=>t??localStorage.getItem("authToken")??"",ir=(t,a)=>{const s=String(t??""),i=String(a??"");return s?i?s.endsWith("/")&&i.startsWith("/")?`${s}${i.slice(1)}`:!s.endsWith("/")&&!i.startsWith("/")?`${s}/${i}`:`${s}${i}`:s:i},Ie={upload:"api/branchapi/frontoffice/uploadfrontofficeDocument",roleDropdown:"api/Branch/getRoledropdownforBranch",staff:{list:"api/branchapi/staff/stafflist",searchByRole:"api/branchapi/staff/staffsearchbyRole",searchByKeywords:"api/branchapi/staff/staffsearchbyKeywords",deactivate:"api/branchapi/staff/staff_deactive",basicById:"api/branchapi/staff/getbasicdetailsbyID",experienceById:"api/branchapi/staff/getworkexperencebyID",payrollById:"api/branchapi/staff/getpayrollbyID",lastEmpNo:"api/branchapi/staff/getLastStaffEMPnumber",addBasic:"api/branchapi/staff/addstaffbasicdetails",editBasic:"api/branchapi/staff/editstaffbasicdetails",addExperience:"api/branchapi/staff/addstaffExperience",editExperience:"api/branchapi/staff/editstaffExperience",addPayroll:"api/branchapi/staff/addstaffpayroll",editPayroll:"api/branchapi/staff/editstaffpayroll",uploadProfile:"api/branchapi/staff/uploadstaffProfilepicture",uploadDocuments:"api/branchapi/staff/uploadDocuments"},master:{shift:{dropdown:"api/branchapi/generalSettings/shiftDropdown",table:"api/branchapi/generalSettings/shiftTable",add:"api/branchapi/generalSettings/shiftTable",add:"api/branchapi/generalSettings/addshift",edit:"api/branchapi/generalSettings/addshift",edit:"api/branchapi/generalSettings/editshift",remove:"api/branchapi/generalSettings/deleteshift",show:"api/branchapi/generalSettings/shiftShowdata"},department:{dropdown:"api/branchapi/humanResource/departmentDropdown",table:"api/branchapi/humanResource/departmenttypeTable",add:"api/branchapi/humanResource/adddepartment",edit:"api/branchapi/humanResource/editdepartment",remove:"api/branchapi/humanResource/deletedepartment",show:"api/branchapi/humanResource/departmentShowdata"},designation:{dropdown:"api/branchapi/humanResource/designationDropdown",table:"api/branchapi/humanResource/designationTable",add:"api/branchapi/humanResource/adddesignation",edit:"api/branchapi/humanResource/editdesignation",remove:"api/branchapi/humanResource/deletedesignation",show:"api/branchapi/humanResource/designationShowdata"},leaveType:{dropdown:"api/branchapi/humanResource/leavetypeDropdown",table:"api/branchapi/humanResource/LeavetypeTable",add:"api/branchapi/humanResource/addleavetype",edit:"api/branchapi/humanResource/editleavetype",remove:"api/branchapi/humanResource/deleteleavetype",show:"api/branchapi/humanResource/leavetypeShowdata"}},leave:{table:"api/branchapi/humanResource/LeaveTable",apply:"api/branchapi/humanResource/applyLeave",requestTable:"api/branchapi/humanResource/leaverequestTable",approveRequest:"api/branchapi/humanResource/approveleaveRequest"},attendance:{staffListForAttendance:"api/staff/attendence/stafflistforAttendence",staffDropdownByRole:"api/staff/attendence/getStaffDropDownByRoleId",addAttendanceToStaffByBranch:"api/staff/attendence/addattendencetoStaffbyBranch",manualAttendance:"api/staff/attendence/staffMenualAttendance",staffShiftByStaffId:"api/branchapi/staff/getStaffShiftByStaffId",dailyAttendance:"api/staff/attendence/dailyAttendance",dailyAttendanceMultipleShift:"api/staff/attendence/dailyAttendanceMultipleShift"},attendanceReport:{monthlyStaffReport:"api/AttendenceReport/staffmonthlyAttendenceReport_new",staffAttendanceList:"api/AttendenceReport/staffAttendanceList",overallStaffReport:"api/staff/attendence/getAlloverAttendenceReportofStaff"},payroll:{monthlyGraph:"api/branchapi/reportGraph/monthlyPayroleReportgraph",staffPayrollByStaffId:"api/branchapi/humanResource/getStaffPayroleByStaffID",generatePayslip:"api/branchapi/humanResource/generatePayslip",payrollByRole:"api/branchapi/humanResource/getpayrolebyRole",monthlyReport:"api/branchapi/humanResource/monthlyPayRolereport"}},sl=()=>ir(He(),Ie.upload),eh=()=>ir(He(),Ie.staff.uploadProfile),th=()=>ir(He(),Ie.staff.uploadDocuments),ah=async({baseUrl:t,page:a=1,perPage:s=10},i)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return K(l,ss(i))},Rt=async(t,a,s)=>Ee(t,a,ss(s)),zt=async(t,a,s)=>Be(t,a,ss(s)),nn=async(t,a,s)=>qe(t,a,ss(s)),Jt=Ie.staff,nh=Ie.master.shift.dropdown,sh=Ie.master.department.dropdown,rh=Ie.master.designation.dropdown,ih=Ie.roleDropdown,wn=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},oh=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",ka={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},_i={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function lh({token:t,mode:a,staffId:s,initialValues:i,onSubmitted:o}){const l=r.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))}catch{return null}},[]),d=String(l?.multiple_shift??"").toLowerCase()==="yes",[c,g]=r.useState(i?.roleValue??null),[h,u]=r.useState(i?.departmentValue??null),[p,A]=r.useState(i?.designationValue??null),[w,b]=r.useState(i?.genderValue??null),[m,j]=r.useState(i?.shiftValue??(d?[]:null)),[D,R]=r.useState(i?.dob?te(i.dob):null),[k,S]=r.useState(i?.doj?te(i.doj):null),[x,f]=r.useState(i?.file??""),{data:_}=W(t?[nh,t]:null,([V,z])=>K(V,z)),{data:T}=W(t?[sh,t]:null,([V,z])=>K(V,z)),{data:I}=W(t?[rh,t]:null,([V,z])=>K(V,z)),{data:B}=W(t?[ih,t]:null,([V,z])=>K(V,z)),{data:L}=W(t?[Jt.lastEmpNo,t]:null,([V,z])=>K(V,z)),y=r.useMemo(()=>wn(_),[_]),P=r.useMemo(()=>wn(T),[T]),O=r.useMemo(()=>wn(I),[I]),$=r.useMemo(()=>wn(B),[B]),U=r.useMemo(()=>{const V=L?.data?.emp_number??L?.emp_number??L?.data??"";return String(V??"")},[L]),N=async V=>{V.preventDefault();const z=new FormData(V.target);z.set("role",c?.value??c??""),z.set("department",h?.value??h??""),z.set("designation",p?.value??p??""),z.set("gender",w?.value??w??""),z.set("dob",D?D.format("YYYY-MM-DD"):""),z.set("doj",k?k.format("YYYY-MM-DD"):""),d?(z.delete("shift_id"),(Array.isArray(m)?m:[]).forEach(M=>{z.append("shift_id[]",M?.value??M??"")})):z.set("shift_id",m?.value??m??""),x&&z.set("file",x);try{const E=a==="edit"&&s,M=E?Jt.editBasic:Jt.addBasic;E&&z.set("staff_id",String(s));const F=E?await zt(M,z,t):await Rt(M,z,t),q=F?.ID??F?.id??s??null;v.success("Success!",{duration:1e3}),o?.({staffId:q,basic:{roleValue:c,departmentValue:h,designationValue:p,genderValue:w,shiftValue:m,dob:D,doj:k,file:x}})}catch(E){v.error(E?.response?.data?.msg??E?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:N,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"number",name:"emp_number",label:"EMP No",defaultValue:i?.emp_number??U,required:!0}),e.jsx(Y,{type:"text",name:"f_name",label:"First Name",defaultValue:i?.f_name??"",required:!0}),e.jsx(Y,{type:"text",name:"l_name",label:"Last Name",defaultValue:i?.l_name??"",required:!0}),e.jsx(Y,{type:"text",name:"pan_no",label:"PAN",defaultValue:i?.pan_no??""}),e.jsx(Y,{type:"text",name:"adhar_no",label:"Aadhar",defaultValue:i?.adhar_no??""}),e.jsx(Q,{label:"Role",options:$,value:c,onChange:V=>g(V??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Q,{label:"Department",options:P,value:h,onChange:V=>u(V??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Q,{label:"Designation",options:O,value:p,onChange:V=>A(V??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Q,{label:"Gender",options:[{value:"Male",label:"Male"},{value:"Female",label:"Female"},{value:"Other",label:"Other"}],value:w,onChange:V=>b(V??null),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Y,{type:"text",name:"email",label:"Email",defaultValue:i?.email??""}),e.jsxs("div",{children:[e.jsx("div",{style:ka,children:"DOB"}),e.jsx(n.DatePicker,{value:D,onChange:V=>R(V),style:_i,placeholder:"Select DOB"})]}),e.jsxs("div",{children:[e.jsx("div",{style:ka,children:"DOJ"}),e.jsx(n.DatePicker,{value:k,onChange:V=>S(V),style:_i,placeholder:"Select DOJ"})]}),e.jsx(Y,{type:"text",name:"bloodGroup",label:"Blood Group",defaultValue:i?.bloodGroup??""}),e.jsx(Y,{type:"text",name:"contact_no",label:"Contact No",defaultValue:i?.contact_no??"",required:!0}),e.jsx(Y,{type:"text",name:"education",label:"Education",defaultValue:i?.education??""}),e.jsxs("div",{children:[e.jsx("div",{style:ka,children:"Shift"}),e.jsx(Q,{options:y,value:m,onChange:V=>j(V??(d?[]:null)),isMulti:d,closeMenuOnSelect:!d,hideSelectedOptions:!1,allowSelectAll:!1,required:!0})]}),e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{style:ka,children:"Profile Picture"}),e.jsx(n.Upload,{maxCount:1,action:eh(),headers:t?{Authorization:t}:void 0,onChange:V=>{if(V?.file?.status==="done"){const z=oh(V?.file?.response);z&&f(z)}V?.file?.status==="removed"&&f("")},children:e.jsx(n.Button,{type:"link",style:{paddingLeft:0},children:x?"Change":"Upload"})})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:ka,children:"Address"}),e.jsx("textarea",{name:"address",rows:3,defaultValue:i?.address??"",placeholder:"Address",style:{width:"100%",resize:"vertical",padding:10,border:"1px solid #d9d9d9",borderRadius:8,outline:"none"}})]}),e.jsx("div",{style:{gridColumn:"1 / -1",display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save & Next",color:"primary"})})]})})}const vn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Ci={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},dh=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Ai=t=>{if(!t)return null;const a=te(t);return a.isValid()?a:null};function ch({token:t,mode:a,staffId:s,initialRows:i,onSubmitted:o,onBack:l}){const[d,c]=r.useState(()=>(Array.isArray(i)&&i.length?i:[{name:"",from:null,to:null,image:""}]).map(b=>({name:b?.name??"",from:Ai(b?.from),to:Ai(b?.to),image:b?.image??""}))),g=r.useMemo(()=>t?{Authorization:t}:void 0,[t]),h=(w,b)=>{c(m=>m.map((j,D)=>D===w?{...j,...b}:j))},u=()=>c(w=>[...w,{name:"",from:null,to:null,image:""}]),p=w=>c(b=>b.length<=1?b:b.filter((m,j)=>j!==w)),A=async w=>{if(w.preventDefault(),!s){v.error("Missing staff id.",{duration:1e3});return}const b=new FormData;b.append("staff_id",String(s)),d.forEach((m,j)=>{b.append(`experience[${j}][name]`,String(m?.name??"")),b.append(`experience[${j}][from]`,m?.from?m.from.format("YYYY-MM-DD"):""),b.append(`experience[${j}][to]`,m?.to?m.to.format("YYYY-MM-DD"):""),b.append(`experience[${j}][image]`,String(m?.image??""))});try{const m=a==="edit",j=m?Jt.editExperience:Jt.addExperience,D=m?await zt(j,b,t):await Rt(j,b,t);v.success("Success!",{duration:1e3}),o?.({experience:d,result:D})}catch(m){v.error(m?.response?.data?.msg??m?.message??"Failed.",{duration:1e3})}};return e.jsx("form",{onSubmit:A,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[d.map((w,b)=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end",border:"1px solid #eee",borderRadius:12,padding:14},children:[e.jsxs("div",{children:[e.jsx("div",{style:vn,children:"Name"}),e.jsx("input",{value:w.name,onChange:m=>h(b,{name:m.target.value}),placeholder:"Company / School",style:{width:"100%",height:40,border:"none",borderBottom:"1px solid #d9d9d9",outline:"none",background:"transparent"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:vn,children:"From"}),e.jsx(n.DatePicker,{value:w.from,onChange:m=>h(b,{from:m}),style:Ci})]}),e.jsxs("div",{children:[e.jsx("div",{style:vn,children:"To"}),e.jsx(n.DatePicker,{value:w.to,onChange:m=>h(b,{to:m}),style:Ci})]}),e.jsxs("div",{children:[e.jsx("div",{style:vn,children:"Document"}),e.jsx(n.Upload,{maxCount:1,action:th(),headers:g,onChange:m=>{if(m?.file?.status==="done"){const j=dh(m?.file?.response);j&&h(b,{image:j})}m?.file?.status==="removed"&&h(b,{image:""})},children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),children:"Upload"})}),!!w.image&&e.jsx("div",{style:{fontSize:12,color:"#666",marginTop:6},children:w.image})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:e.jsx(n.Button,{type:"text",icon:e.jsx(ee.DeleteOutlined,{}),danger:!0,onClick:()=>p(b),disabled:d.length<=1})})]},`exp-${b}`)),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12},children:[e.jsx(n.Button,{icon:e.jsx(ee.PlusOutlined,{}),onClick:u,children:"Add Experience"}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx(n.Button,{onClick:l,children:"Back"}),e.jsx(ne,{type:"submit",value:"Save & Next",color:"primary"})]})]})]})})}const Di=(t,a=[])=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){const s=a.length?a:["allowances","Allowances","dedection","Dedection","deductions","Deductions"],i=[t];t?.data&&typeof t.data=="object"&&i.push(t.data);for(const l of i)for(const d of s){const c=l?.[d]??l?.[d.toLowerCase()]??l?.[d.toUpperCase()];if(Array.isArray(c)&&c.length>0)return c}const o=t?.data;if(Array.isArray(o)&&o.length>0)return o}return[]},Pa=[{label:"Per Hour",value:"Hourly"},{label:"Per Lecture",value:"lecture_wise"}];function uh({token:t,mode:a,staffId:s,initialValues:i,onSubmitted:o,onBack:l}){const[d,c]=r.useState(i?.type??"Permanent"),[g,h]=r.useState(i?.salary_type??Pa[0]?.value),[u,p]=r.useState(Number(i?.amount??0)),[A,w]=r.useState(Number(i?.basic_pay)),[b,m]=r.useState(i?.declarationPERyear??""),{data:j}=W(t?[cc,t]:null,([f,_])=>K(f,_),{revalidateOnFocus:!1}),D=r.useMemo(()=>Di(j,["allowances","Allowances"]),[j]),R=r.useMemo(()=>Di(j,["dedection","Dedection","deductions","Deductions"]),[j]),k=r.useMemo(()=>{const f=Number(A||0),_=(Array.isArray(D)?D:[]).map(y=>{const P=y?.amount_type??y?.amountType??y?.type??"",O=Number(y?.Amount??y?.amount??0),U=String(P).trim().toLowerCase()==="flat"?O:Number(f)/100*Number(O||0);return{...y,value:Number.isFinite(U)?U:0}}),T=(Array.isArray(R)?R:[]).map(y=>{const P=y?.amount_type??y?.amountType??y?.type??"",O=Number(y?.Amount??y?.amount??0),U=String(P).trim().toLowerCase()==="flat"?O:Number(f)/100*Number(O||0);return{...y,value:Number.isFinite(U)?U:0}}),I=_.reduce((y,P)=>y+Number(P?.value||0),0),B=T.reduce((y,P)=>y+Number(P?.value||0),0),L=Math.max(0,Number(f)+I-B);return{allowances:_,deductions:T,netAmount:L}},[D,R,A]),S=async f=>{if(f.preventDefault(),!s){v.error("Missing staff id.",{duration:1e3});return}const _=new FormData;_.append("staff_id",String(s)),_.append("type",d),d==="Nonpermanent"?(_.append("salary_type",g??""),_.append("amount",String(u||"")),_.append("Allowances",JSON.stringify([])),_.append("Dedection",JSON.stringify([]))):(_.append("basic_pay",String(A||"")),_.append("declarationPERyear",String(b??"")),_.append("Allowances",JSON.stringify(k.allowances||[])),_.append("Dedection",JSON.stringify(k.deductions||[])),_.append("amount",String(k.netAmount||0)));try{const T=a==="edit",I=T?Jt.editPayroll:Jt.addPayroll,B=T?await zt(I,_,t):await Rt(I,_,t);o?.({payroll:{staffType:d,salaryType:g,amount:u,basicPay:A,declaration:b},result:B})}catch(T){v.error(T?.response?.data?.msg??T?.message??"Failed.",{duration:1e3})}},x=r.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",ellipsis:!0},{title:"Amount",key:"amount",width:160,render:(f,_)=>`${_?.Amount??""} / ${_?.amount_type??""}`},{title:"Value",dataIndex:"value",key:"value",width:120}],[]);return e.jsx("form",{onSubmit:S,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{label:"Employment Type",options:[{label:"Permanent",value:"Permanent"},{label:"Non Permanent",value:"Nonpermanent"}],value:{label:d==="Nonpermanent"?"Non Permanent":"Permanent",value:d},onChange:f=>c(f?.value??"Permanent"),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),d==="Nonpermanent"?e.jsxs(e.Fragment,{children:[e.jsx(Q,{label:"Type",options:Pa,value:Pa.find(f=>f.value===g)??Pa[0],onChange:f=>h(f?.value??Pa[0]?.value),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsx(Y,{type:"number",label:"Amount",value:u,onChange:f=>p(Number(f.target.value||0)),required:!0})]}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{type:"number",label:"Basic Pay",value:A,onChange:f=>w(Number(f.target.value||0)),required:!0}),e.jsx(Y,{type:"text",label:"IT Declarations/Year",value:b,onChange:f=>m(f.target.value)}),e.jsx(Y,{type:"number",label:"Net Amount",value:k.netAmount,disabled:!0})]})]}),d==="Permanent"&&e.jsxs(e.Fragment,{children:[e.jsx(n.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Allowances"}),children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(f,_)=>`${f?.title??"a"}-${_}`,columns:x,dataSource:k.allowances,pagination:!1})}),e.jsx(n.Card,{size:"small",title:e.jsx("div",{style:{fontWeight:600},children:"Deductions"}),children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(f,_)=>`${f?.title??"d"}-${_}`,columns:x,dataSource:k.deductions,pagination:!1})})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:e.jsx(ne,{type:"submit",value:"Finish",color:"primary"})})]})})}const ph=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function mh({token:t,mode:a="add",staffId:s,onFinished:i}){const[o,l]=r.useState(0),[d,c]=r.useState(s??null),[g,h]=r.useState(null),[u,p]=r.useState(null),[A,w]=r.useState(null),b=a==="edit"?s??d:null,m=r.useMemo(()=>b?`${Ie.staff.basicById}?staff_id=${encodeURIComponent(String(b))}`:null,[b]),j=r.useMemo(()=>b?`${Ie.staff.experienceById}?staff_id=${encodeURIComponent(String(b))}`:null,[b]),D=r.useMemo(()=>b?`${Ie.staff.payrollById}?staff_id=${encodeURIComponent(String(b))}`:null,[b]),{data:R}=W(t&&m?[m,t]:null,([I,B])=>K(I,B)),{data:k}=W(t&&j?[j,t]:null,([I,B])=>K(I,B)),{data:S}=W(t&&D?[D,t]:null,([I,B])=>K(I,B)),x=r.useMemo(()=>{const I=ph(R)[0]??R?.data??R??null;return I?{emp_number:I?.emp_number??I?.empNo??"",f_name:I?.f_name??I?.firstname??I?.first_name??"",l_name:I?.l_name??I?.lastname??I?.last_name??"",pan_no:I?.pan_no??"",adhar_no:I?.adhar_no??"",email:I?.email??"",dob:I?.dob??"",doj:I?.doj??"",bloodGroup:I?.bloodGroup??I?.blood_group??"",contact_no:I?.contact_no??I?.phone??"",education:I?.education??"",address:I?.address??"",file:I?.file??I?.profile_picture??""}:null},[R]),f=r.useMemo(()=>{const I=k?.data??k??null;return(Array.isArray(I?.experience)?I.experience:Array.isArray(I)?I:[]).map(L=>({name:L?.name??"",from:L?.from??"",to:L?.to??"",image:L?.image??""}))},[k]),_=r.useMemo(()=>{const I=S?.data??S??null;return I?{type:I?.type??"Permanent",salary_type:I?.salary_type??"",amount:I?.amount??"",basic_pay:I?.basic_pay??"",declarationPERyear:I?.declarationPERyear??""}:null},[S]),T=r.useMemo(()=>[{title:"Basic"},{title:"Experience"},{title:"Payroll"}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:a==="edit"?"Edit Staff":"Add Staff"}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(n.Steps,{current:o,items:T}),o===0&&e.jsx(lh,{token:t,mode:a,staffId:b,initialValues:x,onSubmitted:({staffId:I})=>{I&&c(I),l(1)}}),o===1&&e.jsx(ch,{token:t,mode:a,staffId:b??d,initialRows:f,onBack:()=>l(0),onSubmitted:()=>l(2)}),o===2&&e.jsx(uh,{token:t,mode:a,staffId:b??d,initialValues:_,onBack:()=>l(1),onSubmitted:()=>{v.success("Completed.",{duration:1e3}),i?.({staffId:b??d}),l(0),a!=="edit"&&(c(null),h(null),p(null),w(null))}})]})})]})}function hh({token:t}){return e.jsx(mh,{token:t,mode:"add"})}const fh=({token:t})=>e.jsx(hh,{token:t}),_n=Ie.staff,yh=Ie.roleDropdown,gh=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},xh=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function bh({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(""),[l,d]=r.useState(""),{data:c}=W(t?[yh,t]:null,([D,R])=>K(D,R)),g=r.useMemo(()=>gh(c),[c]),h=r.useMemo(()=>{const D=a.page,R=a.rowsPerPage,k=i&&!l?`${_n.searchByRole}?role_id=${encodeURIComponent(String(i))}`:l?`${_n.searchByKeywords}?key=${encodeURIComponent(String(l))}`:_n.list,S=k.includes("?")?"&":"?";return`${k}${S}page=${encodeURIComponent(String(D))}&per_page=${encodeURIComponent(String(R))}`},[a.page,a.rowsPerPage,l,i]),{isLoading:u,error:p,data:A,mutate:w}=W(t?[h,t]:null,([D,R])=>K(D,R)),b=r.useMemo(()=>xh(A),[A]),m=async D=>{const R=D?.id??D?.fk_staffID??D?.staff_id;if(R)try{await nn(_n.deactivate,R,t),v.success("Success! Staff deactivated.",{duration:1e3}),await w()}catch(k){v.error(k?.response?.data?.msg??k?.message??"Failed to deactivate staff.",{duration:1e3})}},j=r.useMemo(()=>[{title:"Name",key:"name",ellipsis:!0,render:(D,R)=>`${R?.firstname??R?.first_name??""} ${R?.lastname??R?.last_name??""}`.trim()||R?.name||""},{title:"Role",dataIndex:"role_name",key:"role_name",ellipsis:!0,responsive:["md"]},{title:"Phone",dataIndex:"phone",key:"phone",ellipsis:!0,responsive:["md"]},{title:"Email",dataIndex:"email",key:"email",ellipsis:!0,responsive:["lg"]},{title:"Status",dataIndex:"status",key:"status",width:120,responsive:["lg"]},{title:"Action",key:"action",width:90,fixed:"right",render:(D,R)=>e.jsx(n.Button,{type:"text",danger:!0,size:"small",icon:e.jsx(ee.DeleteOutlined,{}),onClick:()=>m(R),style:{padding:2}})}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20,alignItems:"start"},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:3,style:{margin:0},children:"Filters"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:[{value:"",label:"All Roles"},...g],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Role",placeholder:"Role",allowSelectAll:!1,onChange:D=>{o(D?.value??""),s(R=>({...R,page:1}))}}),e.jsx(Y,{type:"text",label:"Keyword",value:l,onChange:D=>d(D.target.value),placeholder:"Search by keywords"}),e.jsx(ne,{type:"button",value:"Refresh",onClick:()=>w()})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:7,style:{margin:0},children:"Staff Directory"}),children:e.jsx(n.Table,{bordered:!0,size:"small",loading:u,rowKey:D=>String(D?.id??D?.fk_staffID??D?.staff_id??Math.random()),columns:j,dataSource:b,pagination:{current:a.page,pageSize:a.rowsPerPage,onChange:(D,R)=>s({page:D,rowsPerPage:R}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})]})}const jh=({token:t})=>e.jsx(bh,{token:t}),Sh=Ie.attendance,wh=Ie.roleDropdown,Ti=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Cn={display:"block",marginBottom:6,fontSize:"14px",fontWeight:500,color:"#222"},Ri={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function vh({token:t,open:a,onClose:s,roleId:i,onSaved:o}){const[l,d]=r.useState(null),[c,g]=r.useState(""),[h,u]=r.useState(te()),[p,A]=r.useState(te()),[w,b]=r.useState(te()),m=r.useMemo(()=>i?`${Ie.attendance.staffDropdownByRole}?role_id=${encodeURIComponent(String(i))}`:null,[i]),{data:j}=W(t&&m?[m,t]:null,([f,_])=>K(f,_)),D=r.useMemo(()=>Ti(j),[j]),{trigger:R,data:k}=tt(t?Ie.attendance.staffShiftByStaffId:null,(f,{arg:_})=>Gt(f,{arg:_},t)),S=r.useMemo(()=>Ti(k),[k]),x=async()=>{if(!l?.value){v.error("Select staff.",{duration:1e3});return}if(!c){v.error("Select shift.",{duration:1e3});return}const f=new FormData;f.set("staffID",String(l.value)),f.set("shift_id",String(c)),f.set("attendance_date",h?h.format("YYYY-MM-DD"):""),f.set("intime",p?p.format("h:mm a"):""),f.set("outime",w?w.format("h:mm a"):"");try{await Rt(Ie.attendance.manualAttendance,f,t),v.success("Success!",{duration:1e3}),o?.(),s?.(),d(null),g(""),u(te()),A(te()),b(te())}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed.",{duration:1e3})}};return e.jsx(n.Modal,{open:a,onCancel:s,footer:null,destroyOnClose:!0,title:"Attendance",width:620,children:e.jsx(n.Card,{children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Q,{label:"Staff",options:D,value:l,onChange:async f=>{if(d(f??null),g(""),f?.value&&R)try{await R({staff_id:f.value})}catch{}},closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:Cn,children:"Shift"}),e.jsx(n.Radio.Group,{value:c,onChange:f=>g(f.target.value),style:{display:"grid",gap:8},children:S.map(f=>e.jsx(n.Radio,{value:f?.value,children:f?.label??f?.name??f?.title??String(f?.value??"")},String(f?.value)))})]}),e.jsxs("div",{children:[e.jsx("div",{style:Cn,children:"Date"}),e.jsx(n.DatePicker,{value:h,onChange:f=>f&&u(f),style:{width:"100%"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:Cn,children:"Start Time"}),e.jsx(n.TimePicker,{value:p,onChange:f=>f&&A(f),use12Hours:!0,format:"h:mm a",style:Ri})]}),e.jsxs("div",{children:[e.jsx("div",{style:Cn,children:"End Time"}),e.jsx(n.TimePicker,{value:w,onChange:f=>f&&b(f),use12Hours:!0,format:"h:mm a",style:Ri})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(n.Button,{onClick:s,children:"Cancel"}),e.jsx(ne,{type:"button",value:"Save",color:"primary",onClick:x})]})]})})})}const _h=({tableRef:t,excelDisabled:a})=>{const s=new Date().getTime(),i=xa.useReactToPrint({content:()=>t?.current});return e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsxs(n.Row,{gutter:8,children:[e.jsx(n.Col,{children:e.jsx(n.Button,{type:"text",icon:e.jsx(ee.PrinterOutlined,{style:{color:"#5080f8"}}),onClick:i})}),e.jsx(n.Col,{children:a?e.jsx(n.Button,{type:"text",icon:e.jsx(ee.FileTextOutlined,{style:{color:"gray"}}),onClick:()=>v.error("You must save attendance before download",{duration:2e3})}):e.jsx(Qo.DownloadTableExcel,{filename:s,sheet:"users",currentTableRef:t?.current,children:e.jsx(n.Button,{type:"text",icon:e.jsx(ee.FileTextOutlined,{style:{color:"#5080f8"}})})})})]})})})},Ch=(t,a)=>{const s=t?.data?.data??t?.data??t??null;return s?a==="student"?Array.isArray(s?.student)?s.student:[]:Array.isArray(s?.staff)?s.staff:[]:[]},Ah=t=>{const a=t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.total??t?.total_rows,s=Number(a);return Number.isFinite(s)&&s>=0?s:0},Dh=(t,a)=>{const s=t?.data?.data??t?.data??t??null;return s?a==="student"?{sunday:String(s?.sunday??"").toLowerCase()==="yes",holiday:String(s?.holiday??"").toLowerCase()==="yes"}:{sunday:!!s?.sunday,holiday:!!s?.holiday}:{sunday:!1,holiday:!1}};function Th({token:t,url:a,columns:s,reload:i,setReload:o,saveBtnRef:l,setSaveBtnDisabled:d,date:c,type:g="staff"}){const h=r.useRef(null),[u,p]=r.useState({page:0,rowsPerPage:10}),[A,w]=r.useState(!1),[b,m]=r.useState(!1),[j,D]=r.useState(null),[R,k]=r.useState([]),[S,x]=r.useState({sunday:!1,holiday:!1}),[f,_]=r.useState(!0);r.useEffect(()=>{p(L=>({...L,page:0}))},[a]),r.useEffect(()=>{let L=!0;return(async()=>{if(!(!t||!a)){w(!0);try{const P=String(a).includes("?")?"&":"?",O=`${a}${P}page=${u.page+1}&per_page=${u.rowsPerPage}`,$=await K(O,t);if(!L)return;D($),$?.Status==="Success"?(d?.(!1),k(Ch($,g)),x(Dh($,g))):(d?.(!0),k([]),x({sunday:!1,holiday:!1}))}catch{if(!L)return;d?.(!0),k([])}finally{L&&w(!1)}}})(),()=>{L=!1}},[u.page,u.rowsPerPage,i,d,t,g,a]);const T=r.useMemo(()=>Ah(j),[j]);r.useEffect(()=>{const L=(Array.isArray(R)?R:[]).find(y=>y?.attendence_type_id===null);_(!!L)},[R]);const I=async()=>{if(t){m(!0);try{if(g==="staff"){const L=(Array.isArray(R)?R:[]).map(y=>({staff_id:y?.staff_id,attendence_type_id:y?.attendence_type_id?y.attendence_type_id:"1",in_time:y?.intime,out_time:y?.outtime,date:c}));await Rt(Ie.attendance.addAttendanceToStaffByBranch,L,t),v.success("Attendance saved successfully",{duration:2e3}),o?.(y=>!y)}else v.error("Student attendance save is not migrated yet.",{duration:2e3})}catch(L){v.error(L?.response?.data?.msg??L?.message??"Failed required dates",{duration:2e3})}finally{m(!1)}}},B=r.useMemo(()=>(Array.isArray(s)?s:[]).map(y=>y?.selector==="attendence_type_id"?{title:y?.name??"Attendance",dataIndex:y.selector,key:y.selector,render:P=>P==null||P===""?e.jsx(n.Tag,{color:"orange",children:"Not Set"}):String(P)==="1"?e.jsx(n.Tag,{color:"green",children:"Present"}):String(P)==="4"?e.jsx(n.Tag,{color:"red",children:"Absent"}):String(P)==="3"?e.jsx(n.Tag,{color:"orange",children:"Late"}):e.jsx(n.Tag,{children:String(P)})}:y?.selector==="snum"?{title:y?.name??"Sl",key:y.selector,render:(P,O,$)=>$+1}:{title:y?.name??y?.selector,dataIndex:y?.selector,key:y?.selector}),[s]);return e.jsxs("div",{style:{width:"100%"},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs(n.Card,{children:[e.jsx(_h,{tableRef:h,excelDisabled:f}),e.jsx(n.Modal,{open:b,footer:null,closable:!1,centered:!0,children:e.jsxs("div",{style:{display:"grid",placeItems:"center",gap:12,padding:12},children:[e.jsx(n.Spin,{size:"large"}),e.jsx("div",{children:"Please wait..."})]})}),S.sunday?e.jsx("div",{style:{textAlign:"center",fontWeight:600,padding:"16px 0"},children:"Weekly Off"}):S.holiday?e.jsx("div",{style:{textAlign:"center",padding:"16px 0"},children:e.jsx("div",{style:{fontWeight:700,marginBottom:6},children:"Holiday"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:h,children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(L,y)=>String(L?.id??L?.staff_id??y),columns:B,dataSource:R,loading:A,pagination:{current:u.page+1,pageSize:u.rowsPerPage,total:T,showSizeChanger:!0,onChange:(L,y)=>p({page:L-1,rowsPerPage:y})},scroll:{x:"max-content"}})}),e.jsx("button",{type:"button",onClick:I,ref:l,style:{display:"none"},children:"hidden"})]})]})]})}const Rh=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Ih={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function kh({token:t}){const[a,s]=r.useState(""),[i,o]=r.useState(te().format("YYYY-MM-DD")),[l,d]=r.useState(!1),[c,g]=r.useState(null),[h,u]=r.useState(!1),[p,A]=r.useState(!0),[w,b]=r.useState(!1),m=r.useRef(null),{data:j}=W(t?[wh,t]:null,([k,S])=>K(k,S)),D=r.useMemo(()=>Rh(j),[j]),R=r.useMemo(()=>[{id:"1",name:"Staff Id",selector:"employee_id",sortable:!0},{id:"2",name:"Name",selector:"full_name",sortable:!0},{id:"4",name:"Contact",selector:"contact_no",sortable:!0},{id:"3",name:"Attendance",selector:"attendence_type_id",sortable:!0},{id:"5",name:"In Time",selector:"intime",sortable:!0},{id:"6",name:"Out Time",selector:"outtime",sortable:!0}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,onChange:k=>s(k?.value??""),required:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{defaultValue:te(),onChange:k=>k&&o(k.format("YYYY-MM-DD")),style:Ih,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:()=>{!a||!i||(g(`${Sh.staffListForAttendance}?role=${encodeURIComponent(String(a))}&date=${encodeURIComponent(String(i))}`),d(k=>!k))}})})]})}),e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,flexWrap:"wrap",marginBottom:12},children:[e.jsx(n.Button,{size:"small",type:h?"primary":"default",onClick:()=>u(k=>!k),children:h?"Marked":"Mark As Holiday"}),e.jsx(n.Button,{size:"small",type:"default",disabled:p,onClick:()=>b(!0),children:"Give Attendance"})]}),c?e.jsx(Th,{token:t,url:c,columns:R,reload:l,setReload:d,saveBtnRef:m,setSaveBtnDisabled:A,date:i,type:"staff",holidayChecked:h}):null]}),e.jsx(vh,{token:t,open:w,onClose:()=>b(!1),roleId:a,onSaved:()=>d(k=>!k)})]})}const Ph=({token:t})=>e.jsx(kh,{token:t}),Ii=Ie.attendanceReport.monthlyStaffReport,Oh=Ie.roleDropdown,Mh=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Eh({token:t}){const a=r.useRef(null),[s,i]=r.useState(!1),[o,l]=r.useState([]),[d,c]=r.useState({role:"",rolllabel:"",year:"",month:""}),g=r.useMemo(()=>nr(5),[]),{data:h}=W(t?[Oh,t]:null,([L,y])=>K(L,y)),u=r.useMemo(()=>Mh(h),[h]),[p,A]=r.useState([]),[w,b]=r.useState(1),[m,j]=r.useState(!1),[D,R]=r.useState(!1),[k,S]=r.useState(null),x=r.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.session_id??"1"}catch{return"1"}},[]),{trigger:f}=tt(t&&Ii?`${Ii}?page=${w}&per_page=3`:null,(L,{arg:y})=>Gt(L,{arg:y},t),{onSuccess:L=>{j(!1);const y=Array.isArray(L)?L:[];y.length>0&&A(P=>[...P||[],...y]),y.length>1?b(P=>P+1):R(!1)},onError:()=>{j(!1),R(!1)}});r.useEffect(()=>{D&&f&&k&&f(k)},[D,w,k,f]);const _=r.useMemo(()=>{const L=[{title:"Staff Id",dataIndex:"employee_id",key:"employee_id",align:"center"},{title:"Name",dataIndex:"full_name",key:"full_name",render:(y,P)=>e.jsx("span",{className:"attendanceFont",style:{cursor:"pointer",whiteSpace:"nowrap",color:"blue",textDecoration:"underline"},children:P?.full_name??""})}];return Array.isArray(p)&&p.length>0&&((p[0]?.monthly_data??[]).forEach((P,O)=>{L.push({title:O+1,align:"center",key:String(O+1),render:($,U)=>{const N=U?.monthly_data?.[O]?.[0]?.data?.[0]??{},V=N?.intime??"",z=N?.outtime??"",E=N?.attendance_type??"";return e.jsx(n.Tooltip,{title:e.jsxs("div",{style:{fontSize:12},children:[e.jsxs("div",{children:["In Time ",V]}),e.jsxs("div",{children:["Out Time ",z]})]}),placement:"top",children:e.jsx("span",{className:"attendanceFont",style:{fontSize:10,display:"flex",justifyContent:"center"},children:et(E)})})}})}),L.push({title:"Total",key:"Total",render:(P,O)=>{const $=O?.monthly_data??[],U=$.filter(V=>V?.[0]?.data?.[0]?.attendance_type==="A").length,N=$.filter(V=>V?.[0]?.data?.[0]?.attendance_type==="P").length;return e.jsx("span",{className:"attendanceFont",children:e.jsxs("b",{children:["A : ",U," P : ",N]})})}})),L},[p]),T=r.useMemo(()=>[{label:"Present",el:et("P")},{label:"Absent",el:et("A")},{label:"Leave",el:et("L")},{label:"Weekly Off",el:et("W")},{label:"Holiday",el:et("H")}],[]),I=r.useMemo(()=>d.month?o.find(L=>L?.value==d.month)?.label??d.month??"--":"--",[d.month,o]),B=async L=>{if(L.preventDefault(),!d.role||!d.year||!d.month)return;b(1),j(!0),A([]);const y={session:x,year:d.year,month:d.month,day:"01",role:d.role};S(y),R(!0),await f?.(y)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{className:"d-print-none",title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Attendance Report"}),children:e.jsx("form",{onSubmit:B,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:u,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:L=>c(y=>({...y,role:L?.value??"",rolllabel:L?.label??""}))}),e.jsx(Q,{options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:L=>{const y=sr(L?.value);l(y),i(P=>!P),c(P=>({...P,year:L?.label??""}))}}),e.jsx(Q,{options:o,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:L=>c(y=>({...y,month:L?.value??""}))},`month-${s}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Monthly Attendance Report"}),children:e.jsxs("div",{ref:a,children:[e.jsx("div",{className:"print-only",children:e.jsx(Ot,{})}),e.jsxs("div",{style:{border:"1px solid #ddd",borderRadius:8,padding:16,marginBottom:24,backgroundColor:"#f8f9fa"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:12,alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:18,fontWeight:600,marginBottom:6},children:"Staff Attendance Summary"}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:10,fontSize:13},children:[e.jsxs("div",{children:["Role: ",e.jsx("span",{style:{fontWeight:700},children:d.rolllabel||"--"})]}),e.jsxs("div",{children:["Year: ",e.jsx("span",{style:{fontWeight:700},children:d.year||"--"})]}),e.jsxs("div",{children:["Month: ",e.jsx("span",{style:{fontWeight:700},children:I})]})]})]}),e.jsx("div",{className:"d-print-none",style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(wt,{data:{tableRef:a}})})]}),e.jsx("div",{style:{marginTop:14,paddingTop:14,borderTop:"1px solid #e0e0e0"},children:e.jsx("div",{style:{display:"flex",justifyContent:"center",flexWrap:"wrap",gap:12,fontSize:12},children:T.map(L=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsxs("div",{children:[L.label," :"]}),e.jsx("div",{children:L.el})]},L.label))})})]}),e.jsx(n.Skeleton,{active:!0,loading:m,paragraph:{rows:10},children:e.jsx(n.Table,{size:"small",bordered:!0,className:"my-zero-padding-table",columns:_,dataSource:p,pagination:!1,scroll:{x:"max-content"},rowKey:(L,y)=>String(L?.staff_id??L?.id??y)})})]})})]})}const Fh=({token:t})=>e.jsx(Eh,{token:t}),ki=Ie.payroll,Uh=Ie.roleDropdown,$h=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Nh=t=>t?.data?.data??t?.data??t??[];function Lh({token:t,receiptDetailsPath:a="/HumanResourceDashboard/PayrollReceiptDetails",onOpenReceiptDetails:s}){const[i,o]=r.useState({page:1,rowsPerPage:10}),[l,d]=r.useState(!1),[c,g]=r.useState([]),[h,u]=r.useState({role:"",roleLabel:"",year:"",month:""}),[p,A]=r.useState(null),w=_=>{if(!_)return;if(typeof s=="function"){s(_);return}const T=`${a}?id=${encodeURIComponent(String(_))}`;typeof window<"u"&&window?.location&&(window.location.href=T)},{data:b}=W(t?[Uh,t]:null,([_,T])=>K(_,T)),m=r.useMemo(()=>$h(b),[b]),j=r.useMemo(()=>nr(5),[]),{isLoading:D,error:R,data:k}=W(t&&p?[p,t]:null,([_,T])=>K(_,T)),S=r.useMemo(()=>{const _=Nh(k);return Array.isArray(_)?_:[]},[k]),x=r.useMemo(()=>{const _=k?.pagination?.total_rows??k?.data?.pagination?.total_rows??k?.total??k?.total_rows,T=Number(_);return Number.isFinite(T)&&T>=0?T:S.length},[k,S.length]),f=r.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(_,T,I)=>I+1},{title:"Name",dataIndex:"full_name",key:"full_name",ellipsis:!0},{title:"Designations",dataIndex:"designations",key:"designations",ellipsis:!0,responsive:["md"]},{title:"Mobile No",dataIndex:"contact_no",key:"contact_no",width:140,responsive:["md"]},{title:"Status",dataIndex:"status",key:"status",width:120,align:"center",render:(_,T)=>{const I=T?.id??T?.staff_id??T?.staffId;return e.jsx(n.Button,{type:"link",size:"small",style:{padding:0,fontSize:12},onClick:()=>{w(I)},children:Go(T?.status)})}}],[]);return e.jsx("div",{style:{display:"grid",gap:20},children:e.jsxs(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll"}),children:[e.jsx("form",{onSubmit:_=>{if(_.preventDefault(),!h.role||!h.year||!h.month)return;const T=`${ki.payrollByRole}?page=${encodeURIComponent(String(i.page))}&per_page=${encodeURIComponent(String(i.rowsPerPage))}&role=${encodeURIComponent(String(h.role))}&year=${encodeURIComponent(String(h.year))}&month=${encodeURIComponent(String(h.month))}`;A(T)},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end",marginBottom:14,padding:14,borderRadius:12,border:"1px solid #eee",background:"#fafafa"},children:[e.jsx(Q,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Roles",placeholder:"Roles",allowSelectAll:!1,name:"role",required:!0,onChange:_=>u(T=>({...T,role:_?.value??"",roleLabel:_?.label??""}))}),e.jsx(Q,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Year",allowSelectAll:!1,name:"year",required:!0,onChange:_=>{const T=sr(_?.value);g(T),d(I=>!I),u(I=>({...I,year:_?.label??"",month:""}))}}),e.jsx(Q,{options:c,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Month",allowSelectAll:!1,name:"month",required:!0,onChange:_=>u(T=>({...T,month:_?.value??""}))},`month-${l}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary",onClick:()=>o(_=>({..._,page:1}))})})]})}),e.jsx(n.Table,{bordered:!0,size:"small",loading:D,rowKey:(_,T)=>String(_?.id??_?.staff_id??T),columns:f,dataSource:S,pagination:{current:i.page,pageSize:i.rowsPerPage,total:x,showSizeChanger:!0,onChange:(_,T)=>{o({page:_,rowsPerPage:T}),!(!h.role||!h.year||!h.month)&&A(`${ki.payrollByRole}?page=${encodeURIComponent(String(_))}&per_page=${encodeURIComponent(String(T))}&role=${encodeURIComponent(String(h.role))}&year=${encodeURIComponent(String(h.year))}&month=${encodeURIComponent(String(h.month))}`)}},scroll:{x:"max-content"}})]})})}const Bh=({token:t})=>e.jsx(Lh,{token:t}),rl=Ie.leave,Sa=({baseUrl:t,page:a=1,perPage:s=10,token:i})=>W(i&&t?[t,a,s,i]:null,([l,d,c,g])=>ah({baseUrl:l,page:d,perPage:c},g)),qh=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:rl.requestTable,page:a,perPage:s}),zh=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Yh=(t,a)=>{const s=new FormData;return Object.entries(t??{}).forEach(([i,o])=>{o!=null&&s.append(i,String(o))}),s.set("status",a),s};function Vh({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),{isLoading:i,error:o,data:l,mutate:d}=qh({token:t,page:a.page,perPage:a.rowsPerPage}),c=r.useMemo(()=>zh(l),[l]),g=async(u,p)=>{try{const A=Yh(u,p),w=await zt(rl.approveRequest,A,t);w?.Status==="Success"?v.success("Success! Updated request.",{duration:1e3,icon:"🚀"}):v.error(w?.msg??"Failed to update request.",{duration:1e3}),await d()}catch(A){v.error(A?.response?.data?.msg??A?.message??"Failed to update request.",{duration:1e3})}},h=r.useMemo(()=>[{title:"Name",key:"full_name",ellipsis:!0,render:(u,p)=>p?.full_name??p?.staff_name??""},{title:"From",key:"leave_from",width:120,render:(u,p)=>p?.leave_from??p?.from_date??""},{title:"To",key:"leave_to",width:120,render:(u,p)=>p?.leave_to??p?.to_date??""},{title:"Leave Type",key:"leavetype",ellipsis:!0,render:(u,p)=>p?.leavetype??p?.leave_type??""},{title:"Leave Days",key:"leave_days",width:110,render:(u,p)=>p?.leave_days??""},{title:"Remarks",key:"employee_remark",ellipsis:!0,responsive:["md"],render:(u,p)=>p?.employee_remark??p?.reason??""},{title:"View",key:"document_file",width:140,render:(u,p)=>{const A=p?.document_file;return A?e.jsx(n.Button,{size:"small",onClick:()=>window.open(A,"_blank","noopener,noreferrer"),children:"View Document"}):"-"}},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(u,p)=>{const A=String(p?.status??"").toLowerCase();return A==="approved"?e.jsx(n.Tag,{color:"green",children:"Approved"}):A==="declined"?e.jsx(n.Tag,{color:"red",children:"Declined"}):e.jsxs("div",{style:{display:"flex",justifyContent:"center",gap:10},children:[e.jsx(n.Button,{type:"text",size:"small",onClick:()=>g(p,"approved"),icon:e.jsx(ee.CheckOutlined,{style:{color:"#06c937"}})}),e.jsx(n.Button,{type:"text",size:"small",onClick:()=>g(p,"declined"),icon:e.jsx(ee.CloseOutlined,{style:{color:"#e80911"}})})]})}}],[t]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Approve Leave Requests"}),children:e.jsx(n.Table,{bordered:!0,size:"small",loading:i,rowKey:(u,p)=>String(u?.id??u?.leave_id??p),columns:h,dataSource:c,pagination:{current:a.page,pageSize:a.rowsPerPage,onChange:(u,p)=>s({page:u,rowsPerPage:p}),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const Wh=({token:t})=>e.jsx(Vh,{token:t}),Hh=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",Kh=({token:t,value:a,onChange:s})=>{const i=r.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(n.Upload,{maxCount:1,action:sl(),headers:i,onChange:o=>{if(o?.file?.status==="done"){const l=Hh(o?.file?.response);l&&s?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})})},il=Ie.leave,Gh=Ie.master.leaveType.dropdown,Jh=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:il.table,page:a,perPage:s}),Qh=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},ks={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Xh({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(""),[c]=n.Form.useForm(),{isLoading:g,error:h,data:u,mutate:p}=Jh({token:t,page:a.page,perPage:a.rowsPerPage}),{data:A}=W(t?[Gh,t]:null,([S,x])=>K(S,x)),w=r.useMemo(()=>Qh(A),[A]),b=(S,x)=>s({page:S,rowsPerPage:parseInt(x,10)}),m=()=>{d(""),c.resetFields(),c.setFieldsValue({apply_date:te()}),o(!0)},j=()=>{o(!1),d(""),c.resetFields()},D=async S=>{const x=new FormData;x.set("apply_date",S?.apply_date?S.apply_date.format("YYYY-MM-DD"):""),x.set("leave_type",S?.leave_type?.value??S?.leave_type??""),x.set("from_date",S?.from_date?S.from_date.format("YYYY-MM-DD"):""),x.set("to_date",S?.to_date?S.to_date.format("YYYY-MM-DD"):""),x.set("reason",S?.reason??""),l&&x.set("file",l);try{await Rt(il.apply,x,t),v.success("Success! Leave request submitted.",{duration:1e3}),j(),await p()}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to submit leave request.",{duration:1e3})}},R=r.useMemo(()=>{const S=u?.data??u??[];return Array.isArray(S)?S:Array.isArray(S?.data)?S.data:[]},[u]),k=r.useMemo(()=>[{title:"Leave Type",key:"leavetype",render:(S,x)=>x?.leavetype??x?.leave_type??""},{title:"Apply Date",key:"date",width:130,render:(S,x)=>x?.date??x?.apply_date??""},{title:"From",key:"leave_from",width:130,render:(S,x)=>x?.leave_from??x?.from_date??""},{title:"To",key:"leave_to",width:130,render:(S,x)=>x?.leave_to??x?.to_date??""},{title:"Approval Status",dataIndex:"status",key:"status",width:140},{title:"Remark",key:"employee_remark",render:(S,x)=>x?.employee_remark??"",ellipsis:!0,responsive:["md"]}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:i,title:"Add Leave Request",onCancel:j,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:c,layout:"vertical",onFinish:D,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"apply_date",rules:[{required:!0,message:"Select date"}],children:e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{style:ks})]})}),e.jsx(n.Form.Item,{name:"leave_type",rules:[{required:!0,message:"Select leave type"}],children:e.jsx(Q,{options:w,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Leave Type",allowSelectAll:!1})}),e.jsx(n.Form.Item,{name:"from_date",rules:[{required:!0,message:"Select from date"}],children:e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"From"}),e.jsx(n.DatePicker,{style:ks})]})}),e.jsx(n.Form.Item,{name:"to_date",rules:[{required:!0,message:"Select to date"}],children:e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"To"}),e.jsx(n.DatePicker,{style:ks})]})}),e.jsx(n.Form.Item,{name:"reason",rules:[{required:!0,message:"Enter reason"}],children:e.jsx(Y,{type:"text",label:"Reason",placeholder:"Reason"})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:22},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222"},children:"Attachment"}),e.jsx(Kh,{token:t,value:l,onChange:d})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:12},children:[e.jsx(n.Button,{onClick:j,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Apply Leave"}),extra:e.jsx(ne,{type:"button",value:"Add Leave Request",onClick:m})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Leave Requests"}),children:e.jsx(n.Table,{bordered:!0,size:"small",loading:g,rowKey:(S,x)=>String(S?.id??S?.leave_id??x),columns:k,dataSource:R,pagination:{current:a.page,pageSize:a.rowsPerPage,onChange:(S,x)=>b(S,x),showSizeChanger:!0},scroll:{x:"max-content"}})})]})}const Zh=({token:t})=>e.jsx(Xh,{token:t}),Nn=Ie.master.leaveType,ef=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:Nn.table,page:a,perPage:s});function tf({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=r.useState(!1),[c,g]=r.useState(null),{isLoading:h,error:u,data:p,mutate:A}=ef({token:t,page:a.page,perPage:a.rowsPerPage}),w=(S,x)=>{s({page:S,rowsPerPage:parseInt(x,10)})},b=async S=>{const x=new FormData;x.set("title",S?.title??"");try{await A(Rt(Nn.add,x,t),ze(x)),v.success("Success! Added new leave type.",{duration:1e3,icon:"🎉"}),i.resetFields()}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to add leave type.",{duration:1e3})}},m=S=>{g(S??null),o.setFieldsValue({title:S?.leave_type_name??S?.name??""}),d(!0)},j=()=>{d(!1),g(null),o.resetFields()},D=async S=>{const x=c?.id??c?.leave_type_id;if(!x){v.error("Missing leave type id.",{duration:1e3});return}const f=new FormData;f.set("id",String(x)),f.set("title",S?.title??"");try{await zt(Nn.edit,f,t),await A(),v.success("Success! Updated leave type.",{duration:1e3,icon:"🚀"}),j()}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed to update leave type.",{duration:1e3})}},R=async S=>{const x=S?.id??S?.leave_type_id;if(x)try{await A(nn(Nn.remove,x,t),Ne(x)),v.success("Success! Deleted leave type.",{duration:1e3})}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to delete leave type.",{duration:1e3})}},k=r.useMemo(()=>[{title:"Name",dataIndex:"type",key:"type",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(S,x)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>m(x)}),e.jsx(n.Popconfirm,{title:"Remove leave type?",okText:"Yes",cancelText:"No",onConfirm:()=>R(x),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:l,title:"Edit Leave Type",onCancel:j,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:D,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:j,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Leave Type"}),children:e.jsxs(n.Form,{form:i,layout:"vertical",onFinish:b,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter leave type name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Leave Type List"}),children:e.jsx(Te,{parentCallback:w,data:{newData:p,columns:k,columnstype:"antd",action:!1,Loading:h,error:u}})})]})}const af=({token:t})=>e.jsx(tf,{token:t}),Ln=Ie.master.department,nf=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:Ln.table,page:a,perPage:s});function sf({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=r.useState(!1),[c,g]=r.useState(null),{isLoading:h,error:u,data:p,mutate:A}=nf({token:t,page:a.page,perPage:a.rowsPerPage}),w=(S,x)=>{s({page:S,rowsPerPage:parseInt(x,10)})},b=async S=>{const x=new FormData;x.set("title",S?.title??"");try{await A(Rt(Ln.add,x,t),ze(x)),v.success("Success! Added new department.",{duration:1e3,icon:"🎉"}),i.resetFields()}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to add department.",{duration:1e3})}},m=S=>{g(S??null),o.setFieldsValue({title:S?.department_name??S?.name??""}),d(!0)},j=()=>{d(!1),g(null),o.resetFields()},D=async S=>{const x=c?.id??c?.department_id;if(!x){v.error("Missing department id.",{duration:1e3});return}const f=new FormData;f.set("id",String(x)),f.set("title",S?.title??"");try{await zt(Ln.edit,f,t),await A(),v.success("Success! Updated department.",{duration:1e3,icon:"🚀"}),j()}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed to update department.",{duration:1e3})}},R=async S=>{const x=S?.id??S?.department_id;if(x)try{await A(nn(Ln.remove,x,t),Ne(x)),v.success("Success! Deleted department.",{duration:1e3})}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to delete department.",{duration:1e3})}},k=r.useMemo(()=>[{title:"Name",dataIndex:"department_name",key:"department_name",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(S,x)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>m(x)}),e.jsx(n.Popconfirm,{title:"Remove department?",okText:"Yes",cancelText:"No",onConfirm:()=>R(x),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:l,title:"Edit Department",onCancel:j,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:D,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:j,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Department"}),children:e.jsxs(n.Form,{form:i,layout:"vertical",onFinish:b,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter department name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Department List"}),children:e.jsx(Te,{parentCallback:w,data:{newData:p,columns:k,columnstype:"antd",action:!1,Loading:h,error:u}})})]})}const rf=({token:t})=>e.jsx(sf,{token:t}),Bn=Ie.master.designation,of=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:Bn.table,page:a,perPage:s});function lf({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=r.useState(!1),[c,g]=r.useState(null),{isLoading:h,error:u,data:p,mutate:A}=of({token:t,page:a.page,perPage:a.rowsPerPage}),w=(S,x)=>{s({page:S,rowsPerPage:parseInt(x,10)})},b=async S=>{const x=new FormData;x.set("title",S?.title??"");try{await A(Rt(Bn.add,x,t),ze(x)),v.success("Success! Added new designation.",{duration:1e3,icon:"🎉"}),i.resetFields()}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to add designation.",{duration:1e3})}},m=S=>{g(S??null),o.setFieldsValue({title:S?.designation??""}),d(!0)},j=()=>{d(!1),g(null),o.resetFields()},D=async S=>{const x=c?.id??c?.designation_id;if(!x){v.error("Missing designation id.",{duration:1e3});return}const f=new FormData;f.set("id",String(x)),f.set("title",S?.title??"");try{await zt(Bn.edit,f,t),await A(),v.success("Success! Updated designation.",{duration:1e3,icon:"🚀"}),j()}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed to update designation.",{duration:1e3})}},R=async S=>{const x=S?.id??S?.designation_id;if(x)try{await A(nn(Bn.remove,x,t),Ne(x)),v.success("Success! Deleted designation.",{duration:1e3})}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to delete designation.",{duration:1e3})}},k=r.useMemo(()=>[{title:"Name",dataIndex:"designation",key:"designation",ellipsis:!0},{title:"Action",key:"action",width:110,fixed:"right",render:(S,x)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>m(x)}),e.jsx(n.Popconfirm,{title:"Remove designation?",okText:"Yes",cancelText:"No",onConfirm:()=>R(x),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:l,title:"Edit Designation",onCancel:j,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:D,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:j,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Designation"}),children:e.jsxs(n.Form,{form:i,layout:"vertical",onFinish:b,children:[e.jsx(n.Form.Item,{name:"title",rules:[{required:!0,message:"Enter designation name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Designation List"}),children:e.jsx(Te,{parentCallback:w,data:{newData:p,columns:k,columnstype:"antd",action:!1,Loading:h,error:u}})})]})}const df=({token:t})=>e.jsx(lf,{token:t}),qn=Ie.master.shift,cf=({token:t,page:a=1,perPage:s=10})=>Sa({token:t,baseUrl:qn.table,page:a,perPage:s}),ct="hh:mm A",da=t=>{const a=String(t??"");if(!a)return null;const s=te(a,[ct,"HH:mm","HH:mm:ss"],!0);return s.isValid()?s:null},ca=t=>t?t.format(ct):"",St={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function uf({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=r.useState(!1),[c,g]=r.useState(null),{isLoading:h,error:u,data:p,mutate:A}=cf({token:t,page:a.page,perPage:a.rowsPerPage}),w=(f,_)=>{s({page:f,rowsPerPage:parseInt(_,10)})},b=(f,_)=>{const T=new FormData;return _&&T.set("id",String(_)),T.set("name",f?.name??""),T.set("start_time",ca(f?.start_time)),T.set("end_time",ca(f?.end_time)),T.set("shift_start_from",ca(f?.shift_start_from)),T.set("shift_start_to",ca(f?.shift_start_to)),T.set("shift_end_from",ca(f?.shift_end_from)),T.set("shift_end_to",ca(f?.shift_end_to)),T},m=async f=>{try{const _=b(f);await A(Rt(qn.add,_,t),ze(_)),v.success("Success! Added new shift.",{duration:1e3,icon:"🎉"}),i.resetFields()}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed to add shift.",{duration:1e3})}},j=f=>{g(f??null),o.setFieldsValue({name:f?.shift_name??f?.name??"",start_time:da(f?.start_time),end_time:da(f?.end_time),shift_start_from:da(f?.shift_start_from),shift_start_to:da(f?.shift_start_to),shift_end_from:da(f?.shift_end_from),shift_end_to:da(f?.shift_end_to)}),d(!0)},D=()=>{d(!1),g(null),o.resetFields()},R=async f=>{const _=c?.id??c?.shift_id;if(!_){v.error("Missing shift id.",{duration:1e3});return}try{const T=b(f,_);await zt(qn.edit,T,t),await A(),v.success("Success! Updated shift.",{duration:1e3,icon:"🚀"}),D()}catch(T){v.error(T?.response?.data?.msg??T?.message??"Failed to update shift.",{duration:1e3})}},k=async f=>{const _=f?.id??f?.shift_id;if(_)try{await A(nn(qn.remove,_,t),Ne(_)),v.success("Success! Deleted shift.",{duration:1e3})}catch(T){v.error(T?.response?.data?.msg??T?.message??"Failed to delete shift.",{duration:1e3})}},S=r.useMemo(()=>[{title:"Name",dataIndex:"shift_name",key:"shift_name",ellipsis:!0,fixed:"left",width:160},{title:"Start Time",dataIndex:"start_time",key:"start_time",width:120},{title:"End Time",dataIndex:"end_time",key:"end_time",width:120},{title:"Start From",dataIndex:"shift_start_from",key:"shift_start_from",width:120,responsive:["md"]},{title:"Start To",dataIndex:"shift_start_to",key:"shift_start_to",width:120,responsive:["md"]},{title:"End From",dataIndex:"shift_end_from",key:"shift_end_from",width:120,responsive:["md"]},{title:"End To",dataIndex:"shift_end_to",key:"shift_end_to",width:120,responsive:["md"]},{title:"Action",key:"action",width:110,fixed:"right",render:(f,_)=>e.jsxs(n.Space,{size:6,children:[e.jsx(n.Button,{type:"text",size:"small",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>j(_)}),e.jsx(n.Popconfirm,{title:"Remove shift?",okText:"Yes",cancelText:"No",onConfirm:()=>k(_),children:e.jsx(n.Button,{danger:!0,type:"text",size:"small",icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[]),x=[{required:!0,message:"Select time"}];return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{open:l,title:"Edit Shift",onCancel:D,footer:null,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:R,children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsx(n.Form.Item,{name:"start_time",label:"Start Time",rules:x,children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})}),e.jsx(n.Form.Item,{name:"end_time",label:"End Time",rules:x,children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})}),e.jsx(n.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})}),e.jsx(n.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})}),e.jsx(n.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})}),e.jsx(n.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(n.Button,{onClick:D,children:"Cancel"}),e.jsx(ne,{type:"submit",value:"Update",color:"primary"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Shift"}),children:e.jsx(n.Form,{form:i,layout:"vertical",onFinish:m,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",rules:[{required:!0,message:"Enter shift name"}],children:e.jsx(Y,{type:"text",label:"Name"})}),e.jsx(n.Form.Item,{name:"start_time",label:"Start Time",rules:x,children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})}),e.jsx(n.Form.Item,{name:"end_time",label:"End Time",rules:x,children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})}),e.jsx(n.Form.Item,{name:"shift_start_from",label:"Start Time From",children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})}),e.jsx(n.Form.Item,{name:"shift_start_to",label:"Start Time To",children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})}),e.jsx(n.Form.Item,{name:"shift_end_from",label:"End Time From",children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})}),e.jsx(n.Form.Item,{name:"shift_end_to",label:"End Time To",children:e.jsx(n.TimePicker,{format:ct,use12Hours:!0,style:St})}),e.jsx(ne,{type:"submit",value:"Save",color:"primary"})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Shift List"}),children:e.jsx(Te,{parentCallback:w,data:{newData:p,columns:S,columnstype:"antd",action:!1,Loading:h,error:u}})})]})}const pf=({token:t})=>e.jsx(uf,{token:t}),Pi=Ie.attendance;function mf({data:t}){return t?e.jsx("div",{style:{margin:15,fontSize:13,padding:10},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e.jsxs("thead",{children:[e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{}),(t?.shifts??[]).map((a,s)=>e.jsx("th",{colSpan:"2",style:{border:"1px solid #000",paddingLeft:10},children:a?.shift_name??""},`${s}heading1`))]}),e.jsxs("tr",{children:[e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Sl.No"}),e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Teacher's Name"}),(t?.shifts??[]).map((a,s)=>e.jsxs(r.Fragment,{children:[e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"In Time"}),e.jsx("th",{style:{border:"1px solid #000",paddingLeft:10},children:"Out Time"})]},`${s}heading2`))]})]}),e.jsx("tbody",{children:(t?.data??[]).map((a,s)=>e.jsxs("tr",{children:[e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:s+1})}),e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:`${a?.name??""} ${a?.surname??""}`.trim()})}),(t?.shifts??[]).map((i,o)=>e.jsxs(r.Fragment,{children:[e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:a?.attendance_data?(a.attendance_data?.[i?.office_shift_id]?.checkintime??"").toUpperCase():""})}),e.jsx("td",{style:{border:"1px solid #000",paddingLeft:10},children:e.jsx("div",{style:{paddingLeft:10},children:a?.attendance_data?(a.attendance_data?.[i?.office_shift_id]?.checkouttime??"").toUpperCase():""})})]},`${o}cells${s}`))]},`${s}row`))})]})}):null}const hf=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},ff=t=>{const a=String(t??"").toLowerCase();return a==="present"?e.jsx(n.Tag,{color:"green",children:"Present"}):a==="absent"?e.jsx(n.Tag,{color:"red",children:"Absent"}):a==="leave"?e.jsx(n.Tag,{color:"orange",children:"Leave"}):e.jsx(n.Tag,{children:t??""})};function yf({token:t}){const[a,s]=r.useState(te()),[i,o]=r.useState(!1),[l,d]=r.useState(0),c=r.useMemo(()=>`${i?Pi.dailyAttendanceMultipleShift:Pi.dailyAttendance}?attendance_date=${encodeURIComponent(a.format("YYYY-MM-DD"))}`,[a,i,l]),{isLoading:g,error:h,data:u}=W(t?[c,t]:null,([m,j])=>K(m,j)),p=r.useMemo(()=>hf(u),[u]),A=r.useMemo(()=>i?u?.data?.data??u?.data??u??null:null,[u,i]),w=xa.useReactToPrint({content:()=>document.getElementById("ubk-hr-daily-attendance-print")}),b=r.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(m,j,D)=>D+1},{title:"Name",key:"name",render:(m,j)=>`${j?.name??""} ${j?.surname??""}`.trim(),ellipsis:!0},{title:"Designations",dataIndex:"designations",key:"designations",ellipsis:!0,responsive:["md"]},{title:"Status",key:"attendance",width:160,render:(m,j)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[ff(j?.attendance),j?.late_time?e.jsx(n.Tag,{color:"red",children:"L"}):null]})},{title:"In Time",key:"intime",width:120,render:(m,j)=>j?.attendance_data?.[0]?.intime??""},{title:"Out Time",key:"outtime",width:120,render:(m,j)=>j?.attendance_data?.[0]?.outtime??""},{title:"Late",key:"late",width:100,render:(m,j)=>j?.late_time?e.jsx(n.Tag,{color:"red",children:j.late_time}):""}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Daily Attendance"}),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end",padding:14,borderRadius:12,border:"1px solid #eee",background:"#fafafa"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{value:a,onChange:m=>m&&s(m),style:{width:"100%"},allowClear:!1})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingTop:22},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222"},children:"Multiple Shift"}),e.jsx(n.Switch,{checked:i,onChange:o})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",onClick:()=>d(m=>m+1)})})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Staff Attendance List"}),extra:e.jsx(ee.PrinterOutlined,{style:{color:"#5080f8",fontSize:18,cursor:"pointer"},onClick:w}),children:e.jsxs("div",{id:"ubk-hr-daily-attendance-print",children:[e.jsx("div",{className:"print-only",children:e.jsx(Ot,{})}),i?e.jsx(mf,{data:A}):e.jsx(n.Table,{bordered:!0,size:"small",loading:g,rowKey:(m,j)=>String(m?.id??m?.staff_id??j),columns:b,dataSource:p,pagination:{pageSize:20},scroll:{x:"max-content"}})]})})]})}const gf=({token:t})=>e.jsx(yf,{token:t}),Oi=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},xf=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"";function bf({token:t,staffId:a}){const[s,i]=r.useState(!1),[o,l]=r.useState(null),[d,c]=r.useState({value:"Cash",label:"Cash"}),[g,h]=r.useState(""),[u,p]=r.useState(""),A=r.useMemo(()=>{try{return JSON.parse(localStorage.getItem("genrall_settings"))?.currency_icon??""}catch{return""}},[]),w=I=>{const B=Number(I??0),L=Number.isFinite(B)?B.toLocaleString("en-IN"):"0";return`${A?`${A} `:""}${L}`},b=r.useMemo(()=>a?`${Ie.staff.basicById}?staff_id=${encodeURIComponent(String(a))}`:null,[a]),m=r.useMemo(()=>a?`${Ie.payroll.staffPayrollByStaffId}?staff_id=${encodeURIComponent(String(a))}`:null,[a]),{data:j}=W(t&&b?[b,t]:null,([I,B])=>K(I,B)),{data:D,isLoading:R,mutate:k}=W(t&&m?[m,t]:null,([I,B])=>K(I,B)),S=r.useMemo(()=>Oi(j)[0]??j?.data??j??null,[j]),x=r.useMemo(()=>Oi(D),[D]),f=r.useMemo(()=>[{title:"Month",dataIndex:"month",key:"month",width:120,align:"center"},{title:"Basic Salary",dataIndex:"basic_salary",key:"basic_salary",width:140,align:"center",render:(I,B)=>e.jsx("div",{style:{fontSize:11},children:Tt(B?.basic_salary)})},{title:"Gross Salary",dataIndex:"gross_salary",key:"gross_salary",width:140,align:"center",render:(I,B)=>e.jsx("div",{style:{fontSize:11},children:Tt(B?.gross_salary)})},{title:"Net Salary",dataIndex:"net_amount",key:"net_amount",width:140,align:"center",render:(I,B)=>e.jsx("div",{style:{fontSize:11},children:Tt(B?.net_amount)})},{title:"Payable",dataIndex:"Total_Payable_Amount",key:"Total_Payable_Amount",width:140,align:"center",render:(I,B)=>e.jsx("div",{style:{fontSize:11},children:Tt(B?.Total_Payable_Amount)})},{title:"Status",dataIndex:"status",key:"status",width:140,align:"center",render:(I,B)=>e.jsx("div",{style:{cursor:B?.status==="due"?"pointer":"default"},onClick:()=>{B?.status==="due"&&(l(B),i(!0))},children:Go(B?.status)})}],[]),_=r.useMemo(()=>[{value:"Cash",label:"Cash"},{value:"UPI",label:"UPI"},{value:"DD",label:"DD"},{value:"Bank",label:"Bank"},{value:"Internet Banking",label:"Internet Banking"},{value:"Cheque",label:"Cheque"}],[]),T=async()=>{if(!o)return;const I={...o,staff_id:a,payment_type:d?.value??"",notes:g,attchement:u};try{await Ee(Ie.payroll.generatePayslip,{arg:I},t),v.success("Success!",{duration:1e3}),i(!1),l(null),h(""),p(""),await k()}catch(B){v.error(B?.response?.data?.msg??B?.message??"Failed.",{duration:1e3})}};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll Receipt Details"}),children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx("div",{style:{fontSize:13,color:"#444"},children:S?`${S?.f_name??S?.firstname??""} ${S?.l_name??S?.lastname??""}`.trim():""}),e.jsx(n.Table,{bordered:!0,size:"small",loading:R,rowKey:(I,B)=>String(I?.id??`${I?.month}-${B}`),columns:f,dataSource:x,pagination:{pageSize:12},scroll:{x:"max-content"}})]})}),e.jsx(n.Modal,{open:s,onCancel:()=>{i(!1),l(null)},footer:null,destroyOnClose:!0,title:"Payment Options",width:640,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Q,{label:"Pay",options:_,value:d,onChange:I=>c(I??_[0]),closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Note"}),e.jsx(n.Input.TextArea,{rows:4,placeholder:"Note",value:g,onChange:I=>h(I.target.value)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:6,fontSize:14,fontWeight:500,color:"#222"},children:"Attachment"}),e.jsx(n.Upload,{maxCount:1,action:sl(),headers:t?{Authorization:t}:void 0,onChange:I=>{if(I?.file?.status==="done"){const B=xf(I?.file?.response);B&&p(B)}I?.file?.status==="removed"&&p("")},children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),children:"Upload"})}),!!u&&e.jsx("div",{style:{fontSize:12,color:"#666",marginTop:6},children:u})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[e.jsx(n.Button,{onClick:()=>i(!1),children:"Cancel"}),e.jsx(ne,{type:"button",value:o?.Total_Payable_Amount?`Pay ${w(o.Total_Payable_Amount)}`:"Pay",onClick:T})]})]})})]})}function jf({token:t,staffId:a}){const s=r.useMemo(()=>{if(a!=null&&String(a).trim()!=="")return a;if(typeof window>"u")return null;const i=new URLSearchParams(window.location.search).get("id");return i||null},[a]);return s?e.jsx(bf,{token:t,staffId:s}):e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll Receipt Details"}),children:e.jsx("div",{style:{fontSize:13,color:"#666"},children:"Missing staff id."})})}function Yt({onAdd:t,onExport:a,onPrint:s,onDownload:i,onFilter:o,onRefresh:l,actions:d}){const c=r.useMemo(()=>[{key:"add",title:"Add",icon:e.jsx(ee.PlusOutlined,{}),onClick:t},{key:"export",title:"Export",icon:e.jsx(ee.FileExcelOutlined,{}),onClick:a},{key:"print",title:"Print",icon:e.jsx(ee.PrinterOutlined,{}),onClick:s},{key:"download",title:"Download",icon:e.jsx(ee.DownloadOutlined,{}),onClick:i},{key:"filter",title:"Filter",icon:e.jsx(ee.FilterOutlined,{}),onClick:o},{key:"refresh",title:"Refresh",icon:e.jsx(ee.ReloadOutlined,{}),onClick:l}],[t,a,s,i,o,l]),g=r.useMemo(()=>{const h=Array.isArray(d)&&d.length?new Set(d):null;return h?c.filter(u=>h.has(u.key)):c},[c,d]);return e.jsx(n.Space,{size:8,children:g.map(h=>e.jsx(n.Tooltip,{title:h.title,children:e.jsx(n.Button,{type:"text",icon:h.icon,onClick:h.onClick,disabled:!h.onClick})},h.key))})}const or=t=>t??localStorage.getItem("authToken")??"",Pt={dashboard:{monthlyGraph:"api/branchapi/reportGraph/studentPresentvsAbsentmonthlyReportgraph",weeklyGraph:"api/branchapi/reportGraph/studentPresentvsAbsentweeklyReportgraph"},dropdowns:{classes:"api/branchapi/academy/classdropdownlist",sectionsByClass:"api/branchapi/academy/sectionoftheClass",sessions:"api/branchapi/generalSettings/sessiondropdown"},studentAttendance:{list:"api/StudentAttendace/studentlistforBranchbyClass",save:"api/studentAttendace/addattendencebyBranch",emergencyLeave:"api/StudentAttendace/emergency_leave"},dailyAttendance:{list:"api/StudentAttendace/studentlistforBranchbyClass"},monthlyReport:{table:"api/branchapi/student/studentmonthlyAttendence",byStudent:"api/branchapi/student/getStududentMonthlyByIdUrlnew"},yearlyReport:{table:"api/branchapi/student/studentyearlyAttendenceReport"}},Nt=async(t,a)=>K(t,or(a)),Sf=async(t,a,s)=>Ee(t,a,or(s)),wf=async(t,a,s)=>za(t,{arg:a},or(s)),Ya=(t,a)=>{const s=new URLSearchParams;Object.entries(a??{}).forEach(([o,l])=>{l==null||l===""||s.set(o,String(l))});const i=t.includes("?")?"&":"?";return`${t}${i}${s.toString()}`},Mi=()=>{try{return JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1"}catch{return"1"}},vf=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},ol=(t,a)=>{const s=t?.data?.data??t?.data??t??{},i=a?s?.[a]:s;return Array.isArray(i)?i:Array.isArray(s?.student)?s.student:Array.isArray(s?.staff)?s.staff:Array.isArray(s?.data)?s.data:[]},_f=t=>Array.isArray(t?.monthly_data)?t.monthly_data:Array.isArray(t?.month_data)?t.month_data:[],Cf=t=>{const a={present:0,absent:0,late:0,leave:0};return(Array.isArray(t)?t:[]).forEach(s=>{if(Array.isArray(s?.monthly_data)||Array.isArray(s?.month_data)){_f(s).forEach(o=>{const l=o?.[0]?.data?.[0]??o?.data?.[0]??o??{},d=String(l?.attendance_type??l?.attendence_type_id??"").toUpperCase();(d==="P"||d==="1")&&(a.present+=1),(d==="A"||d==="4")&&(a.absent+=1),(d==="L"||d==="3")&&(a.late+=1),(d==="LEAVE"||d==="2")&&(a.leave+=1)});return}const i=String(s?.attendance_type??s?.attendence_type_id??"").toUpperCase();(i==="P"||i==="1")&&(a.present+=1),(i==="A"||i==="4")&&(a.absent+=1),(i==="L"||i==="3")&&(a.late+=1),(i==="LEAVE"||i==="2")&&(a.leave+=1)}),a},lr=(t,a)=>{const{data:s,isLoading:i,error:o}=W(a&&t?[t,a]:null,([l,d])=>Nt(l,d));return{isLoading:i,error:o,data:s,options:r.useMemo(()=>vf(s),[s])}},rs=t=>lr(Pt.dropdowns.classes,t),is=(t,a)=>{const s=t?`${Pt.dropdowns.sectionsByClass}?class_id=${encodeURIComponent(String(t))}`:null;return lr(s,a)},Af=t=>lr(Pt.dropdowns.sessions,t),dr=t=>{const a=String(t??"").toUpperCase();return et(a==="1"||a==="P"||a==="PRESENT"?"P":a==="4"||a==="A"||a==="ABSENT"?"A":a==="3"||a==="L"||a==="LATE"?"L":a==="2"||a==="LEAVE"?"LEAVE":a==="W"?"W":a==="H"?"H":a||"-")},ll=(t,a,s)=>{const i=new Blob([t],{type:a}),o=URL.createObjectURL(i),l=document.createElement("a");l.href=o,l.download=s,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(o)},Ei=t=>String(t??"").replace(/"/g,'""'),Df=({rows:t,columns:a,fileName:s})=>{const i=Array.isArray(a)?a:[],o=Array.isArray(t)?t:[],l=i.map(c=>`"${Ei(c?.title??c?.name??c?.key??c?.dataIndex)}"`).join(","),d=o.map((c,g)=>i.map(h=>{const u=h?.dataIndex??h?.selector??h?.key,p=u==="sl"?g+1:c?.[u];return`"${Ei(p)}"`}).join(",")).join(`
|
|
60
|
+
`);ll([l,d].filter(Boolean).join(`
|
|
61
|
+
`),"text/csv;charset=utf-8;",s)},Tf=({value:t,fileName:a})=>{ll(JSON.stringify(t??null,null,2),"application/json;charset=utf-8;",a)};function dl({summary:t}){const a=[{key:"present",label:"Present",color:"#52c41a"},{key:"absent",label:"Absent",color:"#ff4d4f"},{key:"late",label:"Late",color:"#fa8c16"},{key:"leave",label:"Leave",color:"#1677ff"}];return e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(170px, 1fr))",gap:16},children:a.map(s=>e.jsxs(n.Card,{size:"small",styles:{body:{padding:16}},children:[e.jsx("div",{style:{fontSize:12,color:"#666",marginBottom:8},children:s.label}),e.jsx("div",{style:{fontSize:24,fontWeight:700,color:s.color},children:t?.[s.key]??0})]},s.key))})}function ga({summary:t,title:a="Attendance Overview"}){const s=r.useMemo(()=>[{key:"present",label:"Present",value:Number(t?.present??0),color:"#52c41a"},{key:"absent",label:"Absent",value:Number(t?.absent??0),color:"#ff4d4f"},{key:"late",label:"Late",value:Number(t?.late??0),color:"#fa8c16"},{key:"leave",label:"Leave",value:Number(t?.leave??0),color:"#1677ff"}],[t]),i=Math.max(...s.map(o=>o.value),1);return e.jsx(n.Card,{size:"small",title:a,children:e.jsx("div",{style:{display:"grid",gap:12},children:s.map(o=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"100px 1fr 50px",gap:12,alignItems:"center"},children:[e.jsx("div",{style:{fontSize:12,color:"#444"},children:o.label}),e.jsx("div",{style:{height:12,background:"#f0f0f0",borderRadius:999},children:e.jsx("div",{style:{width:`${o.value/i*100}%`,height:"100%",background:o.color,borderRadius:999}})}),e.jsx("div",{style:{fontSize:12,fontWeight:600,textAlign:"right"},children:o.value})]},o.key))})})}function Rf(){const t=[{label:"Present",node:et("P")},{label:"Absent",node:et("A")},{label:"Late",node:et("L")},{label:"Weekly Off",node:et("W")},{label:"Holiday",node:et("H")}];return e.jsx(n.Space,{wrap:!0,size:[12,8],children:t.map(a=>e.jsxs(n.Space,{size:6,children:[e.jsx("span",{style:{fontSize:12,color:"#555"},children:a.label}),a.node]},a.label))})}function Lt({items:t}){const a=Array.isArray(t)?t.filter(s=>s?.value):[];return a.length?e.jsx(n.Space,{wrap:!0,size:[8,8],children:a.map(s=>e.jsxs(n.Tag,{color:"blue",children:[s.label,": ",s.value]},s.label))}):null}function os({title:t,subtitle:a,printRef:s,exportRows:i,exportColumns:o,onRefresh:l,onAdd:d,filterSection:c,summary:g,chartContent:h,reportTitle:u,reportExtra:p,children:A,fileBaseName:w="attendance"}){const b=xa.useReactToPrint({content:()=>s?.current});return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsxs("div",{children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:t}),a?e.jsx(n.Typography.Text,{type:"secondary",style:{display:"block",marginTop:4},children:a}):null]}),extra:e.jsx(Yt,{actions:["add","export","print","download","refresh"],onAdd:d,onExport:()=>Df({rows:i,columns:o,fileName:`${w}.csv`}),onPrint:b,onDownload:()=>Tf({value:i,fileName:`${w}.json`}),onRefresh:l}),children:c}),e.jsx(dl,{summary:g}),h===!1?null:h||e.jsx(ga,{summary:g}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:u}),extra:p,children:A})]})}const If=[{label:"Present",value:"1"},{label:"Absent",value:"4"},{label:"Late",value:"3"},{label:"Leave",value:"2"}];function kf({rows:t,loading:a,sunday:s,holiday:i,holidayTitle:o,onChangeRows:l,onEmergency:d}){const c=(h,u)=>{const p=(Array.isArray(t)?t:[]).map((A,w)=>(A?.student_session_id??A?.student_id??A?.id??w)===h?{...A,...u}:A);l?.(p)},g=r.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(h,u,p)=>p+1},{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:130},{title:"EC No",dataIndex:"ecno",key:"ecno",width:100},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",key:"full_name",render:(h,u)=>u?.full_name??u?.student_name??u?.name??"--"},{title:"Attendance",dataIndex:"attendence_type_id",key:"attendence_type_id",width:180,render:(h,u,p)=>{const A=u?.student_session_id??u?.student_id??u?.id??p;return e.jsx(n.Select,{size:"small",style:{width:"100%"},options:If,value:String(h??"1"),onChange:w=>c(A,{attendence_type_id:w})})}},{title:"Date",dataIndex:"date",key:"date",width:120,render:h=>h?te(h).format("DD-MM-YYYY"):"--"},{title:"Remarks",dataIndex:"remark",key:"remark",width:140},{title:"In Time",dataIndex:"intime",key:"intime",width:120},{title:"Out Time",dataIndex:"outtime",key:"outtime",width:120},{title:"Emergency Leave",key:"emergency_leave",width:140,render:(h,u)=>e.jsx(n.Tag,{color:"orange",style:{cursor:"pointer"},icon:e.jsx(ee.ClockCircleOutlined,{}),onClick:()=>d?.(u),children:"E.L"})}],[d,t]);return s?e.jsx("div",{style:{textAlign:"center",fontWeight:700,padding:"32px 0"},children:"Weekly Off"}):i?e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{fontWeight:700,marginBottom:8},children:"Holiday"}),e.jsx("div",{children:o||"--"})]}):e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(h,u)=>String(h?.student_session_id??h?.student_id??h?.id??u),columns:g,dataSource:Array.isArray(t)?t:[],loading:a,pagination:{pageSize:25},scroll:{x:"max-content"}})}function Pf({rows:t,loading:a,sunday:s,holiday:i,holidayTitle:o}){const l=r.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(d,c,g)=>g+1},{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:130},{title:"EC No",dataIndex:"ecno",key:"ecno",width:100},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",key:"full_name",render:(d,c)=>c?.full_name??c?.student_name??c?.name??"--"},{title:"Attendance",dataIndex:"attendence_type_id",key:"attendence_type_id",width:120,render:d=>dr(d)},{title:"Date",dataIndex:"date",key:"date",width:120,render:d=>d?te(d).format("DD-MM-YYYY"):"--"},{title:"Remarks",dataIndex:"remark",key:"remark",width:140},{title:"In Time",dataIndex:"intime",key:"intime",width:120},{title:"Out Time",dataIndex:"outtime",key:"outtime",width:120}],[]);return s?e.jsx("div",{style:{textAlign:"center",fontWeight:700,padding:"32px 0"},children:"Weekly Off"}):i?e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{fontWeight:700,marginBottom:8},children:"Holiday"}),e.jsx("div",{children:o||"--"})]}):e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(d,c)=>String(d?.student_session_id??d?.student_id??d?.id??c),columns:l,dataSource:Array.isArray(t)?t:[],loading:a,pagination:{pageSize:25},scroll:{x:"max-content"}})}function Of({data:t,loading:a,onViewStudent:s}){const i=t?.data??t??{},o=Array.isArray(i?.studentAttendance)?i.studentAttendance:Array.isArray(i)?i:[],l=Array.isArray(i?.monthly_holiday)?i.monthly_holiday:[],d=Array.isArray(i?.dateSun)?i.dateSun:[],c=Number(i?.totalDaysMonth??0),g=r.useMemo(()=>{const h=[{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:90,fixed:"left"},{title:"Name",key:"student_name",width:180,fixed:"left",render:(u,p)=>e.jsx(n.Button,{type:"link",style:{padding:0},onClick:()=>s?.(p),children:p?.student_name??p?.full_name??"--"})}];return[...new Array(c).keys()].forEach(u=>{h.push({title:String(u+1),key:`day-${u+1}`,width:52,align:"center",render:(p,A)=>{const b=A?.[`${A?.student_id}_${o.indexOf(A)}`]?.[u]??{},m=b?.attendance_date,j=l.find(D=>D?.date===m);return d.includes(m)?Wr("sunday","W"):j?Wr("holiday","H"):dr(b?.attendence_type_id)}})}),h.push({title:"Total",key:"total",width:140,fixed:"right",render:(u,p)=>{let A=0,w=0,b=0;return[...new Array(c).keys()].forEach(m=>{const j=p?.[`${p?.student_id}_${o.indexOf(p)}`]?.[m]??{},D=String(j?.attendence_type_id??"");D==="1"&&(A+=1),D==="4"&&(w+=1),D==="3"&&(b+=1)}),e.jsxs("span",{children:["P: ",A," A: ",w," L: ",b]})}}),h},[l,s,o,d,c]);return e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(h,u)=>String(h?.student_id??u),columns:g,dataSource:o,loading:a,pagination:{pageSize:20},scroll:{x:"max-content"},locale:{emptyText:e.jsx(n.Empty,{description:"No monthly report found"})}})}function Mf({open:t,onClose:a,loading:s,data:i,studentName:o}){const l=Array.isArray(i?.data?.report)?i.data.report:[],d=[{title:"Date",dataIndex:"attendance_date",key:"attendance_date",render:c=>c?te(c).format("DD-MM-YYYY"):"--"},{title:"Status",key:"status",render:(c,g)=>dr(g?.attendence_type_id??g?.attendance_type)},{title:"In Time",dataIndex:"intime",key:"intime"},{title:"Out Time",dataIndex:"outtime",key:"outtime"},{title:"Remark",dataIndex:"remark",key:"remark"}];return e.jsx(n.Modal,{open:t,onCancel:a,footer:null,width:900,title:`Monthly Details${o?` - ${o}`:""}`,children:e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(c,g)=>String(c?.attendance_date??g),columns:d,dataSource:l,loading:s,pagination:{pageSize:20},scroll:{x:"max-content"}})})}function Ef({open:t,onClose:a,onSubmit:s,loading:i}){const[o,l]=n.Modal.useModal(),[d,c]=r.useState(null),[g,h]=r.useState(""),u=async()=>{if(!d){await o.warning({title:"Select time"});return}await s?.({outtime:d.format("h:mm a"),message:g}),c(null),h("")};return e.jsxs(e.Fragment,{children:[l,e.jsx(n.Modal,{title:"Emergency Leave",open:t,onCancel:a,onOk:u,confirmLoading:i,children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginBottom:6},children:"Select Time"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",value:d,onChange:c,style:{width:"100%"}})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginBottom:6},children:"Purpose"}),e.jsx(n.Input.TextArea,{rows:4,value:g,onChange:p=>h(p.target.value)})]})]})})]})}const cl=t=>Cf(t),Fi=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a.reduce((s,i)=>({present:s.present+Number(i?.present??i?.Present??i?.total_present??0),absent:s.absent+Number(i?.absent??i?.Absent??i?.total_absent??0),late:s.late+Number(i?.late??i?.Late??0),leave:s.leave+Number(i?.leave??i?.Leave??0)}),{present:0,absent:0,late:0,leave:0}):{present:Number(a?.present??a?.Present??a?.total_present??0),absent:Number(a?.absent??a?.Absent??a?.total_absent??0),late:Number(a?.late??a?.Late??0),leave:Number(a?.leave??a?.Leave??0)}};function Ff({token:t}){const{data:a}=W(t?[Pt.dashboard.monthlyGraph,t]:null,([l,d])=>Nt(l,d)),{data:s}=W(t?[Pt.dashboard.weeklyGraph,t]:null,([l,d])=>Nt(l,d)),i=r.useMemo(()=>Fi(a),[a]),o=r.useMemo(()=>Fi(s),[s]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsxs(n.Card,{children:[e.jsx(n.Typography.Title,{level:4,style:{marginTop:0},children:"Attendance Dashboard"}),e.jsx(n.Typography.Paragraph,{style:{marginBottom:0},children:"Student attendance overview with monthly and weekly analytics migrated from the ERP dashboard."})]}),e.jsx(dl,{summary:i}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:20},children:[e.jsx(ga,{summary:i,title:"Monthly Attendance Chart"}),e.jsx(ga,{summary:o,title:"Weekly Attendance Chart"})]})]})}const Ps=Pt.studentAttendance,Uf={width:"100%",height:40};function $f({token:t}){const a=r.useRef(null),[s,i]=r.useState(""),[o,l]=r.useState(""),[d,c]=r.useState(""),[g,h]=r.useState(""),[u,p]=r.useState(""),[A,w]=r.useState(""),[b,m]=r.useState(te()),[j,D]=r.useState(0),[R,k]=r.useState([]),[S,x]=r.useState(!1),[f,_]=r.useState(null),[T,I]=r.useState(!1),[B,L]=r.useState(!1),y=rs(t),P=is(s,t),O=r.useMemo(()=>!s||!d||j===0?null:Ya(Ps.list,{cID:s,sID:d,batch_id:u,date:b.format("YYYY-MM-DD")}),[u,s,b,j,d]),{data:$,isLoading:U,mutate:N}=W(t&&O?[O,t]:null,([J,ae])=>Nt(J,ae));r.useEffect(()=>{k(ol($,"student"))},[$]);const V=$?.data?.data??$?.data??$??{},z=!!V?.sunday,E=!!V?.holiday?.holiday,M=V?.holiday?.title??"",F=r.useMemo(()=>cl(R),[R]),q=r.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no"},{title:"EC No",dataIndex:"ecno"},{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Attendance",dataIndex:"attendence_type_id"},{title:"Date",dataIndex:"date"},{title:"Remarks",dataIndex:"remark"},{title:"In Time",dataIndex:"intime"},{title:"Out Time",dataIndex:"outtime"}],[]),H=async()=>{if(R.length)try{L(!0),await Sf(Ps.save,{attendenceData:R,date:b.format("YYYY-MM-DD"),holiday:S?"YES":"NO"},t),v.success("Student attendance saved."),N?.()}catch(J){v.error(J?.message??"Failed to save attendance.")}finally{L(!1)}},re=async({outtime:J,message:ae})=>{if(f?.attendence_id)try{I(!0),await wf(Ps.emergencyLeave,{outtime:J,message:ae,id:f.attendence_id},t),v.success("Emergency leave updated."),_(null),N?.()}catch(oe){v.error(oe?.message??"Failed to update emergency leave.")}finally{I(!1)}},G=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Q,{options:y.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:J=>{i(J?.value??""),l(J?.label??""),c(""),h(""),p(""),w("")},required:!0}),e.jsx(Q,{options:P.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:J=>{c(J?.value??""),h(J?.label??""),p(""),w("")},required:!0},`section-${s}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{value:b,onChange:J=>J&&m(J),style:Uf,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:()=>D(J=>J+1)})})]}),e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Date",value:b.format("DD-MM-YYYY")}]})]});return e.jsxs(e.Fragment,{children:[e.jsx(v.Toaster,{}),e.jsx(os,{title:"Student Attendance",printRef:a,exportRows:R,exportColumns:q,onRefresh:()=>N?.(),filterSection:G,summary:F,chartContent:!1,reportTitle:"Student Attendance List",reportExtra:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(n.Button,{size:"small",type:S?"primary":"default",onClick:()=>x(J=>!J),children:S?"Marked":"Mark As Holiday"}),e.jsx(n.Button,{size:"small",type:"primary",onClick:H,loading:B,disabled:!R.length,children:"Save Attendance"})]}),fileBaseName:"student-attendance",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(Ot,{}),e.jsx(n.Typography.Title,{level:5,children:"Student Attendance"}),e.jsx(n.Card,{size:"small",style:{marginBottom:12},children:e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Date",value:b.format("DD-MM-YYYY")}]})})]}),e.jsx(kf,{rows:R,loading:U,sunday:z,holiday:E,holidayTitle:M,onChangeRows:k,onEmergency:_})]})}),e.jsx(Ef,{open:!!f,onClose:()=>_(null),onSubmit:re,loading:T})]})}const Nf=Pt.dailyAttendance,Lf={width:"100%",height:40};function Bf({token:t}){const a=r.useRef(null),[s,i]=r.useState(""),[o,l]=r.useState(""),[d,c]=r.useState(""),[g,h]=r.useState(""),[u,p]=r.useState(""),[A,w]=r.useState(te()),[b,m]=r.useState(0),j=rs(t),D=is(s,t),R=r.useMemo(()=>!s||!d||b===0?null:Ya(Nf.list,{cID:s,sID:d,batch_id:u,date:A.format("YYYY-MM-DD")}),[u,s,A,b,d]),{data:k,isLoading:S,mutate:x}=W(t&&R?[R,t]:null,([O,$])=>Nt(O,$)),f=r.useMemo(()=>ol(k,"student"),[k]),_=k?.data?.data??k?.data??k??{},T=!!_?.sunday,I=!!_?.holiday?.holiday,B=_?.holiday?.title??"",L=r.useMemo(()=>cl(f),[f]),y=r.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no"},{title:"EC No",dataIndex:"ecno"},{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Attendance",dataIndex:"attendence_type_id"},{title:"Date",dataIndex:"date"},{title:"Remarks",dataIndex:"remark"},{title:"In Time",dataIndex:"intime"},{title:"Out Time",dataIndex:"outtime"}],[]),P=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Q,{options:j.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:O=>{i(O?.value??""),l(O?.label??""),c(""),h(""),p(""),setBatchLabel("")},required:!0}),e.jsx(Q,{options:D.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:O=>{c(O?.value??""),h(O?.label??""),p(""),setBatchLabel("")},required:!0},`section-${s}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Date"}),e.jsx(n.DatePicker,{value:A,onChange:O=>O&&w(O),style:Lf,allowClear:!1})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:()=>m(O=>O+1)})})]}),e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Date",value:A.format("DD-MM-YYYY")}]})]});return e.jsx(os,{title:"Daily Attendance",subtitle:"Read-only daily attendance enquiry migrated from ERP AttendanceDashboard.",printRef:a,exportRows:f,exportColumns:y,onRefresh:()=>x?.(),filterSection:P,summary:L,chartContent:e.jsx(ga,{summary:L,title:"Daily Attendance Overview"}),reportTitle:"Daily Attendance List",fileBaseName:"daily-attendance",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(Ot,{}),e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Date",value:A.format("DD-MM-YYYY")}]})]}),e.jsx(Pf,{rows:f,loading:S,sunday:T,holiday:I,holidayTitle:B})]})})}const Ui=Pt.monthlyReport,qf=t=>{const a=Array.isArray(t?.studentAttendance)?t.studentAttendance:[],s=Number(t?.totalDaysMonth??0),i={present:0,absent:0,late:0,leave:0};return a.forEach((o,l)=>{[...new Array(s).keys()].forEach(d=>{const c=o?.[`${o?.student_id}_${l}`]?.[d]??{},g=String(c?.attendence_type_id??"");g==="1"&&(i.present+=1),g==="4"&&(i.absent+=1),g==="3"&&(i.late+=1),g==="2"&&(i.leave+=1)})}),i},zf=t=>{const a=Array.isArray(t?.studentAttendance)?t.studentAttendance:[],s=Number(t?.totalDaysMonth??0);return a.map((i,o)=>{let l=0,d=0,c=0;return[...new Array(s).keys()].forEach(g=>{const h=i?.[`${i?.student_id}_${o}`]?.[g]??{},u=String(h?.attendence_type_id??"");u==="1"&&(l+=1),u==="4"&&(d+=1),u==="3"&&(c+=1)}),{roll_no:i?.roll_no??"",student_name:i?.student_name??i?.full_name??"",present:l,absent:d,late:c}})};function Yf({token:t}){const a=r.useRef(null),[s,i]=r.useState(""),[o,l]=r.useState(""),[d,c]=r.useState(""),[g,h]=r.useState(""),[u,p]=r.useState(""),[A,w]=r.useState(""),[b,m]=r.useState(String(new Date().getFullYear())),[j,D]=r.useState(String(new Date().getMonth()+1).padStart(2,"0")),[R,k]=r.useState(0),[S,x]=r.useState(null),f=rs(t),_=is(s,t),T=r.useMemo(()=>sr(Number(b)),[b]),I=r.useMemo(()=>nr(10),[]),B=r.useMemo(()=>!s||!d||!b||!j||R===0?null:Ya(Ui.table,{session:Mi(),class_id:s,section_id:d,year:b,month:j,batch_id:u}),[u,s,j,R,d,b]),{data:L,isLoading:y,mutate:P}=W(t&&B?[B,t]:null,([F,q])=>Nt(F,q)),O=L?.data?.data??L?.data??L??{},$=r.useMemo(()=>qf(O),[O]),U=r.useMemo(()=>zf(O),[O]),N=r.useMemo(()=>[{title:"Roll No",dataIndex:"roll_no"},{title:"Name",dataIndex:"student_name"},{title:"Present",dataIndex:"present"},{title:"Absent",dataIndex:"absent"},{title:"Late",dataIndex:"late"}],[]),V=r.useMemo(()=>S?.student_id?Ya(Ui.byStudent,{student_id:S.student_id,month:j,year:b,session:Mi()}):null,[j,S,b]),{data:z,isLoading:E}=W(t&&V?[V,t]:null,([F,q])=>Nt(F,q)),M=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Q,{options:f.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:F=>{i(F?.value??""),l(F?.label??""),c(""),h(""),p(""),w("")},required:!0}),e.jsx(Q,{options:_.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:F=>{c(F?.value??""),h(F?.label??""),p(""),w("")},required:!0},`section-${s}`),e.jsx(Q,{options:I,label:"Year",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:I.find(F=>String(F?.value)===String(b))??null,onChange:F=>m(String(F?.value??"")),required:!0}),e.jsx(Q,{options:T,label:"Month",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:T.find(F=>String(F?.value)===String(j))??null,onChange:F=>D(String(F?.value??"").padStart(2,"0")),required:!0},`month-${b}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:()=>k(F=>F+1)})})]}),e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Month",value:T.find(F=>String(F?.value)===String(j))?.label??j},{label:"Year",value:b}]}),e.jsx(Rf,{})]});return e.jsxs(e.Fragment,{children:[e.jsx(os,{title:"Monthly Report",subtitle:"Monthly class-wise attendance matrix and student drilldown.",printRef:a,exportRows:U,exportColumns:N,onRefresh:()=>P?.(),filterSection:M,summary:$,chartContent:e.jsx(ga,{summary:$,title:"Monthly Attendance Summary"}),reportTitle:"Monthly Attendance Table",fileBaseName:"monthly-attendance-report",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(Ot,{}),e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Month",value:T.find(F=>String(F?.value)===String(j))?.label??j},{label:"Year",value:b}]})]}),e.jsx(Of,{data:O,loading:y,onViewStudent:x})]})}),e.jsx(Mf,{open:!!S,onClose:()=>x(null),loading:E,data:z,studentName:S?.student_name??S?.full_name})]})}const Vf=Pt.yearlyReport,Wf=t=>{const a=t?.data?.data??t?.data??t??{};return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:Array.isArray(a?.students)?a.students:Array.isArray(a?.report)?a.report:[]},Hf=t=>(Array.isArray(t)?t:[]).reduce((a,s)=>({present:a.present+Number(s?.singleStudentPresentData??s?.present??0),absent:a.absent+Number(s?.singleStudentAbsentData??s?.absent??0),late:a.late+Number(s?.late??0),leave:a.leave+Number(s?.leave??0)}),{present:0,absent:0,late:0,leave:0});function Kf({token:t}){const a=r.useRef(null),[s,i]=r.useState(""),[o,l]=r.useState(""),[d,c]=r.useState(""),[g,h]=r.useState(""),[u,p]=r.useState(""),[A,w]=r.useState(""),[b,m]=r.useState(""),[j,D]=r.useState(""),[R,k]=r.useState(0),S=rs(t),x=is(s,t),f=Af(t),_=r.useMemo(()=>!s||!d||R===0?null:Ya(Vf.table,{class_id:s,section_id:d,session_id:u,batch_id:b}),[b,s,R,d,u]),{data:T,isLoading:I,mutate:B}=W(t&&_?[_,t]:null,([U,N])=>Nt(U,N)),L=r.useMemo(()=>Wf(T),[T]),y=r.useMemo(()=>Hf(L),[L]),P=r.useMemo(()=>[{title:"Roll No",dataIndex:"roll_no"},{title:"Full Name",dataIndex:"full_name"},{title:"Present",dataIndex:"singleStudentPresentData"},{title:"Absent",dataIndex:"singleStudentAbsentData"}],[]),O=r.useMemo(()=>[{title:"Sl No.",key:"sl",width:70,render:(U,N,V)=>V+1},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:100},{title:"Full Name",dataIndex:"full_name",key:"full_name"},{title:"Total Present",dataIndex:"singleStudentPresentData",key:"singleStudentPresentData",width:130},{title:"Total Absent",dataIndex:"singleStudentAbsentData",key:"singleStudentAbsentData",width:130}],[]),$=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16,alignItems:"end"},children:[e.jsx(Q,{options:S.options,label:"Class",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:U=>{i(U?.value??""),l(U?.label??""),c(""),h(""),m(""),D("")},required:!0}),e.jsx(Q,{options:x.options,label:"Section",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:U=>{c(U?.value??""),h(U?.label??""),m(""),D("")},required:!0},`section-${s}`),e.jsx(Q,{options:f.options,label:"Session",closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:U=>{p(U?.value??""),w(U?.label??"")},required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:()=>k(U=>U+1)})})]}),e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Session",value:A}]})]});return e.jsx(os,{title:"Yearly Report",subtitle:"Yearly attendance summary migrated from ERP AttendanceDashboard.",printRef:a,exportRows:L,exportColumns:P,onRefresh:()=>B?.(),filterSection:$,summary:y,chartContent:e.jsx(ga,{summary:y,title:"Yearly Attendance Summary"}),reportTitle:"Yearly Attendance List",fileBaseName:"yearly-attendance-report",children:e.jsxs("div",{ref:a,children:[e.jsxs("div",{className:"print-only",children:[e.jsx(Ot,{}),e.jsx(Lt,{items:[{label:"Class",value:o},{label:"Section",value:g},{label:"Session",value:A}]})]}),e.jsx(n.Table,{bordered:!0,size:"small",rowKey:(U,N)=>String(U?.student_id??U?.id??N),columns:O,dataSource:L,loading:I,pagination:{pageSize:25},scroll:{x:"max-content"}})]})})}const Gf=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Jf({data:t}){const{handleUpdate:a,token:s}=t||{},i=r.useContext(At),{isLoading:o,data:l}=W(s&&i?[`${Oc}?id=${i}`,s]:null,([w,b])=>K(w,b)),{data:d}=W(s?[Uo,s]:null,([w,b])=>K(w,b)),c=r.useMemo(()=>Gf(d),[d]),g=l?.data?.[0],[h,u]=r.useState({income_head:"",name:"",invoice_no:"",date:te(),amount:"",description:"",doc:""});r.useEffect(()=>{g&&u({income_head:g?.inc_head_id||"",name:g?.name||"",invoice_no:g?.invoice_no||"",date:g?.date?te(g.date):te(),amount:g?.amount||"",description:g?.note||"",doc:g?.documents||""})},[g]);const p=(w,b)=>{u(m=>({...m,[w]:b}))},A=c.find(w=>String(w.value)===String(h.income_head))??null;return o?e.jsx(C,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(C,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:w=>a(w,i),children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Edit Income"})}),e.jsx(C,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(C,{children:[e.jsx(Y,{type:"text",value:i,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(Q,{label:"Income Head",options:c,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"income_head",required:!0,value:A,onChange:w=>p("income_head",w?.value||"")})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"name",type:"text",label:"Name",required:!0,value:h.name,onChange:w=>p("name",w.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0,value:h.invoice_no,onChange:w=>p("invoice_no",w.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:h.date,Desplay:"Date",name:"date",required:!0,onChange:w=>p("date",w)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"amount",type:"number",label:"Amount",required:!0,value:h.amount,onChange:w=>p("amount",w.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(st,{name:"description",label:"Description",rows:3,value:h.description,onChange:w=>p("description",w.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(C,{children:[e.jsx(n.Upload,{action:`${He()}/branchapi/frontoffice/uploadfrontofficeDocument`,headers:{Authorization:s},maxCount:1,onChange:w=>{if(w.file.status==="removed"&&p("doc",""),w.file.status==="done"){const b=w.file.response?.data??w.file.response?.file??"";p("doc",String(b??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:h.doc?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"doc",value:h.doc||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const Qf=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Xf({token:t}){const[a,s]=r.useState([]),[i,o]=r.useState(""),[l,d]=r.useState(""),[c,g]=r.useState({income_head:"",name:"",invoice_no:"",date:te().format("YYYY-MM-DD"),amount:"",description:"",doc:""}),[h,u]=r.useState(!1),[p,A]=r.useState({page:1,rowsPerPage:10}),w=(y,P)=>{A({...p,page:y,rowsPerPage:parseInt(P,10)})},b=async(y,P)=>{try{await R(Ee(y,P,t),ze(P)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{v.error("Failed to add the new item.",{duration:1e3})}},{isLoading:m,error:j,data:D,mutate:R}=W(t?[Cc,t,p.page,p.rowsPerPage]:null,([y,P,O,$])=>K(`${y}?page=${O}&per_page=${$}`,P)),k=r.useMemo(()=>[{id:"1",name:"Name",selector:"name",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0},{id:"3",name:"Income Category",selector:"income_category",sortable:!0},{id:"4",name:"Invoice No",selector:"invoice_no",sortable:!0},{id:"5",name:"Date",selector:"date",sortable:!0},{id:"6",name:"Note",selector:"note",sortable:!0},{id:"7",name:"Amount",selector:"amount",sortable:!0},{id:"8",name:"File",selector:"documents",sortable:!1,render:y=>y?e.jsx("span",{style:{textDecoration:"underline",color:"#5080f8",cursor:"pointer"},onClick:()=>window.open(`${He()}/branch/frontoffice/${y}`,"_blank"),children:"View"}):"Not Uploaded"}],[]),S=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],x=async y=>{try{await R(qe(Tc,y,t),Ne(y)),v.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{v.error("Failed to delete the item.",{duration:1e3})}},f=async(y,P,O)=>{try{await R(Be(y,P,t)),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),await O(null)}catch{v.error("Failed to update the item.",{duration:1e3})}},_=async(y,P)=>{y.preventDefault();const O=new FormData(y.target);await f(Dc,O,P),I(!1)},T=async y=>{if(y.preventDefault(),!y.target.date.value)v.error("Select required dates",{duration:1e3}),y.target?.date?.focus(),d("textDanger");else{const P=new FormData(y.target);await b(Ac,P),y.target.reset(),o(""),g(O=>({...O,date:te().format("YYYY-MM-DD")}))}},I=y=>{u(y)},{data:B}=W(t?[Uo,t]:null,([y,P])=>K(y,P)),L=r.useMemo(()=>Qf(B),[B]);return e.jsxs(C,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Add Income"})}),e.jsx(C,{p:3,children:e.jsx("form",{onSubmit:T,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Q,{label:"Income Head",options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"income_head",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"name",type:"text",label:"Name",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:te(),Desplay:"Date",name:"date",status:l===""?"":"error",classnme:l,onChange:()=>d("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"amount",type:"number",label:"Amount",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(C,{children:[e.jsx(n.Upload,{action:`${He()}/branchapi/frontoffice/uploadfrontofficeDocument`,headers:{Authorization:t},maxCount:1,onChange:y=>{if(y.file.status==="removed"&&o(""),y.file.status==="done"){const P=y.file.response?.data??y.file.response?.file??"";o(String(P??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:i?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"doc",value:i||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(st,{name:"description",label:"Description",rows:3})})}),e.jsx(n.Col,{xs:24,md:12,className:"buttonCoustom",children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Income List"})}),e.jsx(C,{pt:3,children:e.jsx(Te,{parentCallback:w,data:{newData:D,columns:k,action:!0,Loading:m,ActionView:S,error:j,editDesign:e.jsx(Jf,{data:{handleUpdate:_,token:t}}),deleteTodoMutation:x,open:h,DrawerUpdate:I}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; } .textDanger { color: #dc2626; } .buttonCoustom { margin-top: 8px; }"})]})}const $i={width:"100%",height:40};function Zf({token:t}){const[a,s]=r.useState(null),[i,o]=r.useState(null),[l,d]=r.useState(""),[c,g]=r.useState(""),[h,u]=r.useState(""),[p,A]=r.useState({page:1,rowsPerPage:10}),w=(S,x)=>{A({...p,page:S,rowsPerPage:parseInt(x,10)})},{isLoading:b,error:m,data:j,mutate:D}=W(t&&l?[l,t,p.page,p.rowsPerPage]:null,([S,x,f,_])=>K(`${S}page=${f}&per_page=${_}`,x)),R=r.useMemo(()=>[{id:"1",name:"Invoice No",selector:"invoice_no",sortable:!0},{id:"2",name:"Date",selector:"date",sortable:!0},{id:"3",name:"Name",selector:"name",sortable:!0},{id:"4",name:"Description",selector:"description",sortable:!0},{id:"5",name:"Income Category",selector:"income_category",sortable:!0},{id:"6",name:"Note",selector:"note",sortable:!0},{id:"7",name:"Amount",selector:"amount",sortable:!0}],[]),k=()=>{if(!a){v.error("Select required dates",{duration:1e3}),g("textDanger");return}if(!i){v.error("Select required dates",{duration:1e3}),u("textDanger");return}const S=a.format("YYYY-MM-DD"),x=i.format("YYYY-MM-DD");d(`${Ec}?from_date=${S}&to_date=${x}&`),A(f=>({...f,page:1}))};return e.jsxs(C,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Search Income"})}),e.jsx(C,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],alignItems:"end",children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsxs(C,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"From Date"}),e.jsx(n.DatePicker,{value:a,onChange:S=>{s(S),g("")},style:$i,allowClear:!1})]})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsxs(C,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"To Date"}),e.jsx(n.DatePicker,{value:i,onChange:S=>{o(S),u("")},style:$i,allowClear:!1})]})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:k})})]})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Income List"})}),e.jsx(C,{pt:3,children:e.jsx(Te,{parentCallback:w,data:{newData:j,columns:R,action:!1,Loading:b,error:m,pageController:p}})})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}function ey({data:t}){const{handleUpdate:a,token:s}=t||{},i=r.useContext(At),{isLoading:o,data:l}=W(s&&i?[`${Mc}?id=${i}`,s]:null,([u,p])=>K(u,p)),d=l?.data?.[0],[c,g]=r.useState({incomehead:"",description:""});r.useEffect(()=>{d&&g({incomehead:d?.income_category||"",description:d?.description||""})},[d]);const h=(u,p)=>{g(A=>({...A,[u]:p}))};return o?e.jsx(C,{pt:4,pb:1,style:{width:350},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(C,{pt:4,pb:1,style:{width:350},children:[e.jsx("form",{onSubmit:u=>a(u),children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(C,{children:[e.jsx(Y,{type:"text",value:i,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(Y,{name:"incomehead",type:"text",label:"Income Head Name",required:!0,value:c.incomehead,onChange:u=>h("incomehead",u.target.value)})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(C,{children:e.jsx(Y,{name:"description",type:"text",label:"Description",required:!0,value:c.description,onChange:u=>h("description",u.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})})})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function ty({token:t}){const[a,s]=r.useState({incomehead:"",description:""}),[i,o]=r.useState(!1),[l,d]=r.useState({page:1,rowsPerPage:10}),c=(S,x)=>{d({...l,page:S,rowsPerPage:parseInt(x,10)})},g=async(S,x)=>{try{await A(Ee(S,x,t),ze(x)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{v.error("Failed to add the new item.",{duration:1e3})}},{isLoading:h,error:u,data:p,mutate:A}=W(t?[Rc,t,l.page,l.rowsPerPage]:null,([S,x,f,_])=>K(`${S}?page=${f}&per_page=${_}`,x)),w=r.useMemo(()=>[{id:"1",name:"Name",selector:"income_category",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],[]),b=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],m=async S=>{try{await A(qe(Pc,S,t),Ne(S)),v.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{v.error("Failed to delete the item.",{duration:1e3})}},j=async(S,x)=>{try{await A(Be(S,x,t)),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"})}catch{v.error("Failed to update the item.",{duration:1e3})}},D=async S=>{S.preventDefault();const x=new FormData(S.target);await j(kc,x),k(!1)},R=async S=>{S.preventDefault();const x=new FormData(S.target);await g(Ic,x),S.target.reset()},k=S=>{o(S)};return e.jsxs(C,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:5,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Income Head"})}),e.jsx(C,{p:3,children:e.jsx("form",{onSubmit:R,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsx(C,{children:e.jsx(Y,{name:"incomehead",type:"text",label:"Income Head Name",required:!0,value:a.incomehead,onChange:S=>s(x=>({...x,incomehead:S.target.value}))})})}),e.jsx(n.Col,{xs:24,children:e.jsx(C,{children:e.jsx(Y,{name:"description",type:"text",label:"Description",required:!0,value:a.description,onChange:S=>s(x=>({...x,description:S.target.value}))})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,md:19,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Income Head List"})}),e.jsx(C,{pt:3,children:e.jsx(Te,{parentCallback:c,data:{newData:p,columns:w,action:!0,Loading:h,ActionView:b,error:u,editDesign:e.jsx(ey,{data:{handleUpdate:D,token:t}}),deleteTodoMutation:m,open:i,DrawerUpdate:k}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const Ni=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Li=[{label:"Cash",value:"cash"},{label:"UPI",value:"upi"},{label:"Phonepay",value:"phonepay"},{label:"Google Pay",value:"google_pay"},{label:"Net Banking",value:"net_banking"},{label:"Cheque",value:"cheque"},{label:"Demand Draft",value:"demand_draft"}];function ay({data:t}){const{handleUpdate:a,token:s}=t||{},i=r.useContext(At),{isLoading:o,data:l}=W(s&&i?[`${Yc}?id=${i}`,s]:null,([D,R])=>K(D,R)),{data:d}=W(s?[$o,s]:null,([D,R])=>K(D,R)),{data:c}=W(s?[No,s]:null,([D,R])=>K(D,R)),g=r.useMemo(()=>Ni(d),[d]),h=r.useMemo(()=>Ni(c),[c]),u=l?.data?.[0],[p,A]=r.useState({expense_head:"",vendor:"",name:"",invoice_no:"",date:te(),amount:"",payment_mode:"",note:"",doc:""});r.useEffect(()=>{u&&A({expense_head:u?.exp_head_id||"",vendor:u?.fk_vendor_id||"",name:u?.name||"",invoice_no:u?.invoice_number||"",date:u?.date?te(u.date):te(),amount:u?.amount||"",payment_mode:u?.payment_mode||"",note:u?.note||"",doc:u?.documents||""})},[u]);const w=(D,R)=>{A(k=>({...k,[D]:R}))},b=g.find(D=>String(D.value)===String(p.expense_head))??null,m=h.find(D=>String(D.value)===String(p.vendor))??null,j=Li.find(D=>String(D.value)===String(p.payment_mode))??null;return o?e.jsx(C,{pt:4,pb:1,style:{width:550},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(C,{pt:4,pb:1,style:{width:550},children:[e.jsx("form",{onSubmit:D=>a(D,i),children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Edit Expense"})}),e.jsx(C,{p:2,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(C,{children:[e.jsx(Y,{type:"text",value:i,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(Q,{label:"Expense Head",options:g,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"expense_head",required:!0,value:b,onChange:D=>w("expense_head",D?.value||"")})]})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Q,{label:"Vendor",options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"vendor",value:m,onChange:D=>w("vendor",D?.value||"")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"name",type:"text",label:"Name",required:!0,value:p.name,onChange:D=>w("name",D.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0,value:p.invoice_no,onChange:D=>w("invoice_no",D.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Me,{format:"YYYY-MM-DD",value:p.date,Desplay:"Date",name:"date",required:!0,onChange:D=>w("date",D)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"amount",type:"number",label:"Amount",required:!0,value:p.amount,onChange:D=>w("amount",D.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Q,{label:"Payment Mode",options:Li,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"payment_mode",required:!0,value:j,onChange:D=>w("payment_mode",D?.value||"")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(st,{name:"note",label:"Description",rows:3,value:p.note,onChange:D=>w("note",D.target.value)})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(C,{children:[e.jsx(n.Upload,{action:`${He()}/branchapi/frontoffice/uploadfrontofficeDocument`,headers:{Authorization:s},maxCount:1,onChange:D=>{if(D.file.status==="removed"&&w("doc",""),D.file.status==="done"){const R=D.file.response?.data??D.file.response?.file??"";w("doc",String(R??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:p.doc?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"doc",value:p.doc||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"center",children:e.jsx(n.Col,{children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})})})})]})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}const Bi=t=>{const a=t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},ny=[{label:"Cash",value:"cash"},{label:"UPI",value:"upi"},{label:"Phonepay",value:"phonepay"},{label:"Google Pay",value:"google_pay"},{label:"Net Banking",value:"net_banking"},{label:"Cheque",value:"cheque"},{label:"Demand Draft",value:"demand_draft"}];function sy({token:t}){const[a,s]=r.useState(""),[i,o]=r.useState(""),[l,d]=r.useState({expense_head:"",vendor:"",name:"",invoice_no:"",date:te(),amount:"",payment_mode:"",note:"",doc:""}),[c,g]=r.useState(!1),[h,u]=r.useState({page:1,rowsPerPage:10}),p=(y,P)=>{u({...h,page:y,rowsPerPage:parseInt(P,10)})},A=async(y,P)=>{try{await j(Ee(y,P,t),ze(P)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{v.error("Failed to add the new item.",{duration:1e3})}},{isLoading:w,error:b,data:m,mutate:j}=W(t?[Fc,t,h.page,h.rowsPerPage]:null,([y,P,O,$])=>K(`${y}?page=${O}&per_page=${$}`,P)),D=r.useMemo(()=>[{id:"1",name:"Sl No",selector:"__serialNumber",sortable:!0},{id:"2",name:"Name",selector:"name",sortable:!0},{id:"3",name:"Description",selector:"description",sortable:!0},{id:"4",name:"Expense Category",selector:"exp_category",sortable:!0},{id:"5",name:"Invoice No",selector:"invoice_no",sortable:!0},{id:"6",name:"Note",selector:"note",sortable:!0},{id:"7",name:"Amount",selector:"amount",sortable:!0},{id:"8",name:"File",selector:"documents",sortable:!1,render:y=>y?e.jsx("span",{style:{textDecoration:"underline",color:"#5080f8",cursor:"pointer"},onClick:()=>window.open(`${He()}/branch/frontoffice/${y}`,"_blank"),children:"View"}):"Not Uploaded"}],[]),R=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],k=async y=>{try{await j(qe(Nc,y,t),Ne(y)),v.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{v.error("Failed to delete the item.",{duration:1e3})}},S=async(y,P,O)=>{try{await j(Be(y,P,t)),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"}),await O(null)}catch{v.error("Failed to update the item.",{duration:1e3})}},x=async(y,P)=>{y.preventDefault();const O=new FormData(y.target);await S($c,O,P),_(!1)},f=async y=>{if(y.preventDefault(),!y.target.date.value)v.error("Select required dates",{duration:1e3}),y.target?.date?.focus(),o("textDanger");else{const P=new FormData(y.target);await A(Uc,P),y.target.reset(),s(""),d(O=>({...O,date:te()}))}},_=y=>{g(y)},{data:T}=W(t?[$o,t]:null,([y,P])=>K(y,P)),{data:I}=W(t?[No,t]:null,([y,P])=>K(y,P)),B=r.useMemo(()=>Bi(T),[T]),L=r.useMemo(()=>Bi(I),[I]);return e.jsxs(C,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Add Expense"})}),e.jsx(C,{p:3,children:e.jsx("form",{onSubmit:f,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Q,{label:"Expense Head",options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"expense_head",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Q,{label:"Vendor",options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"vendor"})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"name",type:"text",label:"Name",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"invoice_no",type:"text",label:"Invoice Number",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Me,{format:"YYYY-MM-DD",defaultValue:te(),Desplay:"Date",name:"date",status:i===""?"":"error",classnme:i,onChange:()=>o("")})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Y,{name:"amount",type:"number",label:"Amount",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(Q,{label:"Payment Mode",options:ny,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,name:"payment_mode",required:!0})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx(C,{children:e.jsx(st,{name:"note",label:"Description",rows:3})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsxs(C,{children:[e.jsx(n.Upload,{action:`${He()}/branchapi/frontoffice/uploadfrontofficeDocument`,headers:{Authorization:t},maxCount:1,onChange:y=>{if(y.file.status==="removed"&&s(""),y.file.status==="done"){const P=y.file.response?.data??y.file.response?.file??"";s(String(P??""))}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})}),e.jsx("input",{type:"hidden",name:"doc",value:a||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,md:12,className:"buttonCoustom",children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Expense List"})}),e.jsx(C,{pt:3,children:e.jsx(Te,{parentCallback:p,data:{newData:m,columns:D,action:!0,Loading:w,ActionView:R,error:b,editDesign:e.jsx(ay,{data:{handleUpdate:x,token:t}}),deleteTodoMutation:k,open:c,DrawerUpdate:_}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; } .textDanger { color: #dc2626; } .buttonCoustom { margin-top: 8px; }"})]})}const qi={width:"100%",height:40};function ry({token:t}){const[a,s]=r.useState(null),[i,o]=r.useState(null),[l,d]=r.useState(""),[c,g]=r.useState(""),[h,u]=r.useState(""),[p,A]=r.useState({page:1,rowsPerPage:10}),w=(S,x)=>{A({...p,page:S,rowsPerPage:parseInt(x,10)})},{isLoading:b,error:m,data:j,mutate:D}=W(t&&l?[l,t,p.page,p.rowsPerPage]:null,([S,x,f,_])=>K(`${S}page=${f}&per_page=${_}`,x)),R=r.useMemo(()=>[{id:"1",name:"Invoice No",selector:"invoice_no",sortable:!0},{id:"2",name:"Date",selector:"date",sortable:!0},{id:"3",name:"Name",selector:"name",sortable:!0},{id:"4",name:"Description",selector:"description",sortable:!0},{id:"5",name:"Expense Category",selector:"exp_category",sortable:!0},{id:"6",name:"Note",selector:"note",sortable:!0},{id:"7",name:"Amount",selector:"amount",sortable:!0}],[]),k=()=>{if(!a){v.error("Select required dates",{duration:1e3}),g("textDanger");return}if(!i){v.error("Select required dates",{duration:1e3}),u("textDanger");return}const S=a.format("YYYY-MM-DD"),x=i.format("YYYY-MM-DD");d(`${Wc}?from_date=${S}&to_date=${x}&`),A(f=>({...f,page:1}))};return e.jsxs(C,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Search Expense"})}),e.jsx(C,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],alignItems:"end",children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsxs(C,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"From Date"}),e.jsx(n.DatePicker,{value:a,onChange:S=>{s(S),g("")},style:qi,allowClear:!1})]})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsxs(C,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"To Date"}),e.jsx(n.DatePicker,{value:i,onChange:S=>{o(S),u("")},style:qi,allowClear:!1})]})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:k})})]})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Expense List"})}),e.jsx(C,{pt:3,children:e.jsx(Te,{parentCallback:w,data:{newData:j,columns:R,action:!1,Loading:b,error:m,pageController:p}})})]})})]}),e.jsx("style",{children:".textDanger { color: #dc2626; }"})]})}function iy({data:t}){const{handleUpdate:a,token:s}=t||{},i=r.useContext(At),{isLoading:o,data:l}=W(s&&i?[`${Vc}?id=${i}`,s]:null,([u,p])=>K(u,p)),d=l?.data?.[0],[c,g]=r.useState({expensehead:"",description:""});r.useEffect(()=>{d&&g({expensehead:d?.exp_category||"",description:d?.description||""})},[d]);const h=(u,p)=>{g(A=>({...A,[u]:p}))};return o?e.jsx(C,{pt:4,pb:1,style:{width:350},children:e.jsx("div",{children:"Please Wait..."})}):e.jsxs(C,{pt:4,pb:1,style:{width:350},children:[e.jsx("form",{onSubmit:u=>a(u),children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(C,{children:[e.jsx(Y,{type:"text",value:i,name:"id",required:!0,className:"noDisplay",onChange:()=>{}}),e.jsx(Y,{name:"expensehead",type:"text",label:"Expense Head Name",required:!0,value:c.expensehead,onChange:u=>h("expensehead",u.target.value)})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(C,{children:e.jsx(Y,{name:"description",type:"text",label:"Description",required:!0,value:c.description,onChange:u=>h("description",u.target.value)})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})})})})]})}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function oy({token:t}){const[a,s]=r.useState({expensehead:"",description:""}),[i,o]=r.useState(!1),[l,d]=r.useState({page:1,rowsPerPage:10}),c=(S,x)=>{d({...l,page:S,rowsPerPage:parseInt(x,10)})},g=async(S,x)=>{try{await A(Ee(S,x,t),ze(x)),v.success("Success! Added new item.",{duration:1e3,icon:"🎉"})}catch{v.error("Failed to add the new item.",{duration:1e3})}},{isLoading:h,error:u,data:p,mutate:A}=W(t?[Lc,t,l.page,l.rowsPerPage]:null,([S,x,f,_])=>K(`${S}?page=${f}&per_page=${_}`,x)),w=r.useMemo(()=>[{id:"1",name:"Name",selector:"exp_category",sortable:!0},{id:"2",name:"Description",selector:"description",sortable:!0}],[]),b=[{key:"Edit",status:!0},{key:"Delete",status:!0},{key:"View",status:!1}],m=async S=>{try{await A(qe(zc,S,t),Ne(S)),v.success("Success! Deleted item.",{duration:1e3,icon:"🗑️"})}catch{v.error("Failed to delete the item.",{duration:1e3})}},j=async(S,x)=>{try{await A(Be(S,x,t)),v.success("Success! Updated item.",{duration:1e3,icon:"🚀"})}catch{v.error("Failed to update the item.",{duration:1e3})}},D=async S=>{S.preventDefault();const x=new FormData(S.target);await j(qc,x),k(!1)},R=async S=>{S.preventDefault();const x=new FormData(S.target);await g(Bc,x),S.target.reset()},k=S=>{o(S)};return e.jsxs(C,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:5,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Expense Head"})}),e.jsx(C,{p:3,children:e.jsx("form",{onSubmit:R,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsx(C,{children:e.jsx(Y,{name:"expensehead",type:"text",label:"Expense Head Name",required:!0,value:a.expensehead,onChange:S=>s(x=>({...x,expensehead:S.target.value}))})})}),e.jsx(n.Col,{xs:24,children:e.jsx(C,{children:e.jsx(Y,{name:"description",type:"text",label:"Description",required:!0,value:a.description,onChange:S=>s(x=>({...x,description:S.target.value}))})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justifyContent:"flex-end",children:e.jsx(n.Col,{children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})})})})]})})})]})}),e.jsx(n.Col,{xs:24,md:19,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Expense Head List"})}),e.jsx(C,{pt:3,children:e.jsx(Te,{parentCallback:c,data:{newData:p,columns:w,action:!0,Loading:h,ActionView:b,error:u,editDesign:e.jsx(iy,{data:{handleUpdate:D,token:t}}),deleteTodoMutation:m,open:i,DrawerUpdate:k}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function ly({token:t}){const[a,s]=r.useState(""),[i,o]=r.useState(""),[l,d]=r.useState(""),[c,g]=r.useState(0),[h,u]=r.useState(""),[p,A]=r.useState({page:1,rowsPerPage:10}),w=(I,B)=>{A({...p,page:I,rowsPerPage:parseInt(B,10)})},{isLoading:b,error:m,data:j,mutate:D}=W(t&&h?[h,t,p.page,p.rowsPerPage]:null,([I,B,L,y])=>K(`${I}page=${L}&per_page=${y}`,B)),{data:R}=W(t?[Xa,t]:null,([I,B])=>K(I,B)),{data:k}=W(t&&a?[`${Za}?class_id=${a}`,t]:null,([I,B])=>K(I,B)),S=r.useMemo(()=>R?Array.isArray(R)?R:Array.isArray(R?.data)?R.data:[]:[],[R]),x=r.useMemo(()=>k?Array.isArray(k)?k:Array.isArray(k?.data)?k.data:[]:[],[k]),f=r.useMemo(()=>[{id:"1",name:"First Name",selector:"firstname",sortable:!0},{id:"2",name:"Last Name",selector:"lastname",sortable:!0},{id:"3",name:"Class",selector:"class",sortable:!0},{id:"4",name:"Section",selector:"section",sortable:!0},{id:"5",name:"ID",selector:"username",sortable:!0},{id:"6",name:"Password",selector:"password",sortable:!0}],[]),_=I=>{s(I?.value||""),o(""),g(B=>B+1)},T=I=>{if(I.preventDefault(),!a){v.error("Please select class",{duration:1e3});return}if(!i){v.error("Please select section",{duration:1e3});return}const B=`${Hc}?class_id=${a}§ion_id=${i}&keyword=${l||""}&`;u(B),A(L=>({...L,page:1}))};return e.jsxs(C,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Student Login Credential"})}),e.jsx(C,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],align:"bottom",children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(C,{children:e.jsx(Q,{label:"Class",options:S,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:S.find(I=>String(I.value)===String(a))??null,onChange:_})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(C,{children:e.jsx(Q,{label:"Section",options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:x.find(I=>String(I.value)===String(i))??null,onChange:I=>o(I?.value||"")})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(C,{children:e.jsx(Y,{name:"keyword",type:"text",label:"Search By Keyword",value:l,onChange:I=>d(I.target.value)})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(ne,{type:"button",value:"Search",color:"primary",onClick:T})})]})})]})}),h&&e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(C,{pt:3,children:e.jsx(Te,{parentCallback:w,data:{newData:j,columns:f,action:!1,Loading:b,error:m,pageController:p}})})]})})]}),e.jsx("style",{children:".noDisplay { display: none; }"})]})}function dy({token:t}){const[a,s]=r.useState(""),[i,o]=r.useState(""),[l,d]=r.useState(""),[c,g]=r.useState(0),[h,u]=r.useState(Lo),[p,A]=r.useState(!1),[w,b]=r.useState(null);console.log("Selected Student ID:",p);const[m,j]=r.useState({page:1,rowsPerPage:10}),D=($,U)=>{j({...m,page:$,rowsPerPage:parseInt(U,10)})},{isLoading:R,error:k,data:S,mutate:x}=W(t&&h?[h,t,m.page,m.rowsPerPage]:null,([$,U,N,V])=>K(`${$}page=${N}&per_page=${V}`,U)),{data:f}=W(t?[Xa,t]:null,([$,U])=>K($,U)),{data:_}=W(t&&a?[`${Za}?class_id=${a}`,t]:null,([$,U])=>K($,U)),T=r.useMemo(()=>f?Array.isArray(f)?f:Array.isArray(f?.data)?f.data:[]:[],[f]),I=r.useMemo(()=>_?Array.isArray(_)?_:Array.isArray(_?.data)?_.data:[]:[],[_]),B=r.useMemo(()=>[{id:"1",name:"EC No",selector:"ec_no",sortable:!0},{id:"2",name:"Roll NO",selector:"roll_no",sortable:!0},{id:"3",name:"Admission Number",selector:"admission_no",sortable:!0},{id:"4",name:"First Name",selector:"firstname",sortable:!0},{id:"5",name:"Last Name",selector:"lastname",sortable:!0},{id:"6",name:"Class",selector:"class",sortable:!0},{id:"7",name:"Section",selector:"section",sortable:!0},{id:"8",name:"Father Name",selector:"father_name",sortable:!0},{id:"9",name:"Medicine",selector:"Medical",sortable:!1,render:($,U)=>e.jsx(n.Button,{type:"primary",size:"small",onClick:()=>{b(U.id),A(!0)},children:"Medical"})}],[]),L=$=>{s($?.value||""),o(""),g(U=>U+1)},y=$=>{if($.preventDefault(),!a||!i){v.error("Please select class and section",{duration:1e3});return}const U=`${qo}?cID=${a}&sID=${i}&page=${m.page}&per_page=${m.rowsPerPage}&`;u(U),j(N=>({...N,page:1}))},P=$=>{$.preventDefault();const U=$.target.searchField?.value||"";d(U);const N=`${Bo}?key=${U}&page=${m.page}&per_page=${m.rowsPerPage}&`;u(N),j(V=>({...V,page:1}))},O=async $=>{$.preventDefault();const U=new FormData($.target),N=Kc;try{await x(addData(N,U,t)),v.success("Medicine added successfully",{duration:1e3}),$.target.reset()}catch{v.error("Failed to add medicine",{duration:1e3})}};return e.jsxs(C,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Medical Report"})}),e.jsx(C,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:y,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx(C,{children:e.jsx(Q,{label:"Class",options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:T.find($=>String($.value)===String(a))??null,onChange:L})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(C,{children:e.jsx(Q,{label:"Section",options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:I.find($=>String($.value)===String(i))??null,onChange:$=>o($?.value||"")})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:P,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:16,children:e.jsx(Y,{name:"searchField",type:"text",label:"Search By Keyword",value:l,onChange:$=>d($.target.value)})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})]})})})]})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(C,{pt:3,children:e.jsx(Te,{parentCallback:D,data:{newData:S,columns:B,action:!1,Loading:R,error:k,pageController:m}})})]})})]}),e.jsx(n.Drawer,{title:"Medical Report",placement:"right",width:600,open:p,footer:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(ne,{type:"button",value:"Close",color:"default"})})}),children:e.jsx(cy,{studentId:w,token:t,onAddMedicine:O})}),e.jsx("style",{children:".noDisplay { display: none; } .buttonCoustom { margin-top: 8px; }"})]})}function cy({studentId:t,token:a,onAddMedicine:s}){const{data:i}=W(a&&t?[`${zo}?id=${t}`,a]:null,([g,h])=>K(g,h)),{data:o}=W(a&&t?[`${Gc}?student_id=${t}`,a]:null,([g,h])=>K(g,h)),l=i?.studentBasicDetails?.[0];let d=[];Array.isArray(o?.data)?d=o.data:Array.isArray(o)&&(d=o);const c=[{title:"Medicine",dataIndex:"medicine",key:"medicine"},{title:"Notes",dataIndex:"notes",key:"notes"},{title:"Date",dataIndex:"date_time",key:"date_time"}];return e.jsxs(C,{children:[l&&e.jsxs(C,{mb:3,children:[e.jsxs(ge,{level:4,children:["Name: ",l?.firstname," ",l?.lastname]}),e.jsxs("div",{style:{fontSize:15},children:["Class: ",l?.class," (",l?.section,")"]}),e.jsxs("div",{style:{fontSize:15},children:["Admission No: ",l?.admission_no]})]}),e.jsx(ge,{level:5,style:{marginBottom:8},children:"Add Medicine"}),e.jsx("form",{onSubmit:s,style:{marginBottom:24},children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(C,{children:[e.jsx(Y,{name:"medicine",type:"text",label:"Medicine Name",required:!0}),e.jsx("input",{name:"student_id",type:"hidden",value:t||"",readOnly:!0})]})}),e.jsx(n.Col,{xs:24,children:e.jsx(C,{children:e.jsx(st,{name:"notes",label:"Note",rows:3})})}),e.jsx(n.Col,{xs:24,children:e.jsx(C,{children:e.jsx(Me,{format:"YYYY-MM-DD HH:mm",Desplay:"Date",name:"date_time",defaultValue:te()})})}),e.jsx(n.Col,{xs:24,children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Add",color:"primary"})})})})})]})}),e.jsx(ge,{level:5,style:{marginBottom:8},children:"Previous Medicine"}),e.jsx(n.Table,{size:"small",dataSource:d,pagination:!1,columns:c})]})}const{Group:zi}=n.Checkbox;function uy({token:t}){const[a,s]=r.useState(""),[i,o]=r.useState(""),[l,d]=r.useState(""),[c,g]=r.useState(0),[h,u]=r.useState(Lo),[p,A]=r.useState(!1),[w,b]=r.useState(null),[m,j]=r.useState({page:1,rowsPerPage:10}),D=(N,V)=>{j({...m,page:N,rowsPerPage:parseInt(V,10)})},{isLoading:R,error:k,data:S,mutate:x}=W(t&&h?[h,t,m.page,m.rowsPerPage]:null,([N,V,z,E])=>K(`${N}page=${z}&per_page=${E}`,V)),{data:f}=W(t?[Xa,t]:null,([N,V])=>K(N,V)),{data:_}=W(t&&a?[`${Za}?class_id=${a}`,t]:null,([N,V])=>K(N,V)),T=r.useMemo(()=>f?Array.isArray(f)?f:Array.isArray(f?.data)?f.data:[]:[],[f]),I=r.useMemo(()=>_?Array.isArray(_)?_:Array.isArray(_?.data)?_.data:[]:[],[_]),B=r.useMemo(()=>[{id:"1",name:"EC No",selector:"ec_no",sortable:!0},{id:"2",name:"Roll NO",selector:"roll_no",sortable:!0},{id:"3",name:"Admission Number",selector:"admission_no",sortable:!0},{id:"4",name:"First Name",selector:"firstname",sortable:!0},{id:"5",name:"Last Name",selector:"lastname",sortable:!0},{id:"6",name:"Class",selector:"class",sortable:!0},{id:"7",name:"Section",selector:"section",sortable:!0},{id:"8",name:"Father Name",selector:"father_name",sortable:!0},{id:"9",name:"Assign Subject",selector:"Assign",sortable:!1,render:(N,V)=>e.jsx(n.Button,{type:"primary",size:"small",onClick:()=>{b(V.id),A(!0)},children:"Assign"})}],[]),L=N=>{s(N?.value||""),o(""),g(V=>V+1)},y=N=>{if(N.preventDefault(),!a||!i){v.error("Please select class and section",{duration:1e3});return}const V=`${qo}?cID=${a}&sID=${i}&page=${m.page}&per_page=${m.rowsPerPage}&`;u(V),j(z=>({...z,page:1}))},P=N=>{N.preventDefault();const V=N.target.searchField?.value||"";d(V);const z=`${Bo}?key=${V}&page=${m.page}&per_page=${m.rowsPerPage}&`;u(z),j(E=>({...E,page:1}))},O=async N=>{N.preventDefault();const V=new FormData(N.target),z=Qc;try{await x(Be(z,V,t)),v.success("Subject updated successfully",{duration:1e3}),N.target.reset(),A(!1)}catch{v.error("Failed to update subject",{duration:1e3})}},$=async N=>{N.preventDefault();const V=new FormData(N.target),z=Ks;try{await x(Be(z,V,t)),v.success("Extra curricular updated successfully",{duration:1e3}),N.target.reset(),A(!1)}catch{v.error("Failed to update extra curricular",{duration:1e3})}},U=N=>{A(N)};return e.jsxs(C,{pt:5,pb:1,children:[e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Assign Student Subject"})}),e.jsx(C,{p:3,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:y,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:8,children:e.jsx(C,{children:e.jsx(Q,{label:"Class",options:T,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:T.find(N=>String(N.value)===String(a))??null,onChange:L})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(C,{children:e.jsx(Q,{label:"Section",options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:I.find(N=>String(N.value)===String(i))??null,onChange:N=>o(N?.value||"")})})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Col,{xs:24,md:12,children:e.jsx("form",{onSubmit:P,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:16,children:e.jsx(Y,{name:"searchField",type:"text",label:"Search By Keyword",value:l,onChange:N=>d(N.target.value)})}),e.jsx(n.Col,{xs:24,md:8,children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})]})})})]})})]})}),e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Student List"})}),e.jsx(C,{pt:3,children:e.jsx(Te,{parentCallback:D,data:{newData:S,columns:B,action:!1,Loading:R,error:k,pageController:m}})})]})})]}),p&&e.jsx(py,{open:p,DrawerUpdate:U,studentId:w,token:t,onUpdate:O,onUpdate2:$}),e.jsx("style",{children:".noDisplay { display: none; } .buttonCoustom { margin-top: 8px; }"})]})}function py({open:t,DrawerUpdate:a,studentId:s,token:i,onUpdate:o,onUpdate2:l}){const[d,c]=r.useState([]),[g,h]=r.useState([]),[u,p]=r.useState([]),[A,w]=r.useState(!1),[b,m]=r.useState([]),[j,D]=r.useState([]),[R,k]=r.useState([]),{trigger:S}=tt(zo,async(B,{arg:L})=>await K(`${B}?id=${L.id}`,i)),{trigger:x}=tt(Ks,async()=>await K(`${Ks}?student_id=${s}`,i)),{trigger:f}=tt(Jc,async(B,{arg:L})=>await K(`${B}?id=${L.id}`,i));r.useEffect(()=>{(async()=>{if(!s)return;w(!0);const L=await S({id:s});L?.studentBasicDetails?.[0];const y=await x(),P=await f({id:s});c(L),p(P),L&&h(y),w(!1)})()},[s,S,x,f]);const _=B=>{D(B);const L=d?.data?.filter(y=>!B.includes(y.value));m(JSON.stringify(L))},T=B=>{k(B)},I=d?.studentBasicDetails?.[0];return!A&&s?e.jsx("div",{style:{position:"fixed",top:0,right:0,width:400,height:"100vh",background:"#fff",boxShadow:"-2px 0 8px rgba(0,0,0,0.15)",zIndex:9999,overflow:"auto"},children:e.jsxs(C,{p:3,children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Edit Assigned Subjects"})}),e.jsxs(C,{p:3,children:[I&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs(ge,{level:4,children:["Name: ",I?.firstname," ",I?.lastname]}),e.jsxs("div",{style:{fontSize:15},children:["Class: ",I?.class," (",I?.section,")"]}),e.jsxs("div",{style:{fontSize:15},children:["Admission No: ",I?.admission_no]})]}),e.jsx("form",{onSubmit:o,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsxs(n.Col,{xs:24,children:[e.jsx(ge,{level:5,children:"Subjects"}),e.jsx(zi,{options:d?.data?.map(B=>({label:B.label||B.name,value:B.value})),value:j,onChange:_,style:{display:"grid",gap:8}})]}),e.jsxs(n.Col,{xs:24,children:[e.jsx("input",{name:"student_id",type:"hidden",value:s||"",readOnly:!0}),e.jsx("input",{name:"subjectUncheck[]",type:"hidden",value:b,readOnly:!0})]}),d?.data?.length===0?e.jsx(n.Col,{xs:24,children:e.jsx("span",{style:{cursor:"pointer",fontSize:15,color:"blue",textDecoration:"underline"},children:"Please Assign Subject"})}):e.jsx(n.Col,{xs:24,className:"buttonCoustom",children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Update",color:"primary"})})})})})]})}),g?.data?.length>0&&e.jsx("form",{onSubmit:l,style:{marginTop:24},children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsxs(n.Col,{xs:24,children:[e.jsx(ge,{level:5,children:"Extra Curricular Activities"}),e.jsx(zi,{options:g?.data?.map(B=>({label:B.label||B.name,value:B.value})),value:R,onChange:T,style:{display:"grid",gap:8}})]}),e.jsx(n.Col,{xs:24,children:e.jsx("input",{name:"student_id",type:"hidden",value:s||"",readOnly:!0})}),e.jsx(n.Col,{xs:24,className:"buttonCoustom",children:e.jsx(n.Row,{justify:"end",children:e.jsx(n.Col,{children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:"Update",color:"primary"})})})})})]})})]})]})}):e.jsx("div",{style:{position:"fixed",top:0,right:0,width:400,height:"100vh",background:"#fff",boxShadow:"-2px 0 8px rgba(0,0,0,0.15)",zIndex:9999,overflow:"auto"},children:e.jsx(C,{p:3,children:e.jsx("div",{children:"Loading..."})})})}function my({token:t}){const[a,s]=r.useState(""),[i,o]=r.useState(""),[l,d]=r.useState(0),[c,g]=r.useState(null),[h,u]=r.useState(!1),{data:p}=W(t?[Xa,t]:null,([f,_])=>K(f,_)),{data:A}=W(t&&a?[`${Za}?class_id=${a}`,t]:null,([f,_])=>K(f,_)),{data:w}=W(t?[Zc,t]:null,([f,_])=>K(`${f}?page=1&per_page=10`,_)),b=r.useMemo(()=>p?Array.isArray(p)?p:Array.isArray(p?.data)?p.data:[]:[],[p]),m=r.useMemo(()=>A?Array.isArray(A)?A:Array.isArray(A?.data)?A.data:[]:[],[A]),j=r.useMemo(()=>[{id:"1",name:"Category Id",selector:"id",sortable:!0},{id:"2",name:"Category",selector:"category",sortable:!0}],[]),D=f=>{s(f?.value||""),o(""),d(_=>_+1)},R=f=>{o(f?.value||"")},k=()=>{const f=document.createElement("a");f.href="/sample_student.xlsx",f.download="sample_student.xlsx",f.click()},S=f=>{f.fileList.length>0?g(f.fileList[0].originFileObj):g(null)},x=async f=>{if(f.preventDefault(),!a){v.error("Please select class",{duration:1e3});return}if(!i){v.error("Please select section",{duration:1e3});return}if(!c){v.error("Please select file",{duration:1e3});return}u(!0);const _=new FormData;_.append("file",c),_.append("class_id",a),_.append("section_id",i);try{const T=await lc(Xc,_,t);T?.Status==="Failed"?v.error(T?.msg||"Upload failed",{duration:2e3}):(v.success(T?.msg||"Upload successful",{duration:2e3}),g(null),s(""),o(""))}catch(T){v.error(T?.response?.data?.msg||"Upload failed",{duration:2e3})}finally{u(!1)}};return e.jsx(C,{pt:5,pb:1,children:e.jsx(n.Row,{gutter:[16,16],children:e.jsx(n.Col,{xs:24,children:e.jsxs(n.Card,{children:[e.jsx(C,{mx:2,mt:-3,py:1,px:1,style:{background:"linear-gradient(90deg, #5080f8 0%, #3b5de7 100%)",borderRadius:8,color:"#fff",display:"inline-block"},children:e.jsx(ge,{level:5,style:{margin:0,color:"#fff"},children:"Bulk Upload Students"})}),e.jsxs(C,{p:3,children:[e.jsx(n.Row,{justify:"end",style:{marginBottom:16},children:e.jsx(n.Col,{children:e.jsx(n.Button,{type:"primary",icon:e.jsx(ee.DownloadOutlined,{}),onClick:k,style:{background:"#368fed"},children:"Download Sample Import File"})})}),e.jsxs("div",{style:{marginBottom:16,padding:16,background:"#f5f5f5",borderRadius:8},children:[e.jsx(ge,{level:5,style:{marginBottom:8},children:"Information"}),e.jsx("div",{children:"1. Your Excel data should be in the format below. The first line of your Excel file should be the column headers as in the table example. Also make sure that your file is UTF-8 to avoid unnecessary encoding problems."}),e.jsx("div",{children:"2. If the column you are trying to import is date make sure that is formatted in format Y-m-d (2024-01-10)."}),e.jsx("div",{children:"3. Duplicate Admission Number, ec_no, aadhaar_number, (unique) rows will not be imported."}),e.jsx("div",{children:"4. For student Gender use Male, Female value."}),e.jsx("div",{children:"5. For student Blood Group use A+, A-, B+, B-, O+, O-, AB+, AB- value."}),e.jsx("div",{children:"6. * Imported field are admission_no, ec_no, firstname, lastname, roll_no, guardian_phone, aadhaar_number, category_id"})]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsx(ge,{level:5,style:{marginBottom:8},children:"Category Table"}),e.jsx(Te,{parentCallback:()=>{},data:{newData:w,columns:j,action:!1,Loading:!1,error:null,pageController:{page:1,rowsPerPage:10}}})]}),e.jsx("form",{onSubmit:x,children:e.jsxs(n.Row,{gutter:[16,16],children:[e.jsx(n.Col,{xs:24,md:6,children:e.jsx(C,{children:e.jsx(Q,{label:"Class",options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0,value:b.find(f=>String(f.value)===String(a))??null,onChange:D})})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsx(C,{children:e.jsx(Q,{label:"Section",options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,required:!0,value:m.find(f=>String(f.value)===String(i))??null,onChange:R},`section-${l}`)})}),e.jsx(n.Col,{xs:24,md:6,children:e.jsxs(C,{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"File"}),e.jsx(n.Upload,{beforeUpload:()=>!1,onChange:S,maxCount:1,accept:".xlsx,.xls",children:e.jsx(n.Button,{icon:e.jsx(ee.UploadOutlined,{}),style:{width:"100%"},children:c?c.name:"Select Excel File"})})]})}),e.jsx(n.Col,{xs:24,md:6,style:{display:"flex",alignItems:"flex-end"},children:e.jsx(C,{children:e.jsx(ne,{type:"submit",value:h?"Processing...":"Save",color:"primary",loading:h})})})]})})]})]})})})})}function hy(){return null}const ls=t=>t??localStorage.getItem("authToken")??"",fy=(t,a)=>{const s=String(t??""),i=String(a);return s?i?s.endsWith("/")&&i.startsWith("/")?`${s}${i.slice(1)}`:!s.endsWith("/")&&!i.startsWith("/")?`${s}/${i}`:`${s}${i}`:s:i},ul=()=>JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",De={uploadNotes:"api/branchapi/Academy/uploadNotes",master:{classes:{dropdown:"api/branchapi/academy/classdropdownlist",table:"api/branchapi/academy/classestableList",add:"api/branchapi/academy/addclasses",edit:"api/branchapi/academy/editclass",remove:"api/branchapi/academy/deleteclass",show:"api/branchapi/academy/classShowdata"},sections:{list:"api/branchapi/academy/sectionlist",table:"api/branchapi/academy/sectiontableList",add:"api/branchapi/academy/addsections",edit:"api/branchapi/academy/editsection",remove:"api/branchapi/academy/deletesection",show:"api/branchapi/academy/sectionShowdata",byClass:"api/branchapi/academy/sectionoftheClass"},subjects:{dropdown:"api/branchapi/Academy/getClassSubjectdropdown",byClassLabelValue:"api/branchapi/Academy/getSubjectsbyClassaslablevalue",table:"api/branchapi/academy/subjecttableList",add:"api/branchapi/academy/addsubjects",edit:"api/branchapi/academy/editsubject",remove:"api/branchapi/academy/deletesubject",show:"api/branchapi/academy/subjectShowdata"},holidays:{table:"api/branchapi/academy/holidayList",add:"api/branchapi/academy/addholidays",edit:"api/branchapi/academy/editholidays",remove:"api/branchapi/academy/deleteholiday",show:"api/branchapi/academy/getByIdholidays"}},assignSubjects:{assign:"api/branchapi/Academy/assign_class_subjects",list:"api/branchapi/academy/getSubjectsbyClass",update:"api/branchapi/academy/updateAssignSubject",editByClass:"api/branchapi/academy/editSubjectsbyClass"},assignByClass:{teacherDropdown:"api/branchapi/topics/getTeacherDropdown",classWithSection:"api/branchapi/academy/getClasswithSection",assignedSubjectsOfTeacher:"api/branchapi/academy/getassignedSubjectsofTeacher",subjectsOfTeacherByTeacherId:"api/branchapi/academy/getSubjectsofTeacherbyTeacherID",assignClassToTeacher:"api/branchapi/academy/assignClasstoTeacher",deleteTeacherSub:"api/branchapi/academy/deleteTeacherSub"},promoteStudents:{searchByClassSection:"api/branchapi/student/currentSessionStudentlist",sessionDropdown:"api/branchapi/generalSettings/sessiondropdown",promote:"api/branchapi/student/promotestudent"},timeGroup:{table:"api/branchapi/academy/getTimeGroupTable",add:"api/branchapi/academy/addTimeGroup",edit:"api/branchapi/academy/editTimeGroup",remove:"api/branchapi/academy/deleteTimeGroup",show:"api/branchapi/academy/getTimeGroupDataById",dropdown:"api/branchapi/academy/getTimeGroupDropDown"},assignTimeGroup:{classIdByTimeGroup:"api/branchapi/academy/getClassIdByTimeGroup",table:"api/branchapi/academy/getAssignedTimeGroupTable",show:"api/branchapi/academy/getAssignedTimeGroupDataById",assign:"api/branchapi/academy/assignTimeGroup"},timetable:{save:"api/timetable/save",byClassSection:"api/timetable/class",teacherTimetable:"api/timetable/teacher/",teachersBySubject:"api/branchapi/Academy/gettechersSubject"},notes:{table:"api/branchapi/Academy/getNotesTable",add:"api/branchapi/Academy/addNotes"},syllabus:{table:"api/branchapi/Academy/getsyllabusTable",add:"api/branchapi/Academy/addsyllabus",edit:"api/branchapi/Academy/editsyllabus"},transferCertificate:{studentList:"api/branchapi/student/getstudenttransferCertificateList",addData:"api/branchapi/academy/addtransferCertificatedata",view:"api/branchapi/academy/gettransferCertificateUrl"},coscholastic:{table:"api/branchapi/academy/getcoscholastic",addSkill:"api/branchapi/academy/add_coscholastic_skill",deleteSkill:"api/branchapi/academy/deleteCoscholastic",categoryDropdown:"api/branchapi/academy/coscholastic_categorydropdown",addCategory:"api/branchapi/academy/addcoscholastic_category",deleteCategory:"api/branchapi/academy/coscholasticCategoryDelete"}},yy=()=>fy(He(),De.uploadNotes),gy=async({baseUrl:t,page:a=1,perPage:s=10},i)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return K(l,ls(i))},_t=async(t,a,s,{includeSession:i=!1}={})=>{const o=a instanceof FormData?a:new FormData;return i&&!o.has("session_id")&&o.append("session_id",ul()),Ee(t,o,ls(s))},Bt=async(t,a,s,{includeSession:i=!1}={})=>{const o=a instanceof FormData?a:new FormData;return i&&!o.has("session_id")&&o.append("session_id",ul()),Be(t,o,ls(s))},qt=async(t,a,s)=>qe(t,a,ls(s)),zn=De.master.sections,sn=({baseUrl:t,page:a=1,perPage:s=10,token:i})=>W(i&&t?[t,a,s,i]:null,([l,d,c,g])=>gy({baseUrl:l,page:d,perPage:c},g)),xy=({token:t,page:a=1,perPage:s=10})=>sn({token:t,baseUrl:zn.table,page:a,perPage:s}),by=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function jy({token:t}){const[a,s]=r.useState({page:1,perPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(null),[c]=n.Form.useForm(),{data:g,isLoading:h,mutate:u}=xy({token:t,page:a.page,perPage:a.perPage}),p=r.useMemo(()=>by(g),[g]),A=r.useMemo(()=>g?.pagination?.total_rows??g?.pagination?.total??p.length??0,[g,p]),w=async R=>{R.preventDefault();const k=new FormData(R.target);try{await _t(zn.add,k,t),v.success("Success! Added new item.",{duration:1e3}),R.target.reset(),u()}catch(S){v.error(S?.response?.data?.msg??S?.message??"Failed to add the new item.",{duration:1500})}},b=async R=>{try{await qt(zn.remove,R,t),v.success("Success! Deleted item.",{duration:1e3}),u()}catch(k){v.error(k?.response?.data?.msg??k?.message??"Failed to delete the item.",{duration:1500})}},m=R=>{d(R),o(!0),c.setFieldsValue({section:R?.section??""})},j=async R=>{const k=new FormData;k.append("id",String(l?.id??"")),k.append("section",R.section??"");try{await Bt(zn.edit,k,t),v.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),u()}catch(S){v.error(S?.response?.data?.msg??S?.message??"Failed to update the item.",{duration:1500})}},D=r.useMemo(()=>[{title:"Section",dataIndex:"section",key:"section"},{title:"Actions",key:"actions",width:120,render:(R,k)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>m(k)}),e.jsx(n.Popconfirm,{title:"Delete this section?",onConfirm:()=>b(k?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[c]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Section",open:i,onClose:()=>{o(!1),d(null)},width:420,children:e.jsxs(n.Form,{form:c,layout:"vertical",onFinish:j,children:[e.jsx(n.Form.Item,{label:"Section Name",name:"section",rules:[{required:!0,message:"Section Name is required"}],children:e.jsx(n.Input,{placeholder:"Section Name"})}),e.jsxs(n.Space,{children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Section"}),children:e.jsx("form",{onSubmit:w,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Y,{type:"text",name:"section",label:"Section Name",required:!0}),e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Section List"}),extra:e.jsx(n.Space,{}),children:e.jsx(n.Table,{rowKey:R=>R.id,columns:D,dataSource:p,loading:h,pagination:{current:a.page,pageSize:a.perPage,total:A,showSizeChanger:!0,onChange:(R,k)=>s({page:R,perPage:k})}})})]})}function Sy({token:t}){return e.jsx(jy,{token:t})}const Na=De.master.classes,wy=({token:t,page:a=1,perPage:s=10})=>sn({token:t,baseUrl:Na.table,page:a,perPage:s}),vy=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},_y=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:[];function Cy({token:t}){const[a,s]=r.useState({page:1,perPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(null),[c]=n.Form.useForm(),[g]=n.Form.useForm(),{data:h}=W(t?[De.master.sections.list,t]:null,([T,I])=>K(T,I)),u=r.useMemo(()=>_y(h),[h]),p=r.useMemo(()=>u.map(T=>({label:T.label??T.section??String(T.value??""),value:String(T.value??T.id??"")})),[u]),{data:A,isLoading:w,mutate:b}=wy({token:t,page:a.page,perPage:a.perPage}),m=r.useMemo(()=>vy(A),[A]),j=r.useMemo(()=>A?.pagination?.total_rows??A?.pagination?.total??m.length??0,[A,m]),{data:D}=W(t&&l?[`${Na.show}?id=${encodeURIComponent(String(l))}`,t]:null,([T,I])=>K(T,I)),R=r.useMemo(()=>{const T=D?.data??D;return Array.isArray(T)?T:Array.isArray(T?.data)?T.data:T?[T]:[]},[D]),k=T=>{const I=T?.id??T?.class_id;I&&(d(I),o(!0))};r.useEffect(()=>{if(!i||!R.length)return;const T=R[0],I=R.map(y=>y?.section_id??y?.fk_sectionId??y?.sectionId??y?.section).filter(y=>y!=null&&String(y).trim()!=="").map(y=>String(y)),B=Array.isArray(T?.section_ids)?T.section_ids.map(y=>String(y)):typeof T?.section_ids=="string"?T.section_ids.split(",").map(y=>y.trim()).filter(Boolean):Array.isArray(T?.section)?T.section.map(y=>String(y)):[],L=I.length?I:B;g.setFieldsValue({name:T?.class??T?.name??"",section:L})},[i,R,g]);const S=async T=>{const I=new FormData;I.append("name",T.name??""),(T.section??[]).forEach(B=>I.append("section[]",String(B)));try{await _t(Na.add,I,t),v.success("Success! Added new item.",{duration:1e3}),c.resetFields(),b()}catch(B){v.error(B?.response?.data?.msg??B?.message??"Failed to add the new item.",{duration:1500})}},x=async T=>{const I=new FormData;I.append("id",String(l??"")),I.append("name",T.name??""),(T.section??[]).forEach(B=>I.append("section[]",String(B)));try{await Bt(Na.edit,I,t),v.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),b()}catch(B){v.error(B?.response?.data?.msg??B?.message??"Failed to update the item.",{duration:1500})}},f=async T=>{try{await qt(Na.remove,T,t),v.success("Success! Deleted item.",{duration:1e3}),b()}catch(I){v.error(I?.response?.data?.msg??I?.message??"Failed to delete the item.",{duration:1500})}},_=r.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class",render:(T,I)=>T??I?.name??""},{title:"Section",dataIndex:"sections",key:"sections",render:T=>T??""},{title:"Actions",key:"actions",width:120,render:(T,I)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>k(I)}),e.jsx(n.Popconfirm,{title:"Delete this class?",onConfirm:()=>f(I?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Class",open:i,onClose:()=>{o(!1),d(null)},width:520,children:e.jsxs(n.Form,{form:g,layout:"vertical",onFinish:x,children:[e.jsx(n.Form.Item,{label:"Class",name:"name",rules:[{required:!0,message:"Class is required"}],children:e.jsx(n.Input,{placeholder:"Class"})}),e.jsx(n.Form.Item,{label:"Sections",name:"section",rules:[{required:!0,message:"Please select at least one section"}],children:e.jsx(n.Checkbox.Group,{options:p})}),e.jsxs(n.Space,{children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Class"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:S,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",label:"Class",rules:[{required:!0,message:"Class is required"}],children:e.jsx(n.Input,{placeholder:"Class"})}),e.jsx(n.Form.Item,{name:"section",label:"Sections",rules:[{required:!0,message:"Select at least one section"}],children:e.jsx(n.Checkbox.Group,{options:p})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Class List"}),children:e.jsx(n.Table,{rowKey:T=>T.id,columns:_,dataSource:m,loading:w,pagination:{current:a.page,pageSize:a.perPage,total:j,showSizeChanger:!0,onChange:(T,I)=>s({page:T,perPage:I})}})})]})}function Ay({token:t}){return e.jsx(Cy,{token:t})}const La=De.master.subjects,Dy=({token:t,page:a=1,perPage:s=10})=>sn({token:t,baseUrl:La.table,page:a,perPage:s}),Ty=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Yi=[{value:"Practical",label:"Practical"},{value:"Theory",label:"Theory"}],Vi=[{value:"Main",label:"Main"},{value:"Additional",label:"Minor/Additional"},{value:"extra_curricular_activities",label:"Extra Curricular Activities"}];function Ry({token:t}){const[a,s]=r.useState({page:1,perPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(null),[c]=n.Form.useForm(),[g]=n.Form.useForm(),{data:h,isLoading:u,mutate:p}=Dy({token:t,page:a.page,perPage:a.perPage}),A=r.useMemo(()=>Ty(h),[h]),w=r.useMemo(()=>h?.pagination?.total_rows??h?.pagination?.total??A.length??0,[h,A]),{data:b}=W(t&&l?[`${La.show}?id=${encodeURIComponent(String(l))}`,t]:null,([x,f])=>K(x,f)),m=r.useMemo(()=>{const x=b?.data??b;return Array.isArray(x)?x[0]:x??null},[b]);r.useEffect(()=>{i&&m&&g.setFieldsValue({name:m?.name??"",subject_type:m?.subject_type??m?.type??"",type:"",subject_types:Array.isArray(m?.subject_types)?m.subject_types:typeof m?.subject_types=="string"?m.subject_types.split(",").map(x=>x.trim()).filter(Boolean):[],code:m?.code??""})},[i,m,g]);const j=async x=>{const f=x?.type??x?.subject_type??"",_={name:x?.name??"",subject_type:f,type:f,subject_types:Array.isArray(x?.subject_types)?x.subject_types:[],code:x?.code??""};try{await Ee(La.add,_,t),v.success("Success! Added new item.",{duration:1e3}),c.resetFields(),p()}catch(T){v.error(T?.response?.data?.msg??T?.message??"Failed to add the new item.",{duration:1500})}},D=async x=>{const f=new FormData,_=x?.type??x?.subject_type??"";f.append("id",String(l??"")),f.append("name",x.name??""),f.append("subject_type",x.subject_type??""),f.append("subject_type",_),f.append("type",_),f.append("code",x.code??"");try{await Bt(La.edit,f,t),v.success("Success! Updated item.",{duration:1e3}),v.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),p()}catch(T){v.error(T?.response?.data?.msg??T?.message??"Failed to update the item.",{duration:1500})}},R=async x=>{try{await qt(La.remove,x,t),v.success("Success! Deleted item.",{duration:1e3}),p()}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to delete the item.",{duration:1500})}},k=x=>{const f=x?.id;f&&(d(f),o(!0))},S=r.useMemo(()=>[{title:"Subject Name",dataIndex:"name",key:"name"},{title:"Subject",dataIndex:"subject_type",key:"subject_type"},{title:"Subject Code",dataIndex:"code",key:"code"},{title:"Subject Type",key:"subject_types",render:(x,f)=>{const _=[],T=f?.subject_types;Array.isArray(T)?T.forEach(P=>{const O=String(P??"").trim();O&&_.push(O)}):typeof T=="string"&&T.split(",").map(P=>P.trim()).filter(Boolean).forEach(P=>_.push(P));const I=["yes","1","true"].includes(String(f?.is_practical??"").toLowerCase()),B=["yes","1","true"].includes(String(f?.is_theory??"").toLowerCase());I&&_.push("Practical"),B&&_.push("Theory");const L=_.map(P=>String(P??"").trim()).filter(Boolean).map(P=>P.toLowerCase()==="practical"?"Practical":P.toLowerCase()==="theory"?"Theory":P),y=Array.from(new Set(L));return y.length?y.join(", "):"-"}},{title:"Actions",key:"actions",width:120,render:(x,f)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>k(f)}),e.jsx(n.Popconfirm,{title:"Delete this subject?",onConfirm:()=>R(f?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Subject",open:i,onClose:()=>{o(!1),d(null)},width:560,children:e.jsxs(n.Form,{form:g,layout:"vertical",onFinish:D,children:[e.jsx(n.Form.Item,{label:"Subject Name",name:"name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(Y,{placeholder:"Subject Name"})}),e.jsx(n.Form.Item,{label:"Subject",name:"subject_type",rules:[{required:!0,message:"Select subject category"}],children:e.jsx(n.Radio.Group,{options:Vi})}),e.jsx(n.Form.Item,{label:"Subject Type",name:"subject_types",rules:[{required:!0,type:"array",min:1,message:"Please choose at least one field"}],children:e.jsx(n.Checkbox.Group,{options:Yi})}),e.jsx(n.Form.Item,{label:"Subject Code",name:"code",children:e.jsx(Y,{placeholder:"Subject Code"})}),e.jsxs(n.Space,{children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Subject"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:j,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"name",label:"Subject Name",rules:[{required:!0,message:"Subject Name is required"}],children:e.jsx(Y,{placeholder:"Subject Name"})}),e.jsx(n.Form.Item,{name:"subject_type",label:"Subject",rules:[{required:!0,message:"Select subject"}],children:e.jsx(n.Radio.Group,{options:Vi})}),e.jsx(n.Form.Item,{name:"subject_types",label:"Subject Type",rules:[{required:!0,type:"array",min:1,message:"Please choose at least one field"}],children:e.jsx(n.Checkbox.Group,{options:Yi})}),e.jsx(n.Form.Item,{name:"code",label:"Subject Code",children:e.jsx(Y,{placeholder:"Subject Code"})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Subject List"}),children:e.jsx(n.Table,{rowKey:x=>x.id,columns:S,dataSource:A,loading:u,pagination:{current:a.page,pageSize:a.perPage,total:w,showSizeChanger:!0,onChange:(x,f)=>s({page:x,perPage:f})}})})]})}function Iy({token:t}){return e.jsx(Ry,{token:t})}const Ba=De.master.holidays,ky=({token:t,page:a=1,perPage:s=10})=>sn({token:t,baseUrl:Ba.table,page:a,perPage:s}),Py=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},An={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Oy({token:t}){const[a,s]=r.useState({page:1,perPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(null),[c]=n.Form.useForm(),[g]=n.Form.useForm(),{data:h,isLoading:u,mutate:p}=ky({token:t,page:a.page,perPage:a.perPage}),A=r.useMemo(()=>Py(h),[h]),w=r.useMemo(()=>h?.pagination?.total_rows??h?.pagination?.total??A.length??0,[h,A]),{data:b}=W(t&&l?[`${Ba.show}?id=${encodeURIComponent(String(l))}`,t]:null,([x,f])=>K(x,f)),m=r.useMemo(()=>{const x=b?.data??b;return Array.isArray(x)?x[0]:x??null},[b]);r.useEffect(()=>{i&&m&&g.setFieldsValue({title:m?.holiday_title??"",description:m?.holiday_description??"",from:m?.start_date?te(m.start_date):null,to:m?.end_date?te(m.end_date):null})},[i,m,g]);const j=async x=>{const f=new FormData;f.append("title",x.title??""),f.append("description",x.description??""),f.append("from",x.from?te(x.from).format("YYYY-MM-DD"):""),f.append("to",x.to?te(x.to).format("YYYY-MM-DD"):"");try{await _t(Ba.add,f,t,{includeSession:!0}),v.success("Success! Added new item.",{duration:1e3}),c.resetFields(),p()}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed to add the new item.",{duration:1500})}},D=async x=>{const f=new FormData;f.append("id",String(l??"")),f.append("title",x.title??""),f.append("description",x.description??""),f.append("from",x.from?te(x.from).format("YYYY-MM-DD"):""),f.append("to",x.to?te(x.to).format("YYYY-MM-DD"):"");try{await Bt(Ba.edit,f,t,{includeSession:!0}),v.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),p()}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed to update the item.",{duration:1500})}},R=async x=>{try{await qt(Ba.remove,x,t),v.success("Success! Deleted item.",{duration:1e3}),p()}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to delete the item.",{duration:1500})}},k=x=>{const f=x?.id;f&&(d(f),o(!0))},S=r.useMemo(()=>[{title:"Holiday Title",dataIndex:"holiday_title",key:"holiday_title"},{title:"Holiday Description",dataIndex:"holiday_description",key:"holiday_description"},{title:"Start From",dataIndex:"start_date",key:"start_date"},{title:"End At",dataIndex:"end_date",key:"end_date"},{title:"Actions",key:"actions",width:120,render:(x,f)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>k(f)}),e.jsx(n.Popconfirm,{title:"Delete this holiday?",onConfirm:()=>R(f?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Holiday",open:i,onClose:()=>{o(!1),d(null)},width:560,children:e.jsxs(n.Form,{form:g,layout:"vertical",onFinish:D,children:[e.jsx(n.Form.Item,{label:"Holiday Title",name:"title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(Y,{placeholder:"Holiday Title"})}),e.jsx(n.Form.Item,{label:"Holiday Description",name:"description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(Y,{placeholder:"Holiday Description"})}),e.jsx(n.Form.Item,{label:"Start From",name:"from",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:An})}),e.jsx(n.Form.Item,{label:"End At",name:"to",rules:[{required:!0,message:"End date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:An})}),e.jsxs(n.Space,{children:[e.jsx(ne,{type:"submit",value:"Update",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Holidays"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:j,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"title",label:"Holiday Title",rules:[{required:!0,message:"Holiday Title is required"}],children:e.jsx(Y,{placeholder:"Holiday Title"})}),e.jsx(n.Form.Item,{name:"description",label:"Holiday Description",rules:[{required:!0,message:"Holiday Description is required"}],children:e.jsx(st,{placeholder:"Holiday Description"})}),e.jsx(n.Form.Item,{name:"from",label:"Start From",rules:[{required:!0,message:"Start date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:An})}),e.jsx(n.Form.Item,{name:"to",label:"End At",rules:[{required:!0,message:"End date is required"}],children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:An})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Holidays List"}),children:e.jsx(n.Table,{rowKey:x=>x.id,columns:S,dataSource:A,loading:u,pagination:{current:a.page,pageSize:a.perPage,total:w,showSizeChanger:!0,onChange:(x,f)=>s({page:x,perPage:f})}})})]})}function My({token:t}){return e.jsx(Oy,{token:t})}const Yn=De.assignSubjects,Ey=({token:t,page:a=1,perPage:s=50})=>sn({token:t,baseUrl:Yn.list,page:a,perPage:s}),Wi=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Fy=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Uy({token:t}){const[a,s]=r.useState({page:1,perPage:50}),[i,o]=r.useState(null),[l,d]=r.useState([]),[c,g]=r.useState(!1),[h,u]=r.useState(!1),[p,A]=r.useState(null),[w,b]=r.useState([]),{data:m}=W(t?[De.master.classes.dropdown,t]:null,([O,$])=>K(O,$)),{data:j}=W(t?[De.master.subjects.dropdown,t]:null,([O,$])=>K(O,$)),D=r.useMemo(()=>Wi(m),[m]),R=r.useMemo(()=>Wi(j),[j]),k=r.useMemo(()=>R.map(O=>({label:O.label??O.subject??String(O.value??""),value:O.value??O.id})),[R]),{data:S,isLoading:x,mutate:f}=Ey({token:t,page:a.page,perPage:a.perPage}),_=r.useMemo(()=>Fy(S),[S]),T=r.useMemo(()=>S?.pagination?.total_rows??S?.pagination?.total??_.length??0,[S,_]),{data:I}=W(t&&p?[`${Yn.editByClass}?class_id=${encodeURIComponent(String(p))}`,t]:null,([O,$])=>K(O,$));r.useEffect(()=>{if(!h)return;const O=I?.data??I,$=Array.isArray(O)?O:Array.isArray(O?.data)?O.data:[];b($.map(U=>U.subject_id).filter(Boolean))},[h,I]);const B=async O=>{if(O.preventDefault(),!i?.value){v.error("Please select class",{duration:1200});return}if(!l.length){v.error("Please select subjects",{duration:1200});return}const $=new FormData;$.append("class_id",String(i.value)),l.forEach(U=>$.append("subject[]",String(U)));try{g(!0),await Bt(Yn.assign,$,t),v.success("Success! Updated item.",{duration:1e3}),o(null),d([]),f()}catch(U){v.error(U?.response?.data?.msg??U?.message??"Failed to update the item.",{duration:1500})}finally{g(!1)}},L=O=>{O&&(A(O),u(!0))},y=async()=>{if(!p)return;if(!w.length){v.error("Please select subjects",{duration:1200});return}const O=new FormData;O.append("class_id",String(p)),w.forEach($=>O.append("subject[]",String($)));try{await Bt(Yn.update,O,t),v.success("Success! Updated item.",{duration:1e3}),u(!1),A(null),f()}catch($){v.error($?.response?.data?.msg??$?.message??"Failed to update the item.",{duration:1500})}},P=r.useMemo(()=>[{title:"Class",dataIndex:"class",align:"center",width:"15%"},{title:"Subject",dataIndex:"subject_name",width:"70%",render:(O,$)=>e.jsx("div",{style:{paddingLeft:10,paddingRight:10,fontSize:14},children:($?.subject_name??O??"").split(",").join(", ")})},{title:"Action",width:"10%",render:(O,$)=>e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>L($?.class_id)})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Assigned Subjects",open:h,onClose:()=>{u(!1),A(null)},width:520,extra:e.jsxs(n.Space,{children:[e.jsx(n.Button,{onClick:()=>u(!1),children:"Cancel"}),e.jsx(n.Button,{type:"primary",onClick:y,children:"Update"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Q,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,value:D.find(O=>String(O.value)===String(p))??null,onChange:()=>{},isDisabled:!0}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(n.Checkbox.Group,{options:k,value:w,onChange:b})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Subject"}),children:e.jsx("form",{onSubmit:B,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:D,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:i,onChange:O=>o(O??null)}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subjects"}),e.jsx(n.Checkbox.Group,{options:k,value:l,onChange:d})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:c?"Please Wait..":"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assigned Subject List"}),children:e.jsx(n.Table,{rowKey:O=>O.id,columns:P,dataSource:_,loading:x,pagination:{current:a.page,pageSize:a.perPage,total:T,showSizeChanger:!0,onChange:(O,$)=>s({page:O,perPage:$})}})})]})}function $y({token:t}){return e.jsx(Uy,{token:t})}const ua=De.assignByClass,pl=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(typeof t?.data?.Status=="string"&&Array.isArray(t?.data?.data))return t.data.data;if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},Oa=t=>pl(t),Ny=t=>pl(t),Ma=t=>Array.isArray(t)?t:t==null||t===""?[]:[t];function Ly({token:t}){const[a,s]=r.useState(null),[i,o]=r.useState(null),[l,d]=r.useState(null),[c,g]=r.useState("No"),[h,u]=r.useState([]),[p,A]=r.useState([]),[w,b]=r.useState(null),[m,j]=r.useState(null),[D,R]=r.useState(!1),[k,S]=r.useState(""),{data:x}=W(t?[ua.teacherDropdown,t]:null,([de,X])=>K(de,X)),{data:f}=W(t?[De.master.classes.dropdown,t]:null,([de,X])=>K(de,X)),{data:_}=W(t&&m?[m,t]:null,([de,X])=>K(de,X)),{data:T}=W(t&&w?[w,t]:null,([de,X])=>K(de,X)),I=r.useMemo(()=>Oa(x),[x]),B=r.useMemo(()=>Oa(f),[f]),L=r.useMemo(()=>Oa(_),[_]),y=r.useMemo(()=>Oa(T),[T]),{data:P}=W(t&&a&&i&&l?[`${ua.subjectsOfTeacherByTeacherId}?teacher_id=${encodeURIComponent(String(a))}&class_id=${encodeURIComponent(String(i))}§ion_id=${encodeURIComponent(String(l))}`,t]:null,([de,X])=>K(de,X)),O=P?.data??P??null;r.useEffect(()=>{O&&(u(Array.isArray(O?.subject_ids)?O.subject_ids:[]),g(O?.isClassTeacher||"No"),A([]))},[O]);const{data:$}=W(t?[ua.classWithSection,t]:null,([de,X])=>K(de,X)),U=r.useMemo(()=>Oa($),[$]),[N,V]=r.useState(null),[z,E]=r.useState({page:1,perPage:25});r.useEffect(()=>{N||U?.[0]&&V(`${U[0].class_id}val${U[0].section_id}`)},[U,N]);const M=r.useMemo(()=>typeof window>"u"?"1":JSON.parse(localStorage.getItem("genrall_settings")??"null")?.session_id??"1",[]),F=r.useMemo(()=>{if(!N)return null;const[de,X]=String(N).split("val");if(!de||!X)return null;const ce=z.page??1,Re=z.perPage??25;return`${ua.assignedSubjectsOfTeacher}?page=${encodeURIComponent(String(ce))}&per_page=${encodeURIComponent(String(Re))}&session_id=${encodeURIComponent(String(M))}&class_id=${encodeURIComponent(String(de))}§ion_id=${encodeURIComponent(String(X))}`},[N,z.page,z.perPage,M]),{data:q,isLoading:H,mutate:re}=W(t&&F?[F,t]:null,([de,X])=>K(de,X),{revalidateOnFocus:!1}),G=r.useMemo(()=>Ny(q),[q]),J=r.useMemo(()=>{const de=q?.pagination??q?.data?.pagination??q?.data?.data?.pagination;return de?.total_rows??de?.total??G.length??0},[q,G]),ae=async de=>{if(de.preventDefault(),S(""),!a||!i||!l){v.error("Please select Teacher, Class and Section",{duration:1200});return}if(!Array.isArray(h)||h.length===0){S("error"),v.error("Please Select Subject",{duration:1200});return}const X=new FormData;X.append("teacher_id",String(a)),X.append("class_id",String(i)),X.append("section_id",String(l)),X.append("isClassTeacher",String(c??"No")),Ma(h).forEach(ce=>X.append("subject_ids[]",String(ce))),Ma(p).forEach(ce=>X.append("delete_subject[]",String(ce)));try{await _t(ua.assignClassToTeacher,X,t,{includeSession:!0}),v.success("Success! Added new item.",{duration:1e3}),S(""),re()}catch(ce){v.error(ce?.response?.data?.msg??ce?.message??"Failed to add the new item.",{duration:1500})}},oe=async de=>{try{await qt(ua.deleteTeacherSub,de,t),v.success("Success! Deleted item.",{duration:1e3}),re()}catch(X){v.error(X?.response?.data?.msg??X?.message??"Failed to delete the item.",{duration:1500})}},pe=de=>{const X=Array.isArray(de?.child)?de.child:[],ce=[{title:"Subject",dataIndex:"subject",key:"subject",align:"center"},{title:"Subject Code",dataIndex:"code",key:"code",align:"center"},{title:"Action",key:"action",align:"center",render:(Re,Ue)=>e.jsx(n.Popconfirm,{title:"Delete this subject?",onConfirm:()=>oe(Ue?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})}];return e.jsx("div",{style:{margin:12},children:e.jsx(n.Table,{columns:ce,bordered:!0,size:"small",dataSource:X,pagination:!1,rowKey:Re=>Re.id})})},_e=[{title:"Teacher Name",dataIndex:"teacher_name",key:"teacher_name",align:"center",render:(de,X)=>e.jsxs("div",{children:[X.teacher_name,X.classTeacher==="Yes"?e.jsx("span",{style:{fontWeight:700},children:" (Class Teacher)"}):null]})}],le=r.useMemo(()=>(U??[]).map(de=>({label:de.label??`${de.class_name??""} ${de.section_name??""}`.trim(),key:`${de.class_id}val${de.section_id}`,children:e.jsx(n.Table,{size:"small",columns:_e,bordered:!0,dataSource:Array.isArray(G)?G:[],loading:H,rowKey:X=>X.id,expandable:{expandedRowRender:pe},pagination:{current:z.page,pageSize:z.perPage,total:J,showSizeChanger:!0,onChange:(X,ce)=>E({page:X,perPage:ce})}})})),[U,z.page,z.perPage,G,H,J]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(320px, 380px) 1fr",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign by Class"}),children:e.jsx("form",{onSubmit:ae,children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Q,{options:I,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teachers",name:"teacher_id",required:!0,allowSelectAll:!1,value:I.find(de=>String(de.value)===String(a))??null,onChange:de=>s(de?.value??null)}),e.jsx(Q,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",required:!0,allowSelectAll:!1,value:B.find(de=>String(de.value)===String(i))??null,onChange:de=>{const X=de?.value??null;o(X),d(null),b(X?`${De.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(X))}`:null),j(X?`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(X))}`:null),R(ce=>!ce)}}),e.jsx(Q,{options:L,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",required:!0,allowSelectAll:!1,value:L.find(de=>String(de.value)===String(l))??null,onChange:de=>d(de?.value??null)},`section_${D}`),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Is Class Teacher?"}),(()=>{const de=[{label:"Yes",value:"Yes"},{label:"No",value:"No"}];return e.jsx(Q,{style:{width:"100%"},options:de,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:de.find(X=>String(X.value)===String(c??"No"))??de[1],onChange:X=>g(X?.value??"No")})})()]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Subject"}),e.jsx(Q,{isMulti:!0,style:{width:"100%"},placeholder:"select Subject",options:y,value:(y??[]).filter(de=>Ma(h).some(X=>String(X)===String(de.value))),onChange:(de,X)=>{const Re=(Array.isArray(de)?de:[]).map(Le=>Le?.value).filter(Le=>Le!=null&&Le!=="");u(Re);const Ue=Array.isArray(O?.subject_ids)?O.subject_ids.map(String):[],ke=X?.removedValue?.value,Ve=X?.option?.value;(X?.action==="remove-value"||X?.action==="pop-value")&&ke!=null&&Ue.includes(String(ke))&&A(Le=>Array.from(new Set([...Ma(Le).map(String),String(ke)]))),X?.action==="select-option"&&Ve!=null&&Ue.includes(String(Ve))&&A(Le=>Ma(Le).filter(at=>String(at)!==String(Ve)))}},`subjects_${D}`),k?e.jsx("div",{style:{color:"#ff4d4f",marginTop:6,fontSize:12},children:"Please select subject"}):null]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Teacher List"}),children:e.jsx(n.Tabs,{activeKey:N??void 0,onChange:de=>{V(de),E(X=>({...X,page:1}))},items:le,type:"card",size:"small"})})]})]})}function By({token:t}){return e.jsx(Ly,{token:t})}const Ea=De.timeGroup,qy=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]},Ut={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"};function Dn(t){if(!t)return null;const a=te(String(t),["h:mm a","HH:mm:ss","HH:mm"],!0);return a.isValid()?a:null}function $t(t){return t?te(t).format("h:mm a"):""}function zy({token:t}){const[a,s]=r.useState({page:1,perPage:50}),[i,o]=r.useState(!1),[l,d]=r.useState(null),[c]=n.Form.useForm(),[g]=n.Form.useForm(),h=`${Ea.table}?page=${encodeURIComponent(String(a.page))}&per_page=${encodeURIComponent(String(a.perPage))}`,{data:u,isLoading:p,mutate:A}=W(t?[h,t]:null,([f,_])=>K(f,_)),w=r.useMemo(()=>qy(u),[u]),b=r.useMemo(()=>u?.pagination?.total_rows??u?.pagination?.total??w.length??0,[u,w]),{data:m}=W(t&&l?[`${Ea.show}?id=${encodeURIComponent(String(l))}`,t]:null,([f,_])=>K(f,_)),j=r.useMemo(()=>{const f=m?.data??m;return Array.isArray(f)?f[0]:f??null},[m]);r.useEffect(()=>{i&&j&&g.setFieldsValue({title:j?.title??"",start_time_from:Dn(j?.start_time_from),start_time_to:Dn(j?.start_time_to),end_time_from:Dn(j?.end_time_from),end_time_to:Dn(j?.end_time_to)})},[i,j,g]);const D=async f=>{const _=new FormData;_.append("title",f.title??""),_.append("start_time_from",$t(f.start_time_from)),_.append("start_time_to",$t(f.start_time_to)),_.append("end_time_from",$t(f.end_time_from)),_.append("end_time_to",$t(f.end_time_to));try{await _t(Ea.add,_,t),v.success("Success! Added new item.",{duration:1e3}),c.resetFields(),A()}catch(T){v.error(T?.response?.data?.msg??T?.message??"Failed to add the new item.",{duration:1500})}},R=async f=>{const _=new FormData;_.append("id",String(l??"")),_.append("title",f.title??""),_.append("start_time_from",$t(f.start_time_from)),_.append("start_time_to",$t(f.start_time_to)),_.append("end_time_from",$t(f.end_time_from)),_.append("end_time_to",$t(f.end_time_to));try{await Bt(Ea.edit,_,t),v.success("Success! Updated item.",{duration:1e3}),o(!1),d(null),A()}catch(T){v.error(T?.response?.data?.msg??T?.message??"Failed to update the item.",{duration:1500})}},k=async f=>{try{await qt(Ea.remove,f,t),v.success("Success! Deleted item.",{duration:1e3}),A()}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed to delete the item.",{duration:1500})}},S=f=>{f?.id&&(d(f.id),o(!0))},x=r.useMemo(()=>[{title:"Title",dataIndex:"title",align:"center"},{title:"Start Time From",dataIndex:"start_time_from",align:"center"},{title:"Start Time To",dataIndex:"start_time_to",align:"center"},{title:"End Time From",dataIndex:"end_time_from",align:"center"},{title:"End Time To",dataIndex:"end_time_to",align:"center"},{title:"Action",align:"center",width:120,render:(f,_)=>e.jsxs(n.Space,{children:[e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>S(_)}),e.jsx(n.Popconfirm,{title:"Delete this time group?",onConfirm:()=>k(_?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Time Group",open:i,onClose:()=>{o(!1),d(null)},width:520,children:e.jsxs(n.Form,{form:g,layout:"vertical",onFinish:R,children:[e.jsx(n.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(Y,{placeholder:"Title"})}),e.jsx(n.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ut})}),e.jsx(n.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ut})}),e.jsx(n.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ut})}),e.jsx(n.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ut})}),e.jsxs(n.Space,{children:[e.jsx(ne,{type:"submit",value:"Submit",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>{o(!1),d(null)},children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Create Time Group"}),children:e.jsx(n.Form,{form:c,layout:"vertical",onFinish:D,initialValues:{},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(Y,{placeholder:"Title"})}),e.jsx(n.Form.Item,{name:"start_time_from",label:"Start Time From",rules:[{required:!0,message:"Start Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ut})}),e.jsx(n.Form.Item,{name:"start_time_to",label:"Start Time To",rules:[{required:!0,message:"Start Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ut})}),e.jsx(n.Form.Item,{name:"end_time_from",label:"End Time From",rules:[{required:!0,message:"End Time From is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ut})}),e.jsx(n.Form.Item,{name:"end_time_to",label:"End Time To",rules:[{required:!0,message:"End Time To is required"}],children:e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm a",style:Ut})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Submit",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Time Group List"}),children:e.jsx(n.Table,{rowKey:f=>f.id,columns:x,dataSource:w,loading:p,pagination:{current:a.page,pageSize:a.perPage,total:b,showSizeChanger:!0,onChange:(f,_)=>s({page:f,perPage:_})}})})]})}function Yy({token:t}){return e.jsx(zy,{token:t})}const Fa=De.assignTimeGroup,Vy=De.timeGroup.dropdown,Wy=De.master.classes.dropdown,Hi=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Hy=t=>{const a=t?.data?.data??t?.data??t??[];return Array.isArray(a)?a:Array.isArray(a?.data)?a.data:[]};function Ky({token:t}){const[a,s]=r.useState({page:1,perPage:50}),[i,o]=r.useState(null),[l,d]=r.useState([]),[c,g]=r.useState(""),[h,u]=r.useState(""),[p,A]=r.useState(null),[w,b]=r.useState(!1),[m,j]=r.useState(!1),[D,R]=r.useState(null),[k,S]=r.useState([]),[x,f]=r.useState(""),[_,T]=r.useState(""),{data:I}=W(t?[Vy,t]:null,([G,J])=>K(G,J)),{data:B}=W(t?[Wy,t]:null,([G,J])=>K(G,J)),L=r.useMemo(()=>Hi(I?.data??I),[I]),y=r.useMemo(()=>Hi(B),[B]),{data:P}=W(t&&p?[p,t]:null,([G,J])=>K(G,J));r.useEffect(()=>{const G=Array.isArray(P?.data)?P.data.map(J=>J.fk_classId):[];G.length&&d(G)},[P]);const O=`${Fa.table}?page=${encodeURIComponent(String(a.page))}&per_page=${encodeURIComponent(String(a.perPage))}`,{data:$,isLoading:U,mutate:N}=W(t?[O,t]:null,([G,J])=>K(G,J)),V=r.useMemo(()=>Hy($),[$]),z=r.useMemo(()=>$?.pagination?.total_rows??$?.pagination?.total??V.length??0,[$,V]),{data:E}=W(t&&D?[`${Fa.show}?id=${encodeURIComponent(String(D))}`,t]:null,([G,J])=>K(G,J)),M=E?.data??E??null;r.useEffect(()=>{if(!m||!M)return;const G=Array.isArray(M?.class_ids)?M.class_ids:[];S(G);const J=Array.isArray(L)?L.find(ae=>String(ae.value)===String(M?.timegroup_id)):null;J&&T(`${J.start_time_from} -> ${J.end_time_from}`)},[m,M,L]);const F=async G=>{if(G.preventDefault(),g(""),!i?.value){v.error("Select Time Group",{duration:1200});return}if(!l.length){g("error"),v.error("Please Select Classes",{duration:1200});return}const J=new FormData;J.append("timegroup_id",String(i.value)),l.forEach(ae=>J.append("class_ids[]",String(ae)));try{await _t(Fa.assign,J,t),v.success("Success! Added new item.",{duration:1e3}),d([]),o(null),u(""),N()}catch(ae){v.error(ae?.response?.data?.msg??ae?.message??"Failed to add the new item.",{duration:1500})}},q=async()=>{if(f(""),!D)return;if(!k.length){f("error"),v.error("Please Select Classes",{duration:1200});return}const G=new FormData;G.append("id",String(D)),G.append("timegroup_id",String(M?.timegroup_id??"")),k.forEach(J=>G.append("class_ids[]",String(J)));try{await Bt(Fa.assign,G,t),v.success("Success! Updated item.",{duration:1e3}),j(!1),R(null),N()}catch(J){v.error(J?.response?.data?.msg??J?.message??"Failed to update the item.",{duration:1500})}},H=G=>{G&&(R(G),j(!0))},re=r.useMemo(()=>[{title:"Title",dataIndex:"title",align:"center"},{title:"Class Names",dataIndex:"class_names",align:"center"},{title:"Start Time From",dataIndex:"start_time_from",align:"center"},{title:"Start Time To",dataIndex:"start_time_to",align:"center"},{title:"End Time From",dataIndex:"end_time_from",align:"center"},{title:"End Time To",dataIndex:"end_time_to",align:"center"},{title:"Action",align:"center",width:90,render:(G,J)=>J?.class_names?e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>H(J?.id)}):null}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Drawer,{title:"Edit Assigned Time Group",open:m,onClose:()=>{j(!1),R(null)},width:520,extra:e.jsxs(n.Space,{children:[e.jsx(n.Button,{onClick:()=>j(!1),children:"Cancel"}),e.jsx(n.Button,{type:"primary",onClick:q,children:"Submit"})]}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(Q,{options:Array.isArray(L)?L:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",allowSelectAll:!1,value:L.find(G=>String(G.value)===String(M?.timegroup_id))??null,onChange:()=>{},isDisabled:!0}),e.jsx("div",{style:{marginTop:4,fontSize:16},children:_}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(n.Select,{mode:"multiple",style:{width:"100%"},status:x,value:k,placeholder:"Select Classes",onChange:G=>S(G),options:Array.isArray(y)?y:[]})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Time Group"}),children:e.jsx("form",{onSubmit:F,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsxs("div",{children:[e.jsx(Q,{options:Array.isArray(L)?L:[],closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Select Time Group",name:"timegroup_id",required:!0,allowSelectAll:!1,value:i,onChange:G=>{o(G??null),d([]),g(""),G?.value?(A(`${Fa.classIdByTimeGroup}?id=${encodeURIComponent(String(G.value))}`),u(`${G.start_time_from} -> ${G.end_time_from}`)):(A(null),u("")),b(J=>!J)}}),e.jsx("div",{style:{marginTop:6},children:h})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Select Classes"}),e.jsx(Q,{mode:"multiple",style:{width:"100%"},status:c,value:l,placeholder:"Select Classes",onChange:G=>d(G),options:Array.isArray(y)?y:[]},`class_${w}`)]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assigned Time group List"}),children:e.jsx(n.Table,{rowKey:G=>G.id,columns:re,dataSource:V,loading:U,pagination:{current:a.page,pageSize:a.perPage,total:z,showSizeChanger:!0,onChange:(G,J)=>s({page:G,perPage:J})}})})]})}function Gy({token:t}){return e.jsx(Ky,{token:t})}const Gs=De.promoteStudents,Jy=({token:t})=>W(t?[Gs.sessionDropdown,t]:null,([a,s])=>K(a,s)),Tn=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},Qy=(t,a)=>{const s=t?.pagination??t?.data?.pagination??t?.data?.data?.pagination,i=s?.total_rows??s?.total??s?.totalItems;return Number.isFinite(Number(i))?Number(i):a};function Xy({token:t}){const[a]=n.Form.useForm(),[s,i]=r.useState({page:1,perPage:300}),[o,l]=r.useState({classId:null,sectionId:null}),[d,c]=r.useState({sessionId:null,classId:null}),[g,h]=r.useState(!1),[u,p]=r.useState([]),A=r.useMemo(()=>new Set(u),[u]),[w,b]=r.useState({}),[m,j]=r.useState({}),{data:D}=W(t?[De.master.classes.dropdown,t]:null,([q,H])=>K(q,H)),R=r.useMemo(()=>Tn(D),[D]),k=r.useMemo(()=>o.classId?`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(o.classId))}`:null,[o.classId]),{data:S}=W(t&&k?[k,t]:null,([q,H])=>K(q,H)),x=r.useMemo(()=>Tn(S),[S]),f=r.useMemo(()=>d.classId?`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(d.classId))}`:null,[d.classId]),{data:_}=W(t&&f?[f,t]:null,([q,H])=>K(q,H),{revalidateOnFocus:!1}),T=r.useMemo(()=>Tn(_),[_]),{data:I}=Jy({token:t}),B=r.useMemo(()=>Tn(I),[I]),{trigger:L,data:y,isMutating:P}=tt(t?Gs.searchByClassSection:null,(q,{arg:H})=>Gt(q,{arg:H},t)),O=r.useMemo(()=>{const q=y?.data?.data??y?.data??y??[];return Array.isArray(q)?q:Array.isArray(q?.data)?q.data:[]},[y]),$=r.useMemo(()=>Qy(y,O.length??0),[y,O.length]),U=r.useMemo(()=>{const q=new Map;return(Array.isArray(O)?O:[]).forEach(H=>{H?.id!==void 0&&H?.id!==null&&q.set(String(H.id),H)}),q},[O]),N=r.useCallback((q,H)=>{const re=String(q);j(G=>({...G,[re]:{...G?.[re]??{},...H}}))},[]),V=r.useCallback((q,H)=>{const re=String(q),G=H==="Leave";b(J=>({...J,[re]:G}))},[]),z=q=>{const H=q?.class_id?.value??q?.class_id??null,re=q?.section_id?.value??q?.section_id??null;if(!H||!re){v.error("Please select Class and Section",{duration:1200});return}i(G=>({...G,page:1})),l({classId:H,sectionId:re}),p([]),b({}),j({})},E=async()=>{if(!d.sessionId||!d.classId){v.error("Please select Session and Class for promotion",{duration:1300});return}if(!Array.isArray(u)||u.length===0){v.error("Please select students to promote",{duration:1200});return}const q=u.map(J=>String(J)).map(J=>{const ae=U.get(J)??{},oe=!!w?.[J],pe=m?.[J]??{},_e=String(pe.current_result??"Pass");if(oe){const X=String(pe.leave_date??"");return{student_id:J,current_result:_e,next_session_status:"Leave",leave_date:X}}const le=String(pe.roll_no??ae?.roll_no??""),de=String(pe.section_id??"");return{student_id:J,roll_no:le,section_id:de,current_result:_e,next_session_status:"Continue"}});if(q.some(J=>J?.next_session_status==="Leave"&&!String(J?.leave_date??"").trim())){v.error("Leave date is required for Leave students.",{duration:1500});return}if(q.some(J=>J?.next_session_status==="Continue"&&!String(J?.section_id??"").trim())){v.error("Section is required for Continue students.",{duration:1500});return}const G={class_id:String(d.classId),session_id:String(d.sessionId),students:q};try{const J=await Be(Gs.promote,G,t);if(J?.Status&&String(J.Status)!=="success")throw new Error(J?.msg||"Failed to update");v.success("Success! Updated.",{duration:1e3});const ae=Number(J?.success_count??0)+Number(J?.leave_count??0),oe=s.page===Math.ceil((Number($)||0)/s.perPage||1),pe=ae>0&&ae===O.length&&O.length===u.length,_e=oe&&pe&&s.page>1?s.page-1:s.page;i(le=>({...le,page:_e})),L?.({cID:o.classId,sID:o.sectionId,page:_e,per_page:s.perPage}),p([]),b({}),j({})}catch(J){v.error(J?.response?.data?.msg??J?.message??"Failed to update",{duration:1500})}},M=r.useMemo(()=>[{title:"Admission No",dataIndex:"admission_no",key:"admission_no",width:140},{title:"Roll No",dataIndex:"roll_no",key:"roll_no",width:120,render:(q,H)=>{const re=String(H?.id??""),G=A.has(re),J=!!w?.[re],oe=(m?.[re]??{}).roll_no??(J?"":H?.roll_no??"");return e.jsx(n.Input,{value:G?oe:H?.roll_no,style:G?{textAlign:"center"}:{textAlign:"center",border:"none",background:"transparent",cursor:"default"},disabled:!G||J,onChange:pe=>N(re,{roll_no:pe.target.value})})}},{title:"Name",dataIndex:"firstname",key:"name",render:(q,H)=>`${H?.firstname??""} ${H?.lastname??""}`.trim()},{title:"Section",dataIndex:"section",key:"section",width:160,render:(q,H)=>{const re=String(H?.id??""),G=A.has(re),J=!!w?.[re],oe=(m?.[re]??{}).section_id??"",pe=Array.isArray(T)?T:[];return e.jsx(n.Select,{options:pe,placeholder:G&&!J?"Select Section":"Section",disabled:!G||J,value:G&&!J&&oe||void 0,style:{width:"100%"},onChange:_e=>N(re,{section_id:_e})},`section_${re}_${g}_${J?"L":"C"}`)}},{title:"Current Result",dataIndex:"current_result",key:"current_result",width:160,render:(q,H)=>{const re=String(H?.id??""),G=A.has(re),J=m?.[re]??{},ae=String(J.current_result??"Pass");return e.jsxs(n.Radio.Group,{value:ae,disabled:!G,buttonStyle:"solid",onChange:oe=>N(re,{current_result:oe.target.value}),children:[e.jsx(n.Radio.Button,{value:"Pass",children:"Pass"}),e.jsx(n.Radio.Button,{value:"Fail",children:"Fail"})]})}},{title:"Next Session Status",dataIndex:"next_session_status",key:"next_session_status",width:220,render:(q,H)=>{const re=String(H?.id??""),G=A.has(re),J=!!w?.[re],ae=m?.[re]??{},oe=String(ae.leave_date??"");return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsxs(n.Radio.Group,{value:J?"Leave":"Continue",disabled:!G,buttonStyle:"solid",onChange:pe=>V(re,pe.target.value),children:[e.jsx(n.Radio.Button,{value:"Continue",children:"Continue"}),e.jsx(n.Radio.Button,{value:"Leave",children:"Leave"})]}),G&&J&&e.jsx(n.DatePicker,{style:{width:"100%"},value:oe?te(oe):null,onChange:pe=>N(re,{leave_date:pe?pe.format("YYYY-MM-DD"):""}),placeholder:"Leave date"})]})}}],[V,w,m,A,g,T,N]),F=r.useMemo(()=>({selectedRowKeys:u,onChange:q=>p((Array.isArray(q)?q:[]).map(H=>String(H)))}),[u]);return r.useEffect(()=>{!o.classId||!o.sectionId||L&&L({cID:o.classId,sID:o.sectionId,page:s.page,per_page:s.perPage})},[s.page,s.perPage,L,o.classId,o.sectionId]),e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Promote Students"}),children:e.jsx(n.Form,{form:a,layout:"vertical",onFinish:z,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{name:"class_id",label:"Class",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:q=>q,children:e.jsx(Q,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:q=>{const H=q?.value??null;a.setFieldValue("section_id",null),l({classId:H,sectionId:null})}})}),e.jsx(n.Form.Item,{name:"section_id",label:"Section",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:q=>q,children:e.jsx(Q,{options:x,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Promote Students In Next Session"}),extra:e.jsx(Yt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs(n.Typography.Text,{children:["Selected: ",u.length]}),e.jsx(n.Typography.Text,{type:"secondary",children:"Select students → set Continue/Leave → Save"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{label:"Session",options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:B.find(q=>String(q.value)===String(d.sessionId))??null,onChange:q=>c(H=>({...H,sessionId:q?.value??null}))}),e.jsx(Q,{label:"Class",options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:R.find(q=>String(q.value)===String(d.classId))??null,onChange:q=>{const H=q?.value??null;c(re=>({...re,classId:H})),h(re=>!re)}}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"button",value:"Save",color:"primary",onClick:E})})]}),e.jsx(n.Table,{rowKey:q=>String(q.id),rowSelection:F,columns:M,dataSource:O,loading:P,pagination:{current:s.page,pageSize:s.perPage,total:$,showSizeChanger:!0,onChange:(q,H)=>{i({page:q,perPage:H}),p([]),b({}),j({})}}})]})})]})}function Zy({token:t}){return e.jsx(Xy,{token:t})}const ma=De.coscholastic,eg=({token:t})=>W(t?[ma.table,t]:null,([a,s])=>K(a,s),{revalidateOnFocus:!1}),tg=({token:t})=>W(t?[ma.categoryDropdown,t]:null,([a,s])=>K(a,s),{revalidateOnFocus:!1}),Ki=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]};function ag({token:t}){const[a,s]=r.useState(""),[i,o]=r.useState(null),[l,d]=r.useState(null),c=r.useRef(null),{data:g}=W(t?[De.master.classes.dropdown,t]:null,([_,T])=>K(_,T)),h=r.useMemo(()=>Ki(g),[g]),{data:u,isLoading:p,mutate:A}=eg({token:t}),w=r.useMemo(()=>{const _=u?.data?.data??u?.data??u??[];return Array.isArray(_)?_:Array.isArray(_?.data)?_.data:[]},[u]),{data:b,mutate:m}=tg({token:t}),j=r.useMemo(()=>Ki(b),[b]),D=r.useMemo(()=>(Array.isArray(j)?j:[]).map(_=>({value:_?.value??_?.id,label:_?.label??_?.title??""})),[j]),R=async()=>{const _=String(a??"").trim();if(!_){v.error("Please enter category title",{duration:1200});return}try{await Ee(ma.addCategory,{title:_},t),v.success("Success! Added category.",{duration:1e3}),s(""),m()}catch(T){v.error(T?.response?.data?.msg??T?.message??"Failed to add category",{duration:1500})}},k=async _=>{try{await qt(ma.deleteCategory,_,t),v.success("Success! Deleted category.",{duration:1e3}),m()}catch(T){v.error(T?.response?.data?.msg??T?.message??"Failed to delete category",{duration:1500})}},S=async _=>{if(_.preventDefault(),!i){v.error("Please select Category",{duration:1200});return}if(!l){v.error("Please select Class",{duration:1200});return}if(!_?.target?.skill?.value){v.error("Please enter Skill Name",{duration:1200});return}const I=new FormData(_.target);I.append("scholastic_catid",String(i)),I.append("class_id",String(l));try{await _t(ma.addSkill,I,t),v.success("Success! Added new item.",{duration:1e3}),_.target.reset(),d(null),A()}catch(B){v.error(B?.response?.data?.msg??B?.message??"Failed to add the new item.",{duration:1500})}},x=async _=>{try{await qt(ma.deleteSkill,_,t),v.success("Success! Deleted item.",{duration:1e3}),A()}catch(T){v.error(T?.response?.data?.msg??T?.message??"Failed to delete the item.",{duration:1500})}},f=r.useMemo(()=>[{title:"Skill Category",dataIndex:"title",key:"title"},{title:"Class",dataIndex:"class",key:"class"},{title:"Skill Name",dataIndex:"skill",key:"skill"},{title:"Action",key:"action",width:90,render:(_,T)=>e.jsx(n.Popconfirm,{title:"Delete this skill?",onConfirm:()=>x(T?.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Co Scholastic Area"}),children:e.jsx("form",{onSubmit:S,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Category"}),e.jsx(Q,{style:{width:"100%"},value:D.find(_=>String(_.value)===String(i))??null,placeholder:"Select Category",onChange:_=>o(_?.value??null),options:D}),e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center",marginTop:10},children:[e.jsx(Y,{placeholder:"New category",ref:c,value:a,onChange:_=>s(_.target.value)}),e.jsx(n.Button,{type:"text",icon:e.jsx(ee.PlusOutlined,{}),onClick:R}),e.jsx(n.Popconfirm,{title:"Delete selected category?",onConfirm:()=>{i&&(k(i),o(null))},children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{}),disabled:!i})})]})]}),e.jsx(Q,{label:"Class",options:h,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,value:h.find(_=>String(_.value)===String(l))??null,onChange:_=>d(_?.value??null)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:"Skill Name"}),e.jsx(Y,{name:"skill",placeholder:"Skill Name"})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Co Scholastic Area List"}),extra:e.jsx(Yt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(n.Table,{rowKey:_=>_.id,columns:f,dataSource:w,loading:p,pagination:!1})})]})}function ng({token:t}){return e.jsx(ag,{token:t})}const sg=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",ml=({token:t,value:a,onChange:s})=>{const i=r.useMemo(()=>{if(t)return{Authorization:t}},[t]);return e.jsx(n.Upload,{maxCount:1,action:yy(),headers:i,onChange:o=>{if(o?.file?.status==="done"){const l=sg(o?.file?.response);l&&s?.(l)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})})},Gi=De.notes,rg=({token:t,url:a})=>W(t&&a?[a,t]:null,([s,i])=>K(s,i),{revalidateOnFocus:!1}),Rn=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},ig=(t,a)=>{const s=String(t??""),i=String(a??"");return s?i?s.endsWith("/")&&i.startsWith("/")?`${s}${i.slice(1)}`:!s.endsWith("/")&&!i.startsWith("/")?`${s}/${i}`:`${s}${i}`:s:i};function og({token:t}){const[a]=n.Form.useForm(),[s]=n.Form.useForm(),[i,o]=r.useState({page:1,perPage:50}),[l,d]=r.useState({classId:null,sectionId:null}),[c,g]=r.useState(!1),[h,u]=r.useState(""),{data:p}=W(t?[De.master.classes.dropdown,t]:null,([F,q])=>K(F,q)),A=r.useMemo(()=>Rn(p),[p]),w=r.useMemo(()=>l.classId?`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(l.classId))}`:null,[l.classId]),{data:b}=W(t&&w?[w,t]:null,([F,q])=>K(F,q)),m=r.useMemo(()=>Rn(b),[b]),j=r.useMemo(()=>!l.classId||!l.sectionId?null:`${Gi.table}?class_id=${encodeURIComponent(String(l.classId))}§ion_id=${encodeURIComponent(String(l.sectionId))}&page=${encodeURIComponent(String(i.page))}&per_page=${encodeURIComponent(String(i.perPage))}`,[l.classId,l.sectionId,i.page,i.perPage]),{data:D,isLoading:R,mutate:k}=rg({token:t,url:j}),S=r.useMemo(()=>{const F=D?.data?.data??D?.data??D??[];return Array.isArray(F)?F:Array.isArray(F?.data)?F.data:[]},[D]),x=r.useMemo(()=>D?.pagination?.total_rows??D?.pagination?.total??S.length??0,[D,S.length]),[f,_]=r.useState(null),[T,I]=r.useState(null),[B,L]=r.useState(null),[y,P]=r.useState(!1),{data:O}=W(t&&B?[B,t]:null,([F,q])=>K(F,q),{revalidateOnFocus:!1}),$=r.useMemo(()=>Rn(O),[O]),{data:U}=W(t&&T?[T,t]:null,([F,q])=>K(F,q)),N=r.useMemo(()=>Rn(U),[U]),V=F=>{const q=F?.class_id?.value??null,H=F?.section_id?.value??null;!q||!H||(o(re=>({...re,page:1})),d({classId:q,sectionId:H}))},z=()=>{u(""),g(!0),_(null),I(null),L(null),P(F=>!F),s.resetFields()},E=async F=>{const q=F?.class_id?.value??null,H=F?.section_id?.value??null,re=F?.sub_id?.value??null,G=F?.status?.value??"publish",J=F?.title??"",ae=F?.remark??"";if(!q||!H||!re||!J||!ae||!h){v.error("Please fill all fields",{duration:1200});return}const oe=new FormData;oe.append("class_id",String(q)),oe.append("section_id",String(H)),oe.append("sub_id",String(re)),oe.append("title",String(J)),oe.append("remark",String(ae)),oe.append("status",String(G)),oe.append("file",String(h));try{await _t(Gi.add,oe,t),v.success("Success! Added new item.",{duration:1e3}),g(!1),k()}catch(pe){v.error(pe?.response?.data?.msg??pe?.message??"Failed to add the new item.",{duration:1500})}},M=r.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",align:"center"},{title:"Remarks",dataIndex:"remark",key:"remark",align:"center"},{title:"Subject",dataIndex:"subject",key:"subject",align:"center"},{title:"Staff Name",dataIndex:"teacher_name",key:"teacher_name",align:"center"},{title:"Status",key:"status",align:"center",render:(F,q)=>{const H=String(q?.status??"").toLowerCase();return e.jsx(n.Tag,{color:H==="publish"?"green":"red",children:q?.status??"-"})}},{title:"File",key:"file",align:"center",render:(F,q)=>{const H=q?.file;if(!H)return"-";const re=ig(He(),`/student/note/${H}`);return e.jsx("a",{href:re,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Date",dataIndex:"publish_date",key:"publish_date",align:"center"}],[]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:"Add Note",open:c,onCancel:()=>g(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsx(n.Form,{form:s,layout:"vertical",onFinish:E,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:F=>F,children:e.jsx(Q,{options:A,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:F=>{const q=F?.value??null;_(q),s.setFieldValue("section_id",null),s.setFieldValue("sub_id",null),L(q?`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(q))}`:null),I(q?`${De.master.subjects.dropdown}?class_id=${encodeURIComponent(String(q))}`:null),P(H=>!H)}},`class_${y}`)}),e.jsx(n.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:F=>F,children:e.jsx(Q,{options:$,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${y}_${f??"none"}`)}),e.jsx(n.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:F=>F,children:e.jsx(Q,{options:N,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${y}_${T??"none"}`)}),e.jsx(n.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(Y,{placeholder:"Title"})}),e.jsx(n.Form.Item,{label:"Remark",name:"remark",rules:[{required:!0,message:"Remark is required"}],children:e.jsx(Y,{placeholder:"Remark"})}),e.jsx(n.Form.Item,{label:"Status",name:"status",initialValue:{label:"Publish",value:"publish"},getValueFromEvent:F=>F,children:e.jsx(Q,{options:[{label:"Publish",value:"publish"},{label:"Unpublish",value:"unpublish"}],closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx(n.Form.Item,{label:"File",required:!0,children:e.jsx(ml,{token:t,value:h,onChange:u})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>g(!1),children:"Cancel"})]})]})})}),e.jsx(n.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Notes"}),e.jsx(Yt,{actions:["add","export","print","download","filter"],onAdd:z,onPrint:()=>window.print()})]}),children:e.jsx(n.Form,{form:a,layout:"vertical",onFinish:V,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:F=>F,children:e.jsx(Q,{options:A,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:F=>{const q=F?.value??null;a.setFieldValue("section_id",null),d({classId:q,sectionId:null})}})}),e.jsx(n.Form.Item,{label:"Section",name:"section_id",rules:[{required:!0,message:"Section is required"}],getValueFromEvent:F=>F,children:e.jsx(Q,{options:m,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Note List"}),children:e.jsx(n.Table,{rowKey:F=>F.id,columns:M,dataSource:S,loading:R,pagination:{current:i.page,pageSize:i.perPage,total:x,showSizeChanger:!0,onChange:(F,q)=>o({page:F,perPage:q})}})})]})}function lg({token:t}){return e.jsx(og,{token:t})}const dg=({token:t})=>W(t?[De.promoteStudents.sessionDropdown,t]:null,([a,s])=>K(a,s),{revalidateOnFocus:!1}),Ji=De.transferCertificate,Os=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},cg={width:"100%",height:40,background:"transparent",border:"none",borderBottom:"1px solid #d9d9d9",borderRadius:0,boxShadow:"none"},ug=(t,a)=>t.inputtype==="Select"?null:t.inputtype==="date"?te():"",Qi=t=>[{name:"ncc_details",inputtype:"text",label:"Ncc Details",required:!1},{name:"extra_curricular_activites",inputtype:"text",label:"Games played or extra-curricular activities in which the pupil usually took part",required:!1},{name:"generalConduct",inputtype:"text",label:"General conduct",required:!1},{name:"qualified_class",inputtype:"Select",label:"Qualified class",required:!1},{name:"application_date",inputtype:"date",label:"Date of application for certificate",required:!1},{name:"issue_date",inputtype:"date",label:"Date of issue of certificate",required:!1},{name:"reason_of_leaving",inputtype:"text",label:"Reason for leaving the school",required:!1},{name:"otherRemarks",inputtype:"text",label:"Any other remarks",required:!1},{name:"student_id",inputtype:"hidden",label:"",required:!1,value:t},{name:"qualified_for_promotion",inputtype:"radio",label:"Qualified for promotion",required:!1},{name:"failed",inputtype:"radio",label:"Failed",required:!1},{name:"nationality",inputtype:"text",label:"Nationality",required:!1},{name:"checked_by",inputtype:"text",label:"Checked By",required:!1},{name:"checked_by_designation",inputtype:"text",label:"Checked By Designation",required:!1}],Xi=t=>[{name:"change_of_school",inputtype:"text",label:"Change of School",required:!1},{name:"character_remark",inputtype:"text",label:"Character",required:!1},{name:"generalConduct",inputtype:"text",label:"General conduct",required:!1},{name:"application_date",inputtype:"date",label:"Date of application for certificate",required:!1},{name:"issue_date",inputtype:"date",label:"Date of issue of certificate",required:!1},{name:"last_attendance",inputtype:"date",label:"Last Class Attendence",required:!1},{name:"otherRemarks",inputtype:"text",label:"Any other remarks",required:!1},{name:"student_id",inputtype:"hidden",label:"",required:!1,value:t},{name:"qualified_for_promotion",inputtype:"radio",label:"Qualified for promotion",required:!1}];function pg({token:t,transferCertificateViewPath:a="/AcademicsDashboard/TransferCertificateView",onOpenTransferCertificateView:s}){const[i]=n.Form.useForm(),[o]=n.Form.useForm(),[l,d]=r.useState({page:1,perPage:10}),[c,g]=r.useState({classId:null,sectionId:null,sessionId:null}),[h,u]=r.useState(null),[p,A]=r.useState(!1),{data:w}=W(t?[De.master.classes.dropdown,t]:null,([M,F])=>K(M,F)),b=r.useMemo(()=>Os(w),[w]),{data:m}=W(t&&h?[h,t]:null,([M,F])=>K(M,F)),j=r.useMemo(()=>Os(m),[m]),{data:D}=dg({token:t}),R=r.useMemo(()=>Os(D),[D]),k=r.useMemo(()=>!c.classId||!c.sectionId||!c.sessionId?null:`${Ji.studentList}?class_id=${encodeURIComponent(String(c.classId))}§ion_id=${encodeURIComponent(String(c.sectionId))}&session_id=${encodeURIComponent(String(c.sessionId))}&page=${encodeURIComponent(String(l.page))}&per_page=${encodeURIComponent(String(l.perPage))}`,[c.classId,c.sectionId,c.sessionId,l.page,l.perPage]),{data:S,isLoading:x,mutate:f}=W(t&&k?[k,t]:null,([M,F])=>K(M,F),{revalidateOnFocus:!1,onSuccess:M=>{const F=M?.data?.data??M?.data??[];Array.isArray(F)&&F[0]?.transefer_certificate_id&&O(String(F[0].transefer_certificate_id))}}),_=r.useMemo(()=>{const M=S?.data?.data??S?.data??S??[];return Array.isArray(M)?M:Array.isArray(M?.data)?M.data:[]},[S]),T=r.useMemo(()=>S?.pagination?.total_rows??S?.pagination?.total??_.length??0,[S,_.length]),[I,B]=r.useState(!1),[L,y]=r.useState(null),[P,O]=r.useState("1"),$=M=>{y(M);const F=P==="1"?Qi(M):Xi(M),q={};F.forEach(H=>{q[H.name]=H.value??ug(H)}),o.setFieldsValue(q),B(!0)},U=async M=>{if(!M)return;if(typeof s=="function")return s(M);const F=`${a}?id=${encodeURIComponent(String(M))}`;window.location.href=F},N=M=>{const F=M?.class_id?.value??null,q=M?.section_id?.value??null,H=M?.session_id?.value??null;if(!F||!q||!H){v.error("Please select Class, Section and Session",{duration:1200});return}d(re=>({...re,page:1})),g({classId:F,sectionId:q,sessionId:H})},V=async M=>{const F=new FormData;Object.entries(M??{}).forEach(([q,H])=>{if(H!=null){if(te.isDayjs(H)){F.append(q,H.format("YYYY-MM-DD"));return}F.append(q,String(H))}});try{await _t(Ji.addData,F,t),v.success("Success! Added new item.",{duration:1e3}),B(!1),y(null),f()}catch(q){v.error(q?.response?.data?.msg??q?.message??"Failed to add the new item.",{duration:1500})}},z=r.useMemo(()=>P==="1"?Qi(L):Xi(L),[P,L]),E=r.useMemo(()=>[{title:"Admission no",dataIndex:"admission_no",key:"admission_no",align:"center"},{title:"Roll NO",dataIndex:"roll_no",key:"roll_no",align:"center"},{title:"Name",dataIndex:"full_name",key:"full_name",align:"center"},{title:"Class",dataIndex:"class",key:"class",align:"center"},{title:"Section",dataIndex:"section",key:"section",align:"center"},{title:"Guardian Name",dataIndex:"guardian_name",key:"guardian_name",align:"center"},{title:"Mobile No",dataIndex:"mobileno",key:"mobileno",align:"center"},{title:"Action",key:"action",align:"center",width:80,render:(M,F)=>e.jsx(n.Button,{type:"text",icon:F?.transfer_certificate_data==="not_present"?e.jsx(ee.EyeOutlined,{}):e.jsx(ee.CheckOutlined,{}),onClick:()=>{F?.transfer_certificate_data==="not_present"?$(F?.id):U(F?.id)}})}],[P]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:"Transfer Certificate",open:I,onCancel:()=>B(!1),footer:null,width:820,destroyOnClose:!0,children:e.jsxs(n.Form,{form:o,layout:"vertical",onFinish:V,children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:z.map(M=>M.inputtype==="hidden"?e.jsx(n.Form.Item,{name:M.name,initialValue:M.value??"",style:{display:"none"},children:e.jsx("input",{type:"hidden"})},M.name):M.inputtype==="date"?e.jsx(n.Form.Item,{label:M.label,name:M.name,children:e.jsx(n.DatePicker,{format:"YYYY-MM-DD",style:cg})},M.name):M.inputtype==="radio"?e.jsx(n.Form.Item,{label:M.label,name:M.name,children:e.jsx(n.Radio.Group,{options:[{label:"Yes",value:"Yes"},{label:"No",value:"No"}]})},M.name):M.inputtype==="Select"?e.jsx(n.Form.Item,{label:M.label,name:M.name,getValueFromEvent:F=>F,children:e.jsx(Q,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})},M.name):e.jsx(n.Form.Item,{label:M.label,name:M.name,children:e.jsx(Y,{placeholder:M.label})},M.name))}),e.jsxs(n.Space,{style:{width:"100%",justifyContent:"flex-end"},children:[e.jsx(ne,{type:"submit",value:"Submit",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>B(!1),children:"Cancel"})]})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Student History"}),children:e.jsx(n.Form,{form:i,layout:"vertical",onFinish:N,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:M=>M,children:e.jsx(Q,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:M=>{const F=M?.value??null;u(F?`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(F))}`:null),A(q=>!q),i.setFieldValue("section_id",null)}})}),e.jsx(n.Form.Item,{label:"Section",name:"section_id",getValueFromEvent:M=>M,children:e.jsx(Q,{options:j,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`section_${p}`)}),e.jsx(n.Form.Item,{label:"Session",name:"session_id",rules:[{required:!0,message:"Session is required"}],getValueFromEvent:M=>M,children:e.jsx(Q,{options:R,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Student List"}),extra:e.jsx(Yt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx(n.Table,{rowKey:M=>M.id,columns:E,dataSource:_,loading:x,pagination:{current:l.page,pageSize:l.perPage,total:T,showSizeChanger:!0,onChange:(M,F)=>d({page:M,perPage:F})}})})]})}function mg({token:t,transferCertificateViewPath:a,onOpenTransferCertificateView:s}){return e.jsx(pg,{token:t,transferCertificateViewPath:a,onOpenTransferCertificateView:s})}const hg=({token:t,url:a})=>W(t&&a?[a,t]:null,([s,i])=>K(s,i),{revalidateOnFocus:!1}),Ms=De.syllabus,Zi=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},fg=(t,a)=>{const s=String(t??""),i=String(a??"");return s?i?s.endsWith("/")&&i.startsWith("/")?`${s}${i.slice(1)}`:!s.endsWith("/")&&!i.startsWith("/")?`${s}/${i}`:`${s}${i}`:s:i};function yg({token:t}){const[a]=n.Form.useForm(),[s]=n.Form.useForm(),[i,o]=r.useState({page:1,perPage:50}),[l,d]=r.useState({classId:null}),[c,g]=r.useState(!1),[h,u]=r.useState(null),[p,A]=r.useState(""),{data:w}=W(t?[De.master.classes.dropdown,t]:null,([U,N])=>K(U,N)),b=r.useMemo(()=>Zi(w),[w]),m=r.useMemo(()=>l.classId?`${Ms.table}?class_id=${encodeURIComponent(String(l.classId))}&page=${encodeURIComponent(String(i.page))}&per_page=${encodeURIComponent(String(i.perPage))}`:null,[l.classId,i.page,i.perPage]),{data:j,isLoading:D,mutate:R}=hg({token:t,url:m}),k=r.useMemo(()=>{const U=j?.data?.data??j?.data??j??[];return Array.isArray(U)?U:Array.isArray(U?.data)?U.data:[]},[j]),S=r.useMemo(()=>j?.pagination?.total_rows??j?.pagination?.total??k.length??0,[j,k.length]),[x,f]=r.useState(null),[_,T]=r.useState(!1),{data:I}=W(t&&x?[x,t]:null,([U,N])=>K(U,N),{revalidateOnFocus:!1}),B=r.useMemo(()=>Zi(I),[I]),L=U=>{const N=U?.class_id?.value??null;N&&(o(V=>({...V,page:1})),d({classId:N}))},y=()=>{u(null),A(""),f(null),T(U=>!U),s.resetFields(),g(!0)},P=U=>{u(U),A(U?.attchement??"");const N=U?.class_id;f(N?`${De.master.subjects.dropdown}?class_id=${encodeURIComponent(String(N))}`:null),T(V=>!V),s.setFieldsValue({class_id:b.find(V=>String(V.value)===String(N))??null,sub_id:B.find(V=>String(V.value)===String(U?.sub_id??U?.subject_id))??(U?.sub_id||U?.subject_id?{label:U?.subject_title??"Subject",value:U?.sub_id??U?.subject_id}:null),title:U?.title??"",description:U?.description??""}),g(!0)},O=async U=>{const N=U?.class_id?.value??null,V=U?.sub_id?.value??null,z=U?.title??"",E=U?.description??"";if(!N||!V||!z||!E||!p){v.error("Please fill all fields",{duration:1200});return}const M=new FormData;M.append("class_id",String(N)),M.append("sub_id",String(V)),M.append("title",String(z)),M.append("description",String(E)),M.append("file",String(p));try{h?.id?(M.append("id",String(h.id)),await _t(Ms.edit,M,t),v.success("Success! Updated item.",{duration:1e3})):(await _t(Ms.add,M,t),v.success("Success! Added new item.",{duration:1e3})),g(!1),u(null),R()}catch(F){v.error(F?.response?.data?.msg??F?.message??"Failed to save",{duration:1500})}},$=r.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title",align:"center"},{title:"Description",dataIndex:"description",key:"description",align:"center"},{title:"Subject",dataIndex:"subject_title",key:"subject_title",align:"center"},{title:"File",key:"file",align:"center",render:(U,N)=>{const V=N?.attchement;if(!V)return"-";const z=fg(He(),`uploads/student/note/${V}`);return e.jsx("a",{href:z,target:"_blank",rel:"noreferrer",children:"View File"})}},{title:"Action",key:"action",width:80,align:"center",render:(U,N)=>e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>P(N)})}],[B,b]);return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Modal,{title:h?"Edit Syllabus":"Add Syllabus",open:c,onCancel:()=>{g(!1),u(null),A("")},footer:null,width:820,destroyOnClose:!0,children:e.jsx(n.Form,{form:s,layout:"vertical",onFinish:O,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:U=>U,children:e.jsx(Q,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1,onChange:U=>{const N=U?.value??null;s.setFieldValue("sub_id",null),f(N?`${De.master.subjects.dropdown}?class_id=${encodeURIComponent(String(N))}`:null),T(V=>!V)}},`class_${h?.id??"add"}_${_}`)}),e.jsx(n.Form.Item,{label:"Subject",name:"sub_id",rules:[{required:!0,message:"Subject is required"}],getValueFromEvent:U=>U,children:e.jsx(Q,{options:B,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1},`sub_${h?.id??"add"}_${_}_${x??"none"}`)}),e.jsx(n.Form.Item,{label:"Title",name:"title",rules:[{required:!0,message:"Title is required"}],children:e.jsx(Y,{placeholder:"Title"})}),e.jsx(n.Form.Item,{label:"Description",name:"description",rules:[{required:!0,message:"Description is required"}],children:e.jsx(st,{placeholder:"Description"})}),e.jsx(n.Form.Item,{label:"File",required:!0,children:e.jsx(ml,{token:t,value:p,onChange:A})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(ne,{type:"submit",value:"Save",color:"primary"}),e.jsx(n.Button,{type:"text",onClick:()=>g(!1),children:"Cancel"})]})]})})}),e.jsx(n.Card,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Syllabus"}),e.jsx(Yt,{actions:["add","export","print","download","filter"],onAdd:y,onPrint:()=>window.print()})]}),children:e.jsx(n.Form,{form:a,layout:"vertical",onFinish:L,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",name:"class_id",rules:[{required:!0,message:"Class is required"}],getValueFromEvent:U=>U,children:e.jsx(Q,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,allowSelectAll:!1})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Syllabus List"}),children:e.jsx(n.Table,{rowKey:U=>U.id,columns:$,dataSource:k,loading:D,pagination:{current:i.page,pageSize:i.perPage,total:S,showSizeChanger:!0,onChange:(U,N)=>o({page:U,perPage:N})}})})]})}function gg({token:t}){return e.jsx(yg,{token:t})}const ds=De.timetable,eo=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},to=t=>{if(!t)return"";const a=te(t,"HH:mm:ss");return a.isValid()?a.format("h:mm a"):String(t)},xg=t=>{const a=String(t).trim().toLowerCase();if(!a)return"default";let s=0;for(let o=0;o<a.length;o+=1)s=(s*31+a.charCodeAt(o))%1e5;const i=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return i[s%i.length]},ao=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],bg=t=>{const a=String(t||"");return a?a.charAt(0).toUpperCase()+a.slice(1):"-"};function jg({token:t}){const[a,s]=r.useState(null),[i,o]=r.useState(!1),[l,d]=r.useState(null),[c,g]=r.useState(""),[h,u]=r.useState(""),{data:p}=W(t?[De.master.classes.dropdown,t]:null,([f,_])=>K(f,_)),A=r.useMemo(()=>eo(p),[p]),{data:w}=W(t&&a?[a,t]:null,([f,_])=>K(f,_)),b=r.useMemo(()=>eo(w),[w]),{data:m,isLoading:j}=W(t&&l?[l,t]:null,([f,_])=>K(f,_),{revalidateOnFocus:!1}),D=r.useMemo(()=>m?.days??m?.data?.days??m?.data?.data?.days??{},[m]),{dataSource:R,daySpanByFirstKey:k}=r.useMemo(()=>{const f=Object.entries(D||{}).slice().sort((I,B)=>ao.indexOf(String(I[0]).toLowerCase())-ao.indexOf(String(B[0]).toLowerCase())),_=new Map,T=[];for(const[I,B]of f){const L=(Array.isArray(B)?B:[]).slice().sort((P,O)=>Number(P?.order_no||0)-Number(O?.order_no||0)),y=L.length;for(let P=0;P<y;P+=1){const O=L[P],$=O?.id||`${I}-${O?.order_no}-${P}`;P===0&&_.set($,y),T.push({key:$,_dayKey:I,...O})}}return{dataSource:T,daySpanByFirstKey:_}},[D]),S=r.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(f,_)=>{const T=k.get(_.key);return T===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(ee.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(n.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:bg(f)})]}),props:{rowSpan:T}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:f=>e.jsx(n.Tag,{color:"#5080f8",style:{fontWeight:500},children:f})},{title:"Time",key:"time",width:180,render:(f,_)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(ee.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(n.Typography.Text,{children:[to(_?.time_from)," - ",to(_?.time_to)]})]})},{title:"Subject",key:"subject",render:(f,_)=>{if(String(_?.is_break)==="1")return e.jsx(n.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const I=_?.subject_name||"-";return e.jsx(n.Tag,{color:xg(I),style:{fontWeight:500},children:I})}},{title:"Teacher",key:"teacher",render:(f,_)=>{const T=String(_?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(ee.UserOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(n.Typography.Text,{children:T?"-":_?.teacher_full_name||"-"})]})}},{title:"Room",key:"room_no",width:120,render:(f,_)=>{const T=String(_?.is_break)==="1";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(ee.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(n.Typography.Text,{children:T?"-":_?.room_no||"-"})]})}}],[k]),x=f=>{f.preventDefault();const _=f.target.class_id?.value,T=f.target.section_id?.value;if(!_||!T)return;const I=A.find(P=>String(P.value)===String(_)),B=b.find(P=>String(P.value)===String(T));g(I?.label||""),u(B?.label||"");const y=`${ds.byClassSection}/${_}/section/${T}`;d(y)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Class / Section Wise Timetable"}),extra:e.jsx(Yt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx("form",{onSubmit:x,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:A,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Class",name:"class_id",allowSelectAll:!1,required:!0,onChange:f=>{s(`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(f?.value??""))}`),o(_=>!_)}}),e.jsx(Q,{options:b,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Section",name:"section_id",allowSelectAll:!1,required:!0},`section_${i}`),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:c||h?`Timetable: ${c} ${h}`:"Timetable"}),children:e.jsx(n.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:R,columns:S,rowKey:"key",loading:j,scroll:{x:"max-content"}})})]})}const Sg=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},no=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],wg=t=>{const a=String(t||"");return a?a.charAt(0).toUpperCase()+a.slice(1):"-"},so=t=>{if(!t)return"";const a=te(t,"HH:mm:ss");return a.isValid()?a.format("h:mm a"):String(t)},vg=t=>{const a=String(t).trim().toLowerCase();if(!a)return"default";let s=0;for(let o=0;o<a.length;o+=1)s=(s*31+a.charCodeAt(o))%1e5;const i=["magenta","red","volcano","orange","gold","lime","green","cyan","blue","geekblue","purple"];return i[s%i.length]};function _g({token:t}){const[a,s]=r.useState(null),[i,o]=r.useState(null),{data:l}=W(t?[De.assignByClass.teacherDropdown,t]:null,([w,b])=>K(w,b)),d=r.useMemo(()=>Sg(l),[l]),{data:c,isLoading:g}=W(t&&i?[i,t]:null,([w,b])=>K(w,b),{revalidateOnFocus:!1}),{dataSource:h,daySpanByFirstKey:u}=r.useMemo(()=>{const b=(Array.isArray(c?.data)&&c.data||Array.isArray(c?.data?.data)&&c.data.data||[]).slice().sort((R,k)=>{const S=no.indexOf(String(R?.day_name||"").toLowerCase()),x=no.indexOf(String(k?.day_name||"").toLowerCase());if(S!==x)return S-x;const f=Number(R?.order_no||0),_=Number(k?.order_no||0);return f!==_?f-_:String(R?.time_from||"").localeCompare(String(k?.time_from||""))}),m=new Map,j=[];let D=0;for(;D<b.length;){const R=String(b[D]?.day_name||"").toLowerCase();let k=D;for(;k<b.length&&String(b[k]?.day_name||"").toLowerCase()===R;)k+=1;const S=k-D;for(let x=D;x<k;x+=1){const f=b[x],_=f?.id||`${R}-${f?.order_no}-${x}`;x===D&&m.set(_,S),j.push({key:_,_dayKey:R,...f})}D=k}return{dataSource:j,daySpanByFirstKey:m}},[c]),p=r.useMemo(()=>[{title:"Day",dataIndex:"_dayKey",key:"_dayKey",width:140,render:(w,b)=>{const m=u.get(b.key);return m===void 0?{children:null,props:{rowSpan:0}}:{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(ee.CalendarOutlined,{style:{color:"#5080f8"}}),e.jsx(n.Tag,{color:"geekblue",style:{margin:0,fontWeight:500},children:wg(w)})]}),props:{rowSpan:m}}}},{title:"Period",dataIndex:"order_no",key:"order_no",width:90,render:w=>e.jsx(n.Tag,{color:"#5080f8",style:{fontWeight:500},children:w})},{title:"Time",key:"time",width:180,render:(w,b)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(ee.ClockCircleOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsxs(n.Typography.Text,{children:[so(b?.time_from)," - ",so(b?.time_to)]})]})},{title:"Subject",key:"subject",render:(w,b)=>{if(String(b?.is_break)==="1")return e.jsx(n.Tag,{color:"orange",style:{fontWeight:500},children:"Tiffin Break"});const j=b?.subject_name||"-";return e.jsx(n.Tag,{color:vg(j),style:{fontWeight:500},children:j})}},{title:"Class",key:"class",width:160,render:(w,b)=>e.jsxs(n.Tag,{color:"purple",style:{fontWeight:500},children:[b?.class_name||b?.class_id||"-"," ",b?.section_name?`(${b.section_name})`:""]})},{title:"Room",key:"room_no",width:120,render:(w,b)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(ee.HomeOutlined,{style:{color:"#5080f8",fontSize:14}}),e.jsx(n.Typography.Text,{children:b?.room_no||"-"})]})}],[u]),A=w=>{w.preventDefault();const b=w.target.teacher_id?.value;if(!b)return;s(b);const j=`${ds.teacherTimetable}${encodeURIComponent(String(b))}`;o(j)};return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Teacher Wise Timetable"}),extra:e.jsx(Yt,{actions:["export","print"],onExport:()=>{},onPrint:()=>window.print()}),children:e.jsx("form",{onSubmit:A,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(Q,{options:d,closeMenuOnSelect:!0,hideSelectedOptions:!1,label:"Teacher",name:"teacher_id",allowSelectAll:!1,required:!0}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Search",color:"primary"})})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Timetable"}),children:e.jsx(n.Table,{size:"middle",bordered:!1,pagination:!1,dataSource:h,columns:p,rowKey:"key",loading:g,scroll:{x:"max-content"}})})]})}function ro(t){if(!t)return null;const a=String(t).trim().replaceAll(".",":");if(!a)return null;const s=a.toLowerCase(),i=s.includes("am")||s.includes("pm");let o=0,l=0,d=0;if(i){const g=s.replace(/\s+/g," ").match(/^(\d{1,2})\s*:\s*(\d{1,2})(?:\s*:\s*(\d{1,2}))?\s*(am|pm)$/i);if(!g)return null;o=Number.parseInt(g[1],10),l=Number.parseInt(g[2],10),d=Number.parseInt(g[3]||"0",10);const h=g[4].toLowerCase();h==="pm"&&o<12&&(o+=12),h==="am"&&o===12&&(o=0)}else{const c=a.split(":").map(g=>g.trim());if(c.length<2)return null;o=Number.parseInt(c[0],10),l=Number.parseInt(c[1],10),d=Number.parseInt(c[2]||"0",10)}return![o,l,d].every(c=>Number.isFinite(c))||o<0||o>23||l<0||l>59||d<0||d>59?null:te().hour(o).minute(l).second(d).millisecond(0)}function Ua(t,a){const s=Number.parseInt(a,10);return!Number.isFinite(s)||s<=0||!t||!t.isValid?.()?null:t.add(s,"minute")}const Vn=t=>{if(Array.isArray(t))return t;if(t&&typeof t=="object"){if(typeof t?.Status=="string"){if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}if(Array.isArray(t?.data))return t.data;if(Array.isArray(t?.data?.data))return t.data.data}return[]},qa={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"},Cg=t=>{const a=qa[String(t)];return a?a.charAt(0).toUpperCase()+a.slice(1):String(t)},Ag=({token:t,classId:a,sectionId:s,subjectId:i,value:o,onChange:l,disabled:d})=>{const c=t&&a&&s&&i?`${ds.teachersBySubject}?subject_id=${encodeURIComponent(String(i))}&class_id=${encodeURIComponent(String(a))}§ion_id=${encodeURIComponent(String(s))}`:null,{data:g,isLoading:h}=W(c?[c,t]:null,([p,A])=>K(p,A),{revalidateOnFocus:!1}),u=r.useMemo(()=>Vn(g?.data??g).map(A=>({value:A?.value??A?.id,label:A?.label??A?.name??A?.teacher_name??""})),[g]);return e.jsx(n.Select,{placeholder:d?"-":"Select Teacher",loading:h,disabled:d,style:{width:"100%"},options:u,value:o?String(o):void 0,onChange:p=>l?.(p),showSearch:!0,optionFilterProp:"label"})};function Dg({token:t}){const[a]=n.Form.useForm(),[s,i]=r.useState({classId:null,sectionId:null,dayKey:"1",daysEnabled:{0:!1,1:!0,2:!0,3:!0,4:!0,5:!0,6:!0}}),[o,l]=r.useState({startTime:null,endTime:null,duration:40,interval:0,roomNo:"",tiffinEnabled:!1,tiffinAfterPeriod:3,tiffinDuration:20}),[d,c]=r.useState({0:[],1:[],2:[],3:[],4:[],5:[],6:[]}),[g,h]=r.useState(!1),u=r.useMemo(()=>t?De.master.classes.dropdown:null,[t]),{data:p}=W(u?[u,t]:null,([y,P])=>K(y,P)),A=r.useMemo(()=>Vn(p).map(y=>({value:y?.value??y?.id,label:y?.label??y?.title??""})),[p]),w=r.useMemo(()=>!t||!s.classId?null:`${De.master.sections.byClass}?class_id=${encodeURIComponent(String(s.classId))}`,[s.classId,t]),{data:b}=W(w?[w,t]:null,([y,P])=>K(y,P)),m=r.useMemo(()=>Vn(b).map(y=>({value:y?.value??y?.id,label:y?.label??y?.title??""})),[b]),j=r.useMemo(()=>!t||!s.classId?null:`${De.master.subjects.byClassLabelValue}?class_id=${encodeURIComponent(String(s.classId))}`,[s.classId,t]),{data:D}=W(j?[j,t]:null,([y,P])=>K(y,P)),R=r.useMemo(()=>Vn(D).map(y=>({value:y?.value??y?.id,label:y?.label??y?.title??""})),[D]),k=r.useMemo(()=>Array.isArray(d?.[s.dayKey])?d[s.dayKey]:[],[s.dayKey,d]),S=r.useCallback((y,P,O)=>{c($=>{const U={...$},N=Array.isArray(U[y])?U[y].slice():[];return N[P]={...N[P]??{},...O},U[y]=N,U})},[]),x=r.useCallback((y,P)=>{c(O=>{const $={...O},U=Array.isArray($[y])?$[y].slice():[];return U.splice(P,1),$[y]=U.map((N,V)=>({...N,order_no:V+1})),$})},[]),f=r.useCallback(y=>{c(P=>{const O={...P},$=Array.isArray(O[y])?O[y].slice():[];let U=null,N=null;const V=$[$.length-1];if(V?.time_to){const z=ro(V.time_to),E=Number.parseInt(o.interval,10)||0,M=Number.parseInt(o.duration,10)||0,F=Ua(z,E),q=M>0?Ua(F,M):null;U=F?.isValid?.()?F.format("HH:mm:ss"):null,N=q?.isValid?.()?q.format("HH:mm:ss"):null}return $.push({order_no:$.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:U,time_to:N,is_break:!1}),O[y]=$,O})},[o.duration,o.interval,o.roomNo]),_=r.useCallback(()=>{const y=o.startTime,P=o.endTime,O=Number.parseInt(o.duration,10),$=Number.parseInt(o.interval,10);if(!y||!y.isValid?.()){v.error("Start time is required",{duration:1500});return}if(!P||!P.isValid?.()){v.error("End time is required",{duration:1500});return}if(!P.isAfter(y)){v.error("End time must be after start time",{duration:1500});return}if(!Number.isFinite(O)||O<=0){v.error("Duration must be a positive number",{duration:1500});return}if(!Number.isFinite($)||$<0){v.error("Interval must be 0 or more",{duration:1500});return}const U=()=>{const N=[];let V=y;for(let z=0;z<50;z+=1){const E=Ua(V,O);if(!E||!E.isValid?.()||E.isAfter(P))break;N.push({order_no:N.length+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:V.format("HH:mm:ss"),time_to:E.format("HH:mm:ss"),is_break:!1});const M=Ua(E,$);if(!M||!M.isValid?.()||M.isAfter(P)||M.isSame(P))break;V=M}if(o.tiffinEnabled){const z=Math.max(0,Number.parseInt(o.tiffinAfterPeriod,10)||0),E=Math.max(0,Number.parseInt(o.tiffinDuration,10)||0),M=Math.min(z,N.length);if(M>0&&E>0){const F=N[M-1],q=F?.time_to?ro(F.time_to):null,H=q?Ua(q,E):null;q?.isValid?.()&&H?.isValid?.()&&!H.isAfter(P)&&N.splice(M,0,{order_no:M+1,subject_id:"",teacher_id:"",room_no:o.roomNo??"",time_from:q.format("HH:mm:ss"),time_to:H.format("HH:mm:ss"),is_break:!0})}}return N.map((z,E)=>({...z,order_no:E+1}))};c(N=>{const V={...N};return Object.keys(qa).forEach(z=>{s.daysEnabled?.[z]&&(V[z]=U())}),V}),v.success("Generated schedule",{duration:1e3})},[o,s.daysEnabled]),T=r.useCallback(()=>{const y=localStorage.getItem("genrall_settings"),O=(y?JSON.parse(y):{})?.session_id??"1",$=s.classId,U=s.sectionId,N=Object.keys(qa).map(V=>{const z=(Array.isArray(d?.[V])?d[V]:[]).map((E,M)=>({order_no:M+1,subject_id:E?.is_break?0:E?.subject_id??null,teacher_id:E?.is_break?0:E?.teacher_id??null,room_no:E?.room_no??"",time_from:E?.time_from??null,time_to:E?.time_to??null,is_break:E?.is_break?1:0}));return{day:qa[V],class_id:$,section_id:U,session_id:O,args:z}});return{class_id:$,section_id:U,session_id:O,days:N}},[s.classId,s.sectionId,d]),I=r.useCallback(async()=>{if(!s.classId||!s.sectionId){v.error("Please select Class and Section",{duration:1500});return}const y=T(),P=Array.isArray(y?.days)?y.days:[];if(!P.some(U=>Array.isArray(U?.args)&&U.args.length>0)){v.error("No timetable rows to submit",{duration:1500});return}const $=U=>{const N=U?.is_break;return N===1||N==="1"||N===!0?!0:String(N??"").toLowerCase()==="true"};P.some(U=>(Array.isArray(U?.args)?U.args:[]).some(N=>String(N?.time_from??"").trim()&&String(N?.time_to??"").trim()?$(N)?!1:!String(N?.subject_id??"").trim()||!String(N?.teacher_id??"").trim():!0)),h(!0);try{const U=ds.save,N=U==="api/timetable/save"?"timetable/save":null,V=async M=>{const F=await as(M,y,t);if(F&&typeof F=="object")return F;throw new Error("No response from server")};let z;try{z=await V(U)}catch{z=await V(N)}const E=String(z?.msg??"");if(String(z?.Status)==="Success"){if(Array.isArray(z?.data)&&z.data.length===0&&E){v.error(E,{duration:3e3});return}v.success(E||"Weekly Time Table added successfully!",{duration:1200});return}v.error(E||"Failed to add time table",{duration:3e3})}catch(U){v.error(U?.response?.data?.msg??U?.message??"Failed to add time table",{duration:3e3})}finally{h(!1)}},[T,s.classId,s.sectionId,t]),B=r.useMemo(()=>[{title:"Period",dataIndex:"order_no",key:"order_no",width:80},{title:"Time From",dataIndex:"time_from",key:"time_from",width:120,render:y=>y?te(y,"HH:mm:ss").format("h:mm a"):"-"},{title:"Time To",dataIndex:"time_to",key:"time_to",width:120,render:y=>y?te(y,"HH:mm:ss").format("h:mm a"):"-"},{title:"Break",dataIndex:"is_break",key:"is_break",width:90,render:(y,P,O)=>e.jsx(n.Switch,{checked:!!P?.is_break,onChange:$=>{S(s.dayKey,O,{is_break:$,subject_id:$?"":P?.subject_id??"",teacher_id:$?"":P?.teacher_id??""})}})},{title:"Subject",dataIndex:"subject_id",key:"subject_id",width:220,render:(y,P,O)=>e.jsx(n.Select,{placeholder:P?.is_break?"-":"Select Subject",disabled:!!P?.is_break,style:{width:"100%"},options:R,value:P?.subject_id?String(P.subject_id):void 0,onChange:$=>S(s.dayKey,O,{subject_id:$,teacher_id:""}),showSearch:!0,optionFilterProp:"label"})},{title:"Teacher",dataIndex:"teacher_id",key:"teacher_id",width:240,render:(y,P,O)=>e.jsx(Ag,{token:t,classId:s.classId,sectionId:s.sectionId,subjectId:P?.subject_id,disabled:!!P?.is_break||!P?.subject_id,value:P?.teacher_id,onChange:$=>S(s.dayKey,O,{teacher_id:$})})},{title:"Room",dataIndex:"room_no",key:"room_no",width:140,render:(y,P,O)=>e.jsx(n.Input,{value:P?.room_no??"",onChange:$=>S(s.dayKey,O,{room_no:$.target.value})})},{title:"Action",key:"action",width:90,render:(y,P,O)=>e.jsx(n.Popconfirm,{title:"Delete this row?",onConfirm:()=>x(s.dayKey,O),children:e.jsx(n.Button,{danger:!0,type:"text",children:"Delete"})})}],[s.classId,s.dayKey,s.sectionId,x,R,t,S]),L=e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Create Time Table"}),children:e.jsx(n.Form,{form:a,layout:"vertical",initialValues:{duration:o.duration,interval:o.interval,roomNo:o.roomNo,tiffinEnabled:o.tiffinEnabled,tiffinAfterPeriod:o.tiffinAfterPeriod,tiffinDuration:o.tiffinDuration},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},children:[e.jsx(n.Form.Item,{label:"Class",required:!0,children:e.jsx(n.Select,{placeholder:"Select Class",options:A,value:s.classId?String(s.classId):void 0,onChange:y=>{i(P=>({...P,classId:y,sectionId:null})),c({0:[],1:[],2:[],3:[],4:[],5:[],6:[]})},showSearch:!0,optionFilterProp:"label"})}),e.jsx(n.Form.Item,{label:"Section",required:!0,children:e.jsx(n.Select,{placeholder:"Select Section",options:m,value:s.sectionId?String(s.sectionId):void 0,onChange:y=>i(P=>({...P,sectionId:y})),disabled:!s.classId,showSearch:!0,optionFilterProp:"label"})}),e.jsx(n.Form.Item,{label:"Start Time",required:!0,children:e.jsx(n.TimePicker,{value:o.startTime,onChange:y=>l(P=>({...P,startTime:y})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"End Time",required:!0,children:e.jsx(n.TimePicker,{value:o.endTime,onChange:y=>l(P=>({...P,endTime:y})),use12Hours:!0,format:"h:mm a",style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"Duration (min)",required:!0,children:e.jsx(n.InputNumber,{min:1,value:o.duration,onChange:y=>l(P=>({...P,duration:y})),style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"Interval (min)",children:e.jsx(n.InputNumber,{min:0,value:o.interval,onChange:y=>l(P=>({...P,interval:y})),style:{width:"100%"}})}),e.jsx(n.Form.Item,{label:"Room No",children:e.jsx(n.Input,{value:o.roomNo,onChange:y=>l(P=>({...P,roomNo:y.target.value}))})}),e.jsx(n.Form.Item,{label:"Tiffin Break",children:e.jsxs(n.Space,{children:[e.jsx(n.Switch,{checked:o.tiffinEnabled,onChange:y=>l(P=>({...P,tiffinEnabled:y}))}),e.jsx(n.Typography.Text,{type:"secondary",children:o.tiffinEnabled?"Enabled":"Disabled"})]})}),e.jsx(n.Form.Item,{label:"After Period",tooltip:"Insert break row after this period",style:{marginBottom:0},children:e.jsx(n.InputNumber,{min:1,value:o.tiffinAfterPeriod,onChange:y=>l(P=>({...P,tiffinAfterPeriod:y})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsx(n.Form.Item,{label:"Break Duration (min)",style:{marginBottom:0},children:e.jsx(n.InputNumber,{min:1,value:o.tiffinDuration,onChange:y=>l(P=>({...P,tiffinDuration:y})),style:{width:"100%"},disabled:!o.tiffinEnabled})}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(n.Button,{onClick:_,children:"Generate"}),e.jsx(n.Button,{type:"primary",loading:g,onClick:I,children:"Save"})]})]})})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Edit Week"}),extra:e.jsxs(n.Space,{children:[e.jsx(n.Typography.Text,{type:"secondary",children:"Day"}),e.jsx(n.Select,{style:{width:160},value:s.dayKey,onChange:y=>i(P=>({...P,dayKey:y})),options:Object.keys(qa).map(y=>({value:String(y),label:Cg(y)}))}),e.jsx(n.Button,{onClick:()=>f(s.dayKey),children:"Add Row"})]}),children:e.jsx(n.Table,{rowKey:(y,P)=>`${s.dayKey}_${P}`,columns:B,dataSource:k,pagination:!1,size:"middle",scroll:{x:"max-content"}})})]});return e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(n.Typography.Title,{level:4,style:{margin:0},children:"Time Table"}),e.jsx(n.Tabs,{type:"card",items:[{key:"create",label:"Create",children:L},{key:"routine",label:"Routine",children:e.jsx(jg,{token:t})},{key:"teacher",label:"Teacher Wise",children:e.jsx(_g,{token:t})}]})]})}function Tg({token:t}){return e.jsx(Dg,{token:t})}function Rg(){return null}const Xt=t=>t??localStorage.getItem("authToken")??"",cr=(t,a)=>{const s=String(t??""),i=String(a??"");return s?i?s.endsWith("/")&&i.startsWith("/")?`${s}${i.slice(1)}`:!s.endsWith("/")&&!i.startsWith("/")?`${s}/${i}`:`${s}${i}`:s:i},yt={organization:{get:"api/branchapi/generalSettings/getorganizationsettingsData",save:"api/branchapi/generalSettings/addorganizationSetting",currencyDropdown:"api/branchapi/generalSettings/currencyDropdown",countryCodeDropdown:"api/branchapi/generalSettings/contrycodeDropdown",timezoneDropdown:"api/branchapi/generalSettings/timezoneDropdown",boardsDropdown:"api/branchapi/generalSettings/getAffliatedBoardsDropDown",uploadLogo:"api/superAdmin/upload_logo",uploadSignature:"api/branchapi/generalSettings/upload_signature",uploadFirebaseJson:"api/branchapi/generalSettings/firebaseJsonUpload"},academicYear:{table:"api/branchapi/generalSettings/sessiontable",add:"api/branchapi/generalSettings/addsession",setActive:"api/branchapi/generalSettings/setsession",remove:"api/branchapi/generalSettings/deletesession"},feeReceiptSetting:{get:"api/branchapi/generalSettings/feesReceiptSettingData",save:"api/branchapi/generalSettings/feesReceiptSetting"},marksheetSetting:{templateTypes:"api/branchapi/GeneralSettings/getmarkssheetTemplate",classDropdown:"api/exam/exam/getClassforAssignMarksSheetType",assignedTable:"api/branchapi/GeneralSettings/getassign_templete",assign:"api/branchapi/GeneralSettings/assign_templete",remove:"api/branchapi/GeneralSettings/deleteTemplate"},legalPages:{get:"api/branchapi/generalSettings/getlegalpage",termsSave:"api/branchapi/generalSettings/terms",privacySave:"api/branchapi/generalSettings/privacy",aboutSave:"api/branchapi/generalSettings/about_us"},feesInfo:{get:"api/branchapi/generalSettings/getFeesInfo",save:"api/branchapi/generalSettings/addFeesInfo",statesDropdown:"api/superAdmin/states"},payrollSettings:{table:"api/branchapi/GeneralSettings/getsetting_allowances_dedection",add:"api/branchapi/GeneralSettings/addsetting_allowances_dedection",edit:"api/branchapi/GeneralSettings/updatesetting_allowances_dedection",remove:"api/branchapi/GeneralSettings/deletesetting_allowances_dedection",byId:"api/branchapi/GeneralSettings/getsetting_allowances_dedectionById"},paymentGateway:{get:"api/payment_gateway/PaymentProcess/getPaymentGatewayList",save:"api/payment_gateway/PaymentProcess"}},ur=t=>cr(He(),t),Ig=()=>cr(He(),"uploads"),hl=t=>cr(Ig(),t),kg=async({baseUrl:t,page:a=1,perPage:s=10},i)=>{const o=t.includes("?")?"&":"?",l=`${t}${o}page=${encodeURIComponent(String(a))}&per_page=${encodeURIComponent(String(s))}`;return K(l,Xt(i))},Pg=async(t,a)=>K(t,Xt(a)),rn=async(t,a,s)=>Ee(t,a,Xt(s)),fl=async(t,a,s)=>Be(t,a,Xt(s)),pr=async(t,a,s)=>qe(t,a,Xt(s)),Og=async(t,a,s)=>as(t,{arg:a},Xt(s)),yl=async(t,a,s)=>za(t,{arg:a},Xt(s)),gl=({baseUrl:t,page:a=1,perPage:s=10,token:i})=>W(i&&t?[t,a,s,i]:null,([l,d,c,g])=>kg({baseUrl:l,page:d,perPage:c},g)),gt=({url:t,token:a})=>W(a&&t?[t,a]:null,([i,o])=>Pg(i,o)),Mg={border:"1px solid #d9d9d9",borderRadius:8,padding:12,minHeight:320,background:"#fff"};function Eg({value:t,onChange:a,placeholder:s}){const[i,o]=r.useState(t??""),l=r.useMemo(()=>typeof t=="string"?t:i,[i,t]);return e.jsx("div",{style:Mg,children:e.jsx(Ko,{html:l||"",onChange:d=>{const c=d?.target?.value??"";o(c),a?.(c)},style:{outline:"none",minHeight:280},placeholder:s})})}function Vt({title:t,actions:a,children:s,headerExtra:i}){return e.jsx("div",{style:{display:"grid",gap:20},children:s})}const Fg=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null;function mr({token:t,title:a,fetchUrl:s,saveUrl:i,fieldName:o,initialHtmlFieldName:l}){const d=r.useRef(null),c=gt({url:s,token:t}),h=r.useMemo(()=>Fg(c.data),[c.data])?.[l??o]??"",[u,p]=r.useState("");r.useEffect(()=>{p(typeof h=="string"?h:"")},[h]);const A=()=>p(typeof h=="string"?h:""),w=()=>{const j=new Blob([String(u??"")],{type:"text/html"}),D=URL.createObjectURL(j),R=document.createElement("a");R.href=D,R.download=`${String(a??"legal").toLowerCase().replaceAll(" ","-")}.html`,R.click(),URL.revokeObjectURL(D)},b=r.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(ee.SyncOutlined,{}),onClick:()=>d.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:A},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:w,disabled:!u}],[u,h]),m=async j=>{j.preventDefault();try{(await yl(i,{[o]:u??""},t))?.Status==="Success"?v.success("Updated successfully.",{duration:1e3}):v.success("Updated.",{duration:1e3}),c.mutate?.()}catch(D){v.error(D?.response?.data?.msg??D?.message??"Failed to update.",{duration:1500})}};return c.isLoading&&!c.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:a,actions:b,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Editor"}),children:e.jsxs("form",{ref:d,onSubmit:m,children:[e.jsx(Eg,{value:u,onChange:p,placeholder:`Enter ${a} content...`}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Update"})})]})})})]})}const Ug=t=>t?typeof t=="string"?t:typeof t?.data=="string"?t.data:typeof t?.filename=="string"?t.filename:typeof t?.file=="string"?t.file:"":"",$g=t=>/^https?:\/\//i.test(String(t??""))||String(t??"").startsWith("data:");function ha({token:t,value:a,onChange:s,action:i,accept:o,maxCount:l=1,previewUrl:d}){const c=r.useMemo(()=>{if(t)return{Authorization:t}},[t]),g=r.useMemo(()=>a?d||($g(a)?a:""):"",[d,a]);return e.jsxs("div",{style:{display:"grid",gap:8},children:[g?e.jsx("img",{src:g,alt:"upload-preview",style:{width:88,height:88,objectFit:"cover",borderRadius:8,border:"1px solid #d9d9d9",background:"#fafafa"}}):null,e.jsx(n.Upload,{maxCount:l,action:i,accept:o,headers:c,onChange:h=>{if(h?.file?.status==="removed"&&s?.(""),h?.file?.status==="done"){const u=Ug(h?.file?.response);u&&s?.(u)}},children:e.jsx("div",{style:{cursor:"pointer",fontSize:12,color:"#1677ff"},children:a?"Change":"Upload"})})]})}const Mt=yt.organization,xl=()=>ur(Mt.uploadLogo),Es=()=>ur(Mt.uploadSignature),Ng=()=>ur(Mt.uploadFirebaseJson),Lg=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[]:[],Bg=({token:t})=>gt({url:Mt.get,token:t}),qg=({token:t})=>gt({url:Mt.currencyDropdown,token:t}),zg=({token:t})=>gt({url:Mt.countryCodeDropdown,token:t}),Yg=({token:t})=>gt({url:Mt.timezoneDropdown,token:t}),Vg=({token:t})=>gt({url:Mt.boardsDropdown,token:t}),In=t=>Lg(t?.data),io={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},Wg=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"].map(t=>({value:t,label:t})),oo=[{value:"Yes",label:"Yes"},{value:"No",label:"No"}],lo=[{value:"yes",label:"Yes"},{value:"no",label:"No"}],Hg=t=>{const a=t?.data;return Array.isArray(a?.data)?a.data[0]??null:Array.isArray(a)?a[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null},Kg=t=>t?.data?.inout_setting?.[0]??t?.inout_setting?.[0]??null,Gg=t=>t?.data?.notification_settings?.[0]??t?.notification_settings?.[0]??null;function Jg({token:t}){const a=r.useRef(null),s=Bg({token:t}),i=qg({token:t}),o=zg({token:t}),l=Yg({token:t}),d=Vg({token:t}),c=r.useMemo(()=>Hg(s.data),[s.data]),g=r.useMemo(()=>Kg(s.data),[s.data]),h=r.useMemo(()=>Gg(s.data),[s.data]),u=r.useMemo(()=>In(i),[i.data]),p=r.useMemo(()=>In(o),[o.data]),A=r.useMemo(()=>In(l),[l.data]),w=r.useMemo(()=>In(d),[d.data]),[b,m]=r.useState(null),[j,D]=r.useState(null),[R,k]=r.useState(null),[S,x]=r.useState(null),[f,_]=r.useState([]),[T,I]=r.useState("No"),[B,L]=r.useState("yes"),[y,P]=r.useState("no"),[O,$]=r.useState("Yes"),[U,N]=r.useState(""),[V,z]=r.useState(""),[E,M]=r.useState(null),[F,q]=r.useState(null),[H,re]=r.useState(null),[G,J]=r.useState(null),ae=()=>{const X=(()=>{try{const ce=c?.weekly_off;if(!ce)return[];const Re=Array.isArray(ce)?ce:JSON.parse(ce);return Array.isArray(Re)?Re.filter(Boolean).map(Ue=>({value:Ue,label:Ue})):[]}catch{return[]}})();_(X),m(u.find(ce=>ce?.value===c?.currency)??null),D(p.find(ce=>ce?.value===c?.country_code)??null),k(A.find(ce=>ce?.value===c?.time_zone)??null),x(w.find(ce=>ce?.value===c?.affliated_board_id)??null),N(c?.logo??""),z(c?.json_file??""),I(c?.attendance_salary_calculation??"No"),L(c?.salary_period??"yes"),P(c?.multiple_shift??"no"),$(c?.readmission_charges??"Yes"),M(g?.in_from?te(g.in_from,"h:mm A"):null),q(g?.in_to?te(g.in_to,"h:mm A"):null),re(g?.out_from?te(g.out_from,"h:mm A"):null),J(g?.out_to?te(g.out_to,"h:mm A"):null)};r.useEffect(()=>{c&&ae()},[c,u,p,A,w]);const oe=()=>{a.current?.reset?.(),ae()},pe=()=>{const X=new FormData(a.current??void 0),ce=Object.fromEntries(X.entries());ce.weekly_off_day=f.map(Ve=>Ve?.value).filter(Boolean);const Re=new Blob([JSON.stringify(ce,null,2)],{type:"application/json"}),Ue=URL.createObjectURL(Re),ke=document.createElement("a");ke.href=Ue,ke.download="organization-setting.json",ke.click(),URL.revokeObjectURL(Ue)},_e=r.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(ee.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:oe},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:pe,disabled:!c}],[c,f]),le=async X=>{X.preventDefault();try{const ce=new FormData(X.target);ce.set("currency",b?.value??""),ce.set("code",j?.value??""),ce.set("time_zone",R?.value??""),ce.set("affliated_board_id",S?.value??""),ce.set("board_name",S?.label??""),ce.set("attendance_salary_calculation",T),ce.set("salary_period",B),ce.set("multiple_shift",y),ce.set("readmission_charges",O),f.forEach(ke=>{ke?.value&&ce.append("weekly_off_day[]",ke.value)}),ce.set("logo",U??""),ce.set("json_file",V??""),ce.set("server_key",h?.server_key??""),ce.set("in_time_start",E?te(E).format("h:mm A"):""),ce.set("in_time_end",F?te(F).format("h:mm A"):""),ce.set("out_time_start",H?te(H).format("h:mm A"):""),ce.set("out_time_end",G?te(G).format("h:mm A"):""),await rn(Mt.save,ce,t);const Ue={...JSON.parse(localStorage.getItem("genrall_settings")??"null")??{},logo:U||c?.logo||"",affliated_board_id:S?.value??c?.affliated_board_id??"",board_name:S?.label??c?.board_name??"",multiple_shift:y??c?.multiple_shift??""};localStorage.setItem("genrall_settings",JSON.stringify(Ue)),v.success("Organization settings saved.",{duration:1e3}),s.mutate?.()}catch(ce){v.error(ce?.response?.data?.msg??ce?.message??"Failed to save settings.",{duration:1500})}},de=T==="Yes";return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:"Organization",actions:_e,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Organization Details"}),children:e.jsxs("form",{ref:a,onSubmit:le,children:[e.jsxs("div",{style:io,children:[e.jsx(Y,{type:"text",name:"name",label:"Organization Name*",required:!0,defaultValue:c?.name??""}),e.jsxs("div",{children:[e.jsx(Q,{label:"Currency*",options:u,value:b,onChange:X=>m(X)}),e.jsx("input",{type:"hidden",name:"currency",value:b?.value??""})]}),e.jsxs("div",{children:[e.jsx(Q,{label:"Default Country Code*",options:p,value:j,onChange:X=>D(X)}),e.jsx("input",{type:"hidden",name:"code",value:j?.value??""})]}),e.jsxs("div",{children:[e.jsx(Q,{label:"Time Zone*",options:A,value:R,onChange:X=>k(X)}),e.jsx("input",{type:"hidden",name:"time_zone",value:R?.value??""})]}),e.jsx(Y,{type:"text",name:"admission_prefix",label:"Receipt Prefix*",required:!0,defaultValue:c?.admission_prefix??""}),e.jsx(Y,{type:"number",name:"admission_start_number",label:"Admission Start Number*",required:!0,defaultValue:c?.admission_no_prefix??c?.admission_start_number??""}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Re-admission Charges"}),e.jsx(n.Radio.Group,{options:oo,optionType:"button",buttonStyle:"solid",value:O,onChange:X=>$(X.target.value)}),e.jsx("input",{type:"hidden",name:"readmission_charges",value:O})]}),e.jsxs("div",{children:[e.jsx(Q,{label:"Weekly off Day",options:Wg,isMulti:!0,value:f,onChange:X=>_(X??[])}),f.map(X=>e.jsx("input",{type:"hidden",name:"weekly_off_day[]",value:X.value},X.value))]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"In Time Start*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:E,onChange:X=>M(X),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_start",value:E?te(E).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"In Time End*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:F,onChange:X=>q(X),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"in_time_end",value:F?te(F).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Out Time Start*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:H,onChange:X=>re(X),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_start",value:H?te(H).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Out Time End*"}),e.jsx(n.TimePicker,{use12Hours:!0,format:"h:mm A",value:G,onChange:X=>J(X),style:{width:"100%"}}),e.jsx("input",{type:"hidden",name:"out_time_end",value:G?te(G).format("h:mm A"):""})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Salary Period"}),e.jsx(n.Radio.Group,{options:lo,optionType:"button",buttonStyle:"solid",value:B,onChange:X=>L(X.target.value)}),e.jsx("input",{type:"hidden",name:"salary_period",value:B})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Salary Deduction"}),e.jsx(n.Radio.Group,{options:oo,optionType:"button",buttonStyle:"solid",value:T,onChange:X=>I(X.target.value)}),e.jsx("input",{type:"hidden",name:"attendance_salary_calculation",value:T})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Multiple Shift"}),e.jsx(n.Radio.Group,{options:lo,optionType:"button",buttonStyle:"solid",value:y,onChange:X=>P(X.target.value)}),e.jsx("input",{type:"hidden",name:"multiple_shift",value:y})]}),de?e.jsx(Y,{type:"number",name:"late_absent_day",label:"No of Late",defaultValue:c?.late_absent_day??""}):e.jsx("input",{type:"hidden",name:"late_absent_day",value:""})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:io,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Logo Upload"}),e.jsx(ha,{token:t,action:xl(),value:U,accept:"image/*",onChange:X=>N(X)}),e.jsx("input",{type:"hidden",name:"logo",value:U??""})]}),e.jsxs("div",{children:[e.jsx(Q,{label:"Select Affiliated Board",options:w,value:S,onChange:X=>x(X)}),e.jsx("input",{type:"hidden",name:"affliated_board_id",value:S?.value??""}),e.jsx("input",{type:"hidden",name:"board_name",value:S?.label??""})]}),e.jsx(st,{label:"Address",name:"address",rows:3,defaultValue:c?.location_name??c?.address??""}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Json for Notification"}),e.jsx(ha,{token:t,action:Ng(),value:V,accept:".json",onChange:X=>z(X)}),e.jsx("input",{type:"hidden",name:"json_file",value:V??""})]})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save",color:"primary"})})]})})})]})}function Qg({token:t}){return e.jsx(Jg,{token:t})}const Wn=yt.academicYear,Xg=({token:t,page:a=1,perPage:s=10})=>gl({baseUrl:Wn.table,token:t,page:a,perPage:s}),Zg={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},ex=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[],tx=(t,a=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??a;function ax({token:t}){const[a,s]=r.useState({page:1,rowsPerPage:10}),[i,o]=r.useState(!1),[l,d]=r.useState(()=>{const f=te(),_=te().add(1,"year");return`${f.format("YYYY")}-${_.format("YYYY")}`}),[c,g]=r.useState(te()),[h,u]=r.useState(te().add(1,"year")),{isLoading:p,data:A,mutate:w}=Xg({token:t,page:a.page,perPage:a.rowsPerPage}),b=r.useMemo(()=>ex(A),[A]),m=r.useMemo(()=>tx(A,b.length),[A,b.length]),j=async()=>{if(!l){v.error("Session name is required.");return}if(h&&c&&te(h).isBefore(c)){v.error("End date must be after start date.");return}try{const f=new FormData;f.set("name",l),f.set("start_date",c?te(c).format("YYYY-MM-DD"):""),f.set("end_date",h?te(h).format("YYYY-MM-DD"):""),await rn(Wn.add,f,t),v.success("Academic year added.",{duration:1e3}),o(!1),w?.()}catch(f){v.error(f?.response?.data?.msg??f?.message??"Failed to add academic year.",{duration:1500})}},D=async f=>{try{const _=new FormData;_.set("session",String(f)),await fl(Wn.setActive,_,t);const T=JSON.parse(localStorage.getItem("genrall_settings")??"null")??{};localStorage.setItem("genrall_settings",JSON.stringify({...T,session_id:String(f)})),v.success("Academic year activated.",{duration:1e3}),w?.()}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed to activate academic year.",{duration:1500})}},R=async f=>{try{await w(pr(Wn.remove,f,t)),v.success("Academic year deleted.",{duration:1e3})}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed to delete academic year.",{duration:1500})}},k=()=>{const f=new Blob([JSON.stringify(b,null,2)],{type:"application/json"}),_=URL.createObjectURL(f),T=document.createElement("a");T.href=_,T.download="academic-years.json",T.click(),URL.revokeObjectURL(_)},S=r.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(ee.PlusOutlined,{}),onClick:()=>o(!0)},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:()=>w?.()},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:k,disabled:b.length===0}],[b.length,w]),x=r.useMemo(()=>[{title:"Name",dataIndex:"name",key:"name"},{title:"Start Date",dataIndex:"start_date",key:"start_date"},{title:"End Date",dataIndex:"end_date",key:"end_date"},{title:"Active",key:"active",render:(f,_)=>{const T=_.status==="Active";return e.jsxs("span",{children:[e.jsx(n.Popconfirm,{title:T?"Deactivate Academic Year?":"Activate Academic Year?",description:T?"Deactivate is not allowed. Activate another session to switch.":"This will set this year as the current academic session.",onConfirm:()=>{T?v.error("Deactivate is not allowed. Activate another session to switch."):D(_.id)},okText:"Yes",cancelText:"No",children:e.jsx(n.Switch,{checked:T})}),T&&e.jsx(n.Tag,{color:"green",style:{marginLeft:8},children:"Active"})]})}},{title:"Action",key:"action",render:(f,_)=>e.jsx(n.Popconfirm,{title:"Delete academic year?",description:"This will remove the session.",onConfirm:()=>R(_.id),okText:"Yes",cancelText:"No",children:e.jsx(n.Button,{type:"link",danger:!0,children:"Delete"})})}],[t,b.length]);return e.jsxs(e.Fragment,{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:"Academic Year",actions:S,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Sessions"}),children:e.jsx(n.Table,{rowKey:"id",dataSource:b,columns:x,loading:p,pagination:{current:a.page,pageSize:a.rowsPerPage,total:m,showSizeChanger:!0,onChange:(f,_)=>s({page:f,rowsPerPage:Number(_)})}})})}),e.jsx(n.Modal,{open:i,onCancel:()=>o(!1),footer:null,title:"Add Academic Year",children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:Zg,children:[e.jsx(Y,{label:"Session Name*",value:l,onChange:f=>d(f.target.value)}),e.jsxs("div",{children:[e.jsx(Me,{Desplay:"Start Date*",value:c,onChange:f=>g(f),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:c?te(c).format("YYYY-MM-DD"):""})]}),e.jsxs("div",{children:[e.jsx(Me,{Desplay:"End Date*",value:h,onChange:f=>u(f),format:"YYYY-MM-DD"}),e.jsx("input",{type:"hidden",value:h?te(h).format("YYYY-MM-DD"):""})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx(ne,{value:"Submit",type:"button",onClick:j}),e.jsx(n.Button,{onClick:()=>o(!1),children:"Cancel"})]})]})})]})}function nx({token:t}){return e.jsx(ax,{token:t})}const bl=yt.feeReceiptSetting,sx=({token:t})=>gt({url:bl.get,token:t}),Fs={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:16,alignItems:"start"},rx=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null;function ix({token:t}){const a=r.useRef(null),s=sx({token:t}),i=r.useMemo(()=>rx(s.data),[s.data]),[o,l]=r.useState(""),[d,c]=r.useState(!1),[g,h]=r.useState(!1),[u,p]=r.useState(!1),[A,w]=r.useState("0"),[b,m]=r.useState("0"),[j,D]=r.useState("0"),[R,k]=r.useState(!1),[S,x]=r.useState(!1),[f,_]=r.useState(""),[T,I]=r.useState(!1),B=()=>{l(i?.number_of_receipt??""),c(String(i?.roll_number??"0")==="1"),h(String(i?.address??"0")==="1"),p(String(i?.gardian_name??"0")==="1"),w(String(i?.authorized_signatory??"0")),m(String(i?.parent_signatory??"0")),D(String(i?.dynamic_qr_code_device??"0")),k(String(i?.sequence_payment??"0")==="1"),x(String(i?.previois_fees??"0")==="1"),_(i?.upfront_payment_months??"")};r.useEffect(()=>{i&&B()},[i]);const L=()=>{a.current?.reset?.(),B()},y=()=>{const $={number_of_receipt:o,rollnumber:d?1:0,address:g?1:0,gardianname:u?1:0,authorizedsignatory:A,parentsignatory:b,dynamic_qr_code_device:j,sequence_payment:R?1:0,previois_fees:S?1:0,upfront_payment_months:f},U=new Blob([JSON.stringify($,null,2)],{type:"application/json"}),N=URL.createObjectURL(U),V=document.createElement("a");V.href=N,V.download="fee-receipt-setting.json",V.click(),URL.revokeObjectURL(N)},P=r.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(ee.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:L},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:y,disabled:!i}],[i,o,d,g,u,A,b,j,R,S,f]),O=async $=>{$.preventDefault(),I(!0);try{const U=new FormData;U.set("number_of_receipt",String(o??"")),U.set("rollnumber",d?"1":"0"),U.set("address",g?"1":"0"),U.set("gardianname",u?"1":"0"),U.set("authorizedsignatory",String(A??"0")),U.set("parentsignatory",String(b??"0")),U.set("dynamic_qr_code_device",String(j??"0")),U.set("sequence_payment",R?"1":"0"),U.set("previois_fees",S?"1":"0"),U.set("upfront_payment_months",String(f??"")),await rn(bl.save,U,t),v.success("Fee receipt settings updated.",{duration:1e3}),s.mutate?.()}catch(U){v.error(U?.response?.data?.msg??U?.message??"Failed to update settings.",{duration:1500})}finally{I(!1)}};return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:"Fee Receipt Setting",actions:P,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Settings Form"}),children:e.jsxs("form",{ref:a,onSubmit:O,children:[e.jsxs("div",{style:Fs,children:[e.jsx(Y,{type:"number",name:"number_of_receipt",label:"Number Of Receipt",value:o,onChange:$=>l($.target.value)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Roll Number"}),e.jsx(n.Checkbox,{checked:d,onChange:$=>c($.target.checked),children:"Show Roll Number in Fees Receipt"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Address"}),e.jsx(n.Checkbox,{checked:g,onChange:$=>h($.target.checked),children:"Show address in Fees Receipt"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Guardian Name"}),e.jsx(n.Checkbox,{checked:u,onChange:$=>p($.target.checked),children:"Show Guardian Name in Fees Receipt"})]})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:Fs,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Authorized Signatory"}),e.jsxs(n.Radio.Group,{value:A,onChange:$=>w($.target.value),children:[e.jsx(n.Radio,{value:"1",children:"Enable"}),e.jsx(n.Radio,{value:"0",children:"Disable"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Parent Signatory"}),e.jsxs(n.Radio.Group,{value:b,onChange:$=>m($.target.value),children:[e.jsx(n.Radio,{value:"1",children:"Enable"}),e.jsx(n.Radio,{value:"0",children:"Disable"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Dynamic QR Code Device"}),e.jsxs(n.Radio.Group,{value:j,onChange:$=>D($.target.value),children:[e.jsx(n.Radio,{value:"1",children:"Enable"}),e.jsx(n.Radio,{value:"0",children:"Disable"})]})]})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:Fs,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Sequence Payment"}),e.jsx(n.Checkbox,{checked:R,onChange:$=>k($.target.checked),children:"Student can pay in sequence"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Previous Fees"}),e.jsx(n.Checkbox,{checked:S,onChange:$=>x($.target.checked),children:"Previous Fees Carry Over to Next Year"})]}),e.jsx(Y,{type:"number",name:"upfront_payment_months",label:"Max Advance Payment (Months)",value:f,onChange:$=>_($.target.value)})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:T?"Updating...":"Done",disabled:T})})]})})})]})}function ox({token:t}){return e.jsx(ix,{token:t})}const Va=yt.marksheetSetting,lx=({token:t})=>gt({url:Va.templateTypes,token:t}),dx=({token:t})=>gt({url:Va.classDropdown,token:t}),cx=({token:t})=>gt({url:Va.assignedTable,token:t}),ux={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))",gap:20,alignItems:"end"},co=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t?.data?.data?.data)?t.data.data.data:[]:[],px=Array.from({length:12},(t,a)=>({value:String(a+1),label:`Design ${a+1}`})),mx=t=>t?Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:Array.isArray(t)?t:[]:[];function hx({token:t}){const a=r.useRef(null),s=lx({token:t}),i=dx({token:t}),o=cx({token:t}),l=r.useMemo(()=>co(s.data),[s.data]),d=r.useMemo(()=>co(i.data),[i.data]),c=r.useMemo(()=>mx(o.data),[o.data]),[g,h]=r.useState(null),[u,p]=r.useState(null),[A,w]=r.useState([]),b=()=>{a.current?.reset?.(),h(null),p(null),w([])},m=()=>{const S=new Blob([JSON.stringify(c,null,2)],{type:"application/json"}),x=URL.createObjectURL(S),f=document.createElement("a");f.href=x,f.download="marksheet-templates.json",f.click(),URL.revokeObjectURL(x)},j=r.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:b},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:m,disabled:c.length===0}],[c.length]),D=async S=>{if(S.preventDefault(),!g?.value){v.error("Select marksheet type.",{duration:1200});return}if(!u?.value){v.error("Select design.",{duration:1200});return}if(!A?.length){v.error("Select at least one class.",{duration:1200});return}try{const x=new FormData;x.set("temp_id",String(g.value)),x.set("ui_id",String(u.value)),A.forEach(f=>x.append("class_id[]",String(f))),await rn(Va.assign,x,t),v.success("Marksheet template assigned.",{duration:1e3}),o.mutate?.(),b()}catch(x){v.error(x?.response?.data?.msg??x?.message??"Failed to assign template.",{duration:1500})}},R=async S=>{try{await pr(Va.remove,S,t),v.success("Template removed.",{duration:1e3}),o.mutate?.()}catch(x){v.error(x?.response?.data?.msg??x?.message??"Failed to remove template.",{duration:1500})}},k=r.useMemo(()=>[{title:"Class",dataIndex:"class",key:"class"},{title:"Template Name",dataIndex:"name",key:"name"},{title:"Template Design",dataIndex:"ui_id",key:"ui_id"},{title:"Action",key:"action",render:(S,x)=>e.jsx(mt,{id:x?.id,funcName:R})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:"Marksheet Setting",actions:j,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))"},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Assign Template"}),children:e.jsxs("form",{ref:a,onSubmit:D,children:[e.jsxs("div",{style:ux,children:[e.jsxs("div",{children:[e.jsx(Q,{label:"Select Marksheet Type",options:l,value:g,onChange:S=>h(S)}),e.jsx("input",{type:"hidden",name:"temp_id",value:g?.value??""})]}),e.jsxs("div",{children:[e.jsx(Q,{label:"Select Design",options:px,value:u,onChange:S=>p(S)}),e.jsx("input",{type:"hidden",name:"ui_id",value:u?.value??""})]})]}),e.jsx(n.Divider,{}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:8},children:"Class"}),e.jsx(n.Checkbox.Group,{options:d,value:A,onChange:S=>w(S)})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save"})})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Marksheet List"}),children:e.jsx(n.Table,{size:"small",rowKey:"id",columns:k,dataSource:c,pagination:!1})})]})})]})}function fx({token:t}){return e.jsx(hx,{token:t})}const Us={fetch:`${yt.legalPages.get}?page_name=terms`,save:yt.legalPages.termsSave,fieldName:"terms_data"};function yx({token:t}){return e.jsx(mr,{token:t,title:"Terms",fetchUrl:Us.fetch,saveUrl:Us.save,fieldName:Us.fieldName})}function gx({token:t}){return e.jsx(yx,{token:t})}const $s={fetch:`${yt.legalPages.get}?page_name=privacy`,save:yt.legalPages.privacySave,fieldName:"privacy_data"};function xx({token:t}){return e.jsx(mr,{token:t,title:"Privacy",fetchUrl:$s.fetch,saveUrl:$s.save,fieldName:$s.fieldName})}function bx({token:t}){return e.jsx(xx,{token:t})}const Ns={fetch:`${yt.legalPages.get}?page_name=about_us`,save:yt.legalPages.aboutSave,fieldName:"about_data"};function jx({token:t}){return e.jsx(mr,{token:t,title:"About",fetchUrl:Ns.fetch,saveUrl:Ns.save,fieldName:Ns.fieldName})}function Sx({token:t}){return e.jsx(jx,{token:t})}const hr=yt.feesInfo,wx=({token:t})=>gt({url:hr.get,token:t}),vx=({token:t})=>gt({url:hr.statesDropdown,token:t}),Ls={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},_x=t=>t?Array.isArray(t?.data)?t.data[0]??null:Array.isArray(t?.data?.data)?t.data.data[0]??null:Array.isArray(t)?t[0]??null:t?.data?.data?.[0]??null:null,Cx=t=>t?Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[]:[],Ax=t=>t?hl(`branch/logo/${t}`):"",Bs=t=>t?hl(`branch/signature/${t}`):"";function Dx({token:t}){const a=r.useRef(null),s=wx({token:t}),i=vx({token:t}),o=r.useMemo(()=>_x(s.data),[s.data]),l=r.useMemo(()=>Cx(i.data),[i.data]),[d,c]=r.useState(null),[g,h]=r.useState(""),[u,p]=r.useState(""),[A,w]=r.useState(""),[b,m]=r.useState(""),j=f=>{const _=new FormData(f),T=Object.fromEntries(_.entries());return T.state_id=d?.value??"",T.fees_receipt_logo=g,T.manager_signature=u,T.principal_signature=A,T.stamp=b,T},D=()=>{c(l.find(f=>String(f?.value)===String(o?.state_id??""))??null),h(o?.fees_receipt_logo??""),p(o?.manager_signature??""),w(o?.principal_signature??""),m(o?.stamp??"")};r.useEffect(()=>{o&&D()},[o,l]);const R=()=>{a.current?.reset?.(),D()},k=()=>{const f=j(a.current),_=new Blob([JSON.stringify(f,null,2)],{type:"application/json"}),T=URL.createObjectURL(_),I=document.createElement("a");I.href=T,I.download="fees-info.json",I.click(),URL.revokeObjectURL(T)},S=r.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(ee.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:R},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:k,disabled:!o}],[o,d,g,u,A,b]),x=async f=>{f.preventDefault();try{const _=j(f.target);await Og(hr.save,_,t),v.success("Fees info saved.",{duration:1e3}),s.mutate?.()}catch(_){v.error(_?.response?.data?.msg??_?.message??"Failed to save fees info.",{duration:1500})}};return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:"Fees Info",actions:S,children:e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"School Information"}),children:e.jsxs("form",{ref:a,onSubmit:x,children:[e.jsxs("div",{style:Ls,children:[e.jsx(Y,{name:"Bussiness_name",label:"Business Name*",defaultValue:o?.name??"",required:!0}),e.jsx(Y,{name:"cin",label:"Sub Heading",defaultValue:o?.cin??""}),e.jsx(Y,{name:"school_no",type:"number",label:"School Number",defaultValue:o?.school_no??""}),e.jsx(Y,{name:"website",label:"Website",defaultValue:o?.website??""}),e.jsx(Y,{name:"school_Code",label:"School Code",defaultValue:o?.school_Code??""}),e.jsx(Y,{name:"offical_number",label:"Official Number",defaultValue:o?.offical_number??""}),e.jsx(Y,{name:"email_id",label:"Email",defaultValue:o?.email_id??""}),e.jsx(Y,{name:"receipt_prefix",label:"Receipt Prefix",defaultValue:o?.receipt_prefix??""}),e.jsx(Y,{name:"recipt_start_number",type:"number",label:"Receipt Start Number",defaultValue:o?.recipt_start_number??""}),e.jsxs("div",{children:[e.jsx(Q,{label:"State",options:l,value:d,onChange:c}),e.jsx("input",{type:"hidden",name:"state_id",value:d?.value??""})]}),e.jsx(Y,{name:"affiliation_no",label:"Affiliation Number",defaultValue:o?.affiliation_no??""}),e.jsx(Y,{name:"affiliation_desc",label:"Affiliation Description",defaultValue:o?.affiliation_desc??""}),e.jsx(Y,{name:"udise_code",label:"UDISE Code",defaultValue:o?.udise_code??""}),e.jsx(Y,{name:"color_code",label:"Primary Color",defaultValue:o?.color_code??""}),e.jsx(Y,{name:"fontcolor_code",label:"Font Color",defaultValue:o?.fontcolor_code??""})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:Ls,children:[e.jsx(st,{name:"Bussiness_address",rows:3,label:"Business Address",defaultValue:o?.Bussiness_address??o?.bussiness_address??""}),e.jsx(st,{name:"note",rows:3,label:"Note",defaultValue:o?.note??""})]}),e.jsx(n.Divider,{}),e.jsxs("div",{style:Ls,children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Fees Receipt Logo"}),e.jsx(ha,{token:t,action:xl(),value:g,previewUrl:Ax(g),accept:"image/*",onChange:h}),e.jsx("input",{type:"hidden",name:"fees_receipt_logo",value:g})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Manager Signature"}),e.jsx(ha,{token:t,action:Es(),value:u,previewUrl:Bs(u),accept:"image/*",onChange:p}),e.jsx("input",{type:"hidden",name:"manager_signature",value:u})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Principal Signature"}),e.jsx(ha,{token:t,action:Es(),value:A,previewUrl:Bs(A),accept:"image/*",onChange:w}),e.jsx("input",{type:"hidden",name:"principal_signature",value:A})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:"Stamp"}),e.jsx(ha,{token:t,action:Es(),value:b,previewUrl:Bs(b),accept:"image/*",onChange:m}),e.jsx("input",{type:"hidden",name:"stamp",value:b})]})]}),e.jsx(n.Divider,{}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save"})})]})})})]})}function Tx({token:t}){return e.jsx(Dx,{token:t})}const Hn=yt.payrollSettings,Rx=({token:t,page:a=1,perPage:s=10})=>gl({baseUrl:Hn.table,token:t,page:a,perPage:s}),Ix={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:20,alignItems:"end"},$a=[{value:"Allowances",label:"Allowances"},{value:"Dedection",label:"Dedection"}],qs=[{value:"Flat",label:"Flat"},{value:"Percentage",label:"Percentage"}],kx=t=>Array.isArray(t)?t:Array.isArray(t?.data)?t.data:Array.isArray(t?.data?.data)?t.data.data:[],Px=(t,a=0)=>t?.pagination?.total_rows??t?.data?.pagination?.total_rows??t?.data?.data?.pagination?.total_rows??a;function Ox({token:t}){const a=r.useRef(null),s=r.useRef(null),[i,o]=r.useState({page:1,rowsPerPage:10}),[l,d]=r.useState(!1),[c,g]=r.useState(null),[h,u]=r.useState($a[0]),[p,A]=r.useState(null),[w,b]=r.useState(null),[m,j]=r.useState(null),D=Rx({token:t,page:i.page,perPage:i.rowsPerPage}),R=r.useMemo(()=>kx(D.data),[D.data]),k=r.useMemo(()=>Px(D.data,R.length),[D.data,R.length]),S=async L=>{L.preventDefault();try{const y=new FormData(L.target);y.set("type",h?.value??""),y.set("amount_type",p?.value??""),await rn(Hn.add,y,t),v.success("Payroll setting added.",{duration:1e3}),D.mutate?.(),L.target.reset(),A(null),u($a[0])}catch(y){v.error(y?.response?.data?.msg??y?.message??"Failed to add payroll setting.",{duration:1500})}},x=L=>{g(L),b($a.find(y=>y.value===L?.type)??null),j(qs.find(y=>y.value===L?.amount_type)??null),d(!0)},f=async L=>{L.preventDefault();try{const y=new FormData(L.target);y.set("id",String(c?.id??"")),y.set("type",w?.value??""),y.set("amount_type",m?.value??""),await fl(Hn.edit,y,t),v.success("Payroll setting updated.",{duration:1e3}),d(!1),D.mutate?.()}catch(y){v.error(y?.response?.data?.msg??y?.message??"Failed to update payroll setting.",{duration:1500})}},_=async L=>{try{await pr(Hn.remove,L,t),v.success("Payroll setting deleted.",{duration:1e3}),D.mutate?.()}catch(y){v.error(y?.response?.data?.msg??y?.message??"Failed to delete payroll setting.",{duration:1500})}},T=()=>{const L=new Blob([JSON.stringify(R,null,2)],{type:"application/json"}),y=URL.createObjectURL(L),P=document.createElement("a");P.href=y,P.download="payroll-settings.json",P.click(),URL.revokeObjectURL(y)},I=r.useMemo(()=>[{key:"add",label:"Add",icon:e.jsx(ee.PlusOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:()=>D.mutate?.()},{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:T,disabled:R.length===0}],[R.length]),B=r.useMemo(()=>[{title:"Title",dataIndex:"title",key:"title"},{title:"Type",dataIndex:"type",key:"type"},{title:"Amount Type",dataIndex:"amount_type",key:"amount_type"},{title:"Amount",dataIndex:"Amount",key:"Amount"},{title:"Action",key:"action",render:(L,y)=>e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(n.Button,{type:"text",icon:e.jsx(ee.EditOutlined,{}),onClick:()=>x(y)}),e.jsx(n.Popconfirm,{title:"Delete payroll setting?",onConfirm:()=>_(y.id),children:e.jsx(n.Button,{type:"text",danger:!0,icon:e.jsx(ee.DeleteOutlined,{})})})]})}],[t]);return e.jsxs(e.Fragment,{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:"Payroll Settings",actions:I,children:e.jsxs("div",{style:{display:"grid",gap:20,gridTemplateColumns:"minmax(320px, 420px) 1fr"},children:[e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Add Allowances / Deductions"}),children:e.jsxs("form",{ref:a,onSubmit:S,children:[e.jsxs("div",{style:Ix,children:[e.jsx(Y,{name:"title",label:"Title",required:!0}),e.jsxs("div",{children:[e.jsx(Q,{label:"Type",options:$a,value:h,onChange:u}),e.jsx("input",{type:"hidden",name:"type",value:h?.value??""})]}),e.jsxs("div",{children:[e.jsx(Q,{label:"Amount Type",options:qs,value:p,onChange:A}),e.jsx("input",{type:"hidden",name:"amount_type",value:p?.value??""})]}),e.jsx(Y,{name:"Amount",type:"number",label:"Amount",required:!0})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:20},children:e.jsx(ne,{type:"submit",value:"Submit"})})]})}),e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:"Payroll Settings List"}),children:e.jsx(n.Table,{rowKey:"id",columns:B,dataSource:R,loading:D.isLoading,pagination:{current:i.page,pageSize:i.rowsPerPage,total:k,showSizeChanger:!0,onChange:(L,y)=>o({page:L,rowsPerPage:Number(y)})}})})]})}),e.jsx(n.Drawer,{open:l,onClose:()=>d(!1),title:"Edit Payroll Setting",width:420,children:e.jsx("form",{ref:s,onSubmit:f,children:e.jsxs("div",{style:{display:"grid",gap:20},children:[e.jsx(Y,{name:"title",label:"Title",required:!0,defaultValue:c?.title??""}),e.jsxs("div",{children:[e.jsx(Q,{label:"Type",options:$a,value:w,onChange:b}),e.jsx("input",{type:"hidden",name:"type",value:w?.value??""})]}),e.jsxs("div",{children:[e.jsx(Q,{label:"Amount Type",options:qs,value:m,onChange:j}),e.jsx("input",{type:"hidden",name:"amount_type",value:m?.value??""})]}),e.jsx(Y,{name:"Amount",type:"number",label:"Amount",required:!0,defaultValue:c?.Amount??""}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Update"})})]})})})]})}function Mx({token:t}){return e.jsx(Ox,{token:t})}const jl=yt.paymentGateway,Ex=({token:t})=>gt({url:jl.get,token:t}),Fx=[{id:"Razorpay",title:"Razorpay",fields:["keyId","keySecret"]},{id:"PhonePe",title:"Pine Labs",fields:["merchantId","saltKey","saltIndex"]},{id:"Paytm",title:"HDFC",fields:["merchantId","merchantKey"]},{id:"SabPaisa",title:"SabPaisa",fields:["clientCode","transUserName","transUserPassword","authKey","authIV"]}],Wt={Razorpay:{keyId:"",keySecret:"",isActive:!0},PhonePe:{merchantId:"",saltKey:"",saltIndex:"1",isActive:!1},Paytm:{merchantId:"",merchantKey:"",isActive:!1},SabPaisa:{clientCode:"",transUserName:"",transUserPassword:"",authKey:"",authIV:"",isActive:!1}},uo=t=>{const a=Array.isArray(t?.data)&&t.data[0]||Array.isArray(t?.data?.data)&&t.data.data[0]||Array.isArray(t)&&t[0]||null;if(!a?.data)return Wt;try{const s=JSON.parse(a.data||"{}"),i=s?.data&&typeof s.data=="object"?s.data:s;return{Razorpay:{...Wt.Razorpay,...i?.Razorpay??{}},PhonePe:{...Wt.PhonePe,...i?.PhonePe??i?.PineLab??i?.PineLabs??{}},Paytm:{...Wt.Paytm,...i?.Paytm??i?.HDFC??{}},SabPaisa:{...Wt.SabPaisa,...i?.SabPaisa??{}}}}catch{return Wt}};function Ux({token:t}){const a=r.useRef(null),s=Ex({token:t}),[i,o]=r.useState(Wt);r.useEffect(()=>{s.data&&o(uo(s.data))},[s.data]);const l=(u,p,A)=>{o(w=>({...w,[u]:{...w[u],[p]:A}}))},d=()=>o(uo(s.data)),c=()=>{const u=new Blob([JSON.stringify(i,null,2)],{type:"application/json"}),p=URL.createObjectURL(u),A=document.createElement("a");A.href=p,A.download="payment-gateway-settings.json",A.click(),URL.revokeObjectURL(p)},g=r.useMemo(()=>[{key:"save",label:"Save",icon:e.jsx(ee.SaveOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"update",label:"Update",icon:e.jsx(ee.SyncOutlined,{}),onClick:()=>a.current?.requestSubmit?.()},{key:"reset",label:"Reset",icon:e.jsx(ee.ReloadOutlined,{}),onClick:d},{key:"export",label:"Export",icon:e.jsx(ee.ExportOutlined,{}),onClick:c}],[i,s.data]),h=async u=>{u.preventDefault();try{await yl(jl.save,{data:i},t),v.success("Payment gateway settings saved.",{duration:1e3}),s.mutate?.()}catch(p){v.error(p?.response?.data?.msg??p?.message??"Failed to save gateway settings.",{duration:1500})}};return s.isLoading&&!s.data?e.jsx("div",{children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsx(v.Toaster,{toastOptions:{position:"top-center"}}),e.jsx(Vt,{title:"Payment Gateway",actions:g,children:e.jsxs("form",{ref:a,onSubmit:h,style:{display:"grid",gap:20},children:[Fx.map(u=>{const p=i[u.id]??{};return e.jsx(n.Card,{title:e.jsx(n.Typography.Title,{level:5,style:{margin:0},children:u.title}),children:e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("span",{style:{fontSize:14,fontWeight:500},children:["Enable ",u.title]}),e.jsx(n.Switch,{checked:!!p.isActive,onChange:A=>l(u.id,"isActive",A)})]}),e.jsx(n.Divider,{style:{margin:0}}),e.jsx("div",{style:{display:"grid",gap:16,gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))"},children:u.fields.map(A=>e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#222",marginBottom:6},children:A}),e.jsx(n.Input,{value:p[A]??"",type:A.toLowerCase().includes("secret")||A.toLowerCase().includes("password")?"password":"text",onChange:w=>l(u.id,A,w.target.value)})]},A))})]})},u.id)}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(ne,{type:"submit",value:"Save"})})]})})]})}function $x({token:t}){return e.jsx(Ux,{token:t})}const Nx=({routes:t=[],onNavigate:a})=>e.jsx(n.Row,{gutter:[16,16],children:t.map((s,i)=>e.jsx(n.Col,{xs:24,md:8,lg:8,children:e.jsx(C,{children:e.jsx(ho,{icon:s?.icon??"",title:s?.title??"",path:s?.path??"",onClick:a})})},`${i}route001`))});exports.About=Sx;exports.AcademicYear=nx;exports.Academics=hy;exports.AddBook=Jp;exports.AddDriver=qp;exports.AddExpense=sy;exports.AddHomework=Hp;exports.AddIncome=Xf;exports.AddStaff=fh;exports.AdmissionEnquiry=Au;exports.ApplyLeave=Zh;exports.AprroveLeaveRequest=Wh;exports.AssignByClass=By;exports.AssignStudentSubject=uy;exports.AssignStudentToTransport=Bp;exports.AssignSubjects=$y;exports.AssignTimeGroup=Gy;exports.AssignVehicles=Pp;exports.AttendanceDashboard=Ff;exports.BookList=Qp;exports.BulkUpload=my;exports.BuySellProduct=Mm;exports.Category=vm;exports.Class=Ay;exports.CoScholasticArea=ng;exports.Complain=_p;exports.CreateTimeGroup=Yy;exports.DailyAttendance=Bf;exports.Department=rf;exports.Designation=df;exports.ErpDashboard=_l;exports.ExpenseHead=oy;exports.FeeReceiptSetting=ox;exports.FeesInfo=Tx;exports.GatePass=Tp;exports.GeneralSetting=Rg;exports.Holidays=My;exports.IncomeHead=ty;exports.IssueReturn=Zp;exports.LeaveType=af;exports.LibraryAssignStudent=em;exports.LibraryCategory=tm;exports.LibraryRenewalReport=nm;exports.LibraryReport=am;exports.ManageStock=Hm;exports.MarksheetSetting=fx;exports.MedicalReport=dy;exports.MenuSubmenu=lu;exports.MonthlyReport=Yf;exports.Notes=lg;exports.NpmReport=Zm;exports.Organization=Qg;exports.PaymentGateway=$x;exports.Payroll=Bh;exports.PayrollReceiptDetails=jf;exports.PayrollSettings=Mx;exports.PhoneCallLog=ap;exports.PostalDispatch=lp;exports.PostalReceive=hp;exports.Privacy=bx;exports.Products=bm;exports.PromoteStudents=Zy;exports.RoutePage=Nx;exports.RouteTimeTable=zp;exports.SearchExpense=ry;exports.SearchIncome=Zf;exports.Sections=Sy;exports.SellReports=Ym;exports.SetupFrontOffice=Cp;exports.Shift=pf;exports.StaffAttendance=Ph;exports.StaffAttendanceReport=Fh;exports.StaffDailyAttendance=gf;exports.StaffDirectory=jh;exports.StockReport=Xm;exports.Stoppage=Vp;exports.StudentAttendance=$f;exports.StudentLoginCredential=ly;exports.SubCategory=Rm;exports.Subjects=Iy;exports.SubmissionDetails=Kp;exports.Syllabus=gg;exports.Terms=gx;exports.TimeTable=Tg;exports.TransferCertificate=mg;exports.TransportBulkUpload=Wp;exports.TransportRoutes=Rp;exports.TransportVehicles=Ip;exports.Unit=$m;exports.Vendor=um;exports.VisitorBook=Hu;exports.YearlyReport=Kf;exports.setBaseUrl=oc;
|